slimsdk 0.1.55 → 0.2.0

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.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/dist/desktop/index.d.ts +13 -12
  3. package/dist/desktop/index.js +1228 -1967
  4. package/dist/desktop/index.js.map +1 -1
  5. package/dist/index-3POan8Vl.d.ts +94 -0
  6. package/dist/index-B4158M0u.d.ts +21 -0
  7. package/dist/index-BAQxKstM.d.ts +8 -0
  8. package/dist/index-BMqjxP9I.d.ts +11 -0
  9. package/dist/index-CD53Vh6h.d.ts +31 -0
  10. package/dist/index-CoYHkkyT.d.ts +14 -0
  11. package/dist/index-D5CUpF9v.d.ts +10 -0
  12. package/dist/index-DBhzpIiB.d.ts +32 -0
  13. package/dist/index-DCw_tM-R.d.ts +28 -0
  14. package/dist/{index-kr8P3eEW.d.ts → index-DWqF-tKY.d.ts} +7 -9
  15. package/dist/index-DzKPF0ja.d.ts +14 -0
  16. package/dist/index-jVam7Sxi.d.ts +15 -0
  17. package/dist/index-uQOR5bdy.d.ts +20 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/lib/index.d.ts +1 -1
  22. package/dist/lib/index.js +1 -1
  23. package/dist/lib/index.js.map +1 -1
  24. package/dist/mobile/index.d.ts +13 -12
  25. package/dist/mobile/index.js +299 -808
  26. package/dist/mobile/index.js.map +1 -1
  27. package/dist/mod/button/index.d.ts +1 -1
  28. package/dist/mod/button/index.js +2 -2
  29. package/dist/mod/button/index.js.map +1 -1
  30. package/dist/mod/config/index.d.ts +52 -0
  31. package/dist/mod/{global → config}/index.js +45 -41
  32. package/dist/mod/config/index.js.map +1 -0
  33. package/dist/mod/cover/index.d.ts +1 -1
  34. package/dist/mod/cover/index.js +3 -3
  35. package/dist/mod/cover/index.js.map +1 -1
  36. package/dist/mod/dialog/index.d.ts +1 -1
  37. package/dist/mod/dialog/index.js +13 -13
  38. package/dist/mod/dialog/index.js.map +1 -1
  39. package/dist/mod/drawer/index.d.ts +1 -1
  40. package/dist/mod/drawer/index.js +8 -8
  41. package/dist/mod/drawer/index.js.map +1 -1
  42. package/dist/mod/drop/index.d.ts +1 -1
  43. package/dist/mod/drop/index.js +15 -15
  44. package/dist/mod/drop/index.js.map +1 -1
  45. package/dist/mod/hwlink/index.d.ts +2 -2
  46. package/dist/mod/hwlink/index.js +44 -656
  47. package/dist/mod/hwlink/index.js.map +1 -1
  48. package/dist/mod/index.d.ts +7 -7
  49. package/dist/mod/index.js +61 -59
  50. package/dist/mod/index.js.map +1 -1
  51. package/dist/mod/modal/index.d.ts +1 -1
  52. package/dist/mod/modal/index.js +12 -12
  53. package/dist/mod/modal/index.js.map +1 -1
  54. package/dist/mod/tabs/index.d.ts +1 -1
  55. package/dist/mod/tabs/index.js +8 -6
  56. package/dist/mod/tabs/index.js.map +1 -1
  57. package/dist/page/desktop/index.d.ts +3 -3
  58. package/dist/page/desktop/index.js +228 -801
  59. package/dist/page/desktop/index.js.map +1 -1
  60. package/dist/page/index.d.ts +7 -7
  61. package/dist/page/index.js +12 -12
  62. package/dist/page/index.js.map +1 -1
  63. package/dist/page/mobile/index.d.ts +2 -2
  64. package/dist/page/mobile/index.js +14 -14
  65. package/dist/page/mobile/index.js.map +1 -1
  66. package/dist/worker/hubworker.js +1 -1
  67. package/dist/worker/hubworker.js.map +1 -1
  68. package/package.json +6 -6
  69. package/dist/index-B2HHS23A.d.ts +0 -20
  70. package/dist/index-BQcJsVJ-.d.ts +0 -10
  71. package/dist/index-Bf_lg-oZ.d.ts +0 -339
  72. package/dist/index-ChdqOPJq.d.ts +0 -15
  73. package/dist/index-CzsSwSvp.d.ts +0 -21
  74. package/dist/index-D3tu8t6p.d.ts +0 -28
  75. package/dist/index-DQt71MNx.d.ts +0 -31
  76. package/dist/index-DZdXvqxA.d.ts +0 -10
  77. package/dist/index-DcvauYN8.d.ts +0 -14
  78. package/dist/index-Pd7FTiEW.d.ts +0 -32
  79. package/dist/index-QRbamarh.d.ts +0 -8
  80. package/dist/mod/global/index.d.ts +0 -57
  81. package/dist/mod/global/index.js.map +0 -1
