@underpostnet/underpost 2.7.82
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 +14 -0
- package/.env.development +6 -0
- package/.env.production +6 -0
- package/.env.test +6 -0
- package/.github/workflows/ghpkg.yml +75 -0
- package/.github/workflows/publish.yml +84 -0
- package/.github/workflows/pwa-microservices-template.test.yml +30 -0
- package/.nycrc +9 -0
- package/.prettierignore +13 -0
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +72 -0
- package/.vscode/settings.json +100 -0
- package/AUTHORS.md +10 -0
- package/CHANGELOG.md +37 -0
- package/Dockerfile +90 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/bin/db.js +172 -0
- package/bin/deploy.js +674 -0
- package/bin/file.js +93 -0
- package/bin/index.js +82 -0
- package/bin/ssl.js +55 -0
- package/bin/util.js +182 -0
- package/bin/vs.js +35 -0
- package/conf.js +251 -0
- package/docker-compose.yml +67 -0
- package/jsconfig.json +7 -0
- package/jsdoc.json +32 -0
- package/nodemon.json +6 -0
- package/package.json +134 -0
- package/prometheus.yml +36 -0
- package/src/api/core/core.controller.js +69 -0
- package/src/api/core/core.model.js +11 -0
- package/src/api/core/core.router.js +23 -0
- package/src/api/core/core.service.js +29 -0
- package/src/api/crypto/crypto.controller.js +51 -0
- package/src/api/crypto/crypto.model.js +23 -0
- package/src/api/crypto/crypto.router.js +20 -0
- package/src/api/crypto/crypto.service.js +64 -0
- package/src/api/default/default.controller.js +69 -0
- package/src/api/default/default.model.js +20 -0
- package/src/api/default/default.router.js +23 -0
- package/src/api/default/default.service.js +31 -0
- package/src/api/file/file.controller.js +53 -0
- package/src/api/file/file.model.js +19 -0
- package/src/api/file/file.router.js +21 -0
- package/src/api/file/file.service.js +80 -0
- package/src/api/instance/instance.controller.js +69 -0
- package/src/api/instance/instance.model.js +36 -0
- package/src/api/instance/instance.router.js +33 -0
- package/src/api/instance/instance.service.js +48 -0
- package/src/api/test/test.controller.js +59 -0
- package/src/api/test/test.model.js +14 -0
- package/src/api/test/test.router.js +21 -0
- package/src/api/test/test.service.js +35 -0
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -0
- package/src/api/user/user.model.js +65 -0
- package/src/api/user/user.router.js +345 -0
- package/src/api/user/user.service.js +479 -0
- package/src/api.js +23 -0
- package/src/client/Default.index.js +40 -0
- package/src/client/components/core/Account.js +290 -0
- package/src/client/components/core/AgGrid.js +160 -0
- package/src/client/components/core/Auth.js +19 -0
- package/src/client/components/core/Badge.js +32 -0
- package/src/client/components/core/Blockchain.js +41 -0
- package/src/client/components/core/Blog.js +9 -0
- package/src/client/components/core/BtnIcon.js +101 -0
- package/src/client/components/core/CalendarCore.js +458 -0
- package/src/client/components/core/Chat.js +64 -0
- package/src/client/components/core/ColorPalette.js +5267 -0
- package/src/client/components/core/CommonJs.js +742 -0
- package/src/client/components/core/Content.js +193 -0
- package/src/client/components/core/Css.js +846 -0
- package/src/client/components/core/CssCore.js +817 -0
- package/src/client/components/core/D3Chart.js +44 -0
- package/src/client/components/core/Docs.js +231 -0
- package/src/client/components/core/DropDown.js +164 -0
- package/src/client/components/core/EventsUI.js +46 -0
- package/src/client/components/core/FileExplorer.js +699 -0
- package/src/client/components/core/FullScreen.js +45 -0
- package/src/client/components/core/Input.js +346 -0
- package/src/client/components/core/JoyStick.js +77 -0
- package/src/client/components/core/Keyboard.js +73 -0
- package/src/client/components/core/LoadingAnimation.js +178 -0
- package/src/client/components/core/LogIn.js +187 -0
- package/src/client/components/core/LogOut.js +58 -0
- package/src/client/components/core/Logger.js +26 -0
- package/src/client/components/core/Modal.js +1612 -0
- package/src/client/components/core/NotificationManager.js +84 -0
- package/src/client/components/core/Panel.js +613 -0
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -0
- package/src/client/components/core/Recover.js +204 -0
- package/src/client/components/core/Responsive.js +53 -0
- package/src/client/components/core/RichText.js +51 -0
- package/src/client/components/core/Router.js +76 -0
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -0
- package/src/client/components/core/SocketIo.js +72 -0
- package/src/client/components/core/Stream.js +113 -0
- package/src/client/components/core/ToggleSwitch.js +87 -0
- package/src/client/components/core/ToolTip.js +26 -0
- package/src/client/components/core/Translate.js +446 -0
- package/src/client/components/core/Validator.js +100 -0
- package/src/client/components/core/VanillaJs.js +463 -0
- package/src/client/components/core/Wallet.js +106 -0
- package/src/client/components/core/Webhook.js +25 -0
- package/src/client/components/core/Worker.js +282 -0
- package/src/client/components/default/CommonDefault.js +29 -0
- package/src/client/components/default/CssDefault.js +13 -0
- package/src/client/components/default/ElementsDefault.js +38 -0
- package/src/client/components/default/LogInDefault.js +41 -0
- package/src/client/components/default/LogOutDefault.js +28 -0
- package/src/client/components/default/MenuDefault.js +389 -0
- package/src/client/components/default/RoutesDefault.js +48 -0
- package/src/client/components/default/SettingsDefault.js +16 -0
- package/src/client/components/default/SignUpDefault.js +9 -0
- package/src/client/components/default/SocketIoDefault.js +54 -0
- package/src/client/components/default/TranslateDefault.js +7 -0
- package/src/client/public/default/android-chrome-144x144.png +0 -0
- package/src/client/public/default/android-chrome-192x192.png +0 -0
- package/src/client/public/default/android-chrome-256x256.png +0 -0
- package/src/client/public/default/android-chrome-36x36.png +0 -0
- package/src/client/public/default/android-chrome-384x384.png +0 -0
- package/src/client/public/default/android-chrome-48x48.png +0 -0
- package/src/client/public/default/android-chrome-512x512.png +0 -0
- package/src/client/public/default/android-chrome-72x72.png +0 -0
- package/src/client/public/default/android-chrome-96x96.png +0 -0
- package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
- package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
- package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
- package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
- package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
- package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
- package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
- package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
- package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
- package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
- package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
- package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
- package/src/client/public/default/assets/background/white.jpg +0 -0
- package/src/client/public/default/assets/background/white0-min.jpg +0 -0
- package/src/client/public/default/assets/background/white0.jpg +0 -0
- package/src/client/public/default/assets/logo/base-icon.png +0 -0
- 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 +12 -0
- package/src/client/public/default/favicon-16x16.png +0 -0
- package/src/client/public/default/favicon-32x32.png +0 -0
- package/src/client/public/default/favicon-48x48.png +0 -0
- package/src/client/public/default/favicon.ico +0 -0
- package/src/client/public/default/manifest.webmanifest +69 -0
- package/src/client/public/default/mstile-144x144.png +0 -0
- package/src/client/public/default/mstile-150x150.png +0 -0
- package/src/client/public/default/mstile-310x150.png +0 -0
- package/src/client/public/default/mstile-310x310.png +0 -0
- package/src/client/public/default/mstile-70x70.png +0 -0
- 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 +148 -0
- package/src/client/public/default/yandex-browser-50x50.png +0 -0
- package/src/client/public/default/yandex-browser-manifest.json +9 -0
- package/src/client/public/doc/favicon.ico +0 -0
- package/src/client/public/doc/sitemap +148 -0
- package/src/client/public/test/favicon.ico +0 -0
- package/src/client/public/test/sitemap +148 -0
- package/src/client/services/core/core.service.js +170 -0
- package/src/client/services/crypto/crypto.service.js +70 -0
- package/src/client/services/default/default.management.js +343 -0
- package/src/client/services/default/default.service.js +89 -0
- package/src/client/services/file/file.service.js +70 -0
- package/src/client/services/instance/instance.management.js +74 -0
- package/src/client/services/instance/instance.service.js +89 -0
- package/src/client/services/test/test.service.js +70 -0
- package/src/client/services/user/user.management.js +50 -0
- package/src/client/services/user/user.service.js +89 -0
- package/src/client/ssr/Render.js +237 -0
- package/src/client/ssr/common/Alert.js +75 -0
- package/src/client/ssr/common/SsrCore.js +91 -0
- package/src/client/ssr/common/Translate.js +26 -0
- package/src/client/ssr/common/Worker.js +28 -0
- package/src/client/ssr/components/body/CacheControl.js +114 -0
- package/src/client/ssr/components/body/DefaultSplashScreen.js +90 -0
- package/src/client/ssr/components/email/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/components/email/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/components/head/Css.js +241 -0
- package/src/client/ssr/components/head/DefaultScripts.js +3 -0
- package/src/client/ssr/components/head/PwaDefault.js +60 -0
- package/src/client/ssr/offline/default.index.js +31 -0
- package/src/client/ssr/pages/404.js +12 -0
- package/src/client/ssr/pages/500.js +12 -0
- package/src/client/sw/default.sw.js +203 -0
- package/src/client/sw/template.sw.js +84 -0
- package/src/client.build.js +22 -0
- package/src/client.dev.js +21 -0
- package/src/cron.js +30 -0
- package/src/db/DataBaseProvider.js +34 -0
- package/src/db/mariadb/MariaDB.js +33 -0
- package/src/db/mongo/MongooseDB.js +125 -0
- package/src/dns.js +22 -0
- package/src/index.js +43 -0
- package/src/mailer/EmailRender.js +69 -0
- package/src/mailer/MailerProvider.js +96 -0
- package/src/proxy.js +22 -0
- package/src/runtime/lampp/Lampp.js +115 -0
- package/src/runtime/nginx/Nginx.js +3 -0
- package/src/runtime/xampp/Xampp.js +49 -0
- package/src/server/auth.js +235 -0
- package/src/server/backup.js +108 -0
- package/src/server/client-build-live.js +98 -0
- package/src/server/client-build.js +821 -0
- package/src/server/client-dev-server.js +60 -0
- package/src/server/client-formatted.js +58 -0
- package/src/server/client-icons.js +151 -0
- package/src/server/conf.js +883 -0
- package/src/server/cron.js +35 -0
- package/src/server/dns.js +89 -0
- package/src/server/downloader.js +42 -0
- package/src/server/logger.js +190 -0
- package/src/server/network.js +122 -0
- package/src/server/peer.js +33 -0
- package/src/server/process.js +66 -0
- package/src/server/prompt-optimizer.js +28 -0
- package/src/server/proxy.js +118 -0
- package/src/server/runtime.js +461 -0
- package/src/server/ssl.js +120 -0
- package/src/server.js +25 -0
- package/src/ws/IoInterface.js +45 -0
- package/src/ws/IoServer.js +39 -0
- package/src/ws/core/channels/core.ws.chat.js +23 -0
- package/src/ws/core/channels/core.ws.mailer.js +35 -0
- package/src/ws/core/channels/core.ws.stream.js +31 -0
- package/src/ws/core/core.ws.connection.js +28 -0
- package/src/ws/core/core.ws.emit.js +14 -0
- package/src/ws/core/core.ws.server.js +24 -0
- package/src/ws/core/management/core.ws.chat.js +8 -0
- package/src/ws/core/management/core.ws.mailer.js +16 -0
- package/src/ws/core/management/core.ws.stream.js +8 -0
- package/src/ws/default/channels/default.ws.main.js +16 -0
- package/src/ws/default/default.ws.connection.js +22 -0
- package/src/ws/default/default.ws.emit.js +14 -0
- package/src/ws/default/default.ws.server.js +20 -0
- package/src/ws/default/management/default.ws.main.js +8 -0
- package/startup.js +11 -0
- package/supervisord-openssh-server.conf +5 -0
- package/test/api.test.js +60 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Auth } from '../../components/core/Auth.js';
|
|
2
|
+
import { loggerFactory } from '../../components/core/Logger.js';
|
|
3
|
+
import { getApiBaseUrl, headersFactory, payloadFactory } from '../core/core.service.js';
|
|
4
|
+
|
|
5
|
+
const logger = loggerFactory(import.meta);
|
|
6
|
+
|
|
7
|
+
logger.info('Load service');
|
|
8
|
+
|
|
9
|
+
const endpoint = 'instance';
|
|
10
|
+
|
|
11
|
+
const InstanceService = {
|
|
12
|
+
post: (options = { id: '', body: {} }) =>
|
|
13
|
+
new Promise((resolve, reject) =>
|
|
14
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: headersFactory(),
|
|
17
|
+
body: payloadFactory(options.body),
|
|
18
|
+
})
|
|
19
|
+
.then(async (res) => {
|
|
20
|
+
return await res.json();
|
|
21
|
+
})
|
|
22
|
+
.then((res) => {
|
|
23
|
+
logger.info(res);
|
|
24
|
+
return resolve(res);
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
logger.error(error);
|
|
28
|
+
return reject(error);
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
31
|
+
put: (options = { id: '', body: {} }) =>
|
|
32
|
+
new Promise((resolve, reject) =>
|
|
33
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
|
+
method: 'PUT',
|
|
35
|
+
headers: headersFactory(),
|
|
36
|
+
body: payloadFactory(options.body),
|
|
37
|
+
})
|
|
38
|
+
.then(async (res) => {
|
|
39
|
+
return await res.json();
|
|
40
|
+
})
|
|
41
|
+
.then((res) => {
|
|
42
|
+
logger.info(res);
|
|
43
|
+
return resolve(res);
|
|
44
|
+
})
|
|
45
|
+
.catch((error) => {
|
|
46
|
+
logger.error(error);
|
|
47
|
+
return reject(error);
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
get: (options = { id: '', body: {} }) =>
|
|
51
|
+
new Promise((resolve, reject) =>
|
|
52
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
53
|
+
method: 'GET',
|
|
54
|
+
headers: headersFactory(),
|
|
55
|
+
})
|
|
56
|
+
.then(async (res) => {
|
|
57
|
+
return await res.json();
|
|
58
|
+
})
|
|
59
|
+
.then((res) => {
|
|
60
|
+
logger.info(res);
|
|
61
|
+
return resolve(res);
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
logger.error(error);
|
|
65
|
+
return reject(error);
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
68
|
+
delete: (options = { id: '', body: {} }) =>
|
|
69
|
+
new Promise((resolve, reject) =>
|
|
70
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
71
|
+
method: 'DELETE',
|
|
72
|
+
headers: headersFactory(),
|
|
73
|
+
body: payloadFactory(options.body),
|
|
74
|
+
})
|
|
75
|
+
.then(async (res) => {
|
|
76
|
+
return await res.json();
|
|
77
|
+
})
|
|
78
|
+
.then((res) => {
|
|
79
|
+
logger.info(res);
|
|
80
|
+
return resolve(res);
|
|
81
|
+
})
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
logger.error(error);
|
|
84
|
+
return reject(error);
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { InstanceService };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Auth } from '../../components/core/Auth.js';
|
|
2
|
+
import { loggerFactory } from '../../components/core/Logger.js';
|
|
3
|
+
import { getApiBaseUrl, headersFactory, payloadFactory } from '../core/core.service.js';
|
|
4
|
+
|
|
5
|
+
const logger = loggerFactory(import.meta);
|
|
6
|
+
|
|
7
|
+
logger.info('Load service');
|
|
8
|
+
|
|
9
|
+
const endpoint = 'test';
|
|
10
|
+
|
|
11
|
+
const TestService = {
|
|
12
|
+
post: (options = { id: '', body: {} }) =>
|
|
13
|
+
new Promise((resolve, reject) =>
|
|
14
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: headersFactory(),
|
|
17
|
+
body: payloadFactory(options.body),
|
|
18
|
+
})
|
|
19
|
+
.then(async (res) => {
|
|
20
|
+
return await res.json();
|
|
21
|
+
})
|
|
22
|
+
.then((res) => {
|
|
23
|
+
logger.info(res);
|
|
24
|
+
return resolve(res);
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
logger.error(error);
|
|
28
|
+
return reject(error);
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
31
|
+
get: (options = { id: '' }) =>
|
|
32
|
+
new Promise((resolve, reject) =>
|
|
33
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
|
+
method: 'GET',
|
|
35
|
+
headers: headersFactory(),
|
|
36
|
+
})
|
|
37
|
+
.then(async (res) => {
|
|
38
|
+
return await res.json();
|
|
39
|
+
})
|
|
40
|
+
.then((res) => {
|
|
41
|
+
logger.info(res);
|
|
42
|
+
return resolve(res);
|
|
43
|
+
})
|
|
44
|
+
.catch((error) => {
|
|
45
|
+
logger.error(error);
|
|
46
|
+
return reject(error);
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
delete: (options = { id: '', body: {} }) =>
|
|
50
|
+
new Promise((resolve, reject) =>
|
|
51
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
52
|
+
method: 'DELETE',
|
|
53
|
+
headers: headersFactory(),
|
|
54
|
+
body: payloadFactory(options.body),
|
|
55
|
+
})
|
|
56
|
+
.then(async (res) => {
|
|
57
|
+
return await res.json();
|
|
58
|
+
})
|
|
59
|
+
.then((res) => {
|
|
60
|
+
logger.info(res);
|
|
61
|
+
return resolve(res);
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
logger.error(error);
|
|
65
|
+
return reject(error);
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { TestService };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DefaultManagement } from '../default/default.management.js';
|
|
2
|
+
import { UserService } from './user.service.js';
|
|
3
|
+
|
|
4
|
+
const UserManagement = {
|
|
5
|
+
RenderTable: async ({ Elements }) => {
|
|
6
|
+
const user = Elements.Data.user.main.model.user;
|
|
7
|
+
const { role } = user;
|
|
8
|
+
return await DefaultManagement.RenderTable({
|
|
9
|
+
idModal: 'modal-user-management',
|
|
10
|
+
serviceId: 'user-management',
|
|
11
|
+
entity: 'user',
|
|
12
|
+
permissions: {
|
|
13
|
+
add: role === 'admin',
|
|
14
|
+
remove: role === 'admin',
|
|
15
|
+
},
|
|
16
|
+
columnDefs: [
|
|
17
|
+
{ field: 'username', headerName: 'username', editable: role === 'admin' },
|
|
18
|
+
{ field: 'email', headerName: 'email', editable: role === 'admin' },
|
|
19
|
+
{ field: 'password', headerName: 'password', editable: role === 'admin' },
|
|
20
|
+
{
|
|
21
|
+
field: 'role',
|
|
22
|
+
headerName: 'role',
|
|
23
|
+
editable: role === 'admin',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
field: 'emailConfirmed',
|
|
27
|
+
headerName: 'emailConfirmed',
|
|
28
|
+
cellDataType: 'boolean',
|
|
29
|
+
cellRendererParams: { disabled: true },
|
|
30
|
+
editable: role === 'admin',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
field: 'createdAt',
|
|
34
|
+
headerName: 'createdAt',
|
|
35
|
+
cellDataType: 'date',
|
|
36
|
+
editable: false,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
field: 'updatedAt',
|
|
40
|
+
headerName: 'updatedAt',
|
|
41
|
+
cellDataType: 'date',
|
|
42
|
+
editable: false,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
defaultColKeyFocus: 'username',
|
|
46
|
+
ServiceProvider: UserService,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export { UserManagement };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Auth } from '../../components/core/Auth.js';
|
|
2
|
+
import { loggerFactory } from '../../components/core/Logger.js';
|
|
3
|
+
import { getApiBaseUrl, headersFactory, payloadFactory } from '../core/core.service.js';
|
|
4
|
+
|
|
5
|
+
const logger = loggerFactory(import.meta);
|
|
6
|
+
|
|
7
|
+
logger.info('Load service');
|
|
8
|
+
|
|
9
|
+
const endpoint = 'user';
|
|
10
|
+
|
|
11
|
+
const UserService = {
|
|
12
|
+
post: (options = { id: '', body: {} }) =>
|
|
13
|
+
new Promise((resolve, reject) =>
|
|
14
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: headersFactory(),
|
|
17
|
+
body: payloadFactory(options.body),
|
|
18
|
+
})
|
|
19
|
+
.then(async (res) => {
|
|
20
|
+
return await res.json();
|
|
21
|
+
})
|
|
22
|
+
.then((res) => {
|
|
23
|
+
logger.info(res);
|
|
24
|
+
return resolve(res);
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
logger.error(error);
|
|
28
|
+
return reject(error);
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
31
|
+
get: (options = { id: '' }) =>
|
|
32
|
+
new Promise((resolve, reject) =>
|
|
33
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
|
+
method: 'GET',
|
|
35
|
+
headers: headersFactory(),
|
|
36
|
+
})
|
|
37
|
+
.then(async (res) => {
|
|
38
|
+
return await res.json();
|
|
39
|
+
})
|
|
40
|
+
.then((res) => {
|
|
41
|
+
logger.info(res);
|
|
42
|
+
return resolve(res);
|
|
43
|
+
})
|
|
44
|
+
.catch((error) => {
|
|
45
|
+
logger.error(error);
|
|
46
|
+
return reject(error);
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
delete: (options = { id: '', body: {} }) =>
|
|
50
|
+
new Promise((resolve, reject) =>
|
|
51
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
52
|
+
method: 'DELETE',
|
|
53
|
+
headers: headersFactory(),
|
|
54
|
+
body: payloadFactory(options.body),
|
|
55
|
+
})
|
|
56
|
+
.then(async (res) => {
|
|
57
|
+
return await res.json();
|
|
58
|
+
})
|
|
59
|
+
.then((res) => {
|
|
60
|
+
logger.info(res);
|
|
61
|
+
return resolve(res);
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
logger.error(error);
|
|
65
|
+
return reject(error);
|
|
66
|
+
}),
|
|
67
|
+
),
|
|
68
|
+
put: (options = { id: '', body: {}, headerId: '' }) =>
|
|
69
|
+
new Promise((resolve, reject) =>
|
|
70
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
71
|
+
method: 'PUT',
|
|
72
|
+
headers: headersFactory(options.headerId),
|
|
73
|
+
body: payloadFactory(options.body),
|
|
74
|
+
})
|
|
75
|
+
.then(async (res) => {
|
|
76
|
+
return await res.json();
|
|
77
|
+
})
|
|
78
|
+
.then((res) => {
|
|
79
|
+
logger.info(res);
|
|
80
|
+
return resolve(res);
|
|
81
|
+
})
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
logger.error(error);
|
|
84
|
+
return reject(error);
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { UserService };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
Render = ({ title, ssrPath, buildId, ssrHeadComponents, ssrBodyComponents, baseSsrLib }) => html`
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<html dir="ltr" lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<title>${title}</title>
|
|
6
|
+
<link rel="icon" type="image/x-icon" href="${ssrPath}favicon.ico" />
|
|
7
|
+
<meta charset="UTF-8" />
|
|
8
|
+
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
9
|
+
${ssrHeadComponents}
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<style>
|
|
13
|
+
html {
|
|
14
|
+
scroll-behavior: smooth;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
body {
|
|
18
|
+
/* overscroll-behavior: contain; */
|
|
19
|
+
/* box-sizing: border-box; */
|
|
20
|
+
padding: 0px;
|
|
21
|
+
margin: 0px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.fl {
|
|
25
|
+
position: relative;
|
|
26
|
+
display: flow-root;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.abs,
|
|
30
|
+
.in {
|
|
31
|
+
display: block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.fll {
|
|
35
|
+
float: left;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.flr {
|
|
39
|
+
float: right;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.abs {
|
|
43
|
+
position: absolute;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.in,
|
|
47
|
+
.inl {
|
|
48
|
+
position: relative;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.inl {
|
|
52
|
+
display: inline-table;
|
|
53
|
+
display: -webkit-inline-table;
|
|
54
|
+
display: -moz-inline-table;
|
|
55
|
+
display: -ms-inline-table;
|
|
56
|
+
display: -o-inline-table;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.fix {
|
|
60
|
+
position: fixed;
|
|
61
|
+
display: block;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.stq {
|
|
65
|
+
position: sticky;
|
|
66
|
+
/* require defined at least top, bottom, left o right */
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.wfa {
|
|
70
|
+
width: available;
|
|
71
|
+
width: -webkit-available;
|
|
72
|
+
width: -moz-available;
|
|
73
|
+
width: -ms-available;
|
|
74
|
+
width: -o-available;
|
|
75
|
+
|
|
76
|
+
width: fill-available;
|
|
77
|
+
width: -webkit-fill-available;
|
|
78
|
+
width: -moz-fill-available;
|
|
79
|
+
width: -ms-fill-available;
|
|
80
|
+
width: -o-fill-available;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.wft {
|
|
84
|
+
width: fit-content;
|
|
85
|
+
width: -webkit-fit-content;
|
|
86
|
+
width: -moz-fit-content;
|
|
87
|
+
width: -ms-fit-content;
|
|
88
|
+
width: -o-fit-content;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.wfm {
|
|
92
|
+
width: max-content;
|
|
93
|
+
width: -webkit-max-content;
|
|
94
|
+
width: -moz-max-content;
|
|
95
|
+
width: -ms-max-content;
|
|
96
|
+
width: -o-max-content;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.negative-color {
|
|
100
|
+
filter: invert(1);
|
|
101
|
+
-webkit-filter: invert(1);
|
|
102
|
+
-moz-filter: invert(1);
|
|
103
|
+
-ms-filter: invert(1);
|
|
104
|
+
-o-filter: invert(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.no-drag {
|
|
108
|
+
user-drag: none;
|
|
109
|
+
-webkit-user-drag: none;
|
|
110
|
+
-moz-user-drag: none;
|
|
111
|
+
-ms-user-drag: none;
|
|
112
|
+
-o-user-drag: none;
|
|
113
|
+
user-select: none;
|
|
114
|
+
-webkit-user-select: none;
|
|
115
|
+
-moz-user-select: none;
|
|
116
|
+
-ms-user-select: none;
|
|
117
|
+
-o-user-select: none;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.center {
|
|
121
|
+
transform: translate(-50%, -50%);
|
|
122
|
+
top: 50%;
|
|
123
|
+
left: 50%;
|
|
124
|
+
width: 100%;
|
|
125
|
+
text-align: center;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
input {
|
|
129
|
+
outline: none !important;
|
|
130
|
+
border: none;
|
|
131
|
+
padding-block: 0;
|
|
132
|
+
padding-inline: 0;
|
|
133
|
+
}
|
|
134
|
+
input::file-selector-button {
|
|
135
|
+
outline: none !important;
|
|
136
|
+
border: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.hide {
|
|
140
|
+
display: none !important;
|
|
141
|
+
}
|
|
142
|
+
/*
|
|
143
|
+
|
|
144
|
+
placeholder
|
|
145
|
+
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
::placeholder {
|
|
149
|
+
color: black;
|
|
150
|
+
opacity: 1;
|
|
151
|
+
/* Firefox */
|
|
152
|
+
background: none;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:-ms-input-placeholder {
|
|
156
|
+
/* Internet Explorer 10-11 */
|
|
157
|
+
color: black;
|
|
158
|
+
background: none;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
::-ms-input-placeholder {
|
|
162
|
+
/* Microsoft Edge */
|
|
163
|
+
color: black;
|
|
164
|
+
background: none;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
|
|
169
|
+
selection
|
|
170
|
+
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
::-moz-selection {
|
|
174
|
+
/* Code for Firefox */
|
|
175
|
+
color: black;
|
|
176
|
+
background: rgb(208, 208, 208);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
::selection {
|
|
180
|
+
color: black;
|
|
181
|
+
background: rgb(208, 208, 208);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.lowercase {
|
|
185
|
+
text-transform: lowercase;
|
|
186
|
+
}
|
|
187
|
+
.uppercase {
|
|
188
|
+
text-transform: uppercase;
|
|
189
|
+
}
|
|
190
|
+
.capitalize {
|
|
191
|
+
text-transform: capitalize;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.bold {
|
|
195
|
+
font-weight: bold;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.m {
|
|
199
|
+
font-family: monospace;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.gray {
|
|
203
|
+
filter: grayscale(1);
|
|
204
|
+
}
|
|
205
|
+
</style>
|
|
206
|
+
<div class="session">
|
|
207
|
+
<style>
|
|
208
|
+
.session-in-log-out {
|
|
209
|
+
display: block;
|
|
210
|
+
}
|
|
211
|
+
.session-inl-log-out {
|
|
212
|
+
display: inline-table;
|
|
213
|
+
}
|
|
214
|
+
.session-fl-log-out {
|
|
215
|
+
display: flow-root;
|
|
216
|
+
}
|
|
217
|
+
.session-in-log-in {
|
|
218
|
+
display: none;
|
|
219
|
+
}
|
|
220
|
+
.session-inl-log-in {
|
|
221
|
+
display: none;
|
|
222
|
+
}
|
|
223
|
+
.session-fl-log-in {
|
|
224
|
+
display: none;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
227
|
+
</div>
|
|
228
|
+
<div class="theme"></div>
|
|
229
|
+
${baseSsrLib
|
|
230
|
+
? html`<script>
|
|
231
|
+
${baseSsrLib};
|
|
232
|
+
</script>`
|
|
233
|
+
: ''}
|
|
234
|
+
${ssrBodyComponents} ${buildId ? html`<script async type="module" src="./${buildId}.js"></script>` : ''}
|
|
235
|
+
</body>
|
|
236
|
+
</html>
|
|
237
|
+
`;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const maintenance = async ({ Translate }) => {
|
|
2
|
+
const icon = html`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 24 24">
|
|
3
|
+
<path
|
|
4
|
+
fill="none"
|
|
5
|
+
stroke="currentColor"
|
|
6
|
+
stroke-linecap="round"
|
|
7
|
+
stroke-linejoin="round"
|
|
8
|
+
stroke-width="2"
|
|
9
|
+
d="M3 7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v2a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3zm9 13H6a3 3 0 0 1-3-3v-2a3 3 0 0 1 3-3h10.5m-.5 6a2 2 0 1 0 4 0a2 2 0 1 0-4 0m2-3.5V16m0 4v1.5m3.032-5.25l-1.299.75m-3.463 2l-1.3.75m0-3.5l1.3.75m3.463 2l1.3.75M7 8v.01M7 16v.01"
|
|
10
|
+
/>
|
|
11
|
+
</svg>`;
|
|
12
|
+
return html` <div class="abs center" style="top: 45%">
|
|
13
|
+
${icon}
|
|
14
|
+
<br />
|
|
15
|
+
<br />${Translate('server-maintenance')}
|
|
16
|
+
</div>`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const noInternet = async ({ Translate }) => {
|
|
20
|
+
const icon = html`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 20 20">
|
|
21
|
+
<path
|
|
22
|
+
fill="currentColor"
|
|
23
|
+
d="M10 18q.128 0 .254-.004a5.5 5.5 0 0 1-.698-1.083c-.536-.207-1.098-.793-1.578-1.821A9.3 9.3 0 0 1 7.42 13.5h1.672q.096-.52.284-1h-2.17A15 15 0 0 1 7 10c0-.883.073-1.725.206-2.5h5.588c.092.541.156 1.115.186 1.713q.48-.138.992-.188a16 16 0 0 0-.165-1.525h2.733c.251.656.406 1.36.448 2.094q.543.276 1.008.66A8 8 0 1 0 10 18m0-15c.657 0 1.407.59 2.022 1.908c.217.466.406 1.002.559 1.592H7.419c.153-.59.342-1.126.56-1.592C8.592 3.59 9.342 3 10 3M7.072 4.485A10.5 10.5 0 0 0 6.389 6.5H3.936a7.02 7.02 0 0 1 3.778-3.118c-.241.33-.456.704-.642 1.103M6.192 7.5A16 16 0 0 0 6 10c0 .87.067 1.712.193 2.5H3.46A7 7 0 0 1 3 10c0-.88.163-1.724.46-2.5zm.197 6c.176.743.407 1.422.683 2.015c.186.399.401.773.642 1.103A7.02 7.02 0 0 1 3.936 13.5zm5.897-10.118A7.02 7.02 0 0 1 16.064 6.5H13.61a10.5 10.5 0 0 0-.683-2.015a6.6 6.6 0 0 0-.642-1.103M19 14.5a4.5 4.5 0 1 1-9 0a4.5 4.5 0 0 1 9 0M14.5 12a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 1 0v-2a.5.5 0 0 0-.5-.5m0 5.125a.625.625 0 1 0 0-1.25a.625.625 0 0 0 0 1.25"
|
|
24
|
+
/>
|
|
25
|
+
</svg>`;
|
|
26
|
+
return html` <div class="abs center" style="top: 45%">
|
|
27
|
+
${icon}
|
|
28
|
+
<br />
|
|
29
|
+
<br />${Translate('no-internet-connection')}
|
|
30
|
+
</div>`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const e404 = async ({ Translate }) => {
|
|
34
|
+
const icon = html`
|
|
35
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 24 24">
|
|
36
|
+
<path
|
|
37
|
+
fill="currentColor"
|
|
38
|
+
d="M15.097 5.904A6.5 6.5 0 0 0 4 10.504l.001 1h-2v-1a8.5 8.5 0 1 1 15.176 5.258l5.344 5.345l-1.414 1.414l-5.344-5.345A8.48 8.48 0 0 1 10.5 19h-1v-2h1a6.5 6.5 0 0 0 4.596-11.096M1.672 13.257L4.5 16.086l2.829-2.829l1.414 1.415L5.915 17.5l2.828 2.828l-1.414 1.415L4.5 18.914l-2.828 2.829l-1.414-1.415L3.086 17.5L.258 14.672z"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
`;
|
|
42
|
+
return html` <div class="abs center" style="top: 45%">
|
|
43
|
+
${icon}
|
|
44
|
+
<br />
|
|
45
|
+
<br />
|
|
46
|
+
<span class="bold">404</span>
|
|
47
|
+
<br />
|
|
48
|
+
<br />${Translate('page-not-found')} <br />
|
|
49
|
+
<br />
|
|
50
|
+
<a href="${location.origin}">${Translate('back')}</a>
|
|
51
|
+
</div>`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const e500 = async ({ Translate }) => {
|
|
55
|
+
const icon = html`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 20 20">
|
|
56
|
+
<path
|
|
57
|
+
fill="currentColor"
|
|
58
|
+
d="M6 2a2 2 0 0 0-2 2v5.207a5.5 5.5 0 0 1 1-.185V4a1 1 0 0 1 1-1h4v3.5A1.5 1.5 0 0 0 11.5 8H15v8a1 1 0 0 1-1 1h-3.6a5.5 5.5 0 0 1-.657 1H14a2 2 0 0 0 2-2V7.414a1.5 1.5 0 0 0-.44-1.06l-3.914-3.915A1.5 1.5 0 0 0 10.586 2zm8.793 5H11.5a.5.5 0 0 1-.5-.5V3.207zM10 14.5a4.5 4.5 0 1 1-9 0a4.5 4.5 0 0 1 9 0M5.5 12a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 1 0v-2a.5.5 0 0 0-.5-.5m0 5.125a.625.625 0 1 0 0-1.25a.625.625 0 0 0 0 1.25"
|
|
59
|
+
/>
|
|
60
|
+
</svg>`;
|
|
61
|
+
return html` <div class="abs center" style="top: 45%">
|
|
62
|
+
${icon}
|
|
63
|
+
<br />
|
|
64
|
+
<br />
|
|
65
|
+
<span class="bold">500</span>
|
|
66
|
+
<br />
|
|
67
|
+
<br />${Translate('page-broken')} <br />
|
|
68
|
+
<br />
|
|
69
|
+
<a href="${location.origin}">${Translate('back')}</a>
|
|
70
|
+
</div>`;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const Alert = { maintenance, noInternet, e404, e500 };
|
|
74
|
+
|
|
75
|
+
export { Alert, e404 };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const s = (el) => document.querySelector(el);
|
|
2
|
+
|
|
3
|
+
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
|
|
4
|
+
|
|
5
|
+
const htmls = (el, html) => (s(el).innerHTML = html);
|
|
6
|
+
|
|
7
|
+
const s4 = () => (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
8
|
+
|
|
9
|
+
const range = (start, end) => {
|
|
10
|
+
return end < start
|
|
11
|
+
? range(end, start).reverse()
|
|
12
|
+
: Array.apply(0, Array(end - start + 1)).map((element, index) => index + start);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
16
|
+
|
|
17
|
+
const newInstance = (obj) => {
|
|
18
|
+
// structuredClone() 2022 ES6 feature
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(JSON.stringify(obj));
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return { error: error.message };
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const fullScreenIn = () => {
|
|
27
|
+
const elem = document.documentElement;
|
|
28
|
+
if (elem.requestFullscreen) {
|
|
29
|
+
elem.requestFullscreen();
|
|
30
|
+
} else if (elem.mozRequestFullScreen) {
|
|
31
|
+
/* Firefox */
|
|
32
|
+
elem.mozRequestFullScreen();
|
|
33
|
+
} else if (elem.webkitRequestFullscreen) {
|
|
34
|
+
/* Chrome, Safari & Opera */
|
|
35
|
+
elem.webkitRequestFullscreen();
|
|
36
|
+
} else if (elem.msRequestFullscreen) {
|
|
37
|
+
/* IE/Edge */
|
|
38
|
+
elem = window.top.document.body; //To break out of frame in IE
|
|
39
|
+
elem.msRequestFullscreen();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const borderChar = (px, color, selectors) => {
|
|
44
|
+
if (selectors) {
|
|
45
|
+
return selectors
|
|
46
|
+
.map(
|
|
47
|
+
(selector) => html`
|
|
48
|
+
<style>
|
|
49
|
+
${selector} {
|
|
50
|
+
text-shadow: ${px}px -${px}px ${px}px ${color}, -${px}px ${px}px ${px}px ${color},
|
|
51
|
+
-${px}px -${px}px ${px}px ${color}, ${px}px ${px}px ${px}px ${color};
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
54
|
+
`,
|
|
55
|
+
)
|
|
56
|
+
.join('');
|
|
57
|
+
}
|
|
58
|
+
return html`
|
|
59
|
+
text-shadow: ${px}px -${px}px ${px}px ${color}, -${px}px ${px}px ${px}px ${color}, -${px}px -${px}px ${px}px
|
|
60
|
+
${color}, ${px}px ${px}px ${px}px ${color};
|
|
61
|
+
`;
|
|
62
|
+
};
|
|
63
|
+
const getLang = () =>
|
|
64
|
+
localStorage.getItem('lang') ? localStorage.getItem('lang') : navigator.language || navigator.userLanguage;
|
|
65
|
+
|
|
66
|
+
const loggerFactory = (meta) => {
|
|
67
|
+
meta = meta.url.split('/').pop();
|
|
68
|
+
const types = ['error', 'warn', 'info', 'debug'];
|
|
69
|
+
const logger = {
|
|
70
|
+
log: function (type, args) {
|
|
71
|
+
if (location.hostname !== 'localhost' && console.log() !== null) {
|
|
72
|
+
console.log = () => null;
|
|
73
|
+
console.error = () => null;
|
|
74
|
+
console.info = () => null;
|
|
75
|
+
console.warn = () => null;
|
|
76
|
+
}
|
|
77
|
+
return location.hostname === 'localhost'
|
|
78
|
+
? console[type](`[${meta}] ${new Date().toISOString()} ${type}:`, ...args)
|
|
79
|
+
: null;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
types.map(
|
|
83
|
+
(type) =>
|
|
84
|
+
(logger[type] = function (...args) {
|
|
85
|
+
return this.log(type, args);
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
return logger;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export { getLang, s, append, s4, range, timer, htmls, newInstance, fullScreenIn, borderChar, loggerFactory };
|