2017-12-03 22:29:23 -05:00
|
|
|
"use strict";
|
|
|
|
|
2018-07-24 08:12:36 +02:00
|
|
|
const sqlInit = require('../services/sql_init');
|
|
|
|
const setupService = require('../services/setup');
|
2019-12-24 14:42:03 +01:00
|
|
|
const utils = require('../services/utils');
|
2022-10-26 23:50:54 +02:00
|
|
|
const assetPath = require("../services/asset_path");
|
2018-07-24 08:12:36 +02:00
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
function setupPage(req, res) {
|
|
|
|
if (sqlInit.isDbInitialized()) {
|
2019-12-24 14:42:03 +01:00
|
|
|
if (utils.isElectron()) {
|
2020-05-08 10:24:57 +02:00
|
|
|
const windowService = require('../services/window');
|
2022-08-05 16:44:26 +02:00
|
|
|
const {app} = require('electron');
|
|
|
|
windowService.createMainWindow(app);
|
2019-12-24 14:42:03 +01:00
|
|
|
windowService.closeSetupWindow();
|
|
|
|
}
|
|
|
|
else {
|
2022-12-25 10:48:51 +01:00
|
|
|
res.redirect('.');
|
2019-12-24 14:42:03 +01:00
|
|
|
}
|
2022-01-12 19:32:23 +01:00
|
|
|
|
|
|
|
return;
|
2018-07-24 08:12:36 +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();
|
2018-07-24 08:12:36 +02:00
|
|
|
|
|
|
|
if (syncInProgress) {
|
|
|
|
// trigger sync if it's not already running
|
|
|
|
setupService.triggerSync();
|
|
|
|
}
|
|
|
|
|
|
|
|
res.render('setup', {
|
2022-10-26 23:50:54 +02:00
|
|
|
syncInProgress: syncInProgress,
|
|
|
|
assetPath: assetPath
|
2018-07-24 08:12:36 +02:00
|
|
|
});
|
2018-03-30 19:31:22 -04:00
|
|
|
}
|
2017-12-03 22:29:23 -05:00
|
|
|
|
2018-03-30 19:31:22 -04:00
|
|
|
module.exports = {
|
|
|
|
setupPage
|
|
|
|
};
|