@underpostnet/underpost 2.7.9

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 (297) hide show
  1. package/.dockerignore +14 -0
  2. package/.env.development +6 -0
  3. package/.env.production +6 -0
  4. package/.env.test +6 -0
  5. package/.github/workflows/ghpkg.yml +115 -0
  6. package/.github/workflows/publish.yml +84 -0
  7. package/.github/workflows/pwa-microservices-template.page.yml +54 -0
  8. package/.github/workflows/pwa-microservices-template.test.yml +30 -0
  9. package/.nycrc +9 -0
  10. package/.prettierignore +13 -0
  11. package/.prettierrc +9 -0
  12. package/.vscode/extensions.json +72 -0
  13. package/.vscode/settings.json +106 -0
  14. package/AUTHORS.md +10 -0
  15. package/CHANGELOG.md +85 -0
  16. package/Dockerfile +90 -0
  17. package/LICENSE +21 -0
  18. package/README.md +96 -0
  19. package/bin/cron.js +47 -0
  20. package/bin/db.js +180 -0
  21. package/bin/deploy.js +859 -0
  22. package/bin/file.js +109 -0
  23. package/bin/index.js +82 -0
  24. package/bin/ssl.js +55 -0
  25. package/bin/util.js +204 -0
  26. package/bin/vs.js +35 -0
  27. package/conf.js +265 -0
  28. package/docker-compose.yml +67 -0
  29. package/jsconfig.json +7 -0
  30. package/jsdoc.json +32 -0
  31. package/nodemon.json +6 -0
  32. package/package.json +134 -0
  33. package/prometheus.yml +36 -0
  34. package/src/api/core/core.controller.js +69 -0
  35. package/src/api/core/core.model.js +11 -0
  36. package/src/api/core/core.router.js +23 -0
  37. package/src/api/core/core.service.js +31 -0
  38. package/src/api/crypto/crypto.controller.js +51 -0
  39. package/src/api/crypto/crypto.model.js +23 -0
  40. package/src/api/crypto/crypto.router.js +20 -0
  41. package/src/api/crypto/crypto.service.js +64 -0
  42. package/src/api/default/default.controller.js +69 -0
  43. package/src/api/default/default.model.js +20 -0
  44. package/src/api/default/default.router.js +23 -0
  45. package/src/api/default/default.service.js +31 -0
  46. package/src/api/file/file.controller.js +53 -0
  47. package/src/api/file/file.model.js +19 -0
  48. package/src/api/file/file.router.js +21 -0
  49. package/src/api/file/file.service.js +80 -0
  50. package/src/api/instance/instance.controller.js +69 -0
  51. package/src/api/instance/instance.model.js +36 -0
  52. package/src/api/instance/instance.router.js +33 -0
  53. package/src/api/instance/instance.service.js +48 -0
  54. package/src/api/test/test.controller.js +59 -0
  55. package/src/api/test/test.model.js +14 -0
  56. package/src/api/test/test.router.js +21 -0
  57. package/src/api/test/test.service.js +35 -0
  58. package/src/api/user/user.build.js +16 -0
  59. package/src/api/user/user.controller.js +70 -0
  60. package/src/api/user/user.model.js +65 -0
  61. package/src/api/user/user.router.js +345 -0
  62. package/src/api/user/user.service.js +479 -0
  63. package/src/api.js +23 -0
  64. package/src/client/Default.index.js +40 -0
  65. package/src/client/components/core/Account.js +290 -0
  66. package/src/client/components/core/AgGrid.js +160 -0
  67. package/src/client/components/core/Auth.js +19 -0
  68. package/src/client/components/core/Badge.js +32 -0
  69. package/src/client/components/core/Blockchain.js +41 -0
  70. package/src/client/components/core/Blog.js +9 -0
  71. package/src/client/components/core/BtnIcon.js +101 -0
  72. package/src/client/components/core/CalendarCore.js +458 -0
  73. package/src/client/components/core/Chat.js +64 -0
  74. package/src/client/components/core/ColorPalette.js +5267 -0
  75. package/src/client/components/core/CommonJs.js +742 -0
  76. package/src/client/components/core/Content.js +193 -0
  77. package/src/client/components/core/Css.js +846 -0
  78. package/src/client/components/core/CssCore.js +844 -0
  79. package/src/client/components/core/D3Chart.js +44 -0
  80. package/src/client/components/core/Docs.js +331 -0
  81. package/src/client/components/core/DropDown.js +164 -0
  82. package/src/client/components/core/EventsUI.js +46 -0
  83. package/src/client/components/core/FileExplorer.js +699 -0
  84. package/src/client/components/core/FullScreen.js +45 -0
  85. package/src/client/components/core/Input.js +346 -0
  86. package/src/client/components/core/JoyStick.js +77 -0
  87. package/src/client/components/core/Keyboard.js +73 -0
  88. package/src/client/components/core/LoadingAnimation.js +178 -0
  89. package/src/client/components/core/LogIn.js +187 -0
  90. package/src/client/components/core/LogOut.js +58 -0
  91. package/src/client/components/core/Logger.js +26 -0
  92. package/src/client/components/core/Modal.js +1814 -0
  93. package/src/client/components/core/NotificationManager.js +84 -0
  94. package/src/client/components/core/Panel.js +613 -0
  95. package/src/client/components/core/PanelForm.js +469 -0
  96. package/src/client/components/core/Polyhedron.js +162 -0
  97. package/src/client/components/core/Recover.js +204 -0
  98. package/src/client/components/core/Responsive.js +68 -0
  99. package/src/client/components/core/RichText.js +53 -0
  100. package/src/client/components/core/Router.js +76 -0
  101. package/src/client/components/core/Scroll.js +34 -0
  102. package/src/client/components/core/SignUp.js +125 -0
  103. package/src/client/components/core/SocketIo.js +72 -0
  104. package/src/client/components/core/Stream.js +113 -0
  105. package/src/client/components/core/ToggleSwitch.js +87 -0
  106. package/src/client/components/core/ToolTip.js +26 -0
  107. package/src/client/components/core/Translate.js +446 -0
  108. package/src/client/components/core/Validator.js +100 -0
  109. package/src/client/components/core/VanillaJs.js +463 -0
  110. package/src/client/components/core/Wallet.js +106 -0
  111. package/src/client/components/core/WebComponent.js +44 -0
  112. package/src/client/components/core/Webhook.js +25 -0
  113. package/src/client/components/core/Worker.js +280 -0
  114. package/src/client/components/default/CommonDefault.js +29 -0
  115. package/src/client/components/default/CssDefault.js +13 -0
  116. package/src/client/components/default/ElementsDefault.js +38 -0
  117. package/src/client/components/default/LogInDefault.js +41 -0
  118. package/src/client/components/default/LogOutDefault.js +28 -0
  119. package/src/client/components/default/MenuDefault.js +389 -0
  120. package/src/client/components/default/RoutesDefault.js +48 -0
  121. package/src/client/components/default/SettingsDefault.js +16 -0
  122. package/src/client/components/default/SignUpDefault.js +9 -0
  123. package/src/client/components/default/SocketIoDefault.js +54 -0
  124. package/src/client/components/default/TranslateDefault.js +7 -0
  125. package/src/client/public/default/android-chrome-144x144.png +0 -0
  126. package/src/client/public/default/android-chrome-192x192.png +0 -0
  127. package/src/client/public/default/android-chrome-256x256.png +0 -0
  128. package/src/client/public/default/android-chrome-36x36.png +0 -0
  129. package/src/client/public/default/android-chrome-384x384.png +0 -0
  130. package/src/client/public/default/android-chrome-48x48.png +0 -0
  131. package/src/client/public/default/android-chrome-512x512.png +0 -0
  132. package/src/client/public/default/android-chrome-72x72.png +0 -0
  133. package/src/client/public/default/android-chrome-96x96.png +0 -0
  134. package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
  135. package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
  136. package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
  137. package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
  138. package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
  139. package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
  140. package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
  141. package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
  142. package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
  143. package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
  144. package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
  145. package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
  146. package/src/client/public/default/apple-touch-icon.png +0 -0
  147. package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
  148. package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
  149. package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
  150. package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
  151. package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
  152. package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
  153. package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
  154. package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
  155. package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
  156. package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
  157. package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
  158. package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
  159. package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
  160. package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
  161. package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
  162. package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
  163. package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
  164. package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
  165. package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
  166. package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
  167. package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
  168. package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
  169. package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
  170. package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
  171. package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
  172. package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
  173. package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
  174. package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
  175. package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
  176. package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
  177. package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
  178. package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
  179. package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
  180. package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
  181. package/src/client/public/default/assets/background/white.jpg +0 -0
  182. package/src/client/public/default/assets/background/white0-min.jpg +0 -0
  183. package/src/client/public/default/assets/background/white0.jpg +0 -0
  184. package/src/client/public/default/assets/logo/base-icon.png +0 -0
  185. package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
  186. package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
  187. package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
  188. package/src/client/public/default/browserconfig.xml +12 -0
  189. package/src/client/public/default/favicon-16x16.png +0 -0
  190. package/src/client/public/default/favicon-32x32.png +0 -0
  191. package/src/client/public/default/favicon-48x48.png +0 -0
  192. package/src/client/public/default/favicon.ico +0 -0
  193. package/src/client/public/default/manifest.webmanifest +69 -0
  194. package/src/client/public/default/mstile-144x144.png +0 -0
  195. package/src/client/public/default/mstile-150x150.png +0 -0
  196. package/src/client/public/default/mstile-310x150.png +0 -0
  197. package/src/client/public/default/mstile-310x310.png +0 -0
  198. package/src/client/public/default/mstile-70x70.png +0 -0
  199. package/src/client/public/default/plantuml/client-conf.svg +1 -0
  200. package/src/client/public/default/plantuml/client-schema.svg +1 -0
  201. package/src/client/public/default/plantuml/cron-conf.svg +1 -0
  202. package/src/client/public/default/plantuml/cron-schema.svg +1 -0
  203. package/src/client/public/default/plantuml/server-conf.svg +1 -0
  204. package/src/client/public/default/plantuml/server-schema.svg +1 -0
  205. package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
  206. package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
  207. package/src/client/public/default/site.webmanifest +69 -0
  208. package/src/client/public/default/sitemap +148 -0
  209. package/src/client/public/default/yandex-browser-50x50.png +0 -0
  210. package/src/client/public/default/yandex-browser-manifest.json +9 -0
  211. package/src/client/public/doc/favicon.ico +0 -0
  212. package/src/client/public/doc/sitemap +148 -0
  213. package/src/client/public/test/favicon.ico +0 -0
  214. package/src/client/public/test/sitemap +148 -0
  215. package/src/client/services/core/core.service.js +170 -0
  216. package/src/client/services/crypto/crypto.service.js +70 -0
  217. package/src/client/services/default/default.management.js +343 -0
  218. package/src/client/services/default/default.service.js +89 -0
  219. package/src/client/services/file/file.service.js +70 -0
  220. package/src/client/services/instance/instance.management.js +74 -0
  221. package/src/client/services/instance/instance.service.js +89 -0
  222. package/src/client/services/test/test.service.js +70 -0
  223. package/src/client/services/user/user.management.js +50 -0
  224. package/src/client/services/user/user.service.js +89 -0
  225. package/src/client/ssr/Render.js +237 -0
  226. package/src/client/ssr/common/Alert.js +75 -0
  227. package/src/client/ssr/common/SsrCore.js +91 -0
  228. package/src/client/ssr/common/Translate.js +26 -0
  229. package/src/client/ssr/common/Worker.js +28 -0
  230. package/src/client/ssr/components/body/CacheControl.js +114 -0
  231. package/src/client/ssr/components/body/DefaultSplashScreen.js +90 -0
  232. package/src/client/ssr/components/email/DefaultRecoverEmail.js +21 -0
  233. package/src/client/ssr/components/email/DefaultVerifyEmail.js +17 -0
  234. package/src/client/ssr/components/head/Css.js +241 -0
  235. package/src/client/ssr/components/head/DefaultScripts.js +3 -0
  236. package/src/client/ssr/components/head/Production.js +1 -0
  237. package/src/client/ssr/components/head/Pwa.js +146 -0
  238. package/src/client/ssr/components/head/PwaDefault.js +60 -0
  239. package/src/client/ssr/components/head/Seo.js +14 -0
  240. package/src/client/ssr/pages/404.js +12 -0
  241. package/src/client/ssr/pages/500.js +12 -0
  242. package/src/client/ssr/pages/maintenance.js +14 -0
  243. package/src/client/ssr/pages/offline.js +21 -0
  244. package/src/client/sw/default.sw.js +205 -0
  245. package/src/client/sw/template.sw.js +84 -0
  246. package/src/client.build.js +22 -0
  247. package/src/client.dev.js +21 -0
  248. package/src/db/DataBaseProvider.js +45 -0
  249. package/src/db/mariadb/MariaDB.js +33 -0
  250. package/src/db/mongo/MongooseDB.js +124 -0
  251. package/src/dns.js +22 -0
  252. package/src/index.js +43 -0
  253. package/src/mailer/EmailRender.js +69 -0
  254. package/src/mailer/MailerProvider.js +96 -0
  255. package/src/proxy.js +22 -0
  256. package/src/runtime/lampp/Lampp.js +115 -0
  257. package/src/runtime/nginx/Nginx.js +3 -0
  258. package/src/runtime/xampp/Xampp.js +49 -0
  259. package/src/server/auth.js +235 -0
  260. package/src/server/backup.js +120 -0
  261. package/src/server/client-build-live.js +98 -0
  262. package/src/server/client-build.js +754 -0
  263. package/src/server/client-dev-server.js +60 -0
  264. package/src/server/client-formatted.js +58 -0
  265. package/src/server/client-icons.js +151 -0
  266. package/src/server/conf.js +929 -0
  267. package/src/server/crypto.js +91 -0
  268. package/src/server/dns.js +118 -0
  269. package/src/server/downloader.js +42 -0
  270. package/src/server/logger.js +190 -0
  271. package/src/server/network.js +209 -0
  272. package/src/server/peer.js +33 -0
  273. package/src/server/process.js +66 -0
  274. package/src/server/prompt-optimizer.js +28 -0
  275. package/src/server/proxy.js +118 -0
  276. package/src/server/runtime.js +463 -0
  277. package/src/server/ssl.js +120 -0
  278. package/src/server.js +25 -0
  279. package/src/ws/IoInterface.js +45 -0
  280. package/src/ws/IoServer.js +39 -0
  281. package/src/ws/core/channels/core.ws.chat.js +23 -0
  282. package/src/ws/core/channels/core.ws.mailer.js +35 -0
  283. package/src/ws/core/channels/core.ws.stream.js +31 -0
  284. package/src/ws/core/core.ws.connection.js +28 -0
  285. package/src/ws/core/core.ws.emit.js +14 -0
  286. package/src/ws/core/core.ws.server.js +24 -0
  287. package/src/ws/core/management/core.ws.chat.js +8 -0
  288. package/src/ws/core/management/core.ws.mailer.js +16 -0
  289. package/src/ws/core/management/core.ws.stream.js +8 -0
  290. package/src/ws/default/channels/default.ws.main.js +16 -0
  291. package/src/ws/default/default.ws.connection.js +22 -0
  292. package/src/ws/default/default.ws.emit.js +14 -0
  293. package/src/ws/default/default.ws.server.js +20 -0
  294. package/src/ws/default/management/default.ws.main.js +8 -0
  295. package/startup.js +11 -0
  296. package/supervisord-openssh-server.conf +5 -0
  297. package/test/api.test.js +60 -0
