@underpostnet/underpost 2.8.5 → 2.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/.github/workflows/ghpkg.yml +1 -1
  2. package/.github/workflows/npmpkg.yml +1 -1
  3. package/.github/workflows/pwa-microservices-template.page.yml +1 -1
  4. package/.vscode/extensions.json +3 -2
  5. package/.vscode/settings.json +6 -0
  6. package/CHANGELOG.md +44 -0
  7. package/Dockerfile +9 -10
  8. package/README.md +39 -2
  9. package/bin/build.js +31 -6
  10. package/bin/deploy.js +1404 -202
  11. package/bin/file.js +8 -0
  12. package/bin/hwt.js +0 -10
  13. package/bin/index.js +1 -187
  14. package/bin/util.js +0 -7
  15. package/bin/vs.js +1 -0
  16. package/cli.md +451 -0
  17. package/conf.js +0 -2
  18. package/docker-compose.yml +1 -1
  19. package/jsdoc.json +1 -1
  20. package/manifests/calico-custom-resources.yaml +25 -0
  21. package/manifests/deployment/adminer/deployment.yaml +32 -0
  22. package/manifests/deployment/adminer/kustomization.yaml +7 -0
  23. package/manifests/deployment/adminer/service.yaml +13 -0
  24. package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
  25. package/manifests/deployment/fastapi/backend-service.yml +19 -0
  26. package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
  27. package/manifests/deployment/fastapi/frontend-service.yml +15 -0
  28. package/manifests/deployment/kafka/deployment.yaml +69 -0
  29. package/manifests/kind-config-dev.yaml +12 -0
  30. package/manifests/kubeadm-calico-config.yaml +119 -0
  31. package/manifests/mongodb/kustomization.yaml +2 -2
  32. package/manifests/mongodb-4.4/kustomization.yaml +7 -0
  33. package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
  34. package/manifests/postgresql/configmap.yaml +9 -0
  35. package/manifests/postgresql/kustomization.yaml +10 -0
  36. package/manifests/postgresql/pv.yaml +15 -0
  37. package/manifests/postgresql/pvc.yaml +13 -0
  38. package/manifests/{core/underpost-engine-headless-service.yaml → postgresql/service.yaml} +3 -3
  39. package/manifests/postgresql/statefulset.yaml +37 -0
  40. package/manifests/valkey/statefulset.yaml +6 -4
  41. package/package.json +10 -14
  42. package/src/api/default/default.service.js +1 -1
  43. package/src/api/user/user.service.js +14 -11
  44. package/src/cli/cluster.js +298 -63
  45. package/src/cli/cron.js +39 -8
  46. package/src/cli/db.js +118 -44
  47. package/src/cli/deploy.js +312 -102
  48. package/src/cli/env.js +9 -3
  49. package/src/cli/fs.js +161 -0
  50. package/src/cli/image.js +45 -104
  51. package/src/cli/index.js +312 -0
  52. package/src/cli/monitor.js +236 -0
  53. package/src/cli/repository.js +26 -2
  54. package/src/cli/script.js +25 -1
  55. package/src/cli/test.js +39 -4
  56. package/src/client/components/core/Account.js +28 -24
  57. package/src/client/components/core/Blockchain.js +1 -1
  58. package/src/client/components/core/CalendarCore.js +14 -73
  59. package/src/client/components/core/CommonJs.js +54 -2
  60. package/src/client/components/core/Css.js +0 -1
  61. package/src/client/components/core/CssCore.js +10 -4
  62. package/src/client/components/core/Docs.js +1 -2
  63. package/src/client/components/core/EventsUI.js +3 -3
  64. package/src/client/components/core/FileExplorer.js +86 -78
  65. package/src/client/components/core/Input.js +4 -2
  66. package/src/client/components/core/JoyStick.js +2 -2
  67. package/src/client/components/core/LoadingAnimation.js +3 -12
  68. package/src/client/components/core/LogIn.js +3 -3
  69. package/src/client/components/core/LogOut.js +1 -1
  70. package/src/client/components/core/Modal.js +44 -14
  71. package/src/client/components/core/Panel.js +26 -66
  72. package/src/client/components/core/PanelForm.js +22 -15
  73. package/src/client/components/core/Recover.js +3 -3
  74. package/src/client/components/core/RichText.js +1 -11
  75. package/src/client/components/core/Router.js +3 -1
  76. package/src/client/components/core/SignUp.js +2 -2
  77. package/src/client/components/default/RoutesDefault.js +3 -2
  78. package/src/client/services/core/core.service.js +15 -10
  79. package/src/client/services/default/default.management.js +45 -38
  80. package/src/client/ssr/Render.js +6 -1
  81. package/src/client/ssr/body/CacheControl.js +2 -3
  82. package/src/client/sw/default.sw.js +3 -3
  83. package/src/db/mongo/MongooseDB.js +17 -1
  84. package/src/index.js +25 -1
  85. package/src/mailer/MailerProvider.js +3 -0
  86. package/src/runtime/lampp/Dockerfile +65 -0
  87. package/src/server/backup.js +3 -3
  88. package/src/server/client-build.js +45 -23
  89. package/src/server/client-formatted.js +2 -1
  90. package/src/server/conf.js +110 -16
  91. package/src/server/dns.js +74 -43
  92. package/src/server/downloader.js +0 -8
  93. package/src/server/json-schema.js +77 -0
  94. package/src/server/network.js +7 -122
  95. package/src/server/peer.js +2 -2
  96. package/src/server/proxy.js +4 -4
  97. package/src/server/runtime.js +40 -12
  98. package/src/server/start.js +122 -0
  99. package/src/server/valkey.js +25 -11
  100. package/test/api.test.js +0 -8
  101. package/manifests/core/kustomization.yaml +0 -11
  102. package/manifests/core/underpost-engine-backup-access.yaml +0 -16
  103. package/manifests/core/underpost-engine-backup-pv-pvc.yaml +0 -22
  104. package/manifests/core/underpost-engine-mongodb-backup-cronjob.yaml +0 -40
  105. package/manifests/core/underpost-engine-mongodb-configmap.yaml +0 -26
  106. package/manifests/core/underpost-engine-statefulset.yaml +0 -91
  107. package/manifests/valkey/underpost-engine-valkey-service.yaml +0 -17
  108. package/manifests/valkey/underpost-engine-valkey-statefulset.yaml +0 -39
  109. /package/manifests/{core/underpost-engine-pv-pvc.yaml → mongodb-4.4/pv-pvc.yaml} +0 -0
