@saltcorn/server 0.6.4-beta.1 → 0.6.4-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +3 -1
- package/auth/resetpw.js +7 -7
- package/auth/routes.js +1 -1
- package/locales/en.json +7 -1
- package/package.json +18 -15
- package/public/flatpickr.min.js +2 -2
- package/public/gridedit.js +169 -221
- package/public/luxon.min.js +1 -0
- package/public/saltcorn.js +83 -15
- package/public/tabulator.min.js +3 -0
- package/public/tabulator_bootstrap4.min.css +2 -0
- package/restart_watcher.js +1 -1
- package/routes/admin.js +2 -2
- package/routes/fields.js +31 -2
- package/routes/homepage.js +1 -1
- package/routes/list.js +176 -89
- package/routes/packs.js +1 -1
- package/routes/pageedit.js +1 -1
- package/routes/plugins.js +3 -1
- package/routes/scapi.js +1 -1
- package/routes/tenant.js +19 -9
- package/routes/viewedit.js +1 -1
- package/serve.js +38 -27
- package/wrapper.js +5 -2
package/serve.js
CHANGED
|
@@ -11,9 +11,10 @@ const db = require("@saltcorn/data/db");
|
|
|
11
11
|
const {
|
|
12
12
|
getState,
|
|
13
13
|
init_multi_tenant,
|
|
14
|
-
create_tenant,
|
|
15
14
|
restart_tenant,
|
|
15
|
+
add_tenant,
|
|
16
16
|
} = require("@saltcorn/data/db/state");
|
|
17
|
+
const { create_tenant } = require("@saltcorn/admin-models/models/tenant");
|
|
17
18
|
|
|
18
19
|
const path = require("path");
|
|
19
20
|
|
|
@@ -38,7 +39,10 @@ const {
|
|
|
38
39
|
getRelevantPackages,
|
|
39
40
|
getPluginDirectories,
|
|
40
41
|
} = require("./restart_watcher");
|
|
41
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
eachTenant,
|
|
44
|
+
getAllTenants,
|
|
45
|
+
} = require("@saltcorn/admin-models/models/tenant");
|
|
42
46
|
|
|
43
47
|
// helpful https://gist.github.com/jpoehls/2232358
|
|
44
48
|
/**
|
|
@@ -72,7 +76,8 @@ const initMaster = async ({ disableMigrate }, useClusterAdaptor = true) => {
|
|
|
72
76
|
// switch on sql logging - but it was initiated before???
|
|
73
77
|
if (getState().getConfig("log_sql", false)) db.set_sql_logging();
|
|
74
78
|
if (db.is_it_multi_tenant()) {
|
|
75
|
-
await
|
|
79
|
+
const tenants = await getAllTenants();
|
|
80
|
+
await init_multi_tenant(loadAllPlugins, disableMigrate, tenants);
|
|
76
81
|
}
|
|
77
82
|
if (useClusterAdaptor) setupPrimary();
|
|
78
83
|
};
|
|
@@ -95,7 +100,14 @@ const workerDispatchMsg = ({ tenant, ...msg }) => {
|
|
|
95
100
|
}
|
|
96
101
|
if (msg.refresh) getState()[`refresh_${msg.refresh}`](true);
|
|
97
102
|
if (msg.createTenant) {
|
|
98
|
-
|
|
103
|
+
const tenant_template = getState().getConfig("tenant_template");
|
|
104
|
+
add_tenant(msg.createTenant);
|
|
105
|
+
create_tenant({
|
|
106
|
+
t: msg.createTenant,
|
|
107
|
+
plugin_loader: loadAllPlugins,
|
|
108
|
+
noSignalOrDB: true,
|
|
109
|
+
tenant_template,
|
|
110
|
+
});
|
|
99
111
|
db.runWithTenant(msg.createTenant, async () => {
|
|
100
112
|
getState().refresh(true);
|
|
101
113
|
});
|
|
@@ -117,29 +129,28 @@ const workerDispatchMsg = ({ tenant, ...msg }) => {
|
|
|
117
129
|
* @param {number} opts.pid
|
|
118
130
|
* @returns {function}
|
|
119
131
|
*/
|
|
120
|
-
const onMessageFromWorker =
|
|
121
|
-
masterState,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
};
|
|
132
|
+
const onMessageFromWorker =
|
|
133
|
+
(masterState, { port, watchReaper, disableScheduler, pid }) =>
|
|
134
|
+
(msg) => {
|
|
135
|
+
//console.log("worker msg", typeof msg, msg);
|
|
136
|
+
if (msg === "Start" && !masterState.started) {
|
|
137
|
+
masterState.started = true;
|
|
138
|
+
runScheduler({ port, watchReaper, disableScheduler, eachTenant });
|
|
139
|
+
require("./systemd")({ port });
|
|
140
|
+
return true;
|
|
141
|
+
} else if (msg === "RestartServer") {
|
|
142
|
+
process.exit(0);
|
|
143
|
+
return true;
|
|
144
|
+
} else if (msg.tenant || msg.createTenant) {
|
|
145
|
+
///ie from saltcorn
|
|
146
|
+
//broadcast
|
|
147
|
+
Object.entries(cluster.workers).forEach(([wpid, w]) => {
|
|
148
|
+
if (wpid !== pid) w.send(msg);
|
|
149
|
+
});
|
|
150
|
+
workerDispatchMsg(msg); //also master
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
143
154
|
|
|
144
155
|
module.exports =
|
|
145
156
|
/**
|
package/wrapper.js
CHANGED
|
@@ -174,12 +174,15 @@ const get_headers = (req, version_tag, description, extras = []) => {
|
|
|
174
174
|
from_cfg.push({ style: state.getConfig("page_custom_css", "") });
|
|
175
175
|
if (state.getConfig("page_custom_html", ""))
|
|
176
176
|
from_cfg.push({ headerTag: state.getConfig("page_custom_html", "") });
|
|
177
|
-
|
|
177
|
+
const state_headers = [];
|
|
178
|
+
for (const hs of Object.values(state.headers)) {
|
|
179
|
+
state_headers.push(...hs);
|
|
180
|
+
}
|
|
178
181
|
return [
|
|
179
182
|
...stdHeaders,
|
|
180
183
|
...iconHeader,
|
|
181
184
|
...meta_description,
|
|
182
|
-
...
|
|
185
|
+
...state_headers,
|
|
183
186
|
...extras,
|
|
184
187
|
...from_cfg,
|
|
185
188
|
];
|