underpost 2.8.867 → 2.8.872

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 (60) hide show
  1. package/.github/workflows/release.cd.yml +3 -1
  2. package/README.md +26 -2
  3. package/bin/build.js +1 -0
  4. package/bin/deploy.js +4 -0
  5. package/bin/util.js +1 -56
  6. package/cli.md +3 -1
  7. package/conf.js +3 -2
  8. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  9. package/manifests/deployment/mongo-express/deployment.yaml +12 -12
  10. package/manifests/maas/nvim.sh +91 -0
  11. package/package.json +2 -12
  12. package/src/api/file/file.service.js +28 -8
  13. package/src/api/user/user.router.js +24 -0
  14. package/src/api/user/user.service.js +3 -4
  15. package/src/cli/cluster.js +2 -13
  16. package/src/cli/cron.js +0 -1
  17. package/src/cli/db.js +0 -19
  18. package/src/cli/deploy.js +17 -26
  19. package/src/cli/fs.js +1 -0
  20. package/src/cli/index.js +1 -0
  21. package/src/cli/repository.js +1 -0
  22. package/src/cli/run.js +10 -2
  23. package/src/client/components/core/Account.js +2 -1
  24. package/src/client/components/core/AgGrid.js +2 -2
  25. package/src/client/components/core/CalendarCore.js +2 -3
  26. package/src/client/components/core/CommonJs.js +1 -2
  27. package/src/client/components/core/Content.js +2 -1
  28. package/src/client/components/core/Css.js +2 -1
  29. package/src/client/components/core/CssCore.js +14 -1
  30. package/src/client/components/core/Docs.js +5 -5
  31. package/src/client/components/core/FileExplorer.js +3 -3
  32. package/src/client/components/core/FullScreen.js +19 -28
  33. package/src/client/components/core/Input.js +1 -0
  34. package/src/client/components/core/JoyStick.js +2 -2
  35. package/src/client/components/core/LoadingAnimation.js +2 -2
  36. package/src/client/components/core/Logger.js +4 -1
  37. package/src/client/components/core/Modal.js +54 -47
  38. package/src/client/components/core/ObjectLayerEngine.js +229 -4
  39. package/src/client/components/core/ObjectLayerEngineModal.js +442 -0
  40. package/src/client/components/core/Pagination.js +14 -0
  41. package/src/client/components/core/Panel.js +3 -8
  42. package/src/client/components/core/PanelForm.js +5 -14
  43. package/src/client/components/core/Recover.js +2 -2
  44. package/src/client/components/core/Router.js +183 -34
  45. package/src/client/components/core/Stream.js +1 -1
  46. package/src/client/components/core/ToggleSwitch.js +15 -1
  47. package/src/client/components/core/VanillaJs.js +0 -84
  48. package/src/client/components/core/Worker.js +2 -2
  49. package/src/client/components/default/MenuDefault.js +4 -3
  50. package/src/client/components/default/RoutesDefault.js +3 -2
  51. package/src/client/public/default/assets/mailer/api-user-default-avatar.png +0 -0
  52. package/src/client/services/core/core.service.js +1 -1
  53. package/src/client/ssr/head/DefaultScripts.js +1 -0
  54. package/src/index.js +1 -1
  55. package/src/server/client-build.js +3 -11
  56. package/src/server/client-icons.js +6 -78
  57. package/src/server/conf.js +4 -56
  58. package/src/server/process.js +2 -1
  59. package/src/server/runtime.js +7 -0
  60. package/src/server/ssl.js +1 -2
package/src/cli/deploy.js CHANGED
@@ -247,6 +247,7 @@ spec:
247
247
  restoreHosts: false,
248
248
  disableUpdateDeployment: false,
249
249
  infoTraffic: false,
250
+ etcHosts: false,
250
251
  },
251
252
  ) {
252
253
  if (options.infoUtil === true)
@@ -326,14 +327,10 @@ Password: <Your Key>
326
327
  }
327
328
  UnderpostDeploy.API.configMap(env);
328
329
  let renderHosts = '';
