underpost 3.2.4 → 3.2.8

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 (141) hide show
  1. package/.github/workflows/release.cd.yml +1 -2
  2. package/CHANGELOG.md +268 -1
  3. package/CLI-HELP.md +26 -13
  4. package/Dockerfile +0 -4
  5. package/README.md +3 -3
  6. package/bin/build.js +13 -3
  7. package/bin/deploy.js +570 -1
  8. package/bin/file.js +5 -0
  9. package/conf.js +11 -2
  10. package/jsconfig.json +1 -1
  11. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -3
  12. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +2 -3
  13. package/manifests/deployment/dd-default-development/deployment.yaml +2 -6
  14. package/manifests/deployment/dd-test-development/deployment.yaml +136 -66
  15. package/manifests/deployment/dd-test-development/proxy.yaml +41 -5
  16. package/package.json +20 -11
  17. package/src/api/core/core.controller.js +10 -10
  18. package/src/api/core/core.service.js +10 -10
  19. package/src/api/default/default.controller.js +10 -10
  20. package/src/api/default/default.service.js +10 -10
  21. package/src/api/document/document.controller.js +12 -12
  22. package/src/api/document/document.model.js +10 -16
  23. package/src/api/file/file.controller.js +8 -8
  24. package/src/api/file/file.model.js +10 -10
  25. package/src/api/file/file.service.js +36 -36
  26. package/src/api/test/test.controller.js +8 -8
  27. package/src/api/test/test.service.js +8 -8
  28. package/src/api/user/guest.service.js +99 -0
  29. package/src/api/user/user.controller.js +6 -6
  30. package/src/api/user/user.model.js +8 -13
  31. package/src/api/user/user.service.js +3 -20
  32. package/src/cli/deploy.js +33 -30
  33. package/src/cli/fs.js +62 -5
  34. package/src/cli/image.js +43 -1
  35. package/src/cli/index.js +5 -1
  36. package/src/cli/release.js +58 -2
  37. package/src/cli/repository.js +35 -3
  38. package/src/cli/run.js +304 -38
  39. package/src/cli/ssh.js +1 -1
  40. package/src/cli/static.js +43 -115
  41. package/src/client/Default.index.js +21 -33
  42. package/src/client/components/core/404.js +4 -4
  43. package/src/client/components/core/500.js +4 -4
  44. package/src/client/components/core/Account.js +73 -60
  45. package/src/client/components/core/AgGrid.js +23 -33
  46. package/src/client/components/core/Alert.js +12 -13
  47. package/src/client/components/core/AppStore.js +1 -1
  48. package/src/client/components/core/Auth.js +20 -32
  49. package/src/client/components/core/Badge.js +7 -13
  50. package/src/client/components/core/BtnIcon.js +15 -17
  51. package/src/client/components/core/CalendarCore.js +42 -63
  52. package/src/client/components/core/Chat.js +13 -15
  53. package/src/client/components/core/ClientEvents.js +87 -0
  54. package/src/client/components/core/ColorPaletteElement.js +309 -0
  55. package/src/client/components/core/Content.js +17 -14
  56. package/src/client/components/core/Css.js +15 -71
  57. package/src/client/components/core/CssCore.js +12 -16
  58. package/src/client/components/core/D3Chart.js +4 -4
  59. package/src/client/components/core/Docs.js +60 -59
  60. package/src/client/components/core/DropDown.js +69 -91
  61. package/src/client/components/core/EventBus.js +92 -0
  62. package/src/client/components/core/EventsUI.js +14 -17
  63. package/src/client/components/core/FileExplorer.js +102 -234
  64. package/src/client/components/core/FullScreen.js +47 -75
  65. package/src/client/components/core/Input.js +24 -69
  66. package/src/client/components/core/Keyboard.js +25 -18
  67. package/src/client/components/core/KeyboardAvoidance.js +145 -0
  68. package/src/client/components/core/LoadingAnimation.js +25 -31
  69. package/src/client/components/core/LogIn.js +41 -41
  70. package/src/client/components/core/LogOut.js +23 -14
  71. package/src/client/components/core/Modal.js +397 -176
  72. package/src/client/components/core/NotificationManager.js +14 -18
  73. package/src/client/components/core/Panel.js +54 -50
  74. package/src/client/components/core/PanelForm.js +25 -125
  75. package/src/client/components/core/Polyhedron.js +110 -214
  76. package/src/client/components/core/PublicProfile.js +39 -32
  77. package/src/client/components/core/Recover.js +52 -48
  78. package/src/client/components/core/Responsive.js +88 -32
  79. package/src/client/components/core/RichText.js +9 -18
  80. package/src/client/components/core/Router.js +24 -3
  81. package/src/client/components/core/SearchBox.js +37 -37
  82. package/src/client/components/core/SignUp.js +39 -30
  83. package/src/client/components/core/SocketIo.js +31 -2
  84. package/src/client/components/core/SocketIoHandler.js +6 -6
  85. package/src/client/components/core/ToggleSwitch.js +8 -20
  86. package/src/client/components/core/ToolTip.js +5 -17
  87. package/src/client/components/core/Translate.js +56 -59
  88. package/src/client/components/core/Validator.js +26 -16
  89. package/src/client/components/core/Wallet.js +15 -26
  90. package/src/client/components/core/Worker.js +140 -25
  91. package/src/client/components/core/windowGetDimensions.js +7 -7
  92. package/src/client/components/default/{MenuDefault.js → AppShellDefault.js} +87 -87
  93. package/src/client/components/default/CssDefault.js +12 -12
  94. package/src/client/components/default/LogInDefault.js +6 -4
  95. package/src/client/components/default/LogOutDefault.js +6 -4
  96. package/src/client/components/default/RouterDefault.js +47 -0
  97. package/src/client/components/default/SettingsDefault.js +4 -4
  98. package/src/client/components/default/SignUpDefault.js +6 -4
  99. package/src/client/components/default/TranslateDefault.js +3 -3
  100. package/src/client/services/core/core.service.js +17 -49
  101. package/src/client/services/default/default.management.js +139 -242
  102. package/src/client/services/default/default.service.js +10 -16
  103. package/src/client/services/document/document.service.js +14 -19
  104. package/src/client/services/file/file.service.js +8 -13
  105. package/src/client/services/test/test.service.js +8 -13
  106. package/src/client/services/user/guest.service.js +79 -0
  107. package/src/client/services/user/user.management.js +5 -5
  108. package/src/client/services/user/user.service.js +14 -20
  109. package/src/client/ssr/body/404.js +3 -3
  110. package/src/client/ssr/body/500.js +3 -3
  111. package/src/client/ssr/body/CacheControl.js +5 -2
  112. package/src/client/ssr/body/DefaultSplashScreen.js +19 -12
  113. package/src/client/ssr/mailer/DefaultRecoverEmail.js +19 -20
  114. package/src/client/ssr/mailer/DefaultVerifyEmail.js +15 -16
  115. package/src/client/ssr/offline/Maintenance.js +12 -11
  116. package/src/client/ssr/offline/NoNetworkConnection.js +3 -3
  117. package/src/client/ssr/pages/Test.js +2 -2
  118. package/src/client/sw/core.sw.js +212 -0
  119. package/src/index.js +1 -1
  120. package/src/runtime/express/Dockerfile +4 -4
  121. package/src/runtime/lampp/Dockerfile +8 -7
  122. package/src/runtime/wp/Dockerfile +11 -17
  123. package/src/server/backup.js +1 -2
  124. package/src/server/client-build-docs.js +45 -46
  125. package/src/server/client-build.js +334 -60
  126. package/src/server/client-formatted.js +47 -16
  127. package/src/server/conf.js +29 -13
  128. package/src/server/cron.js +6 -8
  129. package/src/server/dns.js +2 -1
  130. package/src/server/ipfs-client.js +232 -91
  131. package/src/server/process.js +13 -27
  132. package/src/server/start.js +6 -3
  133. package/src/server/valkey.js +134 -235
  134. package/tsconfig.docs.json +15 -0
  135. package/typedoc.json +20 -0
  136. package/jsdoc.json +0 -52
  137. package/src/client/components/core/ColorPalette.js +0 -5267
  138. package/src/client/components/core/JoyStick.js +0 -80
  139. package/src/client/components/default/RoutesDefault.js +0 -49
  140. package/src/client/sw/default.sw.js +0 -127
  141. package/src/client/sw/template.sw.js +0 -84
