underpost 2.6.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 +14 -0
- package/.env.development +8 -0
- package/.env.production +8 -0
- package/.env.test +8 -0
- package/.nycrc +9 -0
- package/.prettierignore +13 -0
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +72 -0
- package/.vscode/settings.json +99 -0
- package/Dockerfile +88 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/bin/db.js +119 -0
- package/bin/deploy.js +600 -0
- package/bin/dns.js +1 -0
- package/bin/file.js +92 -0
- package/bin/help.js +110 -0
- package/bin/index.js +29 -0
- package/bin/install.js +357 -0
- package/bin/shortcut.js +44 -0
- package/bin/ssl.js +61 -0
- package/bin/util.js +182 -0
- package/bin/vs.js +35 -0
- package/conf.js +244 -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 +128 -0
- package/prometheus.yml +36 -0
- package/setup.sh +25 -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 +51 -0
- package/src/api/file/file.model.js +19 -0
- package/src/api/file/file.router.js +20 -0
- package/src/api/file/file.service.js +70 -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.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 +91 -0
- package/src/client/components/core/CalendarCore.js +319 -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 +708 -0
- package/src/client/components/core/Content.js +49 -0
- package/src/client/components/core/Css.js +1027 -0
- package/src/client/components/core/CssCore.js +792 -0
- package/src/client/components/core/D3Chart.js +44 -0
- package/src/client/components/core/Docs.js +130 -0
- package/src/client/components/core/DropDown.js +164 -0
- package/src/client/components/core/EventsUI.js +54 -0
- package/src/client/components/core/FileExplorer.js +624 -0
- package/src/client/components/core/FullScreen.js +45 -0
- package/src/client/components/core/Input.js +259 -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 +157 -0
- package/src/client/components/core/LogIn.js +181 -0
- package/src/client/components/core/LogOut.js +52 -0
- package/src/client/components/core/Logger.js +26 -0
- package/src/client/components/core/Modal.js +1596 -0
- package/src/client/components/core/NotificationManager.js +84 -0
- package/src/client/components/core/Panel.js +413 -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 +27 -0
- package/src/client/components/core/Router.js +77 -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 +408 -0
- package/src/client/components/core/Validator.js +100 -0
- package/src/client/components/core/VanillaJs.js +454 -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 +272 -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/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/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 +152 -0
- package/src/client/services/crypto/crypto.service.js +70 -0
- package/src/client/services/default/default.management.js +345 -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 +16 -0
- package/src/client/ssr/body-components/CacheControl.js +113 -0
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -0
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/head-components/Css.js +241 -0
- package/src/client/ssr/head-components/DefaultScripts.js +3 -0
- package/src/client/ssr/head-components/Microdata.js +11 -0
- package/src/client/ssr/head-components/Production.js +1 -0
- package/src/client/ssr/head-components/PwaDefault.js +60 -0
- package/src/client/ssr/head-components/Seo.js +14 -0
- package/src/client/sw/default.sw.js +201 -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 +25 -0
- package/src/db/DataBaseProvider.js +34 -0
- package/src/db/mariadb/MariaDB.js +33 -0
- package/src/db/mongo/MongooseDB.js +46 -0
- package/src/dns.js +22 -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 +44 -0
- package/src/runtime/nginx/Nginx.js +3 -0
- package/src/runtime/xampp/Xampp.js +49 -0
- package/src/server/auth.js +204 -0
- package/src/server/backup.js +83 -0
- package/src/server/client-build-live.js +72 -0
- package/src/server/client-build.js +688 -0
- package/src/server/client-dev-server.js +58 -0
- package/src/server/client-formatted.js +48 -0
- package/src/server/client-icons.js +150 -0
- package/src/server/conf.js +611 -0
- package/src/server/dns.js +87 -0
- package/src/server/downloader.js +42 -0
- package/src/server/logger.js +135 -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/proxy.js +118 -0
- package/src/server/runtime.js +393 -0
- package/src/server/ssl.js +107 -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,272 @@
|
|
|
1
|
+
import { BtnIcon } from './BtnIcon.js';
|
|
2
|
+
import { s4 } from './CommonJs.js';
|
|
3
|
+
import { EventsUI } from './EventsUI.js';
|
|
4
|
+
import { LoadingAnimation } from './LoadingAnimation.js';
|
|
5
|
+
import { loggerFactory } from './Logger.js';
|
|
6
|
+
import { LoadRouter } from './Router.js';
|
|
7
|
+
import { Translate } from './Translate.js';
|
|
8
|
+
import { getProxyPath, htmls, s } from './VanillaJs.js';
|
|
9
|
+
|
|
10
|
+
const logger = loggerFactory(import.meta);
|
|
11
|
+
|
|
12
|
+
const Worker = {
|
|
13
|
+
devMode: () => location.origin.match('localhost') || location.origin.match('127.0.0.1'),
|
|
14
|
+
instance: async function ({ router, render }) {
|
|
15
|
+
logger.warn('Init');
|
|
16
|
+
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
|
17
|
+
logger.info('The controller of current browsing context has changed.');
|
|
18
|
+
});
|
|
19
|
+
navigator.serviceWorker.ready.then((worker) => {
|
|
20
|
+
logger.info('Ready', worker);
|
|
21
|
+
// event message
|
|
22
|
+
navigator.serviceWorker.addEventListener('message', (event) => {
|
|
23
|
+
logger.info('Received event message', event.data);
|
|
24
|
+
const { status } = event.data;
|
|
25
|
+
|
|
26
|
+
switch (status) {
|
|
27
|
+
case 'loader':
|
|
28
|
+
{
|
|
29
|
+
LoadingAnimation.RenderCurrentSrcLoad(event);
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// if (navigator.serviceWorker.controller)
|
|
39
|
+
// navigator.serviceWorker.controller.postMessage({
|
|
40
|
+
// title: 'Hello from Client event message',
|
|
41
|
+
// });
|
|
42
|
+
|
|
43
|
+
// broadcast message
|
|
44
|
+
// const channel = new BroadcastChannel('sw-messages');
|
|
45
|
+
// channel.addEventListener('message', (event) => {
|
|
46
|
+
// logger.info('Received broadcast message', event.data);
|
|
47
|
+
// });
|
|
48
|
+
// channel.postMessage({ title: 'Hello from Client broadcast message' });
|
|
49
|
+
// channel.close();
|
|
50
|
+
});
|
|
51
|
+
const isInstall = await this.status();
|
|
52
|
+
if (!isInstall) await this.install();
|
|
53
|
+
else await this.update();
|
|
54
|
+
// else if (location.hostname === 'localhost') await this.update();
|
|
55
|
+
this.RouterInstance = router();
|
|
56
|
+
await render();
|
|
57
|
+
LoadRouter(this.RouterInstance);
|
|
58
|
+
LoadingAnimation.removeSplashScreen();
|
|
59
|
+
if (this.devMode()) {
|
|
60
|
+
const delayLiveReload = 1250;
|
|
61
|
+
// Dev mode
|
|
62
|
+
|
|
63
|
+
window.addEventListener('visibilitychange', (event) => {
|
|
64
|
+
if (document.visibilityState === 'visible') {
|
|
65
|
+
Worker.reload(delayLiveReload);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
window.addEventListener('focus', function () {
|
|
69
|
+
// Worker.reload(delayLiveReload);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
window.serviceWorkerReady = true;
|
|
73
|
+
},
|
|
74
|
+
// Get the current service worker registration.
|
|
75
|
+
getRegistration: async function () {
|
|
76
|
+
return await navigator.serviceWorker.getRegistration();
|
|
77
|
+
},
|
|
78
|
+
reload: async function (timeOut = 3000) {
|
|
79
|
+
return await new Promise((resolve) => {
|
|
80
|
+
if (navigator.serviceWorker && navigator.serviceWorker.controller)
|
|
81
|
+
navigator.serviceWorker.controller.postMessage({
|
|
82
|
+
status: 'skipWaiting',
|
|
83
|
+
});
|
|
84
|
+
// (location.href = `${location.origin}${location.pathname}${location.search}`)
|
|
85
|
+
setTimeout(() => resolve(location.reload()), timeOut);
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
update: async function () {
|
|
89
|
+
const isInstall = await this.status();
|
|
90
|
+
if (isInstall) {
|
|
91
|
+
const cacheNames = await caches.keys();
|
|
92
|
+
for (const cacheName of cacheNames) {
|
|
93
|
+
if (cacheName.match('components/') || cacheName.match('services/') || cacheName.match('.index.js')) {
|
|
94
|
+
await caches.delete(cacheName);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.updateServiceWorker();
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
updateServiceWorker: function () {},
|
|
101
|
+
status: function () {
|
|
102
|
+
let status = false;
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
if ('serviceWorker' in navigator) {
|
|
105
|
+
navigator.serviceWorker
|
|
106
|
+
.getRegistrations()
|
|
107
|
+
.then((registrations) => {
|
|
108
|
+
for (const registration of registrations) {
|
|
109
|
+
if (registration.installing) logger.info('installing', registration);
|
|
110
|
+
else if (registration.waiting) logger.info('waiting', registration);
|
|
111
|
+
else if (registration.active) {
|
|
112
|
+
logger.info('active', registration);
|
|
113
|
+
this.updateServiceWorker = () => registration.update();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (registrations.length > 0) status = true;
|
|
117
|
+
})
|
|
118
|
+
.catch((...args) => {
|
|
119
|
+
logger.error(...args);
|
|
120
|
+
return resolve(false);
|
|
121
|
+
})
|
|
122
|
+
.finally((...args) => {
|
|
123
|
+
logger.info('Finally status', args);
|
|
124
|
+
return resolve(status);
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
logger.warn('Disabled');
|
|
128
|
+
return resolve(false);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
install: function () {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
if ('serviceWorker' in navigator) {
|
|
135
|
+
navigator.serviceWorker
|
|
136
|
+
.register(`/sw.js`, {
|
|
137
|
+
// scope: getProxyPath(),
|
|
138
|
+
// scope: '/',
|
|
139
|
+
type: 'module',
|
|
140
|
+
})
|
|
141
|
+
.then((...args) => {
|
|
142
|
+
logger.warn('Already Registered', args);
|
|
143
|
+
})
|
|
144
|
+
.catch((...args) => {
|
|
145
|
+
logger.error(...args);
|
|
146
|
+
return resolve(args);
|
|
147
|
+
})
|
|
148
|
+
.finally((...args) => {
|
|
149
|
+
logger.info('Finally install', args);
|
|
150
|
+
return resolve(args);
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
logger.warn('Disabled');
|
|
154
|
+
return resolve();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
uninstall: function () {
|
|
159
|
+
return new Promise(async (resolve, reject) => {
|
|
160
|
+
if ('serviceWorker' in navigator) {
|
|
161
|
+
navigator.serviceWorker
|
|
162
|
+
.getRegistrations()
|
|
163
|
+
.then(async (registrations) => {
|
|
164
|
+
const cacheNames = await caches.keys();
|
|
165
|
+
for (const cacheName of cacheNames) await caches.delete(cacheName);
|
|
166
|
+
for (const registration of registrations) {
|
|
167
|
+
logger.info('remove', registration);
|
|
168
|
+
registration.unregister();
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
.catch((...args) => {
|
|
172
|
+
logger.error(...args);
|
|
173
|
+
return resolve(args);
|
|
174
|
+
})
|
|
175
|
+
.finally((...args) => {
|
|
176
|
+
logger.info('Finally uninstall', args);
|
|
177
|
+
return resolve(args);
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
logger.warn('Disabled');
|
|
181
|
+
return resolve();
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
notificationActive: false,
|
|
186
|
+
notificationRequestPermission: function () {
|
|
187
|
+
return new Promise((resolve, reject) =>
|
|
188
|
+
Notification.requestPermission().then((result) => {
|
|
189
|
+
if (result === 'granted') {
|
|
190
|
+
this.notificationActive = true;
|
|
191
|
+
resolve(true);
|
|
192
|
+
} else {
|
|
193
|
+
this.notificationActive = false;
|
|
194
|
+
resolve(false);
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
notificationShow: function () {
|
|
200
|
+
Notification.requestPermission().then((result) => {
|
|
201
|
+
if (result === 'granted') {
|
|
202
|
+
navigator.serviceWorker.ready.then((registration) => {
|
|
203
|
+
registration.showNotification('Vibration Sample', {
|
|
204
|
+
body: 'Buzz! Buzz!',
|
|
205
|
+
icon: '../images/touch/chrome-touch-icon.png',
|
|
206
|
+
vibrate: [200, 100, 200, 100, 200, 100, 200],
|
|
207
|
+
tag: 'vibration-sample',
|
|
208
|
+
requireInteraction: true, // boolean to manually close the notification
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
// TODO: GPS management
|
|
215
|
+
RenderSetting: async function () {
|
|
216
|
+
setTimeout(() => {
|
|
217
|
+
EventsUI.onClick(`.btn-clean-cache`, async (e) => {
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
// await this.update();
|
|
220
|
+
localStorage.clear();
|
|
221
|
+
await this.uninstall();
|
|
222
|
+
await this.reload();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
return html` <div class="in">
|
|
226
|
+
${await BtnIcon.Render({
|
|
227
|
+
class: 'inl section-mp btn-custom btn-install-service-controller hide',
|
|
228
|
+
label: html`<i class="fas fa-download"></i> ${Translate.Render('Install control service')}`,
|
|
229
|
+
})}
|
|
230
|
+
${await BtnIcon.Render({
|
|
231
|
+
class: 'inl section-mp btn-custom btn-uninstall-service-controller hide',
|
|
232
|
+
label: html`<i class="far fa-trash-alt"></i> ${Translate.Render('Uninstall control service')}`,
|
|
233
|
+
})}
|
|
234
|
+
${await BtnIcon.Render({
|
|
235
|
+
class: 'inl section-mp btn-custom btn-clean-cache',
|
|
236
|
+
label: html`<i class="fa-solid fa-broom"></i> ${Translate.Render('clean-cache')}`,
|
|
237
|
+
})}
|
|
238
|
+
${await BtnIcon.Render({
|
|
239
|
+
class: 'inl section-mp btn-custom btn-reload hide',
|
|
240
|
+
label: html`<i class="fas fa-sync-alt"></i> ${Translate.Render('Reload')}`,
|
|
241
|
+
})}
|
|
242
|
+
</div>`;
|
|
243
|
+
return;
|
|
244
|
+
s(`.btn-uninstall-service-controller`).classList.add('hide');
|
|
245
|
+
EventsUI.onClick(`.btn-install-service-controller`, async (e) => {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
const result = await this.install();
|
|
248
|
+
s(`.btn-install-service-controller`).classList.add('hide');
|
|
249
|
+
s(`.btn-uninstall-service-controller`).classList.remove('hide');
|
|
250
|
+
});
|
|
251
|
+
EventsUI.onClick(`.btn-uninstall-service-controller`, async (e) => {
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
const result = await this.uninstall();
|
|
254
|
+
s(`.btn-uninstall-service-controller`).classList.add('hide');
|
|
255
|
+
s(`.btn-install-service-controller`).classList.remove('hide');
|
|
256
|
+
});
|
|
257
|
+
EventsUI.onClick(`.btn-reload`, async (e) => {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
location.reload();
|
|
260
|
+
});
|
|
261
|
+
const workerStatus = await this.status();
|
|
262
|
+
if (workerStatus) {
|
|
263
|
+
s(`.btn-install-service-controller`).classList.add('hide');
|
|
264
|
+
s(`.btn-uninstall-service-controller`).classList.remove('hide');
|
|
265
|
+
} else {
|
|
266
|
+
s(`.btn-uninstall-service-controller`).classList.add('hide');
|
|
267
|
+
s(`.btn-install-service-controller`).classList.remove('hide');
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export { Worker };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const ModelElement = {
|
|
2
|
+
user: () => {
|
|
3
|
+
return {
|
|
4
|
+
user: {
|
|
5
|
+
_id: '',
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const BaseElement = () => {
|
|
12
|
+
return {
|
|
13
|
+
user: {
|
|
14
|
+
main: {
|
|
15
|
+
model: {
|
|
16
|
+
...ModelElement.user(),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
chat: {},
|
|
21
|
+
mailer: {},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const DefaultParams = {
|
|
26
|
+
EVENT_CALLBACK_TIME: 45,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { BaseElement, ModelElement, DefaultParams };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const CssDefaultDark = {
|
|
2
|
+
theme: 'default-dark',
|
|
3
|
+
dark: true,
|
|
4
|
+
render: async () => html` <style></style> `,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const CssDefaultLight = {
|
|
8
|
+
theme: 'default-light',
|
|
9
|
+
dark: false,
|
|
10
|
+
render: async () => html` <style></style> `,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { CssDefaultDark, CssDefaultLight };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { loggerFactory } from '../core/Logger.js';
|
|
2
|
+
import { BaseElement } from './CommonDefault.js';
|
|
3
|
+
|
|
4
|
+
const logger = loggerFactory(import.meta);
|
|
5
|
+
|
|
6
|
+
const ElementsDefault = {
|
|
7
|
+
Data: BaseElement(),
|
|
8
|
+
Interval: {},
|
|
9
|
+
LocalDataScope: {},
|
|
10
|
+
Init: function (options = { type: 'user', id: 'main', element: {} }) {
|
|
11
|
+
const { type, id, element } = options;
|
|
12
|
+
this.Data[type][id] = {
|
|
13
|
+
...BaseElement()[type].main,
|
|
14
|
+
...this.Data[type][id],
|
|
15
|
+
...element,
|
|
16
|
+
};
|
|
17
|
+
if (!this.Interval[type]) this.Interval[type] = {};
|
|
18
|
+
if (!this.Interval[type][id]) this.Interval[type][id] = {};
|
|
19
|
+
if (!this.LocalDataScope[type]) this.LocalDataScope[type] = {};
|
|
20
|
+
if (!this.LocalDataScope[type][id])
|
|
21
|
+
this.LocalDataScope[type][id] = {
|
|
22
|
+
path: [],
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
removeAll: function () {
|
|
26
|
+
for (const type of Object.keys(this.Data)) {
|
|
27
|
+
for (const id of Object.keys(this.Data[type])) {
|
|
28
|
+
if (this.Interval[type] && this.Interval[type][id]) {
|
|
29
|
+
for (const interval of Object.keys(this.Interval[type][id])) clearInterval(this.Interval[type][id][interval]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this.Interval = {};
|
|
34
|
+
this.Data = BaseElement();
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { ElementsDefault };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UserService } from '../../services/user/user.service.js';
|
|
2
|
+
import { Auth } from '../core/Auth.js';
|
|
3
|
+
import { LogIn } from '../core/LogIn.js';
|
|
4
|
+
import { s } from '../core/VanillaJs.js';
|
|
5
|
+
import { ElementsDefault } from './ElementsDefault.js';
|
|
6
|
+
|
|
7
|
+
const LogInDefault = async function () {
|
|
8
|
+
LogIn.Event['LogInDefault'] = async (options) => {
|
|
9
|
+
const { token, user } = options;
|
|
10
|
+
|
|
11
|
+
if (token) {
|
|
12
|
+
localStorage.setItem('jwt', token);
|
|
13
|
+
Auth.setToken(token);
|
|
14
|
+
}
|
|
15
|
+
ElementsDefault.Data.user.main.model.user = user;
|
|
16
|
+
|
|
17
|
+
s(`.main-btn-log-in`).style.display = 'none';
|
|
18
|
+
s(`.main-btn-sign-up`).style.display = 'none';
|
|
19
|
+
s(`.main-btn-log-out`).style.display = null;
|
|
20
|
+
s(`.main-btn-account`).style.display = null;
|
|
21
|
+
|
|
22
|
+
if (s(`.modal-log-in`)) s(`.btn-close-modal-log-in`).click();
|
|
23
|
+
if (s(`.modal-sign-up`)) s(`.btn-close-modal-sign-up`).click();
|
|
24
|
+
};
|
|
25
|
+
const token = localStorage.getItem('jwt');
|
|
26
|
+
if (token) {
|
|
27
|
+
Auth.setToken(token);
|
|
28
|
+
const result = await UserService.get({ id: 'auth' });
|
|
29
|
+
if (result.status === 'success' && result.data) {
|
|
30
|
+
const user = result.data;
|
|
31
|
+
await LogIn.Trigger({
|
|
32
|
+
token,
|
|
33
|
+
user,
|
|
34
|
+
});
|
|
35
|
+
} else localStorage.removeItem('jwt');
|
|
36
|
+
} else {
|
|
37
|
+
// Anon
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { LogInDefault };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Auth } from '../core/Auth.js';
|
|
2
|
+
import { LogOut } from '../core/LogOut.js';
|
|
3
|
+
import { NotificationManager } from '../core/NotificationManager.js';
|
|
4
|
+
import { Translate } from '../core/Translate.js';
|
|
5
|
+
import { s } from '../core/VanillaJs.js';
|
|
6
|
+
import { ElementsDefault } from './ElementsDefault.js';
|
|
7
|
+
|
|
8
|
+
const LogOutDefault = async function () {
|
|
9
|
+
LogOut.Event['LogOutDefault'] = async () => {
|
|
10
|
+
localStorage.removeItem('jwt');
|
|
11
|
+
s(`.main-btn-log-out`).style.display = 'none';
|
|
12
|
+
s(`.main-btn-account`).style.display = 'none';
|
|
13
|
+
s(`.main-btn-log-in`).style.display = null;
|
|
14
|
+
s(`.main-btn-sign-up`).style.display = null;
|
|
15
|
+
if (s(`.modal-log-out`)) s(`.btn-close-modal-log-out`).click();
|
|
16
|
+
if (s(`.modal-account`)) s(`.btn-close-modal-account`).click();
|
|
17
|
+
|
|
18
|
+
ElementsDefault.Data.user.main.model.user = { _id: '' };
|
|
19
|
+
Auth.deleteToken();
|
|
20
|
+
|
|
21
|
+
NotificationManager.Push({
|
|
22
|
+
html: Translate.Render(`success-logout`),
|
|
23
|
+
status: 'success',
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { LogOutDefault };
|