slimsdk 0.1.55 → 0.2.1

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 (90) hide show
  1. package/README.md +3 -5
  2. package/dist/desktop/index.css +0 -48
  3. package/dist/desktop/index.css.map +1 -1
  4. package/dist/desktop/index.d.ts +14 -13
  5. package/dist/desktop/index.js +1476 -1972
  6. package/dist/desktop/index.js.map +1 -1
  7. package/dist/docs-BHtSyl34.d.ts +10 -0
  8. package/dist/index-B4158M0u.d.ts +21 -0
  9. package/dist/index-BAQxKstM.d.ts +8 -0
  10. package/dist/index-BMqjxP9I.d.ts +11 -0
  11. package/dist/index-CD53Vh6h.d.ts +31 -0
  12. package/dist/index-COGi5mfY.d.ts +28 -0
  13. package/dist/index-COUeXLOQ.d.ts +3 -0
  14. package/dist/index-CoYHkkyT.d.ts +14 -0
  15. package/dist/{index-kr8P3eEW.d.ts → index-Cvng8f_u.d.ts} +10 -9
  16. package/dist/index-D5CUpF9v.d.ts +10 -0
  17. package/dist/index-DBhzpIiB.d.ts +32 -0
  18. package/dist/index-D_o5c-YA.d.ts +134 -0
  19. package/dist/index-DzKPF0ja.d.ts +14 -0
  20. package/dist/index-jVam7Sxi.d.ts +15 -0
  21. package/dist/index-uQOR5bdy.d.ts +20 -0
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +2 -2
  24. package/dist/index.js.map +1 -1
  25. package/dist/lib/index.d.ts +1 -1
  26. package/dist/lib/index.js +194 -1
  27. package/dist/lib/index.js.map +1 -1
  28. package/dist/mobile/index.css +0 -48
  29. package/dist/mobile/index.css.map +1 -1
  30. package/dist/mobile/index.d.ts +13 -12
  31. package/dist/mobile/index.js +542 -808
  32. package/dist/mobile/index.js.map +1 -1
  33. package/dist/mod/button/index.d.ts +1 -1
  34. package/dist/mod/button/index.js +2 -2
  35. package/dist/mod/button/index.js.map +1 -1
  36. package/dist/mod/cover/index.d.ts +1 -1
  37. package/dist/mod/cover/index.js +3 -3
  38. package/dist/mod/cover/index.js.map +1 -1
  39. package/dist/mod/dialog/index.d.ts +1 -1
  40. package/dist/mod/dialog/index.js +13 -13
  41. package/dist/mod/dialog/index.js.map +1 -1
  42. package/dist/mod/drawer/index.d.ts +1 -1
  43. package/dist/mod/drawer/index.js +8 -8
  44. package/dist/mod/drawer/index.js.map +1 -1
  45. package/dist/mod/drop/index.d.ts +1 -1
  46. package/dist/mod/drop/index.js +15 -15
  47. package/dist/mod/drop/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/svchub/index.d.ts +2 -0
  67. package/dist/svchub/index.js +760 -0
  68. package/dist/svchub/index.js.map +1 -0
  69. package/dist/worker/hubworker.js +1 -1
  70. package/dist/worker/hubworker.js.map +1 -1
  71. package/package.json +7 -6
  72. package/dist/index-B2HHS23A.d.ts +0 -20
  73. package/dist/index-BQcJsVJ-.d.ts +0 -10
  74. package/dist/index-Bf_lg-oZ.d.ts +0 -339
  75. package/dist/index-ChdqOPJq.d.ts +0 -15
  76. package/dist/index-CzsSwSvp.d.ts +0 -21
  77. package/dist/index-D3tu8t6p.d.ts +0 -28
  78. package/dist/index-DQt71MNx.d.ts +0 -31
  79. package/dist/index-DZdXvqxA.d.ts +0 -10
  80. package/dist/index-DcvauYN8.d.ts +0 -14
  81. package/dist/index-Pd7FTiEW.d.ts +0 -32
  82. package/dist/index-QRbamarh.d.ts +0 -8
  83. package/dist/mod/global/index.d.ts +0 -57
  84. package/dist/mod/global/index.js +0 -117
  85. package/dist/mod/global/index.js.map +0 -1
  86. package/dist/mod/hwlink/index.d.ts +0 -3
  87. package/dist/mod/hwlink/index.js +0 -873
  88. package/dist/mod/hwlink/index.js.map +0 -1
  89. package/dist/mod/hwlink/style.css +0 -1134
  90. package/dist/mod/hwlink/style.css.map +0 -1
