@saltcorn/server 0.6.1-beta.3 → 0.6.1
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/package.json +6 -6
- package/routes/homepage.js +124 -104
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.6.1
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@saltcorn/base-plugin": "0.6.1
|
|
10
|
-
"@saltcorn/builder": "0.6.1
|
|
11
|
-
"@saltcorn/data": "0.6.1
|
|
9
|
+
"@saltcorn/base-plugin": "0.6.1",
|
|
10
|
+
"@saltcorn/builder": "0.6.1",
|
|
11
|
+
"@saltcorn/data": "0.6.1",
|
|
12
12
|
"greenlock-express": "^4.0.3",
|
|
13
|
-
"@saltcorn/markup": "0.6.1
|
|
14
|
-
"@saltcorn/sbadmin2": "0.6.1
|
|
13
|
+
"@saltcorn/markup": "0.6.1",
|
|
14
|
+
"@saltcorn/sbadmin2": "0.6.1",
|
|
15
15
|
"@socket.io/cluster-adapter": "^0.1.0",
|
|
16
16
|
"@socket.io/sticky": "^1.0.1",
|
|
17
17
|
"connect-flash": "^0.1.1",
|
package/routes/homepage.js
CHANGED
|
@@ -21,8 +21,8 @@ const Trigger = require("@saltcorn/data/models/trigger");
|
|
|
21
21
|
const { fileUploadForm } = require("../markup/forms");
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @param {*} tables
|
|
25
|
-
* @param {object} req
|
|
24
|
+
* @param {*} tables
|
|
25
|
+
* @param {object} req
|
|
26
26
|
* @returns {Table}
|
|
27
27
|
*/
|
|
28
28
|
const tableTable = (tables, req) =>
|
|
@@ -38,8 +38,8 @@ const tableTable = (tables, req) =>
|
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* @param {*} tables
|
|
42
|
-
* @param {object} req
|
|
41
|
+
* @param {*} tables
|
|
42
|
+
* @param {object} req
|
|
43
43
|
* @returns {object}
|
|
44
44
|
*/
|
|
45
45
|
const tableCard = (tables, req) => ({
|
|
@@ -67,8 +67,8 @@ const tableCard = (tables, req) => ({
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* @param {*} views
|
|
71
|
-
* @param {object} req
|
|
70
|
+
* @param {*} views
|
|
71
|
+
* @param {object} req
|
|
72
72
|
* @returns {Table}
|
|
73
73
|
*/
|
|
74
74
|
const viewTable = (views, req) =>
|
|
@@ -88,8 +88,8 @@ const viewTable = (views, req) =>
|
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* @param {*} views
|
|
92
|
-
* @param {object} req
|
|
91
|
+
* @param {*} views
|
|
92
|
+
* @param {object} req
|
|
93
93
|
* @returns {object}
|
|
94
94
|
*/
|
|
95
95
|
const viewCard = (views, req) => ({
|
|
@@ -119,8 +119,8 @@ const viewCard = (views, req) => ({
|
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* @param {*} pages
|
|
123
|
-
* @param {object} req
|
|
122
|
+
* @param {*} pages
|
|
123
|
+
* @param {object} req
|
|
124
124
|
* @returns {Table}
|
|
125
125
|
*/
|
|
126
126
|
const pageTable = (pages, req) =>
|
|
@@ -140,8 +140,8 @@ const pageTable = (pages, req) =>
|
|
|
140
140
|
);
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
* @param {*} pages
|
|
144
|
-
* @param {object} req
|
|
143
|
+
* @param {*} pages
|
|
144
|
+
* @param {object} req
|
|
145
145
|
* @returns {object}
|
|
146
146
|
*/
|
|
147
147
|
const pageCard = (pages, req) => ({
|
|
@@ -172,11 +172,11 @@ const pageCard = (pages, req) => ({
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
* @param {object} req
|
|
175
|
+
* @param {object} req
|
|
176
176
|
* @returns {Promise<div>}
|
|
177
177
|
*/
|
|
178
178
|
const filesTab = async (req) => {
|
|
179
|
-
const files = await File.find({}, { orderBy: "filename" });
|
|
179
|
+
const files = await File.find({}, { orderBy: "filename", cached: true });
|
|
180
180
|
return div(
|
|
181
181
|
files.length == 0
|
|
182
182
|
? p(req.__("No files"))
|
|
@@ -196,16 +196,10 @@ const filesTab = async (req) => {
|
|
|
196
196
|
};
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* @param {object} req
|
|
199
|
+
* @param {object} req
|
|
200
200
|
* @returns {Promise<div>}
|
|
201
201
|
*/
|
|
202
|
-
const usersTab = async (req) => {
|
|
203
|
-
const users = await User.find({}, { orderBy: "id" });
|
|
204
|
-
const roles = await User.get_roles();
|
|
205
|
-
var roleMap = {};
|
|
206
|
-
roles.forEach((r) => {
|
|
207
|
-
roleMap[r.id] = r.role;
|
|
208
|
-
});
|
|
202
|
+
const usersTab = async (req, users, roleMap) => {
|
|
209
203
|
return div(
|
|
210
204
|
mkTable(
|
|
211
205
|
[
|
|
@@ -219,20 +213,19 @@ const usersTab = async (req) => {
|
|
|
219
213
|
users
|
|
220
214
|
),
|
|
221
215
|
a(
|
|
222
|
-
{ href: `/useradmin/new`, class: "btn btn-secondary" },
|
|
216
|
+
{ href: `/useradmin/new`, class: "btn btn-secondary my-3" },
|
|
223
217
|
req.__("Create user")
|
|
224
218
|
)
|
|
225
219
|
);
|
|
226
220
|
};
|
|
227
221
|
|
|
228
222
|
/**
|
|
229
|
-
* @param {object} req
|
|
223
|
+
* @param {object} req
|
|
230
224
|
* @returns {Promise<div>}
|
|
231
225
|
*/
|
|
232
|
-
const actionsTab = async (req) => {
|
|
233
|
-
const triggers = await Trigger.findAllWithTableName();
|
|
234
|
-
|
|
226
|
+
const actionsTab = async (req, triggers) => {
|
|
235
227
|
return div(
|
|
228
|
+
{ class: "pb-3" },
|
|
236
229
|
triggers.length <= 1 &&
|
|
237
230
|
p(
|
|
238
231
|
{ class: "mt-2 pr-2" },
|
|
@@ -259,14 +252,73 @@ const actionsTab = async (req) => {
|
|
|
259
252
|
triggers
|
|
260
253
|
),
|
|
261
254
|
a(
|
|
262
|
-
{ href: "/actions/new", class: "btn btn-secondary
|
|
255
|
+
{ href: "/actions/new", class: "btn btn-secondary my-3" },
|
|
263
256
|
req.__("Add trigger")
|
|
264
257
|
)
|
|
265
258
|
);
|
|
266
259
|
};
|
|
260
|
+
const packTab = (req, packlist) =>
|
|
261
|
+
div(
|
|
262
|
+
{ class: "pb-3 pt-2 pr-4" },
|
|
263
|
+
p(req.__("Instead of building, get up and running in no time with packs")),
|
|
264
|
+
p(
|
|
265
|
+
{ class: "font-italic" },
|
|
266
|
+
req.__(
|
|
267
|
+
"Packs are collections of tables, views and plugins that give you a full application which you can then edit to suit your needs."
|
|
268
|
+
)
|
|
269
|
+
),
|
|
270
|
+
mkTable(
|
|
271
|
+
[
|
|
272
|
+
{ label: req.__("Name"), key: "name" },
|
|
273
|
+
{
|
|
274
|
+
label: req.__("Description"),
|
|
275
|
+
key: "description",
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
packlist,
|
|
279
|
+
{ noHeader: true }
|
|
280
|
+
),
|
|
281
|
+
a(
|
|
282
|
+
{ href: `/plugins?set=packs`, class: "btn btn-primary" },
|
|
283
|
+
req.__("Go to pack store »")
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const helpCard = (req) =>
|
|
288
|
+
div(
|
|
289
|
+
{ class: "pb-3 pt-2 pr-4" },
|
|
290
|
+
p(req.__("Confused?")),
|
|
291
|
+
p(
|
|
292
|
+
req.__(
|
|
293
|
+
"The Wiki contains the documentation and tutorials on installing and using Saltcorn"
|
|
294
|
+
)
|
|
295
|
+
),
|
|
296
|
+
a(
|
|
297
|
+
{
|
|
298
|
+
href: `https://wiki.saltcorn.com/`,
|
|
299
|
+
class: "btn btn-primary",
|
|
300
|
+
},
|
|
301
|
+
req.__("Go to Wiki »")
|
|
302
|
+
),
|
|
303
|
+
p(req.__("The YouTube channel has some video tutorials")),
|
|
304
|
+
a(
|
|
305
|
+
{
|
|
306
|
+
href: `https://www.youtube.com/channel/UCBOpAcH8ep7ESbuocxcq0KQ`,
|
|
307
|
+
class: "btn btn-secondary",
|
|
308
|
+
},
|
|
309
|
+
req.__("Go to YouTube »")
|
|
310
|
+
),
|
|
311
|
+
div(
|
|
312
|
+
{ class: "mt-3" },
|
|
313
|
+
a(
|
|
314
|
+
{ href: `https://blog.saltcorn.com/` },
|
|
315
|
+
req.__("What's new? Read the blog »")
|
|
316
|
+
)
|
|
317
|
+
)
|
|
318
|
+
);
|
|
267
319
|
|
|
268
320
|
/**
|
|
269
|
-
* @param {object} req
|
|
321
|
+
* @param {object} req
|
|
270
322
|
* @returns {Promise<object>}
|
|
271
323
|
*/
|
|
272
324
|
const welcome_page = async (req) => {
|
|
@@ -275,10 +327,16 @@ const welcome_page = async (req) => {
|
|
|
275
327
|
...packs_available.slice(0, 5),
|
|
276
328
|
{ name: req.__("More..."), description: "" },
|
|
277
329
|
];
|
|
278
|
-
const tables = await Table.find({}, {
|
|
279
|
-
const views = await View.find({});
|
|
280
|
-
const pages = await Page.find({});
|
|
281
|
-
|
|
330
|
+
const tables = await Table.find({}, { cached: true });
|
|
331
|
+
const views = await View.find({}, { cached: true });
|
|
332
|
+
const pages = await Page.find({}, { cached: true });
|
|
333
|
+
const triggers = await Trigger.findAllWithTableName();
|
|
334
|
+
const users = await User.find({}, { orderBy: "id" });
|
|
335
|
+
const roles = await User.get_roles();
|
|
336
|
+
let roleMap = {};
|
|
337
|
+
roles.forEach((r) => {
|
|
338
|
+
roleMap[r.id] = r.role;
|
|
339
|
+
});
|
|
282
340
|
return {
|
|
283
341
|
above: [
|
|
284
342
|
{
|
|
@@ -293,75 +351,37 @@ const welcome_page = async (req) => {
|
|
|
293
351
|
{
|
|
294
352
|
type: "card",
|
|
295
353
|
//title: req.__("Install pack"),
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
{ label: req.__("Name"), key: "name" },
|
|
312
|
-
{
|
|
313
|
-
label: req.__("Description"),
|
|
314
|
-
key: "description",
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
packlist,
|
|
318
|
-
{ noHeader: true }
|
|
319
|
-
),
|
|
320
|
-
a(
|
|
321
|
-
{ href: `/plugins?set=packs`, class: "btn btn-primary" },
|
|
322
|
-
req.__("Go to pack store »")
|
|
323
|
-
)
|
|
324
|
-
),
|
|
325
|
-
Triggers: await actionsTab(req),
|
|
326
|
-
Files: await filesTab(req),
|
|
327
|
-
},
|
|
354
|
+
bodyClass: "py-0 pr-0",
|
|
355
|
+
class: "welcome-page-entity-list",
|
|
356
|
+
|
|
357
|
+
tabContents:
|
|
358
|
+
triggers.length > 0
|
|
359
|
+
? {
|
|
360
|
+
Triggers: await actionsTab(req, triggers),
|
|
361
|
+
Files: await filesTab(req),
|
|
362
|
+
Packs: packTab(req, packlist),
|
|
363
|
+
}
|
|
364
|
+
: {
|
|
365
|
+
Packs: packTab(req, packlist),
|
|
366
|
+
Triggers: await actionsTab(req, triggers),
|
|
367
|
+
Files: await filesTab(req),
|
|
368
|
+
},
|
|
328
369
|
},
|
|
329
370
|
{
|
|
330
371
|
type: "card",
|
|
331
372
|
//title: req.__("Learn"),
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
class: "btn btn-primary",
|
|
373
|
+
bodyClass: "py-0 pr-0",
|
|
374
|
+
class: "welcome-page-entity-list",
|
|
375
|
+
tabContents:
|
|
376
|
+
users.length > 4
|
|
377
|
+
? {
|
|
378
|
+
Users: await usersTab(req, users, roleMap),
|
|
379
|
+
Help: helpCard(req),
|
|
380
|
+
}
|
|
381
|
+
: {
|
|
382
|
+
Help: helpCard(req),
|
|
383
|
+
Users: await usersTab(req, users, roleMap),
|
|
344
384
|
},
|
|
345
|
-
req.__("Go to Wiki »")
|
|
346
|
-
),
|
|
347
|
-
p(req.__("The YouTube channel has some video tutorials")),
|
|
348
|
-
a(
|
|
349
|
-
{
|
|
350
|
-
href: `https://www.youtube.com/channel/UCBOpAcH8ep7ESbuocxcq0KQ`,
|
|
351
|
-
class: "btn btn-secondary",
|
|
352
|
-
},
|
|
353
|
-
req.__("Go to YouTube »")
|
|
354
|
-
),
|
|
355
|
-
div(
|
|
356
|
-
{ class: "mt-3" },
|
|
357
|
-
a(
|
|
358
|
-
{ href: `https://blog.saltcorn.com/` },
|
|
359
|
-
req.__("What's new? Read the blog »")
|
|
360
|
-
)
|
|
361
|
-
)
|
|
362
|
-
),
|
|
363
|
-
Users: await usersTab(req),
|
|
364
|
-
},
|
|
365
385
|
},
|
|
366
386
|
],
|
|
367
387
|
},
|
|
@@ -370,8 +390,8 @@ const welcome_page = async (req) => {
|
|
|
370
390
|
};
|
|
371
391
|
|
|
372
392
|
/**
|
|
373
|
-
* @param {object} req
|
|
374
|
-
* @param {object} res
|
|
393
|
+
* @param {object} req
|
|
394
|
+
* @param {object} res
|
|
375
395
|
* @returns {Promise<void>}
|
|
376
396
|
*/
|
|
377
397
|
const no_views_logged_in = async (req, res) => {
|
|
@@ -400,9 +420,9 @@ const no_views_logged_in = async (req, res) => {
|
|
|
400
420
|
};
|
|
401
421
|
|
|
402
422
|
/**
|
|
403
|
-
* @param {number} role_id
|
|
404
|
-
* @param {object} res
|
|
405
|
-
* @param {object} req
|
|
423
|
+
* @param {number} role_id
|
|
424
|
+
* @param {object} res
|
|
425
|
+
* @param {object} req
|
|
406
426
|
* @returns {Promise<boolean>}
|
|
407
427
|
*/
|
|
408
428
|
const get_config_response = async (role_id, res, req) => {
|
|
@@ -431,8 +451,8 @@ const get_config_response = async (role_id, res, req) => {
|
|
|
431
451
|
|
|
432
452
|
/**
|
|
433
453
|
* Function assigned to 'module.exports'.
|
|
434
|
-
* @param {object} req
|
|
435
|
-
* @param {object} res
|
|
454
|
+
* @param {object} req
|
|
455
|
+
* @param {object} res
|
|
436
456
|
* @returns {Promise<void>}
|
|
437
457
|
*/
|
|
438
458
|
module.exports = async (req, res) => {
|