underpost 2.7.1 → 2.7.2
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 +13 -13
- package/.env.development +7 -7
- package/.env.production +7 -7
- package/.env.test +7 -7
- package/.github/workflows/publish.yml +26 -0
- package/.nycrc +9 -9
- package/.prettierignore +12 -12
- package/.prettierrc +9 -9
- package/.vscode/extensions.json +72 -72
- package/.vscode/settings.json +100 -99
- package/Dockerfile +89 -89
- package/LICENSE +21 -21
- package/README.md +96 -96
- package/bin/db.js +172 -119
- package/bin/deploy.js +582 -661
- package/bin/dns.js +1 -1
- package/bin/file.js +92 -92
- package/bin/index.js +53 -53
- package/bin/install.js +398 -357
- package/bin/shortcut.js +44 -44
- package/bin/ssl.js +65 -64
- package/bin/util.js +182 -182
- package/bin/vs.js +35 -35
- package/conf.js +251 -249
- package/docker-compose.yml +67 -67
- package/jsconfig.json +7 -7
- package/jsdoc.json +32 -32
- package/nodemon.json +6 -6
- package/package.json +137 -132
- package/prometheus.yml +36 -36
- package/setup.sh +24 -24
- package/src/api/core/core.controller.js +69 -69
- package/src/api/core/core.model.js +11 -11
- package/src/api/core/core.router.js +23 -23
- package/src/api/core/core.service.js +29 -29
- package/src/api/crypto/crypto.controller.js +51 -51
- package/src/api/crypto/crypto.model.js +23 -23
- package/src/api/crypto/crypto.router.js +20 -20
- package/src/api/crypto/crypto.service.js +64 -64
- package/src/api/default/default.controller.js +69 -69
- package/src/api/default/default.model.js +20 -20
- package/src/api/default/default.router.js +23 -23
- package/src/api/default/default.service.js +31 -31
- package/src/api/file/file.controller.js +53 -51
- package/src/api/file/file.model.js +19 -19
- package/src/api/file/file.router.js +21 -20
- package/src/api/file/file.service.js +76 -70
- package/src/api/instance/instance.controller.js +69 -69
- package/src/api/instance/instance.model.js +36 -36
- package/src/api/instance/instance.router.js +33 -33
- package/src/api/instance/instance.service.js +48 -48
- package/src/api/test/test.controller.js +59 -59
- package/src/api/test/test.model.js +14 -14
- package/src/api/test/test.router.js +21 -21
- package/src/api/test/test.service.js +35 -35
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -70
- package/src/api/user/user.model.js +65 -65
- package/src/api/user/user.router.js +345 -345
- package/src/api/user/user.service.js +479 -479
- package/src/api.js +23 -23
- package/src/client/Default.index.js +40 -40
- package/src/client/components/core/Account.js +290 -290
- package/src/client/components/core/AgGrid.js +160 -160
- package/src/client/components/core/Auth.js +19 -19
- package/src/client/components/core/Badge.js +32 -32
- package/src/client/components/core/BlockChain.js +41 -41
- package/src/client/components/core/Blog.js +9 -9
- package/src/client/components/core/BtnIcon.js +101 -94
- package/src/client/components/core/CalendarCore.js +458 -319
- package/src/client/components/core/Chat.js +64 -64
- package/src/client/components/core/ColorPalette.js +5267 -5267
- package/src/client/components/core/CommonJs.js +735 -732
- package/src/client/components/core/Content.js +193 -49
- package/src/client/components/core/Css.js +1064 -1027
- package/src/client/components/core/CssCore.js +817 -796
- package/src/client/components/core/D3Chart.js +44 -44
- package/src/client/components/core/Docs.js +229 -229
- package/src/client/components/core/DropDown.js +164 -164
- package/src/client/components/core/EventsUI.js +46 -54
- package/src/client/components/core/FileExplorer.js +699 -624
- package/src/client/components/core/FullScreen.js +45 -45
- package/src/client/components/core/Input.js +346 -259
- package/src/client/components/core/JoyStick.js +77 -77
- package/src/client/components/core/Keyboard.js +73 -73
- package/src/client/components/core/LoadingAnimation.js +179 -157
- package/src/client/components/core/LogIn.js +187 -181
- package/src/client/components/core/LogOut.js +58 -52
- package/src/client/components/core/Logger.js +26 -26
- package/src/client/components/core/Modal.js +1612 -1596
- package/src/client/components/core/NotificationManager.js +84 -84
- package/src/client/components/core/Panel.js +613 -413
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -162
- package/src/client/components/core/Recover.js +204 -204
- package/src/client/components/core/Responsive.js +53 -53
- package/src/client/components/core/RichText.js +51 -27
- package/src/client/components/core/Router.js +76 -77
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -125
- package/src/client/components/core/SocketIo.js +72 -72
- package/src/client/components/core/Stream.js +113 -113
- package/src/client/components/core/ToggleSwitch.js +87 -87
- package/src/client/components/core/ToolTip.js +26 -26
- package/src/client/components/core/Translate.js +437 -408
- package/src/client/components/core/Validator.js +100 -100
- package/src/client/components/core/VanillaJs.js +460 -457
- package/src/client/components/core/Wallet.js +106 -106
- package/src/client/components/core/Webhook.js +25 -25
- package/src/client/components/core/Worker.js +272 -272
- package/src/client/components/default/CommonDefault.js +29 -29
- package/src/client/components/default/CssDefault.js +13 -13
- package/src/client/components/default/ElementsDefault.js +38 -38
- package/src/client/components/default/LogInDefault.js +41 -41
- package/src/client/components/default/LogOutDefault.js +28 -28
- package/src/client/components/default/MenuDefault.js +389 -389
- package/src/client/components/default/RoutesDefault.js +48 -48
- package/src/client/components/default/SettingsDefault.js +16 -16
- package/src/client/components/default/SignUpDefault.js +9 -9
- package/src/client/components/default/SocketIoDefault.js +54 -54
- package/src/client/components/default/TranslateDefault.js +7 -7
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/browserconfig.xml +11 -11
- package/src/client/public/default/manifest.webmanifest +68 -68
- package/src/client/public/default/plantuml/client-conf.svg +1 -0
- package/src/client/public/default/plantuml/client-schema.svg +1 -0
- package/src/client/public/default/plantuml/cron-conf.svg +1 -0
- package/src/client/public/default/plantuml/cron-schema.svg +1 -0
- package/src/client/public/default/plantuml/server-conf.svg +1 -0
- package/src/client/public/default/plantuml/server-schema.svg +1 -0
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
- package/src/client/public/default/sitemap +147 -147
- package/src/client/public/default/yandex-browser-manifest.json +8 -8
- package/src/client/public/doc/sitemap +147 -147
- package/src/client/public/test/sitemap +147 -147
- package/src/client/services/core/core.service.js +170 -152
- package/src/client/services/crypto/crypto.service.js +70 -70
- package/src/client/services/default/default.management.js +345 -345
- package/src/client/services/default/default.service.js +89 -89
- package/src/client/services/file/file.service.js +70 -70
- package/src/client/services/instance/instance.management.js +74 -74
- package/src/client/services/instance/instance.service.js +89 -89
- package/src/client/services/test/test.service.js +70 -70
- package/src/client/services/user/user.management.js +50 -50
- package/src/client/services/user/user.service.js +89 -89
- package/src/client/ssr/Render.js +16 -16
- package/src/client/ssr/body-components/CacheControl.js +114 -113
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
- package/src/client/ssr/head-components/Css.js +241 -241
- package/src/client/ssr/head-components/DefaultScripts.js +3 -3
- package/src/client/ssr/head-components/Microdata.js +11 -11
- package/src/client/ssr/head-components/Production.js +1 -1
- package/src/client/ssr/head-components/PwaDefault.js +59 -59
- package/src/client/ssr/head-components/Seo.js +14 -14
- package/src/client/sw/default.sw.js +201 -201
- package/src/client/sw/template.sw.js +84 -84
- package/src/client.build.js +22 -22
- package/src/client.dev.js +21 -21
- package/src/cron.js +25 -25
- package/src/db/DataBaseProvider.js +34 -34
- package/src/db/mariadb/MariaDB.js +33 -33
- package/src/db/mongo/MongooseDB.js +46 -46
- package/src/dns.js +22 -22
- package/src/index.js +42 -29
- package/src/mailer/EmailRender.js +69 -69
- package/src/mailer/MailerProvider.js +96 -96
- package/src/proxy.js +22 -22
- package/src/runtime/lampp/Lampp.js +69 -44
- package/src/runtime/nginx/Nginx.js +3 -3
- package/src/runtime/xampp/Xampp.js +49 -49
- package/src/server/auth.js +235 -204
- package/src/server/backup.js +101 -94
- package/src/server/client-build-live.js +72 -72
- package/src/server/client-build.js +705 -699
- package/src/server/client-dev-server.js +60 -58
- package/src/server/client-formatted.js +48 -48
- package/src/server/client-icons.js +149 -150
- package/src/server/conf.js +860 -611
- package/src/server/dns.js +98 -98
- package/src/server/downloader.js +42 -42
- package/src/server/logger.js +180 -180
- package/src/server/network.js +122 -122
- package/src/server/peer.js +33 -33
- package/src/server/process.js +66 -66
- package/src/server/prompt-optimizer.js +28 -28
- package/src/server/proxy.js +118 -118
- package/src/server/runtime.js +444 -393
- package/src/server/ssl.js +109 -107
- package/src/server.js +25 -25
- package/src/ws/IoInterface.js +45 -45
- package/src/ws/IoServer.js +39 -39
- package/src/ws/core/channels/core.ws.chat.js +23 -23
- package/src/ws/core/channels/core.ws.mailer.js +35 -35
- package/src/ws/core/channels/core.ws.stream.js +31 -31
- package/src/ws/core/core.ws.connection.js +28 -28
- package/src/ws/core/core.ws.emit.js +14 -14
- package/src/ws/core/core.ws.server.js +24 -24
- package/src/ws/core/management/core.ws.chat.js +8 -8
- package/src/ws/core/management/core.ws.mailer.js +16 -16
- package/src/ws/core/management/core.ws.stream.js +8 -8
- package/src/ws/default/channels/default.ws.main.js +16 -16
- package/src/ws/default/default.ws.connection.js +22 -22
- package/src/ws/default/default.ws.emit.js +14 -14
- package/src/ws/default/default.ws.server.js +20 -20
- package/src/ws/default/management/default.ws.main.js +8 -8
- package/startup.js +11 -11
- package/supervisord-openssh-server.conf +4 -4
- package/test/api.test.js +60 -60
|
@@ -1,259 +1,346 @@
|
|
|
1
|
-
import { AgGrid } from './AgGrid.js';
|
|
2
|
-
import { BtnIcon } from './BtnIcon.js';
|
|
3
|
-
import { darkTheme } from './Css.js';
|
|
4
|
-
import { loggerFactory } from './Logger.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
-
${options?.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
${options?.
|
|
71
|
-
${options
|
|
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
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
1
|
+
import { AgGrid } from './AgGrid.js';
|
|
2
|
+
import { BtnIcon } from './BtnIcon.js';
|
|
3
|
+
import { darkTheme } from './Css.js';
|
|
4
|
+
import { loggerFactory } from './Logger.js';
|
|
5
|
+
import { RichText } from './RichText.js';
|
|
6
|
+
import { ToggleSwitch } from './ToggleSwitch.js';
|
|
7
|
+
import { Translate } from './Translate.js';
|
|
8
|
+
import { htmls, s } from './VanillaJs.js';
|
|
9
|
+
const logger = loggerFactory(import.meta);
|
|
10
|
+
|
|
11
|
+
const fileFormDataFactory = (e, extensions) => {
|
|
12
|
+
const form = new FormData();
|
|
13
|
+
for (const keyFile of Object.keys(e.target.files)) {
|
|
14
|
+
if (extensions && !extensions.includes(e.target.files[keyFile].type)) {
|
|
15
|
+
logger.error('Invalid file extension', e.target.files[keyFile]);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
form.append(e.target.files[keyFile].name, e.target.files[keyFile]);
|
|
19
|
+
}
|
|
20
|
+
return form;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getFileFromFileData = (fileData) => {
|
|
24
|
+
const blob = new Blob([new Uint8Array(fileData.data.data)], { type: fileData.mimetype });
|
|
25
|
+
return new File([blob], fileData.name, { type: fileData.mimetype });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getSrcFromFileData = (fileData) => {
|
|
29
|
+
const file = getFileFromFileData(fileData);
|
|
30
|
+
return URL.createObjectURL(file);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const Input = {
|
|
34
|
+
Render: async function (options) {
|
|
35
|
+
const { id } = options;
|
|
36
|
+
options?.placeholder
|
|
37
|
+
? options.placeholder === true
|
|
38
|
+
? (options.placeholder = ' . . .')
|
|
39
|
+
: options.placeholder
|
|
40
|
+
: null;
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
if (!s(`.${id}`)) return;
|
|
43
|
+
s(`.input-container-${id}`).onclick = () => {
|
|
44
|
+
['color', 'file'].includes(options.type) ? s(`.${id}`).click() : s(`.${id}`).focus();
|
|
45
|
+
['datetime-local'].includes(options.type) ? s(`.${id}`).showPicker() : s(`.${id}`).focus();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (s(`.btn-eye-${id}`))
|
|
49
|
+
s(`.btn-eye-${id}`).onclick = () => {
|
|
50
|
+
if (s(`.fa-eye-slash-${id}`).style.display === 'none') {
|
|
51
|
+
s(`.fa-eye-${id}`).style.display = 'none';
|
|
52
|
+
s(`.fa-eye-slash-${id}`).style.display = null;
|
|
53
|
+
s(`.${id}`).type = 'text';
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
s(`.fa-eye-slash-${id}`).style.display = 'none';
|
|
57
|
+
s(`.fa-eye-${id}`).style.display = null;
|
|
58
|
+
s(`.${id}`).type = 'password';
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const inputElement = html` <input
|
|
63
|
+
type="${options?.type ? options.type : 'text'}"
|
|
64
|
+
class="${options.inputClass ? options.inputClass : 'in wfa'} ${id}"
|
|
65
|
+
${options?.min !== undefined ? `min="${options.min}"` : ''}
|
|
66
|
+
placeholder${options?.placeholder ? `="${options.placeholder}"` : ''}
|
|
67
|
+
${options?.value !== undefined ? `value="${options.value}"` : ''}
|
|
68
|
+
${options?.autocomplete ? `autocomplete="${options.autocomplete}"` : ''}
|
|
69
|
+
${options?.disabled ? `disabled` : ''}
|
|
70
|
+
${options?.name !== undefined ? `name="${options.name}"` : ''}
|
|
71
|
+
${options?.pattern !== undefined ? `pattern="${options.pattern}"` : ''}
|
|
72
|
+
${options?.pattern === undefined && options.type === 'tel' ? `pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"` : ''}
|
|
73
|
+
${options?.required ? ` required ` : ''}
|
|
74
|
+
${options?.accept ? `accept="${options.accept}"` : ''}
|
|
75
|
+
${options?.multiple ? `multiple="multiple"` : ''}
|
|
76
|
+
/>
|
|
77
|
+
<div class="${id}-input-extension input-info input-extension ${options?.extension ? '' : 'hide'}">
|
|
78
|
+
${options?.extension ? await options.extension() : ''}
|
|
79
|
+
</div>`;
|
|
80
|
+
|
|
81
|
+
return html` <div class="${options?.containerClass ? options.containerClass + ' ' : ''} input-container-${id}">
|
|
82
|
+
<div class="in">
|
|
83
|
+
${options?.label ? html`<div class="in input-label input-label-${id}">${options.label}</div>` : ''}
|
|
84
|
+
${options.type === 'password' && !options.disabledEye
|
|
85
|
+
? html`
|
|
86
|
+
<div class="fl input-row-${id}">
|
|
87
|
+
<div class="in fll" style="width: 80%;">${inputElement}</div>
|
|
88
|
+
<div class="in fll btn-eye-password btn-eye-${id}" style="width: 20%;">
|
|
89
|
+
<i class="fas fa-eye fa-eye-${id} eye-password"></i>
|
|
90
|
+
<i class="fas fa-eye-slash fa-eye-slash-${id} eye-password" style="display: none"></i>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
`
|
|
94
|
+
: options?.placeholderIcon
|
|
95
|
+
? html` <div class="fl input-row-${id}">${options.placeholderIcon} ${inputElement}</div> `
|
|
96
|
+
: inputElement}
|
|
97
|
+
<div class="in input-info input-info-${id}"> </div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>`;
|
|
100
|
+
},
|
|
101
|
+
parseJsonEval: (selector) => {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(s(selector).value);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
return s(selector).value;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
getValues: function (formData) {
|
|
109
|
+
const obj = {};
|
|
110
|
+
for (const inputData of formData) {
|
|
111
|
+
if (inputData.disableRender) continue;
|
|
112
|
+
switch (inputData.inputType) {
|
|
113
|
+
case 'file':
|
|
114
|
+
obj[inputData.model] = s(`.${inputData.id}`).inputFiles;
|
|
115
|
+
continue;
|
|
116
|
+
case 'md':
|
|
117
|
+
obj[inputData.model] = RichText.Tokens[inputData.id].easyMDE.value();
|
|
118
|
+
break;
|
|
119
|
+
case 'checkbox':
|
|
120
|
+
case 'checkbox-on-off':
|
|
121
|
+
obj[inputData.model] = s(`.${inputData.id}-checkbox`).checked;
|
|
122
|
+
continue;
|
|
123
|
+
|
|
124
|
+
default:
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!s(`.${inputData.id}`) || !s(`.${inputData.id}`).value || s(`.${inputData.id}`).value === 'undefined')
|
|
129
|
+
continue;
|
|
130
|
+
if ('model' in inputData) {
|
|
131
|
+
obj[inputData.model] = s(`.${inputData.id}`).value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return obj;
|
|
135
|
+
},
|
|
136
|
+
cleanValues: function (formData) {
|
|
137
|
+
const obj = {};
|
|
138
|
+
for (const inputData of formData) {
|
|
139
|
+
if (!s(`.${inputData.id}`)) continue;
|
|
140
|
+
|
|
141
|
+
switch (inputData.inputType) {
|
|
142
|
+
case 'file':
|
|
143
|
+
s(`.${inputData.id}`).inputFiles = undefined;
|
|
144
|
+
s(`.${inputData.id}`).value = null;
|
|
145
|
+
|
|
146
|
+
if (s(`.file-name-render-${inputData.id}`) && s(`.${inputData.id}`).fileNameInputExtDefaultContent)
|
|
147
|
+
htmls(`.file-name-render-${inputData.id}`, `${s(`.${inputData.id}`).fileNameInputExtDefaultContent}`);
|
|
148
|
+
continue;
|
|
149
|
+
break;
|
|
150
|
+
case 'md':
|
|
151
|
+
RichText.Tokens[inputData.id].easyMDE.value('');
|
|
152
|
+
continue;
|
|
153
|
+
break;
|
|
154
|
+
case 'checkbox':
|
|
155
|
+
case 'checkbox-on-off':
|
|
156
|
+
if (s(`.${inputData.id}-checkbox`).checked) ToggleSwitch.Tokens[inputData.id].click();
|
|
157
|
+
continue;
|
|
158
|
+
break;
|
|
159
|
+
|
|
160
|
+
default:
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if ('model' in inputData) {
|
|
165
|
+
if (!['dropdown'].includes(inputData.inputType)) s(`.${inputData.id}`).value = '';
|
|
166
|
+
}
|
|
167
|
+
if (s(`.input-info-${inputData.id}`)) htmls(`.input-info-${inputData.id}`, html` `);
|
|
168
|
+
}
|
|
169
|
+
return obj;
|
|
170
|
+
},
|
|
171
|
+
setValues: function (formData, obj, originObj, fileObj) {
|
|
172
|
+
setTimeout(() => {
|
|
173
|
+
for (const inputData of formData) {
|
|
174
|
+
if (!s(`.${inputData.id}`)) continue;
|
|
175
|
+
|
|
176
|
+
switch (inputData.inputType) {
|
|
177
|
+
case 'file':
|
|
178
|
+
if (fileObj[inputData.model] && s(`.${inputData.id}`)) {
|
|
179
|
+
const dataTransfer = new DataTransfer();
|
|
180
|
+
|
|
181
|
+
if (fileObj[inputData.model].fileBlob)
|
|
182
|
+
dataTransfer.items.add(getFileFromFileData(fileObj[inputData.model].fileBlob));
|
|
183
|
+
|
|
184
|
+
if (fileObj[inputData.model].mdBlob)
|
|
185
|
+
dataTransfer.items.add(getFileFromFileData(fileObj[inputData.model].mdBlob));
|
|
186
|
+
|
|
187
|
+
if (dataTransfer.files.length) {
|
|
188
|
+
s(`.${inputData.id}`).files = dataTransfer.files;
|
|
189
|
+
s(`.${inputData.id}`).onchange({ target: s(`.${inputData.id}`) });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
continue;
|
|
194
|
+
break;
|
|
195
|
+
case 'md':
|
|
196
|
+
RichText.Tokens[inputData.id].easyMDE.value(fileObj[inputData.model].mdPlain);
|
|
197
|
+
continue;
|
|
198
|
+
break;
|
|
199
|
+
case 'checkbox':
|
|
200
|
+
case 'checkbox-on-off':
|
|
201
|
+
if (
|
|
202
|
+
(obj[inputData.model] === true && !s(`.${inputData.id}-checkbox`).checked) ||
|
|
203
|
+
(!obj[inputData.model] && s(`.${inputData.id}-checkbox`).checked === true)
|
|
204
|
+
)
|
|
205
|
+
ToggleSwitch.Tokens[inputData.id].click();
|
|
206
|
+
continue;
|
|
207
|
+
break;
|
|
208
|
+
case 'datetime-local':
|
|
209
|
+
{
|
|
210
|
+
const date = new Date(originObj[inputData.model]);
|
|
211
|
+
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
|
|
212
|
+
s(`.${inputData.id}`).value = date.toISOString().slice(0, 16);
|
|
213
|
+
}
|
|
214
|
+
continue;
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if ('model' in inputData) {
|
|
221
|
+
if (!['dropdown'].includes(inputData.inputType)) s(`.${inputData.id}`).value = obj[inputData.model];
|
|
222
|
+
}
|
|
223
|
+
if (s(`.input-info-${inputData.id}`)) htmls(`.input-info-${inputData.id}`, html` `);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const InputFile = {
|
|
230
|
+
Render: async function ({ id, multiple }, on = { change: () => {}, clear: () => {} }) {
|
|
231
|
+
// drag drop multi file
|
|
232
|
+
const gridId = `ag-grid-input-file-${id}`;
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
s(`.btn-clear-input-file-${id}`).onclick = (e) => {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
s(`.${id}`).value = null;
|
|
237
|
+
AgGrid.grids[gridId].setGridOption('rowData', []);
|
|
238
|
+
if (on && typeof on.clear === 'function') on.clear();
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
['drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop'].forEach(function (event) {
|
|
242
|
+
s(`.drop-zone-${id}`).addEventListener(event, function (e) {
|
|
243
|
+
e.preventDefault();
|
|
244
|
+
e.stopPropagation();
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
s(`.drop-zone-${id}`).addEventListener(
|
|
248
|
+
'dragover',
|
|
249
|
+
function (e) {
|
|
250
|
+
this.classList.add('drop-hover-container');
|
|
251
|
+
},
|
|
252
|
+
false,
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
s(`.drop-zone-${id}`).addEventListener(
|
|
256
|
+
'dragleave',
|
|
257
|
+
function (e) {
|
|
258
|
+
this.classList.remove('drop-hover-container');
|
|
259
|
+
},
|
|
260
|
+
false,
|
|
261
|
+
);
|
|
262
|
+
s(`.drop-zone-${id}`).addEventListener(
|
|
263
|
+
'drop',
|
|
264
|
+
function (e) {
|
|
265
|
+
this.classList.remove('drop-hover-container');
|
|
266
|
+
const files = e.dataTransfer.files;
|
|
267
|
+
const dataTransfer = new DataTransfer();
|
|
268
|
+
|
|
269
|
+
let countFiles = 0;
|
|
270
|
+
Array.prototype.forEach.call(files, (file) => {
|
|
271
|
+
// logger.info(file);
|
|
272
|
+
if (!multiple && countFiles == 1) return;
|
|
273
|
+
dataTransfer.items.add(file);
|
|
274
|
+
countFiles++;
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
s(`.${id}`).files = dataTransfer.files;
|
|
278
|
+
s(`.${id}`).onchange({ target: s(`.${id}`) });
|
|
279
|
+
},
|
|
280
|
+
false,
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
s(`.drop-zone-${id}`).addEventListener('click', function (e) {
|
|
284
|
+
s(`.${id}`).click();
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
s(`.${id}`).onchange = (e) => {
|
|
288
|
+
// logger.info('e', e);
|
|
289
|
+
const fileGridData = [];
|
|
290
|
+
Object.keys(e.target.files).forEach((fileKey, index) => {
|
|
291
|
+
const file = e.target.files[fileKey];
|
|
292
|
+
logger.info('Load file', file);
|
|
293
|
+
// Get raw:
|
|
294
|
+
// const read = new FileReader();
|
|
295
|
+
// read.readAsBinaryString(file);
|
|
296
|
+
// read.onloadend = () => {
|
|
297
|
+
// console.log('Load File', e.target.files[fileKey], { fileKey, index }, read.result);
|
|
298
|
+
// };
|
|
299
|
+
fileGridData.push(file);
|
|
300
|
+
});
|
|
301
|
+
AgGrid.grids[gridId].setGridOption('rowData', fileGridData);
|
|
302
|
+
if (on && typeof on.change === 'function') on.change(e);
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
return html` <div class="fl">
|
|
306
|
+
<div class="in fll input-file-col">
|
|
307
|
+
<div class="in section-mp input-file-sub-col">
|
|
308
|
+
<input class="wfa ${id}" type="file" ${multiple ? `multiple="multiple"` : ''} />
|
|
309
|
+
<div class="in">
|
|
310
|
+
${await BtnIcon.Render({
|
|
311
|
+
class: `wfa btn-clear-input-file-${id}`,
|
|
312
|
+
label: `<i class="fa-solid fa-broom"></i> ${Translate.Render('clear')}`,
|
|
313
|
+
})}
|
|
314
|
+
</div>
|
|
315
|
+
<div class="in">
|
|
316
|
+
${await AgGrid.Render({
|
|
317
|
+
id: gridId,
|
|
318
|
+
darkTheme,
|
|
319
|
+
style: {
|
|
320
|
+
height: '200px',
|
|
321
|
+
},
|
|
322
|
+
gridOptions: {
|
|
323
|
+
rowData: [],
|
|
324
|
+
columnDefs: [
|
|
325
|
+
// { field: '_id', headerName: 'ID' },
|
|
326
|
+
{ field: 'name', headerName: 'Name' },
|
|
327
|
+
{ field: 'type', headerName: 'Type' },
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
})}
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="in fll input-file-col">
|
|
335
|
+
<div class="in section-mp input-file-sub-col drop-zone-${id}">
|
|
336
|
+
<div class="abs center">
|
|
337
|
+
<i class="fas fa-cloud" style="font-size: 30px"></i><br />
|
|
338
|
+
${Translate.Render('drop-file')}
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
</div>
|
|
342
|
+
</div>`;
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export { Input, InputFile, fileFormDataFactory, getSrcFromFileData, getFileFromFileData };
|