@@ -1,873 +0,0 @@
1
- // src/mod/global.ts
2
- var gbvar = {
3
- UNIX_TIME: 0,
4
- app: {
5
- UUID: "",
6
- NAME: "",
7
- VERSION: "",
8
- RELEASE: ""
9
- },
10
- api: {
11
- URL: "",
12
- TOKEN: ""
13
- },
14
- hub: {
15
- LOGIN: "https://wkrh.info/oauth/v1/authorize",
16
- OAUTH: "https://wkrh.info:8850/oauth/v1",
17
- API: "https://wkrh.info:8850/api/v1",
18
- WSS: "wss://wkrh.info:8855/ws",
19
- UUID: ""
20
- },
21
- hwl: {
22
- HOST: "ws://localhost:8844/ws",
23
- FILE: "https://wkrh.info/app/hwlink/hwlink_setup.exe"
24
- },
25
- 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: ""
38
- }
39
- };
40
- var app = document.querySelector("#app");
41
-
42
- // src/page/index.ts
43
- var app2 = document.querySelector("#app");
44
- var pageSpin = (
45
- /*html*/
46
- `
47
- <div class="lds-spinner">
48
- <div></div><div></div><div></div><div></div>
49
- <div></div><div></div><div></div><div></div>
50
- <div></div><div></div><div></div><div></div>
51
- </div>
52
- `
53
- );
54
- var smallSpin = `<div class="spinner s32"></div>`;
55
- var Loading = (size = "default") => {
56
- if (!app2) return;
57
- if (!app2.querySelector("#page-loader")) {
58
- const loader = document.createElement("div");
59
- loader.id = "page-loader";
60
- loader.className = "overlay center";
61
- loader.innerHTML = size == "default" ? pageSpin : smallSpin;
62
- app2.appendChild(loader);
63
- }
64
- const content = app2.querySelector("#app-content");
65
- if (content) content.style.display = "none";
66
- };
67
- var Ready = (delay = 400) => {
68
- new Promise((r) => setTimeout(r, delay)).then(() => {
69
- clearLoader(true);
70
- });
71
- };
72
- var clearLoader = (showContent) => {
73
- if (!app2) return;
74
- const loader = app2.querySelector("#page-loader");
75
- if (loader) {
76
- loader.style.animation = "fade-out 0.4s forwards";
77
- loader.onanimationend = () => loader.remove();
78
- }
79
- const content = app2.querySelector("#app-content");
80
- if (content) content.style.display = showContent ? "block" : "none";
81
- };
82
-
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
- // src/svchub/hwlink/template.ts
359
- var template = (
360
- /*html*/
361
- `
362
- <div id="page-svchub" class="cover">
363
- <div class="cover-bar">Hardware Link</div>
364
- <div class="cover-body border">
365
- <!-- svcinfo -->
366
- <div id="svcinfo">
367
- <div class="box-tb">
368
- <div class="topic">HwLink</div>
369
- <div class="text" id="hwlink">:</div>
370
- </div>
371
- <div class="box-tb">
372
- <div class="topic">AutoUp</div>
373
- <div class="text" id="autoup">:</div>
374
- </div>
375
- <div class="box-tb">
376
- <div class="topic">CSUUID</div>
377
- <div class="text" id="csuuid">:</div>
378
- </div>
379
- </div>
380
- <hr>
381
- <!-- device -->
382
- <div id="device">
383
- <div class="box-tb">
384
- <div class="topic">\u0E2B\u0E19\u0E48\u0E27\u0E22\u0E07\u0E32\u0E19</div>
385
- <div class="text" id="agcy">:</div>
386
- </div>
387
- <div class="box-tb">
388
- <div class="topic">\u0E01\u0E25\u0E38\u0E48\u0E21\u0E07\u0E32\u0E19</div>
389
- <div class="text" id="dept">:</div>
390
- </div>
391
- <div class="box-tb">
392
- <div class="topic">\u0E0A\u0E37\u0E48\u0E2D\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C</div>
393
- <div class="text" id="dname">:</div>
394
- </div>
395
- <div class="box-tb">
396
- <div class="topic">\u0E40\u0E25\u0E02\u0E17\u0E23\u0E31\u0E1E\u0E22\u0E4C\u0E2A\u0E34\u0E19</div>
397
- <div class="text" id="assno">:</div>
398
- </div>
399
- <button id="btn-edit" class="circle sm blue"
400
- shadow="true">&#xf5ae;</button>
401
- </div>
402
- <hr>
403
- <!-- hwinfo -->
404
- <div id="hwinfo">
405
- <div class="box-tb">
406
- <div class="topic">Hostname</div>
407
- <div class="text" id="host">:</div>
408
- </div>
409
- <div class="box-tb">
410
- <div class="topic">Platform</div>
411
- <div class="text" id="os">:</div>
412
- </div>
413
- <div class="box-tb">
414
- <div class="topic">CpuModel</div>
415
- <div class="text" id="cpu">:</div>
416
- </div>
417
- <div class="box-tb">
418
- <div class="topic">Memory</div>
419
- <div class="text" id="mem">:</div>
420
- </div>
421
- <div class="box-tb">
422
- <div class="topic">Uptime</div>
423
- <div class="text" id="uptime">:</div>
424
- </div>
425
- </div>
426
- <hr>
427
- <!-- x -->
428
- <div id="">
429
- <div class="box-tb">
430
- <div class="topic">SmartCard</div>
431
- <div class="text" id="">:</div>
432
- </div>
433
- <div class="box-tb">
434
- <div class="topic">Biometric</div>
435
- <div class="text" id="">:</div>
436
- </div>
437
- </div>
438
- </div>
439
- </div>
440
- <style>
441
- #page-svchub {
442
- margin: auto;
443
- max-width: 600px;
444
- min-width: 480px;
445
- line-height: 1.5;
446
- }
447
- #page-svchub .topic {
448
- float: left;
449
- width: 100px;
450
- font-weight: 600;
451
- }
452
- #page-svchub .text {
453
- float: left;
454
- width: calc(100% - 100px);
455
- }
456
- #page-svchub #device {
457
- position: relative;
458
- }
459
- #page-svchub #btn-edit {
460
- position: absolute;
461
- top: 0;
462
- right: 0;
463
- }
464
- </style>
465
- `
466
- );
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
-
764
- // src/svchub/hwlink/index.ts
765
- var app5 = document.querySelector("#app");
766
- var AGCY;
767
- var ACCT;
768
- var CSID;
769
- var isREADY;
770
- var WSSVC;
771
- var boxDv;
772
- var HwLink = () => {
773
- if (!app5) return;
774
- const content = document.createElement("div");
775
- content.id = "app-content";
776
- 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 = "";
800
- isREADY = false;
801
- if (!gbvar.api.TOKEN) {
802
- const btn = app5.querySelectorAll("button");
803
- btn.forEach((elm) => elm.style.display = "none");
804
- }
805
- wsSvc();
806
- };
807
- var wsSvc = () => {
808
- WSSVC = new WebSocket(gbvar.hwl.HOST);
809
- WSSVC.onopen = () => {
810
- hwinfo();
811
- dvinfo();
812
- T_hwinfo = setInterval(hwinfo, 1e3 * 10);
813
- };
814
- WSSVC.onclose = () => {
815
- clearInterval(T_hwinfo);
816
- setTimeout(wsSvc, 1e3 * 10);
817
- };
818
- WSSVC.onmessage = (e) => {
819
- const resp = JSON.parse(e.data);
820
- const head = resp.head ? resp.head : "";
821
- const data = resp.data ? resp.data : "";
822
- if (head == "CSUUID") CSID = data;
823
- if (head == "HWINFO") setHwInfo(data);
824
- if (head == "DVINFO") {
825
- if (!isREADY) {
826
- isREADY = true;
827
- Ready();
828
- }
829
- setDvInfo(data);
830
- Loading2(boxDv, false);
831
- }
832
- };
833
- let T_hwinfo;
834
- const hwinfo = () => WSSVC.send('{"head": "HWINFO"}');
835
- const dvinfo = () => WSSVC.send('{"head": "DVINFO"}');
836
- };
837
- var setHwInfo = (data) => {
838
- if (!app5) return;
839
- 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}`;
843
- const cpu = data.cpu;
844
- const mem = data.mem;
845
- const hwinfo = app5.querySelector("#hwinfo");
846
- const uptime = Number(data.uptime);
847
- const hh = Math.floor(uptime / 3600);
848
- const mm = Math.floor(uptime % 3600 / 60);
849
- const memUsed = (Number(mem.used) / 1024 / 1024 / 1024).toFixed(1);
850
- const memTotal = (Number(mem.total) / 1024 / 1024 / 1024).toFixed(1);
851
- const mem_text = `${memUsed}/${memTotal} GB (${mem.percent}%)`;
852
- hwinfo.querySelector("#host").innerText = `: ${data.hostname}`;
853
- hwinfo.querySelector("#os").innerText = `: ${data.platform}`;
854
- 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}`;
869
- };
870
- export {
871
- HwLink
872
- };
873
- //# sourceMappingURL=index.js.map