@@ -0,0 +1,236 @@
1
+ import { loadReplicas, pathPortAssignmentFactory } from '../server/conf.js';
2
+ import { loggerFactory } from '../server/logger.js';
3
+ import UnderpostDeploy from './deploy.js';
4
+ import axios from 'axios';
5
+ import UnderpostRootEnv from './env.js';
6
+ import fs from 'fs-extra';
7
+ import { shellExec } from '../server/process.js';
8
+ import { isInternetConnection } from '../server/dns.js';
9
+
10
+ const logger = loggerFactory(import.meta);
11
+
12
+ class UnderpostMonitor {
13
+ static API = {
14
+ async callback(
15
+ deployId,
16
+ env = 'development',
17
+ options = { now: false, single: false, msInterval: '', type: '', replicas: '', sync: false },
18
+ commanderOptions,
19
+ auxRouter,
20
+ ) {
21
+ if (deployId === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`)) {
22
+ for (const _deployId of fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(','))
23
+ UnderpostMonitor.API.callback(
24
+ _deployId.trim(),
25
+ env,
26
+ options,
27
+ commanderOptions,
28
+ await UnderpostDeploy.API.routerFactory(_deployId, env),
29
+ );
30
+ return;
31
+ }
32
+
33
+ const router = auxRouter ?? (await UnderpostDeploy.API.routerFactory(deployId, env));
34
+
35
+ const confServer = loadReplicas(
36
+ JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
37
+ 'proxy',
38
+ );
39
+
40
+ const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
41
+
42
+ let errorPayloads = [];
43
+ if (options.sync === true) {
44
+ const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
45
+ if (currentTraffic) UnderpostRootEnv.API.set(`${deployId}-${env}-traffic`, currentTraffic);
46
+ }
47
+ let traffic = UnderpostRootEnv.API.get(`${deployId}-${env}-traffic`) ?? 'blue';
48
+ const maxAttempts = parseInt(
49
+ Object.keys(pathPortAssignmentData)
50
+ .map((host) => pathPortAssignmentData[host].length)
51
+ .reduce((accumulator, value) => accumulator + value, 0) * 2.5,
52
+ );
53
+
54
+ logger.info(`Init deploy monitor`, {
55
+ pathPortAssignmentData,
56
+ maxAttempts,
57
+ deployId,
58
+ env,
59
+ traffic,
60
+ });
61
+
62
+ const switchTraffic = () => {
63
+ if (traffic === 'blue') traffic = 'green';
64
+ else traffic = 'blue';
65
+ UnderpostRootEnv.API.set(`${deployId}-${env}-traffic`, traffic);
66
+ shellExec(
67
+ `node bin deploy --info-router --build-manifest --traffic ${traffic} --replicas ${
68
+ options.replicas ? options.replicas : 1
69
+ } ${deployId} ${env}`,
70
+ );
71
+ shellExec(`sudo kubectl apply -f ./engine-private/conf/${deployId}/build/${env}/proxy.yaml`);
72
+ };
73
+
74
+ const monitor = async (reject) => {
75
+ if (UnderpostRootEnv.API.get(`monitor-init-callback-script`))
76
+ shellExec(UnderpostRootEnv.API.get(`monitor-init-callback-script`));
77
+ const currentTimestamp = new Date().getTime();
78
+ errorPayloads = errorPayloads.filter((e) => currentTimestamp - e.timestamp < 60 * 1000 * 5);
79
+ logger.info(`[${deployId}-${env}] Check server health`);
80
+ for (const host of Object.keys(pathPortAssignmentData)) {
81
+ for (const instance of pathPortAssignmentData[host]) {
82
+ const { port, path } = instance;
83
+ if (path.match('peer') || path.match('socket')) continue;
84
+ let urlTest = `http://localhost:${port}${path}`;
85
+ switch (options.type) {
86
+ case 'remote':
87
+ case 'blue-green':
88
+ urlTest = `https://${host}${path}`;
89
+ break;
90
+
91
+ default:
92
+ break;
93
+ }
94
+ // logger.info('Test instance', urlTest);
95
+ await axios.get(urlTest, { timeout: 10000 }).catch((error) => {
96
+ // console.log(error);
97
+ const errorPayload = {
98
+ urlTest,
99
+ host,
100
+ port,
101
+ path,
102
+ name: error.name,
103
+ status: error.status,
104
+ code: error.code,
105
+ errors: error.errors,
106
+ timestamp: new Date().getTime(),
107
+ };
108
+ if (errorPayload.status !== 404) {
109
+ errorPayloads.push(errorPayload);
110
+ if (errorPayloads.length >= maxAttempts) {
111
+ const message = JSON.stringify(errorPayloads, null, 4);
112
+ logger.error(
113
+ `Deployment ${deployId} ${env} has been reached max attempts error payloads`,
114
+ errorPayloads,
115
+ );
116
+ switch (options.type) {
117
+ case 'blue-green':
118
+ {
119
+ const confServer = JSON.parse(
120
+ fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'),
121
+ );
122
+
123
+ shellExec(`kubectl delete configmap underpost-config`);
124
+ shellExec(
125
+ `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
126
+ );
127
+
128
+ for (const host of Object.keys(confServer)) {
129
+ shellExec(`sudo kubectl delete HTTPProxy ${host}`);
130
+ }
131
+ shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${traffic}`);
132
+
133
+ switchTraffic();
134
+ }
135
+
136
+ break;
137
+
138
+ case 'remote':
139
+ break;
140
+
141
+ default:
142
+ if (reject) reject(message);
143
+ else throw new Error(message);
144
+ }
145
+ errorPayloads = [];
146
+ }
147
+ logger.error(`Error accumulator ${deployId}-${env}-${traffic}`, errorPayloads.length);
148
+ }
149
+ });
150
+ }
151
+ }
152
+ };
153
+ if (options.now === true) await monitor();
154
+ if (options.single === true) return;
155
+ let optionsMsTimeout = parseInt(options.msInterval);
156
+ if (isNaN(optionsMsTimeout)) optionsMsTimeout = 60250; // 60.25 seconds
157
+ let monitorTrafficName;
158
+ let monitorPodName;
159
+ const monitorCallBack = (resolve, reject) => {
160
+ const envMsTimeout = UnderpostRootEnv.API.get(`${deployId}-${env}-monitor-ms`);
161
+ setTimeout(
162
+ async () => {
163
+ const isOnline = await isInternetConnection();
164
+ if (!isOnline) {
165
+ logger.warn('No internet connection');
166
+ monitorCallBack(resolve, reject);
167
+ return;
168
+ }
169
+ switch (options.type) {
170
+ case 'blue-green':
171
+ {
172
+ if (monitorTrafficName !== traffic) {
173
+ monitorTrafficName = undefined;
174
+ monitorPodName = undefined;
175
+ }
176
+ const cmd = `underpost config get container-status`;
177
+ const checkDeploymentReadyStatus = () => {
178
+ const pods = UnderpostDeploy.API.get(`${deployId}-${env}-${traffic}`);
179
+ if (pods && pods[0]) {
180
+ const { NAME } = pods[0];
181
+ if (
182
+ shellExec(`sudo kubectl exec -i ${NAME} -- sh -c "${cmd}"`, { stdout: true }).match(
183
+ `${deployId}-${env}-running-deployment`,
184
+ )
185
+ ) {
186
+ monitorPodName = NAME;
187
+ monitorTrafficName = `${traffic}`;
188
+ }
189
+ }
190
+ };
191
+ if (!monitorPodName) {
192
+ checkDeploymentReadyStatus();
193
+ monitorCallBack(resolve, reject);
194
+ return;
195
+ }
196
+ }
197
+
198
+ break;
199
+
200
+ default:
201
+ break;
202
+ }
203
+ for (const monitorStatus of [
204
+ { key: `monitor-input`, value: UnderpostRootEnv.API.get(`monitor-input`) },
205
+ {
206
+ key: `${deployId}-${env}-monitor-input`,
207
+ value: UnderpostRootEnv.API.get(`${deployId}-${env}-monitor-input`),
208
+ },
209
+ ])
210
+ switch (monitorStatus.value) {
211
+ case 'pause':
212
+ monitorCallBack(resolve, reject);
213
+ return;
214
+ case 'restart':
215
+ UnderpostRootEnv.API.delete(monitorStatus.key);
216
+ return reject();
217
+ case 'stop':
218
+ UnderpostRootEnv.API.delete(monitorStatus.key);
219
+ return resolve();
220
+ case 'blue-green-switch':
221
+ UnderpostRootEnv.API.delete(monitorStatus.key);
222
+ switchTraffic();
223
+ }
224
+ await monitor(reject);
225
+ monitorCallBack(resolve, reject);
226
+ return;
227
+ },
228
+ !isNaN(envMsTimeout) ? envMsTimeout : optionsMsTimeout,
229
+ );
230
+ };
231
+ return new Promise((...args) => monitorCallBack(...args));
232
+ },
233
+ };
234
+ }
235
+
236
+ export default UnderpostMonitor;
@@ -4,7 +4,7 @@ import { pbcopy, shellExec } from '../server/process.js';
4
4
  import { actionInitLog, loggerFactory } from '../server/logger.js';