329
- let concatHots = '';
330
- const etcHost = (
331
- concat,
332
- ) => `127.0.0.1 ${concat} localhost localhost.localdomain localhost4 localhost4.localdomain4
333
- ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6`;
330
+ let etcHosts = [];
334
331
  if (options.restoreHosts === true) {
335
- renderHosts = etcHost(concatHots);
336
- fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
332
+ const factoryResult = UnderpostDeploy.API.etcHostFactory(etcHosts);
333
+ renderHosts = factoryResult.renderHosts;
337
334
  logger.info(renderHosts);
338
335
  return;
339
336
  }
@@ -362,7 +359,7 @@ Password: <Your Key>
362
359
  for (const host of Object.keys(confServer)) {
363
360
  shellExec(`sudo kubectl delete HTTPProxy ${host}`);
364
361
  if (env === 'production' && options.cert === true) shellExec(`sudo kubectl delete Certificate ${host}`);
365
- if (!options.remove === true && env === 'development') concatHots += ` ${host}`;
362
+ if (!options.remove === true && env === 'development') etcHosts.push(host);
366
363
  }
367
364
 
368
365
  const manifestsPath =
@@ -377,24 +374,9 @@ Password: <Your Key>
377
374
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
378
375
  }
379
376
  }
380
- switch (process.platform) {
381
- case 'linux':
382
- {
383
- switch (env) {
384
- case 'development':
385
- renderHosts = etcHost(concatHots);
386
- fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
387
-
388
- break;
389
-
390
- default:
391
- break;
392
- }
393
- }
394
- break;
395
-
396
- default:
397
- break;
377
+ if (options.etcHosts === true) {
378
+ const factoryResult = UnderpostDeploy.API.etcHostFactory(etcHosts);
379
+ renderHosts = factoryResult.renderHosts;
398
380
  }
399
381
  if (renderHosts)
400
382
  logger.info(
@@ -488,6 +470,15 @@ Password: <Your Key>
488
470
  );
489
471
  shellExec(`sudo kubectl apply -f ./engine-private/conf/${deployId}/build/${env}/proxy.yaml`);
490
472
  },
473
+ etcHostFactory(hosts = []) {
474
+ const renderHosts = `127.0.0.1 ${hosts.join(
475
+ ' ',
476
+ )} localhost localhost.localdomain localhost4 localhost4.localdomain4
477
+ ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6`;
478
+
479
+ fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
480
+ return { renderHosts };
481
+ },
491
482
  };
492
483
  }
493
484
 
package/src/cli/fs.js CHANGED
@@ -61,6 +61,7 @@ class UnderpostFileStorage {
61
61
  await UnderpostFileStorage.API.pull(_path, options);
62
62
  } else logger.warn(`Pull path already exists`, _path);
63
63
  }
64
+ shellExec(`cd ${path} && git init && git add . && git commit -m "Base pull state"`);
64
65
  } else {
65
66
  const files =
66
67
  options.git === true
package/src/cli/index.js CHANGED
@@ -169,6 +169,7 @@ program
169
169
  .option('--disable-update-deployment', 'Disables updates to deployments.')
170
170
  .option('--info-traffic', 'Retrieves traffic configuration from current resource deployments.')
171
171
  .option('--kubeadm', 'Enables the kubeadm context for deployment operations.')
172
+ .option('--etc-hosts', 'Enables the etc-hosts context for deployment operations.')
172
173
  .option('--restore-hosts', 'Restores default `/etc/hosts` entries.')
173
174
  .description('Manages application deployments, defaulting to deploying development pods.')
174
175
  .action(Underpost.deploy.callback);
@@ -49,6 +49,7 @@ class UnderpostRepository {
49
49
  },
50
50
  ) {
51
51
  if (commitType === 'reset') {
52
+ pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
52
53
  shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
53
54
  return;
54
55
  }
package/src/cli/run.js CHANGED
@@ -72,12 +72,19 @@ class UnderpostRun {
72
72
  const baseCommand = options.dev ? 'node bin' : 'underpost';
73
73
  shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --reset`);
74
74
  shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''}`);
75
+ const mongoHosts = ['mongodb-0.mongodb-service'];
75
76
  shellExec(
76
- `${baseCommand} cluster${options.dev ? ' --dev' : ''} --mongodb --mongo-db-host ${'127.0.0.1'} --pull-image`,
77
+ `${baseCommand} cluster${options.dev ? ' --dev' : ''} --mongodb --mongo-db-host ${mongoHosts.join(
78
+ ',',
79
+ )} --pull-image`,
77
80
  );
78
81
  shellExec(`${baseCommand} cluster${options.dev ? ' --dev' : ''} --valkey --pull-image`);
79
82
  shellExec(`${baseCommand} deploy --expose mongo`, { async: true });
80
83
  shellExec(`${baseCommand} deploy --expose valkey`, { async: true });
84
+ {
85
+ const hostListenResult = UnderpostDeploy.API.etcHostFactory(mongoHosts);
86
+ logger.info(hostListenResult.renderHosts);
87
+ }
81
88
  },