@@ -0,0 +1,469 @@
1
+ import { getCapVariableName, getId, newInstance, random, range, timer, uniqueArray } from './CommonJs.js';
2
+ import { marked } from 'marked';
3
+ import {
4
+ getBlobFromUint8ArrayFile,
5
+ getDataFromInputFile,
6
+ getQueryParams,
7
+ getRawContentFile,
8
+ htmls,
9
+ } from './VanillaJs.js';
10
+ import { Panel } from './Panel.js';
11
+ import { NotificationManager } from './NotificationManager.js';
12
+ import { DocumentService } from '../../services/document/document.service.js';
13
+ import { FileService } from '../../services/file/file.service.js';
14
+ import { getSrcFromFileData } from './Input.js';
15
+ import { Auth } from './Auth.js';
16
+ import { imageShimmer, renderCssAttr } from './Css.js';
17
+ import { Translate } from './Translate.js';
18
+ import { Modal } from './Modal.js';
19
+ import { listenQueryPathInstance, setQueryPath } from './Router.js';
20
+
21
+ const PanelForm = {
22
+ Data: {},
23
+ instance: async function (
24
+ options = {
25
+ idPanel: '',
26
+ heightTopBar: 50,
27
+ heightBottomBar: 50,
28
+ defaultUrlImage: '',
29
+ Elements: {},
30
+ parentIdModal: undefined,
31
+ route: 'home',
32
+ },
33
+ ) {
34
+ const { idPanel, heightTopBar, heightBottomBar, defaultUrlImage, Elements } = options;
35
+
36
+ let prefixTags = [idPanel, 'public'];
37
+ this.Data[idPanel] = {
38
+ originData: [],
39
+ data: [],
40
+ filesData: [],
41
+ };
42
+
43
+ const formData = [
44
+ {
45
+ id: 'panel-title',
46
+ model: 'title',
47
+ inputType: 'text',
48
+ rules: [{ type: 'isEmpty' }],
49
+ panel: { type: 'title' },
50
+ },
51
+ {
52
+ id: 'panel-createdAt',
53
+ model: 'createdAt',
54
+ inputType: 'datetime-local',
55
+ panel: { type: 'subtitle' },
56
+ rules: [{ type: 'isEmpty' }],
57
+ disableRender: true,
58
+ },
59
+ {
60
+ id: 'panel-fileId',
61
+ model: 'fileId',
62
+ inputType: 'file',
63
+ rules: [],
64
+ panel: {},
65
+ },
66
+ {
67
+ id: 'panel-tags',
68
+ model: 'tags',
69
+ label: {
70
+ disabled: true,
71
+ },
72
+ inputType: 'text',
73
+ panel: { type: 'tags' },
74
+ // panel: {
75
+ // type: 'info-row-pin',
76
+ // icon: {
77
+ // value: html``,
78
+ // },
79
+ // },
80
+ rules: [{ type: 'isEmpty' }],
81
+ },
82
+ {
83
+ id: 'panel-mdFileId',
84
+ model: 'mdFileId',
85
+ inputType: 'md',
86
+ panel: { type: 'info-row' },
87
+ rules: [],
88
+ label: {
89
+ disabled: true,
90
+ },
91
+ },
92
+ ];
93
+ const dateFormat = (date) =>
94
+ html`<span
95
+ style="${renderCssAttr({
96
+ style: {
97
+ 'font-size': '14px',
98
+ color: '#888',
99
+ },
100
+ })}"
101
+ >${new Date(date).toLocaleString().replaceAll(',', '')}</span
102
+ >`;
103
+ const titleIcon = html`<i class="fa-solid fa-quote-left"></i>`;
104
+ const panelRender = async ({ data }) =>
105
+ await Panel.Render({
106
+ idPanel,
107
+ formData,
108
+ heightTopBar,
109
+ heightBottomBar,
110
+ data,
111
+ parentIdModal: options.parentIdModal,
112
+ originData: () => PanelForm.Data[idPanel].originData,
113
+ filesData: () => PanelForm.Data[idPanel].filesData,
114
+ scrollClassContainer: options.scrollClassContainer ? options.scrollClassContainer : 'main-body',
115
+ titleIcon,
116
+ formContainerClass: 'session-in-log-in',
117
+ onClick: async function ({ payload }) {
118
+ if (options.route) {
119
+ setQueryPath({ path: options.route, queryPath: payload._id });
120
+ if (options.parentIdModal) Modal.Data[options.parentIdModal].query = `${window.location.search}`;
121
+ if (PanelForm.Data[idPanel].updatePanel) await PanelForm.Data[idPanel].updatePanel();
122
+ }
123
+ },
124
+ callBackPanelRender: async function (options) {
125
+ if (options.data.ssr) {
126
+ return await options.htmlRender({
127
+ render: imageShimmer(),
128
+ });
129
+ }
130
+ if (!options.data.fileId)
131
+ return await options.htmlRender({
132
+ render: html`
133
+ <img
134
+ class="abs center"
135
+ style="${renderCssAttr({
136
+ style: {
137
+ width: '100px',
138
+ height: '100px',
139
+ opacity: 0.2,
140
+ },
141
+ })}"
142
+ src="${defaultUrlImage}"
143
+ />
144
+ `,
145
+ });
146
+ return await options.fileRender({
147
+ file: PanelForm.Data[idPanel].filesData.find((f) => f._id === options.data._id).fileId.fileBlob,
148
+ style: {
149
+ overflow: 'auto',
150
+ width: '100%',
151
+ height: 'auto',
152
+ },
153
+ });
154
+ },
155
+ on: {
156
+ remove: async function ({ e, data }) {
157
+ e.preventDefault();
158
+ const confirmResult = await Modal.RenderConfirm({
159
+ html: async () => {
160
+ return html`
161
+ <div class="in section-mp" style="text-align: center">
162
+ ${Translate.Render('confirm-delete-item')}
163
+ <br />
164
+ "${data.title}"
165
+ </div>
166
+ `;
167
+ },
168
+ id: `delete-${idPanel}`,
169
+ });
170
+ if (confirmResult.status === 'confirm') {
171
+ const { status, message } = await DocumentService.delete({
172
+ id: data._id,
173
+ });
174
+ NotificationManager.Push({
175
+ html: status,
176
+ status,
177
+ });
178
+ if (getQueryParams().cid === data.id) {
179
+ setQueryPath({ path: options.route, queryPath: '' });
180
+ if (PanelForm.Data[idPanel].updatePanel) await PanelForm.Data[idPanel].updatePanel();
181
+ }
182
+
183
+ return { status };
184
+ }
185
+ return { status: 'error' };
186
+ },
187
+ add: async function ({ data, editId }) {
188
+ let mdFileId;
189
+ const mdFileName = `${getCapVariableName(data.title)}.md`;
190
+ const location = `${prefixTags.join('/')}`;
191
+ const blob = new Blob([data.mdFileId], { type: 'text/markdown' });
192
+ const md = new File([blob], mdFileName, { type: 'text/markdown' });
193
+ const tags = uniqueArray(
194
+ data.tags
195
+ .replaceAll('/', ',')
196
+ .replaceAll('-', ',')
197
+ .replaceAll(' ', ',')
198
+ .split(',')
199
+ .map((t) => t.trim())
200
+ .filter((t) => t)
201
+ .concat(prefixTags),
202
+ );
203
+ let originObj, originFileObj, indexOriginObj;
204
+ if (editId) {
205
+ indexOriginObj = PanelForm.Data[idPanel].originData.findIndex((d) => d._id === editId);
206
+ if (indexOriginObj > -1) {
207
+ originObj = PanelForm.Data[idPanel].originData[indexOriginObj];
208
+ originFileObj = PanelForm.Data[idPanel].filesData.find((d) => d._id === editId);
209
+ }
210
+ }
211
+
212
+ const mdBlob = {
213
+ data: {
214
+ data: await getDataFromInputFile(md),
215
+ },
216
+ mimetype: md.type,
217
+ name: md.name,
218
+ };
219
+ const mdPlain = await getRawContentFile(getBlobFromUint8ArrayFile(mdBlob.data.data, mdBlob.mimetype));
220
+ const baseNewDoc = newInstance(data);
221
+ baseNewDoc.tags = tags.filter((t) => !prefixTags.includes(t));
222
+ baseNewDoc.mdFileId = marked.parse(data.mdFileId);
223
+ baseNewDoc.userId = Elements.Data.user.main.model.user._id;
224
+ baseNewDoc.tools = true;
225
+
226
+ const documents = [];
227
+ let message = '';
228
+ let status = 'success';
229
+ let indexFormDoc = -1;
230
+ const filesData = data.fileId ? data.fileId : [null];
231
+
232
+ for (const file of filesData) {
233
+ indexFormDoc++;
234
+ let fileId;
235
+
236
+ await (async () => {
237
+ const body = new FormData();
238
+ body.append('md', md);
239
+ if (file) body.append('file', file);
240
+ const { status, data } = await FileService.post({ body });
241
+ // await timer(3000);
242
+ NotificationManager.Push({
243
+ html: Translate.Render(`${status}-upload-file`),
244
+ status,
245
+ });
246
+ if (status === 'success') {
247
+ mdFileId = data[0]._id;
248
+ if (data[1]) fileId = data[1]._id;
249
+ }
250
+ })();
251
+ const body = {
252
+ location,
253
+ tags,
254
+ fileId,
255
+ mdFileId,
256
+ title: data.title,
257
+ };
258
+ const {
259
+ status: documentStatus,
260
+ message: documentMessage,
261
+ data: documentData,
262
+ } = originObj && indexFormDoc === 0
263
+ ? await DocumentService.put({ id: originObj._id, body })
264
+ : await DocumentService.post({
265
+ body,
266
+ });
267
+
268
+ const newDoc = {
269
+ ...baseNewDoc,
270
+ fileId: file ? URL.createObjectURL(file) : undefined,
271
+ _id: documentData._id,
272
+ id: documentData._id,
273
+ createdAt: dateFormat(documentData.createdAt),
274
+ };
275
+
276
+ if (documentStatus === 'error') status = 'error';
277
+ if (message) message += `${indexFormDoc === 0 ? '' : ', '}${documentMessage}`;
278
+
279
+ const filesData = {
280
+ id: documentData._id,
281
+ _id: documentData._id,
282
+ mdFileId: { mdBlob, mdPlain },
283
+ fileId: {
284
+ fileBlob: file
285
+ ? {
286
+ data: {
287
+ data: await getDataFromInputFile(file),
288
+ },
289
+ mimetype: file.type,
290
+ name: file.name,
291
+ }
292
+ : undefined,
293
+ filePlain: undefined,
294
+ },
295
+ };
296
+
297
+ if (originObj && indexFormDoc === 0) {
298
+ PanelForm.Data[idPanel].originData[indexOriginObj] = documentData;
299
+ PanelForm.Data[idPanel].data[indexOriginObj] = newDoc;
300
+ PanelForm.Data[idPanel].filesData[indexOriginObj] = filesData;
301
+ } else {
302
+ PanelForm.Data[idPanel].originData.push(documentData);
303
+ PanelForm.Data[idPanel].data.push(newDoc);
304
+ PanelForm.Data[idPanel].filesData.push(filesData);
305
+ }
306
+ documents.push(newDoc);
307
+ }
308
+
309
+ NotificationManager.Push({
310
+ html:
311
+ status === 'success'
312
+ ? originObj
313
+ ? Translate.Render('success-edit-post')
314
+ : Translate.Render('success-add-post')
315
+ : message,
316
+ status: status,
317
+ });
318
+
319
+ setQueryPath({ path: options.route, queryPath: documents.map((d) => d._id).join(',') });
320
+ if (options.parentIdModal) Modal.Data[options.parentIdModal].query = `${window.location.search}`;
321
+
322
+ return { data: documents, status, message };
323
+ },
324
+ },
325
+ });
326
+
327
+ const getPanelData = async () => {
328
+ const result = await DocumentService.get({
329
+ id: `public/?tags=${prefixTags.join(',')}${getQueryParams().cid ? `&cid=${getQueryParams().cid}` : ''}`,
330
+ });
331
+
332
+ NotificationManager.Push({
333
+ html: result.status === 'success' ? Translate.Render('success-get-posts') : result.message,
334
+ status: result.status,
335
+ });
336
+ if (result.status === 'success') {
337
+ PanelForm.Data[idPanel].originData = newInstance(result.data);
338
+ PanelForm.Data[idPanel].filesData = [];
339
+ PanelForm.Data[idPanel].data = [];
340
+ for (const documentObject of result.data) {
341
+ let mdFileId, fileId;
342
+ let mdBlob, fileBlob;
343
+ let mdPlain, filePlain;
344
+
345
+ {
346
+ const {
347
+ data: [file],
348
+ status,
349
+ } = await FileService.get({ id: documentObject.mdFileId });
350
+
351
+ // const ext = file.name.split('.')[file.name.split('.').length - 1];
352
+ mdBlob = file;
353
+ mdPlain = await getRawContentFile(getBlobFromUint8ArrayFile(file.data.data, file.mimetype));
354
+ mdFileId = newInstance(mdPlain);
355
+ }
356
+ if (documentObject.fileId) {
357
+ const {
358
+ data: [file],
359
+ status,
360
+ } = await FileService.get({ id: documentObject.fileId._id });
361
+
362
+ // const ext = file.name.split('.')[file.name.split('.').length - 1];
363
+ fileBlob = file;
364
+ filePlain = undefined;
365
+ fileId = getSrcFromFileData(file);
366
+ }
367
+
368
+ PanelForm.Data[idPanel].filesData.push({
369
+ id: documentObject._id,
370
+ _id: documentObject._id,
371
+ mdFileId: { mdBlob, mdPlain },
372
+ fileId: { fileBlob, filePlain },
373
+ });
374
+
375
+ PanelForm.Data[idPanel].data.push({
376
+ id: documentObject._id,
377
+ title: documentObject.title,
378
+ createdAt: dateFormat(documentObject.createdAt),
379
+ tags: documentObject.tags.filter((t) => !prefixTags.includes(t)),
380
+ mdFileId: marked.parse(mdFileId),
381
+ userId: documentObject.userId._id,
382
+ fileId,
383
+ tools: Elements.Data.user.main.model.user._id === documentObject.userId._id,
384
+ _id: documentObject._id,
385
+ });
386
+ }
387
+ }
388
+ };
389
+ const renderSrrPanelData = async () =>
390
+ await panelRender({
391
+ data: range(0, 5).map((i) => ({
392
+ id: i,
393
+ title: html`<div class="fl">
394
+ <div
395
+ class="in fll ssr-shimmer-search-box"
396
+ style="${renderCssAttr({
397
+ style: {
398
+ width: '80%',
399
+ height: '30px',
400
+ top: '-13px',
401
+ left: '10px',
402
+ },
403
+ })}"
404
+ ></div>
405
+ </div>`,
406
+ createdAt: html`<div class="fl">
407
+ <div
408
+ class="in fll ssr-shimmer-search-box"
409
+ style="${renderCssAttr({
410
+ style: {
411
+ width: '50%',
412
+ height: '30px',
413
+ left: '-5px',
414
+ },
415
+ })}"
416
+ ></div>
417
+ </div>`,
418
+ mdFileId: html`<div class="fl section-mp">
419
+ <div
420
+ class="in fll ssr-shimmer-search-box"
421
+ style="${renderCssAttr({
422
+ style: {
423
+ width: '80%',
424
+ height: '30px',
425
+ },
426
+ })}"
427
+ ></div>
428
+ </div>`.repeat(random(2, 4)),
429
+ ssr: true,
430
+ })),
431
+ });
432
+
433
+ let lastCid;
434
+ let lasUserId;
435
+ this.Data[idPanel].updatePanel = async () => {
436
+ const cid = getQueryParams().cid ? getQueryParams().cid : '';
437
+ if (lastCid === cid && lasUserId === Elements.Data.user.main.model.user._id) return;
438
+ if (options.route === 'home') Modal.homeCid = newInstance(cid);
439
+ lastCid = cid;
440
+ lasUserId = newInstance(Elements.Data.user.main.model.user._id);
441
+ htmls(`.${options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body'}`, await renderSrrPanelData());
442
+ await getPanelData();
443
+ htmls(
444
+ `.${options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body'}`,
445
+ await panelRender({ data: this.Data[idPanel].data }),
446
+ );
447
+ };
448
+ if (options.route)
449
+ listenQueryPathInstance({
450
+ id: options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body',
451
+ routeId: options.route,
452
+ event: async (path) => {
453
+ await this.Data[idPanel].updatePanel();
454
+ },
455
+ });
456
+
457
+ // if (options.route === 'home') setTimeout(this.Data[idPanel].updatePanel);
458
+ if (!Auth.getToken()) setTimeout(this.Data[idPanel].updatePanel);
459
+
460
+ if (options.parentIdModal) {
461
+ htmls(`.html-${options.parentIdModal}`, await renderSrrPanelData());
462
+ return '';
463
+ }
464
+
465
+ return await renderSrrPanelData();
466
+ },
467
+ };
468
+
469
+ export { PanelForm };
@@ -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 };