5
5
  import fs from 'fs-extra';
6
6
  import { getNpmRootPath } from '../server/conf.js';
7
- import { listenPortController, listenServerFactory } from '../server/network.js';
7
+ import UnderpostStartUp from '../server/start.js';
8
8
 
9
9
  dotenv.config();
10
10
 
@@ -78,7 +78,10 @@ class UnderpostRepository {
78
78
  return new Promise(async (resolve, reject) => {
79
79
  try {
80
80
  await logger.setUpInfo();
81
- if (repositoryName === 'service') return resolve(await listenPortController(listenServerFactory(), ':'));
81
+ if (repositoryName === 'service')
82
+ return resolve(
83
+ await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), ':'),
84
+ );
82
85
  else actionInitLog();
83
86
  const exeRootPath = `${getNpmRootPath()}/underpost`;
84
87
  const destFolder = `./${repositoryName}`;
@@ -98,6 +101,27 @@ class UnderpostRepository {
98
101
  }
99
102
  });
100
103
  },
104
+
105
+ getDeleteFiles(path = '.') {
106
+ const commandUntrack = `cd ${path} && git ls-files --deleted`;
107
+ const diffUntrackOutput = shellExec(commandUntrack, { stdout: true, silent: true });
108
+ return diffUntrackOutput.toString().split('\n').filter(Boolean);
109
+ },
110
+
111
+ getChangedFiles(path = '.', extension = '', head = false) {
112
+ const extensionFilter = extension ? `-- '***.${extension}'` : '';
113
+ const command = `cd ${path} && git diff ${head ? 'HEAD^ HEAD ' : ''}--name-only ${extensionFilter}`;
114
+ const commandUntrack = `cd ${path} && git ls-files --others --exclude-standard`;
115
+ const diffOutput = shellExec(command, { stdout: true, silent: true });
116
+ const diffUntrackOutput = shellExec(commandUntrack, { stdout: true, silent: true });
117
+ const deleteFiles = UnderpostRepository.API.getDeleteFiles(path);
118
+ return diffOutput
119
+ .toString()
120
+ .split('\n')
121
+ .filter(Boolean)
122
+ .concat(diffUntrackOutput.toString().split('\n').filter(Boolean))
123
+ .filter((f) => !deleteFiles.includes(f));
124
+ },
101
125
  };
