From cc57a8b80a90d26140af563822d7306790814932 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Tue, 5 Sep 2023 13:15:36 +0200 Subject: [PATCH] add startPage settings files --- src/server/admin/startPageManager.js | 4 +-- .../templates/default/startPage.config.json | 5 +++ .../ui/home/templates/default/startPage.json | 31 +++++++++++++++++++ .../main/src/views/admin/EventsView.vue | 6 ++-- src/webapp/main/src/views/admin/PagesView.vue | 12 ++++--- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/server/admin/startPageManager.js b/src/server/admin/startPageManager.js index a5ed678..802548d 100644 --- a/src/server/admin/startPageManager.js +++ b/src/server/admin/startPageManager.js @@ -24,8 +24,8 @@ class StartPageManager { loadStartPagePreferences( startPageName ) { let conf, options; try { - conf = JSON.parse( fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.json' ) ) ); - options = JSON.parse( fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.json' ) ) ); + options = JSON.parse( fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.json' ) ) ); + conf = JSON.parse( fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.json' ) ) ); return { 'conf': conf, 'options': options }; } catch ( err ) { return {}; diff --git a/src/server/ui/home/templates/default/startPage.config.json b/src/server/ui/home/templates/default/startPage.config.json index e69de29..6f861d4 100644 --- a/src/server/ui/home/templates/default/startPage.config.json +++ b/src/server/ui/home/templates/default/startPage.config.json @@ -0,0 +1,5 @@ +{ + "subtitle": "this is a test", + "description": "this is a test description", + "banner": "homeBanner.jpg" +} \ No newline at end of file diff --git a/src/server/ui/home/templates/default/startPage.json b/src/server/ui/home/templates/default/startPage.json index e69de29..08b5c50 100644 --- a/src/server/ui/home/templates/default/startPage.json +++ b/src/server/ui/home/templates/default/startPage.json @@ -0,0 +1,31 @@ +{ + "subtitle": { + "id": "subtitle", + "type": "text", + "display": "Subtitle", + "can-be-empty": false + }, + "description": { + "id": "description", + "type": "textarea", + "display": "Description", + "textarea-settings": { + "resize-y": true, + "resize-x": false, + "max-length": 0, + "min-length": 100 + }, + "can-be-empty": false + }, + "banner": { + "id": "banner", + "type": "image", + "display": "Banner", + "image-settings": { + "upload-name": "homeBanner", + "accept-filetype": "image/jpeg", + "height": 200, + "width": 350 + } + } +} \ No newline at end of file diff --git a/src/webapp/main/src/views/admin/EventsView.vue b/src/webapp/main/src/views/admin/EventsView.vue index 426eee4..a841abb 100644 --- a/src/webapp/main/src/views/admin/EventsView.vue +++ b/src/webapp/main/src/views/admin/EventsView.vue @@ -21,7 +21,7 @@

{{ event.description }}

{{ event.date }} - +
@@ -29,7 +29,7 @@

{{ event.description }}

{{ event.date }}
- +
@@ -107,7 +107,7 @@ }, data () { return { - events: { 'test':{ 'name': 'TestEvent', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-08-15', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test', 'currency': 'CHF', 'logo': new URL( '/src/assets/logo.png', import.meta.url ).href }, 'test2':{ 'name': 'TestEvent2', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-06-13', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test2', 'currency': 'CHF', 'logo': new URL( '/src/assets/logo.png', import.meta.url ).href } }, + events: { 'test':{ 'name': 'TestEvent', 'description': 'This is a description for the TestEvent to test multiline support and proper positioning of the Fields', 'freeSeats': 2, 'maxSeats': 2, 'date':'2023-08-15', 'startingPrice':15, 'location': 'TestLocation', 'eventID': 'test', 'currency': 'CHF', 'logo': new URL( '/assets/logo.png', import.meta.url ).href } }, currentDate: new Date().getTime(), eventList: { 'upcoming': { 'name': 'Upcoming', 'content': {} }, 'past': { 'name': 'Past', 'content': {} }, 'drafts': { 'name': 'Drafts', 'content': {} } }, currentlyOpenMenu: '', diff --git a/src/webapp/main/src/views/admin/PagesView.vue b/src/webapp/main/src/views/admin/PagesView.vue index cce3221..5f30f9a 100644 --- a/src/webapp/main/src/views/admin/PagesView.vue +++ b/src/webapp/main/src/views/admin/PagesView.vue @@ -16,7 +16,9 @@
- +
+ {{ setting }} +
@@ -35,8 +37,10 @@ fetch( '/admin/getAPI/getStartPageSettings?name=' + this.selectedTemplate ).then( res => { if ( res.status === 200 ) { res.json().then( json => { - this.startPageSettings = json; - console.log( json ); + this.startPageSettings = json[ 'options' ]; + for ( let option in this.startPageSettings ) { + this.startPageSettings[ option ][ 'value' ] = json[ 'conf' ][ option ]; + } } ); } } ); @@ -59,7 +63,7 @@ fetch( '/admin/getAPI/getSettings' ).then( res => { if ( res.status === 200 ) { res.json().then( json => { - this.selectedTemplate = String( json[ 'startPage' ] ); + this.selectedTemplate = json[ 'startPage' ]; } ); } } );