@underpostnet/underpost 2.8.1 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +1 -0
- package/.github/workflows/ghpkg.yml +14 -11
- package/.github/workflows/pwa-microservices-template.page.yml +10 -3
- package/.vscode/extensions.json +17 -71
- package/.vscode/settings.json +10 -4
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +63 -3
- package/Dockerfile +41 -62
- package/README.md +1 -28
- package/bin/build.js +278 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +105 -55
- package/bin/file.js +33 -4
- package/bin/index.js +33 -51
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -89
- package/bin/vs.js +25 -2
- package/conf.js +31 -138
- package/docker-compose.yml +1 -1
- package/manifests/core/kustomization.yaml +11 -0
- package/manifests/core/underpost-engine-backup-access.yaml +16 -0
- package/manifests/core/underpost-engine-backup-pv-pvc.yaml +22 -0
- package/manifests/core/underpost-engine-headless-service.yaml +10 -0
- package/manifests/core/underpost-engine-mongodb-backup-cronjob.yaml +40 -0
- package/manifests/core/underpost-engine-mongodb-configmap.yaml +26 -0
- package/manifests/core/underpost-engine-pv-pvc.yaml +23 -0
- package/manifests/core/underpost-engine-statefulset.yaml +91 -0
- package/manifests/deployment/mongo-express.yaml +60 -0
- package/manifests/deployment/phpmyadmin.yaml +54 -0
- package/manifests/kind-config.yaml +12 -0
- package/manifests/letsencrypt-prod.yaml +15 -0
- package/manifests/mariadb/config.yaml +10 -0
- package/manifests/mariadb/kustomization.yaml +9 -0
- package/manifests/mariadb/pv.yaml +12 -0
- package/manifests/mariadb/pvc.yaml +10 -0
- package/manifests/mariadb/secret.yaml +8 -0
- package/manifests/mariadb/service.yaml +10 -0
- package/manifests/mariadb/statefulset.yaml +55 -0
- package/manifests/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/underpost-engine-valkey-service.yaml +17 -0
- package/manifests/valkey/underpost-engine-valkey-statefulset.yaml +39 -0
- package/package.json +7 -28
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +1 -1
- package/src/client/components/core/CalendarCore.js +115 -49
- package/src/client/components/core/CommonJs.js +150 -19
- package/src/client/components/core/CssCore.js +6 -0
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/Input.js +17 -3
- package/src/client/components/core/Modal.js +10 -5
- package/src/client/components/core/Panel.js +84 -25
- package/src/client/components/core/PanelForm.js +4 -18
- package/src/client/components/core/Translate.js +43 -9
- package/src/client/components/core/Validator.js +9 -1
- package/src/client/services/default/default.management.js +4 -2
- package/src/db/mongo/MongooseDB.js +13 -1
- package/src/index.js +8 -1
- package/src/runtime/lampp/Lampp.js +1 -13
- package/src/runtime/xampp/Xampp.js +0 -13
- package/src/server/auth.js +3 -3
- package/src/server/client-build.js +3 -13
- package/src/server/conf.js +296 -29
- package/src/server/dns.js +2 -3
- package/src/server/logger.js +10 -5
- package/src/server/network.js +0 -36
- package/src/server/process.js +25 -2
- package/src/server/project.js +39 -0
- package/src/server/proxy.js +4 -26
- package/src/server/runtime.js +6 -7
- package/src/server/ssl.js +1 -1
- package/src/server/valkey.js +2 -0
- package/startup.cjs +12 -0
- package/src/server/prompt-optimizer.js +0 -28
- package/startup.js +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventSchedulerService } from '../../services/event-scheduler/event-scheduler.service.js';
|
|
2
2
|
import { Auth } from './Auth.js';
|
|
3
3
|
import { BtnIcon } from './BtnIcon.js';
|
|
4
|
-
import { newInstance, range, s4 } from './CommonJs.js';
|
|
4
|
+
import { isValidDate, newInstance, range, s4 } from './CommonJs.js';
|
|
5
5
|
import { renderCssAttr } from './Css.js';
|
|
6
6
|
import { Modal } from './Modal.js';
|
|
7
7
|
import { NotificationManager } from './NotificationManager.js';
|
|
@@ -13,15 +13,27 @@ import { append, getQueryParams, getTimeZone, htmls, s, sa } from './VanillaJs.j
|
|
|
13
13
|
|
|
14
14
|
// https://fullcalendar.io/docs/event-object
|
|
15
15
|
|
|
16
|
+
const daysOfWeekOptions = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
|
17
|
+
|
|
18
|
+
const eventDateFactory = (event) =>
|
|
19
|
+
newInstance({
|
|
20
|
+
event: { ...event.extendedProps, title: event._def.title },
|
|
21
|
+
start: event.start,
|
|
22
|
+
end: event.end,
|
|
23
|
+
});
|
|
24
|
+
|
|
16
25
|
const CalendarCore = {
|
|
17
26
|
RenderStyle: async function () {},
|
|
18
27
|
Data: {},
|
|
19
|
-
Render: async function (
|
|
28
|
+
Render: async function (
|
|
29
|
+
options = { idModal: '', Elements: {}, heightTopBar: 50, heightBottomBar: 50, hiddenDates: [] },
|
|
30
|
+
) {
|
|
20
31
|
this.Data[options.idModal] = {
|
|
21
32
|
data: [],
|
|
22
33
|
originData: [],
|
|
23
34
|
filesData: [],
|
|
24
35
|
calendar: {},
|
|
36
|
+
hiddenDates: options.hiddenDates ? options.hiddenDates : [],
|
|
25
37
|
};
|
|
26
38
|
|
|
27
39
|
const { heightTopBar, heightBottomBar } = options;
|
|
@@ -40,56 +52,89 @@ const CalendarCore = {
|
|
|
40
52
|
};
|
|
41
53
|
getSrrData();
|
|
42
54
|
|
|
43
|
-
const dateFormat = (date) =>
|
|
44
|
-
html`<span
|
|
45
|
-
style="${renderCssAttr({
|
|
46
|
-
style: {
|
|
47
|
-
'font-size': '14px',
|
|
48
|
-
color: '#888',
|
|
49
|
-
},
|
|
50
|
-
})}"
|
|
51
|
-
>${new Date(date).toLocaleString().replaceAll(',', '')}</span
|
|
52
|
-
>`;
|
|
53
|
-
|
|
54
55
|
const getPanelData = async () => {
|
|
55
56
|
const result = await EventSchedulerService.get({
|
|
56
|
-
id: `${getQueryParams().cid ? getQueryParams().cid : 'creatorUser'}`,
|
|
57
|
+
id: `${getQueryParams().cid ? getQueryParams().cid : Auth.getToken() ? 'creatorUser' : ''}`,
|
|
57
58
|
});
|
|
58
59
|
NotificationManager.Push({
|
|
59
60
|
html: result.status === 'success' ? Translate.Render('success-get-events-scheduler') : result.message,
|
|
60
61
|
status: result.status,
|
|
61
62
|
});
|
|
62
63
|
if (result.status === 'success') {
|
|
63
|
-
const resultData = Array.isArray(result.data) ? result.data : [result.data];
|
|
64
|
+
const resultData = Array.isArray(result.data) ? result.data : result.data ? [result.data] : [];
|
|
64
65
|
this.Data[options.idModal].filesData = [];
|
|
65
66
|
this.Data[options.idModal].originData = newInstance(resultData);
|
|
66
67
|
this.Data[options.idModal].data = resultData.map((o) => {
|
|
67
68
|
if (o.creatorUserId && options.Elements.Data.user.main.model.user._id === o.creatorUserId) o.tools = true;
|
|
68
69
|
o.id = o._id;
|
|
69
|
-
|
|
70
|
-
o.end = dateFormat(o.end);
|
|
70
|
+
|
|
71
71
|
this.Data[options.idModal].filesData.push({});
|
|
72
72
|
return o;
|
|
73
73
|
});
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
renderCalendar(
|
|
76
|
+
resultData.map((o) => {
|
|
77
|
+
// FREQ=WEEKLY;
|
|
78
|
+
// if (o.daysOfWeek && o.daysOfWeek.length > 0) {
|
|
79
|
+
// o.rrule = `RRULE:BYDAY=${o.daysOfWeek.map((d) => `${d[0]}${d[1]}`.toUpperCase()).join(',')}`;
|
|
80
|
+
// }
|
|
81
|
+
// o.rrule = 'FREQ=WEEKLY;BYDAY=SU;BYHOUR=10,11;COUNT=10';
|
|
82
|
+
if (o.daysOfWeek && o.daysOfWeek.length > 0)
|
|
83
|
+
o.daysOfWeek = o.daysOfWeek.map((v, i) => daysOfWeekOptions.indexOf(v));
|
|
84
|
+
else delete o.daysOfWeek;
|
|
85
|
+
// o.exdate = ['2024-04-02'];
|
|
86
|
+
// delete o.end;
|
|
87
|
+
// delete o.start;
|
|
88
|
+
|
|
89
|
+
return o;
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
});
|
|
74
93
|
}
|
|
75
94
|
};
|
|
76
95
|
|
|
77
|
-
const renderCalendar = () => {
|
|
96
|
+
const renderCalendar = (events) => {
|
|
78
97
|
const calendarEl = s(`.calendar-${idPanel}`);
|
|
79
98
|
this.Data[options.idModal].calendar = new FullCalendar.Calendar(calendarEl, {
|
|
80
|
-
|
|
99
|
+
allDaySlot: false,
|
|
100
|
+
plugins: [
|
|
101
|
+
FullCalendar.DayGrid.default,
|
|
102
|
+
FullCalendar.TimeGrid.default,
|
|
103
|
+
FullCalendar.List.default,
|
|
104
|
+
// https://fullcalendar.io/docs/rrule-plugin
|
|
105
|
+
FullCalendar.RRule.default,
|
|
106
|
+
],
|
|
81
107
|
// initialView: 'dayGridWeek',
|
|
82
108
|
timeZone: getTimeZone(),
|
|
83
109
|
dateClick: function (arg) {
|
|
84
110
|
console.error('calendar dateClick', arg.date.toString());
|
|
85
111
|
},
|
|
86
|
-
events: [{ title: 'Meeting', start: new Date() }],
|
|
112
|
+
events: events ?? [{ title: 'Meeting', start: new Date() }],
|
|
87
113
|
initialView: 'dayGridMonth',
|
|
88
114
|
headerToolbar: {
|
|
89
115
|
left: 'prev,next today',
|
|
90
116
|
center: 'title',
|
|
91
117
|
right: 'dayGridMonth,timeGridWeek,listWeek',
|
|
92
118
|
},
|
|
119
|
+
eventClick: async function (args) {
|
|
120
|
+
const dateData = eventDateFactory(args.event);
|
|
121
|
+
// element -> args.el
|
|
122
|
+
// remove all events associated -> args.event.remove();
|
|
123
|
+
// console.error('eventClick', JSON.stringify(dateData, null, 4));
|
|
124
|
+
if (options.eventClick) await options.eventClick(dateData, args);
|
|
125
|
+
},
|
|
126
|
+
eventClassNames: function (args) {
|
|
127
|
+
// console.error('eventClassNames', JSON.stringify(dateData, null, 4));
|
|
128
|
+
if (!args.event.extendedProps._id) return args.event.remove();
|
|
129
|
+
const dateData = eventDateFactory(args.event);
|
|
130
|
+
if (
|
|
131
|
+
new Date(dateData.start).getTime() <= new Date().getTime() ||
|
|
132
|
+
CalendarCore.Data[options.idModal].hiddenDates.find(
|
|
133
|
+
(d) => d.eventSchedulerId === dateData.event._id && d.date === dateData.start,
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
return ['hide'];
|
|
137
|
+
},
|
|
93
138
|
});
|
|
94
139
|
|
|
95
140
|
this.Data[options.idModal].calendar.render();
|
|
@@ -139,29 +184,52 @@ const CalendarCore = {
|
|
|
139
184
|
rules: [{ type: 'isEmpty' }],
|
|
140
185
|
},
|
|
141
186
|
{
|
|
142
|
-
id: '
|
|
143
|
-
model: '
|
|
187
|
+
id: 'title',
|
|
188
|
+
model: 'title',
|
|
144
189
|
inputType: 'text',
|
|
145
190
|
rules: [{ type: 'isEmpty' }],
|
|
146
191
|
panel: { type: 'title' },
|
|
147
192
|
},
|
|
148
193
|
{
|
|
149
|
-
id: '
|
|
150
|
-
model: '
|
|
151
|
-
inputType: '
|
|
152
|
-
rules: [],
|
|
153
|
-
panel: { type: 'info-row'
|
|
194
|
+
id: 'description',
|
|
195
|
+
model: 'description',
|
|
196
|
+
inputType: 'text',
|
|
197
|
+
rules: [{ type: 'isEmpty' }],
|
|
198
|
+
panel: { type: 'info-row' },
|
|
154
199
|
},
|
|
155
200
|
{
|
|
156
201
|
id: 'start',
|
|
157
202
|
model: 'start',
|
|
158
203
|
inputType: 'datetime-local',
|
|
159
|
-
|
|
204
|
+
translateCode: 'startTime',
|
|
205
|
+
panel: { type: 'info-row' },
|
|
160
206
|
},
|
|
161
207
|
{
|
|
162
208
|
id: 'end',
|
|
163
209
|
model: 'end',
|
|
164
210
|
inputType: 'datetime-local',
|
|
211
|
+
translateCode: 'endTime',
|
|
212
|
+
panel: { type: 'info-row' },
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
id: 'daysOfWeek',
|
|
216
|
+
model: 'daysOfWeek',
|
|
217
|
+
inputType: 'dropdown-checkbox',
|
|
218
|
+
dropdown: {
|
|
219
|
+
options: daysOfWeekOptions,
|
|
220
|
+
},
|
|
221
|
+
panel: { type: 'list' },
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
id: 'startTime',
|
|
225
|
+
model: 'startTime',
|
|
226
|
+
inputType: 'time',
|
|
227
|
+
panel: { type: 'info-row' },
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: 'endTime',
|
|
231
|
+
model: 'endTime',
|
|
232
|
+
inputType: 'time',
|
|
165
233
|
panel: { type: 'info-row' },
|
|
166
234
|
},
|
|
167
235
|
];
|
|
@@ -209,14 +277,14 @@ const CalendarCore = {
|
|
|
209
277
|
data: this.Data[options.idModal].data,
|
|
210
278
|
formContainerClass: '',
|
|
211
279
|
scrollClassContainer: `main-body-calendar-${options.idModal}`,
|
|
280
|
+
role: options.role,
|
|
212
281
|
originData: () => this.Data[options.idModal].originData,
|
|
213
282
|
filesData: () => this.Data[options.idModal].filesData,
|
|
214
283
|
onClick: async function ({ payload }) {
|
|
215
284
|
if (options.route) {
|
|
216
285
|
setQueryPath({ path: options.route, queryPath: payload._id });
|
|
217
286
|
if (options.parentIdModal) Modal.Data[options.parentIdModal].query = `${window.location.search}`;
|
|
218
|
-
|
|
219
|
-
await CalendarCore.Data[options.idModal].updatePanel();
|
|
287
|
+
await CalendarCore.Data[options.idModal].updatePanel();
|
|
220
288
|
}
|
|
221
289
|
},
|
|
222
290
|
titleIcon,
|
|
@@ -250,12 +318,19 @@ const CalendarCore = {
|
|
|
250
318
|
],
|
|
251
319
|
on: {
|
|
252
320
|
add: async function ({ data, editId }) {
|
|
321
|
+
if (data.daysOfWeek && data.daysOfWeek.length > 0 && daysOfWeekOptions[data.daysOfWeek[0]]) {
|
|
322
|
+
data.daysOfWeek = data.daysOfWeek.map((d) => daysOfWeekOptions[d]);
|
|
323
|
+
}
|
|
324
|
+
data.timeZoneClient = getTimeZone();
|
|
253
325
|
const {
|
|
254
326
|
status,
|
|
255
327
|
message,
|
|
256
328
|
data: documentData,
|
|
257
329
|
} = editId
|
|
258
|
-
? await EventSchedulerService.put({
|
|
330
|
+
? await EventSchedulerService.put({
|
|
331
|
+
id: editId,
|
|
332
|
+
body: { ...data, _id: undefined },
|
|
333
|
+
})
|
|
259
334
|
: await EventSchedulerService.post({ body: data });
|
|
260
335
|
NotificationManager.Push({
|
|
261
336
|
html:
|
|
@@ -268,10 +343,9 @@ const CalendarCore = {
|
|
|
268
343
|
});
|
|
269
344
|
|
|
270
345
|
if (status === 'success') {
|
|
271
|
-
|
|
272
|
-
data.
|
|
273
|
-
data
|
|
274
|
-
data._id = documentData._id;
|
|
346
|
+
documentData.tools = true;
|
|
347
|
+
// data._id = documentData._id;
|
|
348
|
+
data = documentData;
|
|
275
349
|
|
|
276
350
|
let originObj, indexOriginObj;
|
|
277
351
|
let filesData = {};
|
|
@@ -291,8 +365,7 @@ const CalendarCore = {
|
|
|
291
365
|
|
|
292
366
|
setQueryPath({ path: options.route, queryPath: documentData._id });
|
|
293
367
|
if (options.parentIdModal) Modal.Data[options.parentIdModal].query = `${window.location.search}`;
|
|
294
|
-
|
|
295
|
-
await CalendarCore.Data[options.idModal].updatePanel();
|
|
368
|
+
await CalendarCore.Data[options.idModal].updatePanel();
|
|
296
369
|
}
|
|
297
370
|
return { data, status, message };
|
|
298
371
|
},
|
|
@@ -319,11 +392,8 @@ const CalendarCore = {
|
|
|
319
392
|
status,
|
|
320
393
|
});
|
|
321
394
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (CalendarCore.Data[options.idModal].updatePanel)
|
|
325
|
-
await CalendarCore.Data[options.idModal].updatePanel();
|
|
326
|
-
}
|
|
395
|
+
setQueryPath({ path: options.route, queryPath: '' });
|
|
396
|
+
await CalendarCore.Data[options.idModal].updatePanel();
|
|
327
397
|
|
|
328
398
|
return { status };
|
|
329
399
|
}
|
|
@@ -334,17 +404,13 @@ const CalendarCore = {
|
|
|
334
404
|
<div class="in" style="margin-bottom: 100px"></div>`;
|
|
335
405
|
};
|
|
336
406
|
|
|
337
|
-
let lastCid;
|
|
338
|
-
let lasUserId;
|
|
339
407
|
this.Data[options.idModal].updatePanel = async () => {
|
|
340
408
|
const cid = getQueryParams().cid ? getQueryParams().cid : '';
|
|
341
|
-
if (lastCid === cid && lasUserId === options.Elements.Data.user.main.model.user._id) return;
|
|
342
409
|
if (options.route === 'home') Modal.homeCid = newInstance(cid);
|
|
343
|
-
lasUserId = newInstance(options.Elements.Data.user.main.model.user._id);
|
|
344
|
-
lastCid = cid;
|
|
345
410
|
if (s(`.main-body-calendar-${options.idModal}`)) {
|
|
346
|
-
if (Auth.getToken())
|
|
347
|
-
else getSrrData();
|
|
411
|
+
// if (Auth.getToken())
|
|
412
|
+
// else getSrrData();
|
|
413
|
+
await getPanelData();
|
|
348
414
|
htmls(`.main-body-calendar-${options.idModal}`, await panelRender());
|
|
349
415
|
}
|
|
350
416
|
};
|
|
@@ -518,25 +518,25 @@ function getDirname(path) {
|
|
|
518
518
|
return parts.join('/'); // Adjust separator if needed for Windows ('\')
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
-
const isDayValid = (day) => {
|
|
522
|
-
const date = new Date();
|
|
523
|
-
date.setDate(day);
|
|
524
|
-
return date.getDate() === day;
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
const isMonthValid = (month) => {
|
|
528
|
-
const date = new Date();
|
|
529
|
-
date.setMonth(month - 1);
|
|
530
|
-
return date.getMonth() === month - 1;
|
|
531
|
-
};
|
|
532
|
-
|
|
533
521
|
const isValidDate = (day, month, year) => {
|
|
534
|
-
if (!
|
|
535
|
-
|
|
536
|
-
|
|
522
|
+
if (!month && !year) return !(new Date(day) == 'Invalid Date');
|
|
523
|
+
// new Date('2025-12-28')
|
|
524
|
+
// Sat Dec 27 2025 19:00:00 GMT-0500 (Eastern Standard Time)
|
|
525
|
+
// new Date('2025/12/28')
|
|
526
|
+
// Sun Dec 28 2025 00:00:00 GMT-0500 (Eastern Standard Time)
|
|
527
|
+
return !(new Date(`${year}/${month}/${day}`) == 'Invalid Date');
|
|
528
|
+
};
|
|
537
529
|
|
|
538
|
-
|
|
539
|
-
|
|
530
|
+
// console.log(req.body.timeZoneClient, Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
531
|
+
// DateTime.fromISO("2017-05-15T09:10:23", { zone: "Europe/Paris" });
|
|
532
|
+
const strToDateUTC = (date = '2025-01-30T14:32') => {
|
|
533
|
+
const year = parseInt(date.split('-')[0]);
|
|
534
|
+
const month = parseInt(date.split('-')[1]);
|
|
535
|
+
const day = parseInt(date.split('-')[2].split('T')[0]);
|
|
536
|
+
const hour = parseInt(date.split('T')[1].split(':')[0]);
|
|
537
|
+
const minute = parseInt(date.split('T')[1].split(':')[1]);
|
|
538
|
+
date = new Date(Date.UTC(year, month - 1, day, hour, minute, 0, 0));
|
|
539
|
+
return date;
|
|
540
540
|
};
|
|
541
541
|
|
|
542
542
|
const isValidFormat = (value, format) => {
|
|
@@ -662,6 +662,22 @@ function componentFromStr(numStr, percent) {
|
|
|
662
662
|
return percent ? Math.floor((255 * Math.min(100, num)) / 100) : Math.min(255, num);
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
+
const isChileanIdentityDocument = function (rutCompleto) {
|
|
666
|
+
const dv = function (T) {
|
|
667
|
+
let M = 0,
|
|
668
|
+
S = 1;
|
|
669
|
+
for (; T; T = Math.floor(T / 10)) S = (S + (T % 10) * (9 - (M++ % 6))) % 11;
|
|
670
|
+
return S ? S - 1 : 'k';
|
|
671
|
+
};
|
|
672
|
+
rutCompleto = rutCompleto.replace('‐', '-');
|
|
673
|
+
if (!/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test(rutCompleto)) return false;
|
|
674
|
+
var tmp = rutCompleto.split('-');
|
|
675
|
+
var digv = tmp[1];
|
|
676
|
+
var rut = tmp[0];
|
|
677
|
+
if (digv == 'K') digv = 'k';
|
|
678
|
+
return dv(rut) == digv;
|
|
679
|
+
};
|
|
680
|
+
|
|
665
681
|
function rgbToHex(rgb) {
|
|
666
682
|
const rgbRegex = /^rgb\(\s*(-?\d+)(%?)\s*,\s*(-?\d+)(%?)\s*,\s*(-?\d+)(%?)\s*\)$/;
|
|
667
683
|
let result,
|
|
@@ -685,10 +701,121 @@ const hexToNumber = (hex = 0xdc) => Number(hex) || parseFloat(hex, 16);
|
|
|
685
701
|
|
|
686
702
|
const numberToHex = (number = 0) => number.toString(16);
|
|
687
703
|
|
|
704
|
+
const generateRandomPasswordSelection = (length) => {
|
|
705
|
+
const _random = (arr) => {
|
|
706
|
+
const rand = Math.floor(Math.random() * arr.length);
|
|
707
|
+
return arr[rand];
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
const uppercase = [
|
|
711
|
+
'A',
|
|
712
|
+
'B',
|
|
713
|
+
'C',
|
|
714
|
+
'D',
|
|
715
|
+
'E',
|
|
716
|
+
'F',
|
|
717
|
+
'G',
|
|
718
|
+
'H',
|
|
719
|
+
'I',
|
|
720
|
+
'J',
|
|
721
|
+
'K',
|
|
722
|
+
'L',
|
|
723
|
+
'M',
|
|
724
|
+
'N',
|
|
725
|
+
'O',
|
|
726
|
+
'P',
|
|
727
|
+
'Q',
|
|
728
|
+
'R',
|
|
729
|
+
'S',
|
|
730
|
+
'T',
|
|
731
|
+
'U',
|
|
732
|
+
'V',
|
|
733
|
+
'W',
|
|
734
|
+
'X',
|
|
735
|
+
'Y',
|
|
736
|
+
'Z',
|
|
737
|
+
];
|
|
738
|
+
const lowercase = [
|
|
739
|
+
'a',
|
|
740
|
+
'b',
|
|
741
|
+
'c',
|
|
742
|
+
'd',
|
|
743
|
+
'e',
|
|
744
|
+
'f',
|
|
745
|
+
'g',
|
|
746
|
+
'h',
|
|
747
|
+
'i',
|
|
748
|
+
'j',
|
|
749
|
+
'k',
|
|
750
|
+
'l',
|
|
751
|
+
'm',
|
|
752
|
+
'n',
|
|
753
|
+
'o',
|
|
754
|
+
'p',
|
|
755
|
+
'q',
|
|
756
|
+
'r',
|
|
757
|
+
's',
|
|
758
|
+
't',
|
|
759
|
+
'u',
|
|
760
|
+
'v',
|
|
761
|
+
'w',
|
|
762
|
+
'x',
|
|
763
|
+
'y',
|
|
764
|
+
'z',
|
|
765
|
+
];
|
|
766
|
+
const special = [
|
|
767
|
+
'~',
|
|
768
|
+
'!',
|
|
769
|
+
'@',
|
|
770
|
+
'#',
|
|
771
|
+
'$',
|
|
772
|
+
'%',
|
|
773
|
+
'^',
|
|
774
|
+
'&',
|
|
775
|
+
'*',
|
|
776
|
+
'(',
|
|
777
|
+
')',
|
|
778
|
+
'_',
|
|
779
|
+
'+',
|
|
780
|
+
'-',
|
|
781
|
+
'=',
|
|
782
|
+
'{',
|
|
783
|
+
'}',
|
|
784
|
+
'[',
|
|
785
|
+
']',
|
|
786
|
+
':',
|
|
787
|
+
';',
|
|
788
|
+
'?',
|
|
789
|
+
',',
|
|
790
|
+
'.',
|
|
791
|
+
'|',
|
|
792
|
+
'\\',
|
|
793
|
+
];
|
|
794
|
+
const numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
795
|
+
|
|
796
|
+
const nonSpecial = [...uppercase, ...lowercase, ...numbers];
|
|
797
|
+
|
|
798
|
+
let password = '';
|
|
799
|
+
|
|
800
|
+
for (let i = 0; i < length; i++) {
|
|
801
|
+
// Previous character is a special character
|
|
802
|
+
if (i !== 0 && special.includes(password[i - 1])) {
|
|
803
|
+
password += _random(nonSpecial);
|
|
804
|
+
} else password += _random([...nonSpecial, ...special]);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
return password;
|
|
808
|
+
};
|
|
809
|
+
|
|
688
810
|
// 0x = Hexadecimal
|
|
689
811
|
// 0b = Binary
|
|
690
812
|
// 0o = Octal
|
|
691
813
|
|
|
814
|
+
const userRoleEnum = ['admin', 'moderator', 'user', 'guest'];
|
|
815
|
+
|
|
816
|
+
const commonAdminGuard = (role) => userRoleEnum.indexOf(role) === userRoleEnum.indexOf('admin');
|
|
817
|
+
const commonModeratorGuard = (role) => userRoleEnum.indexOf(role) <= userRoleEnum.indexOf('moderator');
|
|
818
|
+
|
|
692
819
|
export {
|
|
693
820
|
s4,
|
|
694
821
|
range,
|
|
@@ -727,10 +854,9 @@ export {
|
|
|
727
854
|
getSubpaths,
|
|
728
855
|
formatBytes,
|
|
729
856
|
getDirname,
|
|
730
|
-
isDayValid,
|
|
731
|
-
isMonthValid,
|
|
732
857
|
isValidDate,
|
|
733
858
|
isValidFormat,
|
|
859
|
+
strToDateUTC,
|
|
734
860
|
getTimezoneOffset,
|
|
735
861
|
cleanString,
|
|
736
862
|
splitEveryXChar,
|
|
@@ -742,4 +868,9 @@ export {
|
|
|
742
868
|
getCapVariableName,
|
|
743
869
|
hexToNumber,
|
|
744
870
|
numberToHex,
|
|
871
|
+
generateRandomPasswordSelection,
|
|
872
|
+
userRoleEnum,
|
|
873
|
+
commonAdminGuard,
|
|
874
|
+
commonModeratorGuard,
|
|
875
|
+
isChileanIdentityDocument,
|
|
745
876
|
};
|
|
@@ -117,6 +117,12 @@ const CssCommonCore = async () => {
|
|
|
117
117
|
animation: ripple 600ms linear;
|
|
118
118
|
background-color: rgba(137, 137, 137, 0.503);
|
|
119
119
|
}
|
|
120
|
+
.slide-menu-top-bar-fix {
|
|
121
|
+
top: 0;
|
|
122
|
+
left: 0;
|
|
123
|
+
width: 100%;
|
|
124
|
+
z-index: 1;
|
|
125
|
+
}
|
|
120
126
|
@keyframes ripple {
|
|
121
127
|
to {
|
|
122
128
|
transform: scale(4);
|
|
@@ -16,7 +16,11 @@ const DropDown = {
|
|
|
16
16
|
onClick: () => {
|
|
17
17
|
console.log('DropDown onClick', this.value);
|
|
18
18
|
if (options && options.resetOnClick) options.resetOnClick();
|
|
19
|
-
|
|
19
|
+
if (options && options.type === 'checkbox')
|
|
20
|
+
for (const opt of DropDown.Tokens[id].value) {
|
|
21
|
+
s(`.dropdown-option-${id}-${opt}`).click();
|
|
22
|
+
}
|
|
23
|
+
else this.Tokens[id].value = undefined;
|
|
20
24
|
},
|
|
21
25
|
});
|
|
22
26
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AgGrid } from './AgGrid.js';
|
|
2
2
|
import { BtnIcon } from './BtnIcon.js';
|
|
3
|
+
import { isValidDate } from './CommonJs.js';
|
|
3
4
|
import { darkTheme } from './Css.js';
|
|
5
|
+
import { DropDown } from './DropDown.js';
|
|
4
6
|
import { loggerFactory } from './Logger.js';
|
|
5
7
|
import { RichText } from './RichText.js';
|
|
6
8
|
import { ToggleSwitch } from './ToggleSwitch.js';
|
|
@@ -147,6 +149,10 @@ const Input = {
|
|
|
147
149
|
htmls(`.file-name-render-${inputData.id}`, `${s(`.${inputData.id}`).fileNameInputExtDefaultContent}`);
|
|
148
150
|
continue;
|
|
149
151
|
break;
|
|
152
|
+
case 'dropdown-checkbox': {
|
|
153
|
+
s(`.dropdown-option-${inputData.id}-reset`).click();
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
150
156
|
case 'md':
|
|
151
157
|
RichText.Tokens[inputData.id].easyMDE.value('');
|
|
152
158
|
continue;
|
|
@@ -196,6 +202,12 @@ const Input = {
|
|
|
196
202
|
RichText.Tokens[inputData.id].easyMDE.value(fileObj[inputData.model].mdPlain);
|
|
197
203
|
continue;
|
|
198
204
|
break;
|
|
205
|
+
|
|
206
|
+
case 'dropdown-checkbox': {
|
|
207
|
+
s(`.dropdown-option-${inputData.id}-reset`).click();
|
|
208
|
+
for (const opt of originObj[inputData.model]) s(`.dropdown-option-${inputData.id}-${opt}`).click();
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
199
211
|
case 'checkbox':
|
|
200
212
|
case 'checkbox-on-off':
|
|
201
213
|
if (
|
|
@@ -207,9 +219,11 @@ const Input = {
|
|
|
207
219
|
break;
|
|
208
220
|
case 'datetime-local':
|
|
209
221
|
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
222
|
+
if (isValidDate(originObj[inputData.model])) {
|
|
223
|
+
const date = new Date(originObj[inputData.model]);
|
|
224
|
+
// date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
|
|
225
|
+
s(`.${inputData.id}`).value = date.toISOString().slice(0, 16);
|
|
226
|
+
} else s(`.${inputData.id}`).value = null;
|
|
213
227
|
}
|
|
214
228
|
continue;
|
|
215
229
|
break;
|
|
@@ -403,6 +403,11 @@ const Modal = {
|
|
|
403
403
|
})}
|
|
404
404
|
</div>
|
|
405
405
|
</div>
|
|
406
|
+
${options?.slideMenuTopBarFix
|
|
407
|
+
? html`<div class="abs modal slide-menu-top-bar-fix" style="height: ${options.heightTopBar}px">
|
|
408
|
+
${await options.slideMenuTopBarFix()}
|
|
409
|
+
</div>`
|
|
410
|
+
: ''}
|
|
406
411
|
</div>`,
|
|
407
412
|
);
|
|
408
413
|
EventsUI.onClick(`.action-btn-profile-log-in`, () => {
|
|
@@ -537,12 +542,12 @@ const Modal = {
|
|
|
537
542
|
if (routerId) {
|
|
538
543
|
if (
|
|
539
544
|
s(`.main-btn-${routerId}`) &&
|
|
540
|
-
(routerId.
|
|
545
|
+
(routerId.toLowerCase().match(s(`.${id}`).value.toLowerCase()) ||
|
|
541
546
|
(Translate.Data[routerId] &&
|
|
542
547
|
Object.keys(Translate.Data[routerId]).filter((keyLang) =>
|
|
543
548
|
Translate.Data[routerId][keyLang]
|
|
544
|
-
.
|
|
545
|
-
.match(s(`.${id}`).value.
|
|
549
|
+
.toLowerCase()
|
|
550
|
+
.match(s(`.${id}`).value.toLowerCase()),
|
|
546
551
|
).length > 0))
|
|
547
552
|
) {
|
|
548
553
|
const fontAwesomeIcon = getAllChildNodes(s(`.main-btn-${routerId}`)).find((e) => {
|
|
@@ -1691,7 +1696,7 @@ const Modal = {
|
|
|
1691
1696
|
const htmlRender = html`
|
|
1692
1697
|
<br />
|
|
1693
1698
|
<div class="in section-mp" style="font-size: 40px; text-align: center">
|
|
1694
|
-
<i class="fas fa-question-circle"></i
|
|
1699
|
+
${options.icon ? options.icon : html` <i class="fas fa-question-circle"></i>`}
|
|
1695
1700
|
</div>
|
|
1696
1701
|
${await options.html()}
|
|
1697
1702
|
<div class="in section-mp">
|
|
@@ -1702,7 +1707,7 @@ const Modal = {
|
|
|
1702
1707
|
style: `margin: auto`,
|
|
1703
1708
|
})}
|
|
1704
1709
|
</div>
|
|
1705
|
-
<div class="in section-mp">
|
|
1710
|
+
<div class="in section-mp ${options.disableBtnCancel ? 'hide' : ''}">
|
|
1706
1711
|
${await BtnIcon.Render({
|
|
1707
1712
|
class: `in section-mp form-button btn-cancel-${id}`,
|
|
1708
1713
|
label: Translate.Render('cancel'),
|