start pages settings (BROKEN)

This commit is contained in:
janis
2023-09-04 17:05:58 +02:00
parent bebf53e5eb
commit a52ec14845
5 changed files with 48 additions and 4 deletions

View File

@@ -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' } );
}

View File

@@ -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 ) );

View File

@@ -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>