underpost 2.6.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.
Files changed (269) hide show
  1. package/.dockerignore +14 -0
  2. package/.env.development +8 -0
  3. package/.env.production +8 -0
  4. package/.env.test +8 -0
  5. package/.nycrc +9 -0
  6. package/.prettierignore +13 -0
  7. package/.prettierrc +9 -0
  8. package/.vscode/extensions.json +72 -0
  9. package/.vscode/settings.json +99 -0
  10. package/Dockerfile +88 -0
  11. package/LICENSE +21 -0
  12. package/README.md +51 -0
  13. package/bin/db.js +119 -0
  14. package/bin/deploy.js +600 -0
  15. package/bin/dns.js +1 -0
  16. package/bin/file.js +92 -0
  17. package/bin/help.js +110 -0
  18. package/bin/index.js +29 -0
  19. package/bin/install.js +357 -0
  20. package/bin/shortcut.js +44 -0
  21. package/bin/ssl.js +61 -0
  22. package/bin/util.js +182 -0
  23. package/bin/vs.js +35 -0
  24. package/conf.js +244 -0
  25. package/docker-compose.yml +67 -0
  26. package/jsconfig.json +7 -0
  27. package/jsdoc.json +32 -0
  28. package/nodemon.json +6 -0
  29. package/package.json +128 -0
  30. package/prometheus.yml +36 -0
  31. package/setup.sh +25 -0
  32. package/src/api/core/core.controller.js +69 -0
  33. package/src/api/core/core.model.js +11 -0
  34. package/src/api/core/core.router.js +23 -0
  35. package/src/api/core/core.service.js +29 -0
  36. package/src/api/crypto/crypto.controller.js +51 -0
  37. package/src/api/crypto/crypto.model.js +23 -0
  38. package/src/api/crypto/crypto.router.js +20 -0
  39. package/src/api/crypto/crypto.service.js +64 -0
  40. package/src/api/default/default.controller.js +69 -0
  41. package/src/api/default/default.model.js +20 -0
  42. package/src/api/default/default.router.js +23 -0
  43. package/src/api/default/default.service.js +31 -0
  44. package/src/api/file/file.controller.js +51 -0
  45. package/src/api/file/file.model.js +19 -0
  46. package/src/api/file/file.router.js +20 -0
  47. package/src/api/file/file.service.js +70 -0
  48. package/src/api/instance/instance.controller.js +69 -0
  49. package/src/api/instance/instance.model.js +36 -0
  50. package/src/api/instance/instance.router.js +33 -0
  51. package/src/api/instance/instance.service.js +48 -0
  52. package/src/api/test/test.controller.js +59 -0
  53. package/src/api/test/test.model.js +14 -0
  54. package/src/api/test/test.router.js +21 -0
  55. package/src/api/test/test.service.js +35 -0
  56. package/src/api/user/user.controller.js +70 -0
  57. package/src/api/user/user.model.js +65 -0
  58. package/src/api/user/user.router.js +345 -0
  59. package/src/api/user/user.service.js +479 -0
  60. package/src/api.js +23 -0
  61. package/src/client/Default.index.js +40 -0
  62. package/src/client/components/core/Account.js +290 -0
  63. package/src/client/components/core/AgGrid.js +160 -0
  64. package/src/client/components/core/Auth.js +19 -0
  65. package/src/client/components/core/Badge.js +32 -0
  66. package/src/client/components/core/BlockChain.js +41 -0
  67. package/src/client/components/core/Blog.js +9 -0
  68. package/src/client/components/core/BtnIcon.js +91 -0
  69. package/src/client/components/core/CalendarCore.js +319 -0
  70. package/src/client/components/core/Chat.js +64 -0
  71. package/src/client/components/core/ColorPalette.js +5267 -0
  72. package/src/client/components/core/CommonJs.js +708 -0
  73. package/src/client/components/core/Content.js +49 -0
  74. package/src/client/components/core/Css.js +1027 -0
  75. package/src/client/components/core/CssCore.js +792 -0
  76. package/src/client/components/core/D3Chart.js +44 -0
  77. package/src/client/components/core/Docs.js +130 -0
  78. package/src/client/components/core/DropDown.js +164 -0
  79. package/src/client/components/core/EventsUI.js +54 -0
  80. package/src/client/components/core/FileExplorer.js +624 -0
  81. package/src/client/components/core/FullScreen.js +45 -0
  82. package/src/client/components/core/Input.js +259 -0
  83. package/src/client/components/core/JoyStick.js +77 -0
  84. package/src/client/components/core/Keyboard.js +73 -0
  85. package/src/client/components/core/LoadingAnimation.js +157 -0
  86. package/src/client/components/core/LogIn.js +181 -0
  87. package/src/client/components/core/LogOut.js +52 -0
  88. package/src/client/components/core/Logger.js +26 -0
  89. package/src/client/components/core/Modal.js +1596 -0
  90. package/src/client/components/core/NotificationManager.js +84 -0
  91. package/src/client/components/core/Panel.js +413 -0
  92. package/src/client/components/core/Polyhedron.js +162 -0
  93. package/src/client/components/core/Recover.js +204 -0
  94. package/src/client/components/core/Responsive.js +53 -0
  95. package/src/client/components/core/RichText.js +27 -0
  96. package/src/client/components/core/Router.js +77 -0
  97. package/src/client/components/core/SignUp.js +125 -0
  98. package/src/client/components/core/SocketIo.js +72 -0
  99. package/src/client/components/core/Stream.js +113 -0
  100. package/src/client/components/core/ToggleSwitch.js +87 -0
  101. package/src/client/components/core/ToolTip.js +26 -0
  102. package/src/client/components/core/Translate.js +408 -0
  103. package/src/client/components/core/Validator.js +100 -0
  104. package/src/client/components/core/VanillaJs.js +454 -0
  105. package/src/client/components/core/Wallet.js +106 -0
  106. package/src/client/components/core/Webhook.js +25 -0
  107. package/src/client/components/core/Worker.js +272 -0
  108. package/src/client/components/default/CommonDefault.js +29 -0
  109. package/src/client/components/default/CssDefault.js +13 -0
  110. package/src/client/components/default/ElementsDefault.js +38 -0
  111. package/src/client/components/default/LogInDefault.js +41 -0
  112. package/src/client/components/default/LogOutDefault.js +28 -0
  113. package/src/client/components/default/MenuDefault.js +389 -0
  114. package/src/client/components/default/RoutesDefault.js +48 -0
  115. package/src/client/components/default/SettingsDefault.js +16 -0
  116. package/src/client/components/default/SignUpDefault.js +9 -0
  117. package/src/client/components/default/SocketIoDefault.js +54 -0
  118. package/src/client/components/default/TranslateDefault.js +7 -0
  119. package/src/client/public/default/android-chrome-144x144.png +0 -0
  120. package/src/client/public/default/android-chrome-192x192.png +0 -0
  121. package/src/client/public/default/android-chrome-256x256.png +0 -0
  122. package/src/client/public/default/android-chrome-36x36.png +0 -0
  123. package/src/client/public/default/android-chrome-384x384.png +0 -0
  124. package/src/client/public/default/android-chrome-48x48.png +0 -0
  125. package/src/client/public/default/android-chrome-512x512.png +0 -0
  126. package/src/client/public/default/android-chrome-72x72.png +0 -0
  127. package/src/client/public/default/android-chrome-96x96.png +0 -0
  128. package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
  129. package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
  130. package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
  131. package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
  132. package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
  133. package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
  134. package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
  135. package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
  136. package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
  137. package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
  138. package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
  139. package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
  140. package/src/client/public/default/apple-touch-icon.png +0 -0
  141. package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
  142. package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
  143. package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
  144. package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
  145. package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
  146. package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
  147. package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
  148. package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
  149. package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
  150. package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
  151. package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
  152. package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
  153. package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
  154. package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
  155. package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
  156. package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
  157. package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
  158. package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
  159. package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
  160. package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
  161. package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
  162. package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
  163. package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
  164. package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
  165. package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
  166. package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
  167. package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
  168. package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
  169. package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
  170. package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
  171. package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
  172. package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
  173. package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
  174. package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
  175. package/src/client/public/default/assets/background/white.jpg +0 -0
  176. package/src/client/public/default/assets/background/white0-min.jpg +0 -0
  177. package/src/client/public/default/assets/background/white0.jpg +0 -0
  178. package/src/client/public/default/assets/logo/base-icon.png +0 -0
  179. package/src/client/public/default/browserconfig.xml +12 -0
  180. package/src/client/public/default/favicon-16x16.png +0 -0
  181. package/src/client/public/default/favicon-32x32.png +0 -0
  182. package/src/client/public/default/favicon-48x48.png +0 -0
  183. package/src/client/public/default/favicon.ico +0 -0
  184. package/src/client/public/default/manifest.webmanifest +69 -0
  185. package/src/client/public/default/mstile-144x144.png +0 -0
  186. package/src/client/public/default/mstile-150x150.png +0 -0
  187. package/src/client/public/default/mstile-310x150.png +0 -0
  188. package/src/client/public/default/mstile-310x310.png +0 -0
  189. package/src/client/public/default/mstile-70x70.png +0 -0
  190. package/src/client/public/default/sitemap +148 -0
  191. package/src/client/public/default/yandex-browser-50x50.png +0 -0
  192. package/src/client/public/default/yandex-browser-manifest.json +9 -0
  193. package/src/client/public/doc/favicon.ico +0 -0
  194. package/src/client/public/doc/sitemap +148 -0
  195. package/src/client/public/test/favicon.ico +0 -0
  196. package/src/client/public/test/sitemap +148 -0
  197. package/src/client/services/core/core.service.js +152 -0
  198. package/src/client/services/crypto/crypto.service.js +70 -0
  199. package/src/client/services/default/default.management.js +345 -0
  200. package/src/client/services/default/default.service.js +89 -0
  201. package/src/client/services/file/file.service.js +70 -0
  202. package/src/client/services/instance/instance.management.js +74 -0
  203. package/src/client/services/instance/instance.service.js +89 -0
  204. package/src/client/services/test/test.service.js +70 -0
  205. package/src/client/services/user/user.management.js +50 -0
  206. package/src/client/services/user/user.service.js +89 -0
  207. package/src/client/ssr/Render.js +16 -0
  208. package/src/client/ssr/body-components/CacheControl.js +113 -0
  209. package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -0
  210. package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -0
  211. package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -0
  212. package/src/client/ssr/head-components/Css.js +241 -0
  213. package/src/client/ssr/head-components/DefaultScripts.js +3 -0
  214. package/src/client/ssr/head-components/Microdata.js +11 -0
  215. package/src/client/ssr/head-components/Production.js +1 -0
  216. package/src/client/ssr/head-components/PwaDefault.js +60 -0
  217. package/src/client/ssr/head-components/Seo.js +14 -0
  218. package/src/client/sw/default.sw.js +201 -0
  219. package/src/client/sw/template.sw.js +84 -0
  220. package/src/client.build.js +22 -0
  221. package/src/client.dev.js +21 -0
  222. package/src/cron.js +25 -0
  223. package/src/db/DataBaseProvider.js +34 -0
  224. package/src/db/mariadb/MariaDB.js +33 -0
  225. package/src/db/mongo/MongooseDB.js +46 -0
  226. package/src/dns.js +22 -0
  227. package/src/mailer/EmailRender.js +69 -0
  228. package/src/mailer/MailerProvider.js +96 -0
  229. package/src/proxy.js +22 -0
  230. package/src/runtime/lampp/Lampp.js +44 -0
  231. package/src/runtime/nginx/Nginx.js +3 -0
  232. package/src/runtime/xampp/Xampp.js +49 -0
  233. package/src/server/auth.js +204 -0
  234. package/src/server/backup.js +83 -0
  235. package/src/server/client-build-live.js +72 -0
  236. package/src/server/client-build.js +688 -0
  237. package/src/server/client-dev-server.js +58 -0
  238. package/src/server/client-formatted.js +48 -0
  239. package/src/server/client-icons.js +150 -0
  240. package/src/server/conf.js +611 -0
  241. package/src/server/dns.js +87 -0
  242. package/src/server/downloader.js +42 -0
  243. package/src/server/logger.js +135 -0
  244. package/src/server/network.js +122 -0
  245. package/src/server/peer.js +33 -0
  246. package/src/server/process.js +66 -0
  247. package/src/server/proxy.js +118 -0
  248. package/src/server/runtime.js +393 -0
  249. package/src/server/ssl.js +107 -0
  250. package/src/server.js +25 -0
  251. package/src/ws/IoInterface.js +45 -0
  252. package/src/ws/IoServer.js +39 -0
  253. package/src/ws/core/channels/core.ws.chat.js +23 -0
  254. package/src/ws/core/channels/core.ws.mailer.js +35 -0
  255. package/src/ws/core/channels/core.ws.stream.js +31 -0
  256. package/src/ws/core/core.ws.connection.js +28 -0
  257. package/src/ws/core/core.ws.emit.js +14 -0
  258. package/src/ws/core/core.ws.server.js +24 -0
  259. package/src/ws/core/management/core.ws.chat.js +8 -0
  260. package/src/ws/core/management/core.ws.mailer.js +16 -0
  261. package/src/ws/core/management/core.ws.stream.js +8 -0
  262. package/src/ws/default/channels/default.ws.main.js +16 -0
  263. package/src/ws/default/default.ws.connection.js +22 -0
  264. package/src/ws/default/default.ws.emit.js +14 -0
  265. package/src/ws/default/default.ws.server.js +20 -0
  266. package/src/ws/default/management/default.ws.main.js +8 -0
  267. package/startup.js +11 -0
  268. package/supervisord-openssh-server.conf +5 -0
  269. package/test/api.test.js +60 -0
