Notes/src/routes/setup.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-12-03 22:29:23 -05:00
"use strict";
const sqlInit = require('../services/sql_init');
2024-04-03 23:28:26 +03:00
const setupService = require('../services/setup');
2024-02-16 21:38:09 +02:00
const utils = require('../services/utils');
2024-02-17 19:09:36 +02:00
const assetPath = require('../services/asset_path');
2024-02-17 19:20:32 +02:00
const appPath = require('../services/app_path');
2020-06-20 12:31:38 +02:00
function setupPage(req, res) {
if (sqlInit.isDbInitialized()) {
if (utils.isElectron()) {
2024-02-18 12:19:09 +02:00
const windowService = require('../services/window');
2024-04-03 23:28:26 +03:00
const { app } = require('electron');
2022-08-05 16:44:26 +02:00
windowService.createMainWindow(app);
windowService.closeSetupWindow();
}
else {
res.redirect('.');
}
2022-01-12 19:32:23 +01:00
return;
}
2023-06-29 23:32:19 +02:00
// we got here because DB is not completely initialized, so if schema exists,
// it means we're in "sync in progress" state.
2020-06-20 12:31:38 +02:00
const syncInProgress = sqlInit.schemaExists();
if (syncInProgress) {
// trigger sync if it's not already running
setupService.triggerSync();
}
res.render('setup', {
syncInProgress: syncInProgress,
assetPath: assetPath,
appPath: appPath
});
}
2017-12-03 22:29:23 -05:00
module.exports = {
setupPage
};