@saltcorn/server 0.8.3-beta.2 → 0.8.3

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/locales/da.json CHANGED
@@ -683,5 +683,26 @@
683
683
  "Pages are the web pages of your application built with a drag-and-drop builder. They have static content, and by embedding views, dynamic content.": "Pages are the web pages of your application built with a drag-and-drop builder. They have static content, and by embedding views, dynamic content.",
684
684
  "Triggers run actions in response to events.": "Triggers run actions in response to events.",
685
685
  "No triggers": "No triggers",
686
- "Code": "Code"
686
+ "Code": "Code",
687
+ "Invalid form data, try again": "Invalid form data, try again",
688
+ "View pattern": "View pattern",
689
+ "The view pattern sets the foundation of how the view relates to the table and the behaviour of the view": "The view pattern sets the foundation of how the view relates to the table and the behaviour of the view",
690
+ "Slug": "Slug",
691
+ "Field that can be used for a prettier URL structure": "Field that can be used for a prettier URL structure",
692
+ "Column width": "Column width",
693
+ "Units": "Units",
694
+ "Save indicator": "Save indicator",
695
+ "%s view - %s on %s": "%s view - %s on %s",
696
+ "URL after delete": "URL after delete",
697
+ "Save before going back": "Save before going back",
698
+ "Reload after going back": "Reload after going back",
699
+ "Steps to go back": "Steps to go back",
700
+ "No row selected": "No row selected",
701
+ "Finish": "Finish",
702
+ "Back": "Back",
703
+ "Preview": "Preview",
704
+ "Tables organise data by fields and rows.": "Tables organise data by fields and rows.",
705
+ "Views display data from tables. A view is a view pattern applied to a table, with configuration.": "Views display data from tables. A view is a view pattern applied to a table, with configuration.",
706
+ "No views": "No views",
707
+ "No pages": "No pages"
687
708
  }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@saltcorn/server",
3
- "version": "0.8.3-beta.2",
3
+ "version": "0.8.3",
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.3-beta.2",
10
- "@saltcorn/builder": "0.8.3-beta.2",
11
- "@saltcorn/data": "0.8.3-beta.2",
12
- "@saltcorn/admin-models": "0.8.3-beta.2",
13
- "@saltcorn/filemanager": "0.8.3-beta.2",
14
- "@saltcorn/markup": "0.8.3-beta.2",
15
- "@saltcorn/sbadmin2": "0.8.3-beta.2",
9
+ "@saltcorn/base-plugin": "0.8.3",
10
+ "@saltcorn/builder": "0.8.3",
11
+ "@saltcorn/data": "0.8.3",
12
+ "@saltcorn/admin-models": "0.8.3",
13
+ "@saltcorn/filemanager": "0.8.3",
14
+ "@saltcorn/markup": "0.8.3",
15
+ "@saltcorn/sbadmin2": "0.8.3",
16
16
  "@socket.io/cluster-adapter": "^0.2.1",
17
17
  "@socket.io/sticky": "^1.0.1",
18
18
  "adm-zip": "0.5.10",
