add start page settings

This commit is contained in:
2023-09-05 17:42:39 +02:00
parent cc57a8b80a
commit adf0133cd3
20 changed files with 345 additions and 33 deletions

View File

@@ -10,12 +10,12 @@
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 ) {
this.pluginManager = new pm( settings );
this.settings = settings;
this.startPageManager = new spm( settings );
}
handleCall ( call, query ) {
@@ -115,9 +115,17 @@ class GETHandler {
} else if ( call === 'getAllPlugins' ) {
resolve( this.pluginManager.getPlugins() );
} else if ( call === 'getStartPageSettings' ) {
resolve( startPageManager.loadStartPagePreferences( query.name ) );
resolve( this.startPageManager.loadStartPagePreferences( query.name ) );
} else if ( call === 'getAllStartPages' ) {
resolve( startPageManager.findAllStartPageTemplates() );
resolve( this.startPageManager.findAllStartPageTemplates() );
} else if ( call === 'buildStartPage' ) {
( async() => {
if ( await this.startPageManager.renderStartPage( query.page ) ) {
resolve( 'ok' );
} else {
reject( { 'code': 412, 'error': 'Missing entries' } );
}
} )();
} else {
reject( { 'code': 404, 'error': 'Route not found' } );
}

View File

@@ -12,6 +12,8 @@ const pwdmanager = require( '../pwdmanager.js' );
const fs = require( 'fs' );
const path = require( 'path' );
const pm = require( '../../backend/plugins/manager.js' );
const spm = require( '../startPageManager.js' );
const startPageManager = new spm();
const letters = [ ',', '{' ];
@@ -178,6 +180,9 @@ class POSTHandler {
} ).catch( err => {
reject( { 'code': 500, 'message': err } );
} );
} else if ( call === 'savePageSettings' ) {
startPageManager.saveStartPagePreferences( data.page, data.preferences );
resolve( 'ok' );
} else {
reject( { 'code': 404, 'error': 'Route not found' } );
}

View File

