underpost 2.7.83 → 2.7.92

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 (85) hide show
  1. package/.github/workflows/ghpkg.yml +41 -1
  2. package/.github/workflows/pwa-microservices-template.page.yml +54 -0
  3. package/.vscode/settings.json +7 -0
  4. package/CHANGELOG.md +64 -16
  5. package/bin/cron.js +47 -0
  6. package/bin/db.js +60 -7
  7. package/bin/deploy.js +358 -26
  8. package/bin/file.js +18 -1
  9. package/bin/hwt.js +59 -0
  10. package/bin/index.js +1 -1
  11. package/bin/util.js +31 -1
  12. package/conf.js +46 -8
  13. package/docker-compose.yml +1 -1
  14. package/package.json +133 -133
  15. package/src/api/core/core.router.js +9 -9
  16. package/src/api/core/core.service.js +12 -4
  17. package/src/api/default/default.service.js +4 -4
  18. package/src/api/file/file.service.js +3 -3
  19. package/src/api/user/user.service.js +10 -8
  20. package/src/client/components/core/404.js +20 -0
  21. package/src/client/components/core/500.js +20 -0
  22. package/src/client/{ssr/common → components/core}/Alert.js +13 -11
  23. package/src/client/components/core/CommonJs.js +3 -0
  24. package/src/client/components/core/CssCore.js +30 -3
  25. package/src/client/components/core/Docs.js +110 -10
  26. package/src/client/components/core/LoadingAnimation.js +4 -2
  27. package/src/client/components/core/Modal.js +223 -22
  28. package/src/client/components/core/Panel.js +1 -1
  29. package/src/client/components/core/PanelForm.js +2 -1
  30. package/src/client/components/core/Responsive.js +34 -5
  31. package/src/client/components/core/RichText.js +4 -2
  32. package/src/client/components/core/Translate.js +21 -5
  33. package/src/client/components/core/VanillaJs.js +2 -1
  34. package/src/client/components/core/WebComponent.js +44 -0
  35. package/src/client/components/core/Worker.js +15 -18
  36. package/src/client/components/default/MenuDefault.js +68 -0
  37. package/src/client/components/default/RoutesDefault.js +2 -0
  38. package/src/client/public/default/plantuml/client-conf.svg +1 -1
  39. package/src/client/public/default/plantuml/client-schema.svg +1 -1
  40. package/src/client/public/default/plantuml/cron-conf.svg +1 -1
  41. package/src/client/public/default/plantuml/cron-schema.svg +1 -1
  42. package/src/client/public/default/plantuml/server-conf.svg +1 -1
  43. package/src/client/public/default/plantuml/server-schema.svg +1 -1
  44. package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
  45. package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
  46. package/src/client/public/default/site.webmanifest +69 -0
  47. package/src/client/ssr/Render.js +1 -6
  48. package/src/client/ssr/{components/body → body}/CacheControl.js +1 -1
  49. package/src/client/ssr/head/Production.js +1 -0
  50. package/src/client/ssr/head/Pwa.js +146 -0
  51. package/src/client/ssr/head/Seo.js +14 -0
  52. package/src/client/ssr/mailer/DefaultRecoverEmail.js +21 -0
  53. package/src/client/ssr/mailer/DefaultVerifyEmail.js +17 -0
  54. package/src/client/ssr/offline/NoNetworkConnection.js +65 -0
  55. package/src/client/ssr/pages/Test.js +196 -0
  56. package/src/client/ssr/pages/maintenance.js +14 -0
  57. package/src/client/ssr/pages/offline.js +21 -0
  58. package/src/client/sw/default.sw.js +44 -165
  59. package/src/db/DataBaseProvider.js +12 -1
  60. package/src/db/mongo/MongooseDB.js +0 -1
  61. package/src/mailer/EmailRender.js +2 -4
  62. package/src/mailer/MailerProvider.js +4 -1
  63. package/src/runtime/lampp/Lampp.js +9 -9
  64. package/src/server/backup.js +82 -70
  65. package/src/server/client-build.js +133 -155
  66. package/src/server/client-formatted.js +2 -4
  67. package/src/server/conf.js +114 -23
  68. package/src/server/crypto.js +91 -0
  69. package/src/server/dns.js +48 -16
  70. package/src/server/network.js +94 -7
  71. package/src/server/proxy.js +26 -28
  72. package/src/server/runtime.js +42 -12
  73. package/src/server/ssl.js +2 -2
  74. package/src/client/ssr/common/SsrCore.js +0 -91
  75. package/src/client/ssr/common/Translate.js +0 -26
  76. package/src/client/ssr/common/Worker.js +0 -28
  77. package/src/client/ssr/components/head/PwaDefault.js +0 -60
  78. package/src/client/ssr/offline/default.index.js +0 -31
  79. package/src/cron.js +0 -30
  80. package/src/server/cron.js +0 -35
  81. /package/src/client/ssr/{components/body → body}/DefaultSplashScreen.js +0 -0
  82. /package/src/client/ssr/{components/email → email}/DefaultRecoverEmail.js +0 -0
  83. /package/src/client/ssr/{components/email → email}/DefaultVerifyEmail.js +0 -0
  84. /package/src/client/ssr/{components/head → head}/Css.js +0 -0
  85. /package/src/client/ssr/{components/head → head}/DefaultScripts.js +0 -0