@@ -1,11 +1,16 @@
1
- // src/mod/global.ts
2
- var gbvar = {
1
+ // src/config/global.ts
2
+ var app = document.querySelector("#app");
3
+
4
+ // src/config/index.ts
5
+ var cfg = {
3
6
  UNIX_TIME: 0,
4
7
  app: {
5
8
  UUID: "",
6
9
  NAME: "",
10
+ SECRET: "",
7
11
  VERSION: "",
8
- RELEASE: ""
12
+ RELEASE: "",
13
+ CALLBACK: ""
9
14
  },
10
15
  api: {
11
16
  URL: "",
@@ -23,21 +28,20 @@ var gbvar = {
23
28
  FILE: "https://wkrh.info/app/hwlink/hwlink_setup.exe"
24
29
  },
25
30
  user: {
26
- ACCT: 0,
27
- ACTYPE: 0,
28
- ACROLE: 0,
29
- ACNAME: "",
30
- PICTURE: "",
31
- AGCY: 0,
32
- DVSN: 0,
33
- SECT: 0,
34
- DEPT: "0,0",
35
- AGCY_NAME: "",
36
- DVSN_NAME: "",
37
- SECT_NAME: ""
31
+ sub: 0,
32
+ name: "",
33
+ utyp: "",
34
+ unit: "",
35
+ unit_id: 0,
36
+ role_id: 0,
37
+ metadata: {
38
+ emp_type: "",
39
+ emp_level: "",
40
+ position: ""
41
+ },
42
+ picture: ""
38
43
  }
39
44
  };
40
- var app = document.querySelector("#app");
41
45
 
42
46
  // src/page/index.ts
43
47
  var app2 = document.querySelector("#app");
@@ -52,7 +56,7 @@ var pageSpin = (
52
56
  `
53
57
  );
54
58
  var smallSpin = `<div class="spinner s32"></div>`;
55
- var Loading = (size = "default") => {
59
+ var loading = (size = "default") => {
56
60
  if (!app2) return;
57
61
  if (!app2.querySelector("#page-loader")) {
58
62
  const loader = document.createElement("div");
@@ -64,7 +68,7 @@ var Loading = (size = "default") => {
64
68
  const content = app2.querySelector("#app-content");
65
69
  if (content) content.style.display = "none";
66
70
  };
67
- var Ready = (delay = 400) => {
71
+ var ready = (delay = 400) => {
68
72
  new Promise((r) => setTimeout(r, delay)).then(() => {
69
73
  clearLoader(true);
70
74
  });
@@ -80,281 +84,6 @@ var clearLoader = (showContent) => {
80
84
  if (content) content.style.display = showContent ? "block" : "none";
81
85
  };
82
86
 
83
- // src/mod/built-in/cover/index.ts
84
- var Loading2 = (cover, state = false, align = "top", hide = true) => {
85
- const inner = cover.querySelectorAll("*");
86
- if (state) {
87
- cover.querySelector(".cover-loader")?.remove();
88
- cover.style.position = "relative";
89
- if (hide) inner.forEach((el) => el.style.visibility = "hidden");
90
- const loader = document.createElement("div");
91
- loader.className = `cover-loader ${align}`;
92
- loader.innerHTML = `<div class="spinner s28"></div>`;
93
- cover.appendChild(loader);
94
- } else {
95
- new Promise((r) => setTimeout(r, 400)).then(() => {
96
- cover.querySelector(".cover-loader")?.remove();
97
- cover.style.position = "";
98
- inner.forEach((el) => el.style.visibility = "");
99
- });
100
- }
101
- };
102
-
103
- // src/mod/modal/index.ts
104
- var app3 = document.querySelector("#app");
105
- var tmpBtnSave = (
106
- /* html */
107
- `
108
- <button class="solid green" type="submit">
109
- <i>&#xf0c7;</i>\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01
110
- </button>
111
- `
112
- );
113
- var tmpBtnCancel = (
114
- /* html */
115
- `
116
- <button class="solid gray" type="button" id="btn-cancel">
117
- <i>&#xf057;</i>\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01
118
- </button>
119
- `
120
- );
121
- var tmpBtnClose = (
122
- /* html */
123
- `
124
- <button class="solid blue" type="button" id="btn-close">
125
- <i>&#xf057;</i>\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32
126
- </button>
127
- `
128
- );
129
- var Create = (params) => {
130
- const icon = params.icon ? params.icon : "&#xf40e;";
131
- const title = params.title ? params.title : "Modal Title";
132
- const body = params.body ? params.body : "Modal Body";
133
- const width = params.width ? params.width : "100%";
134
- const align = params.button?.align ? params.button?.align : "";
135
- const doc = params.target ? params.target : app3;
136
- let button = "";
137
- if (params.button?.cancel) button += tmpBtnCancel;
138
- if (params.button?.close) button += tmpBtnClose;
139
- if (params.button?.save) button += tmpBtnSave;
140
- const modal = document.createElement("div");
141
- modal.className = "overlay slim-modal";
142
- modal.innerHTML = /*html*/
143
- `
144
- <form>
145
- <div class="content" style="width: ${width};">
146
- <div class="header">
147
- <i class="icon pad">${icon}</i>${title}
148
- <button id="btn-exit" type="button"
149
- class="icon">&#xf00d;</button>
150
- </div>
151
- <div class="body">${body}</div>
152
- <div class="footer ${align}">${button}</div>
153
- <div class="loader">
154
- <div class="spinner s28"></div>
155
- </div>
156
- </div>
157
- </form>
158
- `;
159
- if (!doc) return modal;
160
- doc.appendChild(modal);
161
- if (width == "auto") {
162
- const content2 = modal.querySelector(".content");
163
- if (content2) content2.style.maxWidth = `450px`;
164
- }
165
- window.location.hash = "modal";
166
- const content = modal.querySelector(".content");
167
- content.classList.add("modal-in");
168
- modal.classList.add("overlay-in");
169
- content.addEventListener("animationend", () => {
170
- if (content.classList.contains("modal-in")) {
171
- content.classList.remove("modal-in");
172
- modal.classList.remove("overlay-in");
173
- }
174
- });
175
- const hashChange = () => {
176
- const hash = window.location.hash.replaceAll("#", "");
177
- if (hash != "modal") done();
178
- };
179
- const done = () => {
180
- destroy(modal);
181
- if (window.location.hash == "#modal") history.back();
182
- window.removeEventListener("hashchange", hashChange);
183
- };
184
- window.addEventListener("hashchange", hashChange);
185
- const btnExit = modal.querySelector("#btn-exit");
186
- const btnCancel = modal.querySelector("#btn-cancel");
187
- const btnClose = modal.querySelector("#btn-close");
188
- if (btnExit) {
189
- btnExit.focus();
190
- btnExit.onclick = done;
191
- }
192
- if (btnCancel) btnCancel.onclick = done;
193
- if (btnClose) btnClose.onclick = done;
194
- return modal;
195
- };
196
- var Close = (modal) => new Promise((resolve) => {
197
- modal.querySelector("#btn-exit").click();
198
- const content = modal.querySelector(".content");
199
- content.addEventListener("animationend", () => resolve());
200
- });
201
- var destroy = (modal) => {
202
- const content = modal.querySelector(".content");
203
- content.classList.add("modal-out");
204
- modal.classList.add("overlay-out");
205
- content.addEventListener("animationend", () => {
206
- if (content.classList.contains("modal-out")) {
207
- modal.style.display = "none";
208
- modal.remove();
209
- }
210
- });
211
- };
212
- var Loading3 = (modal) => {
213
- const body = modal.querySelector(".body");
214
- const loader = modal.querySelector(".loader");
215
- if (body) body.style.visibility = "hidden";
216
- if (loader) loader.style.display = "flex";
217
- };
218
- var Ready2 = (modal) => {
219
- const body = modal.querySelector(".body");
220
- const loader = modal.querySelector(".loader");
221
- if (body) body.style.visibility = "visible";
222
- if (loader) loader.style.display = "none";
223
- };
224
- var Hidden = (modal) => {
225
- modal.style.display = "none";
226
- };
227
- var Visible = (modal) => {
228
- modal.style.display = "block";
229
- };
230
-
231
- // src/mod/dialog/index.ts
232
- var app4 = document.querySelector("#app");
233
- var Confirm = (message, params) => new Promise((resolve) => {
234
- if (!app4) return;
235
- const doc = params && params?.target ? params.target : app4;
236
- const color = params && params?.color ? params.color : "green";
237
- const dialog = document.createElement("div");
238
- dialog.className = "overlay slim-dialog";
239
- dialog.innerHTML = /*html*/
240
- `
241
- <div class="confirm ${color}">
242
- <div class="header">
243
- <i class="icon solid">&#xf058;</i> Slim Confirm
244
- </div>
245
- <div class="message">${message}</div>
246
- <div class="footer">
247
- <button class="lg gray left" id="btn-no">
248
- <i>&#xf057;</i>\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01
249
- </button>
250
- <button class="lg ${color} right" id="btn-yes">
251
- <i>&#xf058;</i>\u0E15\u0E01\u0E25\u0E07
252
- </button>
253
- </div>
254
- </div>
255
- `;
256
- doc.appendChild(dialog);
257
- dialog.querySelector("#btn-yes").focus();
258
- dialog.querySelector("#btn-yes").onclick = () => {
259
- dialog.remove();
260
- resolve(true);
261
- };
262
- dialog.querySelector("#btn-no").onclick = () => {
263
- dialog.remove();
264
- resolve(false);
265
- };
266
- });
267
- var Alert = (message, params) => new Promise((resolve) => {
268
- if (!app4) return;
269
- const doc = params && params?.target ? params.target : app4;
270
- const type = params && params?.type ? params.type : "success";
271
- let color = "";
272
- let icon = "";
273
- if (type == "success") {
274
- color = "green";
275
- icon = "&#xf058;";
276
- }
277
- if (type == "failure") {
278
- color = "red";
279
- icon = "&#xf057;";
280
- }
281
- if (type == "warning") {
282
- color = "orange";
283
- icon = "&#xf06a;";
284
- }
285
- if (type == "info") {
286
- color = "blue";
287
- icon = "&#xf05a;";
288
- }
289
- const dialog = document.createElement("div");
290
- dialog.className = "overlay slim-dialog";
291
- dialog.innerHTML = /*html*/
292
- `
293
- <div class="alert ${color}">
294
- <div class="icon solid">${icon}</div>
295
- <div class="message">${message}</div>
296
- <div class="footer">
297
- <button class="lg ${color}" id="btn-yes">\u0E15\u0E01\u0E25\u0E07</button>
298
- </div>
299
- </div>
300
- `;
301
- doc.appendChild(dialog);
302
- dialog.querySelector("#btn-yes").focus();
303
- dialog.querySelector("#btn-yes").onclick = () => {
304
- dialog.remove();
305
- resolve();
306
- };
307
- });
308
- var Toast = (message, params) => new Promise((resolve) => {
309
- if (!app4) return;
310
- const doc = params && params?.target ? params.target : app4;
311
- const type = params && params?.type ? params.type : "success";
312
- let color = "";
313
- let icon = "";
314
- if (type == "success") {
315
- color = "green";
316
- icon = "&#xf058;";
317
- }
318
- if (type == "failure") {
319
- color = "red";
320
- icon = "&#xf057;";
321
- }
322
- if (type == "warning") {
323
- color = "orange";
324
- icon = "&#xf06a;";
325
- }
326
- if (type == "info") {
327
- color = "blue";
328
- icon = "&#xf05a;";
329
- }
330
- const toast = document.createElement("div");
331
- toast.className = `slim-toast ${color}`;
332
- toast.innerHTML = /*html*/
333
- `
334
- <i class="icon">${icon}</i>
335
- <span class="text">${message}</span>
336
- `;
337
- doc.appendChild(toast);
338
- toast.classList.add("show");
339
- let count = 0;
340
- toast.onanimationend = () => {
341
- count++;
342
- if (count == 2) {
343
- toast.remove();
344
- resolve();
345
- }
346
- };
347
- });
348
-
349
- // src/lib/utility.ts
350
- var strCheck = (str) => {
351
- let out = String(str);
352
- out = out.replaceAll("'", "\\'");
353
- out = out.replaceAll('"', '\\"');
354
- out = out.trim();
355
- return out;
356
- };
357
-
358
87
  // src/svchub/hwlink/template.ts
359
88
  var template = (
360
89
  /*html*/
@@ -382,19 +111,19 @@ var template = (
382
111
  <div id="device">
383
112
  <div class="box-tb">
384
113
  <div class="topic">\u0E2B\u0E19\u0E48\u0E27\u0E22\u0E07\u0E32\u0E19</div>
385
- <div class="text" id="agcy">:</div>
114
+ <div class="text" id="">:</div>
386
115
  </div>
387
116
  <div class="box-tb">
388
117
  <div class="topic">\u0E01\u0E25\u0E38\u0E48\u0E21\u0E07\u0E32\u0E19</div>
389
- <div class="text" id="dept">:</div>
118
+ <div class="text" id="">:</div>
390
119
  </div>
391
120
  <div class="box-tb">
392
121
  <div class="topic">\u0E0A\u0E37\u0E48\u0E2D\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C</div>
393
- <div class="text" id="dname">:</div>
122
+ <div class="text" id="">:</div>
394
123
  </div>
395
124
  <div class="box-tb">
396
125
  <div class="topic">\u0E40\u0E25\u0E02\u0E17\u0E23\u0E31\u0E1E\u0E22\u0E4C\u0E2A\u0E34\u0E19</div>
397
- <div class="text" id="assno">:</div>
126
+ <div class="text" id="">:</div>
398
127
  </div>
399
128
  <button id="btn-edit" class="circle sm blue"
400
129
  shadow="true">&#xf5ae;</button>
@@ -464,351 +193,26 @@ var template = (
464
193
  </style>
465
194
  `
466
195
  );
467
- var frmDevice = (
468
- /*html*/
469
- `
470
- <div id="frm-device" class="cover grid">
471
- <div class="input-box span">
472
- <select id="inp-agcy" required></select>
473
- <div class="label">\u0E2B\u0E19\u0E48\u0E27\u0E22\u0E07\u0E32\u0E19 *</div>
474
- </div>
475
- <div class="input-box span">
476
- <select id="inp-dept"></select>
477
- <div class="label">\u0E01\u0E25\u0E38\u0E48\u0E21\u0E07\u0E32\u0E19/\u0E2A\u0E48\u0E27\u0E19\u0E07\u0E32\u0E19</div>
478
- </div>
479
- <div class="input-box span">
480
- <input type="text" id="inp-name" maxlength="100" required>
481
- <div class="label">\u0E0A\u0E37\u0E48\u0E2D\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C *</div>
482
- </div>
483
- </div>
484
- <style>
485
- #frm-device {
486
- gap: 5px;
487
- }
488
- #frm-device .dvsn {
489
- font-weight: 600;
490
- }
491
- #frm-device .sect {
492
- font-style: italic;
493
- }
494
- </style>
495
- `
496
- );
497
-
498
- // src/svchub/api/agency/agcy.ts
499
- var Read = (agcy) => new Promise((resolve, reject) => {
500
- let url = `/agcy`;
501
- if (agcy) url = `/agcy/${agcy}`;
502
- fetch(gbvar.hub.API + url, {
503
- method: "GET",
504
- headers: gbvar.api.HEADERS
505
- }).then((resp) => {
506
- if (!resp.ok) throw resp;
507
- return resp.json();
508
- }).then((json) => {
509
- resolve(json);
510
- }).catch((err) => reject(err));
511
- });
512
- var Set = async (elm) => {
513
- elm.innerHTML = '<option value="">- \u0E40\u0E25\u0E37\u0E2D\u0E01 -</option>';
514
- await Read().then((resp) => {
515
- const data = resp.data;
516
- for (const val of data) {
517
- const name = val.short ? val.short : val.name;
518
- const opt = document.createElement("option");
519
- opt.value = `${val.id}`;
520
- opt.text = name;
521
- elm.appendChild(opt);
522
- }
523
- }).catch((err) => console.error(err));
524
- };
525
-
526
- // src/svchub/api/agency/dept.ts
527
- var Read2 = (agcy) => new Promise((resolve, reject) => {
528
- const url = `/agcy/${agcy}/dept`;
529
- fetch(gbvar.hub.API + url, {
530
- method: "GET",
531
- headers: gbvar.api.HEADERS
532
- }).then((resp) => {
533
- if (!resp.ok) throw resp;
534
- return resp.json();
535
- }).then((json) => {
536
- resolve(json);
537
- }).catch((err) => reject(err));
538
- });
539
- var Set2 = async (agcy, elm) => {
540
- elm.innerHTML = '<option value="">- \u0E40\u0E25\u0E37\u0E2D\u0E01 -</option>';
541
- await Read2(agcy).then((resp) => {
542
- const data = resp.data;
543
- for (const val of data) {
544
- const opt = document.createElement("option");
545
- opt.value = `${val.dvsn},${val.sect}`;
546
- if (val.sect == 0) {
547
- opt.text = `${val.name}`;
548
- opt.style.fontWeight = "600";
549
- } else {
550
- opt.text = `- ${val.name}`;
551
- opt.style.fontStyle = "italic";
552
- }
553
- elm.appendChild(opt);
554
- }
555
- }).catch((err) => console.error(err));
556
- };
557
-
558
- // src/svchub/api/account/index.ts
559
- var Read3 = (agcy, acct, params) => new Promise((resolve, reject) => {
560
- const status = params && params.status ? params.status : 1;
561
- let query = `?status=${status}`;
562
- if (params) {
563
- const dvsn = params.dvsn ? params.dvsn : 0;
564
- const sect = params.sect ? params.sect : 0;
565
- const actype = params.actype ? params.actype : 0;
566
- const acrole = params.acrole ? params.acrole : 0;
567
- if (dvsn) query += `&dvsn=${dvsn}`;
568
- if (sect) query += `&sect=${sect}`;
569
- if (actype) query += `&actype=${actype}`;
570
- if (acrole) query += `&acrole=${acrole}`;
571
- }
572
- let url = `/agcy/${agcy}/acct${query}`;
573
- if (acct) url = `/agcy/${agcy}/acct/${acct}`;
574
- fetch(gbvar.hub.API + url, {
575
- method: "GET",
576
- headers: gbvar.api.HEADERS
577
- }).then((resp) => {
578
- if (!resp.ok) throw resp;
579
- return resp.json();
580
- }).then((json) => {
581
- resolve(json);
582
- }).catch((err) => reject(err));
583
- });
584
- var Create2 = (agcy, params) => new Promise((resolve, reject) => {
585
- const url = `/agcy/${agcy}/acct`;
586
- fetch(gbvar.hub.API + url, {
587
- method: "POST",
588
- headers: gbvar.api.HEADERS,
589
- body: JSON.stringify(params)
590
- }).then((resp) => {
591
- if (!resp.ok) throw resp;
592
- return resp.json();
593
- }).then((json) => {
594
- resolve(json);
595
- }).catch((err) => reject(err));
596
- });
597
- var Update = (agcy, acct, params) => new Promise((resolve, reject) => {
598
- const url = `/agcy/${agcy}/acct/${acct}`;
599
- fetch(gbvar.hub.API + url, {
600
- method: "PUT",
601
- headers: gbvar.api.HEADERS,
602
- body: JSON.stringify(params)
603
- }).then((resp) => {
604
- if (!resp.ok) throw resp;
605
- return resp.json();
606
- }).then((json) => {
607
- resolve(json);
608
- }).catch((err) => reject(err));
609
- });
610
-
611
- // src/svchub/hwlink/device.ts
612
- var Create3 = (csid) => new Promise((resolve, reject) => {
613
- const modal = Create({
614
- title: "\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E04\u0E2D\u0E21\u0E1E\u0E34\u0E27\u0E40\u0E15\u0E2D\u0E23\u0E4C",
615
- icon: "&#xf390;",
616
- width: "400px",
617
- body: frmDevice,
618
- button: { save: true, cancel: true }
619
- });
620
- const inpAgcy = modal.querySelector("#inp-agcy");
621
- const inpDept = modal.querySelector("#inp-dept");
622
- const inpName = modal.querySelector("#inp-name");
623
- inpAgcy.onchange = () => {
624
- Set2(Number(inpAgcy.value), inpDept);
625
- };
626
- (async () => {
627
- await Set(inpAgcy);
628
- await Set2(Number(inpAgcy.value), inpDept);
629
- Ready2(modal);
630
- })();
631
- const form = modal.querySelector("form");
632
- if (form) form.onsubmit = async (e) => {
633
- e.preventDefault();
634
- Hidden(modal);
635
- const res = await Confirm("\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19.! \u0E01\u0E32\u0E23\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25");
636
- Visible(modal);
637
- if (res) {
638
- Loading3(modal);
639
- const newAgcy = Number(inpAgcy.value);
640
- const [dvsn, sect] = inpDept.value.split(",");
641
- const params = {
642
- agcy: newAgcy,
643
- dvsn: dvsn ? Number(dvsn) : 0,
644
- sect: sect ? Number(sect) : 0,
645
- actype: 2,
646
- // อุปกรณ์
647
- acrole: 8,
648
- // คอมพิวเตอร์
649
- acuuid: strCheck(csid),
650
- profile: {
651
- dvtype: 1,
652
- // คอมพิวเตอร์
653
- name: strCheck(inpName.value)
654
- }
655
- };
656
- await Create2(newAgcy, params).then(() => {
657
- Close(modal);
658
- Toast("\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 \u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08.!", { type: "success" });
659
- resolve();
660
- }).catch((err) => {
661
- Close(modal);
662
- Alert("\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14...!", { type: "failure" });
663
- reject(err);
664
- });
665
- }
666
- };
667
- });
668
- var Update2 = (agcy, acct, csid) => new Promise((resolve, reject) => {
669
- const modal = Create({
670
- title: "\u0E41\u0E01\u0E49\u0E44\u0E02\u0E23\u0E32\u0E22\u0E25\u0E30\u0E40\u0E2D\u0E35\u0E22\u0E14",
671
- icon: "&#xf390;",
672
- width: "400px",
673
- body: frmDevice,
674
- button: { save: true, cancel: true }
675
- });
676
- const inpAgcy = modal.querySelector("#inp-agcy");
677
- const inpDept = modal.querySelector("#inp-dept");
678
- const inpName = modal.querySelector("#inp-name");
679
- inpAgcy.onchange = () => {
680
- Set2(Number(inpAgcy.value), inpDept);
681
- };
682
- (async () => {
683
- await Read3(agcy, acct).then(async (resp) => {
684
- const data = resp.data;
685
- const profile = data.profile;
686
- await Set(inpAgcy);
687
- await Set2(data.agcy, inpDept);
688
- inpAgcy.value = String(data.agcy);
689
- inpDept.value = data.dvsn ? `${data.dvsn},${data.sect}` : "";
690
- inpName.value = profile.name;
691
- }).catch((err) => console.error(err));
692
- Ready2(modal);
693
- })();
694
- const form = modal.querySelector("form");
695
- if (form) form.onsubmit = async (e) => {
696
- e.preventDefault();
697
- Hidden(modal);
698
- const res = await Confirm("\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19.! \u0E01\u0E32\u0E23\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25");
699
- Visible(modal);
700
- if (res) {
701
- Loading3(modal);
702
- const newAgcy = Number(inpAgcy.value);
703
- const [dvsn, sect] = inpDept.value.split(",");
704
- const params = {
705
- agcy: newAgcy,
706
- dvsn: dvsn ? Number(dvsn) : 0,
707
- sect: sect ? Number(sect) : 0,
708
- actype: 2,
709
- // อุปกรณ์
710
- acrole: 8,
711
- // คอมพิวเตอร์
712
- acuuid: strCheck(csid),
713
- profile: {
714
- dvtype: 1,
715
- // คอมพิวเตอร์
716
- name: strCheck(inpName.value)
717
- }
718
- };
719
- await Update(agcy, acct, params).then(() => {
720
- Close(modal);
721
- Toast("\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 \u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08.!", { type: "success" });
722
- resolve();
723
- }).catch((err) => {
724
- Close(modal);
725
- Alert("\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14...!", { type: "failure" });
726
- reject(err);
727
- });
728
- }
729
- };
730
- });
731
- var PwdChk = () => new Promise((resolve) => {
732
- const modal = Create({
733
- title: "\u0E01\u0E23\u0E2D\u0E01\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19",
734
- icon: "&#xf084;",
735
- width: "230px",
736
- body: (
737
- /*html*/
738
- `
739
- <div class="cover">
740
- <input type="password" id="inp-pass"
741
- value="admin@wkr" style="width: 100%;">
742
- </div>
743
- `
744
- ),
745
- button: { save: true, cancel: true, align: "center" }
746
- });
747
- Ready2(modal);
748
- const inpPass = modal.querySelector("#inp-pass");
749
- inpPass?.focus();
750
- const form = modal.querySelector("form");
751
- if (form) form.onsubmit = async (e) => {
752
- e.preventDefault();
753
- const pass = inpPass?.value?.trim();
754
- if (pass === "admin@wkr") {
755
- await Close(modal);
756
- resolve(true);
757
- } else {
758
- await Alert("\u0E23\u0E2B\u0E31\u0E2A\u0E1C\u0E48\u0E32\u0E19.! \u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07", { type: "failure" });
759
- inpPass?.focus();
760
- }
761
- };
762
- });
763
196
 
764
197
  // src/svchub/hwlink/index.ts
765
- var app5 = document.querySelector("#app");
766
- var AGCY;
767
- var ACCT;
768
- var CSID;
198
+ var app3 = document.querySelector("#app");
769
199
  var isREADY;
770
200
  var WSSVC;
771
- var boxDv;
772
- var HwLink = () => {
773
- if (!app5) return;
201
+ var hwLink = () => {
202
+ if (!app3) return;
774
203
  const content = document.createElement("div");
775
204
  content.id = "app-content";
776
205
  content.innerHTML = template;
777
- app5.classList.add("full-page");
778
- app5.appendChild(content);
779
- boxDv = app5.querySelector("#device");
780
- const btnEdit = app5.querySelector("#btn-edit");
781
- if (btnEdit) btnEdit.onclick = async () => {
782
- if (await PwdChk()) {
783
- if (AGCY > 0 && ACCT > 0 && CSID != "") {
784
- Update2(AGCY, ACCT, CSID).then(() => {
785
- Loading2(boxDv, true);
786
- WSSVC.send('{"head": "KEYRST"}');
787
- }).catch((err) => console.error(err));
788
- } else {
789
- Create3(CSID).then(() => {
790
- Loading2(boxDv, true);
791
- WSSVC.send('{"head": "KEYRST"}');
792
- }).catch((err) => console.error(err));
793
- }
794
- }
795
- };
796
- Loading();
797
- AGCY = 0;
798
- ACCT = 0;
799
- CSID = "";
206
+ app3.classList.add("full-page");
207
+ app3.appendChild(content);
800
208
  isREADY = false;
801
- if (!gbvar.api.TOKEN) {
802
- const btn = app5.querySelectorAll("button");
803
- btn.forEach((elm) => elm.style.display = "none");
804
- }
209
+ loading();
805
210
  wsSvc();
806
211
  };
807
212
  var wsSvc = () => {
808
- WSSVC = new WebSocket(gbvar.hwl.HOST);
213
+ WSSVC = new WebSocket(cfg.hwl.HOST);
809
214
  WSSVC.onopen = () => {
810
215
  hwinfo();
811
- dvinfo();
812
216
  T_hwinfo = setInterval(hwinfo, 1e3 * 10);
813
217
  };
814
218
  WSSVC.onclose = () => {
@@ -819,30 +223,26 @@ var wsSvc = () => {
819
223
  const resp = JSON.parse(e.data);
820
224
  const head = resp.head ? resp.head : "";
821
225
  const data = resp.data ? resp.data : "";
822
- if (head == "CSUUID") CSID = data;
823
- if (head == "HWINFO") setHwInfo(data);
824
- if (head == "DVINFO") {
226
+ if (head == "CSUUID") {
825
227
  if (!isREADY) {
826
228
  isREADY = true;
827
- Ready();
229
+ ready();
828
230
  }
829
- setDvInfo(data);
830
- Loading2(boxDv, false);
831
231
  }
232
+ if (head == "HWINFO") setHwInfo(data);
832
233
  };
833
234
  let T_hwinfo;
834
235
  const hwinfo = () => WSSVC.send('{"head": "HWINFO"}');
835
- const dvinfo = () => WSSVC.send('{"head": "DVINFO"}');
836
236
  };
837
237
  var setHwInfo = (data) => {
838
- if (!app5) return;
238
+ if (!app3) return;
839
239
  const svc = data.svc;
840
- app5.querySelector("#hwlink").innerText = `: ${svc.hwlink}`;
841
- app5.querySelector("#autoup").innerText = `: ${svc.autoup}`;
842
- app5.querySelector("#csuuid").innerText = `: ${data.csuuid}`;
240
+ app3.querySelector("#hwlink").innerText = `: ${svc.hwlink}`;
241
+ app3.querySelector("#autoup").innerText = `: ${svc.autoup}`;
242
+ app3.querySelector("#csuuid").innerText = `: ${data.csuuid}`;
843
243
  const cpu = data.cpu;
844
244
  const mem = data.mem;
845
- const hwinfo = app5.querySelector("#hwinfo");
245
+ const hwinfo = app3.querySelector("#hwinfo");
846
246
  const uptime = Number(data.uptime);
847
247
  const hh = Math.floor(uptime / 3600);
848
248
  const mm = Math.floor(uptime % 3600 / 60);
@@ -852,22 +252,10 @@ var setHwInfo = (data) => {
852
252
  hwinfo.querySelector("#host").innerText = `: ${data.hostname}`;
853
253
  hwinfo.querySelector("#os").innerText = `: ${data.platform}`;
854
254
  hwinfo.querySelector("#cpu").innerText = `: ${cpu.model}`;
855
- app5.querySelector("#mem").innerText = `: ${mem_text}`;
856
- app5.querySelector("#uptime").innerText = `: ${hh} h ${mm} m`;
857
- };
858
- var setDvInfo = (data) => {
859
- if (!app5 || !data.acct || Number(data.acct) == 0) return;
860
- AGCY = Number(data.agcy);
861
- ACCT = Number(data.acct);
862
- let dept = data.dvsn_name;
863
- if (Number(data.sect) > 0) {
864
- dept += ` - ${data.sect_name}`;
865
- }
866
- app5.querySelector("#agcy").innerText = `: ${data.agcy_name}`;
867
- app5.querySelector("#dept").innerText = `: ${dept}`;
868
- app5.querySelector("#dname").innerText = `: ${data.acname}`;
255
+ app3.querySelector("#mem").innerText = `: ${mem_text}`;
256
+ app3.querySelector("#uptime").innerText = `: ${hh} h ${mm} m`;
869
257
  };
870
258
  export {
871
- HwLink
259
+ hwLink
872
260
  };
873
261
  //# sourceMappingURL=index.js.map