underpost 2.8.635 → 2.8.641
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/Dockerfile +9 -10
- package/bin/build.js +2 -2
- package/bin/deploy.js +2 -1
- package/bin/index.js +14 -8
- package/docker-compose.yml +1 -1
- package/package.json +1 -3
- package/src/api/default/default.service.js +1 -1
- package/src/api/user/user.service.js +1 -1
- package/src/cli/cron.js +39 -8
- package/src/cli/deploy.js +63 -10
- package/src/cli/fs.js +7 -6
- package/src/cli/image.js +40 -34
- package/src/cli/monitor.js +62 -38
- package/src/client/components/core/Account.js +25 -21
- package/src/client/components/core/Blockchain.js +1 -1
- package/src/client/components/core/CalendarCore.js +14 -84
- package/src/client/components/core/CommonJs.js +2 -1
- package/src/client/components/core/CssCore.js +8 -2
- package/src/client/components/core/EventsUI.js +2 -2
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/LoadingAnimation.js +1 -17
- package/src/client/components/core/LogIn.js +3 -3
- package/src/client/components/core/LogOut.js +1 -1
- package/src/client/components/core/Modal.js +12 -7
- package/src/client/components/core/Panel.js +19 -61
- package/src/client/components/core/PanelForm.js +13 -22
- package/src/client/components/core/Recover.js +3 -3
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/core/SignUp.js +2 -2
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/default/default.management.js +45 -38
- package/src/client/ssr/Render.js +2 -0
- package/src/index.js +10 -3
- package/src/runtime/lampp/Dockerfile +65 -0
- package/src/server/dns.js +9 -1
- package/src/server/json-schema.js +77 -0
- package/src/server/network.js +7 -122
- package/src/server/runtime.js +1 -3
package/src/cli/monitor.js
CHANGED
|
@@ -4,13 +4,12 @@ import UnderpostDeploy from './deploy.js';
|
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import UnderpostRootEnv from './env.js';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
|
-
import { timer } from '../client/components/core/CommonJs.js';
|
|
8
7
|
|
|
9
8
|
const logger = loggerFactory(import.meta);
|
|
10
9
|
|
|
11
10
|
class UnderpostMonitor {
|
|
12
11
|
static API = {
|
|
13
|
-
async callback(deployId, env = 'development', options = {
|
|
12
|
+
async callback(deployId, env = 'development', options = { now: false, single: false, msInterval: '' }) {
|
|
14
13
|
const router = await UnderpostDeploy.API.routerFactory(deployId, env);
|
|
15
14
|
|
|
16
15
|
const confServer = loadReplicas(
|
|
@@ -22,45 +21,70 @@ class UnderpostMonitor {
|
|
|
22
21
|
|
|
23
22
|
logger.info('', pathPortAssignmentData);
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.reduce((accumulator, value) => accumulator + value, 0);
|
|
24
|
+
const errorPayloads = [];
|
|
25
|
+
const maxAttempts = Object.keys(pathPortAssignmentData)
|
|
26
|
+
.map((host) => pathPortAssignmentData[host].length)
|
|
27
|
+
.reduce((accumulator, value) => accumulator + value, 0);
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
const monitor = async (reject) => {
|
|
30
|
+
logger.info('Check server health');
|
|
31
|
+
for (const host of Object.keys(pathPortAssignmentData)) {
|
|
32
|
+
for (const instance of pathPortAssignmentData[host]) {
|
|
33
|
+
const { port, path } = instance;
|
|
34
|
+
if (path.match('peer') || path.match('socket')) continue;
|
|
35
|
+
const urlTest = `http://localhost:${port}${path}`;
|
|
36
|
+
// logger.info('Test instance', urlTest);
|
|
37
|
+
await axios.get(urlTest, { timeout: 10000 }).catch((error) => {
|
|
38
|
+
// console.log(error);
|
|
39
|
+
const errorPayload = {
|
|
40
|
+
urlTest,
|
|
41
|
+
host,
|
|
42
|
+
port,
|
|
43
|
+
path,
|
|
44
|
+
name: error.name,
|
|
45
|
+
status: error.status,
|
|
46
|
+
code: error.code,
|
|
47
|
+
errors: error.errors,
|
|
48
|
+
};
|
|
49
|
+
if (errorPayload.status !== 404) {
|
|
50
|
+
errorPayloads.push(errorPayload);
|
|
51
|
+
if (errorPayloads.length >= maxAttempts) {
|
|
52
|
+
const message = JSON.stringify(errorPayloads, null, 4);
|
|
53
|
+
if (reject) reject(message);
|
|
54
|
+
else throw new Error(message);
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
logger.error('Error accumulator', errorPayloads.length);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
if (options.now === true) await monitor();
|
|
63
|
+
if (options.single === true) return;
|
|
64
|
+
let optionsMsTimeout = parseInt(options.msInterval);
|
|
65
|
+
if (isNaN(optionsMsTimeout)) optionsMsTimeout = 30000;
|
|
66
|
+
const monitorCallBack = (resolve, reject) => {
|
|
67
|
+
const envMsTimeout = UnderpostRootEnv.API.get('monitor-ms');
|
|
68
|
+
setTimeout(
|
|
69
|
+
async () => {
|
|
70
|
+
switch (UnderpostRootEnv.API.get('monitor-input')) {
|
|
71
|
+
case 'pause':
|
|
72
|
+
monitorCallBack(resolve, reject);
|
|
73
|
+
return;
|
|
74
|
+
case 'restart':
|
|
75
|
+
return reject();
|
|
76
|
+
case 'stop':
|
|
77
|
+
return resolve();
|
|
78
|
+
default:
|
|
79
|
+
await monitor(reject);
|
|
80
|
+
monitorCallBack(resolve, reject);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
!isNaN(envMsTimeout) ? envMsTimeout : optionsMsTimeout,
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
return await new Promise((...args) => monitorCallBack(...args));
|
|
64
88
|
},
|
|
65
89
|
};
|
|
66
90
|
}
|
|
@@ -151,23 +151,27 @@ const Account = {
|
|
|
151
151
|
// s(`.btn-close-modal-account`).click();
|
|
152
152
|
s(`.main-btn-recover`).click();
|
|
153
153
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
154
|
+
EventsUI.onClick(
|
|
155
|
+
`.btn-account-delete-confirm`,
|
|
156
|
+
async (e) => {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
const confirmResult = await Modal.RenderConfirm({
|
|
159
|
+
html: async () => {
|
|
160
|
+
return html`
|
|
161
|
+
<div class="in section-mp" style="text-align: center">
|
|
162
|
+
${Translate.Render('confirm-delete-account')}
|
|
163
|
+
</div>
|
|
164
|
+
`;
|
|
165
|
+
},
|
|
166
|
+
id: 'delete-account-modal',
|
|
167
|
+
});
|
|
168
|
+
if (confirmResult.status === 'cancelled') return;
|
|
169
|
+
s(`.btn-account-delete-confirm`).classList.add('hide');
|
|
170
|
+
s(`.btn-account-delete`).classList.remove('hide');
|
|
171
|
+
s(`.btn-account-delete`).click();
|
|
172
|
+
},
|
|
173
|
+
{ context: 'modal' },
|
|
174
|
+
);
|
|
171
175
|
EventsUI.onClick(`.btn-account-delete`, async (e) => {
|
|
172
176
|
e.preventDefault();
|
|
173
177
|
const result = await UserService.delete({ id: user._id });
|
|
@@ -178,7 +182,7 @@ const Account = {
|
|
|
178
182
|
s(`.btn-account-delete-confirm`).classList.remove('hide');
|
|
179
183
|
s(`.btn-account-delete`).classList.add('hide');
|
|
180
184
|
if (result.status === 'success') {
|
|
181
|
-
|
|
185
|
+
Modal.onHomeRouterEvent();
|
|
182
186
|
await Auth.sessionOut();
|
|
183
187
|
}
|
|
184
188
|
});
|
|
@@ -252,7 +256,7 @@ const Account = {
|
|
|
252
256
|
${options?.bottomRender ? await options.bottomRender() : ``}
|
|
253
257
|
<div class="in hide">
|
|
254
258
|
${await BtnIcon.Render({
|
|
255
|
-
class: 'section-mp form-button btn-account',
|
|
259
|
+
class: 'in section-mp form-button btn-account',
|
|
256
260
|
label: Translate.Render('update'),
|
|
257
261
|
type: 'submit',
|
|
258
262
|
})}
|
|
@@ -260,13 +264,13 @@ const Account = {
|
|
|
260
264
|
</form>
|
|
261
265
|
<div class="in">
|
|
262
266
|
${await BtnIcon.Render({
|
|
263
|
-
class: 'section-mp form-button btn-account-delete hide',
|
|
267
|
+
class: 'in section-mp form-button btn-account-delete hide',
|
|
264
268
|
label: html` ${Translate.Render(`delete-account`)}`,
|
|
265
269
|
type: 'button',
|
|
266
270
|
style: 'color: #5f5f5f',
|
|
267
271
|
})}
|
|
268
272
|
${await BtnIcon.Render({
|
|
269
|
-
class: 'section-mp form-button btn-account-delete-confirm',
|
|
273
|
+
class: 'in section-mp form-button btn-account-delete-confirm',
|
|
270
274
|
label: html` ${Translate.Render(`delete-account`)}`,
|
|
271
275
|
type: 'button',
|
|
272
276
|
style: 'color: #5f5f5f',
|
|
@@ -25,7 +25,7 @@ const BlockChainManagement = {
|
|
|
25
25
|
placeholder: true,
|
|
26
26
|
})}
|
|
27
27
|
${await BtnIcon.Render({
|
|
28
|
-
class: `section-mp btn-custom btn-upload-blockchain`,
|
|
28
|
+
class: `inl section-mp btn-custom btn-upload-blockchain`,
|
|
29
29
|
label: html`<i class="fas fa-plus"></i> ${Translate.Render(`create`)}`,
|
|
30
30
|
})}
|
|
31
31
|
</div>
|
|
@@ -40,18 +40,6 @@ const CalendarCore = {
|
|
|
40
40
|
|
|
41
41
|
const titleIcon = html`<i class="fas fa-calendar-alt"></i>`;
|
|
42
42
|
|
|
43
|
-
const getSrrData = () => {
|
|
44
|
-
this.Data[options.idModal].data = range(0, 5).map((i) => {
|
|
45
|
-
return {
|
|
46
|
-
id: `event-${i}`,
|
|
47
|
-
description: `Event ${s4()}${s4()}${s4()}`,
|
|
48
|
-
start: new Date().toTimeString(),
|
|
49
|
-
end: new Date().toTimeString(),
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
getSrrData();
|
|
54
|
-
|
|
55
43
|
const getPanelData = async () => {
|
|
56
44
|
const result = await EventSchedulerService.get({
|
|
57
45
|
id: `${getQueryParams().cid ? getQueryParams().cid : Auth.getToken() ? 'creatorUser' : ''}`,
|
|
@@ -235,35 +223,9 @@ const CalendarCore = {
|
|
|
235
223
|
];
|
|
236
224
|
|
|
237
225
|
setTimeout(() => {
|
|
238
|
-
const resizeModal = () => {
|
|
239
|
-
Modal.Data[options.idModal].onObserverListener[options.idModal] = () => {
|
|
240
|
-
if (s(`.main-body-calendar-${options.idModal}`))
|
|
241
|
-
s(`.main-body-calendar-${options.idModal}`).style.height = `${
|
|
242
|
-
s(`.${options.idModal}`).offsetHeight - Modal.headerTitleHeight
|
|
243
|
-
}px`;
|
|
244
|
-
};
|
|
245
|
-
Modal.Data[options.idModal].onObserverListener[options.idModal]();
|
|
246
|
-
};
|
|
247
|
-
setTimeout(resizeModal);
|
|
248
|
-
RouterEvents[`${options.idModal}-main-body`] = ({ route }) => {
|
|
249
|
-
if (route === 'calendar') {
|
|
250
|
-
setTimeout(() => {
|
|
251
|
-
resizeModal();
|
|
252
|
-
}, 400);
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
|
|
256
226
|
s(`.close-calendar-container`).onclick = () => {
|
|
257
227
|
s(`.calendar-container`).classList.add('hide');
|
|
258
228
|
s(`.main-body-calendar-${options.idModal}`).classList.remove('hide');
|
|
259
|
-
htmls(
|
|
260
|
-
`.style-calendar`,
|
|
261
|
-
html`<style>
|
|
262
|
-
.modal-calendar {
|
|
263
|
-
overflow: hidden;
|
|
264
|
-
}
|
|
265
|
-
</style>`,
|
|
266
|
-
);
|
|
267
229
|
};
|
|
268
230
|
});
|
|
269
231
|
|
|
@@ -305,14 +267,6 @@ const CalendarCore = {
|
|
|
305
267
|
// renderCalendar();
|
|
306
268
|
CalendarCore.Data[options.idModal].calendar.setOption('height', 700);
|
|
307
269
|
Translate.Event['fullcalendar-lang']();
|
|
308
|
-
htmls(
|
|
309
|
-
`.style-calendar`,
|
|
310
|
-
html`<style>
|
|
311
|
-
.modal-calendar {
|
|
312
|
-
overflow: auto;
|
|
313
|
-
}
|
|
314
|
-
</style>`,
|
|
315
|
-
);
|
|
316
270
|
},
|
|
317
271
|
},
|
|
318
272
|
],
|
|
@@ -404,16 +358,11 @@ const CalendarCore = {
|
|
|
404
358
|
<div class="in" style="margin-bottom: 100px"></div>`;
|
|
405
359
|
};
|
|
406
360
|
|
|
407
|
-
let
|
|
361
|
+
let lastCid;
|
|
408
362
|
this.Data[options.idModal].updatePanel = async () => {
|
|
409
|
-
if (delayBlock) return;
|
|
410
|
-
else {
|
|
411
|
-
delayBlock = true;
|
|
412
|
-
setTimeout(() => {
|
|
413
|
-
delayBlock = false;
|
|
414
|
-
}, 500);
|
|
415
|
-
}
|
|
416
363
|
const cid = getQueryParams().cid ? getQueryParams().cid : '';
|
|
364
|
+
if (lastCid === cid) return;
|
|
365
|
+
lastCid = cid;
|
|
417
366
|
if (options.route === 'home') Modal.homeCid = newInstance(cid);
|
|
418
367
|
if (s(`.main-body-calendar-${options.idModal}`)) {
|
|
419
368
|
// if (Auth.getToken())
|
|
@@ -423,39 +372,22 @@ const CalendarCore = {
|
|
|
423
372
|
}
|
|
424
373
|
};
|
|
425
374
|
|
|
426
|
-
if (options.route)
|
|
375
|
+
if (options.route) {
|
|
427
376
|
listenQueryPathInstance({
|
|
428
377
|
id: options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body',
|
|
429
378
|
routeId: options.route,
|
|
430
379
|
event: async (path) => {
|
|
431
|
-
|
|
432
|
-
CalendarCore.Data[options.idModal].updatePanel();
|
|
433
|
-
});
|
|
380
|
+
CalendarCore.Data[options.idModal].updatePanel();
|
|
434
381
|
},
|
|
435
382
|
});
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
383
|
+
if (!options.parentIdModal)
|
|
384
|
+
Modal.Data['modal-menu'].onHome[idPanel] = async () => {
|
|
385
|
+
lastCid = undefined;
|
|
386
|
+
setQueryPath({ path: options.route, queryPath: '' });
|
|
387
|
+
await this.Data[idPanel].updatePanel();
|
|
388
|
+
};
|
|
389
|
+
}
|
|
442
390
|
return html`
|
|
443
|
-
<style>
|
|
444
|
-
.main-body-calendar-${options.idModal} {
|
|
445
|
-
overflow: auto;
|
|
446
|
-
}
|
|
447
|
-
.${idPanel}-form {
|
|
448
|
-
max-width: 750px !important;
|
|
449
|
-
}
|
|
450
|
-
</style>
|
|
451
|
-
<div class="style-calendar">
|
|
452
|
-
<style>
|
|
453
|
-
.modal-calendar {
|
|
454
|
-
overflow: hidden;
|
|
455
|
-
}
|
|
456
|
-
</style>
|
|
457
|
-
</div>
|
|
458
|
-
|
|
459
391
|
<div class="in main-body-calendar-${options.idModal}">${await panelRender()}</div>
|
|
460
392
|
<style>
|
|
461
393
|
.calendar-container {
|
|
@@ -513,15 +445,13 @@ const CalendarCore = {
|
|
|
513
445
|
|
|
514
446
|
.calendar-buttons-container {
|
|
515
447
|
padding-bottom: 15px;
|
|
516
|
-
top: ${Modal.headerTitleHeight}px;
|
|
517
448
|
height: 60px;
|
|
518
|
-
z-index: 4;
|
|
519
449
|
}
|
|
520
450
|
</style>
|
|
521
451
|
<div class="in calendar-container hide">
|
|
522
|
-
<div class="
|
|
452
|
+
<div class="in modal calendar-buttons-container">
|
|
523
453
|
${await BtnIcon.Render({
|
|
524
|
-
class: `section-mp btn-custom close-calendar-container flr`,
|
|
454
|
+
class: `inl section-mp btn-custom close-calendar-container flr`,
|
|
525
455
|
label: html`<i class="fa-solid fa-xmark"></i> ${Translate.Render('close')}`,
|
|
526
456
|
type: 'button',
|
|
527
457
|
})}
|
|
@@ -396,7 +396,8 @@ const CssCoreDark = {
|
|
|
396
396
|
text-align: center;
|
|
397
397
|
background: #1a1a1a;
|
|
398
398
|
font-size: 17px;
|
|
399
|
-
height:
|
|
399
|
+
height: 30px;
|
|
400
|
+
padding: 5px 0px 5px 0px;
|
|
400
401
|
}
|
|
401
402
|
::placeholder {
|
|
402
403
|
color: #c6c4c4;
|
|
@@ -471,6 +472,7 @@ const CssCoreDark = {
|
|
|
471
472
|
width: 260px;
|
|
472
473
|
font-size: 20px;
|
|
473
474
|
padding: 10px;
|
|
475
|
+
min-height: 45px;
|
|
474
476
|
}
|
|
475
477
|
.toggle-form-container {
|
|
476
478
|
border: 2px solid #313131;
|
|
@@ -494,6 +496,7 @@ const CssCoreDark = {
|
|
|
494
496
|
font-size: 20px;
|
|
495
497
|
padding: 10px;
|
|
496
498
|
text-align: center;
|
|
499
|
+
min-height: 45px;
|
|
497
500
|
}
|
|
498
501
|
.drop-zone-file-explorer {
|
|
499
502
|
min-height: 300px;
|
|
@@ -700,7 +703,8 @@ const CssCoreLight = {
|
|
|
700
703
|
text-align: center;
|
|
701
704
|
background: #eaeaea;
|
|
702
705
|
font-size: 17px;
|
|
703
|
-
height:
|
|
706
|
+
height: 30px;
|
|
707
|
+
padding: 5px 0px 5px 0px;
|
|
704
708
|
}
|
|
705
709
|
::placeholder {
|
|
706
710
|
color: #333;
|
|
@@ -776,6 +780,7 @@ const CssCoreLight = {
|
|
|
776
780
|
width: 260px;
|
|
777
781
|
font-size: 20px;
|
|
778
782
|
padding: 10px;
|
|
783
|
+
min-height: 45px;
|
|
779
784
|
}
|
|
780
785
|
.toggle-form-container {
|
|
781
786
|
border-radius: 5px;
|
|
@@ -800,6 +805,7 @@ const CssCoreLight = {
|
|
|
800
805
|
font-size: 20px;
|
|
801
806
|
padding: 10px;
|
|
802
807
|
text-align: center;
|
|
808
|
+
min-height: 45px;
|
|
803
809
|
}
|
|
804
810
|
.input-container-width {
|
|
805
811
|
cursor: pointer;
|
|
@@ -16,7 +16,7 @@ const EventsUI = {
|
|
|
16
16
|
if (complete) {
|
|
17
17
|
complete = false;
|
|
18
18
|
await LoadingAnimation.spinner.play(loadingContainer ? loadingContainer : id);
|
|
19
|
-
await LoadingAnimation.bar.play(id);
|
|
19
|
+
if (options.context !== 'modal') await LoadingAnimation.bar.play(id);
|
|
20
20
|
try {
|
|
21
21
|
await logic(e);
|
|
22
22
|
} catch (error) {
|
|
@@ -26,7 +26,7 @@ const EventsUI = {
|
|
|
26
26
|
html: error?.message ? error.message : error ? error : 'Event error',
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
LoadingAnimation.bar.stop(id);
|
|
29
|
+
if (options.context !== 'modal') LoadingAnimation.bar.stop(id);
|
|
30
30
|
await LoadingAnimation.spinner.stop(loadingContainer ? loadingContainer : id);
|
|
31
31
|
complete = true;
|
|
32
32
|
return;
|
|
@@ -323,50 +323,54 @@ const FileExplorer = {
|
|
|
323
323
|
|
|
324
324
|
downloadFile(new Blob([new Uint8Array(file.data.data)], { type: params.data.mimetype }), params.data.name);
|
|
325
325
|
});
|
|
326
|
-
EventsUI.onClick(
|
|
327
|
-
|
|
328
|
-
{
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
326
|
+
EventsUI.onClick(
|
|
327
|
+
`.btn-file-delete-${params.data._id}`,
|
|
328
|
+
async (e) => {
|
|
329
|
+
e.preventDefault();
|
|
330
|
+
{
|
|
331
|
+
const confirmResult = await Modal.RenderConfirm({
|
|
332
|
+
html: async () => {
|
|
333
|
+
return html`
|
|
334
|
+
<div class="in section-mp" style="text-align: center">
|
|
335
|
+
${Translate.Render('confirm-delete-item')}
|
|
336
|
+
<br />
|
|
337
|
+
"${params.data.title}"
|
|
338
|
+
</div>
|
|
339
|
+
`;
|
|
340
|
+
},
|
|
341
|
+
id: `delete-${params.data._id}`,
|
|
342
|
+
});
|
|
343
|
+
if (confirmResult.status !== 'confirm') return;
|
|
342
344
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
const { data, status, message } = await FileService.delete({
|
|
346
|
+
id: params.data.fileId,
|
|
347
|
+
});
|
|
348
|
+
NotificationManager.Push({
|
|
349
|
+
html: status,
|
|
350
|
+
status,
|
|
351
|
+
});
|
|
352
|
+
if (status === 'error') return;
|
|
353
|
+
}
|
|
354
|
+
const { data, status, message } = await DocumentService.delete({
|
|
355
|
+
id: params.data._id,
|
|
345
356
|
});
|
|
346
357
|
NotificationManager.Push({
|
|
347
358
|
html: status,
|
|
348
359
|
status,
|
|
349
360
|
});
|
|
350
361
|
if (status === 'error') return;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
});
|
|
362
|
+
|
|
363
|
+
documentInstance = documentInstance.filter((f) => f._id !== params.data._id);
|
|
364
|
+
const format = FileExplorer.documentDataFormat({ document: documentInstance, location });
|
|
365
|
+
files = format.files;
|
|
366
|
+
folders = format.folders;
|
|
367
|
+
// AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
368
|
+
// const selectedData = gridApi.getSelectedRows();
|
|
369
|
+
AgGrid.grids[gridFileId].applyTransaction({ remove: [params.data] });
|
|
370
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
371
|
+
},
|
|
372
|
+
{ context: 'modal' },
|
|
373
|
+
);
|
|
370
374
|
});
|
|
371
375
|
}
|
|
372
376
|
|
|
@@ -400,49 +404,53 @@ const FileExplorer = {
|
|
|
400
404
|
`;
|
|
401
405
|
|
|
402
406
|
setTimeout(() => {
|
|
403
|
-
EventsUI.onClick(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
<
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
407
|
+
EventsUI.onClick(
|
|
408
|
+
`.btn-folder-delete-${id}`,
|
|
409
|
+
async (e) => {
|
|
410
|
+
const confirmResult = await Modal.RenderConfirm({
|
|
411
|
+
html: async () => {
|
|
412
|
+
return html`
|
|
413
|
+
<div class="in section-mp" style="text-align: center">
|
|
414
|
+
${Translate.Render('confirm-delete-item')}
|
|
415
|
+
<br />
|
|
416
|
+
"${params.data.location}"
|
|
417
|
+
</div>
|
|
418
|
+
`;
|
|
419
|
+
},
|
|
420
|
+
id: `delete-${id}`,
|
|
421
|
+
});
|
|
422
|
+
if (confirmResult.status !== 'confirm') return;
|
|
417
423
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
424
|
+
e.preventDefault();
|
|
425
|
+
const idFilesDelete = [];
|
|
426
|
+
for (const file of documentInstance.filter(
|
|
427
|
+
(f) => FileExplorer.locationFormat({ f }) === params.data.location, // .startsWith(params.data.location),
|
|
428
|
+
)) {
|
|
429
|
+
{
|
|
430
|
+
const { data, status, message } = await FileService.delete({
|
|
431
|
+
id: file.fileId._id,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
{
|
|
435
|
+
idFilesDelete.push(file._id);
|
|
436
|
+
const { data, status, message } = await DocumentService.delete({
|
|
437
|
+
id: file._id,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
427
440
|
}
|
|
428
|
-
{
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
files = format.files;
|
|
442
|
-
folders = format.folders;
|
|
443
|
-
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
444
|
-
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
445
|
-
});
|
|
441
|
+
NotificationManager.Push({
|
|
442
|
+
html: Translate.Render('success-delete'),
|
|
443
|
+
status: 'success',
|
|
444
|
+
});
|
|
445
|
+
documentInstance = documentInstance.filter((f) => !idFilesDelete.includes(f._id));
|
|
446
|
+
const format = FileExplorer.documentDataFormat({ document: documentInstance, location });
|
|
447
|
+
files = format.files;
|
|
448
|
+
folders = format.folders;
|
|
449
|
+
AgGrid.grids[gridFileId].setGridOption('rowData', files);
|
|
450
|
+
AgGrid.grids[gridFolderId].setGridOption('rowData', folders);
|
|
451
|
+
},
|
|
452
|
+
{ context: 'modal' },
|
|
453
|
+
);
|
|
446
454
|
});
|
|
447
455
|
}
|
|
448
456
|
|