@@ -409,10 +409,14 @@ function initialize_page() {
409
409
  $("[data-inline-edit-dest-url]").click(function () {
410
410
  var url = $(this).attr("data-inline-edit-dest-url");
411
411
  var current = $(this).children("span.current").html();
412
+ var key = $(this).attr("data-inline-edit-field") || "value";
413
+ var ajax = !!$(this).attr("data-inline-edit-ajax");
412
414
  $(this).replaceWith(
413
- `<form method="post" action="${url}" >
415
+ `<form method="post" action="${url}" ${
416
+ ajax ? `onsubmit="inline_ajax_submit(event)"` : ""
417
+ }>
414
418
  <input type="hidden" name="_csrf" value="${_sc_globalCsrf}">
415
- <input type="text" name="value" value="${current}">
419
+ <input type="text" name="${key}" value="${current}">
416
420
  <button type="submit" class="btn btn-sm btn-primary">OK</button>
417
421
  </form>`
418
422
  );
@@ -527,6 +531,28 @@ function initialize_page() {
527
531
 
528
532
  $(initialize_page);
529
533
 
534
+ function inline_ajax_submit(e) {
535
+ e.preventDefault();
536
+ var form = $(e.target).closest("form");
537
+ var form_data = form.serialize();
538
+ var url = form.attr("action");
539
+ $.ajax(url, {
540
+ type: "POST",
541
+ headers: {
542
+ "CSRF-Token": _sc_globalCsrf,
543
+ },
544
+ data: form_data,
545
+ success: function (res) {
546
+ location.reload();
547
+ },
548
+ error: function (e) {
549
+ ajax_done(
550
+ e.responseJSON || { error: "Unknown error: " + e.responseText }
551
+ );
552
+ },
553
+ });
554
+ }
555
+
530
556
  function ajax_indicator(show, e) {
531
557
  const $ind = e
532
558
  ? $(e).closest(".card,.modal").find(".sc-ajax-indicator")
package/routes/files.js CHANGED
@@ -201,6 +201,12 @@ router.get(
201
201
  if (file.s3_store) s3storage.serveObject(file, res, false);
202
202
  else res.sendFile(file.location);
203
203
  } else {
204
+ getState().log(
205
+ 5,
206
+ `File serve denied. path=${serve_path} file_exists=${!!file} file_min_role=${
207
+ file?.min_role_read
208
+ } role=${role} user_id=${user_id}`
209
+ );
204
210
  res
205
211
  .status(404)
206
212
  .sendWrap(req.__("Not found"), h1(req.__("File not found")));
@@ -32,10 +32,9 @@ const { get_base_url } = require("./utils.js");
32
32
  const tableTable = (tables, req) =>
33
33
  mkTable(
34
34
  [
35
- { label: req.__("Name"), key: "name" },
36
35
  {
37
- label: req.__("Edit"),
38
- key: (r) => link(`/table/${r.id}`, req.__("Edit")),
36
+ label: req.__("Name"),
37
+ key: (r) => link(`/table/${r.id}`, r.name),
39
38
  },
40
39
  ],
41
40
  tables
package/routes/page.js CHANGED
@@ -40,12 +40,18 @@ router.get(
40
40
  const { pagename } = req.params;
41
41
  const state = getState();
42
42
  state.log(3, `Route /page/${pagename} user=${req.user?.id}`);
43
+ const tic = state.logLevel >= 5 ? new Date() : null;
43
44
 
44
45
  const role = req.user && req.user.id ? req.user.role_id : 10;
45
46
  const db_page = await Page.findOne({ name: pagename });
46
47
  if (db_page && role <= db_page.min_role) {
47
48
  const contents = await db_page.run(req.query, { res, req });
48
49
  const title = scan_for_page_title(contents, db_page.title);
50
+ if (tic) {
51
+ const tock = new Date();
52
+ const ms = tock.getTime() - tic.getTime();
53
+ state.log(5, `Page ${pagename} rendered in ${ms} ms`);
54
+ }
49
55
  res.sendWrap(
50
56
  {
51
57
  title,
@@ -229,7 +229,7 @@ router.get(
229
229
  "/",
230
230
  isAdmin,
231
231
  error_catcher(async (req, res) => {
232
- const pages = await Page.find({}, { orderBy: "name" });
232
+ const pages = await Page.find({}, { orderBy: "name", nocase: true });
233
233
  const roles = await User.get_roles();
234
234
 
235
235
  res.sendWrap(req.__("Pages"), {
package/routes/tables.js CHANGED
@@ -1030,7 +1030,10 @@ router.get(
1030
1030
  "/",
1031
1031
  isAdmin,
1032
1032
  error_catcher(async (req, res) => {
1033
- const rows = await Table.find_with_external({}, { orderBy: "name" });
1033
+ const rows = await Table.find_with_external(
1034
+ {},
1035
+ { orderBy: "name", nocase: true }
1036
+ );
1034
1037
  const roles = await User.get_roles();
1035
1038
  const getRole = (rid) => roles.find((r) => r.id === rid).role;
1036
1039
  const mainCard = await tablesList(rows, req);
package/routes/view.js CHANGED
@@ -51,6 +51,7 @@ router.get(
51
51
  res.redirect("/");
52
52
  return;
53
53
  }
54
+ const tic = state.logLevel >= 5 ? new Date() : null;
54
55
 
55
56
  view.rewrite_query_from_slug(query, req.params);
56
57
  if (
@@ -82,6 +83,11 @@ router.get(
82
83
  );
83
84
  if (isModal && view.attributes?.popup_save_indicator)
84
85
  res.set("SaltcornModalSaveIndicator", `true`);
86
+ if (tic) {
87
+ const tock = new Date();
88
+ const ms = tock.getTime() - tic.getTime();
89
+ state.log(5, `View ${viewname} rendered in ${ms} ms`);
90
+ }
85
91
  res.sendWrap(
86
92
  title,
87
93
  add_edit_bar({