Database initialization wizard
This commit is contained in:
1 parent
b51c97e97a
commit
6cb0d0449b
10 files changed
+613
-19
No files matched your search
@@ -20,6 +20,7 @@
|
||||
import m, { RouteResolver } from "mithril";
|
||||
import layout from "./layout";
|
||||
import * as store from "./store";
|
||||
import * as wizardPage from "./wizard-page";
|
||||
import * as loginPage from "./login-page";
|
||||
import * as overviewPage from "./overview-page";
|
||||
import * as devicesPage from "./devices-page";
|
||||
@@ -136,6 +137,7 @@ function redirectAdminPage(): RouteResolver {
|
||||
}
|
||||
|
||||
m.route(document.body, "/overview", {
|
||||
"/wizard": pagify("wizard", wizardPage),
|
||||
"/login": pagify("login", loginPage),
|
||||
"/overview": pagify("overview", overviewPage),
|
||||
"/devices": pagify("devices", devicesPage),
|
||||
|
||||
@@ -716,3 +716,12 @@ span.parameter-value {
|
||||
color: #aaa;
|
||||
}
|
||||
}
|
||||
|
||||
.wizard-dialog {
|
||||
max-width: 720px;
|
||||
margin: 10px auto;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--color1);
|
||||
box-shadow: 0 0 10px #ccc;
|
||||
}
|
||||
@@ -69,6 +69,12 @@ export function init(args): Promise<{}> {
|
||||
const filter = args.hasOwnProperty("filter") ? "" + args["filter"] : "";
|
||||
const sort = args.hasOwnProperty("sort") ? "" + args["sort"] : "";
|
||||
const indexParameters = Object.values(config.ui.index);
|
||||
if (!indexParameters.length) {
|
||||
indexParameters.push({
|
||||
label: "ID",
|
||||
parameter: ["PARAM", "DeviceID.ID"]
|
||||
});
|
||||
}
|
||||
resolve({ filter, indexParameters, sort });
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import config from "./config";
|
||||
import * as store from "./store";
|
||||
import pieChartComponent from "./pie-chart-component";
|
||||
|
||||
const GROUPS = config.ui.overview.groups;
|
||||
const GROUPS = config.ui.overview.groups || {};
|
||||
const CHARTS = {};
|
||||
for (const group of Object.values(GROUPS)) {
|
||||
for (const chartName of Object.values(group["charts"]) as string[])
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* Copyright 2013-2019 GenieACS Inc.
|
||||
*
|
||||
* This file is part of GenieACS.
|
||||
*
|
||||
* GenieACS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* GenieACS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import m, { ClosureComponent, Component } from "mithril";
|
||||
import * as notifications from "./notifications";
|
||||
|
||||
export async function init(): Promise<{}> {
|
||||
return m.request({ url: "/init" });
|
||||
}
|
||||
|
||||
export const component: ClosureComponent = (vnode): Component => {
|
||||
let options = vnode.attrs;
|
||||
const selected = new Set();
|
||||
for (const [k, v] of Object.entries(options)) if (v) selected.add(k);
|
||||
|
||||
return {
|
||||
view: () => {
|
||||
document.title = "Initialization wizard - GenieACS";
|
||||
|
||||
const checkboxes = [
|
||||
"users",
|
||||
"presets",
|
||||
"filters",
|
||||
"device",
|
||||
"index",
|
||||
"overview"
|
||||
].map(s => {
|
||||
if (!options[s]) selected.delete(s);
|
||||
return m("input", {
|
||||
type: "checkbox",
|
||||
checked: selected.has(s),
|
||||
disabled: !options[s],
|
||||
style: "display: inline; margin-right: 0.5em;",
|
||||
onclick: e => {
|
||||
if (e.target.checked) selected.add(s);
|
||||
else selected.delete(s);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return m(".wizard-dialog", [
|
||||
m("h1", "Initialization wizard"),
|
||||
m(
|
||||
"p",
|
||||
"This wizard will seed the database with a minimal initial configuration to serve as a starting point. Select what you want to initialize and click 'ABRACADABRA!'."
|
||||
),
|
||||
m("div", m("label", checkboxes[0], "Users, roles and permissions")),
|
||||
m("div", m("label", checkboxes[1], "Presets and provisions")),
|
||||
m(
|
||||
"div",
|
||||
m("label", checkboxes[2], "Devices predefined search filters")
|
||||
),
|
||||
m("div", m("label", checkboxes[3], "Device details page")),
|
||||
m("div", m("label", checkboxes[4], "Devices listing page")),
|
||||
m("div", m("label", checkboxes[5], "Overview page")),
|
||||
m(
|
||||
"button.primary",
|
||||
{
|
||||
style: "margin: 10px;",
|
||||
disabled: selected.size === 0,
|
||||
onclick: e => {
|
||||
e.target.disabled = true;
|
||||
|
||||
const opts = {};
|
||||
for (const s of selected) opts[s] = true;
|
||||
|
||||
m.request({
|
||||
method: "POST",
|
||||
url: "/init",
|
||||
data: opts
|
||||
})
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
m.request({ url: "/init" }).then(o => {
|
||||
e.target.disabled = false;
|
||||
options = o;
|
||||
notifications.push("success", "Initialization complete", {
|
||||
"Open Sesame!": () => {
|
||||
m.route.set("/login");
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 3000);
|
||||
if (opts["users"]) {
|
||||
alert(
|
||||
"An administrator user has been created for you. Use admin/admin to log in. Don't forget to change the default password."
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
notifications.push("error", err.message);
|
||||
});
|
||||
}
|
||||
},
|
||||
"ABRACADABRA!"
|
||||
)
|
||||
]);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user