@saltcorn/server 0.8.5-beta.1 → 0.8.5-beta.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/routes/utils.js CHANGED
@@ -18,6 +18,24 @@ const cookieSession = require("cookie-session");
18
18
  const is = require("contractis/is");
19
19
  const { validateHeaderName, validateHeaderValue } = require("http");
20
20
  const Crash = require("@saltcorn/data/models/crash");
21
+ const si = require("systeminformation");
22
+
23
+ const get_sys_info = async () => {
24
+ const disks = await si.fsSize();
25
+ let size = 0;
26
+ let used = 0;
27
+ disks.forEach((d) => {
28
+ if (d && d.used && d.size) {
29
+ size += d.size;
30
+ used += d.used;
31
+ }
32
+ });
33
+ const diskUsage = Math.round(100 * (used / size));
34
+ const simem = await si.mem();
35
+ const memUsage = Math.round(100 - 100 * (simem.available / simem.total));
36
+ const cpuUsage = Math.round((await si.currentLoad()).currentLoad);
37
+ return { memUsage, diskUsage, cpuUsage };
38
+ };
21
39
 
22
40
  /**
23
41
  * Checks that user logged or not.
@@ -314,4 +332,5 @@ module.exports = {
314
332
  get_tenant_from_req,
315
333
  addOnDoneRedirect,
316
334
  is_relative_url,
335
+ get_sys_info,
317
336
  };
@@ -198,11 +198,11 @@ Gordon Kane, 217`;
198
198
  .set("Cookie", loginCookie)
199
199
  .expect(toInclude("books constraints"));
200
200
  await request(app)
201
- .get("/table/add-constraint/" + id)
201
+ .get("/table/add-constraint/" + id + "/Unique")
202
202
  .set("Cookie", loginCookie)
203
203
  .expect(toInclude("Add constraint to books"));
204
204
  await request(app)
205
- .post("/table/add-constraint/" + id)
205
+ .post("/table/add-constraint/" + id + "/Unique")
206
206
  .send("author=on")
207
207
  .send("pages=on")
208
208
  .set("Cookie", loginCookie)