82
89
  'ssh-cluster-info': (path, options = UnderpostRun.DEFAULT_OPTION) => {
83
90
  const { underpostRoot } = options;
@@ -121,6 +128,7 @@ class UnderpostRun {
121
128
  }
122
129
  },
123
130
  'ssh-deploy': (path, options = UnderpostRun.DEFAULT_OPTION) => {
131
+ actionInitLog();
124
132
  const baseCommand = options.dev || true ? 'node bin' : 'underpost';
125
133
  shellCd('/home/dd/engine');
126
134
  shellExec(`git reset`);
@@ -306,7 +314,7 @@ class UnderpostRun {
306
314
 
307
315
  UnderpostDeploy.API.switchTraffic(deployId, env, targetTraffic);
308
316
 
309
- shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${currentTraffic}`);
317
+ // shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${currentTraffic}`);
310
318
  },
311
319
  'tf-vae-test': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
312
320
  const { underpostRoot } = options;
@@ -10,7 +10,8 @@ import { Modal } from './Modal.js';
10
10
  import { NotificationManager } from './NotificationManager.js';
11
11
  import { Translate } from './Translate.js';
12
12
  import { Validator } from './Validator.js';
13
- import { append, getProxyPath, htmls, s } from './VanillaJs.js';
13
+ import { append, htmls, s } from './VanillaJs.js';
14
+ import { getProxyPath } from './Router.js';
14
15
 