@@ -18,7 +18,11 @@ class StartPageManager {
}
saveStartPagePreferences( startPageName, preferences ) {
fs.writeFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.html' ), JSON.stringify( preferences ) );
let conf = {};
for ( let setting in preferences ) {
conf[ setting ] = preferences[ setting ][ 'value' ];
}
fs.writeFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/startPage.config.json' ), JSON.stringify( conf ) );
}
loadStartPagePreferences( startPageName ) {
@@ -43,14 +47,19 @@ class StartPageManager {
async renderStartPage( startPageName ) {
this.setActiveStartPage( startPageName );
let self = this;
const app = createSSRApp( {
data() {
return this.loadStartPagePreferences( startPageName );
return {
'data': self.loadStartPagePreferences( startPageName ),
'pageName': self.settings.pageName,
};
},
template: '' + fs.readFileSync( path.join( __dirname + '/../ui/home/templates/' + startPageName + '/index.html' ) )
} );
fs.writeFileSync( path.join( __dirname + '/../ui/home/active/en/index.html' ), await renderToString( app ) );
return true;
}
}

View File

@@ -1,17 +1 @@
{
"init":true,
"twoFA":"enforce",
"setupKey":"hello world",
"twoFAMode":"enhanced",
"db":"json",
"payments":"stripe",
"name":"libreevent",
"yourDomain":"http://localhost:8080",
"mailSender":"libreevent <info@libreevent.janishutz.com>",
"maxTickets":10,
"currency":"CHF",
"gcInterval":300,
"ticketTimeout":900,
"startPage":"default",
"version":"1.0.0"
}
{"init":true,"twoFA":"enforce","setupKey":"hello world","twoFAMode":"enhanced","db":"json","payments":"stripe","name":"libreevent","yourDomain":"http://localhost:8080","mailSender":"libreevent <info@libreevent.janishutz.com>","maxTickets":10,"currency":"CHF","gcInterval":300,"ticketTimeout":900,"startPage":"default","version":"1.0.0"}

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"> -->
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link rel="stylesheet" href="/supportFiles/style.css">
<link rel="stylesheet" href="/startPage/mainStyle">
<script defer src="/startPage/helperFunction"></script>
<title>libreevent</title>
</head>
<body>
<nav>
<a class="home">Home</a> |
<a href="/tickets">Tickets</a> |
<a href="/cart">Cart</a> |
<a href="/account">Account</a> |
<button onclick="changeTheme();" id="themeSelector">&#9789;</button>
</nav>
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
<h1>Welcome to libreevent!</h1>
<p>No start page has been configured yet! Please configure one either by using the configurator in the settings or by uploading your own HTML page to the correct folder as detailed <a href="https://libreevent.janishutz.com/docs/admin-panel/pages">here</a></p>
</body>
</html>

View File

@@ -20,6 +20,6 @@
</nav>
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
<h1>Welcome to {{ pageName }}!</h1>
<p>{{ description }}</p>
<p>{{ data.description }}</p>
</body>
</html>

View File

@@ -1,5 +1 @@
{
"subtitle": "this is a test",
"description": "this is a test description",
"banner": "homeBanner.jpg"
}
{"subtitle":"this is a test","description":"this is a test description"}

View File

@@ -10,8 +10,8 @@
"type": "textarea",
"display": "Description",
"textarea-settings": {
"resize-y": true,
"resize-x": false,
"cols": 50,
"rows": 5,
"max-length": 0,
"min-length": 100
},

View File

@@ -0,0 +1,12 @@
/*
* libreevent - style.css
*
* Created by Janis Hutz 08/29/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
*/
.logo {
height: 50vh;
}

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"> -->
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link rel="stylesheet" href="/supportFiles/style.css">
<link rel="stylesheet" href="/startPage/mainStyle">
<script defer src="/startPage/helperFunction"></script>
<title>{{ pageName }} :: Home</title>
</head>
<body>
<nav>
<a class="home">Home</a> |
<a href="/tickets">Tickets</a> |
<a href="/cart">Cart</a> |
<a href="/account">Account</a> |
<button onclick="changeTheme();" id="themeSelector">&#9789;</button>
</nav>
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
<h1>Welcome to {{ pageName }}!</h1>
<p>{{ data.description }}</p>
</body>
</html>

View File

@@ -0,0 +1 @@
{"subtitle":"this is a test","description":"this is a test description"}

View File

@@ -0,0 +1,31 @@
{
"subtitle": {
"id": "subtitle",
"type": "text",
"display": "Subtitle",
"can-be-empty": false
},
"description": {
"id": "description",
"type": "textarea",
"display": "Description",
"textarea-settings": {
"cols": 50,
"rows": 5,
"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
}
}
}

View File

@@ -20,6 +20,6 @@
</nav>
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
<h1>Welcome to {{ pageName }}!</h1>
<p>{{ description }}</p>
<p>{{ data.description }}</p>
</body>
</html>

View File

@@ -0,0 +1 @@
{"subtitle":"this is a test","description":"this is a test description"}

View File

@@ -0,0 +1,31 @@
{
"subtitle": {
"id": "subtitle",
"type": "text",
"display": "Subtitle",
"can-be-empty": false
},
"description": {
"id": "description",
"type": "textarea",
"display": "Description",
"textarea-settings": {
"cols": 50,
"rows": 5,
"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
}
}
}

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"> -->
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link rel="stylesheet" href="/supportFiles/style.css">
<link rel="stylesheet" href="/startPage/mainStyle">
<script defer src="/startPage/helperFunction"></script>
<title>{{ pageName }} :: Home</title>
</head>
<body>
<nav>
<a class="home">Home</a> |
<a href="/tickets">Tickets</a> |
<a href="/cart">Cart</a> |
<a href="/account">Account</a> |
<button onclick="changeTheme();" id="themeSelector">&#9789;</button>
</nav>
<img src="/otherAssets/logo.png" alt="libreevent logo" class="logo">
<h1>Welcome to {{ pageName }}!</h1>
<p>{{ data.description }}</p>
</body>
</html>

View File

@@ -0,0 +1 @@
{"subtitle":"this is a test","description":"this is a test description"}

View File

@@ -0,0 +1,31 @@
{
"subtitle": {
"id": "subtitle",
"type": "text",
"display": "Subtitle",
"can-be-empty": false
},
"description": {
"id": "description",
"type": "textarea",
"display": "Description",
"textarea-settings": {
"cols": 50,
"rows": 5,
"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
}
}
}

View File

@@ -0,0 +1,12 @@
/*
* libreevent - style.css
*
* Created by Janis Hutz 08/29/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
*/
.logo {
height: 50vh;
}