@saltcorn/server 0.8.5-beta.0 → 0.8.5-beta.2

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 CHANGED
@@ -57,7 +57,8 @@ const getUserFields = async (req) => {
57
57
  (signup_form.configuration.columns || []).forEach((f) => {
58
58
  const uf = userFields.find((uff) => uff.name === f.field_name);
59
59
  if (uf) {
60
- if (!f?.fieldview?.unsuitableAsAdminDefault) {
60
+ const fvObj = uf.type?.fieldviews?.[uf.fieldview];
61
+ if (fvObj && !fvObj?.fieldview?.unsuitableAsAdminDefault) {
61
62
  uf.fieldview = f.fieldview;
62
63
  uf.attributes = { ...f.configuration, ...uf.attributes };
63
64
  }
@@ -68,6 +69,7 @@ const getUserFields = async (req) => {
68
69
  };
69
70
  await iterForm("signup_form");
70
71
  await iterForm("new_user_form");
72
+ //console.log(userFields);
71
73
  for (const f of userFields) {
72
74
  await f.fill_fkey_options();
73
75
  if (f.name === "email") {
package/locales/en.json CHANGED
@@ -1105,5 +1105,7 @@
1105
1105
  "Tag entry": "Tag entry",
1106
1106
  "Clear": "Clear",
1107
1107
  "Restore a snapshot": "Restore a snapshot",
1108
- "Snapshot restored": "Snapshot restored"
1108
+ "Snapshot restored": "Snapshot restored",
1109
+ "Configuration check report": "Configuration check report",
1110
+ "Re-run": "Re-run"
1109
1111
  }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@saltcorn/server",
3
- "version": "0.8.5-beta.0",
3
+ "version": "0.8.5-beta.2",
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.8.5-beta.0",
10
- "@saltcorn/builder": "0.8.5-beta.0",
11
- "@saltcorn/data": "0.8.5-beta.0",
12
- "@saltcorn/admin-models": "0.8.5-beta.0",
13
- "@saltcorn/filemanager": "0.8.5-beta.0",
14
- "@saltcorn/markup": "0.8.5-beta.0",
15
- "@saltcorn/sbadmin2": "0.8.5-beta.0",
9
+ "@saltcorn/base-plugin": "0.8.5-beta.2",
10
+ "@saltcorn/builder": "0.8.5-beta.2",
11
+ "@saltcorn/data": "0.8.5-beta.2",
12
+ "@saltcorn/admin-models": "0.8.5-beta.2",
13
+ "@saltcorn/filemanager": "0.8.5-beta.2",
14
+ "@saltcorn/markup": "0.8.5-beta.2",
15
+ "@saltcorn/sbadmin2": "0.8.5-beta.2",
16
16
  "@socket.io/cluster-adapter": "^0.2.1",
17
17
  "@socket.io/sticky": "^1.0.1",
18
18
  "adm-zip": "0.5.10",
@@ -227,7 +227,6 @@ footer.bs-mobile-nav-footer {
227
227
 
228
228
  .containerbgimage {
229
229
  position: absolute;
230
- top: 0;
231
230
  left: 0;
232
231
  width: 100%;
233
232
  height: 100%;
@@ -372,7 +371,7 @@ table.table-inner-grid td {
372
371
  }
373
372
 
374
373
  .join-table-header {
375
- padding: 0.25rem 1rem;
374
+ padding: 0.25rem 1rem;
376
375
  margin-bottom: 0 !important;
377
376
  text-decoration: underline;
378
- }
377
+ }
@@ -320,6 +320,7 @@ function saveAndContinue(e, k) {
320
320
  data: form_data,
321
321
  success: function (res) {
322
322
  ajax_indicator(false);
323
+ form.parent().find(".full-form-error").text("");
323
324
  if (res.id && form.find("input[name=id")) {
324
325
  form.append(
325
326
  `<input type="hidden" class="form-control " name="id" value="${res.id}">`
@@ -327,9 +328,23 @@ function saveAndContinue(e, k) {
327
328
  }
328
329
  },
329
330
  error: function (request) {
330
- $("#page-inner-content").html(request.responseText);
331
+ var ct = request.getResponseHeader("content-type") || "";
332
+ if (ct.startsWith && ct.startsWith("application/json")) {
333
+ var errorArea = form.parent().find(".full-form-error");
334
+ if (errorArea.length) {
335
+ errorArea.text(request.responseJSON.error);
336
+ } else {
337
+ form
338
+ .parent()
339
+ .append(
340
+ `<p class="text-danger full-form-error">${request.responseJSON.error}</p>`
341
+ );
342
+ }
343
+ } else {
344
+ $("#page-inner-content").html(request.responseText);
345
+ initialize_page();
346
+ }
331
347
  ajax_indicate_error(e, request);
332
- initialize_page();
333
348
  },
334
349
  complete: function () {
335
350
  if (k) k();
package/routes/actions.js CHANGED
@@ -41,6 +41,7 @@ const {
41
41
  h6,
42
42
  pre,
43
43
  text,
44
+ i,
44
45
  } = require("@saltcorn/markup/tags");
45
46
  const Table = require("@saltcorn/data/models/table");
46
47
  const { getActionConfigFields } = require("@saltcorn/data/plugin-helper");
@@ -510,17 +511,20 @@ router.post(
510
511
  });
511
512
  form.validate(req.body);
512
513
  if (form.hasErrors) {
513
- send_events_page({
514
- res,
515
- req,
516
- active_sub: "Triggers",
517
- sub2_page: "Configure",
518
- contents: {
519
- type: "card",
520
- title: req.__("Configure trigger"),
521
- contents: renderForm(form, req.csrfToken()),
522
- },
523
- });
514
+ if (req.xhr) {
515
+ res.status(400).json({ error: form.errorSummary });
516
+ } else
517
+ send_events_page({
518
+ res,
519
+ req,
520
+ active_sub: "Triggers",
521
+ sub2_page: "Configure",
522
+ contents: {
523
+ type: "card",
524
+ title: req.__("Configure trigger"),
525
+ contents: renderForm(form, req.csrfToken()),
526
+ },
527
+ });
524
528
  } else {
525
529
  await Trigger.update(trigger.id, { configuration: form.values });
526
530
  if (req.xhr) {
@@ -598,6 +602,7 @@ router.get(
598
602
  user: req.user,
599
603
  });
600
604
  } catch (e) {
605
+ console.error(e);
601
606
  fakeConsole.error(e.message);
602
607
  }
603
608
  if (output.length === 0) {
@@ -622,8 +627,16 @@ router.get(
622
627
  div({ class: "testrunoutput" }, output),
623
628
 
624
629
  a(
625
- { href: `/actions`, class: "mt-4 btn btn-primary" },
630
+ { href: `/actions`, class: "mt-4 btn btn-primary me-1" },
626
631
  "&laquo;&nbsp;" + req.__("back to actions")
632
+ ),
633
+ a(
634
+ {
635
+ href: `/actions/testrun/${id}`,
636
+ class: "ms-1 mt-4 btn btn-primary",
637
+ },
638
+ i({ class: "fas fa-redo me-1" }),
639
+ req.__("Re-run")
627
640
  )
628
641
  ),
629
642
  },
package/routes/admin.js CHANGED
@@ -40,6 +40,7 @@ const {
40
40
  p,
41
41
  code,
42
42
  h5,
43
+ h3,
43
44
  pre,
44
45
  button,
45
46
  form,
@@ -100,6 +101,7 @@ const os = require("os");
100
101
  const Page = require("@saltcorn/data/models/page");
101
102
  const { getSafeSaltcornCmd } = require("@saltcorn/data/utils");
102
103
  const stream = require("stream");
104
+ const Crash = require("@saltcorn/data/models/crash");
103
105
 
104
106
  const router = new Router();
105
107
  module.exports = router;
@@ -892,7 +894,6 @@ router.get(
892
894
  {
893
895
  href: "/admin/configuration-check",
894
896
  class: "btn btn-info",
895
- onClick: "press_store_button(this)",
896
897
  },
897
898
  i({ class: "fas fa-stethoscope" }),
898
899
  " ",
@@ -1306,49 +1307,74 @@ router.get(
1306
1307
  "/configuration-check",
1307
1308
  isAdmin,
1308
1309
  error_catcher(async (req, res) => {
1309
- const { passes, errors, pass, warnings } = await runConfigurationCheck(req);
1310
- const mkError = (err) =>
1311
- div(
1312
- { class: "alert alert-danger", role: "alert" },
1313
- pre({ class: "mb-0" }, code(err))
1310
+ const filename = `${moment().format("YYYMMDDHHmm")}.html`;
1311
+ await File.new_folder("configuration_checks");
1312
+ const go = async () => {
1313
+ const { passes, errors, pass, warnings } = await runConfigurationCheck(
1314
+ req
1314
1315
  );
1315
- const mkWarning = (err) =>
1316
- div(
1317
- { class: "alert alert-warning", role: "alert" },
1318
- pre({ class: "mb-0" }, code(err))
1316
+ const mkError = (err) =>
1317
+ div(
1318
+ { class: "alert alert-danger", role: "alert" },
1319
+ pre({ class: "mb-0" }, code(err))
1320
+ );
1321
+ const mkWarning = (err) =>
1322
+ div(
1323
+ { class: "alert alert-warning", role: "alert" },
1324
+ pre({ class: "mb-0" }, code(err))
1325
+ );
1326
+
1327
+ const report =
1328
+ div(
1329
+ h3("Errors"),
1330
+ pass
1331
+ ? div(req.__("No errors detected during configuration check"))
1332
+ : errors.map(mkError)
1333
+ ) +
1334
+ div(
1335
+ h3("Warnings"),
1336
+ (warnings || []).length
1337
+ ? (warnings || []).map(mkWarning)
1338
+ : "No warnings"
1339
+ ) +
1340
+ div(
1341
+ h3("Passes"),
1342
+
1343
+ pre(code(passes.join("\n")))
1344
+ );
1345
+ await File.from_contents(
1346
+ filename,
1347
+ "text/html",
1348
+ report,
1349
+ req.user.id,
1350
+ 1,
1351
+ "/configuration_checks"
1319
1352
  );
1353
+ };
1354
+ go().catch((err) => Crash.create(err, req));
1320
1355
  res.sendWrap(req.__(`Admin`), {
1321
1356
  above: [
1322
1357
  {
1323
1358
  type: "breadcrumbs",
1324
1359
  crumbs: [
1325
1360
  { text: req.__("Settings") },
1326
- { text: req.__("Admin"), href: "/admin" },
1361
+ { text: req.__("About application"), href: "/admin" },
1362
+ { text: req.__("System"), href: "/admin/system" },
1327
1363
  { text: req.__("Configuration check") },
1328
1364
  ],
1329
1365
  },
1366
+
1330
1367
  {
1331
1368
  type: "card",
1332
- title: req.__("Configuration errors"),
1369
+ title: req.__("Configuration check report"),
1333
1370
  contents: div(
1334
- pass
1335
- ? div(
1336
- { class: "alert alert-success", role: "alert" },
1337
- i({ class: "fas fa-check-circle fa-lg me-2" }),
1338
- h5(
1339
- { class: "d-inline" },
1340
- req.__("No errors detected during configuration check")
1341
- )
1342
- )
1343
- : errors.map(mkError),
1344
- (warnings || []).map(mkWarning)
1371
+ "When completed, the report will be ready here: ",
1372
+ a(
1373
+ { href: `/files/serve/configuration_checks/${filename}` },
1374
+ "/configuration_checks/" + filename
1375
+ )
1345
1376
  ),
1346
1377
  },
1347
- {
1348
- type: "card",
1349
- title: req.__("Configuration checks passed"),
1350
- contents: div(pre(code(passes.join("\n")))),
1351
- },
1352
1378
  ],
1353
1379
  });
1354
1380
  })