Add initial dashboard entrypoint server side rendering routes

This commit is contained in:
Johannes Zellner
2025-07-11 11:16:03 +02:00
parent 148c0d9213
commit 66d1de0821
9 changed files with 87 additions and 7 deletions
+64 -1
View File
@@ -4,15 +4,27 @@ exports = module.exports = {
getConfig,
startPrepareLocation,
changeLocation
changeLocation,
renderIndex,
renderFilemanager,
renderLogs,
renderTerminal,
renderPasswordreset,
renderSetupaccount,
};
const AuditSource = require('../auditsource.js'),
BoxError = require('../boxerror.js'),
branding = require('../branding.js'),
constants = require('../constants.js'),
dashboard = require('../dashboard.js'),
ejs = require('ejs'),
fs = require('fs'),
HttpError = require('@cloudron/connect-lastmile').HttpError,
HttpSuccess = require('@cloudron/connect-lastmile').HttpSuccess,
path = require('path'),
paths = require('../paths.js'),
safe = require('safetydance');
async function getConfig(req, res, next) {
@@ -39,3 +51,54 @@ async function changeLocation(req, res, next) {
next(new HttpSuccess(204, {}));
}
async function renderIndex(req, res) {
const template = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'index.html'), 'utf-8');
const cloudronName = await branding.getCloudronName();
const html = ejs.render(template, { cloudronName });
res.send(html);
}
async function renderFilemanager(req, res) {
const template = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'filemanager.html'), 'utf-8');
const html = template;
res.send(html);
}
async function renderLogs(req, res) {
const template = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'logs.html'), 'utf-8');
const html = template;
res.send(html);
}
async function renderTerminal(req, res) {
const template = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'terminal.html'), 'utf-8');
const html = template;
res.send(html);
}
async function renderPasswordreset(req, res) {
const template = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'passwordreset.html'), 'utf-8');
const cloudronName = await branding.getCloudronName();
const html = ejs.render(template, { cloudronName });
res.send(html);
}
async function renderSetupaccount(req, res) {
const template = fs.readFileSync(path.join(paths.DASHBOARD_DIR, 'setupaccount.html'), 'utf-8');
const cloudronName = await branding.getCloudronName();
const html = ejs.render(template, { cloudronName });
res.send(html);
}