@@ -86,6 +86,7 @@ const Modal = {
86
86
  onDragEndListener: {},
87
87
  onObserverListener: {},
88
88
  onClickListener: {},
89
+ onExpandUiListener: {},
89
90
  query: options.query ? `${window.location.search}` : undefined,
90
91
  };
91
92
  if (options && 'mode' in options) {
@@ -191,11 +192,20 @@ const Modal = {
191
192
  s(`.${idModal}`).style.width = `${this.Data[idModal][options.mode].width}px`;
192
193
  s(`.html-${idModal}`).style.display = 'block';
193
194
  // s(`.title-modal-${idModal}`).style.display = 'block';
194
- if (s(`.main-body-top`)) {
195
- s(`.btn-bar-center-icon-close`).classList.remove('hide');
196
- s(`.btn-bar-center-icon-menu`).classList.add('hide');
197
- }
195
+ setTimeout(() => {
196
+ s(`.main-body-btn-ui-menu-menu`).classList.add('hide');
197
+ s(`.main-body-btn-ui-menu-close`).classList.remove('hide');
198
+ if (s(`.btn-bar-center-icon-menu`)) {
199
+ s(`.btn-bar-center-icon-close`).classList.remove('hide');
200
+ s(`.btn-bar-center-icon-menu`).classList.add('hide');
201
+ }
202
+ });
198
203
 
204
+ setTimeout(() => {
205
+ s(`.main-body-btn-container`).style[
206
+ true || (options.mode && options.mode.match('right')) ? 'right' : 'left'
207
+ ] = options.mode && options.mode.match('right') ? `${slideMenuWidth}px` : '0px';
208
+ });
199
209
  Responsive.Event[`slide-menu-${idModal}`]();
200
210
  };
201
211
  barConfig.buttons.close.onClick = () => {
@@ -204,15 +214,106 @@ const Modal = {
204
214
  s(`.btn-menu-${idModal}`).classList.remove('hide');
205
215
  s(`.${idModal}`).style.width = `${this.Data[idModal][options.mode].width}px`;
206
216
  s(`.html-${idModal}`).style.display = 'none';
207
- if (s(`.main-body-top`)) {
208
- s(`.btn-bar-center-icon-menu`).classList.remove('hide');
209
- s(`.btn-bar-center-icon-close`).classList.add('hide');
210
- }
217
+ setTimeout(() => {
218
+ s(`.main-body-btn-ui-menu-close`).classList.add('hide');
219
+ s(`.main-body-btn-ui-menu-menu`).classList.remove('hide');
220
+ if (s(`.btn-bar-center-icon-menu`)) {
221
+ s(`.btn-bar-center-icon-menu`).classList.remove('hide');
222
+ s(`.btn-bar-center-icon-close`).classList.add('hide');
223
+ }
224
+ });
211
225
  // s(`.title-modal-${idModal}`).style.display = 'none';
226
+ setTimeout(() => {
227
+ s(`.main-body-btn-container`).style[
228
+ true || (options.mode && options.mode.match('right')) ? 'right' : 'left'
229
+ ] = `${0}px`;
230
+ });
212
231
  Responsive.Event[`slide-menu-${idModal}`]();
213
232
  };
214
233
  transition += `, width 0.3s`;
215
234
 
235
+ setTimeout(() => {
236
+ append(
237
+ 'body',
238
+ html`
239
+ <div
240
+ class="abs main-body-btn-container"
241
+ style="top: ${options.heightTopBar + 50}px; z-index: 9; ${true ||
242
+ (options.mode && options.mode.match('right'))
243
+ ? 'right'
244
+ : 'left'}: 50px; width: 50px; height: 100px; transition: .3s"
245
+ >
246
+ <div
247
+ class="abs main-body-btn main-body-btn-menu"
248
+ style="top: 50px; ${true || (options.mode && options.mode.match('right'))
249
+ ? 'right'
250
+ : 'left'}: 0px"
251
+ >
252
+ <div class="abs center">
253
+ <i class="fa-solid fa-xmark hide main-body-btn-ui-menu-close"></i>
254
+ <i class="fa-solid fa-bars main-body-btn-ui-menu-menu"></i>
255
+ </div>
256
+ </div>
257
+ <div
258
+ class="abs main-body-btn main-body-btn-ui"
259
+ style="top: 0px; ${true || (options.mode && options.mode.match('right')) ? 'right' : 'left'}: 0px"
260
+ >
261
+ <div class="abs center">
262
+ <i class="fas fa-caret-down main-body-btn-ui-open hide"></i>
263
+ <i class="fas fa-caret-up main-body-btn-ui-close"></i>
264
+ </div>
265
+ </div>
266
+ </div>
267
+ `,
268
+ );
269
+
270
+ s(`.main-body-btn-menu`).onclick = () => {
271
+ Modal.actionBtnCenter();
272
+ };
273
+
274
+ let _heightTopBar, _heightBottomBar, _topMenu;
275
+ s(`.main-body-btn-ui`).onclick = () => {
276
+ if (s(`.main-body-btn-ui-open`).classList.contains('hide')) {
277
+ s(`.main-body-btn-ui-open`).classList.remove('hide');
278
+ s(`.main-body-btn-ui-close`).classList.add('hide');
279
+ _heightTopBar = newInstance(options.heightTopBar);
280
+ _heightBottomBar = newInstance(options.heightBottomBar);
281
+ _topMenu = newInstance(s(`.modal-menu`).style.top);
282
+ options.heightTopBar = 0;
283
+ options.heightBottomBar = 0;
284
+ s(`.slide-menu-top-bar`).classList.add('hide');
285
+ s(`.bottom-bar`).classList.add('hide');
286
+ s(`.modal-menu`).style.top = '0px';
287
+ s(`.main-body-btn-container`).style.top = '50px';
288
+ s(`.main-body`).style.top = '0px';
289
+ } else {
290
+ s(`.main-body-btn-ui-close`).classList.remove('hide');
291
+ s(`.main-body-btn-ui-open`).classList.add('hide');
292
+ options.heightTopBar = _heightTopBar;
293
+ options.heightBottomBar = _heightBottomBar;
294
+ s(`.modal-menu`).style.top = _topMenu;
295
+ s(`.main-body-btn-container`).style.top = `${options.heightTopBar + 50}px`;
296
+ s(`.slide-menu-top-bar`).classList.remove('hide');
297
+ s(`.bottom-bar`).classList.remove('hide');
298
+ s(`.main-body`).style.top = `${options.heightTopBar}px`;
299
+ }
300
+ Responsive.Event[`slide-menu-modal-menu`]();
301
+ Object.keys(this.Data).map((_idModal) => {
302
+ if (this.Data[_idModal].slideMenu) {
303
+ if (s(`.btn-maximize-${_idModal}`)) s(`.btn-maximize-${_idModal}`).click();
304
+ }
305
+ });
306
+ Responsive.Event[`view-${'main-body'}`]();
307
+ if (Responsive.Event[`view-${'bottom-bar'}`]) Responsive.Event[`view-${'bottom-bar'}`]();
308
+ if (Responsive.Event[`view-${'main-body-top'}`]) Responsive.Event[`view-${'main-body-top'}`]();
309
+ for (const keyEvent of Object.keys(this.Data[idModal].onExpandUiListener)) {
310
+ this.Data[idModal].onExpandUiListener[keyEvent](
311
+ !s(`.main-body-btn-ui-open`).classList.contains('hide'),
312
+ );
313
+ }
314
+ };
315
+ });
316
+
216
317
  const inputSearchBoxId = `top-bar-search-box`;
217
318
  append(
218
319
  'body',
@@ -726,6 +827,7 @@ const Modal = {
726
827
  heightTopBar: originHeightTopBar,
727
828
  heightBottomBar: originHeightBottomBar,
728
829
  barMode: options.barMode,
830
+ observer: true,
729
831
  });
730
832
  const maxWidthInputSearchBox = 450;
731
833
  const paddingInputSearchBox = 5;
@@ -970,11 +1072,24 @@ const Modal = {
970
1072
 
971
1073
  Responsive.Event[`view-${id}`] = () => {
972
1074
  if (!this.Data[id] || !s(`.${id}`)) return delete Responsive.Event[`view-${id}`];
973
- s(`.${id}`).style.height = `${
974
- window.innerHeight -
975
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
976
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
977
- }px`;
1075
+ s(`.${id}`).style.height =
1076
+ s(`.main-body-btn-ui-close`).classList.contains('hide') &&
1077
+ s(`.btn-restore-${id}`).style.display !== 'none'
1078
+ ? `${window.innerHeight}px`
1079
+ : `${
1080
+ window.innerHeight -
1081
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1082
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1083
+ }px`;
1084
+
1085
+ if (
1086
+ s(`.main-body-btn-ui-close`).classList.contains('hide') &&
1087
+ s(`.btn-restore-${id}`).style.display !== 'none'
1088
+ ) {
1089
+ s(`.${id}`).style.top = '0px';
1090
+ } else {
1091
+ s(`.${id}`).style.top = `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1092
+ }
978
1093
  };
979
1094
  Responsive.Event[`view-${id}`]();
980
1095
 
@@ -1049,6 +1164,28 @@ const Modal = {
1049
1164
  top: 5%;
1050
1165
  left: 5%;
1051
1166
  }
1167
+ .sub-menu-title-container-${idModal},
1168
+ .nav-path-container-${idModal} {
1169
+ top: 0px;
1170
+ left: 0px;
1171
+ width: 200px;
1172
+ height: 50px;
1173
+ overflow: hidden;
1174
+ font-size: 20px;
1175
+ cursor: default;
1176
+ }
1177
+ .nav-path-display-${idModal} {
1178
+ font-size: 11px;
1179
+ width: 100%;
1180
+ top: 35px;
1181
+ left: 37px;
1182
+ }
1183
+ .nav-title-display-${idModal} {
1184
+ font-size: 19px;
1185
+ width: 100%;
1186
+ top: 13px;
1187
+ left: 13px;
1188
+ }
1052
1189
  </style>
1053
1190
  ${renderStyleTag(`style-${idModal}`, `.${idModal}`, options)}
1054
1191
  <div class="fix ${options && options.class ? options.class : ''} modal box-shadow ${idModal}">
@@ -1117,7 +1254,10 @@ const Modal = {
1117
1254
 
1118
1255
  <div class="in html-${idModal}">
1119
1256
  ${options.mode && options.mode.match('slide-menu')
1120
- ? html`<div class="in" style="${renderCssAttr({ style: { height: '50px' } })}">
1257
+ ? html`<div
1258
+ class="stq modal"
1259
+ style="${renderCssAttr({ style: { height: '50px', 'z-index': 1, top: '0px' } })}"
1260
+ >
1121
1261
  ${await BtnIcon.Render({
1122
1262
  style: renderCssAttr({ style: { height: '100%', color: '#5f5f5f' } }),
1123
1263
  class: `in flr main-btn-menu action-bar-box btn-icon-menu-mode`,
@@ -1134,6 +1274,19 @@ const Modal = {
1134
1274
  ></i>
1135
1275
  </div>`,
1136
1276
  })}
1277
+ ${await BtnIcon.Render({
1278
+ style: renderCssAttr({ style: { height: '100%', color: '#5f5f5f' } }),
1279
+ class: `in flr main-btn-menu action-bar-box btn-icon-menu-back hide`,
1280
+ label: html`<div class="abs center"><i class="fas fa-undo-alt"></i></div>`,
1281
+ })}
1282
+ <div class="abs sub-menu-title-container-${idModal} ac">
1283
+ <div class="abs nav-title-display-${idModal}">
1284
+ <!-- <i class="fas fa-home"></i> ${Translate.Render('home')} -->
1285
+ </div>
1286
+ </div>
1287
+ <div class="abs nav-path-container-${idModal} ahc bold">
1288
+ <div class="abs nav-path-display-${idModal}"><!-- ${location.pathname} --></div>
1289
+ </div>
1137
1290
  </div>`
1138
1291
  : ''}
1139
1292
  ${options && options.html ? (typeof options.html === 'function' ? await options.html() : options.html) : ''}
@@ -1167,6 +1320,15 @@ const Modal = {
1167
1320
  case 'slide-menu':
1168
1321
  case 'slide-menu-right':
1169
1322
  case 'slide-menu-left':
1323
+ const backMenuButtonEvent = async () => {
1324
+ if (location.pathname !== getProxyPath()) setPath(getProxyPath());
1325
+ if (s(`.menu-btn-container-children`)) htmls(`.menu-btn-container-children`, '');
1326
+ // htmls(`.nav-title-display-${'modal-menu'}`, html`<i class="fas fa-home"></i> ${Translate.Render('home')}`);
1327
+ htmls(`.nav-title-display-${'modal-menu'}`, html``);
1328
+ htmls(`.nav-path-display-${idModal}`, '');
1329
+ s(`.btn-icon-menu-back`).classList.add('hide');
1330
+ if (s(`.menu-btn-container-main`)) s(`.menu-btn-container-main`).classList.remove('hide');
1331
+ };
1170
1332
  s(`.main-btn-home`).onclick = () => {
1171
1333
  for (const keyModal of Object.keys(this.Data)) {
1172
1334
  if (
@@ -1175,9 +1337,11 @@ const Modal = {
1175
1337
  .includes(keyModal)
1176
1338
  )
1177
1339
  s(`.btn-close-${keyModal}`).click();
1340
+ backMenuButtonEvent();
1178
1341
  }
1179
1342
  s(`.btn-close-modal-menu`).click();
1180
1343
  };
1344
+ EventsUI.onClick(`.btn-icon-menu-back`, backMenuButtonEvent);
1181
1345
  EventsUI.onClick(`.btn-icon-menu-mode`, () => {
1182
1346
  if (s(`.btn-icon-menu-mode-right`).classList.contains('hide')) {
1183
1347
  s(`.btn-icon-menu-mode-right`).classList.remove('hide');
@@ -1188,6 +1352,12 @@ const Modal = {
1188
1352
  }
1189
1353
  if (slideMenuWidth === originSlideMenuWidth) {
1190
1354
  slideMenuWidth = collapseSlideMenuWidth;
1355
+ setTimeout(() => {
1356
+ s(`.main-body-btn-container`).style[
1357
+ true || (options.mode && options.mode.match('right')) ? 'right' : 'left'
1358
+ ] = options.mode && options.mode.match('right') ? `${slideMenuWidth}px` : '0px';
1359
+ }, 1);
1360
+
1191
1361
  if (!s(`.btn-bar-center-icon-close`).classList.contains('hide')) {
1192
1362
  sa(`.handle-btn-container`).forEach((el) => el.classList.add('hide'));
1193
1363
  sa(`.menu-label-text`).forEach((el) => el.classList.add('hide'));
@@ -1195,18 +1365,32 @@ const Modal = {
1195
1365
  sa(`.tooltip-menu`).forEach((el) => el.classList.remove('hide'));
1196
1366
  s(`.${idModal}`).style.overflow = 'visible';
1197
1367
  }
1368
+ if (s(`.menu-btn-container-main`) && s(`.menu-btn-container-main`).classList.contains('hide'))
1369
+ s(`.btn-icon-menu-back`).classList.add('hide');
1198
1370
  }
1199
1371
  if (options.onCollapseMenu) options.onCollapseMenu();
1372
+ s(`.sub-menu-title-container-${'modal-menu'}`).classList.add('hide');
1373
+ s(`.nav-path-container-${'modal-menu'}`).classList.add('hide');
1200
1374
  } else {
1201
1375
  slideMenuWidth = originSlideMenuWidth;
1376
+ setTimeout(() => {
1377
+ s(`.main-body-btn-container`).style[
1378
+ true || (options.mode && options.mode.match('right')) ? 'right' : 'left'
1379
+ ] = options.mode && options.mode.match('right') ? `${slideMenuWidth}px` : '0px';
1380
+ }, 1);
1381
+
1202
1382
  sa(`.handle-btn-container`).forEach((el) => el.classList.remove('hide'));
1203
1383
  sa(`.menu-label-text`).forEach((el) => el.classList.remove('hide'));
1204
1384
  if (!Modal.mobileModal()) {
1205
1385
  sa(`.tooltip-menu`).forEach((el) => el.classList.add('hide'));
1206
1386
  s(`.${idModal}`).style.overflow = null;
1207
1387
  }
1388
+ if (s(`.menu-btn-container-main`) && s(`.menu-btn-container-main`).classList.contains('hide'))
1389
+ s(`.btn-icon-menu-back`).classList.remove('hide');
1208
1390
 
1209
1391
  if (options.onExtendMenu) options.onExtendMenu();
1392
+ s(`.sub-menu-title-container-${'modal-menu'}`).classList.remove('hide');
1393
+ s(`.nav-path-container-${'modal-menu'}`).classList.remove('hide');
1210
1394
  }
1211
1395
  // btn-bar-center-icon-menu
1212
1396
  this.actionBtnCenter();
@@ -1345,13 +1529,26 @@ const Modal = {
1345
1529
  callBack,
1346
1530
  id: options.slideMenu,
1347
1531
  };
1348
- s(`.${idModal}`).style.height = `${
1349
- window.innerHeight -
1350
- (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1351
- (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1352
- }px`;
1353
- s(`.${idModal}`).style.top = `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1532
+ Responsive.Event['h-ui-hide-' + idModal] = () => {
1533
+ setTimeout(() => {
1534
+ if (!s(`.${idModal}`) || !s(`.main-body-btn-ui-close`)) return;
1535
+ if (s(`.btn-restore-${idModal}`).style.display !== 'none') {
1536
+ s(`.${idModal}`).style.height = s(`.main-body-btn-ui-close`).classList.contains('hide')
1537
+ ? `${window.innerHeight}px`
1538
+ : `${
1539
+ window.innerHeight -
1540
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1541
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1542
+ }px`;
1543
+ s(`.${idModal}`).style.top = s(`.main-body-btn-ui-close`).classList.contains('hide')
1544
+ ? `0px`
1545
+ : `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1546
+ }
1547
+ });
1548
+ };
1549
+ Responsive.Event['h-ui-hide-' + idModal]();
1354
1550
  } else {
1551
+ delete Responsive.Event['h-ui-hide-' + idModal];
1355
1552
  s(`.${idModal}`).style.width = '100%';
1356
1553
  s(`.${idModal}`).style.height = '100%';
1357
1554
  s(`.${idModal}`).style.top = `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
@@ -1547,8 +1744,12 @@ const Modal = {
1547
1744
  headerTitleHeight: 40,
1548
1745
  actionBtnCenter: function () {
1549
1746
  // if (!s(`.btn-close-modal-menu`).classList.contains('hide')) return s(`.main-btn-home`).click();
1550
- if (!s(`.btn-close-modal-menu`).classList.contains('hide')) return s(`.btn-close-modal-menu`).click();
1551
- if (!s(`.btn-menu-modal-menu`).classList.contains('hide')) return s(`.btn-menu-modal-menu`).click();
1747
+ if (!s(`.btn-close-modal-menu`).classList.contains('hide')) {
1748
+ return s(`.btn-close-modal-menu`).click();
1749
+ }
1750
+ if (!s(`.btn-menu-modal-menu`).classList.contains('hide')) {
1751
+ return s(`.btn-menu-modal-menu`).click();
1752
+ }
1552
1753
  },
1553
1754
  cleanUI: function () {
1554
1755
  s(`.top-bar`).classList.add('hide');
@@ -507,7 +507,7 @@ const Panel = {
507
507
  color: black;
508
508
  padding: 10px;
509
509
  cursor: pointer;
510
- max-height: 400px;
510
+ min-height: 400px;
511
511
  overflow: hidden;
512
512
  }
513
513
  .${idPanel}:hover {
@@ -454,7 +454,8 @@ const PanelForm = {
454
454
  },
455
455
  });
456
456
 
457
- if (options.route === 'home') setTimeout(this.Data[idPanel].updatePanel);
457
+ // if (options.route === 'home') setTimeout(this.Data[idPanel].updatePanel);
458
+ if (!Auth.getToken()) setTimeout(this.Data[idPanel].updatePanel);
458
459
 
459
460
  if (options.parentIdModal) {
460
461
  htmls(`.html-${options.parentIdModal}`, await renderSrrPanelData());
@@ -1,6 +1,9 @@
1
1
  import { newInstance } from './CommonJs.js';
2
+ import { loggerFactory } from './Logger.js';
2
3
  import { getResponsiveData } from './VanillaJs.js';
3
4
 
5
+ const logger = loggerFactory(import.meta);
6
+
4
7
  const Responsive = {
5
8
  Data: {},
6
9
  Event: {},
@@ -18,9 +21,9 @@ const Responsive = {
18
21
  ResponsiveDataAmplitude.height = ResponsiveDataAmplitude.height * dimAmplitude;
19
22
  return ResponsiveDataAmplitude;
20
23
  },
21
- resizeCallback: function () {
24
+ resizeCallback: function (force) {
22
25
  const Data = getResponsiveData();
23
- if (Data.minValue !== Responsive.Data.minValue || Data.maxValue !== Responsive.Data.maxValue) {
26
+ if (force === true || Data.minValue !== Responsive.Data.minValue || Data.maxValue !== Responsive.Data.maxValue) {
24
27
  Responsive.Data = Data;
25
28
  Responsive.triggerEvents();
26
29
  }
@@ -28,13 +31,13 @@ const Responsive = {
28
31
  resize: 0,
29
32
  Init: async function () {
30
33
  Responsive.resizeCallback();
31
- window.onresize = () => {
34
+ window.onresize = (e, force) => {
32
35
  Responsive.resize++;
33
36
  const resize = Responsive.resize;
34
- Responsive.resizeCallback();
37
+ Responsive.resizeCallback(force);
35
38
  setTimeout(() => {
36
39
  if (resize === Responsive.resize) {
37
- Responsive.resizeCallback();
40
+ Responsive.resizeCallback(force);
38
41
  Responsive.resize = 0;
39
42
  for (const event of Object.keys(Responsive.DelayEvent)) Responsive.DelayEvent[event]();
40
43
  }
@@ -43,11 +46,37 @@ const Responsive = {
43
46
  // alternative option
44
47
  // this.Observer = new ResizeObserver(this.resizeCallback);
45
48
  // this.Observer.observe(document.documentElement);
49
+ screen.orientation.addEventListener('change', (event) => {
50
+ const type = event.target.type; // landscape-primary | portrait-primary
51
+ const angle = event.target.angle; // 90 degrees.
52
+ logger.info(`ScreenOrientation change: ${type}, ${angle} degrees.`);
53
+ setTimeout(() => window.onresize({}, true));
54
+ Responsive.triggerEventsOrientation();
55
+ });
56
+ Responsive.matchMediaOrientationInstance = matchMedia('screen and (orientation:portrait)');
57
+
58
+ Responsive.matchMediaOrientationInstance.onchange = (e) => {
59
+ console.log('orientation change', Responsive.matchMediaOrientationInstance.matches ? 'portrait' : 'landscape');
60
+ // though beware square will be marked as landscape here,
61
+ // if you want to handle this special case
62
+ // create an other mediaquery (orientation:landscape)
63
+ setTimeout(() => window.onresize({}, true));
64
+ Responsive.triggerEventsOrientation();
65
+ };
66
+ },
67
+ triggerEventsOrientation: function () {
68
+ for (const event of Object.keys(this.orientationEvent)) this.orientationEvent[event]();
69
+ setTimeout(() => {
70
+ window.onresize();
71
+ for (const event of Object.keys(this.orientationDelayEvent)) this.orientationDelayEvent[event]();
72
+ }, 1500);
46
73
  },
47
74
  triggerEvents: function (keyEvent) {
48
75
  if (keyEvent) return this.Event[keyEvent]();
49
76
  return Object.keys(this.Event).map((key) => this.Event[key]());
50
77
  },
78
+ orientationEvent: {},
79
+ orientationDelayEvent: {},
51
80
  };
52
81
 
53
82
  export { Responsive };
@@ -20,14 +20,16 @@ const RichText = {
20
20
  s(`.${options.parentIdModal}`).style.top = '0px';
21
21
  s(`.${options.parentIdModal}`).style.height = `${window.innerHeight}px`;
22
22
  }
23
- Modal.cleanUI();
23
+ // Modal.cleanUI();
24
+ if (s(`.slide-menu-top-bar`)) s(`.slide-menu-top-bar`).classList.add('hide');
24
25
  } else {
25
26
  if (options.parentIdModal) {
26
27
  s(`.btn-bar-modal-container-${options.parentIdModal}`).classList.remove('hide');
27
28
  s(`.${options.parentIdModal}`).style.top = top;
28
29
  s(`.${options.parentIdModal}`).style.height = height;
29
30
  }
30
- Modal.restoreUI();
31
+ if (s(`.slide-menu-top-bar`)) s(`.slide-menu-top-bar`).classList.add('remove');
32
+ // Modal.restoreUI();
31
33
  }
32
34
  },
33
35
  });
@@ -66,11 +66,7 @@ const Translate = {
66
66
 
67
67
  const TranslateCore = {
68
68
  Init: async function () {
69
- s('html').lang = localStorage.getItem('lang')
70
- ? localStorage.getItem('lang')
71
- : getLang() && getLang().match('es')
72
- ? 'es'
73
- : 'en';
69
+ s('html').lang = getLang();
74
70
  Translate.Data = {
75
71
  ...Translate.Data,
76
72
  isEmpty: {
@@ -252,6 +248,26 @@ const TranslateCore = {
252
248
  en: 'Comments',
253
249
  es: 'Comentarios',
254
250
  },
251
+ ['server-maintenance']: {
252
+ en: "The server is under maintenance <br> we'll be back soon.",
253
+ es: 'El servidor está en mantenimiento <br> volveremos pronto.',
254
+ },
255
+ ['no-internet-connection']: {
256
+ en: 'No internet connection <br> verify your network',
257
+ es: 'Sin conexión a internet <br> verifica tu red',
258
+ },
259
+ ['page-not-found']: {
260
+ en: 'Page not found',
261
+ es: 'Página no encontrada',
262
+ },
263
+ ['page-broken']: {
264
+ es: 'Algo salio mal',
265
+ en: 'Something went wrong',
266
+ },
267
+ ['back']: {
268
+ en: 'Back to <br> homepage',
269
+ es: 'Volver a <br> la pagina principal',
270
+ },
255
271
  },
256
272
  };
257
273
  Translate.Data['warning-upload-no-selects-file'] = {
@@ -428,7 +428,8 @@ const isDevInstance = () => location.origin.match('localhost') && location.port;
428
428
 
429
429
  const getDataFromInputFile = async (file) => Array.from(new Uint8Array(await file.arrayBuffer()));
430
430
 
431
- const getLang = () => navigator.language || navigator.userLanguage;
431
+ const getLang = () =>
432
+ (localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
432
433
 
433
434
  export {
434
435
  s,
@@ -0,0 +1,44 @@
1
+ // https://javascript.info/
2
+ // https://javascript.info/web-components
3
+
4
+ class MyElement extends HTMLElement {
5
+ constructor() {
6
+ super();
7
+ // element created
8
+ }
9
+
10
+ connectedCallback() {
11
+ // browser calls this method when the element is added to the document
12
+ // (can be called many times if an element is repeatedly added/removed)
13
+ }
14
+
15
+ disconnectedCallback() {
16
+ // browser calls this method when the element is removed from the document
17
+ // (can be called many times if an element is repeatedly added/removed)
18
+ }
19
+
20
+ static get observedAttributes() {
21
+ return [
22
+ /* array of attribute names to monitor for changes */
23
+ ];
24
+ }
25
+
26
+ attributeChangedCallback(name, oldValue, newValue) {
27
+ // called when one of attributes listed above is modified
28
+ }
29
+
30
+ adoptedCallback() {
31
+ // called when the element is moved to a new document
32
+ // (happens in document.adoptNode, very rarely used)
33
+ }
34
+
35
+ // there can be other element methods and properties
36
+ }
37
+
38
+ customElements.define('my-element', MyElement);
39
+
40
+ // Now for any HTML elements with tag <my-element>,
41
+ // an instance of MyElement is created, and the aforementioned
42
+ // methods are called.
43
+
44
+ export { MyElement };
@@ -13,6 +13,15 @@ const Worker = {
13
13
  devMode: () => location.origin.match('localhost') || location.origin.match('127.0.0.1'),
14
14
  instance: async function ({ router, render }) {
15
15
  logger.warn('Init');
16
+ window.ononline = async () => {
17
+ logger.warn('ononline');
18
+ };
19
+ window.onoffline = async () => {
20
+ logger.warn('onoffline');
21
+ };
22
+ setTimeout(() => {
23
+ if ('onLine' in navigator && navigator.onLine) window.ononline();
24
+ });
16
25
  navigator.serviceWorker.addEventListener('controllerchange', () => {
17
26
  logger.info('The controller of current browsing context has changed.');
18
27
  });
@@ -48,11 +57,9 @@ const Worker = {
48
57
  // channel.postMessage({ title: 'Hello from Client broadcast message' });
49
58
  // channel.close();
50
59
  });
60
+ this.RouterInstance = router();
51
61
  const isInstall = await this.status();
52
62
  if (!isInstall) await this.install();
53
- else await this.update();
54
- // else if (location.hostname === 'localhost') await this.update();
55
- this.RouterInstance = router();
56
63
  await render();
57
64
  LoadRouter(this.RouterInstance);
58
65
  LoadingAnimation.removeSplashScreen();
@@ -61,9 +68,9 @@ const Worker = {
61
68
  // Dev mode
62
69
 
63
70
  window.addEventListener('visibilitychange', (event) => {
64
- if (document.visibilityState === 'visible') {
65
- Worker.reload(delayLiveReload);
66
- }
71
+ // if (document.visibilityState === 'visible') {
72
+ // Worker.reload(delayLiveReload);
73
+ // }
67
74
  });
68
75
  window.addEventListener('focus', function () {
69
76
  // Worker.reload(delayLiveReload);
@@ -90,21 +97,11 @@ const Worker = {
90
97
  if (isInstall) {
91
98
  const cacheNames = await caches.keys();
92
99
  for (const cacheName of cacheNames) {
93
- if (
94
- cacheName.match('components/') ||
95
- cacheName.match('services/') ||
96
- cacheName.match('.index.js') ||
97
- cacheName.match('offline.')
98
- ) {
100
+ if (cacheName.match('components/') || cacheName.match('services/') || cacheName.match('.index.js')) {
99
101
  await caches.delete(cacheName);
100
102
  }
101
103
  }
102
104
  await this.updateServiceWorker();
103
- try {
104
- await fetch('/offline.html');
105
- } catch (error) {
106
- logger.error('error');
107
- }
108
105
  }
109
106
  },
110
107
  updateServiceWorker: async function () {},
@@ -143,7 +140,7 @@ const Worker = {
143
140
  return new Promise((resolve, reject) => {
144
141
  if ('serviceWorker' in navigator) {
145
142
  navigator.serviceWorker
146
- .register(`/sw.js`, {
143
+ .register(`${getProxyPath()}sw.js`, {
147
144
  // scope: getProxyPath(),
148
145
  // scope: '/',
149
146
  type: 'module',