@@ -0,0 +1,259 @@
1
+ import { AgGrid } from './AgGrid.js';
2
+ import { BtnIcon } from './BtnIcon.js';
3
+ import { darkTheme } from './Css.js';
4
+ import { loggerFactory } from './Logger.js';
5
+ import { ToggleSwitch } from './ToggleSwitch.js';
6
+ import { Translate } from './Translate.js';
7
+ import { htmls, s } from './VanillaJs.js';
8
+ const logger = loggerFactory(import.meta);
9
+
10
+ const fileFormDataFactory = (e, extensions) => {
11
+ const form = new FormData();
12
+ for (const keyFile of Object.keys(e.target.files)) {
13
+ if (extensions && !extensions.includes(e.target.files[keyFile].type)) {
14
+ logger.error('Invalid file extension', e.target.files[keyFile]);
15
+ continue;
16
+ }
17
+ form.append(e.target.files[keyFile].name, e.target.files[keyFile]);
18
+ }
19
+ return form;
20
+ };
21
+
22
+ const Input = {
23
+ Render: async function (options) {
24
+ const { id } = options;
25
+ options?.placeholder
26
+ ? options.placeholder === true
27
+ ? (options.placeholder = ' . . .')
28
+ : options.placeholder
29
+ : null;
30
+ setTimeout(() => {
31
+ s(`.input-container-${id}`).onclick = () => {
32
+ ['color'].includes(options.type) ? s(`.${id}`).click() : s(`.${id}`).focus();
33
+ ['datetime-local'].includes(options.type) ? s(`.${id}`).showPicker() : s(`.${id}`).focus();
34
+ };
35
+
36
+ if (s(`.btn-eye-${id}`))
37
+ s(`.btn-eye-${id}`).onclick = () => {
38
+ if (s(`.fa-eye-slash-${id}`).style.display === 'none') {
39
+ s(`.fa-eye-${id}`).style.display = 'none';
40
+ s(`.fa-eye-slash-${id}`).style.display = null;
41
+ s(`.${id}`).type = 'text';
42
+ return;
43
+ }
44
+ s(`.fa-eye-slash-${id}`).style.display = 'none';
45
+ s(`.fa-eye-${id}`).style.display = null;
46
+ s(`.${id}`).type = 'password';
47
+ };
48
+ });
49
+
50
+ const inputElement = html` <input
51
+ type="${options?.type ? options.type : 'text'}"
52
+ class="${options.inputClass ? options.inputClass : 'in wfa'} ${id}"
53
+ ${options?.min !== undefined ? `min="${options.min}"` : ''}
54
+ placeholder${options?.placeholder ? `="${options.placeholder}"` : ''}
55
+ ${options?.value !== undefined ? `value="${options.value}"` : ''}
56
+ ${options?.autocomplete ? `autocomplete="${options.autocomplete}"` : ''}
57
+ ${options?.disabled ? `disabled` : ''}
58
+ ${options?.name !== undefined ? `name="${options.name}"` : ''}
59
+ ${options?.pattern !== undefined ? `pattern="${options.pattern}"` : ''}
60
+ ${options?.pattern === undefined && options.type === 'tel' ? `pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"` : ''}
61
+ ${options?.required ? ` required ` : ''}
62
+ ${options?.accept ? `accept="${options.accept}"` : ''}
63
+ />
64
+ <div class="${id}-input-extension input-info input-extension ${options?.extension ? '' : 'hide'}">
65
+ ${options?.extension ? await options.extension() : ''}
66
+ </div>`;
67
+
68
+ return html` <div class="${options?.containerClass ? options.containerClass + ' ' : ''} input-container-${id}">
69
+ <div class="in">
70
+ ${options?.label ? html`<div class="in input-label input-label-${id}">${options.label}</div>` : ''}
71
+ ${options.type === 'password' && !options.disabledEye
72
+ ? html`
73
+ <div class="fl input-row-${id}">
74
+ <div class="in fll" style="width: 80%;">${inputElement}</div>
75
+ <div class="in fll btn-eye-password btn-eye-${id}" style="width: 20%;">
76
+ <i class="fas fa-eye fa-eye-${id} eye-password"></i>
77
+ <i class="fas fa-eye-slash fa-eye-slash-${id} eye-password" style="display: none"></i>
78
+ </div>
79
+ </div>
80
+ `
81
+ : options?.placeholderIcon
82
+ ? html` <div class="fl input-row-${id}">${options.placeholderIcon} ${inputElement}</div> `
83
+ : inputElement}
84
+ <div class="in input-info input-info-${id}">&nbsp</div>
85
+ </div>
86
+ </div>`;
87
+ },
88
+ parseJsonEval: (selector) => {
89
+ try {
90
+ return JSON.parse(s(selector).value);
91
+ } catch (error) {
92
+ return s(selector).value;
93
+ }
94
+ },
95
+ getValues: function (formData) {
96
+ const obj = {};
97
+ for (const inputData of formData) {
98
+ switch (inputData.inputType) {
99
+ case 'checkbox':
100
+ case 'checkbox-on-off':
101
+ obj[inputData.model] = s(`.${inputData.id}-checkbox`).checked;
102
+ continue;
103
+ break;
104
+
105
+ default:
106
+ break;
107
+ }
108
+
109
+ if (!s(`.${inputData.id}`) || !s(`.${inputData.id}`).value || s(`.${inputData.id}`).value === 'undefined')
110
+ continue;
111
+ if ('model' in inputData) {
112
+ obj[inputData.model] = s(`.${inputData.id}`).value;
113
+ }
114
+ }
115
+ return obj;
116
+ },
117
+ cleanValues: function (formData) {
118
+ const obj = {};
119
+ for (const inputData of formData) {
120
+ if (!s(`.${inputData.id}`)) continue;
121
+
122
+ switch (inputData.inputType) {
123
+ case 'checkbox':
124
+ case 'checkbox-on-off':
125
+ if (s(`.${inputData.id}-checkbox`).checked) ToggleSwitch.Tokens[inputData.id].click();
126
+ continue;
127
+ break;
128
+
129
+ default:
130
+ break;
131
+ }
132
+
133
+ if ('model' in inputData) {
134
+ if (!['dropdown'].includes(inputData.inputType)) s(`.${inputData.id}`).value = '';
135
+ }
136
+ if (s(`.input-info-${inputData.id}`)) htmls(`.input-info-${inputData.id}`, html`&nbsp`);
137
+ }
138
+ return obj;
139
+ },
140
+ };
141
+
142
+ const InputFile = {
143
+ Render: async function ({ id, multiple }, on = { change: () => {}, clear: () => {} }) {
144
+ // drag drop multi file
145
+ const gridId = `ag-grid-input-file-${id}`;
146
+ setTimeout(() => {
147
+ s(`.btn-clear-input-file-${id}`).onclick = (e) => {
148
+ e.preventDefault();
149
+ s(`.${id}`).value = null;
150
+ AgGrid.grids[gridId].setGridOption('rowData', []);
151
+ if (on && typeof on.clear === 'function') on.clear();
152
+ };
153
+
154
+ ['drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop'].forEach(function (event) {
155
+ s(`.drop-zone-${id}`).addEventListener(event, function (e) {
156
+ e.preventDefault();
157
+ e.stopPropagation();
158
+ });
159
+ });
160
+ s(`.drop-zone-${id}`).addEventListener(
161
+ 'dragover',
162
+ function (e) {
163
+ this.classList.add('drop-hover-container');
164
+ },
165
+ false,
166
+ );
167
+
168
+ s(`.drop-zone-${id}`).addEventListener(
169
+ 'dragleave',
170
+ function (e) {
171
+ this.classList.remove('drop-hover-container');
172
+ },
173
+ false,
174
+ );
175
+ s(`.drop-zone-${id}`).addEventListener(
176
+ 'drop',
177
+ function (e) {
178
+ this.classList.remove('drop-hover-container');
179
+ const files = e.dataTransfer.files;
180
+ const dataTransfer = new DataTransfer();
181
+
182
+ let countFiles = 0;
183
+ Array.prototype.forEach.call(files, (file) => {
184
+ // logger.info(file);
185
+ if (!multiple && countFiles == 1) return;
186
+ dataTransfer.items.add(file);
187
+ countFiles++;
188
+ });
189
+
190
+ s(`.${id}`).files = dataTransfer.files;
191
+ s(`.${id}`).onchange({ target: s(`.${id}`) });
192
+ },
193
+ false,
194
+ );
195
+
196
+ s(`.drop-zone-${id}`).addEventListener('click', function (e) {
197
+ s(`.${id}`).click();
198
+ });
199
+
200
+ s(`.${id}`).onchange = (e) => {
201
+ // logger.info('e', e);
202
+ const fileGridData = [];
203
+ Object.keys(e.target.files).forEach((fileKey, index) => {
204
+ const file = e.target.files[fileKey];
205
+ logger.info('Load file', file);
206
+ // Get raw:
207
+ // const read = new FileReader();
208
+ // read.readAsBinaryString(file);
209
+ // read.onloadend = () => {
210
+ // console.log('Load File', e.target.files[fileKey], { fileKey, index }, read.result);
211
+ // };
212
+ fileGridData.push(file);
213
+ });
214
+ AgGrid.grids[gridId].setGridOption('rowData', fileGridData);
215
+ if (on && typeof on.change === 'function') on.change(e);
216
+ };
217
+ });
218
+ return html` <div class="fl">
219
+ <div class="in fll input-file-col">
220
+ <div class="in section-mp input-file-sub-col">
221
+ <input class="wfa ${id}" type="file" ${multiple ? `multiple="multiple"` : ''} />
222
+ <div class="in">
223
+ ${await BtnIcon.Render({
224
+ class: `wfa btn-clear-input-file-${id}`,
225
+ label: `<i class="fa-solid fa-broom"></i> ${Translate.Render('clear')}`,
226
+ })}
227
+ </div>
228
+ <div class="in">
229
+ ${await AgGrid.Render({
230
+ id: gridId,
231
+ darkTheme,
232
+ style: {
233
+ height: '200px',
234
+ },
235
+ gridOptions: {
236
+ rowData: [],
237
+ columnDefs: [
238
+ // { field: '_id', headerName: 'ID' },
239
+ { field: 'name', headerName: 'Name' },
240
+ { field: 'type', headerName: 'Type' },
241
+ ],
242
+ },
243
+ })}
244
+ </div>
245
+ </div>
246
+ </div>
247
+ <div class="in fll input-file-col">
248
+ <div class="in section-mp input-file-sub-col drop-zone-${id}">
249
+ <div class="abs center">
250
+ <i class="fas fa-cloud" style="font-size: 30px"></i><br />
251
+ ${Translate.Render('drop-file')}
252
+ </div>
253
+ </div>
254
+ </div>
255
+ </div>`;
256
+ },
257
+ };
258
+
259
+ export { Input, InputFile, fileFormDataFactory };
@@ -0,0 +1,77 @@
1
+ import JoystickController from 'joystick-controller';
2
+ import { getDirection, getId } from './CommonJs.js';
3
+ import { loggerFactory } from './Logger.js';
4
+ import { append, getProxyPath, s } from './VanillaJs.js';
5
+
6
+ const logger = loggerFactory(import.meta);
7
+
8
+ const JoyStick = {
9
+ Tokens: {},
10
+ Render: async function (options = { id: '', callback: ({ joyDataSet }) => {}, callBackTime: 50 }) {
11
+ const { callback, callBackTime } = options;
12
+ const id = options.id ? options.id : getId(this.Tokens, 'joystick-');
13
+ this.Tokens[id] = { callback };
14
+ append(
15
+ 'body',
16
+ html`
17
+ <style>
18
+ .dynamic-joystick-container-${id} {
19
+ /* border: 2px solid red; */
20
+ left: 5px;
21
+ bottom: 5px;
22
+ height: 200px;
23
+ width: 200px;
24
+ z-index: 3;
25
+ }
26
+ .joy-img-background-${id} {
27
+ width: 93%;
28
+ height: 93%;
29
+ opacity: 0.8;
30
+ }
31
+ .dynamic-joystick-container-${id}:hover .joy-img-background-${id} {
32
+ width: 97%;
33
+ height: 97%;
34
+ opacity: 1;
35
+ }
36
+ </style>
37
+ <div class="abs dynamic-joystick-container-${id}">
38
+ <img class="abs center joy-img-background-${id}" src="${getProxyPath()}assets/joy/joy_alpha.png" />
39
+ </div>
40
+ `,
41
+ );
42
+
43
+ this.Tokens[id].instance = new JoystickController(
44
+ {
45
+ maxRange: 70,
46
+ level: 10,
47
+ radius: 70,
48
+ joystickRadius: 50,
49
+ opacity: 0.5,
50
+ // containerClass: 'joystick-container',
51
+ // controllerClass: 'joystick-controller',
52
+ // joystickClass: 'joystick',
53
+ distortion: true,
54
+ dynamicPosition: true,
55
+ dynamicPositionTarget: s(`.dynamic-joystick-container-${id}`),
56
+ mouseClickButton: 'ALL',
57
+ hideContextMenu: true,
58
+ // x: '120px',
59
+ // y: '120px',
60
+ },
61
+ (args = { x, y, leveledX, leveledY, distance, angle }) => {
62
+ const { angle } = args;
63
+ if (angle === 0) return (this.Tokens[id].joyDataSet = undefined);
64
+ const radians = parseFloat(angle);
65
+ const direction = getDirection({ radians });
66
+ this.Tokens[id].joyDataSet = { ...args, radians, direction };
67
+ // logger.info(this.Tokens[id].joyDataSet, id);
68
+ },
69
+ );
70
+ setInterval(() => {
71
+ if (!this.Tokens[id].joyDataSet || !this.Tokens[id].joyDataSet.direction) return;
72
+ this.Tokens[id].callback({ joyDataSet: this.Tokens[id].joyDataSet });
73
+ }, callBackTime);
74
+ },
75
+ };
76
+
77
+ export { JoyStick };
@@ -0,0 +1,73 @@
1
+ import { cap, getId } from './CommonJs.js';
2
+
3
+ const Keyboard = {
4
+ ActiveKey: {},
5
+ Event: {},
6
+ Init: async function (options = { callBackTime: 50 }) {
7
+ const { callBackTime } = options;
8
+ window.onkeydown = (e = new KeyboardEvent()) => {
9
+ this.ActiveKey[e.key] = true;
10
+ // e.composedPath()
11
+ // if (['Tab'].includes(e.key)) {
12
+ // e.preventDefault();
13
+ // e.stopPropagation();
14
+ // e.stopImmediatePropagation();
15
+ // }
16
+ };
17
+ window.onkeyup = (e = new KeyboardEvent()) => {
18
+ delete this.ActiveKey[e.key];
19
+ };
20
+ setInterval(() => {
21
+ Object.keys(this.Event).map((key) => {
22
+ Object.keys(this.ActiveKey).map((activeKey) => {
23
+ if (activeKey in this.Event[key]) this.Event[key][activeKey]();
24
+ });
25
+ });
26
+ }, callBackTime);
27
+ },
28
+ instanceMultiPressKeyTokens: {},
29
+ instanceMultiPressKey: (options = { keys: [], id, timePressDelay, eventCallBack: () => {} }) => {
30
+ if (typeof options.keys[0] === 'string') options.keys[0] = [options.keys[0]];
31
+ if (!options.id) options.id = getId(Keyboard.instanceMultiPressKeyTokens, 'key-press-');
32
+ if (!options.timePressDelay) options.timePressDelay = 500;
33
+ const { id, timePressDelay, keys, eventCallBack } = options;
34
+ Keyboard.instanceMultiPressKeyTokens[id] = { ...options };
35
+
36
+ let indexCombined = -1;
37
+ for (const combinedKeys of keys) {
38
+ indexCombined++;
39
+ const privateIndexCombined = indexCombined;
40
+ const multiPressKey = {};
41
+ const triggerMultiPressKey = () => {
42
+ for (const key of Object.keys(multiPressKey)) {
43
+ if (!multiPressKey[key].press) return;
44
+ }
45
+ eventCallBack();
46
+ };
47
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`] = {};
48
+ for (const key of combinedKeys) {
49
+ multiPressKey[key] = {
50
+ press: false,
51
+ trigger: function () {
52
+ if (!multiPressKey[key].press) {
53
+ multiPressKey[key].press = true;
54
+ triggerMultiPressKey();
55
+ setTimeout(() => {
56
+ multiPressKey[key].press = false;
57
+ }, timePressDelay);
58
+ }
59
+ },
60
+ };
61
+
62
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][key] = multiPressKey[key].trigger;
63
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][key.toLowerCase()] =
64
+ multiPressKey[key].trigger;
65
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][key.toUpperCase()] =
66
+ multiPressKey[key].trigger;
67
+ Keyboard.Event[`instanceMultiPressKey-${id}-${privateIndexCombined}`][cap(key)] = multiPressKey[key].trigger;
68
+ }
69
+ }
70
+ },
71
+ };
72
+
73
+ export { Keyboard };
@@ -0,0 +1,157 @@
1
+ import { CoreService } from '../../services/core/core.service.js';
2
+ import { s4 } from './CommonJs.js';
3
+ import { darkTheme } from './Css.js';
4
+ import { loggerFactory } from './Logger.js';
5
+ import { append, getProxyPath, htmls, s } from './VanillaJs.js';
6
+
7
+ const logger = loggerFactory(import.meta);
8
+
9
+ const LoadingAnimation = {
10
+ bar: {
11
+ tokens: {},
12
+ getId: (id) => `bar-progress-${id.slice(1)}`,
13
+ play: async function (container) {
14
+ const id = this.getId(container);
15
+ const idEvent = s4() + s4() + s4();
16
+ this.tokens[container] = `${idEvent}`;
17
+ // diagonal-bar-background-animation
18
+ // #6d68ff #790079
19
+ append(
20
+ 'body',
21
+ html`
22
+ <div
23
+ class="fix progress-bar box-shadow ${id}"
24
+ style="left: -100%; background: ${darkTheme
25
+ ? LoadingAnimation.darkColor
26
+ ? LoadingAnimation.darkColor
27
+ : `#c9c9c9`
28
+ : LoadingAnimation.lightColor
29
+ ? LoadingAnimation.lightColor
30
+ : `#515151`};"
31
+ ></div>
32
+ `,
33
+ );
34
+ for (const frame of [
35
+ { time: 500, value: 35 },
36
+ { time: 1250, value: 15 },
37
+ { time: 3000, value: 5 },
38
+ { time: 5000, value: 1 },
39
+ ])
40
+ setTimeout(() => {
41
+ if (this.tokens[container] === idEvent && s(`.${id}`)) {
42
+ s(`.${id}`).style.left = `-${frame.value}%`;
43
+ // const percentageRender = html`${100 - frame.value}%`;
44
+ }
45
+ }, frame.time);
46
+ },
47
+ stop: function (container) {
48
+ const id = this.getId(container);
49
+ delete this.tokens[container];
50
+ if (!s(`.${id}`)) return;
51
+ s(`.${id}`).style.left = '0%';
52
+ s(`.${id}`).style.opacity = 1;
53
+ setTimeout(() => (s(`.${id}`).style.opacity = 0));
54
+ setTimeout(() => s(`.${id}`).remove(), 400);
55
+ },
56
+ },
57
+ spinner: {
58
+ spinners: {},
59
+ getId: (id) => `spinner-progress-${id.slice(1)}`,
60
+ spinnerSrcValidator: async function (spinner) {
61
+ if (!this.spinners[spinner]) {
62
+ const url = getProxyPath() + 'dist/loadingio/' + spinner + '/index.html';
63
+ this.spinners[spinner] = {
64
+ url,
65
+ html: await CoreService.getRaw({ url }),
66
+ };
67
+ append(
68
+ 'head',
69
+ html`<link
70
+ rel="stylesheet"
71
+ type="text/css"
72
+ href="${getProxyPath()}dist/loadingio/${spinner}/index.min.css"
73
+ />`,
74
+ );
75
+ }
76
+ },
77
+ play: async function (container, spinner = 'dual-ring') {
78
+ await this.spinnerSrcValidator(spinner);
79
+ const id = this.getId(container);
80
+ if (s(container))
81
+ append(
82
+ container,
83
+ html` <div class="in ${id} loading-animation-container">${this.spinners[spinner].html}</div> `,
84
+ );
85
+ },
86
+ stop: function (container) {
87
+ const id = this.getId(container);
88
+ if (!s(`.${id}`)) return;
89
+ s(`.${id}`).remove();
90
+ },
91
+ },
92
+ img: {
93
+ tokens: {},
94
+ load: function ({ key, src, classes, style }) {
95
+ this.tokens[key] = { src, classes, style };
96
+ },
97
+ play: function (container, key) {
98
+ append(
99
+ container,
100
+ html`<img
101
+ ${this.tokens[key].classes ? `class="${this.tokens[key].classes}"` : ''}
102
+ ${this.tokens[key].style ? `style="${this.tokens[key].style}"` : ''}
103
+ src="${getProxyPath()}${this.tokens[key].src}"
104
+ />`,
105
+ );
106
+ },
107
+ },
108
+ barLevel: {
109
+ append: () => {
110
+ s(`.ssr-blink-bar`).classList.remove('ssr-blink-bar');
111
+ append('.ssr-loading-bar', html`<div class="ssr-loading-bar-block ssr-blink-bar"></div>`);
112
+ },
113
+ clear: () => {
114
+ htmls('.ssr-loading-bar', html`<div class="ssr-loading-bar-block ssr-blink-bar"></div>`);
115
+ },
116
+ },
117
+ removeSplashScreen: function () {
118
+ if (s(`.clean-cache-container`)) s(`.clean-cache-container`).style.display = 'none';
119
+ if (s('.ssr-background'))
120
+ setTimeout(() => {
121
+ s('.ssr-background').style.opacity = 0;
122
+ setTimeout(async () => {
123
+ s('.ssr-background').style.display = 'none';
124
+ }, 300);
125
+ });
126
+ },
127
+ lightColor: null,
128
+ setLightColor: function (color) {
129
+ this.lightColor = color;
130
+ },
131
+ darkColor: null,
132
+ setDarkColor: function (color) {
133
+ this.darkColor = color;
134
+ },
135
+ RenderCurrentSrcLoad: function (event) {
136
+ if (s(`.ssr-loading-info`)) {
137
+ let nameSrcLoad = event.data.path;
138
+ if (nameSrcLoad) {
139
+ if (nameSrcLoad.match('assets'))
140
+ nameSrcLoad =
141
+ location.hostname +
142
+ location.pathname +
143
+ (location.pathname[location.pathname.length - 1] !== '/' ? '/' : '') +
144
+ 'assets';
145
+ else if (!nameSrcLoad.match('api')) nameSrcLoad = undefined;
146
+ if (nameSrcLoad)
147
+ htmls(
148
+ `.ssr-loading-info`,
149
+ html`<span style="color: white">Download </span> <br />
150
+ <br />
151
+ ...${nameSrcLoad.slice(-30)}`,
152
+ );
153
+ }
154
+ }
155
+ },
156
+ };
157
+ export { LoadingAnimation };