@@ -14,6 +14,7 @@ import { NotificationManager } from './NotificationManager.js';
14
14
  import { SearchBox } from './SearchBox.js';
15
15
  import { Translate } from './Translate.js';
16
16
  import { s } from './VanillaJs.js';
17
+ import { GuestService } from '../../services/user/guest.service.js';
17
18
 
18
19
  const logger = loggerFactory(import.meta, { trace: true });
19
20
 
@@ -22,20 +23,6 @@ const logger = loggerFactory(import.meta, { trace: true });
22
23
  * @memberof AuthClient
23
24
  */
24
25
  class Auth {
25
- /**
26
- * The current user access token (JWT).
27
- * @type {string}
28
- * @method
29
- */
30
- #token = '';
31
-
32
- /**
33
- * The token for anonymous guest sessions.
34
- * @type {string}
35
- * @method
36
- */
37
- #guestToken = '';
38
-
39
26
  /**
40
27
  * Timeout ID for the token refresh schedule.
41
28
  * @type {number | undefined}
@@ -59,7 +46,7 @@ class Auth {
59
46
  * @returns {string} The set token value.
60
47
  */
61
48
  setToken(value = '') {
62
- return (this.#token = value);
49
+ return GuestService.setUserToken(value);
63
50
  }
64
51
 
65
52
  /**
@@ -68,7 +55,7 @@ class Auth {
68
55
  * @returns {string} An empty string.
69
56
  */
70
57
  deleteToken() {
71
- return (this.#token = '');
58
+ return GuestService.clearUserToken();
72
59
  }
73
60
 
74
61
  /**
@@ -77,7 +64,7 @@ class Auth {
77
64
  * @returns {string} The JWT token.
78
65
  */
79
66
  getToken() {
80
- return this.#token;
67
+ return GuestService.getUserToken();
81
68
  }
82
69
 
83
70
  /**
@@ -87,7 +74,7 @@ class Auth {
87
74
  * @returns {string} The set guest token value.
88
75
  */
89
76
  setGuestToken(value = '') {
90
- return (this.#guestToken = value);
77
+ return GuestService.setGuestToken(value);
91
78
  }
92
79
 
93
80
  /**
@@ -96,7 +83,7 @@ class Auth {
96
83
  * @returns {string} An empty string.
97
84
  */
98
85
  deleteGuestToken() {
99
- return (this.#guestToken = '');
86
+ return GuestService.clearGuestToken();
100
87
  }
101
88
 
102
89
  /**
@@ -105,7 +92,7 @@ class Auth {
105
92
  * @returns {string} The guest token.
106
93
  */
107
94
  getGuestToken() {
108
- return this.#guestToken;
95
+ return GuestService.getGuestToken();
109
96
  }
110
97
 
111
98
  /**
@@ -114,9 +101,7 @@ class Auth {
114
101
  * @returns {string} The Bearer token string or an empty string.
115
102
  */
116
103
  getJWT() {
117
- if (this.getToken()) return `Bearer ${this.getToken()}`;
118
- if (this.getGuestToken()) return `Bearer ${this.getGuestToken()}`;
119
- return '';
104
+ return GuestService.getAuthorizationHeader();
120
105
  }
121
106
 
122
107
  /**
@@ -190,7 +175,7 @@ class Auth {
190
175
  */
191
176
  async sessionIn(userServicePayload) {
192
177
  try {
193
- let token = userServicePayload?.data?.token || localStorage.getItem('jwt');
178
+ let token = userServicePayload?.data?.token || GuestService.getUserToken();
194
179
 
195
180
  if (token) {
196
181
  this.setToken(token);
@@ -204,7 +189,11 @@ class Auth {
204
189
  if (status === 'success' && data.token) {
205
190
  // A valid user token was found/refreshed
206
191
  this.setToken(data.token);
207
- localStorage.setItem('jwt', data.token);
192
+ GuestService.clearGuestToken();
193
+ await GuestService.setMeta('session', {
194
+ role: data.user?.role,
195
+ userId: data.user?._id,
196
+ });
208
197
  // Clear cached profile image to ensure fresh load for new user
209
198
  LogIn.Scope.user.main.model.user = {};
210
199
  this.renderSessionUI();
@@ -218,7 +207,7 @@ class Auth {
218
207
  setTimeout(() => {
219
208
  s(`.main-btn-log-in`).click();
220
209
  NotificationManager.Push({
221
- html: Translate.Render(`expired-session`),
210
+ html: Translate.instance(`expired-session`),
222
211
  status: 'warning',
223
212
  });
224
213
  });
@@ -227,17 +216,19 @@ class Auth {
227
216
 
228
217
  // Cleanup failed user session attempt
229
218
  this.deleteToken();
230
- localStorage.removeItem('jwt');
231
219
 
232
220
  // Anon guest session attempt
233
- let guestToken = localStorage.getItem('jwt.g');
221
+ let guestToken = GuestService.getGuestToken();
234
222
  if (guestToken) {
235
223
  this.setGuestToken(guestToken);
236
224
  let { data, status, message } = await UserService.get({ id: 'auth' }); // Verify guest token
237
225
  if (status === 'success' && data.token) {
238
226
  // Guest token is valid and refreshed
239
227
  this.setGuestToken(data.token);
240
- localStorage.setItem('jwt.g', data.token);
228
+ await GuestService.setMeta('guest-session', {
229
+ role: data.user?.role,
230
+ userId: data.user?._id,
231
+ });
241
232
  // Clear cached profile image for fresh guest session
242
233
  LogIn.Scope.user.main.model.user = {};
243
234
  await LogIn.Trigger(data);
@@ -267,7 +258,6 @@ class Auth {
267
258
  // 1. End User Session
268
259
  try {
269
260
  const result = await UserService.delete({ id: 'logout' });
270
- localStorage.removeItem('jwt');
271
261
  SearchBox.RecentResults.clear();
272
262
  this.deleteToken();
273
263
  if (this.#refreshTimeout) {
@@ -284,12 +274,10 @@ class Auth {
284
274
 
285
275
  // 2. Start Guest Session
286
276
  try {
287
- localStorage.removeItem('jwt.g');
288
277
  this.deleteGuestToken();
289
278
  const result = await UserService.post({ id: 'guest' }); // Request a new guest token
290
279
 
291
280
  if (result.status === 'success' && result.data.token) {
292
- localStorage.setItem('jwt.g', result.data.token);
293
281
  this.setGuestToken(result.data.token);
294
282
  // Recursively call sessionIn to complete the guest login process (UI update, etc.)
295
283
  return await this.sessionIn();
@@ -2,31 +2,25 @@ import { getId, getIsoDate } from './CommonJs.js';
2
2
  import { Css, renderCssAttr, Themes } from './Css.js';
3
3
  import { Modal } from './Modal.js';
4
4
  import { append, prepend, s } from './VanillaJs.js';
5
-
6
- const Badge = {
7
- Tokens: {},
8
- Render: async function (options = { id: '', type: 'circle-red', classList: '', text: '', style: '' }) {
9
- if (!options.id) options.id = getId(this.Tokens, 'badge-');
5
+ class Badge {
6
+ static Tokens = {};
7
+ static async instance(options = { id: '', type: 'circle-red', classList: '', text: '', style: '' }) {
8
+ if (!options.id) options.id = getId(Badge.Tokens, 'badge-');
10
9
  else options.id = 'badge-' + options.id;
11
10
  if (options && options.style && !options.style.color) options.style.color = 'white';
12
11
  if (!options.classList) options.classList = '';
13
-
14
12
  const { id, type } = options;
15
- this.Tokens[id] = { ...options };
16
-
13
+ Badge.Tokens[id] = { ...options };
17
14
  switch (type) {
18
15
  case 'circle-red':
19
16
  options.classList += ' badge-notification-circle-red ';
20
17
  break;
21
-
22
18
  default:
23
19
  break;
24
20
  }
25
-
26
21
  return html`<div class="badge wfm ${options.classList} ${id}" style="${renderCssAttr(options)}">
27
22
  <div class="badge-text">${options?.text ? options.text : 'B'}</div>
28
23
  </div>`;
29
- },
30
- };
31
-
24
+ }
25
+ }
32
26
  export { Badge };
@@ -2,10 +2,9 @@ import { getId, s4 } from './CommonJs.js';
2
2
  import { renderCssAttr } from './Css.js';
3
3
  import { ToolTip } from './ToolTip.js';
4
4
  import { getAllChildNodes, htmlStrSanitize, s } from './VanillaJs.js';
5
-
6
- const BtnIcon = {
7
- Tokens: {},
8
- Render: async function (
5
+ class BtnIcon {
6
+ static Tokens = {};
7
+ static async instance(
9
8
  options = {
10
9
  class: '',
11
10
  type: '',
@@ -19,9 +18,9 @@ const BtnIcon = {
19
18
  useMenuBtn: false,
20
19
  },
21
20
  ) {
22
- const tokenId = getId(this.Tokens, 'btn-token-');
21
+ const tokenId = getId(BtnIcon.Tokens, 'btn-token-');
23
22
  if (options.useMenuBtn) options.class += ' main-menu-btn-selector';
24
- this.Tokens[tokenId] = { ...options };
23
+ BtnIcon.Tokens[tokenId] = { ...options };
25
24
  setTimeout(() => {
26
25
  if (s(`.a-${tokenId}`)) s(`.a-${tokenId}`).onclick = (e) => e.preventDefault();
27
26
  });
@@ -57,7 +56,7 @@ const BtnIcon = {
57
56
  if (options.tooltipHtml)
58
57
  setTimeout(() => {
59
58
  if (s(`.${tokenId}`))
60
- ToolTip.Render({
59
+ ToolTip.instance({
61
60
  container: `.${tokenId}`,
62
61
  id: tokenId,
63
62
  htmlRender: options.tooltipHtml,
@@ -66,15 +65,15 @@ const BtnIcon = {
66
65
  });
67
66
  });
68
67
  return render;
69
- },
68
+ }
70
69
  // https://developer.mozilla.org/en-US/docs/Games/Techniques/Control_mechanisms/Mobile_touch
71
- TouchTokens: {},
72
- RenderTouch: async function (options = { id: '', Events: {} }) {
70
+ static TouchTokens = {};
71
+ static async RenderTouch(options = { id: '', Events: {} }) {
73
72
  const { id } = options;
74
- this.TouchTokens[id] = { Events: {}, ...options };
73
+ BtnIcon.TouchTokens[id] = { Events: {}, ...options };
75
74
  setTimeout(() => {
76
75
  const triggerTouchEvents = () => {
77
- for (const event of Object.keys(this.TouchTokens[id].Events)) this.TouchTokens[id].Events[event]();
76
+ for (const event of Object.keys(BtnIcon.TouchTokens[id].Events)) BtnIcon.TouchTokens[id].Events[event]();
78
77
  };
79
78
  if (s(`.${id}`)) {
80
79
  s(`.${id}`).addEventListener('touchstart', () => {
@@ -101,11 +100,10 @@ const BtnIcon = {
101
100
  style="${renderCssAttr({ style: { width: '100%', height: '100%', top: '0px', left: '0px', border: 'none' } })}"
102
101
  >
103
102
  </canvas>`;
104
- },
105
- findLabel: (el) =>
103
+ }
104
+ static findLabel = (el) =>
106
105
  getAllChildNodes(el).find((e) => {
107
106
  return e.classList && Array.from(e.classList).find((e) => e.match('BtnIcon-label'));
108
- }),
109
- };
110
-
107
+ });
108
+ }
111
109
  export { BtnIcon };
@@ -10,49 +10,42 @@ import { Responsive } from './Responsive.js';
10
10
  import { listenQueryPathInstance, RouterEvents, setQueryPath, getQueryParams } from './Router.js';
11
11
  import { Translate } from './Translate.js';
12
12
  import { append, getTimeZone, htmls, s, sa } from './VanillaJs.js';
13
-
14
13
  // https://fullcalendar.io/docs/event-object
15
-
16
14
  const daysOfWeekOptions = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
17
-
18
15
  const eventDateFactory = (event) =>
19
16
  newInstance({
20
17
  event: { ...event.extendedProps, title: event._def.title },
21
18
  start: event.start,
22
19
  end: event.end,
23
20
  });
24
-
25
- const CalendarCore = {
26
- RenderStyle: async function () {},
27
- Data: {},
28
- Render: async function (options = { idModal: '', appStore: {}, hiddenDates: [] }) {
29
- this.Data[options.idModal] = {
21
+ class CalendarCore {
22
+ static async RenderStyle() {}
23
+ static Data = {};
24
+ static async instance(options = { idModal: '', appStore: {}, hiddenDates: [] }) {
25
+ CalendarCore.Data[options.idModal] = {
30
26
  data: [],
31
27
  originData: [],
32
28
  filesData: [],
33
29
  calendar: {},
34
30
  hiddenDates: options.hiddenDates ? options.hiddenDates : [],
35
31
  };
36
-
37
32
  const titleIcon = html`<i class="fas fa-calendar-alt"></i>`;
38
-
39
33
  const getPanelData = async () => {
40
34
  const result = await EventSchedulerService.get({
41
35
  id: `${getQueryParams().cid ? getQueryParams().cid : Auth.getToken() ? 'creatorUser' : ''}`,
42
36
  });
43
37
  NotificationManager.Push({
44
- html: result.status === 'success' ? Translate.Render('success-get-events-scheduler') : result.message,
38
+ html: result.status === 'success' ? Translate.instance('success-get-events-scheduler') : result.message,
45
39
  status: result.status,
46
40
  });
47
41
  if (result.status === 'success') {
48
42
  const resultData = Array.isArray(result.data) ? result.data : result.data ? [result.data] : [];
49
- this.Data[options.idModal].filesData = [];
50
- this.Data[options.idModal].originData = newInstance(resultData);
51
- this.Data[options.idModal].data = resultData.map((o) => {
43
+ CalendarCore.Data[options.idModal].filesData = [];
44
+ CalendarCore.Data[options.idModal].originData = newInstance(resultData);
45
+ CalendarCore.Data[options.idModal].data = resultData.map((o) => {
52
46
  if (o.creatorUserId && options.appStore.Data.user.main.model.user._id === o.creatorUserId) o.tools = true;
53
47
  o.id = o._id;
54
-
55
- this.Data[options.idModal].filesData.push({});
48
+ CalendarCore.Data[options.idModal].filesData.push({});
56
49
  return o;
57
50
  });
58
51
  setTimeout(() => {
@@ -69,17 +62,15 @@ const CalendarCore = {
69
62
  // o.exdate = ['2024-04-02'];
70
63
  // delete o.end;
71
64
  // delete o.start;
72
-
73
65
  return o;
74
66
  }),
75
67
  );
76
68
  });
77
69
  }
78
70
  };
79
-
80
71
  const renderCalendar = (events) => {
81
72
  const calendarEl = s(`.calendar-${idPanel}`);
82
- this.Data[options.idModal].calendar = new FullCalendar.Calendar(calendarEl, {
73
+ CalendarCore.Data[options.idModal].calendar = new FullCalendar.Calendar(calendarEl, {
83
74
  allDaySlot: false,
84
75
  plugins: [
85
76
  FullCalendar.DayGrid.default,
@@ -120,44 +111,42 @@ const CalendarCore = {
120
111
  return ['hide'];
121
112
  },
122
113
  });
123
-
124
- this.Data[options.idModal].calendar.render();
114
+ CalendarCore.Data[options.idModal].calendar.render();
125
115
  };
126
116
  setTimeout(() => {
127
117
  renderCalendar();
128
- Translate.Event['fullcalendar-lang'] = () => {
129
- this.Data[options.idModal].calendar.setOption('locale', s(`html`).lang);
130
- if (s(`.fc-timegrid-axis-cushion`)) htmls(`.fc-timegrid-axis-cushion`, Translate.Render('all-day'));
131
- if (s(`.fc-dayGridMonth-button`)) htmls(`.fc-dayGridMonth-button`, Translate.Render('month'));
132
- if (s(`.fc-timeGridWeek-button`)) htmls(`.fc-timeGridWeek-button`, Translate.Render('week'));
133
- if (s(`.fc-listWeek-button`)) htmls(`.fc-listWeek-button`, Translate.Render('summary'));
134
- if (s(`.fc-today-button`)) htmls(`.fc-today-button`, Translate.Render('today'));
118
+ const applyFullCalendarLang = () => {
119
+ CalendarCore.Data[options.idModal].calendar.setOption('locale', s(`html`).lang);
120
+ if (s(`.fc-timegrid-axis-cushion`)) htmls(`.fc-timegrid-axis-cushion`, Translate.instance('all-day'));
121
+ if (s(`.fc-dayGridMonth-button`)) htmls(`.fc-dayGridMonth-button`, Translate.instance('month'));
122
+ if (s(`.fc-timeGridWeek-button`)) htmls(`.fc-timeGridWeek-button`, Translate.instance('week'));
123
+ if (s(`.fc-listWeek-button`)) htmls(`.fc-listWeek-button`, Translate.instance('summary'));
124
+ if (s(`.fc-today-button`)) htmls(`.fc-today-button`, Translate.instance('today'));
135
125
  };
126
+ Translate.onChanged(applyFullCalendarLang, { key: 'fullcalendar-lang' });
136
127
  setTimeout(() => {
137
- Translate.Event['fullcalendar-lang']();
128
+ applyFullCalendarLang();
138
129
  s(`.fc-dayGridMonth-button`).onclick = () => {
139
- Translate.Event['fullcalendar-lang']();
130
+ applyFullCalendarLang();
140
131
  };
141
132
  s(`.fc-listWeek-button`).onclick = () => {
142
- Translate.Event['fullcalendar-lang']();
133
+ applyFullCalendarLang();
143
134
  };
144
135
  s(`.fc-timeGridWeek-button`).onclick = () => {
145
- Translate.Event['fullcalendar-lang']();
136
+ applyFullCalendarLang();
146
137
  };
147
138
  s(`.fc-next-button`).onclick = () => {
148
- Translate.Event['fullcalendar-lang']();
139
+ applyFullCalendarLang();
149
140
  };
150
141
  s(`.fc-prev-button`).onclick = () => {
151
- Translate.Event['fullcalendar-lang']();
142
+ applyFullCalendarLang();
152
143
  };
153
144
  s(`.fc-today-button`).onclick = () => {
154
- Translate.Event['fullcalendar-lang']();
145
+ applyFullCalendarLang();
155
146
  };
156
147
  });
157
-
158
148
  sa(`.fc-button-group`)[1].style.float = 'right';
159
149
  });
160
-
161
150
  const idPanel = `calendar-panel-${options.idModal}`;
162
151
  const formData = [
163
152
  {
@@ -217,25 +206,23 @@ const CalendarCore = {
217
206
  panel: { type: 'info-row' },
218
207
  },
219
208
  ];
220
-
221
209
  setTimeout(() => {
222
210
  s(`.close-calendar-container`).onclick = () => {
223
211
  s(`.calendar-container`).classList.add('hide');
224
212
  s(`.main-body-calendar-${options.idModal}`).classList.remove('hide');
225
213
  };
226
214
  });
227
-
228
215
  const panelRender = async () => {
229
- return html`${await Panel.Render({
216
+ return html`${await Panel.instance({
230
217
  idPanel,
231
218
  parentIdModal: options.idModal,
232
219
  formData,
233
- data: this.Data[options.idModal].data,
220
+ data: CalendarCore.Data[options.idModal].data,
234
221
  formContainerClass: '',
235
222
  scrollClassContainer: `main-body-calendar-${options.idModal}`,
236
223
  role: options.role,
237
- originData: () => this.Data[options.idModal].originData,
238
- filesData: () => this.Data[options.idModal].filesData,
224
+ originData: () => CalendarCore.Data[options.idModal].originData,
225
+ filesData: () => CalendarCore.Data[options.idModal].filesData,
239
226
  onClick: async function ({ payload }) {
240
227
  if (options.route) {
241
228
  setQueryPath({ path: options.route, queryPath: payload._id });
@@ -254,13 +241,13 @@ const CalendarCore = {
254
241
  },
255
242
  customButtons: [
256
243
  {
257
- label: html`<i class="fa-regular fa-calendar-days"></i> ${Translate.Render('calendar')}`,
244
+ label: html`<i class="fa-regular fa-calendar-days"></i> ${Translate.instance('calendar')}`,
258
245
  onClick: function () {
259
246
  s(`.calendar-container`).classList.remove('hide');
260
247
  s(`.main-body-calendar-${options.idModal}`).classList.add('hide');
261
248
  // renderCalendar();
262
249
  CalendarCore.Data[options.idModal].calendar.setOption('height', 700);
263
- Translate.Event['fullcalendar-lang']();
250
+ Translate.emitChanged({ lang: s('html').lang });
264
251
  },
265
252
  },
266
253
  ],
@@ -284,17 +271,15 @@ const CalendarCore = {
284
271
  html:
285
272
  status === 'success'
286
273
  ? editId
287
- ? Translate.Render('success-edit-event-scheduler')
288
- : Translate.Render('success-add-event-scheduler')
274
+ ? Translate.instance('success-edit-event-scheduler')
275
+ : Translate.instance('success-add-event-scheduler')
289
276
  : message,
290
277
  status: status,
291
278
  });
292
-
293
279
  if (status === 'success') {
294
280
  documentData.tools = true;
295
281
  // data._id = documentData._id;
296
282
  data = documentData;
297
-
298
283
  let originObj, indexOriginObj;
299
284
  let filesData = {};
300
285
  if (editId) {
@@ -310,7 +295,6 @@ const CalendarCore = {
310
295
  CalendarCore.Data[options.idModal].data.push(data);
311
296
  CalendarCore.Data[options.idModal].filesData.push(filesData);
312
297
  }
313
-
314
298
  setQueryPath({ path: options.route, queryPath: documentData._id });
315
299
  if (options.parentIdModal) Modal.Data[options.parentIdModal].query = `${window.location.search}`;
316
300
  await CalendarCore.Data[options.idModal].updatePanel();
@@ -323,7 +307,7 @@ const CalendarCore = {
323
307
  html: async () => {
324
308
  return html`
325
309
  <div class="in section-mp" style="text-align: center">
326
- ${Translate.Render('confirm-delete-item')}
310
+ ${Translate.instance('confirm-delete-item')}
327
311
  <br />
328
312
  "${data.description}"
329
313
  </div>
@@ -339,10 +323,8 @@ const CalendarCore = {
339
323
  html: status,
340
324
  status,
341
325
  });
342
-
343
326
  setQueryPath({ path: options.route, queryPath: '' });
344
327
  await CalendarCore.Data[options.idModal].updatePanel();
345
-
346
328
  return { status };
347
329
  }
348
330
  return { status: 'error' };
@@ -351,9 +333,8 @@ const CalendarCore = {
351
333
  })}
352
334
  <div class="in" style="margin-bottom: 100px"></div>`;
353
335
  };
354
-
355
336
  let lastCid;
356
- this.Data[options.idModal].updatePanel = async () => {
337
+ CalendarCore.Data[options.idModal].updatePanel = async () => {
357
338
  const cid = getQueryParams().cid ? getQueryParams().cid : '';
358
339
  if (lastCid === cid) return;
359
340
  lastCid = cid;
@@ -364,7 +345,6 @@ const CalendarCore = {
364
345
  htmls(`.main-body-calendar-${options.idModal}`, await panelRender());
365
346
  }
366
347
  };
367
-
368
348
  if (options.route) {
369
349
  listenQueryPathInstance({
370
350
  id: options.parentIdModal ? 'html-' + options.parentIdModal : 'main-body',
@@ -377,7 +357,7 @@ const CalendarCore = {
377
357
  Modal.Data['modal-menu'].onHome[idPanel] = async () => {
378
358
  lastCid = undefined;
379
359
  setQueryPath({ path: options.route, queryPath: '' });
380
- await this.Data[idPanel].updatePanel();
360
+ await CalendarCore.Data[idPanel].updatePanel();
381
361
  };
382
362
  }
383
363
  return html`
@@ -443,16 +423,15 @@ const CalendarCore = {
443
423
  </style>
444
424
  <div class="in calendar-container hide">
445
425
  <div class="in modal calendar-buttons-container">
446
- ${await BtnIcon.Render({
426
+ ${await BtnIcon.instance({
447
427
  class: `inl section-mp btn-custom close-calendar-container flr`,
448
- label: html`<i class="fa-solid fa-xmark"></i> ${Translate.Render('close')}`,
428
+ label: html`<i class="fa-solid fa-xmark"></i> ${Translate.instance('close')}`,
449
429
  type: 'button',
450
430
  })}
451
431
  </div>
452
432
  <div class="in"><div class="calendar-${idPanel}"></div></div>
453
433
  </div>
454
434
  `;
455
- },
456
- };
457
-
435
+ }
436
+ }
458
437
  export { CalendarCore };
@@ -5,12 +5,11 @@ import { Modal } from './Modal.js';
5
5
  import { SocketIo } from './SocketIo.js';
6
6
  import { Translate } from './Translate.js';
7
7
  import { s, append } from './VanillaJs.js';
8
-
9
- const Chat = {
10
- Data: {},
11
- Render: async function (options) {
8
+ class Chat {
9
+ static Data = {};
10
+ static async instance(options) {
12
11
  const { idModal } = options;
13
- this.Data[idModal] = {};
12
+ Chat.Data[idModal] = {};
14
13
  setTimeout(() => {
15
14
  Modal.Data[idModal].onObserverListener[`chat-${idModal}`] = (options) => {
16
15
  const { height } = options;
@@ -19,7 +18,7 @@ const Chat = {
19
18
  s(`.btn-send-chat-${idModal}`).onclick = (e) => {
20
19
  e.preventDefault();
21
20
  if (!s(`.input-chat-${idModal}`).value) return;
22
- this.appendChatBox({ id: SocketIo.socket.id, idModal, message: s(`.input-chat-${idModal}`).value });
21
+ Chat.appendChatBox({ id: SocketIo.socket.id, idModal, message: s(`.input-chat-${idModal}`).value });
23
22
  SocketIo.Emit('chat', {
24
23
  message: s(`.input-chat-${idModal}`).value,
25
24
  });
@@ -29,23 +28,23 @@ const Chat = {
29
28
  return html`
30
29
  <form>
31
30
  <div class="in section-mp chat-box ${idModal}-chat-box"></div>
32
- ${await Input.Render({
31
+ ${await Input.instance({
33
32
  id: `input-chat-${idModal}`,
34
- label: html`<i class="fa-solid fa-pen-to-square"></i> ${Translate.Render('write')}`,
33
+ label: html`<i class="fa-solid fa-pen-to-square"></i> ${Translate.instance('write')}`,
35
34
  containerClass: 'in section-mp width-mini-box-hover input-container-width',
36
35
  placeholder: true,
37
36
  })}
38
37
  <div class="in">
39
- ${await BtnIcon.Render({
38
+ ${await BtnIcon.instance({
40
39
  class: `btn-send-chat-${idModal}`,
41
- label: Translate.Render('send'),
40
+ label: Translate.instance('send'),
42
41
  type: 'submit',
43
42
  })}
44
43
  </div>
45
44
  </form>
46
45
  `;
47
- },
48
- appendChatBox: function (options) {
46
+ }
47
+ static appendChatBox(options) {
49
48
  const { idModal, id, message } = options;
50
49
  if (!s(`.${idModal}-chat-box`)) return;
51
50
  append(
@@ -58,7 +57,6 @@ const Chat = {
58
57
  `,
59
58
  );
60
59
  s(`.${idModal}-chat-box`).scrollTop = s(`.${idModal}-chat-box`).scrollHeight;
61
- },
62
- };
63
-
60
+ }
61
+ }
64
62
  export { Chat };