mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 21:34:24 +00:00
start pages settings (BROKEN)
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
const db = require( '../../backend/db/db.js' );
|
||||
const pm = require( '../../backend/plugins/manager.js' );
|
||||
const spm = require( '../startPageManager.js' );
|
||||
const startPageManager = new spm();
|
||||
|
||||
class GETHandler {
|
||||
constructor ( settings ) {
|
||||
@@ -112,6 +114,10 @@ class GETHandler {
|
||||
resolve( this.settings );
|
||||
} else if ( call === 'getAllPlugins' ) {
|
||||
resolve( this.pluginManager.getPlugins() );
|
||||
} else if ( call === 'getStartPageSettings' ) {
|
||||
resolve( startPageManager.loadStartPagePreferences( query.name ) );
|
||||
} else if ( call === 'getAllStartPages' ) {
|
||||
resolve( startPageManager.findAllStartPageTemplates() );
|
||||
} else {
|
||||
reject( { 'code': 404, 'error': 'Route not found' } );
|
||||
}
|
||||
|
||||
@@ -25,6 +25,10 @@ class StartPageManager {
|
||||
return JSON.parse( fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.html' ) ) );
|
||||
}
|
||||
|
||||
findAllStartPageTemplates() {
|
||||
return fs.readdirSync( path.join( __dirname + '/../ui/home/templates/' ) );
|
||||
}
|
||||
|
||||
setActiveStartPage( startPageName ) {
|
||||
this.settings[ 'startPage' ] = startPageName;
|
||||
fs.writeFileSync( path.join( __dirname + '/../config/settings.config.json' ), JSON.stringify( this.settings ) );
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>Pages</h2>
|
||||
<p>Here you can modify your landing page (the start page of libreǝvent) and other pages</p>
|
||||
<p>Here you can modify your landing page (the start page of libreǝvent)</p>
|
||||
<select name="templateSel" id="templateSel" v-bind="selectedTemplate">
|
||||
<option v-for="el in startPageTemplates" :value="el">{{ el }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -18,13 +21,44 @@
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
formData: {}
|
||||
startPageTemplates: [],
|
||||
startPageSettings: {},
|
||||
selectedTemplate: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setup () {
|
||||
|
||||
loadPageSettings() {
|
||||
fetch( '/admin/getAPI/getStartPageSettings?name=' + this.selectedTemplate ).then( res => {
|
||||
if ( res.status === 200 ) {
|
||||
res.json().then( json => {
|
||||
this.startPageSettings = json;
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selectedTemplate( value ) {
|
||||
this.loadPageSettings();
|
||||
}
|
||||
},
|
||||
created () {
|
||||
fetch( '/admin/getAPI/getAllStartPages' ).then( res => {
|
||||
if ( res.status === 200 ) {
|
||||
res.json().then( json => {
|
||||
this.startPageTemplates = json;
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
fetch( '/admin/getAPI/getSettings' ).then( res => {
|
||||
if ( res.status === 200 ) {
|
||||
res.json().then( json => {
|
||||
console.log( json[ 'startPage' ] );
|
||||
this.selectedTemplate = json[ 'startPage' ];
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user