@saltcorn/server 0.9.6-beta.4 → 0.9.6-beta.6
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/auth/admin.js +4 -1
- package/load_plugins.js +5 -1
- package/package.json +9 -9
- package/routes/fields.js +61 -41
- package/routes/plugins.js +6 -1
- package/routes/tables.js +4 -0
- package/routes/utils.js +5 -2
- package/tests/plugins.test.js +2 -0
package/auth/admin.js
CHANGED
|
@@ -531,7 +531,10 @@ router.post(
|
|
|
531
531
|
if (restart_required)
|
|
532
532
|
res.json({
|
|
533
533
|
success: "ok",
|
|
534
|
-
notify:
|
|
534
|
+
notify:
|
|
535
|
+
req.__("Restart required for changes to take effect.") +
|
|
536
|
+
" " +
|
|
537
|
+
a({ href: "/admin/system" }, req.__("Restart here")),
|
|
535
538
|
});
|
|
536
539
|
else res.json({ success: "ok" });
|
|
537
540
|
}
|
package/load_plugins.js
CHANGED
|
@@ -141,7 +141,11 @@ const loadAndSaveNewPlugin = async (
|
|
|
141
141
|
const existing = await Plugin.findOne({ location: loc });
|
|
142
142
|
if (!existing && loc !== plugin.location) {
|
|
143
143
|
await loadAndSaveNewPlugin(
|
|
144
|
-
new Plugin({
|
|
144
|
+
new Plugin({
|
|
145
|
+
name: loc.replace("@saltcorn/", ""),
|
|
146
|
+
location: loc,
|
|
147
|
+
source: "npm",
|
|
148
|
+
}),
|
|
145
149
|
force,
|
|
146
150
|
noSignalOrDB
|
|
147
151
|
);
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.9.6-beta.
|
|
3
|
+
"version": "0.9.6-beta.6",
|
|
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
9
|
"@aws-sdk/client-s3": "^3.451.0",
|
|
10
|
-
"@saltcorn/base-plugin": "0.9.6-beta.
|
|
11
|
-
"@saltcorn/builder": "0.9.6-beta.
|
|
12
|
-
"@saltcorn/data": "0.9.6-beta.
|
|
13
|
-
"@saltcorn/admin-models": "0.9.6-beta.
|
|
14
|
-
"@saltcorn/filemanager": "0.9.6-beta.
|
|
15
|
-
"@saltcorn/markup": "0.9.6-beta.
|
|
16
|
-
"@saltcorn/plugins-loader": "0.9.6-beta.
|
|
17
|
-
"@saltcorn/sbadmin2": "0.9.6-beta.
|
|
10
|
+
"@saltcorn/base-plugin": "0.9.6-beta.6",
|
|
11
|
+
"@saltcorn/builder": "0.9.6-beta.6",
|
|
12
|
+
"@saltcorn/data": "0.9.6-beta.6",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.6-beta.6",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.6-beta.6",
|
|
15
|
+
"@saltcorn/markup": "0.9.6-beta.6",
|
|
16
|
+
"@saltcorn/plugins-loader": "0.9.6-beta.6",
|
|
17
|
+
"@saltcorn/sbadmin2": "0.9.6-beta.6",
|
|
18
18
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
19
19
|
"@socket.io/sticky": "^1.0.1",
|
|
20
20
|
"adm-zip": "0.5.10",
|
package/routes/fields.js
CHANGED
|
@@ -255,6 +255,7 @@ const fieldFlow = (req) =>
|
|
|
255
255
|
expression = "__aggregation";
|
|
256
256
|
attributes.agg_relation = context.agg_relation;
|
|
257
257
|
attributes.agg_field = context.agg_field;
|
|
258
|
+
attributes.agg_order_by = context.agg_order_by;
|
|
258
259
|
attributes.aggwhere = context.aggwhere;
|
|
259
260
|
attributes.aggregate = context.aggregate;
|
|
260
261
|
const [table, ref] = context.agg_relation.split(".");
|
|
@@ -435,46 +436,64 @@ const fieldFlow = (req) =>
|
|
|
435
436
|
|
|
436
437
|
const { child_field_list, child_relations } =
|
|
437
438
|
await table.get_child_relations(true);
|
|
438
|
-
const agg_field_opts =
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
439
|
+
const agg_field_opts = [];
|
|
440
|
+
const agg_order_opts = [];
|
|
441
|
+
child_relations.forEach(({ table, key_field, through }) => {
|
|
442
|
+
const aggKey =
|
|
443
|
+
(through ? `${through.name}->` : "") +
|
|
444
|
+
`${table.name}.${key_field.name}`;
|
|
445
|
+
aggStatOptions[aggKey] = [
|
|
446
|
+
"Count",
|
|
447
|
+
"CountUnique",
|
|
448
|
+
"Avg",
|
|
449
|
+
"Sum",
|
|
450
|
+
"Max",
|
|
451
|
+
"Min",
|
|
452
|
+
"Array_Agg",
|
|
453
|
+
];
|
|
454
|
+
table.fields.forEach((f) => {
|
|
455
|
+
if (f.type && f.type.name === "Date") {
|
|
456
|
+
aggStatOptions[aggKey].push(`Latest ${f.name}`);
|
|
457
|
+
aggStatOptions[aggKey].push(`Earliest ${f.name}`);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
agg_field_opts.push({
|
|
461
|
+
name: `agg_field`,
|
|
462
|
+
label: req.__("On Field"),
|
|
463
|
+
type: "String",
|
|
464
|
+
required: true,
|
|
465
|
+
attributes: {
|
|
466
|
+
options: table.fields
|
|
467
|
+
.filter((f) => !f.calculated || f.stored)
|
|
468
|
+
.map((f) => ({
|
|
469
|
+
label: f.name,
|
|
470
|
+
name: `${f.name}@${f.type_name}`,
|
|
471
|
+
})),
|
|
472
|
+
},
|
|
473
|
+
showIf: {
|
|
474
|
+
agg_relation: aggKey,
|
|
475
|
+
expression_type: "Aggregation",
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
agg_order_opts.push({
|
|
479
|
+
name: `agg_order_by`,
|
|
480
|
+
label: req.__("Order by"),
|
|
481
|
+
type: "String",
|
|
482
|
+
attributes: {
|
|
483
|
+
options: table.fields
|
|
484
|
+
.filter((f) => !f.calculated || f.stored)
|
|
485
|
+
.map((f) => ({
|
|
486
|
+
label: f.name,
|
|
487
|
+
name: f.name,
|
|
488
|
+
})),
|
|
489
|
+
},
|
|
490
|
+
showIf: {
|
|
491
|
+
agg_relation: aggKey,
|
|
492
|
+
expression_type: "Aggregation",
|
|
493
|
+
aggregate: "Array_Agg",
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
});
|
|
478
497
|
return new Form({
|
|
479
498
|
fields: [
|
|
480
499
|
{
|
|
@@ -520,6 +539,7 @@ const fieldFlow = (req) =>
|
|
|
520
539
|
required: false,
|
|
521
540
|
showIf: { expression_type: "Aggregation" },
|
|
522
541
|
},
|
|
542
|
+
...agg_order_opts,
|
|
523
543
|
{
|
|
524
544
|
name: "model",
|
|
525
545
|
label: req.__("Model"),
|
|
@@ -1157,7 +1177,7 @@ router.post(
|
|
|
1157
1177
|
else res.send(fv.run(result, req, { row, ...configuration }));
|
|
1158
1178
|
} catch (e) {
|
|
1159
1179
|
console.error("show-calculated error", e);
|
|
1160
|
-
return res.status(
|
|
1180
|
+
return res.status(200).send(``);
|
|
1161
1181
|
}
|
|
1162
1182
|
})
|
|
1163
1183
|
);
|
package/routes/plugins.js
CHANGED
|
@@ -1315,7 +1315,12 @@ router.get(
|
|
|
1315
1315
|
await upgrade_all_tenants_plugins((p, f) =>
|
|
1316
1316
|
load_plugins.loadPlugin(p, f)
|
|
1317
1317
|
);
|
|
1318
|
-
req.flash(
|
|
1318
|
+
req.flash(
|
|
1319
|
+
"success",
|
|
1320
|
+
req.__(`Modules up-to-date. Please restart server`) +
|
|
1321
|
+
". " +
|
|
1322
|
+
a({ href: "/admin/system" }, req.__("Restart here"))
|
|
1323
|
+
);
|
|
1319
1324
|
} else {
|
|
1320
1325
|
const installed_plugins = await Plugin.find({});
|
|
1321
1326
|
for (const plugin of installed_plugins) {
|
package/routes/tables.js
CHANGED
package/routes/utils.js
CHANGED
|
@@ -14,7 +14,7 @@ const {
|
|
|
14
14
|
} = require("@saltcorn/data/db/state");
|
|
15
15
|
const { get_base_url } = require("@saltcorn/data/models/config");
|
|
16
16
|
const { hash } = require("@saltcorn/data/utils");
|
|
17
|
-
const { input, script, domReady } = require("@saltcorn/markup/tags");
|
|
17
|
+
const { input, script, domReady, a } = require("@saltcorn/markup/tags");
|
|
18
18
|
const session = require("express-session");
|
|
19
19
|
const cookieSession = require("cookie-session");
|
|
20
20
|
const is = require("contractis/is");
|
|
@@ -398,7 +398,10 @@ const admin_config_route = ({
|
|
|
398
398
|
if (restart_required)
|
|
399
399
|
res.json({
|
|
400
400
|
success: "ok",
|
|
401
|
-
notify:
|
|
401
|
+
notify:
|
|
402
|
+
req.__("Restart required for changes to take effect.") +
|
|
403
|
+
" " +
|
|
404
|
+
a({ href: "/admin/system" }, req.__("Restart here")),
|
|
402
405
|
});
|
|
403
406
|
else res.json({ success: "ok" });
|
|
404
407
|
}
|
package/tests/plugins.test.js
CHANGED
|
@@ -137,8 +137,10 @@ describe("Plugin dependency resolution and upgrade", () => {
|
|
|
137
137
|
.expect(toRedirect("/plugins"));
|
|
138
138
|
const quill = await Plugin.findOne({ name: "quill-editor" });
|
|
139
139
|
expect(quill.location).toBe("@saltcorn/quill-editor");
|
|
140
|
+
expect(quill.name).toBe("quill-editor");
|
|
140
141
|
const html = await Plugin.findOne({ location: "@saltcorn/html" });
|
|
141
142
|
expect(html.location).toBe("@saltcorn/html");
|
|
143
|
+
expect(html.name).toBe("html");
|
|
142
144
|
const html_type = getState().types.HTML;
|
|
143
145
|
expect(!!html_type.fieldviews.Quill).toBe(true);
|
|
144
146
|
});
|