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,290 @@
1
+ import { UserService } from '../../services/user/user.service.js';
2
+ import { BtnIcon } from './BtnIcon.js';
3
+ import { newInstance, s4 } from './CommonJs.js';
4
+ import { renderStatus, renderWave } from './Css.js';
5
+ import { EventsUI } from './EventsUI.js';
6
+ import { fileFormDataFactory, Input } from './Input.js';
7
+ import { LogIn } from './LogIn.js';
8
+ import { LogOut } from './LogOut.js';
9
+ import { Modal } from './Modal.js';
10
+ import { NotificationManager } from './NotificationManager.js';
11
+ import { Translate } from './Translate.js';
12
+ import { Validator } from './Validator.js';
13
+ import { append, htmls, s } from './VanillaJs.js';
14
+
15
+ const Account = {
16
+ UpdateEvent: {},
17
+ Render: async function (options = { user: {}, bottomRender: async () => '', idModal: '' }) {
18
+ // app profile page design example
19
+ // CSS animated backgrounds
20
+ let { user, idModal } = options;
21
+ const waveAnimationId = 'account-wave';
22
+ const profileFileAccept = ['image/png', 'image/jpeg'];
23
+ setTimeout(async () => {
24
+ if (LogIn.Scope.user.main.model.user.profileImage) {
25
+ append(
26
+ `.wave-animation-container-${waveAnimationId}`,
27
+ html` <div class="abs center account-profile-image-container">
28
+ <img
29
+ class="abs center account-profile-image"
30
+ style="opacity: 1"
31
+ src="${LogIn.Scope.user.main.model.user.profileImage.imageSrc}"
32
+ />
33
+ </div>
34
+ <div class="abs center account-profile-image-loading" style="color: white"></div>`,
35
+ );
36
+ }
37
+
38
+ const formData = [
39
+ {
40
+ model: 'username',
41
+ id: `account-username`,
42
+ rules: [{ type: 'isEmpty' }, { type: 'isLength', options: { min: 2, max: 20 } }],
43
+ },
44
+ { model: 'email', id: `account-email`, rules: [{ type: 'isEmpty' }, { type: 'isEmail' }] },
45
+ {
46
+ model: 'password',
47
+ defaultValue: '*******',
48
+ id: `account-password`,
49
+ rules: [{ type: 'isStrongPassword' }],
50
+ },
51
+ ];
52
+ const validators = await Validator.instance(formData);
53
+
54
+ for (const inputData of formData) {
55
+ s(`.${inputData.id}`).value =
56
+ !user[inputData.model] && inputData.defaultValue ? inputData.defaultValue : user[inputData.model];
57
+ }
58
+ let lastUser;
59
+ const submit = async () => {
60
+ lastUser = newInstance(user);
61
+ const { errorMessage } = await validators();
62
+ if (errorMessage) return;
63
+ const body = {};
64
+ for (const inputData of formData) {
65
+ if (!s(`.${inputData.id}`).value || s(`.${inputData.id}`).value === 'undefined') continue;
66
+ if ('model' in inputData) {
67
+ body[inputData.model] = s(`.${inputData.id}`).value;
68
+ user[inputData.model] = s(`.${inputData.id}`).value;
69
+ }
70
+ }
71
+ const result = await UserService.put({ id: user._id, body });
72
+ NotificationManager.Push({
73
+ html:
74
+ result.status === 'error' && result.message
75
+ ? result.message
76
+ : Translate.Render(`${result.status}-update-user`),
77
+ status: result.status,
78
+ });
79
+ if (result.status === 'success') {
80
+ user = result.data;
81
+ this.triggerUpdateEvent({ user });
82
+ if (lastUser.emailConfirmed !== user.emailConfirmed) {
83
+ this.renderVerifyEmailStatus(user);
84
+ }
85
+ lastUser = newInstance(user);
86
+ }
87
+ };
88
+ EventsUI.onClick(`.btn-account`, async (e) => {
89
+ e.preventDefault();
90
+ await submit();
91
+ });
92
+ EventsUI.onClick(`.btn-account-update-username`, async (e) => {
93
+ e.preventDefault();
94
+ await submit();
95
+ });
96
+
97
+ if (s(`.btn-confirm-email`))
98
+ EventsUI.onClick(`.btn-confirm-email`, async (e) => {
99
+ e.preventDefault();
100
+ const result = await UserService.post({
101
+ id: 'mailer/verify-email',
102
+ body: { email: s(`.account-email`).value },
103
+ });
104
+ NotificationManager.Push({
105
+ html: result.status === 'error' ? result.message : Translate.Render(`email send`),
106
+ status: result.status,
107
+ });
108
+ });
109
+ this.renderVerifyEmailStatus(user);
110
+
111
+ s(`.${waveAnimationId}`).style.cursor = 'pointer';
112
+ s(`.${waveAnimationId}`).onclick = async (e) => {
113
+ e.preventDefault();
114
+ s(`.account-profile-image-input`).click();
115
+ };
116
+ EventsUI.onChange(
117
+ `.account-profile-image-input`,
118
+ async (e) => {
119
+ e.preventDefault();
120
+ s(`.account-profile-image`).style.opacity = 0;
121
+ const formFile = fileFormDataFactory(e, profileFileAccept);
122
+
123
+ const { status, data } = await UserService.put({
124
+ id: `profile-image/${user._id}`,
125
+ body: formFile,
126
+ headerId: 'file',
127
+ });
128
+
129
+ if (status === 'success') {
130
+ user.profileImageId = data.profileImageId;
131
+ delete LogIn.Scope.user.main.model.user.profileImage;
132
+ await LogIn.Trigger({ user });
133
+ s(`.account-profile-image`).src = LogIn.Scope.user.main.model.user.profileImage.imageSrc;
134
+ } else {
135
+ NotificationManager.Push({
136
+ html: Translate.Render('file-upload-failed'),
137
+ status: 'error',
138
+ });
139
+ }
140
+
141
+ s(`.account-profile-image`).style.opacity = 1;
142
+ },
143
+ { loadingContainer: `.account-profile-image-loading` },
144
+ );
145
+ s(`.btn-account-change-password`).onclick = (e) => {
146
+ e.preventDefault();
147
+ // s(`.btn-close-modal-account`).click();
148
+ s(`.main-btn-recover`).click();
149
+ };
150
+ s(`.btn-account-delete-confirm`).onclick = async (e) => {
151
+ e.preventDefault();
152
+ const confirmResult = await Modal.RenderConfirm({
153
+ html: async () => {
154
+ return html`
155
+ <div class="in section-mp" style="text-align: center">${Translate.Render('confirm-delete-account')}</div>
156
+ `;
157
+ },
158
+ id: 'delete-account-modal',
159
+ });
160
+ if (confirmResult.status === 'cancelled') return;
161
+ s(`.btn-account-delete-confirm`).classList.add('hide');
162
+ s(`.btn-account-delete`).classList.remove('hide');
163
+ s(`.btn-account-delete`).click();
164
+ };
165
+ EventsUI.onClick(`.btn-account-delete`, async (e) => {
166
+ e.preventDefault();
167
+ const result = await UserService.delete({ id: user._id });
168
+ NotificationManager.Push({
169
+ html: result.status === 'error' ? result.message : Translate.Render(`success-delete-account`),
170
+ status: result.status,
171
+ });
172
+ s(`.btn-account-delete-confirm`).classList.remove('hide');
173
+ s(`.btn-account-delete`).classList.add('hide');
174
+ if (result.status === 'success') {
175
+ LogOut.Trigger();
176
+ s(`.main-btn-home`).click();
177
+ }
178
+ });
179
+ });
180
+ return html`
181
+ <input type="file" accept="${profileFileAccept.join(', ')}" class="account-profile-image-input hide" />
182
+ ${renderWave({ id: waveAnimationId })}
183
+
184
+ <form class="in">
185
+ <div class="in">
186
+ ${await Input.Render({
187
+ id: `account-username`,
188
+ type: 'text',
189
+ label: html`<i class="fa-solid fa-pen-to-square"></i> ${Translate.Render('username')}`,
190
+ containerClass: 'inl section-mp width-mini-box input-container',
191
+ placeholder: true,
192
+ disabled: false,
193
+ extension: async () =>
194
+ html`${await BtnIcon.Render({
195
+ class: `wfa btn-input-extension btn-account-update-username`,
196
+ type: 'button',
197
+ style: 'text-align: left',
198
+ label: html`${Translate.Render(`update`)}`,
199
+ })}`,
200
+ })}
201
+ </div>
202
+ <div class="in">
203
+ ${await Input.Render({
204
+ id: `account-email`,
205
+ type: 'email',
206
+ label: html`<i class="fa-solid fa-envelope"></i> ${Translate.Render('email')}`,
207
+ containerClass: 'inl section-mp width-mini-box input-container',
208
+ placeholder: true,
209
+ autocomplete: 'email',
210
+ disabled: user.emailConfirmed,
211
+ extension: !(options && options.disabled && options.disabled.includes('emailConfirm'))
212
+ ? async () => html`<div class="in verify-email-status"></div>
213
+ ${await BtnIcon.Render({
214
+ class: `wfa btn-input-extension btn-confirm-email`,
215
+ type: 'button',
216
+ style: 'text-align: left',
217
+ label: html`<div class="in">
218
+ <i class="fa-solid fa-paper-plane"></i> ${Translate.Render('send')}
219
+ ${Translate.Render('verify-email')}
220
+ </div> `,
221
+ })}`
222
+ : undefined,
223
+ })}
224
+ </div>
225
+ <div class="in">
226
+ ${await Input.Render({
227
+ id: `account-password`,
228
+ type: 'password',
229
+ autocomplete: 'new-password',
230
+ label: html`<i class="fa-solid fa-lock"></i> ${Translate.Render('password')}`,
231
+ containerClass: 'inl section-mp width-mini-box input-container',
232
+ placeholder: true,
233
+ disabled: true,
234
+ disabledEye: true,
235
+ extension: async () =>
236
+ html`${await BtnIcon.Render({
237
+ class: `wfa btn-input-extension btn-account-change-password`,
238
+ type: 'button',
239
+ style: 'text-align: left',
240
+ label: html`${Translate.Render(`change-password`)}`,
241
+ })}`,
242
+ })}
243
+ </div>
244
+ ${options?.bottomRender ? await options.bottomRender() : ``}
245
+ <div class="in hide">
246
+ ${await BtnIcon.Render({
247
+ class: 'section-mp form-button btn-account',
248
+ label: Translate.Render('update'),
249
+ type: 'submit',
250
+ })}
251
+ </div>
252
+ </form>
253
+ <div class="in">
254
+ ${await BtnIcon.Render({
255
+ class: 'section-mp form-button btn-account-delete hide',
256
+ label: html` ${Translate.Render(`delete-account`)}`,
257
+ type: 'button',
258
+ style: 'color: #5f5f5f',
259
+ })}
260
+ ${await BtnIcon.Render({
261
+ class: 'section-mp form-button btn-account-delete-confirm',
262
+ label: html` ${Translate.Render(`delete-account`)}`,
263
+ type: 'button',
264
+ style: 'color: #5f5f5f',
265
+ })}
266
+ </div>
267
+ `;
268
+ },
269
+ triggerUpdateEvent: async function (options = { user: {} }) {
270
+ for (const updateEvent of Object.keys(this.UpdateEvent)) {
271
+ await this.UpdateEvent[updateEvent](options);
272
+ }
273
+ },
274
+ renderVerifyEmailStatus: function (user) {
275
+ if (s('.verify-email-status')) {
276
+ if (s(`.btn-confirm-email`)) {
277
+ if (user.emailConfirmed) s(`.btn-confirm-email`).classList.add('hide');
278
+ else s(`.btn-confirm-email`).classList.remove('hide');
279
+ }
280
+ htmls(
281
+ '.verify-email-status',
282
+ html`${renderStatus(user.emailConfirmed ? 'success' : 'error', { class: 'inl' })} ${Translate.Render('email')}
283
+ ${Translate.Render(user.emailConfirmed ? 'confirmed' : 'unconfirmed')}`,
284
+ );
285
+ if (user.emailConfirmed === true) s(`.account-email`).setAttribute('disabled', '');
286
+ }
287
+ },
288
+ };
289
+
290
+ export { Account };
@@ -0,0 +1,160 @@
1
+ // https://www.ag-grid.com/javascript-data-grid/getting-started/
2
+ // https://www.ag-grid.com/javascript-data-grid/themes/
3
+
4
+ import { ThemeEvents, darkTheme } from './Css.js';
5
+ import { append, getProxyPath, htmls, s } from './VanillaJs.js';
6
+ import * as agGrid from 'ag-grid-community';
7
+
8
+ const AgGrid = {
9
+ grids: {},
10
+ theme: `ag-theme-alpine`, // quartz
11
+ Render: async function (options) {
12
+ let { id } = options;
13
+ setTimeout(() => {
14
+ // Grid Options: Contains all of the grid configurations
15
+ const gridOptions = {
16
+ // Row Data: The data to be displayed.
17
+ // rowHeight: 60,
18
+ enableCellChangeFlash: true,
19
+ defaultColDef: {
20
+ editable: false,
21
+ flex: 1,
22
+ minWidth: 50,
23
+ filter: true,
24
+ autoHeight: true,
25
+ },
26
+ // domLayout: 'autoHeight', || 'normal'
27
+ // Column Definitions: Defines & controls grid columns.
28
+ columnDefs: options?.gridOptions?.rowData?.[0]
29
+ ? Object.keys(options.gridOptions.rowData[0]).map((field) => {
30
+ return { field };
31
+ })
32
+ : [],
33
+ ...options.gridOptions,
34
+ };
35
+
36
+ // Your Javascript code to create the grid
37
+ const myGridElement = s(`.${id}`);
38
+ if (this.grids[id]) this.grids[id].destroy();
39
+ this.grids[id] = agGrid.createGrid(myGridElement, gridOptions);
40
+ // myGridElement.style.setProperty('width', '100%');
41
+ ThemeEvents[id] = () => {
42
+ if (s(`.${id}`)) {
43
+ s(`.${id}`).classList.remove(darkTheme ? this.theme : this.theme + '-dark');
44
+ s(`.${id}`).classList.add(!darkTheme ? this.theme : this.theme + '-dark');
45
+ } else {
46
+ // console.warn('change theme: grid not found');
47
+ delete ThemeEvents[id];
48
+ }
49
+ };
50
+ });
51
+ return html`
52
+ <div
53
+ class="${id} ${this.theme}${options?.darkTheme ? `-dark` : ''}"
54
+ style="${options?.style
55
+ ? Object.keys(options.style).map((styleKey) => `${styleKey}: ${options.style[styleKey]}; `)
56
+ : 'height: 500px'}"
57
+ ></div>
58
+ `;
59
+ },
60
+ RenderStyle: async function (
61
+ options = {
62
+ eventThemeId: 'AgGrid',
63
+ style: {
64
+ 'font-family': '',
65
+ 'font-size': '',
66
+ 'no-cell-focus-style': false,
67
+ 'row-cursor': '',
68
+ },
69
+ },
70
+ ) {
71
+ /*
72
+ --ag-foreground-color: rgb(126, 46, 132);
73
+ --ag-background-color: rgb(249, 245, 227);
74
+ --ag-header-foreground-color: rgb(204, 245, 172);
75
+ --ag-header-background-color: rgb(209, 64, 129);
76
+ --ag-odd-row-background-color: rgb(0, 0, 0, 0.03);
77
+ --ag-header-column-resize-handle-color: rgb(126, 46, 132);
78
+
79
+ --ag-font-size: 17px;
80
+ */
81
+ if (!s(`.ag-grid-base-style`))
82
+ append(
83
+ 'head',
84
+ html`<link
85
+ class="ag-grid-base-style"
86
+ rel="stylesheet"
87
+ type="text/css"
88
+ href="${getProxyPath()}styles/ag-grid-community/ag-grid.min.css"
89
+ /><link
90
+ rel="stylesheet"
91
+ type="text/css"
92
+ href="${getProxyPath()}styles/ag-grid-community/${this.theme}.min.css"
93
+ />`,
94
+ );
95
+ ThemeEvents[options.eventThemeId] = () => {
96
+ htmls(
97
+ `.ag-grid-style`,
98
+ html` ${options.style['font-family']
99
+ ? html`<style>
100
+ .ag-theme-alpine,
101
+ .ag-theme-alpine-dark {
102
+ --ag-font-family: '{{ag-font-family}}';
103
+ }
104
+ </style>`.replaceAll('{{ag-font-family}}', options.style['font-family'])
105
+ : ''}
106
+ ${options.style['font-size']
107
+ ? html`<style>
108
+ .ag-theme-alpine,
109
+ .ag-theme-alpine-dark {
110
+ --ag-font-size: '{{ag-font-size}}';
111
+ }
112
+ </style>`.replaceAll('{{ag-font-size}}', options.style['font-size'])
113
+ : ''}
114
+ ${options.style['no-cell-focus-style']
115
+ ? html`<style>
116
+ .ag-has-focus .ag-cell-focus {
117
+ border: none !important;
118
+ }
119
+ </style>`
120
+ : ''}
121
+ ${options.style['row-cursor']
122
+ ? html`<style>
123
+ .ag-row {
124
+ cursor: '{{ag-row-cursor}}';
125
+ }
126
+ </style>`.replaceAll(`'{{ag-row-cursor}}'`, options.style['row-cursor'])
127
+ : ''}
128
+
129
+ <style>
130
+ .ag-btn-renderer {
131
+ font-size: 16px;
132
+ min-width: 90px;
133
+ min-height: 90px;
134
+ }
135
+ </style>
136
+ ${darkTheme
137
+ ? html`
138
+ <style>
139
+ .ag-cell-data-changed,
140
+ .ag-cell-data-changed-animation {
141
+ background-color: #6d68ff !important;
142
+ background: #6d68ff !important;
143
+ color: #e4e4e4 !important;
144
+ }
145
+ </style>
146
+ `
147
+ : html`<style>
148
+ .ag-cell-data-changed,
149
+ .ag-cell-data-changed-animation {
150
+ background-color: #d1d1d1 !important;
151
+ background: #d1d1d1 !important;
152
+ color: #2e2e2e !important;
153
+ }
154
+ </style>`}`,
155
+ );
156
+ };
157
+ },
158
+ };
159
+
160
+ export { AgGrid };
@@ -0,0 +1,19 @@
1
+ const token = Symbol('token');
2
+
3
+ const Auth = {
4
+ [token]: '',
5
+ setToken: function (value = '') {
6
+ return (this[token] = value);
7
+ },
8
+ deleteToken: function () {
9
+ return (this[token] = '');
10
+ },
11
+ getToken: function () {
12
+ return this[token];
13
+ },
14
+ getJWT: function () {
15
+ return `Bearer ${this.getToken()}`;
16
+ },
17
+ };
18
+
19
+ export { Auth };
@@ -0,0 +1,32 @@
1
+ import { getId, getIsoDate } from './CommonJs.js';
2
+ import { Css, renderCssAttr, Themes } from './Css.js';
3
+ import { Modal } from './Modal.js';
4
+ import { append, prepend, s } from './VanillaJs.js';
5
+
6
+ const Badge = {
7
+ Tokens: {},
8
+ Render: async function (options = { id: '', type: 'circle-red', classList: '', text: '' }) {
9
+ if (!options.id) options.id = getId(this.Tokens, 'badge-');
10
+ else options.id = 'badge-' + options.id;
11
+ if (options && options.style && !options.style.color) options.style.color = 'white';
12
+ if (!options.classList) options.classList = '';
13
+
14
+ const { id, type } = options;
15
+ this.Tokens[id] = { ...options };
16
+
17
+ switch (type) {
18
+ case 'circle-red':
19
+ options.classList += ' badge-notification-circle-red ';
20
+ break;
21
+
22
+ default:
23
+ break;
24
+ }
25
+
26
+ return html`<div class="badge wfm ${options.classList} ${id}" style="${renderCssAttr(options)}">
27
+ <div class="badge-text">${options?.text ? options.text : 'B'}</div>
28
+ </div>`;
29
+ },
30
+ };
31
+
32
+ export { Badge };
@@ -0,0 +1,41 @@
1
+ import { BlockChainService } from '../../services/blockchain/blockchain.service.js';
2
+ import { BtnIcon } from './BtnIcon.js';
3
+ import { dynamicCol } from './Css.js';
4
+ import { EventsUI } from './EventsUI.js';
5
+ import { Input } from './Input.js';
6
+ import { Translate } from './Translate.js';
7
+
8
+ const BlockChainManagement = {
9
+ Render: async function (options) {
10
+ setTimeout(() => {
11
+ EventsUI.onClick(`.btn-upload-blockchain`, async () => {
12
+ // const { result, status } = new BlockChainService.post();
13
+ });
14
+ });
15
+ return html` ${dynamicCol({ containerSelector: options.idModal, id: 'blockchain' })}
16
+ <div class="fl">
17
+ <div class="in fll blockchain-col-a">
18
+ <div class="in section-mp">
19
+ <div class="in sub-title-modal"><i class="fa-solid fa-sliders"></i> ${Translate.Render('config')}</div>
20
+ <div class="in">
21
+ ${await Input.Render({
22
+ id: `blockchain-seed`,
23
+ label: html`<i class="fa-solid fa-pen-to-square"></i> ${Translate.Render('blockchain-seed')}`,
24
+ containerClass: 'section-mp width-mini-box input-container',
25
+ placeholder: true,
26
+ })}
27
+ ${await BtnIcon.Render({
28
+ class: `section-mp btn-custom btn-upload-blockchain`,
29
+ label: html`<i class="fas fa-plus"></i> ${Translate.Render(`create`)}`,
30
+ })}
31
+ </div>
32
+ </div>
33
+ </div>
34
+ <div class="in fll blockchain-col-b">
35
+ <div class="in section-mp"></div>
36
+ </div>
37
+ </div>`;
38
+ },
39
+ };
40
+
41
+ export { BlockChainManagement };
@@ -0,0 +1,9 @@
1
+ import { RichText } from './RichText.js';
2
+
3
+ const Blog = {
4
+ Render: async function () {
5
+ return html`${await RichText.Render()}`;
6
+ },
7
+ };
8
+
9
+ export { Blog };
@@ -0,0 +1,91 @@
1
+ import { getId, s4 } from './CommonJs.js';
2
+ import { renderCssAttr } from './Css.js';
3
+ import { ToolTip } from './ToolTip.js';
4
+ import { s } from './VanillaJs.js';
5
+
6
+ const BtnIcon = {
7
+ Tokens: {},
8
+ Render: async function (
9
+ options = {
10
+ class: '',
11
+ type: '',
12
+ style: '',
13
+ attrs: '',
14
+ label: '',
15
+ tabHref: '',
16
+ tooltipHtml: '',
17
+ },
18
+ ) {
19
+ const tokenId = getId(this.Tokens, 'btn-token-');
20
+ this.Tokens[tokenId] = { ...options };
21
+ setTimeout(() => {
22
+ if (s(`.a-${tokenId}`)) s(`.a-${tokenId}`).onclick = (e) => e.preventDefault();
23
+ });
24
+ let label = html` ${options.label}
25
+ ${options.handleContainerClass
26
+ ? html` <div class="abs ${options.handleContainerClass}">
27
+ <div class="abs center">
28
+ <i class="fas fa-grip-vertical"></i>
29
+ </div>
30
+ </div>`
31
+ : ''}`;
32
+ let render = html`<button
33
+ ${options?.class ? `class="${options.class} ${tokenId}"` : ''}
34
+ ${options?.type ? `type="${options.type}"` : ''}
35
+ ${options?.style ? `style="${options.style}"` : ''}
36
+ ${options?.attrs ? `${options.attrs}` : ''}
37
+ >
38
+ ${options.tabHref
39
+ ? html`<a
40
+ class="abs a-btn a-${tokenId}"
41
+ href="${options.tabHref}"
42
+ style="${renderCssAttr({ style: { width: '100%', height: '100%', top: '0%', left: '0%' } })}"
43
+ >
44
+ <span class="in btn-label-content"> ${label}</span></a
45
+ >`
46
+ : label}
47
+ </button>`;
48
+ if (options.tooltipHtml)
49
+ setTimeout(() => {
50
+ ToolTip.Render({ container: `.${tokenId}`, id: tokenId, htmlRender: options.tooltipHtml });
51
+ });
52
+ return render;
53
+ },
54
+ // https://developer.mozilla.org/en-US/docs/Games/Techniques/Control_mechanisms/Mobile_touch
55
+ TouchTokens: {},
56
+ RenderTouch: async function (options = { id: '', Events: {} }) {
57
+ const { id } = options;
58
+ this.TouchTokens[id] = { Events: {}, ...options };
59
+ setTimeout(() => {
60
+ const triggerTouchEvents = () => {
61
+ for (const event of Object.keys(this.TouchTokens[id].Events)) this.TouchTokens[id].Events[event]();
62
+ };
63
+ if (s(`.${id}`)) {
64
+ s(`.${id}`).addEventListener('touchstart', () => {
65
+ // handleStart
66
+ triggerTouchEvents();
67
+ });
68
+ s(`.${id}`).addEventListener('touchmove', () => {
69
+ // handleMove
70
+ triggerTouchEvents();
71
+ });
72
+ s(`.${id}`).addEventListener('touchend', () => {
73
+ // handleEnd
74
+ triggerTouchEvents();
75
+ });
76
+ s(`.${id}`).addEventListener('touchcancel', () => {
77
+ // handleCancel
78
+ triggerTouchEvents();
79
+ });
80
+ s(`.${id}`).onclick = triggerTouchEvents;
81
+ }
82
+ });
83
+ return html` <canvas
84
+ class="abs ${id}"
85
+ style="${renderCssAttr({ style: { width: '100%', height: '100%', top: '0px', left: '0px', border: 'none' } })}"
86
+ >
87
+ </canvas>`;
88
+ },
89
+ };
90
+
91
+ export { BtnIcon };