102
126
  }
103
127
 
package/src/cli/script.js CHANGED
@@ -2,6 +2,7 @@ import { getNpmRootPath } from '../server/conf.js';
2
2
  import { loggerFactory } from '../server/logger.js';
3
3
  import { shellExec } from '../server/process.js';
4
4
  import fs from 'fs-extra';
5
+ import UnderpostDeploy from './deploy.js';
5
6
 
6
7
  const logger = loggerFactory(import.meta);
7
8
 
@@ -13,8 +14,31 @@ class UnderpostScript {
13
14
  packageJson.scripts[key] = value;
14
15
  fs.writeFileSync(`${npmRoot}/package.json`, JSON.stringify(packageJson, null, 4));
15
16
  },
16
- run(key) {
17
+ run(key, value, options) {
17
18
  const npmRoot = `${getNpmRootPath()}/underpost`;
19
+ const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
20
+ if (options.itc === true) {
21
+ value = packageJson.scripts[key];
22
+ const podScriptPath = `${options.itcPath && typeof options.itcPath === 'string' ? options.itcPath : '/'}${value
23
+ .split('/')
24
+ .pop()}`;
25
+ const nameSpace = options.ns && typeof options.ns === 'string' ? options.ns : 'default';
26
+ const podMatch = options.podName && typeof options.podName === 'string' ? options.podName : key;
27
+
28
+ if (fs.existsSync(`${value}`)) {
29
+ for (const pod of UnderpostDeploy.API.get(podMatch)) {
30
+ shellExec(`sudo kubectl cp ${value} ${nameSpace}/${pod.NAME}:${podScriptPath}`);
31
+ const cmd = `node ${podScriptPath}`;
32
+ shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${cmd}"`);
33
+ }
34
+ } else {
35
+ for (const pod of UnderpostDeploy.API.get(podMatch)) {
36
+ shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${value}"`);
37
+ }
38
+ }
39
+
40
+ return;
41
+ }
18
42
  shellExec(`cd ${npmRoot} && npm run ${key}`);
19
43
  },
20
44
  get(key) {
package/src/cli/test.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { timer } from '../client/components/core/CommonJs.js';
1
2
  import { MariaDB } from '../db/mariadb/MariaDB.js';
2
3
  import { getNpmRootPath } from '../server/conf.js';
3
4
  import { actionInitLog, loggerFactory, setUpInfo } from '../server/logger.js';
@@ -28,9 +29,17 @@ class UnderpostTest {
28
29
  actionInitLog();
29
30
  shellExec(`cd ${getNpmRootPath()}/underpost && npm run test`);
30
31
  },
31
- async callback(deployList = '', options = { insideContainer: false, sh: false, logs: false }) {
32
+ async callback(deployList = '', options = { itc: false, sh: false, logs: false }) {
33
+ if (
34
+ options.podName &&
35
+ typeof options.podName === 'string' &&
36
+ options.podStatus &&
37
+ typeof options.podStatus === 'string'
38
+ )
39
+ return await UnderpostTest.API.statusMonitor(options.podName, options.podStatus, options.kindType);
40
+
32
41
  if (options.sh === true || options.logs === true) {
33
- const [pod] = UnderpostDeploy.API.getPods(deployList);
42
+ const [pod] = UnderpostDeploy.API.get(deployList);
34
43
  if (pod) {
35
44
  if (options.sh) return pbcopy(`sudo kubectl exec -it ${pod.NAME} -- sh`);
36
45
  if (options.logs) return shellExec(`sudo kubectl logs -f ${pod.NAME}`);
@@ -41,7 +50,7 @@ class UnderpostTest {
41
50
  for (const _deployId of deployList.split(',')) {
42
51
  const deployId = _deployId.trim();
43
52
  if (!deployId) continue;
44
- if (options.insideContainer === true)
53
+ if (options.itc === true)
45
54
  switch (deployId) {
46
55
  case 'dd-lampp':
47
56
  {
@@ -64,7 +73,7 @@ class UnderpostTest {
64
73
  break;
65
74
  }
66
75
  else {
67
- const pods = UnderpostDeploy.API.getPods(deployId);
76
+ const pods = UnderpostDeploy.API.get(deployId);
68
77
  if (pods.length > 0)
69
78
  for (const deployData of pods) {
70
79
  const { NAME } = deployData;
@@ -77,6 +86,32 @@ class UnderpostTest {
77
86
  }
78
87
  } else return UnderpostTest.API.run();
79
88
  },
89
+ statusMonitor(podName, status = 'Running', kindType = '', deltaMs = 1000, maxAttempts = 60 * 5) {
90
+ if (!(kindType && typeof kindType === 'string')) kindType = 'pods';
91
+ return new Promise(async (resolve) => {
92
+ let index = 0;
93
+ logger.info(`Loading instance`, { podName, status, kindType, deltaMs, maxAttempts });
94
+ const _monitor = async () => {
95
+ await timer(deltaMs);
96
+ const pods = UnderpostDeploy.API.get(podName, kindType);
97
+ const result = pods.find((p) => p.STATUS === status);
98
+ logger.info(
99
+ `Testing pod ${podName}... ${result ? 1 : 0}/1 - elapsed time ${deltaMs * (index + 1)}s - attempt ${
100
+ index + 1
101
+ }/${maxAttempts}`,
102
+ pods[0] ? pods[0].STATUS : 'Not found kind object',
103
+ );
104
+ if (result) return resolve(true);
105
+ index++;
106
+ if (index === maxAttempts) {
107
+ logger.error(`Failed to test pod ${podName} within ${maxAttempts} attempts`);
108
+ return resolve(false);
109
+ }
110
+ return _monitor();
111
+ };
112
+ await _monitor();
113
+ });
114
+ },
80
115
  };
81
116
  }
82
117
 
@@ -151,23 +151,27 @@ const Account = {
151
151
  // s(`.btn-close-modal-account`).click();
152
152
  s(`.main-btn-recover`).click();
153
153
  };
154
- s(`.btn-account-delete-confirm`).onclick = async (e) => {
155
- e.preventDefault();
156
- const confirmResult = await Modal.RenderConfirm({
157
- html: async () => {
158
- return html`
159
- <div class="in section-mp" style="text-align: center">
160
- ${Translate.Render('confirm-delete-account')}
161
- </div>
162
- `;
163
- },
164
- id: 'delete-account-modal',
165
- });
166
- if (confirmResult.status === 'cancelled') return;
167
- s(`.btn-account-delete-confirm`).classList.add('hide');
168
- s(`.btn-account-delete`).classList.remove('hide');
169
- s(`.btn-account-delete`).click();
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
- s(`.main-btn-home`).click();
185
+ Modal.onHomeRouterEvent();
182
186
  await Auth.sessionOut();
183
187
  }
184
188
  });
@@ -200,7 +204,7 @@ const Account = {
200
204
  disabled: false,
201
205
  extension: async () =>
202
206
  html`${await BtnIcon.Render({
203
- class: `wfa btn-input-extension btn-account-update-username`,
207
+ class: `in wfa btn-input-extension btn-account-update-username`,
204
208
  type: 'button',
205
209
  style: 'text-align: left',
206
210
  label: html`${Translate.Render(`update`)}`,
@@ -219,7 +223,7 @@ const Account = {
219
223
  extension: !(options && options.disabled && options.disabled.includes('emailConfirm'))
220
224
  ? async () => html`<div class="in verify-email-status"></div>
221
225
  ${await BtnIcon.Render({
222
- class: `wfa btn-input-extension btn-confirm-email`,
226
+ class: `in wfa btn-input-extension btn-confirm-email`,
223
227
  type: 'button',
224
228
  style: 'text-align: left',
225
229
  label: html`<div class="in">
@@ -242,7 +246,7 @@ const Account = {
242
246
  disabledEye: true,
243
247
  extension: async () =>
244
248
  html`${await BtnIcon.Render({
245
- class: `wfa btn-input-extension btn-account-change-password`,
249
+ class: `in wfa btn-input-extension btn-account-change-password`,
246
250
  type: 'button',
247
251
  style: 'text-align: left',
248
252
  label: html`${Translate.Render(`change-password`)}`,
@@ -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,8 +358,11 @@ const CalendarCore = {
404
358
  <div class="in" style="margin-bottom: 100px"></div>`;
405
359
  };
406
360
 
361
+ let lastCid;
407
362
  this.Data[options.idModal].updatePanel = async () => {
408
363
  const cid = getQueryParams().cid ? getQueryParams().cid : '';
364
+ if (lastCid === cid) return;
365
+ lastCid = cid;
409
366
  if (options.route === 'home') Modal.homeCid = newInstance(cid);
410
367
  if (s(`.main-body-calendar-${options.idModal}`)) {
411
368
  // if (Auth.getToken())
@@ -415,36 +372,22 @@ const CalendarCore = {
415
372
  }
416
373
  };
417
374
 
418
- if (options.route)
375
+ if (options.route) {
419
376
  listenQueryPathInstance({
420
377
  id: options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body',
421
378
  routeId: options.route,
422
379
  event: async (path) => {
423
- setTimeout(() => {
424
- CalendarCore.Data[options.idModal].updatePanel();
425
- });
380
+ CalendarCore.Data[options.idModal].updatePanel();
426
381
  },
427
382
  });
428
-
429
- if (options.route === 'home') setTimeout(CalendarCore.Data[options.idModal].updatePanel);
430
-
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
+ }
431
390
  return html`
432
- <style>
433
- .main-body-calendar-${options.idModal} {
434
- overflow: auto;
435
- }
436
- .${idPanel}-form {
437
- max-width: 750px !important;
438
- }
439
- </style>
440
- <div class="style-calendar">
441
- <style>
442
- .modal-calendar {
443
- overflow: hidden;
444
- }
445
- </style>
446
- </div>
447
-
448
391
  <div class="in main-body-calendar-${options.idModal}">${await panelRender()}</div>
449
392
  <style>
450
393
  .calendar-container {
@@ -502,15 +445,13 @@ const CalendarCore = {
502
445
 
503
446
  .calendar-buttons-container {
504
447
  padding-bottom: 15px;
505
- top: ${Modal.headerTitleHeight}px;
506
448
  height: 60px;
507
- z-index: 4;
508
449
  }
509
450
  </style>
510
451
  <div class="in calendar-container hide">
511
- <div class="stq modal calendar-buttons-container">
452
+ <div class="in modal calendar-buttons-container">
512
453
  ${await BtnIcon.Render({
513
- class: `section-mp btn-custom close-calendar-container flr`,
454
+ class: `inl section-mp btn-custom close-calendar-container flr`,
514
455
  label: html`<i class="fa-solid fa-xmark"></i> ${Translate.Render('close')}`,
515
456
  type: 'button',
516
457
  })}