underpost 2.8.1 → 2.8.41
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 +115 -136
- 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
package/package.json
CHANGED
|
@@ -1,137 +1,116 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"swagger-ui-express": "^5.0.0",
|
|
118
|
-
"systeminformation": "^5.23.7",
|
|
119
|
-
"uglify-js": "^3.17.4",
|
|
120
|
-
"validator": "^13.11.0",
|
|
121
|
-
"vanilla-jsoneditor": "^2.3.2",
|
|
122
|
-
"web3": "^4.13.0",
|
|
123
|
-
"winston": "^3.11.0"
|
|
124
|
-
},
|
|
125
|
-
"devDependencies": {
|
|
126
|
-
"clean-jsdoc-theme": "^4.3.0",
|
|
127
|
-
"easy-json-schema": "^0.0.2-beta",
|
|
128
|
-
"mocha": "^10.4.0",
|
|
129
|
-
"plantuml": "^0.0.2",
|
|
130
|
-
"swagger-autogen": "^2.23.7"
|
|
131
|
-
},
|
|
132
|
-
"publishConfig": {
|
|
133
|
-
"provenance": true,
|
|
134
|
-
"access": "public",
|
|
135
|
-
"registry": "https://registry.npmjs.org/"
|
|
136
|
-
}
|
|
137
|
-
}
|
|
2
|
+
"type": "module",
|
|
3
|
+
"main": "src/index.js",
|
|
4
|
+
"name": "underpost",
|
|
5
|
+
"version": "2.8.41",
|
|
6
|
+
"description": "pwa api rest template",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
9
|
+
"build": "node bin/deploy build-full-client",
|
|
10
|
+
"dev": "env-cmd -f .env.development node src/client.dev default",
|
|
11
|
+
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
12
|
+
"docs": "jsdoc -c jsdoc.json",
|
|
13
|
+
"install-global": "npm install -g pm2 && npm install -g jsdoc && npm install -g prettier && npm install -g env-cmd && npm install -g yarn && npm install -g auto-changelog",
|
|
14
|
+
"install-test": "npm install -g mocha && npm install -g c8 && npm install -g nyc && npm install -g coveralls",
|
|
15
|
+
"install": "npm run install-global && npm run install-test",
|
|
16
|
+
"docker:start": "docker-compose up",
|
|
17
|
+
"prettier": "prettier --write .",
|
|
18
|
+
"test": "env-cmd -f .env.test c8 mocha"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"underpost": "bin/index.js"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/underpostnet/pwa-microservices-template.git"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"engine",
|
|
29
|
+
"server",
|
|
30
|
+
"proxy",
|
|
31
|
+
"client"
|
|
32
|
+
],
|
|
33
|
+
"author": "https://github.com/underpostnet",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/underpostnet/pwa-microservices-template/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/underpostnet/pwa-microservices-template#readme",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@fortawesome/fontawesome-free": "^6.4.2",
|
|
41
|
+
"@fullcalendar/rrule": "^6.1.15",
|
|
42
|
+
"@loadingio/css-spinner": "^2.0.2",
|
|
43
|
+
"@neodrag/vanilla": "^2.0.3",
|
|
44
|
+
"adm-zip": "^0.5.10",
|
|
45
|
+
"ag-grid-community": "31.0.0",
|
|
46
|
+
"axios": "^1.5.1",
|
|
47
|
+
"chai": "^5.1.0",
|
|
48
|
+
"cli-progress": "^3.12.0",
|
|
49
|
+
"cli-spinners": "^3.0.0",
|
|
50
|
+
"clipboardy": "^4.0.0",
|
|
51
|
+
"color": "^4.2.3",
|
|
52
|
+
"colors": "^1.4.0",
|
|
53
|
+
"commander": "^12.1.0",
|
|
54
|
+
"compression": "^1.7.4",
|
|
55
|
+
"cors": "^2.8.5",
|
|
56
|
+
"d3": "^7.9.0",
|
|
57
|
+
"dotenv": "^16.3.1",
|
|
58
|
+
"easymde": "^2.18.0",
|
|
59
|
+
"env-cmd": "^10.1.0",
|
|
60
|
+
"express": "^4.18.2",
|
|
61
|
+
"express-fileupload": "^1.4.3",
|
|
62
|
+
"favicons": "^7.2.0",
|
|
63
|
+
"font-awesome-assets": "^0.0.9",
|
|
64
|
+
"fs-extra": "^11.1.1",
|
|
65
|
+
"fullcalendar": "^6.1.15",
|
|
66
|
+
"html-minifier-terser": "^7.2.0",
|
|
67
|
+
"http-proxy-middleware": "^2.0.6",
|
|
68
|
+
"ignore-walk": "^6.0.4",
|
|
69
|
+
"iovalkey": "^0.2.1",
|
|
70
|
+
"jimp": "^0.22.12",
|
|
71
|
+
"joystick-controller": "^1.0.15",
|
|
72
|
+
"json-colorizer": "^2.2.2",
|
|
73
|
+
"jsonwebtoken": "^9.0.2",
|
|
74
|
+
"keyword-extractor": "^0.0.28",
|
|
75
|
+
"log-update": "^6.0.0",
|
|
76
|
+
"mariadb": "^3.2.2",
|
|
77
|
+
"marked": "^12.0.2",
|
|
78
|
+
"mongoose": "^8.9.5",
|
|
79
|
+
"morgan": "^1.10.0",
|
|
80
|
+
"nodemailer": "^6.9.9",
|
|
81
|
+
"nodemon": "^3.0.1",
|
|
82
|
+
"pathfinding": "^0.4.18",
|
|
83
|
+
"peer": "^1.0.2",
|
|
84
|
+
"peerjs": "^1.5.2",
|
|
85
|
+
"pixi.js": "7.4.2",
|
|
86
|
+
"prom-client": "^15.1.2",
|
|
87
|
+
"public-ip": "^6.0.1",
|
|
88
|
+
"read": "^2.1.0",
|
|
89
|
+
"rrule": "^2.8.1",
|
|
90
|
+
"sharp": "^0.32.5",
|
|
91
|
+
"shelljs": "^0.8.5",
|
|
92
|
+
"simple-icons": "^13.9.0",
|
|
93
|
+
"sitemap": "^7.1.1",
|
|
94
|
+
"socket.io": "^4.8.0",
|
|
95
|
+
"sortablejs": "^1.15.0",
|
|
96
|
+
"split-file": "^2.3.0",
|
|
97
|
+
"swagger-ui-express": "^5.0.0",
|
|
98
|
+
"systeminformation": "^5.23.7",
|
|
99
|
+
"uglify-js": "^3.17.4",
|
|
100
|
+
"validator": "^13.11.0",
|
|
101
|
+
"vanilla-jsoneditor": "^2.3.2",
|
|
102
|
+
"winston": "^3.11.0"
|
|
103
|
+
},
|
|
104
|
+
"devDependencies": {
|
|
105
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
106
|
+
"easy-json-schema": "^0.0.2-beta",
|
|
107
|
+
"mocha": "^10.4.0",
|
|
108
|
+
"plantuml": "^0.0.2",
|
|
109
|
+
"swagger-autogen": "^2.23.7"
|
|
110
|
+
},
|
|
111
|
+
"publishConfig": {
|
|
112
|
+
"provenance": true,
|
|
113
|
+
"access": "public",
|
|
114
|
+
"registry": "https://registry.npmjs.org/"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Schema, model } from 'mongoose';
|
|
2
2
|
import validator from 'validator';
|
|
3
|
+
import { userRoleEnum } from '../../client/components/core/CommonJs.js';
|
|
3
4
|
|
|
4
5
|
// https://mongoosejs.com/docs/2.7.x/docs/schematypes.html
|
|
5
6
|
|
|
6
|
-
const userRoleEnum = ['admin', 'moderator', 'user', 'guest'];
|
|
7
|
-
|
|
8
7
|
const UserSchema = new Schema(
|
|
9
8
|
{
|
|
10
9
|
email: {
|
|
@@ -26,7 +25,11 @@ const UserSchema = new Schema(
|
|
|
26
25
|
profileImageId: { type: Schema.Types.ObjectId, ref: 'File' },
|
|
27
26
|
phoneNumbers: [
|
|
28
27
|
{
|
|
29
|
-
type: {
|
|
28
|
+
type: {
|
|
29
|
+
type: String,
|
|
30
|
+
enum: ['office', 'home', 'private'],
|
|
31
|
+
},
|
|
32
|
+
number: { type: String },
|
|
30
33
|
},
|
|
31
34
|
],
|
|
32
35
|
publicKey: {
|
|
@@ -38,6 +41,12 @@ const UserSchema = new Schema(
|
|
|
38
41
|
],
|
|
39
42
|
default: [],
|
|
40
43
|
},
|
|
44
|
+
associatedCompanies: [
|
|
45
|
+
{
|
|
46
|
+
company: { type: Schema.Types.ObjectId, ref: 'Company', required: true },
|
|
47
|
+
context: [{ type: String, enum: ['client', 'supplier', 'employee', 'owner'] }],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
41
50
|
},
|
|
42
51
|
{
|
|
43
52
|
timestamps: true,
|
|
@@ -58,6 +67,10 @@ const UserDto = {
|
|
|
58
67
|
},
|
|
59
68
|
},
|
|
60
69
|
auth: {
|
|
70
|
+
// TODO: -> set login device, location, ip, fingerprint
|
|
71
|
+
// and validate on authorization middleware
|
|
72
|
+
// -> dynamic refresh 100 tokens per session with 12h interval
|
|
73
|
+
// -> back secret per user, registrarion user model -> secret: { type: String }
|
|
61
74
|
payload: (user) => ({ _id: user._id.toString(), role: user.role, email: user.email }),
|
|
62
75
|
},
|
|
63
76
|
};
|
|
@@ -237,7 +237,7 @@ const UserService = {
|
|
|
237
237
|
const validatePassword = validatePasswordMiddleware(req.body.password);
|
|
238
238
|
if (validatePassword.status === 'error') throw new Error(validatePassword.message);
|
|
239
239
|
req.body.password = await hashPassword(req.body.password);
|
|
240
|
-
req.body.role = 'user';
|
|
240
|
+
req.body.role = req.body.role === 'guest' ? 'guest' : 'user';
|
|
241
241
|
req.body.profileImageId = await getDefaultProfileImageId(File);
|
|
242
242
|
const { _id } = await new User(req.body).save();
|
|
243
243
|
if (_id) {
|
|
@@ -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
|
};
|