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,84 @@
1
+ import { getId, getIsoDate } from './CommonJs.js';
2
+ import { Css, Themes } from './Css.js';
3
+ import { Modal } from './Modal.js';
4
+ import { append, prepend, s } from './VanillaJs.js';
5
+
6
+ const NotificationManager = {
7
+ Types: ['success', 'error', 'warning', 'info'],
8
+ RenderBoard: async function (options) {
9
+ this.options = options;
10
+ append(
11
+ 'body',
12
+ html`
13
+ <style>
14
+ .notification-board-container {
15
+ right: 5px !important;
16
+ width: 300px !important;
17
+ bottom: ${5 + (options?.heightBottomBar ? options.heightBottomBar : 0)}px !important;
18
+ z-index: 5 !important;
19
+ }
20
+ .notification-board-title {
21
+ padding: 5px !important;
22
+ }
23
+ .notification-manager-date {
24
+ font-size: 20px !important;
25
+ color: #7a7a7a !important;
26
+ }
27
+ </style>
28
+ <div class="fix notification-board-container"></div>
29
+ `,
30
+ );
31
+ },
32
+ Tokens: {},
33
+ Push: async function (options = { status: '', html: '' }) {
34
+ const { barConfig } = await Themes[Css.currentTheme](); // newInstance
35
+ barConfig.buttons.maximize.disabled = true;
36
+ barConfig.buttons.minimize.disabled = true;
37
+ barConfig.buttons.restore.disabled = true;
38
+ barConfig.buttons.menu.disabled = true;
39
+ const idNotification = getId(this.Tokens, 'board-notification-');
40
+ this.Tokens[idNotification] = {};
41
+ await Modal.Render({
42
+ title: html`<div class="in notification-manager-date">${getIsoDate(new Date())}</div>
43
+ ${options.html}`,
44
+ html: '',
45
+ id: idNotification,
46
+ selector: `.notification-board-container`,
47
+ class: 'in',
48
+ titleClass: 'notification-board-title',
49
+ renderType: 'prepend',
50
+ barConfig,
51
+ style: {
52
+ width: '300px',
53
+ },
54
+ mode: 'dropNotification',
55
+ status: options.status,
56
+ });
57
+ setTimeout(() => {
58
+ if (s(`.btn-close-${idNotification}`)) s(`.btn-close-${idNotification}`).click();
59
+ }, 2000);
60
+ },
61
+ NotificationScheme: {
62
+ // Visual Options
63
+ body: '<String>',
64
+ icon: '<URL String>',
65
+ image: '<URL String>',
66
+ badge: '<URL String>',
67
+ dir: "<String of 'auto' | 'ltr' | 'rtl'>",
68
+ timestamp: '<Long>',
69
+
70
+ // Both visual & behavioral options
71
+ actions: '<Array of Strings>',
72
+ data: '<Anything>',
73
+
74
+ // Behavioral Options
75
+ tag: '<String>',
76
+ requireInteraction: '<boolean>',
77
+ renotify: '<Boolean>',
78
+ vibrate: '<Array of Integers>',
79
+ sound: '<URL String>',
80
+ silent: '<Boolean>',
81
+ },
82
+ };
83
+
84
+ export { NotificationManager };
@@ -0,0 +1,413 @@
1
+ import { getId } from './CommonJs.js';
2
+ import { LoadingAnimation } from '../core/LoadingAnimation.js';
3
+ import { Validator } from '../core/Validator.js';
4
+ import { Input } from '../core/Input.js';
5
+ import { Responsive } from '../core/Responsive.js';
6
+ import { append, htmls, prepend, s } from './VanillaJs.js';
7
+ import { BtnIcon } from './BtnIcon.js';
8
+ import { Translate } from './Translate.js';
9
+ import { DropDown } from './DropDown.js';
10
+ import { dynamicCol } from './Css.js';
11
+ import { EventsUI } from './EventsUI.js';
12
+ import { ToggleSwitch } from './ToggleSwitch.js';
13
+ import { Modal } from './Modal.js';
14
+ import { RouterEvents } from './Router.js';
15
+
16
+ const Panel = {
17
+ Tokens: {},
18
+ Render: async function (options = { idPanel: '', scrollClassContainer: '', formData: [], data: [] }) {
19
+ const idPanel = options?.idPanel ? options.idPanel : getId(this.Tokens, `${idPanel}-`);
20
+ if (options.formData)
21
+ options.formData = options.formData.map((formObj) => {
22
+ formObj.id = `${idPanel}-${formObj.id}`;
23
+ return formObj;
24
+ });
25
+ const { scrollClassContainer, formData, data, heightTopBar, heightBottomBar } = options;
26
+
27
+ const titleObj = formData.find((f) => f.panel && f.panel.type === 'title');
28
+ const titleKey = titleObj ? titleObj.model : '';
29
+
30
+ const subTitleObj = formData.find((f) => f.panel && f.panel.type === 'subtitle');
31
+ const subTitleKey = subTitleObj ? subTitleObj.model : '';
32
+
33
+ const renderPanel = async (obj) => {
34
+ const { id } = obj;
35
+
36
+ setTimeout(async () => {
37
+ LoadingAnimation.spinner.play(`.${idPanel}-img-spinner-${id}`, 'dual-ring');
38
+ if (options && options.callBackPanelRender)
39
+ await options.callBackPanelRender({
40
+ data: obj,
41
+ imgRender: async ({ imageUrl }) => {
42
+ htmls(`.${idPanel}-cell-col-a-${id}`, html`<img class="in img-${idPanel}" src="${imageUrl}" />`);
43
+ },
44
+ htmlRender: async ({ render }) => {
45
+ htmls(`.${idPanel}-cell-col-a-${id}`, render);
46
+ },
47
+ });
48
+ });
49
+ return html` <div class="in box-shadow ${idPanel}">
50
+ <div class="in ${idPanel}-head">
51
+ <div class="in ${idPanel}-title">
52
+ ${obj.new ? obj.new : options.titleIcon} &nbsp ${titleKey ? obj[titleKey] : ''}
53
+ </div>
54
+ <div class="in ${idPanel}-subtitle">${subTitleKey ? obj[subTitleKey] : ''}</div>
55
+ </div>
56
+ <div class="fl">
57
+ <div class="in fll ${idPanel}-cell ${idPanel}-cell-col-a ${idPanel}-cell-col-a-${id}">
58
+ <div class="abs center ${idPanel}-img-spinner-${id}"></div>
59
+ </div>
60
+ <div class="in fll ${idPanel}-cell ${idPanel}-cell-col-b">
61
+ ${Object.keys(obj)
62
+ .map((infoKey) => {
63
+ const formObjData = formData.find((f) => f.model === infoKey);
64
+ const valueIcon = formObjData?.panel?.icon?.value ? formObjData.panel.icon.value : '';
65
+ const keyIcon = formObjData?.panel?.icon?.key ? formObjData.panel.icon.key : '';
66
+
67
+ const valueNewIcon =
68
+ obj.new && formObjData?.panel?.newIcon?.value ? formObjData.panel.newIcon.value : '';
69
+ const keyNewIcon = obj.new && formObjData?.panel?.newIcon?.key ? formObjData.panel.newIcon.key : '';
70
+
71
+ if (formData.find((f) => f.model === infoKey && f.panel && f.panel.type === 'info-row-pin'))
72
+ return html`<div class="in ${idPanel}-row">
73
+ <span class="${idPanel}-row-pin-key capitalize">${keyNewIcon} ${keyIcon} ${infoKey}:</span>
74
+ <span class="${idPanel}-row-pin-value">${valueNewIcon} ${valueIcon} ${obj[infoKey]}</span>
75
+ </div> `;
76
+
77
+ if (formData.find((f) => f.model === infoKey && f.panel && f.panel.type === 'info-row'))
78
+ return html`<div class="in ${idPanel}-row">
79
+ <span class="${idPanel}-row-key capitalize">${keyNewIcon} ${keyIcon} ${infoKey}:</span>
80
+ <span class="${idPanel}-row-value">${valueNewIcon} ${valueIcon} ${obj[infoKey]}</span>
81
+ </div> `;
82
+
83
+ return html``;
84
+ })
85
+ .join('')}
86
+ </div>
87
+ </div>
88
+ </div>`;
89
+ };
90
+
91
+ let render = '';
92
+ let renderForm = html` <div class="in modal stq" style="top: 0px; z-index: 1; padding-bottom: 5px">
93
+ ${await BtnIcon.Render({
94
+ class: `section-mp btn-custom btn-${idPanel}-close`,
95
+ label: html`<i class="fa-solid fa-xmark"></i> ${Translate.Render('close')}`,
96
+ type: 'button',
97
+ })}
98
+ </div>`;
99
+
100
+ for (const modelData of formData) {
101
+ if (modelData.disableRender) continue;
102
+ switch (modelData.inputType) {
103
+ case 'dropdown':
104
+ renderForm += html` <div class="in section-mp">
105
+ ${await DropDown.Render({
106
+ id: `${modelData.id}`,
107
+ label: html`${Translate.Render(modelData.model)}`,
108
+ containerClass: `${idPanel}-dropdown`,
109
+ // type: 'checkbox',
110
+ value: modelData.dropdown.options[0].replaceAll(' ', '-').toLowerCase(),
111
+ data: modelData.dropdown.options.map((dKey) => {
112
+ const key = dKey.replaceAll(' ', '-').toLowerCase();
113
+ return {
114
+ value: key,
115
+ data: dKey,
116
+ // checked: true,
117
+ display: html`${Translate.Render(dKey)}`,
118
+ onClick: function () {},
119
+ };
120
+ }),
121
+ })}
122
+ </div>`;
123
+ break;
124
+
125
+ case 'checkbox-on-off':
126
+ {
127
+ setTimeout(() => {
128
+ s(`.toggle-form-container-${modelData.id}`).onclick = () => {
129
+ ToggleSwitch.Tokens[`${modelData.id}`].click();
130
+ };
131
+ });
132
+ renderForm += html`<div
133
+ class="in section-mp toggle-form-container toggle-form-container-${modelData.id} hover"
134
+ style="height: 82px;"
135
+ >
136
+ <div class="fl">
137
+ <div class="in fll" style="width: 70%">
138
+ <div class="in">
139
+ ${modelData.panel && modelData.panel.icon ? modelData.panel.icon : ''}
140
+ ${Translate.Render(modelData.model)}
141
+ </div>
142
+ </div>
143
+ <div class="in fll" style="width: 30%">
144
+ ${await ToggleSwitch.Render({
145
+ id: `${modelData.id}`,
146
+ containerClass: 'inl',
147
+ disabledOnClick: true,
148
+ checked: false,
149
+ on: {
150
+ unchecked: () => {},
151
+ checked: () => {},
152
+ },
153
+ })}
154
+ </div>
155
+ </div>
156
+ </div>`;
157
+ }
158
+ break;
159
+
160
+ default:
161
+ renderForm += `${await Input.Render({
162
+ id: `${modelData.id}`,
163
+ type: modelData.inputType,
164
+ // autocomplete: 'new-password',
165
+ label: html`<i class="fa-solid fa-pen-to-square"></i> ${Translate.Render(modelData.model)}`,
166
+ containerClass: 'in section-mp width-mini-box input-container',
167
+ placeholder: true,
168
+ // disabled: true,
169
+ // disabledEye: true,
170
+ })}`;
171
+ break;
172
+ }
173
+ }
174
+ let renderFormBtn = html`
175
+ ${await BtnIcon.Render({
176
+ class: `section-mp btn-custom btn-${idPanel}-submit`,
177
+ label: html`<i class="fas fa-plus"></i> ${Translate.Render('add')}`,
178
+ type: 'submit',
179
+ })}
180
+ ${await BtnIcon.Render({
181
+ class: `section-mp btn-custom btn-${idPanel}-clean`,
182
+ label: html`<i class="fa-solid fa-broom"></i> ${Translate.Render('clear')}`,
183
+ type: 'button',
184
+ })}
185
+ `;
186
+
187
+ setTimeout(async () => {
188
+ const resizeParentModal = () => {
189
+ if (options.parentIdModal) {
190
+ Modal.Data[options.parentIdModal].onObserverListener[`form-panel-${options.parentIdModal}`] = () => {
191
+ if (s(`.${idPanel}-form-container`))
192
+ s(`.${idPanel}-form-container`).style.maxHeight = `${
193
+ s(`.${options.parentIdModal}`).offsetHeight - Modal.headerTitleHeight
194
+ }px`;
195
+ };
196
+ Modal.Data[options.parentIdModal].onObserverListener[`form-panel-${options.parentIdModal}`]();
197
+ } else {
198
+ Responsive.Event[`${idPanel}-responsive`] = () => {
199
+ if (s(`.${idPanel}-form-container`))
200
+ s(`.${idPanel}-form-container`).style.maxHeight = `${
201
+ window.innerHeight -
202
+ heightTopBar -
203
+ heightBottomBar -
204
+ (options.customFormHeightAdjust ? options.customFormHeightAdjust : 0)
205
+ }px`;
206
+ };
207
+ Responsive.Event[`${idPanel}-responsive`]();
208
+ }
209
+ };
210
+ setTimeout(resizeParentModal);
211
+ if (options.route) {
212
+ RouterEvents[options.parentIdModal] = ({ route }) => {
213
+ if (route === options.route) {
214
+ setTimeout(() => {
215
+ resizeParentModal();
216
+ }, 350);
217
+ }
218
+ };
219
+ }
220
+
221
+ const validators = await Validator.instance(formData);
222
+
223
+ s(`.${idPanel}-form`).onsubmit = (e) => {
224
+ e.preventDefault();
225
+ s(`.btn-${idPanel}-submit`).click();
226
+ };
227
+ EventsUI.onClick(`.btn-${idPanel}-submit`, async (e) => {
228
+ e.preventDefault();
229
+ const { errorMessage } = await validators();
230
+ if (errorMessage) return;
231
+ const obj = Input.getValues(formData);
232
+ obj.id = `${data.length}`;
233
+ if (options && options.on && options.on.add) {
234
+ const { status } = await options.on.add({ data: obj });
235
+ if (status === 'error') return;
236
+ }
237
+ obj.new = html`<span class="bold" style="color: #ff533ecf;"> ${options.titleIcon} NEW ! </span>`;
238
+ data.push(obj);
239
+ prepend(`.${idPanel}-render`, await renderPanel(obj));
240
+ Input.cleanValues(formData);
241
+ s(`.btn-${idPanel}-close`).click();
242
+ s(`.${scrollClassContainer}`).scrollTop = 0;
243
+ });
244
+ s(`.btn-${idPanel}-clean`).onclick = () => {
245
+ Input.cleanValues(formData);
246
+ };
247
+ s(`.btn-${idPanel}-close`).onclick = (e) => {
248
+ e.preventDefault();
249
+ s(`.${idPanel}-form-body`).style.opacity = 0;
250
+ s(`.btn-${idPanel}-add`).classList.remove('hide');
251
+ s(`.${scrollClassContainer}`).style.overflow = 'auto';
252
+ if (options.customButtons) {
253
+ let customBtnIndex = -1;
254
+ for (const dataBtn of options.customButtons) {
255
+ customBtnIndex++;
256
+ const customBtnIndexFn = customBtnIndex;
257
+ const btnSelector = `btn-${idPanel}-custom${customBtnIndexFn}`;
258
+ s(`.${btnSelector}`).classList.remove('hide');
259
+ }
260
+ }
261
+ setTimeout(() => {
262
+ s(`.${idPanel}-form-body`).classList.add('hide');
263
+ });
264
+ };
265
+ s(`.btn-${idPanel}-add`).onclick = (e) => {
266
+ e.preventDefault();
267
+ s(`.${idPanel}-form-body`).classList.remove('hide');
268
+ s(`.btn-${idPanel}-add`).classList.add('hide');
269
+ s(`.${scrollClassContainer}`).style.overflow = 'hidden';
270
+ if (options.customButtons) {
271
+ let customBtnIndex = -1;
272
+ for (const dataBtn of options.customButtons) {
273
+ customBtnIndex++;
274
+ const customBtnIndexFn = customBtnIndex;
275
+ const btnSelector = `btn-${idPanel}-custom${customBtnIndexFn}`;
276
+ s(`.${btnSelector}`).classList.add('hide');
277
+ }
278
+ }
279
+ setTimeout(() => {
280
+ s(`.${idPanel}-form-body`).style.opacity = 1;
281
+ });
282
+ };
283
+ });
284
+
285
+ for (const obj of data) render += await renderPanel(obj);
286
+
287
+ this.Tokens[idPanel] = { idPanel, scrollClassContainer, formData, data, titleKey, subTitleKey, renderPanel };
288
+
289
+ let customButtonsRender = '';
290
+ if (options && options.customButtons) {
291
+ let customBtnIndex = -1;
292
+ for (const dataBtn of options.customButtons) {
293
+ customBtnIndex++;
294
+ const customBtnIndexFn = customBtnIndex;
295
+ const btnSelector = `btn-${idPanel}-custom${customBtnIndexFn}`;
296
+ if (dataBtn.onClick)
297
+ setTimeout(() => {
298
+ s(`.${btnSelector}`).onclick = () => dataBtn.onClick();
299
+ });
300
+ customButtonsRender += ` ${await BtnIcon.Render({
301
+ class: `section-mp btn-custom ${btnSelector}`,
302
+ label: dataBtn.label,
303
+ type: 'button',
304
+ })}`;
305
+ }
306
+ }
307
+
308
+ return html`
309
+ <style>
310
+ .${scrollClassContainer} {
311
+ scroll-behavior: smooth;
312
+ }
313
+ .${idPanel}-form-container {
314
+ padding-bottom: 20px;
315
+ top: 0px;
316
+ z-index: 1;
317
+ overflow: auto;
318
+ }
319
+ .${idPanel}-form {
320
+ max-width: 900px;
321
+ }
322
+ .${idPanel}-cell {
323
+ min-height: 200px;
324
+ }
325
+ .${idPanel}-container {
326
+ }
327
+ .${idPanel} {
328
+ margin: 10px;
329
+ transition: 0.3s;
330
+ cursor: default;
331
+ border-radius: 10px;
332
+ background: white;
333
+ color: black;
334
+ padding: 10px;
335
+ }
336
+ .${idPanel}-head {
337
+ /* background: white; */
338
+ margin-bottom: 10px;
339
+ }
340
+ .img-${idPanel} {
341
+ width: 100%;
342
+ }
343
+ .${idPanel}-title {
344
+ color: rgba(109, 104, 255, 1);
345
+ font-size: 24px;
346
+ padding: 15px;
347
+ }
348
+ .${idPanel}-row {
349
+ padding: 5px;
350
+ margin: 5px;
351
+ font-size: 16px;
352
+ }
353
+ .${idPanel}-subtitle {
354
+ font-size: 17px;
355
+ margin-left: 20px;
356
+ top: -7px;
357
+ }
358
+ .${idPanel}-row-key {
359
+ }
360
+ .${idPanel}-row-value {
361
+ }
362
+ .${idPanel}-row-pin-key {
363
+ }
364
+ .${idPanel}-row-pin-value {
365
+ font-size: 20px;
366
+ color: rgb(19 190 84);
367
+ }
368
+ .${idPanel}-form-header {
369
+ }
370
+ .${idPanel}-form-body {
371
+ transition: 0.3s;
372
+ }
373
+ .btn-${idPanel}-add {
374
+ padding: 10px;
375
+ font-size: 20px;
376
+ }
377
+ .${idPanel}-dropdown {
378
+ min-height: 100px;
379
+ }
380
+ </style>
381
+ <div class="${idPanel}-container">
382
+ <div
383
+ class="stq modal ${idPanel}-form-container ${options.formContainerClass ? options.formContainerClass : ''}"
384
+ >
385
+ <div class="in ${idPanel}-form-header">
386
+ ${await BtnIcon.Render({
387
+ class: `section-mp btn-custom btn-${idPanel}-add`,
388
+ label: html`<i class="fas fa-plus"></i> ${Translate.Render('add')}`,
389
+ type: 'button',
390
+ })}
391
+ ${customButtonsRender}
392
+ </div>
393
+ <div class="in ${idPanel}-form-body hide" style="opacity: 0">
394
+ <form class="in ${idPanel}-form">
395
+ <div class="fl">${renderForm}</div>
396
+ <div class="in">${renderFormBtn}</div>
397
+ <br /><br />
398
+ </form>
399
+ </div>
400
+ </div>
401
+ ${dynamicCol({
402
+ id: `${idPanel}-cell`,
403
+ containerSelector: `${idPanel}-render`,
404
+ limit: 500,
405
+ type: 'a-50-b-50',
406
+ })}
407
+ <div class="in ${idPanel}-render">${render}</div>
408
+ </div>
409
+ `;
410
+ },
411
+ };
412
+
413
+ export { Panel };
@@ -0,0 +1,162 @@
1
+ // https://underpost.net/cube.php
2
+
3
+ import { BtnIcon } from './BtnIcon.js';
4
+ import { getId, random } from './CommonJs.js';
5
+ import { dynamicCol } from './Css.js';
6
+ import { htmls, s } from './VanillaJs.js';
7
+
8
+ // https://css-loaders.com/3d/
9
+
10
+ const Polyhedron = {
11
+ Tokens: {},
12
+ Render: async function (options) {
13
+ const id = options?.id ? options.id : getId(this.Tokens, 'polyhedron-');
14
+ if (!this.Tokens[id])
15
+ this.Tokens[id] = {
16
+ cr: [-25, -57, 90],
17
+ ct: [0, 0, 0],
18
+ dim: 150,
19
+ interval: null,
20
+ };
21
+ const renderTransform = () => {
22
+ s(
23
+ `.polyhedron-${id}`,
24
+ ).style.transform = `rotateX(${this.Tokens[id].cr[0]}deg) rotateY(${this.Tokens[id].cr[1]}deg) rotateZ(${this.Tokens[id].cr[2]}deg)
25
+ translateX(${this.Tokens[id].ct[0]}px) translateY(${this.Tokens[id].ct[1]}px) translateZ(${this.Tokens[id].ct[2]}px)`;
26
+ s(`.polyhedron-${id}`).style.left = `${s(`.scene-${id}`).offsetWidth / 2 - this.Tokens[id].dim / 2}px`;
27
+ s(`.polyhedron-${id}`).style.top = `${s(`.scene-${id}`).offsetHeight / 2 - this.Tokens[id].dim / 2}px`;
28
+ s(`.polyhedron-${id}`).style.width = `${this.Tokens[id].dim}px`;
29
+ s(`.polyhedron-${id}`).style.height = `${this.Tokens[id].dim}px`;
30
+ /* rotate Y */
31
+ s(`.face_front-${id}`).style.transform = `rotateY(0deg) translateZ(${this.Tokens[id].dim / 2}px)`;
32
+ s(`.face_back-${id}`).style.transform = `rotateY(-180deg) translateZ(${this.Tokens[id].dim / 2}px)`;
33
+ s(`.face_left-${id}`).style.transform = `rotateY(90deg) translateZ(${this.Tokens[id].dim / 2}px)`;
34
+ s(`.face_right-${id}`).style.transform = `rotateY(-90deg) translateZ(${this.Tokens[id].dim / 2}px)`;
35
+ /* rotate X */
36
+ s(`.face_top-${id}`).style.transform = `rotateX(-90deg) translateZ(${this.Tokens[id].dim / 2}px)`;
37
+ s(`.face_bottom-${id}`).style.transform = `rotateX(90deg) translateZ(${this.Tokens[id].dim / 2}px)`;
38
+ };
39
+ if (this.Tokens[id].interval) clearInterval(this.Tokens[id].interval);
40
+ this.Tokens[id].interval = setInterval(() => {
41
+ if (s(`.polyhedron-${id}`)) renderTransform();
42
+ else return clearInterval(this.Tokens[id].interval);
43
+ }, 200);
44
+
45
+ setTimeout(() => {
46
+ renderTransform();
47
+ s(`.polyhedron-${id}`).style.transition = `.4s`;
48
+
49
+ s(`.btn-polyhedron-rotate-down-${id}`).onclick = () => {
50
+ this.Tokens[id].cr[0] += 45;
51
+ };
52
+ s(`.btn-polyhedron-rotate-up-${id}`).onclick = () => {
53
+ this.Tokens[id].cr[0] -= 45;
54
+ };
55
+ s(`.btn-polyhedron-rotate-left-${id}`).onclick = () => {
56
+ this.Tokens[id].cr[1] += 45;
57
+ };
58
+ s(`.btn-polyhedron-rotate-right-${id}`).onclick = () => {
59
+ this.Tokens[id].cr[1] -= 45;
60
+ };
61
+
62
+ s(`.btn-polyhedron-add-zoom-${id}`).onclick = () => {
63
+ this.Tokens[id].dim += 25;
64
+ };
65
+ s(`.btn-polyhedron-remove-zoom-${id}`).onclick = () => {
66
+ this.Tokens[id].dim -= 25;
67
+ };
68
+ });
69
+ return html`
70
+ <style>
71
+ .scene-${id} {
72
+ height: 500px;
73
+ background: #c7c7c7;
74
+ overflow: hidden;
75
+ /* perspective: 10000px; */
76
+ }
77
+ .polyhedron-${id} {
78
+ transform-style: preserve-3d;
79
+ cursor: pointer;
80
+ }
81
+ .face-${id} {
82
+ width: 100%;
83
+ height: 100%;
84
+ }
85
+
86
+ ${options?.style?.face
87
+ ? css`
88
+ .face-${id} {
89
+ ${Object.keys(options.style.face)
90
+ .map((styleKey) => `${styleKey} : ${options.style.face[styleKey]};`)
91
+ .join('')}
92
+ }
93
+ `
94
+ : css``}
95
+ ${options?.style?.scene
96
+ ? css`
97
+ .scene-${id} {
98
+ ${Object.keys(options.style.scene)
99
+ .map((styleKey) => `${styleKey} : ${options.style.scene[styleKey]};`)
100
+ .join('')}
101
+ }
102
+ `
103
+ : css``}
104
+ </style>
105
+ <!--
106
+ <style class="polyhedron-animation-${id}"></style>
107
+ -->
108
+
109
+ ${dynamicCol({ containerSelector: options.idModal, id: `polyhedron-${id}` })}
110
+ <div class="fl">
111
+ <div class="in fll polyhedron-${id}-col-a">
112
+ <div class="in section-mp">
113
+ <div class="in sub-title-modal"><i class="fa-solid fa-arrows-spin"></i> Rotate</div>
114
+ ${await BtnIcon.Render({
115
+ class: `inl section-mp btn-custom btn-polyhedron-rotate-up-${id}`,
116
+ label: html`<i class="fa-solid fa-angle-up"></i>`,
117
+ })}
118
+ ${await BtnIcon.Render({
119
+ class: `inl section-mp btn-custom btn-polyhedron-rotate-down-${id}`,
120
+ label: html`<i class="fa-solid fa-angle-down"></i>`,
121
+ })}
122
+ ${await BtnIcon.Render({
123
+ class: `inl section-mp btn-custom btn-polyhedron-rotate-left-${id}`,
124
+ label: html`<i class="fa-solid fa-angle-left"></i>`,
125
+ })}
126
+ ${await BtnIcon.Render({
127
+ class: `inl section-mp btn-custom btn-polyhedron-rotate-right-${id}`,
128
+ label: html`<i class="fa-solid fa-angle-right"></i>`,
129
+ })}
130
+
131
+ <div class="in sub-title-modal"><i class="fa-solid fa-magnifying-glass"></i> Zoom</div>
132
+ ${await BtnIcon.Render({
133
+ class: `inl section-mp btn-custom btn-polyhedron-add-zoom-${id}`,
134
+ label: html`<i class="fa-solid fa-plus"></i>`,
135
+ })}
136
+ ${await BtnIcon.Render({
137
+ class: `inl section-mp btn-custom btn-polyhedron-remove-zoom-${id}`,
138
+ label: html`<i class="fa-solid fa-minus"></i>`,
139
+ })}
140
+ </div>
141
+ </div>
142
+ <div class="in fll polyhedron-${id}-col-b">
143
+ <div class="in section-mp">
144
+ <div class="in sub-title-modal"><i class="fa-solid fa-vector-square"></i> Render</div>
145
+ <div class="in scene-${id}">
146
+ <div class="abs polyhedron-${id}">
147
+ <div class="abs face-${id} face_front-${id} ${id}-0"><div class="abs center">1</div></div>
148
+ <div class="abs face-${id} face_bottom-${id} ${id}-1"><div class="abs center">2</div></div>
149
+ <div class="abs face-${id} face_back-${id} ${id}-2"><div class="abs center">3</div></div>
150
+ <div class="abs face-${id} face_top-${id} ${id}-3"><div class="abs center">4</div></div>
151
+ <div class="abs face-${id} face_right-${id} ${id}-4"><div class="abs center">5</div></div>
152
+ <div class="abs face-${id} face_left-${id} ${id}-5"><div class="abs center">6</div></div>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ `;
159
+ },
160
+ };
161
+
162
+ export { Polyhedron };