underpost 2.6.3 → 2.7.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.
- package/.dockerignore +13 -13
- package/.env.development +7 -7
- package/.env.production +7 -7
- package/.env.test +7 -7
- package/.github/workflows/publish.yml +26 -0
- package/.nycrc +9 -9
- package/.prettierignore +12 -12
- package/.prettierrc +9 -9
- package/.vscode/extensions.json +72 -72
- package/.vscode/settings.json +100 -99
- package/AUTHORS.md +10 -0
- package/CHANGELOG.md +91 -0
- package/Dockerfile +89 -89
- package/LICENSE +21 -21
- package/README.md +96 -96
- package/bin/db.js +172 -119
- package/bin/deploy.js +582 -626
- package/bin/dns.js +1 -1
- package/bin/file.js +92 -92
- package/bin/index.js +53 -34
- package/bin/install.js +398 -357
- package/bin/shortcut.js +44 -44
- package/bin/ssl.js +65 -61
- package/bin/util.js +182 -182
- package/bin/vs.js +35 -35
- package/conf.js +251 -249
- package/docker-compose.yml +67 -67
- package/jsconfig.json +7 -7
- package/jsdoc.json +32 -32
- package/nodemon.json +6 -6
- package/package.json +137 -128
- package/prometheus.yml +36 -36
- package/setup.sh +24 -24
- package/src/api/core/core.controller.js +69 -69
- package/src/api/core/core.model.js +11 -11
- package/src/api/core/core.router.js +23 -23
- package/src/api/core/core.service.js +29 -29
- package/src/api/crypto/crypto.controller.js +51 -51
- package/src/api/crypto/crypto.model.js +23 -23
- package/src/api/crypto/crypto.router.js +20 -20
- package/src/api/crypto/crypto.service.js +64 -64
- package/src/api/default/default.controller.js +69 -69
- package/src/api/default/default.model.js +20 -20
- package/src/api/default/default.router.js +23 -23
- package/src/api/default/default.service.js +31 -31
- package/src/api/file/file.controller.js +53 -51
- package/src/api/file/file.model.js +19 -19
- package/src/api/file/file.router.js +21 -20
- package/src/api/file/file.service.js +76 -70
- package/src/api/instance/instance.controller.js +69 -69
- package/src/api/instance/instance.model.js +36 -36
- package/src/api/instance/instance.router.js +33 -33
- package/src/api/instance/instance.service.js +48 -48
- package/src/api/test/test.controller.js +59 -59
- package/src/api/test/test.model.js +14 -14
- package/src/api/test/test.router.js +21 -21
- package/src/api/test/test.service.js +35 -35
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -70
- package/src/api/user/user.model.js +65 -65
- package/src/api/user/user.router.js +345 -345
- package/src/api/user/user.service.js +479 -479
- package/src/api.js +23 -23
- package/src/client/Default.index.js +40 -40
- package/src/client/components/core/Account.js +290 -290
- package/src/client/components/core/AgGrid.js +160 -160
- package/src/client/components/core/Auth.js +19 -19
- package/src/client/components/core/Badge.js +32 -32
- package/src/client/components/core/BlockChain.js +41 -41
- package/src/client/components/core/Blog.js +9 -9
- package/src/client/components/core/BtnIcon.js +101 -94
- package/src/client/components/core/CalendarCore.js +458 -319
- package/src/client/components/core/Chat.js +64 -64
- package/src/client/components/core/ColorPalette.js +5267 -5267
- package/src/client/components/core/CommonJs.js +735 -732
- package/src/client/components/core/Content.js +193 -49
- package/src/client/components/core/Css.js +1064 -1027
- package/src/client/components/core/CssCore.js +817 -796
- package/src/client/components/core/D3Chart.js +44 -44
- package/src/client/components/core/Docs.js +229 -229
- package/src/client/components/core/DropDown.js +164 -164
- package/src/client/components/core/EventsUI.js +46 -54
- package/src/client/components/core/FileExplorer.js +699 -624
- package/src/client/components/core/FullScreen.js +45 -45
- package/src/client/components/core/Input.js +346 -259
- package/src/client/components/core/JoyStick.js +77 -77
- package/src/client/components/core/Keyboard.js +73 -73
- package/src/client/components/core/LoadingAnimation.js +179 -157
- package/src/client/components/core/LogIn.js +187 -181
- package/src/client/components/core/LogOut.js +58 -52
- package/src/client/components/core/Logger.js +26 -26
- package/src/client/components/core/Modal.js +1612 -1596
- package/src/client/components/core/NotificationManager.js +84 -84
- package/src/client/components/core/Panel.js +613 -413
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -162
- package/src/client/components/core/Recover.js +204 -204
- package/src/client/components/core/Responsive.js +53 -53
- package/src/client/components/core/RichText.js +51 -27
- package/src/client/components/core/Router.js +76 -77
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -125
- package/src/client/components/core/SocketIo.js +72 -72
- package/src/client/components/core/Stream.js +113 -113
- package/src/client/components/core/ToggleSwitch.js +87 -87
- package/src/client/components/core/ToolTip.js +26 -26
- package/src/client/components/core/Translate.js +437 -408
- package/src/client/components/core/Validator.js +100 -100
- package/src/client/components/core/VanillaJs.js +460 -457
- package/src/client/components/core/Wallet.js +106 -106
- package/src/client/components/core/Webhook.js +25 -25
- package/src/client/components/core/Worker.js +272 -272
- package/src/client/components/default/CommonDefault.js +29 -29
- package/src/client/components/default/CssDefault.js +13 -13
- package/src/client/components/default/ElementsDefault.js +38 -38
- package/src/client/components/default/LogInDefault.js +41 -41
- package/src/client/components/default/LogOutDefault.js +28 -28
- package/src/client/components/default/MenuDefault.js +389 -389
- package/src/client/components/default/RoutesDefault.js +48 -48
- package/src/client/components/default/SettingsDefault.js +16 -16
- package/src/client/components/default/SignUpDefault.js +9 -9
- package/src/client/components/default/SocketIoDefault.js +54 -54
- package/src/client/components/default/TranslateDefault.js +7 -7
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/browserconfig.xml +11 -11
- package/src/client/public/default/manifest.webmanifest +68 -68
- package/src/client/public/default/plantuml/client-conf.svg +1 -0
- package/src/client/public/default/plantuml/client-schema.svg +1 -0
- package/src/client/public/default/plantuml/cron-conf.svg +1 -0
- package/src/client/public/default/plantuml/cron-schema.svg +1 -0
- package/src/client/public/default/plantuml/server-conf.svg +1 -0
- package/src/client/public/default/plantuml/server-schema.svg +1 -0
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
- package/src/client/public/default/sitemap +147 -147
- package/src/client/public/default/yandex-browser-manifest.json +8 -8
- package/src/client/public/doc/sitemap +147 -147
- package/src/client/public/test/sitemap +147 -147
- package/src/client/services/core/core.service.js +170 -152
- package/src/client/services/crypto/crypto.service.js +70 -70
- package/src/client/services/default/default.management.js +345 -345
- package/src/client/services/default/default.service.js +89 -89
- package/src/client/services/file/file.service.js +70 -70
- package/src/client/services/instance/instance.management.js +74 -74
- package/src/client/services/instance/instance.service.js +89 -89
- package/src/client/services/test/test.service.js +70 -70
- package/src/client/services/user/user.management.js +50 -50
- package/src/client/services/user/user.service.js +89 -89
- package/src/client/ssr/Render.js +16 -16
- package/src/client/ssr/body-components/CacheControl.js +114 -113
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
- package/src/client/ssr/head-components/Css.js +241 -241
- package/src/client/ssr/head-components/DefaultScripts.js +3 -3
- package/src/client/ssr/head-components/Microdata.js +11 -11
- package/src/client/ssr/head-components/Production.js +1 -1
- package/src/client/ssr/head-components/PwaDefault.js +59 -59
- package/src/client/ssr/head-components/Seo.js +14 -14
- package/src/client/sw/default.sw.js +201 -201
- package/src/client/sw/template.sw.js +84 -84
- package/src/client.build.js +22 -22
- package/src/client.dev.js +21 -21
- package/src/cron.js +25 -25
- package/src/db/DataBaseProvider.js +34 -34
- package/src/db/mariadb/MariaDB.js +33 -33
- package/src/db/mongo/MongooseDB.js +46 -46
- package/src/dns.js +22 -22
- package/src/index.js +42 -0
- package/src/mailer/EmailRender.js +69 -69
- package/src/mailer/MailerProvider.js +96 -96
- package/src/proxy.js +22 -22
- package/src/runtime/lampp/Lampp.js +69 -44
- package/src/runtime/nginx/Nginx.js +3 -3
- package/src/runtime/xampp/Xampp.js +49 -49
- package/src/server/auth.js +235 -204
- package/src/server/backup.js +101 -84
- package/src/server/client-build-live.js +72 -72
- package/src/server/client-build.js +705 -699
- package/src/server/client-dev-server.js +60 -58
- package/src/server/client-formatted.js +48 -48
- package/src/server/client-icons.js +149 -150
- package/src/server/conf.js +860 -611
- package/src/server/dns.js +98 -87
- package/src/server/downloader.js +42 -42
- package/src/server/logger.js +180 -135
- package/src/server/network.js +122 -122
- package/src/server/peer.js +33 -33
- package/src/server/process.js +66 -66
- package/src/server/prompt-optimizer.js +28 -0
- package/src/server/proxy.js +118 -118
- package/src/server/runtime.js +444 -393
- package/src/server/ssl.js +109 -107
- package/src/server.js +25 -25
- package/src/ws/IoInterface.js +45 -45
- package/src/ws/IoServer.js +39 -39
- package/src/ws/core/channels/core.ws.chat.js +23 -23
- package/src/ws/core/channels/core.ws.mailer.js +35 -35
- package/src/ws/core/channels/core.ws.stream.js +31 -31
- package/src/ws/core/core.ws.connection.js +28 -28
- package/src/ws/core/core.ws.emit.js +14 -14
- package/src/ws/core/core.ws.server.js +24 -24
- package/src/ws/core/management/core.ws.chat.js +8 -8
- package/src/ws/core/management/core.ws.mailer.js +16 -16
- package/src/ws/core/management/core.ws.stream.js +8 -8
- package/src/ws/default/channels/default.ws.main.js +16 -16
- package/src/ws/default/default.ws.connection.js +22 -22
- package/src/ws/default/default.ws.emit.js +14 -14
- package/src/ws/default/default.ws.server.js +20 -20
- package/src/ws/default/management/default.ws.main.js +8 -8
- package/startup.js +11 -11
- package/supervisord-openssh-server.conf +4 -4
- package/test/api.test.js +60 -60
- package/bin/help.js +0 -110
|
@@ -1,624 +1,699 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
EventsUI.onClick(`.btn-input-
|
|
216
|
-
e.preventDefault();
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
await
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
},
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
{
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
1
|
+
import { getApiBaseUrl } from '../../services/core/core.service.js';
|
|
2
|
+
import { DocumentService } from '../../services/document/document.service.js';
|
|
3
|
+
import { FileService } from '../../services/file/file.service.js';
|
|
4
|
+
import { AgGrid } from './AgGrid.js';
|
|
5
|
+
import { Auth } from './Auth.js';
|
|
6
|
+
import { BtnIcon } from './BtnIcon.js';
|
|
7
|
+
import { getSubpaths, timer, uniqueArray } from './CommonJs.js';
|
|
8
|
+
import { Content } from './Content.js';
|
|
9
|
+
import { darkTheme, renderCssAttr } from './Css.js';
|
|
10
|
+
import { EventsUI } from './EventsUI.js';
|
|
11
|
+
import { fileFormDataFactory, Input, InputFile } from './Input.js';
|
|
12
|
+
import { loggerFactory } from './Logger.js';
|
|
13
|
+
import { Modal } from './Modal.js';
|
|
14
|
+
import { NotificationManager } from './NotificationManager.js';
|
|
15
|
+
import { RouterEvents } from './Router.js';
|
|
16
|
+
import { Translate } from './Translate.js';
|
|
17
|
+
import { Validator } from './Validator.js';
|
|
18
|
+
import { copyData, downloadFile, getProxyPath, getQueryParams, s, setPath } from './VanillaJs.js';
|
|
19
|
+
|
|
20
|
+
const logger = loggerFactory(import.meta);
|
|
21
|
+
|
|
22
|
+
class LoadFolderRenderer {
|
|
23
|
+
eGui;
|
|
24
|
+
|
|
25
|
+
async init(params) {
|
|
26
|
+
console.log('LoadFolderRenderer created', params);
|
|
27
|
+
// params.data._id
|
|
28
|
+
|
|
29
|
+
this.eGui = document.createElement('div');
|
|
30
|
+
this.eGui.innerHTML = html`<i class="fas fa-folder"></i> ${params.data.location}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getGui() {
|
|
34
|
+
return this.eGui;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
refresh(params) {
|
|
38
|
+
console.log('LoadFolderRenderer refreshed', params);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class LoadFileNameRenderer {
|
|
44
|
+
eGui;
|
|
45
|
+
|
|
46
|
+
async init(params) {
|
|
47
|
+
console.log('LoadFileNameRenderer created', params);
|
|
48
|
+
// params.data._id
|
|
49
|
+
|
|
50
|
+
this.eGui = document.createElement('div');
|
|
51
|
+
this.eGui.innerHTML = html`<i class="fas fa-file"></i> ${params.data.name}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getGui() {
|
|
55
|
+
return this.eGui;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
refresh(params) {
|
|
59
|
+
console.log('LoadFileNameRenderer refreshed', params);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class FolderHeaderComp {
|
|
65
|
+
eGui;
|
|
66
|
+
|
|
67
|
+
async init(params) {
|
|
68
|
+
console.log('FolderHeaderComp created', params);
|
|
69
|
+
// params.data._id
|
|
70
|
+
|
|
71
|
+
this.eGui = document.createElement('div');
|
|
72
|
+
this.eGui.innerHTML = html`<i class="fas fa-file"></i>`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getGui() {
|
|
76
|
+
return this.eGui;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
refresh(params) {
|
|
80
|
+
console.log('FolderHeaderComp refreshed', params);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const FileExplorer = {
|
|
86
|
+
Api: {},
|
|
87
|
+
Render: async function (options = { idModal: '' }) {
|
|
88
|
+
const { idModal } = options;
|
|
89
|
+
FileExplorer.Api[idModal] = options;
|
|
90
|
+
const gridFolderId = 'folder-explorer-grid';
|
|
91
|
+
const gridFileId = 'file-explorer-grid';
|
|
92
|
+
const idDropFileInput = 'file-explorer';
|
|
93
|
+
let formBodyFiles;
|
|
94
|
+
const query = getQueryParams();
|
|
95
|
+
let location = query?.location ? this.locationFormat({ f: query }) : '/';
|
|
96
|
+
let files, folders, documentId, documentInstance;
|
|
97
|
+
const cleanData = () => {
|
|
98
|
+
files = [];
|
|
99
|
+
folders = [];
|
|
100
|
+
documentId = '';
|
|
101
|
+
documentInstance = [];
|
|
102
|
+
};
|
|
103
|
+
cleanData();
|
|
104
|
+
FileExplorer.Api[idModal].displayList = async () => {
|
|
105
|
+
if (!s(`.${idModal}`)) return;
|
|
106
|
+
const query = getQueryParams();
|
|
107
|
+
location = query?.location ? this.locationFormat({ f: query }) : '/';
|
|
108
|
+
s(`.file-explorer-query-nav`).value = location;
|
|
109
|
+
const format = this.documentDataFormat({ document: documentInstance, location });
|
|
110
|
+
files = format.files;
|
|
111
|
+
folders = format.folders;
|
|
112
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
113
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
114
|
+
};
|
|
115
|
+
FileExplorer.Api[idModal].updateData = async (optionsUpdate = { display: false }) => {
|
|
116
|
+
if (!s(`.${idModal}`)) return;
|
|
117
|
+
if (Auth.getToken()) {
|
|
118
|
+
try {
|
|
119
|
+
const { status, data: document } = await DocumentService.get();
|
|
120
|
+
const format = this.documentDataFormat({ document, location });
|
|
121
|
+
files = format.files;
|
|
122
|
+
documentId = format.documentId;
|
|
123
|
+
folders = format.folders;
|
|
124
|
+
documentInstance = document;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
logger.error(error);
|
|
127
|
+
NotificationManager.Push({
|
|
128
|
+
html: error.message,
|
|
129
|
+
status: 'error',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
} else cleanData();
|
|
133
|
+
setTimeout(async () => {
|
|
134
|
+
if (s(`.${idModal}`) && optionsUpdate && optionsUpdate.display) await FileExplorer.Api[idModal].displayList();
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
RouterEvents['file-explorer'] = ({ path, pushPath, route }) => {
|
|
139
|
+
if (route === 'cloud')
|
|
140
|
+
setTimeout(async () => {
|
|
141
|
+
// await this.Api[idModal].updateData();
|
|
142
|
+
await FileExplorer.Api[idModal].displayList();
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
setTimeout(async () => {
|
|
147
|
+
FileExplorer.Api[idModal].updateData({ display: true });
|
|
148
|
+
const formData = [
|
|
149
|
+
{
|
|
150
|
+
model: 'location',
|
|
151
|
+
id: `file-explorer-query-nav`,
|
|
152
|
+
rules: [], // { type: 'isEmpty' }
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
const validators = await Validator.instance(formData);
|
|
156
|
+
|
|
157
|
+
EventsUI.onClick(`.btn-input-file-explorer`, async (e) => {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
const { errorMessage } = await validators();
|
|
160
|
+
if (!formBodyFiles)
|
|
161
|
+
return NotificationManager.Push({
|
|
162
|
+
html: Translate.Render(`warning-upload-no-selects-file`),
|
|
163
|
+
status: 'warning',
|
|
164
|
+
});
|
|
165
|
+
if (errorMessage) return;
|
|
166
|
+
let fileData;
|
|
167
|
+
{
|
|
168
|
+
const { status, data } = await FileService.post({ body: formBodyFiles });
|
|
169
|
+
fileData = data;
|
|
170
|
+
}
|
|
171
|
+
{
|
|
172
|
+
// const body = {};
|
|
173
|
+
// for (const inputData of formData) {
|
|
174
|
+
// if ('model' in inputData) body[inputData.model] = s(`.${inputData.id}`).value;
|
|
175
|
+
// }
|
|
176
|
+
location = this.locationFormat({ f: { location: s(`.file-explorer-query-nav`).value } });
|
|
177
|
+
let status = 'success';
|
|
178
|
+
for (const file of fileData) {
|
|
179
|
+
const result = await DocumentService.post({
|
|
180
|
+
body: {
|
|
181
|
+
fileId: file._id,
|
|
182
|
+
location,
|
|
183
|
+
title: file.name,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
if (result.status === 'success') documentInstance.push({ ...result.data, fileId: file });
|
|
187
|
+
else if (status !== 'error') status = 'error';
|
|
188
|
+
}
|
|
189
|
+
const format = this.documentDataFormat({ document: documentInstance, location });
|
|
190
|
+
files = format.files;
|
|
191
|
+
folders = format.folders;
|
|
192
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
193
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
194
|
+
NotificationManager.Push({
|
|
195
|
+
html: Translate.Render(`${status}-upload-file`),
|
|
196
|
+
status,
|
|
197
|
+
});
|
|
198
|
+
if (status === 'success') {
|
|
199
|
+
s(`.btn-input-home-directory`).click();
|
|
200
|
+
s(`.btn-clear-input-file-${idDropFileInput}`).click();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
EventsUI.onClick(`.btn-input-go-explorer`, async (e) => {
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
const newLocation = this.locationFormat({ f: { location: s(`.file-explorer-query-nav`).value } });
|
|
208
|
+
if (newLocation === location) return;
|
|
209
|
+
location = newLocation;
|
|
210
|
+
setPath(`${window.location.pathname}?location=${location}`);
|
|
211
|
+
s(`.file-explorer-query-nav`).value = location;
|
|
212
|
+
// const format = this.documentDataFormat({ document: documentInstance, location });
|
|
213
|
+
await FileExplorer.Api[idModal].updateData({ display: true });
|
|
214
|
+
});
|
|
215
|
+
EventsUI.onClick(`.btn-input-home-directory`, async (e) => {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
let newLocation = '/';
|
|
218
|
+
if (s(`.file-explorer-uploader`).style.display !== 'none') {
|
|
219
|
+
s(`.file-explorer-uploader`).style.display = 'none';
|
|
220
|
+
s(`.file-explorer-nav`).style.display = 'block';
|
|
221
|
+
} else if (newLocation === location) return;
|
|
222
|
+
else location = newLocation;
|
|
223
|
+
setPath(`${window.location.pathname}?location=${location}`);
|
|
224
|
+
s(`.file-explorer-query-nav`).value = location;
|
|
225
|
+
const format = this.documentDataFormat({ document: documentInstance, location });
|
|
226
|
+
files = format.files;
|
|
227
|
+
folders = format.folders;
|
|
228
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
229
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
230
|
+
});
|
|
231
|
+
EventsUI.onClick(`.btn-input-copy-directory`, async (e) => {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
await copyData(window.location.href);
|
|
234
|
+
NotificationManager.Push({
|
|
235
|
+
html: Translate.Render('success-copy-data'),
|
|
236
|
+
status: 'success',
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
EventsUI.onClick(`.btn-input-back-explorer`, async (e) => {
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
window.history.back();
|
|
242
|
+
});
|
|
243
|
+
EventsUI.onClick(`.btn-input-forward-explorer`, async (e) => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
window.history.forward();
|
|
246
|
+
});
|
|
247
|
+
EventsUI.onClick(`.btn-input-upload-file`, async (e) => {
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
s(`.file-explorer-nav`).style.display = 'none';
|
|
250
|
+
s(`.file-explorer-uploader`).style.display = 'block';
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
class LoadFileActionsRenderer {
|
|
255
|
+
eGui;
|
|
256
|
+
|
|
257
|
+
async init(params) {
|
|
258
|
+
console.log('LoadFileActionsRenderer created', params);
|
|
259
|
+
// params.data._id
|
|
260
|
+
|
|
261
|
+
this.eGui = document.createElement('div');
|
|
262
|
+
this.eGui.innerHTML = html`
|
|
263
|
+
<div class="fl">
|
|
264
|
+
${await BtnIcon.Render({
|
|
265
|
+
class: `in fll management-table-btn-mini btn-file-download-${params.data._id}`,
|
|
266
|
+
label: html` <i class="fas fa-download"></i>`,
|
|
267
|
+
type: 'button',
|
|
268
|
+
})}
|
|
269
|
+
${await BtnIcon.Render({
|
|
270
|
+
class: `in fll management-table-btn-mini btn-file-delete-${params.data._id}`,
|
|
271
|
+
label: html` <i class="fa-solid fa-circle-xmark"></i>`,
|
|
272
|
+
type: 'button',
|
|
273
|
+
})}
|
|
274
|
+
${await BtnIcon.Render({
|
|
275
|
+
class: `in fll management-table-btn-mini btn-file-view-${params.data._id}`,
|
|
276
|
+
label: html` <i class="fas fa-eye"></i>`,
|
|
277
|
+
type: 'button',
|
|
278
|
+
})}
|
|
279
|
+
${await BtnIcon.Render({
|
|
280
|
+
class: `in fll management-table-btn-mini btn-file-copy-content-link-${params.data._id}`,
|
|
281
|
+
label: html`<i class="fas fa-copy"></i>`,
|
|
282
|
+
type: 'button',
|
|
283
|
+
})}
|
|
284
|
+
</div>
|
|
285
|
+
`;
|
|
286
|
+
|
|
287
|
+
setTimeout(() => {
|
|
288
|
+
const uri = `${getProxyPath()}content/?cid=${params.data._id}`;
|
|
289
|
+
const url = `${window.location.origin}${uri}`;
|
|
290
|
+
|
|
291
|
+
const originObj = documentInstance.find((d) => d._id === params.data._id);
|
|
292
|
+
const blobUri = originObj ? getApiBaseUrl({ id: originObj.fileId._id, endpoint: 'file/blob' }) : undefined;
|
|
293
|
+
|
|
294
|
+
if (!originObj) {
|
|
295
|
+
s(`.btn-file-view-${params.data._id}`).classList.add('hide');
|
|
296
|
+
s(`.btn-file-copy-content-link-${params.data._id}`).classList.add('hide');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
EventsUI.onClick(`.btn-file-view-${params.data._id}`, async (e) => {
|
|
300
|
+
e.preventDefault();
|
|
301
|
+
if (location.href !== url) {
|
|
302
|
+
setPath(uri);
|
|
303
|
+
s(`.main-btn-content`).click();
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
EventsUI.onClick(`.btn-file-copy-content-link-${params.data._id}`, async (e) => {
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
await copyData(blobUri);
|
|
310
|
+
NotificationManager.Push({
|
|
311
|
+
html: Translate.Render('success-copy-data'),
|
|
312
|
+
status: 'success',
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
EventsUI.onClick(`.btn-file-download-${params.data._id}`, async (e) => {
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
console.log(params);
|
|
319
|
+
const {
|
|
320
|
+
data: [file],
|
|
321
|
+
status,
|
|
322
|
+
} = await FileService.get({ id: params.data.fileId });
|
|
323
|
+
|
|
324
|
+
downloadFile(new Blob([new Uint8Array(file.data.data)], { type: params.data.mimetype }), params.data.name);
|
|
325
|
+
});
|
|
326
|
+
EventsUI.onClick(`.btn-file-delete-${params.data._id}`, async (e) => {
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
{
|
|
329
|
+
const confirmResult = await Modal.RenderConfirm({
|
|
330
|
+
html: async () => {
|
|
331
|
+
return html`
|
|
332
|
+
<div class="in section-mp" style="text-align: center">
|
|
333
|
+
${Translate.Render('confirm-delete-item')}
|
|
334
|
+
<br />
|
|
335
|
+
"${params.data.title}"
|
|
336
|
+
</div>
|
|
337
|
+
`;
|
|
338
|
+
},
|
|
339
|
+
id: `delete-${params.data._id}`,
|
|
340
|
+
});
|
|
341
|
+
if (confirmResult.status !== 'confirm') return;
|
|
342
|
+
|
|
343
|
+
const { data, status, message } = await FileService.delete({
|
|
344
|
+
id: params.data.fileId,
|
|
345
|
+
});
|
|
346
|
+
NotificationManager.Push({
|
|
347
|
+
html: status,
|
|
348
|
+
status,
|
|
349
|
+
});
|
|
350
|
+
if (status === 'error') return;
|
|
351
|
+
}
|
|
352
|
+
const { data, status, message } = await DocumentService.delete({
|
|
353
|
+
id: params.data._id,
|
|
354
|
+
});
|
|
355
|
+
NotificationManager.Push({
|
|
356
|
+
html: status,
|
|
357
|
+
status,
|
|
358
|
+
});
|
|
359
|
+
if (status === 'error') return;
|
|
360
|
+
|
|
361
|
+
documentInstance = documentInstance.filter((f) => f._id !== params.data._id);
|
|
362
|
+
const format = FileExplorer.documentDataFormat({ document: documentInstance, location });
|
|
363
|
+
files = format.files;
|
|
364
|
+
folders = format.folders;
|
|
365
|
+
// AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
366
|
+
// const selectedData = gridApi.getSelectedRows();
|
|
367
|
+
AgGrid.grids[gridFileId].applyTransaction({ remove: [params.data] });
|
|
368
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
getGui() {
|
|
374
|
+
return this.eGui;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
refresh(params) {
|
|
378
|
+
console.log('LoadFileActionsRenderer refreshed', params);
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
class LoadFolderActionsRenderer {
|
|
384
|
+
eGui;
|
|
385
|
+
|
|
386
|
+
async init(params) {
|
|
387
|
+
console.log('LoadFolderActionsRenderer created', params);
|
|
388
|
+
// params.data._id
|
|
389
|
+
const id = params.data.locationId;
|
|
390
|
+
|
|
391
|
+
this.eGui = document.createElement('div');
|
|
392
|
+
this.eGui.innerHTML = html`
|
|
393
|
+
<div class="fl">
|
|
394
|
+
${await BtnIcon.Render({
|
|
395
|
+
class: `in fll management-table-btn-mini btn-folder-delete-${id}`,
|
|
396
|
+
label: html` <i class="fa-solid fa-circle-xmark"></i>`,
|
|
397
|
+
type: 'button',
|
|
398
|
+
})}
|
|
399
|
+
</div>
|
|
400
|
+
`;
|
|
401
|
+
|
|
402
|
+
setTimeout(() => {
|
|
403
|
+
EventsUI.onClick(`.btn-folder-delete-${id}`, async (e) => {
|
|
404
|
+
const confirmResult = await Modal.RenderConfirm({
|
|
405
|
+
html: async () => {
|
|
406
|
+
return html`
|
|
407
|
+
<div class="in section-mp" style="text-align: center">
|
|
408
|
+
${Translate.Render('confirm-delete-item')}
|
|
409
|
+
<br />
|
|
410
|
+
"${params.data.location}"
|
|
411
|
+
</div>
|
|
412
|
+
`;
|
|
413
|
+
},
|
|
414
|
+
id: `delete-${id}`,
|
|
415
|
+
});
|
|
416
|
+
if (confirmResult.status !== 'confirm') return;
|
|
417
|
+
|
|
418
|
+
e.preventDefault();
|
|
419
|
+
const idFilesDelete = [];
|
|
420
|
+
for (const file of documentInstance.filter(
|
|
421
|
+
(f) => FileExplorer.locationFormat({ f }) === params.data.location, // .startsWith(params.data.location),
|
|
422
|
+
)) {
|
|
423
|
+
{
|
|
424
|
+
const { data, status, message } = await FileService.delete({
|
|
425
|
+
id: file.fileId._id,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
{
|
|
429
|
+
idFilesDelete.push(file._id);
|
|
430
|
+
const { data, status, message } = await DocumentService.delete({
|
|
431
|
+
id: file._id,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
NotificationManager.Push({
|
|
436
|
+
html: Translate.Render('success-delete'),
|
|
437
|
+
status: 'success',
|
|
438
|
+
});
|
|
439
|
+
documentInstance = documentInstance.filter((f) => !idFilesDelete.includes(f._id));
|
|
440
|
+
const format = FileExplorer.documentDataFormat({ document: documentInstance, location });
|
|
441
|
+
files = format.files;
|
|
442
|
+
folders = format.folders;
|
|
443
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
444
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
getGui() {
|
|
450
|
+
return this.eGui;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
refresh(params) {
|
|
454
|
+
console.log('LoadFolderActionsRenderer refreshed', params);
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return html`
|
|
460
|
+
<form>
|
|
461
|
+
<div class="fl">
|
|
462
|
+
${await BtnIcon.Render({
|
|
463
|
+
class: 'in fll management-table-btn-mini btn-input-home-directory',
|
|
464
|
+
label: html`<i class="fas fa-home"></i>
|
|
465
|
+
<!-- ${Translate.Render('home-directory')} -->`,
|
|
466
|
+
type: 'button',
|
|
467
|
+
})}
|
|
468
|
+
${await BtnIcon.Render({
|
|
469
|
+
class: 'in fll management-table-btn-mini btn-input-back-explorer',
|
|
470
|
+
label: html` <i class="fa-solid fa-circle-left"></i>
|
|
471
|
+
<!-- ${Translate.Render('go')} -->`,
|
|
472
|
+
type: 'button',
|
|
473
|
+
})}
|
|
474
|
+
${await BtnIcon.Render({
|
|
475
|
+
class: 'in fll management-table-btn-mini btn-input-forward-explorer',
|
|
476
|
+
label: html` <i class="fa-solid fa-circle-right"></i>
|
|
477
|
+
<!-- ${Translate.Render('go')} -->`,
|
|
478
|
+
type: 'button',
|
|
479
|
+
})}
|
|
480
|
+
${await BtnIcon.Render({
|
|
481
|
+
class: 'in fll management-table-btn-mini btn-input-go-explorer',
|
|
482
|
+
label: html`<i class="fas fa-sync-alt"></i>
|
|
483
|
+
<!-- ${Translate.Render('go')} -->`,
|
|
484
|
+
type: 'submit',
|
|
485
|
+
})}
|
|
486
|
+
${await BtnIcon.Render({
|
|
487
|
+
class: 'in fll management-table-btn-mini btn-input-copy-directory',
|
|
488
|
+
label: html`<i class="fas fa-copy"></i>
|
|
489
|
+
<!-- ${Translate.Render('home-directory')} -->`,
|
|
490
|
+
type: 'button',
|
|
491
|
+
})}
|
|
492
|
+
${await BtnIcon.Render({
|
|
493
|
+
class: 'in fll management-table-btn-mini btn-input-upload-file',
|
|
494
|
+
label: html`<i class="fa-solid fa-cloud-arrow-up"></i>
|
|
495
|
+
<!-- ${Translate.Render('home-directory')} -->`,
|
|
496
|
+
type: 'button',
|
|
497
|
+
})}
|
|
498
|
+
</div>
|
|
499
|
+
<div class="in">
|
|
500
|
+
${await Input.Render({
|
|
501
|
+
id: `file-explorer-query-nav`,
|
|
502
|
+
type: 'text',
|
|
503
|
+
label: html`<i class="fab fa-wpexplorer"></i> ${Translate.Render('current-path')}`,
|
|
504
|
+
containerClass: 'in section-mp input-container-width',
|
|
505
|
+
placeholder: true,
|
|
506
|
+
value: location,
|
|
507
|
+
})}
|
|
508
|
+
</div>
|
|
509
|
+
</form>
|
|
510
|
+
<div class="fl file-explorer-nav">
|
|
511
|
+
<div class="in fll explorer-file-col">
|
|
512
|
+
<div class="in explorer-file-sub-col section-mp">
|
|
513
|
+
<div class="in">
|
|
514
|
+
${await AgGrid.Render({
|
|
515
|
+
id: gridFolderId,
|
|
516
|
+
darkTheme,
|
|
517
|
+
// style: {
|
|
518
|
+
// height: '200px',
|
|
519
|
+
// },
|
|
520
|
+
gridOptions: {
|
|
521
|
+
defaultColDef: {
|
|
522
|
+
editable: false,
|
|
523
|
+
minWidth: 100,
|
|
524
|
+
filter: true,
|
|
525
|
+
autoHeight: true,
|
|
526
|
+
},
|
|
527
|
+
rowData: folders,
|
|
528
|
+
columnDefs: [
|
|
529
|
+
{
|
|
530
|
+
field: 'location',
|
|
531
|
+
headerName: 'Folder',
|
|
532
|
+
minWidth: 200,
|
|
533
|
+
flex: 1,
|
|
534
|
+
cellStyle: function (params) {
|
|
535
|
+
return { cursor: 'pointer' };
|
|
536
|
+
},
|
|
537
|
+
cellRenderer: LoadFolderRenderer,
|
|
538
|
+
onCellClicked: (event) => {
|
|
539
|
+
// console.warn('onCellClicked', event);
|
|
540
|
+
const newLocation = event.data.location;
|
|
541
|
+
if (newLocation === location) return;
|
|
542
|
+
location = newLocation;
|
|
543
|
+
setPath(`${window.location.pathname}?location=${location}`);
|
|
544
|
+
s(`.file-explorer-query-nav`).value = location;
|
|
545
|
+
const format = this.documentDataFormat({ document: documentInstance, location });
|
|
546
|
+
files = format.files;
|
|
547
|
+
folders = format.folders;
|
|
548
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
549
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
// suppressHeaderMenuButton: true,
|
|
554
|
+
// sortable: false,
|
|
555
|
+
field: 'fileCount',
|
|
556
|
+
headerName: '🗎',
|
|
557
|
+
width: 60,
|
|
558
|
+
cellStyle: function (params) {
|
|
559
|
+
return { cursor: 'pointer' };
|
|
560
|
+
},
|
|
561
|
+
// headerComponent: FolderHeaderComp,
|
|
562
|
+
// headerComponentParams: {
|
|
563
|
+
// menuIcon: 'fa-bars',
|
|
564
|
+
// template: `test`,
|
|
565
|
+
// },
|
|
566
|
+
},
|
|
567
|
+
{ headerName: '', width: 60, cellRenderer: LoadFolderActionsRenderer },
|
|
568
|
+
],
|
|
569
|
+
rowSelection: 'single',
|
|
570
|
+
onSelectionChanged: (event) => {
|
|
571
|
+
return;
|
|
572
|
+
const selectedRows = AgGrid.grids[gridFolderId].getSelectedRows();
|
|
573
|
+
console.log('selectedRows', { event, selectedRows });
|
|
574
|
+
if (selectedRows[0]) {
|
|
575
|
+
const newLocation = selectedRows[0].location;
|
|
576
|
+
if (newLocation === location) return;
|
|
577
|
+
location = newLocation;
|
|
578
|
+
setPath(`${window.location.pathname}?location=${location}`);
|
|
579
|
+
s(`.file-explorer-query-nav`).value = location;
|
|
580
|
+
const format = this.documentDataFormat({ document: documentInstance, location });
|
|
581
|
+
files = format.files;
|
|
582
|
+
folders = format.folders;
|
|
583
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
584
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
})}
|
|
589
|
+
</div>
|
|
590
|
+
</div>
|
|
591
|
+
</div>
|
|
592
|
+
<div class="in fll explorer-file-col">
|
|
593
|
+
<div class="in explorer-file-sub-col section-mp">
|
|
594
|
+
<div class="in">
|
|
595
|
+
${await AgGrid.Render({
|
|
596
|
+
id: gridFileId,
|
|
597
|
+
darkTheme,
|
|
598
|
+
// style: {
|
|
599
|
+
// height: '200px',
|
|
600
|
+
// },
|
|
601
|
+
gridOptions: {
|
|
602
|
+
defaultColDef: {
|
|
603
|
+
editable: false,
|
|
604
|
+
minWidth: 100,
|
|
605
|
+
filter: true,
|
|
606
|
+
autoHeight: true,
|
|
607
|
+
},
|
|
608
|
+
// rowData: files,
|
|
609
|
+
rowData: undefined,
|
|
610
|
+
columnDefs: [
|
|
611
|
+
{ field: 'name', flex: 2, headerName: 'Name', cellRenderer: LoadFileNameRenderer },
|
|
612
|
+
{ field: 'mimetype', flex: 1, headerName: 'Type' },
|
|
613
|
+
{ headerName: '', width: 80, cellRenderer: LoadFileActionsRenderer },
|
|
614
|
+
],
|
|
615
|
+
},
|
|
616
|
+
})}
|
|
617
|
+
</div>
|
|
618
|
+
</div>
|
|
619
|
+
</div>
|
|
620
|
+
</div>
|
|
621
|
+
<form class="file-explorer-uploader" style="display: none">
|
|
622
|
+
${await InputFile.Render(
|
|
623
|
+
{
|
|
624
|
+
id: idDropFileInput,
|
|
625
|
+
multiple: true,
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
clear: () => {
|
|
629
|
+
console.log('file explorer clear file');
|
|
630
|
+
formBodyFiles = undefined;
|
|
631
|
+
},
|
|
632
|
+
change: (e) => {
|
|
633
|
+
console.log('file explorer change file', e);
|
|
634
|
+
formBodyFiles = fileFormDataFactory(e);
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
)}
|
|
638
|
+
<div class="in">
|
|
639
|
+
${await BtnIcon.Render({
|
|
640
|
+
class: 'wfa section-mp btn-input-file-explorer',
|
|
641
|
+
style: renderCssAttr({
|
|
642
|
+
style: {
|
|
643
|
+
'font-size': '25px',
|
|
644
|
+
'text-align': 'center',
|
|
645
|
+
padding: '20px',
|
|
646
|
+
},
|
|
647
|
+
}),
|
|
648
|
+
label: html`<i class="fa-solid fa-cloud-arrow-up"></i> ${Translate.Render('upload')}`,
|
|
649
|
+
type: 'submit',
|
|
650
|
+
})}
|
|
651
|
+
</div>
|
|
652
|
+
</form>
|
|
653
|
+
`;
|
|
654
|
+
},
|
|
655
|
+
locationFormat: function ({ f }) {
|
|
656
|
+
if (f.location[0] !== '/') f.location = `/${f.location}`;
|
|
657
|
+
if (f.location !== '/' && f.location[f.location.length - 1] === '/') f.location = f.location.slice(0, -1);
|
|
658
|
+
return f.location;
|
|
659
|
+
},
|
|
660
|
+
documentDataFormat: function ({ document, location }) {
|
|
661
|
+
let files = document.map((f) => {
|
|
662
|
+
if (!f.fileId)
|
|
663
|
+
f.fileId = {
|
|
664
|
+
name: f.title + '.md',
|
|
665
|
+
mimetype: 'text/markdown',
|
|
666
|
+
_id: f.mdFileId,
|
|
667
|
+
};
|
|
668
|
+
return {
|
|
669
|
+
location: this.locationFormat({ f }),
|
|
670
|
+
name: f.fileId.name,
|
|
671
|
+
mimetype: f.fileId.mimetype,
|
|
672
|
+
fileId: f.fileId._id,
|
|
673
|
+
_id: f._id,
|
|
674
|
+
title: f.title,
|
|
675
|
+
};
|
|
676
|
+
});
|
|
677
|
+
let documentId = document._id;
|
|
678
|
+
let folders = [];
|
|
679
|
+
for (const folderPath of uniqueArray(files.map((f) => f.location)))
|
|
680
|
+
folders = ['/'].concat(folders.concat(getSubpaths(folderPath)));
|
|
681
|
+
folders = uniqueArray(folders).map((f, i) => {
|
|
682
|
+
return {
|
|
683
|
+
location: f,
|
|
684
|
+
locationId: `loc-${i}`,
|
|
685
|
+
};
|
|
686
|
+
});
|
|
687
|
+
files = files.filter((f) => f.location === location);
|
|
688
|
+
folders = folders
|
|
689
|
+
.filter((f) => f.location.startsWith(location))
|
|
690
|
+
.map((f) => {
|
|
691
|
+
f.fileCount = document.filter((file) => file.location === f.location).length;
|
|
692
|
+
return f;
|
|
693
|
+
})
|
|
694
|
+
.filter((f) => f.fileCount > 0);
|
|
695
|
+
return { files, documentId, folders };
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
export { FileExplorer };
|