15
16
  const Account = {
16
17
  UpdateEvent: {},
@@ -2,8 +2,8 @@
2
2
  // https://www.ag-grid.com/javascript-data-grid/themes/
3
3
 
4
4
  import { ThemeEvents, darkTheme } from './Css.js';
5
- import { append, getProxyPath, htmls, s } from './VanillaJs.js';
6
- import * as agGrid from 'ag-grid-community';
5
+ import { append, htmls, s } from './VanillaJs.js';
6
+ import { getProxyPath } from './Router.js';
7
7
 
8
8
  const AgGrid = {
9
9
  grids: {},
@@ -7,9 +7,9 @@ import { Modal } from './Modal.js';
7
7
  import { NotificationManager } from './NotificationManager.js';
8
8
  import { Panel } from './Panel.js';
9
9
  import { Responsive } from './Responsive.js';
10
- import { listenQueryPathInstance, RouterEvents, setQueryPath } from './Router.js';
10
+ import { listenQueryPathInstance, RouterEvents, setQueryPath, getQueryParams } from './Router.js';
11
11
  import { Translate } from './Translate.js';
12
- import { append, getQueryParams, getTimeZone, htmls, s, sa } from './VanillaJs.js';
12
+ import { append, getTimeZone, htmls, s, sa } from './VanillaJs.js';
13
13
 
14
14
  // https://fullcalendar.io/docs/event-object
15
15
 
@@ -363,7 +363,6 @@ const CalendarCore = {
363
363
  const cid = getQueryParams().cid ? getQueryParams().cid : '';
364
364
  if (lastCid === cid) return;
365
365
  lastCid = cid;
366
- if (options.route === 'home') Modal.homeCid = newInstance(cid);
367
366
  if (s(`.main-body-calendar-${options.idModal}`)) {
368
367
  // if (Auth.getToken())
369
368
  // else getSrrData();
@@ -577,8 +577,7 @@ const getCurrentTrace = () => {
577
577
  try {
578
578
  _stack;
579
579
  } catch (error) {
580
- console.error(error);
581
- return error;
580
+ return error.stack;
582
581
  }
583
582
  };
584
583
 
@@ -1,6 +1,6 @@
1
1
  import { marked } from 'marked';
2
2
  import { FileService } from '../../services/file/file.service.js';
3
- import { append, getBlobFromUint8ArrayFile, getQueryParams, getRawContentFile, htmls, s } from './VanillaJs.js';
3
+ import { append, getBlobFromUint8ArrayFile, getRawContentFile, htmls, s } from './VanillaJs.js';
4
4
  import { titleFormatted } from './CommonJs.js';
5
5
  import { Translate } from './Translate.js';
6
6
  import { Modal, renderViewTitle } from './Modal.js';
@@ -8,6 +8,7 @@ import { DocumentService } from '../../services/document/document.service.js';
8
8
  import { CoreService, getApiBaseUrl } from '../../services/core/core.service.js';
9
9
  import { loggerFactory } from './Logger.js';
10
10
  import { imageShimmer, renderChessPattern, renderCssAttr, styleFactory } from './Css.js';
11
+ import { getQueryParams } from './Router.js';
11
12
 
12
13
  const logger = loggerFactory(import.meta);
13
14
 
@@ -3,7 +3,8 @@ import { CssCoreDark, CssCoreLight } from './CssCore.js';
3
3
  import { DropDown } from './DropDown.js';
4
4
  import { Modal } from './Modal.js';
5
5
  import { Translate } from './Translate.js';
6
- import { append, getProxyPath, htmls, s, sa } from './VanillaJs.js';
6
+ import { append, htmls, s, sa } from './VanillaJs.js';
7
+ import { getProxyPath } from './Router.js';
7
8
 
8
9
  let ThemesScope = [];
9
10
 
@@ -1,7 +1,8 @@
1
1
  import { AgGrid } from './AgGrid.js';
2
2
  import { borderChar, boxShadow, scrollBarDarkRender, scrollBarLightRender } from './Css.js';
3
3
  import { LoadingAnimation } from './LoadingAnimation.js';
4
- import { append, getProxyPath, s } from './VanillaJs.js';
4
+ import { append, s } from './VanillaJs.js';
5
+ import { getProxyPath } from './Router.js';
5
6
 
6
7
  const CssCommonCore = async () => {
7
8
  if (!s(`.fa-link`))
@@ -524,6 +525,12 @@ const CssCoreDark = {
524
525
  }
525
526
  .btn-input-extension:hover {
526
527
  }
528
+ .section-mp-border {
529
+ border: 2px solid #313131;
530
+ border-radius: 5px;
531
+ padding: 5px;
532
+ margin: 5px;
533
+ }
527
534
  </style>
528
535
  ${scrollBarDarkRender()} ${borderChar(1, 'black', ['.main-body-btn-container'])}
529
536
  `,
@@ -848,6 +855,12 @@ const CssCoreLight = {
848
855
  }
849
856
  .btn-input-extension:hover {
850
857
  }
858
+ .section-mp-border {
859
+ border: 2px solid #bbb;
860
+ border-radius: 5px;
861
+ padding: 5px;
862
+ margin: 5px;
863
+ }
851
864
  </style>
852
865
  ${scrollBarLightRender()} ${borderChar(1, 'white', ['.main-body-btn-container'])}
853
866
  `,
@@ -1,12 +1,11 @@
1
1
  import { Badge } from './Badge.js';
2
2
  import { BtnIcon } from './BtnIcon.js';
3
- import { rgbToHex } from './CommonJs.js';
4
- import { Css, darkTheme, dynamicCol, renderCssAttr, simpleIconsRender, ThemeEvents, Themes } from './Css.js';
3
+ import { Css, renderCssAttr, simpleIconsRender, ThemeEvents, Themes } from './Css.js';
5
4
  import { DropDown } from './DropDown.js';
6
5
  import { buildBadgeToolTipMenuOption, Modal, renderMenuLabel, renderViewTitle } from './Modal.js';
7
- import { listenQueryPathInstance, setQueryPath } from './Router.js';
6
+ import { listenQueryPathInstance, setQueryPath, closeModalRouteChangeEvent, getProxyPath } from './Router.js';
8
7
  import { Translate } from './Translate.js';
9
- import { getProxyPath, getQueryParams, htmls, s, sa } from './VanillaJs.js';
8
+ import { htmls, s } from './VanillaJs.js';
10
9
  import Sortable from 'sortablejs';
11
10
 
12
11
  // https://mintlify.com/docs/quickstart
@@ -34,6 +33,7 @@ const Docs = {
34
33
  },
35
34
  maximize: true,
36
35
  mode: 'view',
36
+ route: 'docs',
37
37
  slideMenu: 'modal-menu',
38
38
  observer: true,
39
39
  barMode: 'top-bottom-bar',
@@ -51,7 +51,7 @@ const Docs = {
51
51
  };
52
52
  Modal.Data[ModalId].onObserverListener[ModalId]();
53
53
  Modal.Data[ModalId].onCloseListener[ModalId] = () => {
54
- setQueryPath({ path: 'docs', queryPath: '' });
54
+ closeModalRouteChangeEvent({ closedId: ModalId });
55
55
  };
56
56
  },
57
57
  Data: [
@@ -4,8 +4,7 @@ import { FileService } from '../../services/file/file.service.js';
4
4
  import { AgGrid } from './AgGrid.js';
5
5
  import { Auth } from './Auth.js';
6
6
  import { BtnIcon } from './BtnIcon.js';
7
- import { getSubpaths, timer, uniqueArray } from './CommonJs.js';
8
- import { Content } from './Content.js';
7
+ import { getSubpaths, uniqueArray } from './CommonJs.js';
9
8
  import { darkTheme, renderCssAttr } from './Css.js';
10
9
  import { EventsUI } from './EventsUI.js';
11
10
  import { fileFormDataFactory, Input, InputFile } from './Input.js';
@@ -15,7 +14,8 @@ import { NotificationManager } from './NotificationManager.js';
15
14
  import { RouterEvents } from './Router.js';
16
15
  import { Translate } from './Translate.js';
17
16
  import { Validator } from './Validator.js';
18
- import { copyData, downloadFile, getProxyPath, getQueryParams, s, setPath } from './VanillaJs.js';
17
+ import { copyData, downloadFile, s } from './VanillaJs.js';
18
+ import { getProxyPath, getQueryParams, setPath } from './Router.js';
19
19
 
20
20
  const logger = loggerFactory(import.meta);
21
21
 
@@ -9,35 +9,26 @@ const FullScreen = {
9
9
  Responsive.Event['full-screen-settings'] = () => {
10
10
  let fullScreenMode = checkFullScreen();
11
11
  if ((fullScreenSwitch && !fullScreenMode) || (!fullScreenSwitch && fullScreenMode))
12
- if (s('.fullscreen-toggle')) ToggleSwitch.Tokens[`fullscreen-toggle`].click();
12
+ if (s('.fullscreen')) ToggleSwitch.Tokens[`fullscreen`].click();
13
13
  };
14
- setTimeout(
15
- () => (s(`.toggle-form-container-fullscreen`).onclick = () => ToggleSwitch.Tokens[`fullscreen-toggle`].click()),
16
- );
17
- return html`<div class="in section-mp toggle-form-container toggle-form-container-fullscreen hover">
18
- <div class="fl ">
19
- <div class="in fll" style="width: 70%">
20
- <div class="in"><i class="fa-solid fa-expand"></i> ${Translate.Render('fullscreen')}</div>
21
- </div>
22
- <div class="in fll" style="width: 30%">
23
- ${await ToggleSwitch.Render({
24
- id: 'fullscreen-toggle',
25
- containerClass: 'inl',
26
- disabledOnClick: true,
27
- checked: fullScreenSwitch,
28
- on: {
29
- unchecked: () => {
30
- fullScreenSwitch = false;
31
- if (checkFullScreen()) fullScreenOut();
32
- },
33
- checked: () => {
34
- fullScreenSwitch = true;
35
- if (!checkFullScreen()) fullScreenIn();
36
- },
37
- },
38
- })}
39
- </div>
40
- </div>
14
+ return html`<div class="in section-mp">
15
+ ${await ToggleSwitch.Render({
16
+ wrapper: true,
17
+ wrapperLabel: html`<i class="fa-solid fa-expand"></i> ${Translate.Render('fullscreen')}`,
18
+ id: 'fullscreen',
19
+ disabledOnClick: true,
20
+ checked: fullScreenSwitch,
21
+ on: {
22
+ unchecked: () => {
23
+ fullScreenSwitch = false;
24
+ if (checkFullScreen()) fullScreenOut();
25
+ },
26
+ checked: () => {
27
+ fullScreenSwitch = true;
28
+ if (!checkFullScreen()) fullScreenIn();
29
+ },
30
+ },
31
+ })}
41
32
  </div>`;
42
33
  },
43
34
  };
@@ -65,6 +65,7 @@ const Input = {
65
65
  type="${options?.type ? options.type : 'text'}"
66
66
  class="${options.inputClass ? options.inputClass : 'in wfa'} ${id}"
67
67
  ${options?.min !== undefined ? `min="${options.min}"` : ''}
68
+ ${options?.max !== undefined ? `max="${options.max}"` : ''}
68
69
  placeholder${options?.placeholder ? `="${options.placeholder}"` : ''}
69
70
  ${options?.value !== undefined ? `value="${options.value}"` : ''}
70
71
  ${options?.autocomplete ? `autocomplete="${options.autocomplete}"` : ''}
@@ -1,7 +1,7 @@
1
1
  import JoystickController from 'joystick-controller';
2
2
  import { getDirection, getId } from './CommonJs.js';
3
- import { loggerFactory } from './Logger.js';
4
- import { append, getProxyPath, s } from './VanillaJs.js';
3
+ import { append, s } from './VanillaJs.js';
4
+ import { getProxyPath } from './Router.js';
5
5
 
6
6
  const logger = loggerFactory(import.meta);
7
7
 
@@ -1,9 +1,9 @@
1
- import { CoreService } from '../../services/core/core.service.js';
2
1
  import { BtnIcon } from './BtnIcon.js';
3
2
  import { s4 } from './CommonJs.js';
4
3
  import { darkTheme, renderCssAttr, subThemeManager } from './Css.js';
5
4
  import { loggerFactory } from './Logger.js';
6
- import { append, getAllChildNodes, getProxyPath, htmls, s, sa } from './VanillaJs.js';
5
+ import { append, htmls, s } from './VanillaJs.js';
6
+ import { getProxyPath } from './Router.js';
7
7
 
8
8
  const logger = loggerFactory(import.meta);
9
9
 
@@ -1,4 +1,6 @@
1
- const loggerFactory = (meta) => {
1
+ import { getCurrentTrace } from './CommonJs.js';
2
+
3
+ const loggerFactory = (meta, options = { trace: false }) => {
2
4
  meta = meta.url.split('/').pop();
3
5
  const types = ['error', 'warn', 'info', 'debug'];
4
6
  const logger = {
@@ -9,6 +11,7 @@ const loggerFactory = (meta) => {
9
11
  console.info = () => null;
10
12
  console.warn = () => null;
11
13
  }
14
+ if (options.trace === true) args.push(getCurrentTrace().split('Logger.js:23')[1]);
12
15
  return location.hostname === 'localhost'
13
16
  ? console[type](`[${meta}] ${new Date().toISOString()} ${type}:`, ...args)
14
17
  : null;
@@ -1,16 +1,6 @@
1
- import { cap, getId, newInstance } from './CommonJs.js';
1
+ import { getId, newInstance } from './CommonJs.js';
2
2
  import { Draggable } from '@neodrag/vanilla';
3
- import {
4
- append,
5
- s,
6
- prepend,
7
- setPath,
8
- getProxyPath,
9
- htmls,
10
- sa,
11
- getAllChildNodes,
12
- isActiveElement,
13
- } from './VanillaJs.js';
3
+ import { append, s, prepend, htmls, sa, getAllChildNodes, isActiveElement } from './VanillaJs.js';
14
4
  import { BtnIcon } from './BtnIcon.js';
15
5
  import { Responsive } from './Responsive.js';
16
6
  import { loggerFactory } from './Logger.js';
@@ -24,12 +14,18 @@ import {
24
14
  renderStatus,
25
15
  renderCssAttr,
26
16
  } from './Css.js';
27
- import { setDocTitle, closeModalRouteChangeEvent, handleModalViewRoute } from './Router.js';
17
+ import {
18
+ setDocTitle,
19
+ closeModalRouteChangeEvent,
20
+ handleModalViewRoute,
21
+ getProxyPath,
22
+ setPath,
23
+ coreUI,
24
+ } from './Router.js';
28
25
  import { NotificationManager } from './NotificationManager.js';
29
26
  import { EventsUI } from './EventsUI.js';
30
27
  import { Translate } from './Translate.js';
31
28
  import { Input, isTextInputFocused } from './Input.js';
32
- import { Validator } from './Validator.js';
33
29
  import { DropDown } from './DropDown.js';
34
30
  import { Keyboard } from './Keyboard.js';
35
31
  import { Badge } from './Badge.js';
@@ -186,9 +182,7 @@ const Modal = {
186
182
  htmls(
187
183
  `.default-slide-menu-top-bar-fix-title-container`,
188
184
  html`
189
- <div class="inl default-slide-menu-top-bar-fix-title-container-text">
190
- ${options.RouterInstance.BannerAppTemplate}
191
- </div>
185
+ <div class="inl default-slide-menu-top-bar-fix-title-container-text">${options.title}</div>
192
186
  `,
193
187
  );
194
188
  } else
@@ -274,6 +268,7 @@ const Modal = {
274
268
  s(`.btn-menu-${idModal}`).classList.remove('hide');
275
269
  s(`.${idModal}`).style.width = `${this.Data[idModal][options.mode].width}px`;
276
270
  s(`.html-${idModal}`).style.display = 'none';
271
+ // s(`.title-modal-${idModal}`).style.display = 'none';
277
272
  setTimeout(() => {
278
273
  s(`.main-body-btn-ui-menu-close`).classList.add('hide');
279
274
  s(`.main-body-btn-ui-menu-menu`).classList.remove('hide');
@@ -281,9 +276,6 @@ const Modal = {
281
276
  s(`.btn-bar-center-icon-menu`).classList.remove('hide');
282
277
  s(`.btn-bar-center-icon-close`).classList.add('hide');
283
278
  }
284
- });
285
- // s(`.title-modal-${idModal}`).style.display = 'none';
286
- setTimeout(() => {
287
279
  s(`.main-body-btn-container`).style[
288
280
  true || (options.mode && options.mode.match('right')) ? 'right' : 'left'
289
281
  ] = `${0}px`;
@@ -787,8 +779,7 @@ const Modal = {
787
779
  dragDisabled: true,
788
780
  maximize: true,
789
781
  heightBottomBar: 0,
790
- heightTopBar: originHeightTopBar,
791
- barMode: options.barMode,
782
+ heightTopBar: options.heightTopBar,
792
783
  });
793
784
 
794
785
  // Bind hover/focus and click-outside to dismiss
@@ -1535,18 +1526,6 @@ const Modal = {
1535
1526
  s(`.btn-icon-menu-back`).classList.add('hide');
1536
1527
  if (s(`.menu-btn-container-main`)) s(`.menu-btn-container-main`).classList.remove('hide');
1537
1528
  };
1538
- this.onHomeRouterEvent = async () => {
1539
- for (const keyModal of Object.keys(this.Data)) {
1540
- if (
1541
- ![idModal, 'main-body-top', 'main-body'].concat(this.Data[idModal]?.homeModals || []).includes(keyModal)
1542
- )
1543
- if (s(`.btn-close-${keyModal}`)) s(`.btn-close-${keyModal}`).click();
1544
- backMenuButtonEvent();
1545
- }
1546
- if (s(`.btn-close-modal-menu`)) s(`.btn-close-modal-menu`).click();
1547
- setPath(getProxyPath());
1548
- setDocTitle();
1549
- };
1550
1529
  s(`.main-btn-home`).onclick = async () => {
1551
1530
  // await this.onHomeRouterEvent();
1552
1531
  s(`.action-btn-home`).click();
@@ -1767,13 +1746,8 @@ const Modal = {
1767
1746
  if (!s(`.${idModal}`)) return;
1768
1747
  this.removeModal(idModal);
1769
1748
  // Handle modal route change
1770
- if (options.route) {
1771
- closeModalRouteChangeEvent({
1772
- route: options.route,
1773
- RouterInstance: options.RouterInstance,
1774
- homeCid: Modal.homeCid,
1775
- });
1776
- }
1749
+ closeModalRouteChangeEvent({ closedId: idModal });
1750
+ // history.back();
1777
1751
  }, 300);
1778
1752
  };
1779
1753
  s(`.btn-close-${idModal}`).onclick = btnCloseEvent;
@@ -1967,7 +1941,45 @@ const Modal = {
1967
1941
  ...this.Data[idModal],
1968
1942
  };
1969
1943
  },
1970
- onHomeRouterEvent: () => {},
1944
+ onHomeRouterEvent: async () => {
1945
+ // 1. Get list of modals to close.
1946
+ const modalsToClose = Object.keys(Modal.Data).filter((idModal) => {
1947
+ const modal = Modal.Data[idModal];
1948
+ if (!modal) return false;
1949
+ // Don't close the core UI elements
1950
+
1951
+ if (coreUI.find((id) => idModal.startsWith(id))) {
1952
+ return false;
1953
+ }
1954
+ // Don't close modals that are part of the "home" screen itself
1955
+ const homeModals = Modal.Data['modal-menu']?.homeModals || [];
1956
+ if (homeModals.includes(idModal)) {
1957
+ return false;
1958
+ }
1959
+ return true;
1960
+ });
1961
+
1962
+ // 2. Navigate to home first, creating a new history entry.
1963
+ setPath(`${getProxyPath()}${location.search ?? ''}${location.hash ?? ''}`);
1964
+ setDocTitle();
1965
+
1966
+ // 3. Close the modals without them affecting the URL.
1967
+ for (const id of modalsToClose) {
1968
+ Modal.removeModal(id);
1969
+ }
1970
+
1971
+ // 4. Finally, handle UI cleanup for the slide-menu.
1972
+ if (s(`.menu-btn-container-children`)) htmls(`.menu-btn-container-children`, '');
1973
+ if (s(`.nav-title-display-modal-menu`)) htmls(`.nav-title-display-modal-menu`, '');
1974
+ if (s(`.nav-path-display-modal-menu`)) htmls(`.nav-path-display-modal-menu`, '');
1975
+ if (s(`.btn-icon-menu-back`)) s(`.btn-icon-menu-back`).classList.add('hide');
1976
+ if (s(`.menu-btn-container-main`)) s(`.menu-btn-container-main`).classList.remove('hide');
1977
+
1978
+ // And close the slide menu if it's open
1979
+ if (s(`.btn-close-modal-menu`) && !s(`.btn-close-modal-menu`).classList.contains('hide')) {
1980
+ s(`.btn-close-modal-menu`).click();
1981
+ }
1982
+ },
1971
1983
  currentTopModalId: '',
1972
1984
  zIndexSync: function ({ idModal }) {
1973
1985
  setTimeout(() => {
@@ -1996,11 +2008,6 @@ const Modal = {
1996
2008
  setTopModalCallback: function (idModal) {
1997
2009
  s(`.${idModal}`).style.zIndex = '4';
1998
2010
  this.currentTopModalId = `${idModal}`;
1999
- if (
2000
- this.Data[idModal].query &&
2001
- `${location.pathname}${window.location.search}` !== `${location.pathname}${this.Data[idModal].query}`
2002
- )
2003
- setPath(`${location.pathname}${this.Data[idModal].query}`);
2004
2011
  },
2005
2012
  mobileModal: () => window.innerWidth < 600 || window.innerHeight < 600,
2006
2013
  writeHTML: ({ idModal, html }) => htmls(`.html-${idModal}`, html),