underpost 2.8.637 → 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/bin/build.js +1 -1
- package/bin/deploy.js +2 -1
- package/bin/index.js +2 -0
- 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/image.js +2 -4
- package/src/client/components/core/Account.js +22 -18
- package/src/client/components/core/CalendarCore.js +13 -85
- package/src/client/components/core/CommonJs.js +2 -1
- package/src/client/components/core/EventsUI.js +2 -2
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/Modal.js +12 -7
- package/src/client/components/core/Panel.js +14 -56
- package/src/client/components/core/PanelForm.js +13 -24
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/default/default.management.js +45 -38
- package/src/index.js +10 -3
- 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/bin/build.js
CHANGED
|
@@ -47,7 +47,7 @@ if (process.argv.includes('conf')) {
|
|
|
47
47
|
if (!fs.existsSync(`../${privateRepoName}`)) {
|
|
48
48
|
shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
|
|
49
49
|
} else {
|
|
50
|
-
shellExec(`cd ../${privateRepoName} && underpost pull . ${privateGitUri}`);
|
|
50
|
+
shellExec(`cd ../${privateRepoName} && git checkout . && git clean -f -d && underpost pull . ${privateGitUri}`);
|
|
51
51
|
}
|
|
52
52
|
const toPath = `../${privateRepoName}/conf/${_confName}`;
|
|
53
53
|
fs.removeSync(toPath);
|
package/bin/deploy.js
CHANGED
|
@@ -33,8 +33,9 @@ import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
|
33
33
|
import { Lampp } from '../src/runtime/lampp/Lampp.js';
|
|
34
34
|
import { DefaultConf } from '../conf.js';
|
|
35
35
|
import { JSONweb } from '../src/server/client-formatted.js';
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
import { Xampp } from '../src/runtime/xampp/Xampp.js';
|
|
38
|
+
import { ejs } from '../src/server/json-schema.js';
|
|
38
39
|
|
|
39
40
|
const logger = loggerFactory(import.meta);
|
|
40
41
|
|
package/bin/index.js
CHANGED
|
@@ -105,6 +105,7 @@ program
|
|
|
105
105
|
.option('--info-util', 'Display kubectl util management commands')
|
|
106
106
|
.option('--cert', 'Reset tls/ssl certificate secrets')
|
|
107
107
|
.option('--build-manifest', 'Build kind yaml manifests: deployments, services, proxy and secrets')
|
|
108
|
+
.option('--dashboard-update', 'Update dashboard instance data with current router config')
|
|
108
109
|
.option('--version', 'Set custom version')
|
|
109
110
|
.description('Manage deployment, for default deploy development pods')
|
|
110
111
|
.action(Underpost.deploy.callback);
|
|
@@ -195,6 +196,7 @@ program
|
|
|
195
196
|
.option('--itc', 'Inside container execution context')
|
|
196
197
|
.option('--init', 'Init cron jobs for cron job default deploy id')
|
|
197
198
|
.option('--git', 'Upload to github')
|
|
199
|
+
.option('--dashboard-update', 'Update dashboard cron data with current jobs config')
|
|
198
200
|
.description('Cron jobs management')
|
|
199
201
|
.action(Underpost.cron.callback);
|
|
200
202
|
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.641",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"cors": "^2.8.5",
|
|
70
70
|
"d3": "^7.9.0",
|
|
71
71
|
"dotenv": "^16.3.1",
|
|
72
|
-
"easy-json-schema": "^0.0.2-beta",
|
|
73
72
|
"easymde": "^2.18.0",
|
|
74
73
|
"env-cmd": "^10.1.0",
|
|
75
74
|
"express": "^4.18.2",
|
|
@@ -121,7 +120,6 @@
|
|
|
121
120
|
},
|
|
122
121
|
"devDependencies": {
|
|
123
122
|
"clean-jsdoc-theme": "^4.3.0",
|
|
124
|
-
"easy-json-schema": "^0.0.2-beta",
|
|
125
123
|
"mocha": "^10.8.2",
|
|
126
124
|
"plantuml": "^0.0.2",
|
|
127
125
|
"swagger-autogen": "^2.23.7"
|
|
@@ -24,7 +24,7 @@ const DefaultService = {
|
|
|
24
24
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
25
25
|
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
|
|
26
26
|
if (req.params.id) return await Default.findByIdAndDelete(req.params.id);
|
|
27
|
-
else return await
|
|
27
|
+
else return await Default.deleteMany();
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -378,7 +378,7 @@ const UserService = {
|
|
|
378
378
|
switch (user.role) {
|
|
379
379
|
case 'admin': {
|
|
380
380
|
if (req.params.id) return await User.findByIdAndDelete(req.params.id);
|
|
381
|
-
else return await
|
|
381
|
+
else return await User.deleteMany();
|
|
382
382
|
}
|
|
383
383
|
default:
|
|
384
384
|
if (req.auth.user._id !== req.params.id) throw new Error(`Invalid token user id`);
|
package/src/cli/cron.js
CHANGED
|
@@ -4,20 +4,24 @@
|
|
|
4
4
|
* @namespace UnderpostCron
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import { DataBaseProvider } from '../db/DataBaseProvider.js';
|
|
8
8
|
import BackUp from '../server/backup.js';
|
|
9
9
|
import { Cmd } from '../server/conf.js';
|
|
10
10
|
import Dns from '../server/dns.js';
|
|
11
|
-
import {
|
|
11
|
+
import { loggerFactory } from '../server/logger.js';
|
|
12
|
+
|
|
12
13
|
import { shellExec } from '../server/process.js';
|
|
13
14
|
import fs from 'fs-extra';
|
|
14
15
|
|
|
16
|
+
const logger = loggerFactory(import.meta);
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* UnderpostCron main module methods
|
|
17
20
|
* @class
|
|
18
21
|
* @memberof UnderpostCron
|
|
19
22
|
*/
|
|
20
23
|
class UnderpostCron {
|
|
24
|
+
static NETWORK = [];
|
|
21
25
|
static JOB = {
|
|
22
26
|
/**
|
|
23
27
|
* DNS cli API
|
|
@@ -46,10 +50,10 @@ class UnderpostCron {
|
|
|
46
50
|
callback: async function (
|
|
47
51
|
deployList = 'default',
|
|
48
52
|
jobList = Object.keys(UnderpostCron.JOB),
|
|
49
|
-
options = { itc: false, init: false, git: false },
|
|
53
|
+
options = { itc: false, init: false, git: false, dashboardUpdate: false },
|
|
50
54
|
) {
|
|
51
55
|
if (options.init === true) {
|
|
52
|
-
|
|
56
|
+
UnderpostCron.NETWORK = [];
|
|
53
57
|
const jobDeployId = fs.readFileSync('./engine-private/deploy/dd.cron', 'utf8').trim();
|
|
54
58
|
deployList = fs.readFileSync('./engine-private/deploy/dd.router', 'utf8').trim();
|
|
55
59
|
const confCronConfig = JSON.parse(fs.readFileSync(`./engine-private/conf/${jobDeployId}/conf.cron.json`));
|
|
@@ -57,7 +61,7 @@ class UnderpostCron {
|
|
|
57
61
|
for (const job of Object.keys(confCronConfig.jobs)) {
|
|
58
62
|
const name = `${jobDeployId}-${job}`;
|
|
59
63
|
let deployId;
|
|
60
|
-
shellExec(Cmd.delete(name));
|
|
64
|
+
if (!options.dashboardUpdate) shellExec(Cmd.delete(name));
|
|
61
65
|
switch (job) {
|
|
62
66
|
case 'dns':
|
|
63
67
|
deployId = jobDeployId;
|
|
@@ -67,15 +71,16 @@ class UnderpostCron {
|
|
|
67
71
|
deployId = deployList;
|
|
68
72
|
break;
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
if (!options.dashboardUpdate)
|
|
75
|
+
shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
|
|
76
|
+
UnderpostCron.NETWORK.push({
|
|
72
77
|
deployId,
|
|
73
78
|
jobId: job,
|
|
74
79
|
expression: confCronConfig.jobs[job].expression,
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
|
-
await
|
|
83
|
+
if (options.dashboardUpdate === true) await UnderpostCron.API.updateDashboardData();
|
|
79
84
|
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
80
85
|
return;
|
|
81
86
|
}
|
|
@@ -84,6 +89,32 @@ class UnderpostCron {
|
|
|
84
89
|
if (UnderpostCron.JOB[jobId]) await UnderpostCron.JOB[jobId].callback(deployList, options);
|
|
85
90
|
}
|
|
86
91
|
},
|
|
92
|
+
async updateDashboardData() {
|
|
93
|
+
try {
|
|
94
|
+
const deployId = process.env.DEFAULT_DEPLOY_ID;
|
|
95
|
+
const host = process.env.DEFAULT_DEPLOY_HOST;
|
|
96
|
+
const path = process.env.DEFAULT_DEPLOY_PATH;
|
|
97
|
+
const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
|
|
98
|
+
const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
|
|
99
|
+
const { db } = confServer[host][path];
|
|
100
|
+
|
|
101
|
+
await DataBaseProvider.load({ apis: ['cron'], host, path, db });
|
|
102
|
+
|
|
103
|
+
/** @type {import('../api/cron/cron.model.js').CronModel} */
|
|
104
|
+
const Cron = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Cron;
|
|
105
|
+
|
|
106
|
+
await Cron.deleteMany();
|
|
107
|
+
|
|
108
|
+
for (const cronInstance of UnderpostCron.NETWORK) {
|
|
109
|
+
logger.info('save', cronInstance);
|
|
110
|
+
await new Cron(cronInstance).save();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
114
|
+
} catch (error) {
|
|
115
|
+
logger.error(error, error.stack);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
87
118
|
};
|
|
88
119
|
}
|
|
89
120
|
|
package/src/cli/deploy.js
CHANGED
|
@@ -12,11 +12,12 @@ import { loggerFactory } from '../server/logger.js';
|
|
|
12
12
|
import { shellExec } from '../server/process.js';
|
|
13
13
|
import fs from 'fs-extra';
|
|
14
14
|
import dotenv from 'dotenv';
|
|
15
|
-
import
|
|
15
|
+
import { DataBaseProvider } from '../db/DataBaseProvider.js';
|
|
16
16
|
|
|
17
17
|
const logger = loggerFactory(import.meta);
|
|
18
18
|
|
|
19
19
|
class UnderpostDeploy {
|
|
20
|
+
static NETWORK = {};
|
|
20
21
|
static API = {
|
|
21
22
|
sync(deployList) {
|
|
22
23
|
const deployGroupId = 'dd.tmp';
|
|
@@ -50,7 +51,7 @@ class UnderpostDeploy {
|
|
|
50
51
|
if (env === 'development') fs.mkdirSync(`./manifests/deployment/${deployId}-${env}`, { recursive: true });
|
|
51
52
|
|
|
52
53
|
logger.info('port range', { deployId, fromPort, toPort });
|
|
53
|
-
// const customImg = `underpost-engine:${version && typeof version === 'string' ? version :
|
|
54
|
+
// const customImg = `underpost-engine:${version && typeof version === 'string' ? version : '0.0.0'}`;
|
|
54
55
|
// lifecycle:
|
|
55
56
|
// postStart:
|
|
56
57
|
// exec:
|
|
@@ -85,11 +86,7 @@ spec:
|
|
|
85
86
|
- -c
|
|
86
87
|
- >
|
|
87
88
|
npm install -g npm@11.2.0 &&
|
|
88
|
-
npm
|
|
89
|
-
npm config delete http-proxy &&
|
|
90
|
-
npm config delete https-proxy &&
|
|
91
|
-
npm config set registry http://registry.npmjs.org/ &&
|
|
92
|
-
npm install --unsafe-perm --ignore-scripts -g underpost &&
|
|
89
|
+
npm install -g underpost &&
|
|
93
90
|
underpost secret underpost --create-from-file /etc/config/.env.${env} &&
|
|
94
91
|
underpost dockerfile-node-script --build --run ${deployId} ${env}
|
|
95
92
|
volumeMounts:
|
|
@@ -99,7 +96,7 @@ spec:
|
|
|
99
96
|
- name: config-volume
|
|
100
97
|
configMap:
|
|
101
98
|
name: underpost-config
|
|
102
|
-
# image: localhost/${deployId}-${env}:${version && typeof version === 'string' ? version :
|
|
99
|
+
# image: localhost/${deployId}-${env}:${version && typeof version === 'string' ? version : '0.0.0'}
|
|
103
100
|
---
|
|
104
101
|
apiVersion: v1
|
|
105
102
|
kind: Service
|
|
@@ -200,6 +197,7 @@ spec:
|
|
|
200
197
|
expose: false,
|
|
201
198
|
cert: false,
|
|
202
199
|
version: '',
|
|
200
|
+
dashboardUpdate: false,
|
|
203
201
|
},
|
|
204
202
|
) {
|
|
205
203
|
if (options.infoUtil === true)
|
|
@@ -212,8 +210,9 @@ kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>
|
|
|
212
210
|
deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
|
|
213
211
|
if (options.sync) UnderpostDeploy.API.sync(deployList);
|
|
214
212
|
if (options.buildManifest === true) await UnderpostDeploy.API.buildManifest(deployList, env, options.version);
|
|
215
|
-
if (options.infoRouter === true)
|
|
216
|
-
|
|
213
|
+
if (options.infoRouter === true) logger.info('router', await UnderpostDeploy.API.routerFactory(deployList, env));
|
|
214
|
+
if (options.dashboardUpdate === true) await UnderpostDeploy.API.updateDashboardData(deployList, env, options);
|
|
215
|
+
if (options.infoRouter === true) return;
|
|
217
216
|
shellExec(`kubectl delete configmap underpost-config`);
|
|
218
217
|
shellExec(
|
|
219
218
|
`kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
|
|
@@ -316,6 +315,60 @@ kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>
|
|
|
316
315
|
|
|
317
316
|
return result;
|
|
318
317
|
},
|
|
318
|
+
async updateDashboardData(deployList, env, options) {
|
|
319
|
+
try {
|
|
320
|
+
const deployId = process.env.DEFAULT_DEPLOY_ID;
|
|
321
|
+
const host = process.env.DEFAULT_DEPLOY_HOST;
|
|
322
|
+
const path = process.env.DEFAULT_DEPLOY_PATH;
|
|
323
|
+
const { db } = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'))[host][
|
|
324
|
+
path
|
|
325
|
+
];
|
|
326
|
+
|
|
327
|
+
await DataBaseProvider.load({ apis: ['instance'], host, path, db });
|
|
328
|
+
|
|
329
|
+
/** @type {import('../api/instance/instance.model.js').InstanceModel} */
|
|
330
|
+
const Instance = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Instance;
|
|
331
|
+
|
|
332
|
+
await Instance.deleteMany();
|
|
333
|
+
|
|
334
|
+
for (const _deployId of deployList.split(',')) {
|
|
335
|
+
const deployId = _deployId.trim();
|
|
336
|
+
if (!deployId) continue;
|
|
337
|
+
const confServer = loadReplicas(
|
|
338
|
+
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
339
|
+
'proxy',
|
|
340
|
+
);
|
|
341
|
+
const router = await UnderpostDeploy.API.routerFactory(deployId, env);
|
|
342
|
+
const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
|
|
343
|
+
|
|
344
|
+
for (const host of Object.keys(confServer)) {
|
|
345
|
+
for (const { path, port } of pathPortAssignmentData[host]) {
|
|
346
|
+
if (!confServer[host][path]) continue;
|
|
347
|
+
|
|
348
|
+
const { client, runtime, apis } = confServer[host][path];
|
|
349
|
+
|
|
350
|
+
const body = {
|
|
351
|
+
deployId,
|
|
352
|
+
host,
|
|
353
|
+
path,
|
|
354
|
+
port,
|
|
355
|
+
client,
|
|
356
|
+
runtime,
|
|
357
|
+
apis,
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
logger.info('save', body);
|
|
361
|
+
|
|
362
|
+
await new Instance(body).save();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
368
|
+
} catch (error) {
|
|
369
|
+
logger.error(error, error.stack);
|
|
370
|
+
}
|
|
371
|
+
},
|
|
319
372
|
};
|
|
320
373
|
}
|
|
321
374
|
|
package/src/cli/image.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import Underpost from '../index.js';
|
|
3
2
|
import { shellCd, shellExec } from '../server/process.js';
|
|
4
3
|
import dotenv from 'dotenv';
|
|
5
4
|
import { awaitDeployMonitor, getNpmRootPath } from '../server/conf.js';
|
|
6
|
-
import { timer } from '../client/components/core/CommonJs.js';
|
|
7
5
|
import { loggerFactory } from '../server/logger.js';
|
|
8
6
|
import UnderpostMonitor from './monitor.js';
|
|
9
7
|
|
|
@@ -71,7 +69,8 @@ class UnderpostImage {
|
|
|
71
69
|
shellExec(`cd ${buildBasePath}/engine && underpost clone underpostnet/${repoName}-private`);
|
|
72
70
|
shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
|
|
73
71
|
shellCd(`${buildBasePath}/engine`);
|
|
74
|
-
shellExec(`
|
|
72
|
+
shellExec(`npm install`);
|
|
73
|
+
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
75
74
|
if (fs.existsSync('./engine-private/itc-scripts')) {
|
|
76
75
|
const itcScripts = await fs.readdir('./engine-private/itc-scripts');
|
|
77
76
|
for (const itcScript of itcScripts)
|
|
@@ -110,7 +109,6 @@ class UnderpostImage {
|
|
|
110
109
|
}
|
|
111
110
|
break;
|
|
112
111
|
}
|
|
113
|
-
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
114
112
|
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
115
113
|
}
|
|
116
114
|
if (options.run === true) {
|
|
@@ -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
|
});
|
|
@@ -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,18 +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
|
-
const _currentPath = `${location.pathname}${location.search}`;
|
|
413
|
-
setTimeout(() => {
|
|
414
|
-
delayBlock = false;
|
|
415
|
-
if (`${location.pathname}${location.search}` !== _currentPath) this.Data[options.idModal].updatePanel();
|
|
416
|
-
}, 1000);
|
|
417
|
-
}
|
|
418
363
|
const cid = getQueryParams().cid ? getQueryParams().cid : '';
|
|
364
|
+
if (lastCid === cid) return;
|
|
365
|
+
lastCid = cid;
|
|
419
366
|
if (options.route === 'home') Modal.homeCid = newInstance(cid);
|
|
420
367
|
if (s(`.main-body-calendar-${options.idModal}`)) {
|
|
421
368
|
// if (Auth.getToken())
|
|
@@ -425,39 +372,22 @@ const CalendarCore = {
|
|
|
425
372
|
}
|
|
426
373
|
};
|
|
427
374
|
|
|
428
|
-
if (options.route)
|
|
375
|
+
if (options.route) {
|
|
429
376
|
listenQueryPathInstance({
|
|
430
377
|
id: options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body',
|
|
431
378
|
routeId: options.route,
|
|
432
379
|
event: async (path) => {
|
|
433
|
-
|
|
434
|
-
CalendarCore.Data[options.idModal].updatePanel();
|
|
435
|
-
});
|
|
380
|
+
CalendarCore.Data[options.idModal].updatePanel();
|
|
436
381
|
},
|
|
437
382
|
});
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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
|
+
}
|
|
444
390
|
return html`
|
|
445
|
-
<style>
|
|
446
|
-
.main-body-calendar-${options.idModal} {
|
|
447
|
-
overflow: auto;
|
|
448
|
-
}
|
|
449
|
-
.${idPanel}-form {
|
|
450
|
-
max-width: 750px !important;
|
|
451
|
-
}
|
|
452
|
-
</style>
|
|
453
|
-
<div class="style-calendar">
|
|
454
|
-
<style>
|
|
455
|
-
.modal-calendar {
|
|
456
|
-
overflow: hidden;
|
|
457
|
-
}
|
|
458
|
-
</style>
|
|
459
|
-
</div>
|
|
460
|
-
|
|
461
391
|
<div class="in main-body-calendar-${options.idModal}">${await panelRender()}</div>
|
|
462
392
|
<style>
|
|
463
393
|
.calendar-container {
|
|
@@ -515,13 +445,11 @@ const CalendarCore = {
|
|
|
515
445
|
|
|
516
446
|
.calendar-buttons-container {
|
|
517
447
|
padding-bottom: 15px;
|
|
518
|
-
top: ${Modal.headerTitleHeight}px;
|
|
519
448
|
height: 60px;
|
|
520
|
-
z-index: 4;
|
|
521
449
|
}
|
|
522
450
|
</style>
|
|
523
451
|
<div class="in calendar-container hide">
|
|
524
|
-
<div class="
|
|
452
|
+
<div class="in modal calendar-buttons-container">
|
|
525
453
|
${await BtnIcon.Render({
|
|
526
454
|
class: `inl section-mp btn-custom close-calendar-container flr`,
|
|
527
455
|
label: html`<i class="fa-solid fa-xmark"></i> ${Translate.Render('close')}`,
|
|
@@ -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;
|