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,624 @@
1
+ import { DocumentService } from '../../services/document/document.service.js';
2
+ import { FileService } from '../../services/file/file.service.js';
3
+ import { AgGrid } from './AgGrid.js';
4
+ import { BtnIcon } from './BtnIcon.js';
5
+ import { getSubpaths, uniqueArray } from './CommonJs.js';
6
+ import { darkTheme } from './Css.js';
7
+ import { EventsUI } from './EventsUI.js';
8
+ import { fileFormDataFactory, Input, InputFile } from './Input.js';
9
+ import { Modal } from './Modal.js';
10
+ import { NotificationManager } from './NotificationManager.js';
11
+ import { RouterEvents } from './Router.js';
12
+ import { Translate } from './Translate.js';
13
+ import { Validator } from './Validator.js';
14
+ import { copyData, downloadFile, getProxyPath, getQueryParams, s, setPath } from './VanillaJs.js';
15
+
16
+ class LoadFolderRenderer {
17
+ eGui;
18
+
19
+ async init(params) {
20
+ console.log('LoadFolderRenderer created', params);
21
+ // params.data._id
22
+
23
+ this.eGui = document.createElement('div');
24
+ this.eGui.innerHTML = html`<i class="fas fa-folder"></i> ${params.data.location}`;
25
+ }
26
+
27
+ getGui() {
28
+ return this.eGui;
29
+ }
30
+
31
+ refresh(params) {
32
+ console.log('LoadFolderRenderer refreshed', params);
33
+ return true;
34
+ }
35
+ }
36
+
37
+ class LoadFileNameRenderer {
38
+ eGui;
39
+
40
+ async init(params) {
41
+ console.log('LoadFileNameRenderer created', params);
42
+ // params.data._id
43
+
44
+ this.eGui = document.createElement('div');
45
+ this.eGui.innerHTML = html`<i class="fas fa-file"></i> ${params.data.name}`;
46
+ }
47
+
48
+ getGui() {
49
+ return this.eGui;
50
+ }
51
+
52
+ refresh(params) {
53
+ console.log('LoadFileNameRenderer refreshed', params);
54
+ return true;
55
+ }
56
+ }
57
+
58
+ class FolderHeaderComp {
59
+ eGui;
60
+
61
+ async init(params) {
62
+ console.log('FolderHeaderComp created', params);
63
+ // params.data._id
64
+
65
+ this.eGui = document.createElement('div');
66
+ this.eGui.innerHTML = html`<i class="fas fa-file"></i>`;
67
+ }
68
+
69
+ getGui() {
70
+ return this.eGui;
71
+ }
72
+
73
+ refresh(params) {
74
+ console.log('FolderHeaderComp refreshed', params);
75
+ return true;
76
+ }
77
+ }
78
+
79
+ const FileExplorer = {
80
+ Render: async function () {
81
+ const gridFolderId = 'folder-explorer-grid';
82
+ const gridFileId = 'file-explorer-grid';
83
+ const idDropFileInput = 'file-explorer';
84
+ let formBodyFiles;
85
+ const query = getQueryParams();
86
+ let location = query?.location ? this.locationFormat({ f: query }) : '/';
87
+ let files = [];
88
+ let folders = [];
89
+ let documentId = '';
90
+ let documentInstance = [];
91
+
92
+ RouterEvents['file-explorer'] = ({ path, pushPath, route }) => {
93
+ if (route === 'cloud') {
94
+ setTimeout(() => {
95
+ const query = getQueryParams();
96
+ location = query?.location ? this.locationFormat({ f: query }) : '/';
97
+ if (!s(`.file-explorer-query-nav`)) return;
98
+ s(`.file-explorer-query-nav`).value = location;
99
+ const format = this.documentDataFormat({ document: documentInstance, location });
100
+ files = format.files;
101
+ folders = format.folders;
102
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
103
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
104
+ });
105
+ }
106
+ };
107
+
108
+ try {
109
+ const { status, data: document } = await DocumentService.get();
110
+ const format = this.documentDataFormat({ document, location });
111
+ files = format.files;
112
+ documentId = format.documentId;
113
+ folders = format.folders;
114
+ documentInstance = document;
115
+ } catch (error) {
116
+ console.error(error);
117
+ }
118
+
119
+ console.log({ location, documentId, folders, files });
120
+
121
+ setTimeout(async () => {
122
+ const formData = [
123
+ {
124
+ model: 'location',
125
+ id: `file-explorer-query-nav`,
126
+ rules: [], // { type: 'isEmpty' }
127
+ },
128
+ ];
129
+ const validators = await Validator.instance(formData);
130
+
131
+ EventsUI.onClick(`.btn-input-file-explorer`, async (e) => {
132
+ e.preventDefault();
133
+ const { errorMessage } = await validators();
134
+ if (!formBodyFiles)
135
+ return NotificationManager.Push({
136
+ html: Translate.Render(`warning-upload-no-selects-file`),
137
+ status: 'warning',
138
+ });
139
+ if (errorMessage) return;
140
+ let fileData;
141
+ {
142
+ const { status, data } = await FileService.post({ body: formBodyFiles });
143
+ fileData = data;
144
+ }
145
+ {
146
+ // const body = {};
147
+ // for (const inputData of formData) {
148
+ // if ('model' in inputData) body[inputData.model] = s(`.${inputData.id}`).value;
149
+ // }
150
+ location = this.locationFormat({ f: { location: s(`.file-explorer-query-nav`).value } });
151
+ let status = 'success';
152
+ for (const file of fileData) {
153
+ const result = await DocumentService.post({
154
+ body: {
155
+ fileId: file._id,
156
+ location,
157
+ },
158
+ });
159
+ if (result.status === 'success') documentInstance.push({ ...result.data, fileId: file });
160
+ else if (status !== 'error') status = 'error';
161
+ }
162
+ const format = this.documentDataFormat({ document: documentInstance, location });
163
+ files = format.files;
164
+ folders = format.folders;
165
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
166
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
167
+ NotificationManager.Push({
168
+ html: Translate.Render(`${status}-upload-file`),
169
+ status,
170
+ });
171
+ if (status === 'success') {
172
+ s(`.btn-input-home-directory`).click();
173
+ s(`.btn-clear-input-file-${idDropFileInput}`).click();
174
+ }
175
+ }
176
+ });
177
+
178
+ EventsUI.onClick(`.btn-input-go-explorer`, async (e) => {
179
+ e.preventDefault();
180
+ const newLocation = this.locationFormat({ f: { location: s(`.file-explorer-query-nav`).value } });
181
+ if (newLocation === location) return;
182
+ location = newLocation;
183
+ setPath(`${window.location.pathname}?location=${location}`);
184
+ s(`.file-explorer-query-nav`).value = location;
185
+ const format = this.documentDataFormat({ document: documentInstance, location });
186
+ files = format.files;
187
+ folders = format.folders;
188
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
189
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
190
+ });
191
+ EventsUI.onClick(`.btn-input-home-directory`, async (e) => {
192
+ e.preventDefault();
193
+ let newLocation = '/';
194
+ if (s(`.file-explorer-uploader`).style.display !== 'none') {
195
+ s(`.file-explorer-uploader`).style.display = 'none';
196
+ s(`.file-explorer-nav`).style.display = 'block';
197
+ } else if (newLocation === location) return;
198
+ else location = newLocation;
199
+ setPath(`${window.location.pathname}?location=${location}`);
200
+ s(`.file-explorer-query-nav`).value = location;
201
+ const format = this.documentDataFormat({ document: documentInstance, location });
202
+ files = format.files;
203
+ folders = format.folders;
204
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
205
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
206
+ });
207
+ EventsUI.onClick(`.btn-input-copy-directory`, async (e) => {
208
+ e.preventDefault();
209
+ await copyData(window.location.href);
210
+ NotificationManager.Push({
211
+ html: Translate.Render('success-copy-data'),
212
+ status: 'success',
213
+ });
214
+ });
215
+ EventsUI.onClick(`.btn-input-back-explorer`, async (e) => {
216
+ e.preventDefault();
217
+ window.history.back();
218
+ });
219
+ EventsUI.onClick(`.btn-input-forward-explorer`, async (e) => {
220
+ e.preventDefault();
221
+ window.history.forward();
222
+ });
223
+ EventsUI.onClick(`.btn-input-upload-file`, async (e) => {
224
+ e.preventDefault();
225
+ s(`.file-explorer-nav`).style.display = 'none';
226
+ s(`.file-explorer-uploader`).style.display = 'block';
227
+ });
228
+ });
229
+
230
+ class LoadFileActionsRenderer {
231
+ eGui;
232
+
233
+ async init(params) {
234
+ console.log('LoadFileActionsRenderer created', params);
235
+ // params.data._id
236
+
237
+ this.eGui = document.createElement('div');
238
+ this.eGui.innerHTML = html`
239
+ ${await BtnIcon.Render({
240
+ class: `in btn-file-download-${params.data._id}`,
241
+ label: html` <i class="fas fa-download"></i>`,
242
+ type: 'button',
243
+ })}
244
+ ${await BtnIcon.Render({
245
+ class: `in btn-file-delete-${params.data._id}`,
246
+ label: html` <i class="fa-solid fa-circle-xmark"></i>`,
247
+ type: 'button',
248
+ })}
249
+ ${await BtnIcon.Render({
250
+ class: `in btn-file-view-${params.data._id}`,
251
+ label: html` <i class="fas fa-eye"></i>`,
252
+ type: 'button',
253
+ })}
254
+ ${await BtnIcon.Render({
255
+ class: `in btn-file-copy-content-link-${params.data._id}`,
256
+ label: html`<i class="fas fa-copy"></i>`,
257
+ type: 'button',
258
+ })}
259
+ `;
260
+
261
+ setTimeout(() => {
262
+ const uri = `${getProxyPath()}content/?id=${params.data.fileId}`;
263
+ const url = `${window.location.origin}${uri}`;
264
+
265
+ // ${window.location.origin[window.location.origin.length - 1] === '/' ? '' : '/'}
266
+
267
+ console.log({ url, uri });
268
+
269
+ EventsUI.onClick(`.btn-file-view-${params.data._id}`, async (e) => {
270
+ e.preventDefault();
271
+ if (location.href !== url) {
272
+ setPath(uri);
273
+ s(`.main-btn-content`).click();
274
+ }
275
+ });
276
+
277
+ EventsUI.onClick(`.btn-file-copy-content-link-${params.data._id}`, async (e) => {
278
+ e.preventDefault();
279
+ await copyData(url);
280
+ NotificationManager.Push({
281
+ html: Translate.Render('success-copy-data'),
282
+ status: 'success',
283
+ });
284
+ });
285
+
286
+ EventsUI.onClick(`.btn-file-download-${params.data._id}`, async (e) => {
287
+ e.preventDefault();
288
+ console.log(params);
289
+ const {
290
+ data: [file],
291
+ status,
292
+ } = await FileService.get({ id: params.data.fileId });
293
+
294
+ downloadFile(new Blob([new Uint8Array(file.data.data)], { type: params.data.mimetype }), params.data.name);
295
+ });
296
+ EventsUI.onClick(`.btn-file-delete-${params.data._id}`, async (e) => {
297
+ e.preventDefault();
298
+ {
299
+ const { data, status, message } = await FileService.delete({
300
+ id: params.data.fileId,
301
+ });
302
+ NotificationManager.Push({
303
+ html: status,
304
+ status,
305
+ });
306
+ if (status === 'error') return;
307
+ }
308
+ const { data, status, message } = await DocumentService.delete({
309
+ id: params.data._id,
310
+ });
311
+ NotificationManager.Push({
312
+ html: status,
313
+ status,
314
+ });
315
+ if (status === 'error') return;
316
+
317
+ documentInstance = documentInstance.filter((f) => f._id !== params.data._id);
318
+ const format = FileExplorer.documentDataFormat({ document: documentInstance, location });
319
+ files = format.files;
320
+ folders = format.folders;
321
+ // AgGrid.grids[gridFileId].setGridOption('rowData', files);
322
+ // const selectedData = gridApi.getSelectedRows();
323
+ AgGrid.grids[gridFileId].applyTransaction({ remove: [params.data] });
324
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
325
+ });
326
+ });
327
+ }
328
+
329
+ getGui() {
330
+ return this.eGui;
331
+ }
332
+
333
+ refresh(params) {
334
+ console.log('LoadFileActionsRenderer refreshed', params);
335
+ return true;
336
+ }
337
+ }
338
+
339
+ class LoadFolderActionsRenderer {
340
+ eGui;
341
+
342
+ async init(params) {
343
+ console.log('LoadFolderActionsRenderer created', params);
344
+ // params.data._id
345
+ const id = params.data.locationId;
346
+
347
+ this.eGui = document.createElement('div');
348
+ this.eGui.innerHTML = html`
349
+ ${await BtnIcon.Render({
350
+ class: `in btn-folder-delete-${id}`,
351
+ label: html` <i class="fa-solid fa-circle-xmark"></i>`,
352
+ type: 'button',
353
+ })}
354
+ `;
355
+
356
+ setTimeout(() => {
357
+ EventsUI.onClick(`.btn-folder-delete-${id}`, async (e) => {
358
+ e.preventDefault();
359
+ const idFilesDelete = [];
360
+ for (const file of documentInstance.filter(
361
+ (f) => FileExplorer.locationFormat({ f }) === params.data.location, // .startsWith(params.data.location),
362
+ )) {
363
+ {
364
+ const { data, status, message } = await FileService.delete({
365
+ id: file.fileId._id,
366
+ });
367
+ }
368
+ {
369
+ idFilesDelete.push(file._id);
370
+ const { data, status, message } = await DocumentService.delete({
371
+ id: file._id,
372
+ });
373
+ }
374
+ }
375
+ NotificationManager.Push({
376
+ html: Translate.Render('success-delete'),
377
+ status: 'success',
378
+ });
379
+ documentInstance = documentInstance.filter((f) => !idFilesDelete.includes(f._id));
380
+ const format = FileExplorer.documentDataFormat({ document: documentInstance, location });
381
+ files = format.files;
382
+ folders = format.folders;
383
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
384
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
385
+ });
386
+ });
387
+ }
388
+
389
+ getGui() {
390
+ return this.eGui;
391
+ }
392
+
393
+ refresh(params) {
394
+ console.log('LoadFolderActionsRenderer refreshed', params);
395
+ return true;
396
+ }
397
+ }
398
+
399
+ return html`
400
+ <form>
401
+ <div class="in">
402
+ ${await BtnIcon.Render({
403
+ class: 'inl tool-btn-file-explorer btn-input-home-directory',
404
+ label: html`<i class="fas fa-home"></i>
405
+ <!-- ${Translate.Render('home-directory')} -->`,
406
+ type: 'button',
407
+ })}
408
+ ${await BtnIcon.Render({
409
+ class: 'inl tool-btn-file-explorer btn-input-back-explorer',
410
+ label: html` <i class="fa-solid fa-circle-left"></i>
411
+ <!-- ${Translate.Render('go')} -->`,
412
+ type: 'button',
413
+ })}
414
+ ${await BtnIcon.Render({
415
+ class: 'inl tool-btn-file-explorer btn-input-forward-explorer',
416
+ label: html` <i class="fa-solid fa-circle-right"></i>
417
+ <!-- ${Translate.Render('go')} -->`,
418
+ type: 'button',
419
+ })}
420
+ ${await BtnIcon.Render({
421
+ class: 'inl tool-btn-file-explorer btn-input-go-explorer',
422
+ label: html`<i class="fas fa-sync-alt"></i>
423
+ <!-- ${Translate.Render('go')} -->`,
424
+ type: 'submit',
425
+ })}
426
+ ${await BtnIcon.Render({
427
+ class: 'inl tool-btn-file-explorer btn-input-copy-directory',
428
+ label: html`<i class="fas fa-copy"></i>
429
+ <!-- ${Translate.Render('home-directory')} -->`,
430
+ type: 'button',
431
+ })}
432
+ ${await BtnIcon.Render({
433
+ class: 'inl tool-btn-file-explorer btn-input-upload-file',
434
+ label: html`<i class="fa-solid fa-cloud-arrow-up"></i>
435
+ <!-- ${Translate.Render('home-directory')} -->`,
436
+ type: 'button',
437
+ })}
438
+ </div>
439
+ <div class="in">
440
+ ${await Input.Render({
441
+ id: `file-explorer-query-nav`,
442
+ type: 'text',
443
+ label: html`<i class="fab fa-wpexplorer"></i> ${Translate.Render('current-path')}`,
444
+ containerClass: 'in section-mp input-container-width',
445
+ placeholder: true,
446
+ value: location,
447
+ })}
448
+ </div>
449
+ </form>
450
+ <div class="fl file-explorer-nav">
451
+ <div class="in fll explorer-file-col">
452
+ <div class="in explorer-file-sub-col section-mp">
453
+ <div class="in">
454
+ ${await AgGrid.Render({
455
+ id: gridFolderId,
456
+ darkTheme,
457
+ // style: {
458
+ // height: '200px',
459
+ // },
460
+ gridOptions: {
461
+ defaultColDef: {
462
+ editable: false,
463
+ minWidth: 100,
464
+ filter: true,
465
+ autoHeight: true,
466
+ },
467
+ rowData: folders,
468
+ columnDefs: [
469
+ {
470
+ field: 'location',
471
+ headerName: 'Folder',
472
+ minWidth: 200,
473
+ flex: 1,
474
+ cellStyle: function (params) {
475
+ return { cursor: 'pointer' };
476
+ },
477
+ cellRenderer: LoadFolderRenderer,
478
+ onCellClicked: (event) => {
479
+ // console.warn('onCellClicked', event);
480
+ const newLocation = event.data.location;
481
+ if (newLocation === location) return;
482
+ location = newLocation;
483
+ setPath(`${window.location.pathname}?location=${location}`);
484
+ s(`.file-explorer-query-nav`).value = location;
485
+ const format = this.documentDataFormat({ document: documentInstance, location });
486
+ files = format.files;
487
+ folders = format.folders;
488
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
489
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
490
+ },
491
+ },
492
+ {
493
+ // suppressHeaderMenuButton: true,
494
+ // sortable: false,
495
+ field: 'fileCount',
496
+ headerName: '🗎',
497
+ width: 60,
498
+ cellStyle: function (params) {
499
+ return { cursor: 'pointer' };
500
+ },
501
+ // headerComponent: FolderHeaderComp,
502
+ // headerComponentParams: {
503
+ // menuIcon: 'fa-bars',
504
+ // template: `test`,
505
+ // },
506
+ },
507
+ { headerName: '', width: 60, cellRenderer: LoadFolderActionsRenderer },
508
+ ],
509
+ rowSelection: 'single',
510
+ onSelectionChanged: (event) => {
511
+ return;
512
+ const selectedRows = AgGrid.grids[gridFolderId].getSelectedRows();
513
+ console.log('selectedRows', { event, selectedRows });
514
+ if (selectedRows[0]) {
515
+ const newLocation = selectedRows[0].location;
516
+ if (newLocation === location) return;
517
+ location = newLocation;
518
+ setPath(`${window.location.pathname}?location=${location}`);
519
+ s(`.file-explorer-query-nav`).value = location;
520
+ const format = this.documentDataFormat({ document: documentInstance, location });
521
+ files = format.files;
522
+ folders = format.folders;
523
+ AgGrid.grids[gridFileId].setGridOption('rowData', files);
524
+ AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
525
+ }
526
+ },
527
+ },
528
+ })}
529
+ </div>
530
+ </div>
531
+ </div>
532
+ <div class="in fll explorer-file-col">
533
+ <div class="in explorer-file-sub-col section-mp">
534
+ <div class="in">
535
+ ${await AgGrid.Render({
536
+ id: gridFileId,
537
+ darkTheme,
538
+ // style: {
539
+ // height: '200px',
540
+ // },
541
+ gridOptions: {
542
+ defaultColDef: {
543
+ editable: false,
544
+ minWidth: 100,
545
+ filter: true,
546
+ autoHeight: true,
547
+ },
548
+ rowData: files,
549
+ columnDefs: [
550
+ { field: 'name', flex: 2, headerName: 'Name', cellRenderer: LoadFileNameRenderer },
551
+ { field: 'mimetype', flex: 1, headerName: 'Type' },
552
+ { headerName: '', width: 80, cellRenderer: LoadFileActionsRenderer },
553
+ ],
554
+ },
555
+ })}
556
+ </div>
557
+ </div>
558
+ </div>
559
+ </div>
560
+ <form class="file-explorer-uploader" style="display: none">
561
+ <div class="in">
562
+ ${await BtnIcon.Render({
563
+ class: 'wfa section-mp btn-input-file-explorer',
564
+ label: html`<i class="fas fa-upload"></i> ${Translate.Render('upload')}`,
565
+ type: 'submit',
566
+ })}
567
+ </div>
568
+ ${await InputFile.Render(
569
+ {
570
+ id: idDropFileInput,
571
+ multiple: true,
572
+ },
573
+ {
574
+ clear: () => {
575
+ console.log('file explorer clear file');
576
+ formBodyFiles = undefined;
577
+ },
578
+ change: (e) => {
579
+ console.log('file explorer change file', e);
580
+ formBodyFiles = fileFormDataFactory(e);
581
+ },
582
+ },
583
+ )}
584
+ </form>
585
+ `;
586
+ },
587
+ locationFormat: function ({ f }) {
588
+ if (f.location[0] !== '/') f.location = `/${f.location}`;
589
+ if (f.location !== '/' && f.location[f.location.length - 1] === '/') f.location = f.location.slice(0, -1);
590
+ return f.location;
591
+ },
592
+ documentDataFormat: function ({ document, location }) {
593
+ let files = document.map((f) => {
594
+ return {
595
+ location: this.locationFormat({ f }),
596
+ name: f.fileId.name,
597
+ mimetype: f.fileId.mimetype,
598
+ fileId: f.fileId._id,
599
+ _id: f._id,
600
+ };
601
+ });
602
+ let documentId = document._id;
603
+ let folders = [];
604
+ for (const folderPath of uniqueArray(files.map((f) => f.location)))
605
+ folders = ['/'].concat(folders.concat(getSubpaths(folderPath)));
606
+ folders = uniqueArray(folders).map((f, i) => {
607
+ return {
608
+ location: f,
609
+ locationId: `loc-${i}`,
610
+ };
611
+ });
612
+ files = files.filter((f) => f.location === location);
613
+ folders = folders
614
+ .filter((f) => f.location.startsWith(location))
615
+ .map((f) => {
616
+ f.fileCount = document.filter((file) => file.location === f.location).length;
617
+ return f;
618
+ })
619
+ .filter((f) => f.fileCount > 0);
620
+ return { files, documentId, folders };
621
+ },
622
+ };
623
+
624
+ export { FileExplorer };
@@ -0,0 +1,45 @@
1
+ import { Responsive } from './Responsive.js';
2
+ import { ToggleSwitch } from './ToggleSwitch.js';
3
+ import { Translate } from './Translate.js';
4
+ import { checkFullScreen, fullScreenIn, fullScreenOut, s } from './VanillaJs.js';
5
+
6
+ const FullScreen = {
7
+ RenderSetting: async function () {
8
+ let fullScreenSwitch = checkFullScreen();
9
+ Responsive.Event['full-screen-settings'] = () => {
10
+ let fullScreenMode = checkFullScreen();
11
+ if ((fullScreenSwitch && !fullScreenMode) || (!fullScreenSwitch && fullScreenMode))
12
+ if (s('.fullscreen-toggle')) ToggleSwitch.Tokens[`fullscreen-toggle`].click();
13
+ };
14
+ setTimeout(
15
+ () => (s(`.toggle-form-container-fullscreen`).onclick = () => ToggleSwitch.Tokens[`fullscreen-toggle`].click()),
16
+ );
17
+ return html`<div class="in section-mp toggle-form-container toggle-form-container-fullscreen hover">
18
+ <div class="fl ">
19
+ <div class="in fll" style="width: 70%">
20
+ <div class="in"><i class="fa-solid fa-expand"></i> ${Translate.Render('fullscreen')}</div>
21
+ </div>
22
+ <div class="in fll" style="width: 30%">
23
+ ${await ToggleSwitch.Render({
24
+ id: 'fullscreen-toggle',
25
+ containerClass: 'inl',
26
+ disabledOnClick: true,
27
+ checked: fullScreenSwitch,
28
+ on: {
29
+ unchecked: () => {
30
+ fullScreenSwitch = false;
31
+ if (checkFullScreen()) fullScreenOut();
32
+ },
33
+ checked: () => {
34
+ fullScreenSwitch = true;
35
+ if (!checkFullScreen()) fullScreenIn();
36
+ },
37
+ },
38
+ })}
39
+ </div>
40
+ </div>
41
+ </div>`;
42
+ },
43
+ };
44
+
45
+ export { FullScreen };