underpost 2.8.87 → 2.8.88
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/.env.development +35 -3
- package/.env.production +39 -4
- package/.env.test +35 -3
- package/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/npmpkg.ci.yml +1 -1
- package/.github/workflows/pwa-microservices-template-page.cd.yml +6 -5
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +3 -3
- package/README.md +56 -2
- package/bin/build.js +4 -0
- package/bin/deploy.js +62 -8
- package/bin/file.js +3 -2
- package/cli.md +8 -2
- package/conf.js +30 -4
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +174 -0
- package/manifests/deployment/dd-test-development/proxy.yaml +51 -0
- package/package.json +6 -5
- package/src/api/core/core.router.js +2 -1
- package/src/api/default/default.controller.js +6 -1
- package/src/api/default/default.router.js +6 -2
- package/src/api/default/default.service.js +10 -1
- package/src/api/document/document.controller.js +66 -0
- package/src/api/document/document.model.js +51 -0
- package/src/api/document/document.router.js +24 -0
- package/src/api/document/document.service.js +125 -0
- package/src/api/file/file.controller.js +15 -1
- package/src/api/file/file.router.js +2 -1
- package/src/api/test/test.router.js +1 -1
- package/src/api/user/postman_collection.json +216 -0
- package/src/api/user/user.controller.js +25 -60
- package/src/api/user/user.model.js +29 -7
- package/src/api/user/user.router.js +9 -3
- package/src/api/user/user.service.js +84 -32
- package/src/cli/baremetal.js +33 -3
- package/src/cli/cloud-init.js +11 -0
- package/src/cli/cron.js +0 -1
- package/src/cli/deploy.js +46 -23
- package/src/cli/index.js +5 -0
- package/src/cli/lxd.js +7 -0
- package/src/cli/repository.js +42 -6
- package/src/cli/run.js +45 -13
- package/src/cli/ssh.js +20 -6
- package/src/client/Default.index.js +42 -1
- package/src/client/components/core/Account.js +10 -2
- package/src/client/components/core/AgGrid.js +30 -8
- package/src/client/components/core/Auth.js +99 -56
- package/src/client/components/core/BtnIcon.js +3 -2
- package/src/client/components/core/CalendarCore.js +2 -3
- package/src/client/components/core/CommonJs.js +1 -2
- package/src/client/components/core/Content.js +15 -12
- package/src/client/components/core/Css.js +2 -1
- package/src/client/components/core/CssCore.js +6 -1
- package/src/client/components/core/Docs.js +5 -5
- package/src/client/components/core/FileExplorer.js +3 -3
- package/src/client/components/core/Input.js +22 -17
- package/src/client/components/core/JoyStick.js +2 -2
- package/src/client/components/core/LoadingAnimation.js +2 -2
- package/src/client/components/core/LogIn.js +16 -23
- package/src/client/components/core/LogOut.js +5 -1
- package/src/client/components/core/Logger.js +4 -1
- package/src/client/components/core/Modal.js +82 -53
- package/src/client/components/core/ObjectLayerEngineModal.js +2 -1
- package/src/client/components/core/Pagination.js +207 -0
- package/src/client/components/core/Panel.js +10 -10
- package/src/client/components/core/PanelForm.js +130 -33
- package/src/client/components/core/Recover.js +2 -2
- package/src/client/components/core/Router.js +210 -34
- package/src/client/components/core/SignUp.js +1 -2
- package/src/client/components/core/Stream.js +1 -1
- package/src/client/components/core/VanillaJs.js +3 -84
- package/src/client/components/core/Worker.js +2 -2
- package/src/client/components/default/LogInDefault.js +0 -6
- package/src/client/components/default/LogOutDefault.js +0 -16
- package/src/client/components/default/MenuDefault.js +97 -44
- package/src/client/components/default/RoutesDefault.js +5 -2
- package/src/client/services/core/core.service.js +8 -20
- package/src/client/services/default/default.management.js +115 -18
- package/src/client/services/default/default.service.js +13 -4
- package/src/client/services/document/document.service.js +97 -0
- package/src/client/services/file/file.service.js +2 -0
- package/src/client/services/test/test.service.js +3 -0
- package/src/client/services/user/user.management.js +6 -0
- package/src/client/services/user/user.service.js +15 -4
- package/src/client/ssr/Render.js +1 -1
- package/src/client/ssr/head/DefaultScripts.js +3 -0
- package/src/client/ssr/head/Seo.js +1 -0
- package/src/index.js +24 -2
- package/src/runtime/lampp/Lampp.js +89 -2
- package/src/runtime/xampp/Xampp.js +48 -1
- package/src/server/auth.js +519 -155
- package/src/server/backup.js +2 -2
- package/src/server/conf.js +66 -8
- package/src/server/process.js +2 -1
- package/src/server/runtime.js +135 -286
- package/src/server/ssl.js +1 -2
- package/src/server/ssr.js +85 -0
- package/src/server/start.js +2 -2
- package/src/server/valkey.js +2 -1
|
@@ -17,10 +17,11 @@ import { LogOut } from '../core/LogOut.js';
|
|
|
17
17
|
import { buildBadgeToolTipMenuOption, Modal, renderMenuLabel, renderViewTitle } from '../core/Modal.js';
|
|
18
18
|
import { SignUp } from '../core/SignUp.js';
|
|
19
19
|
import { Translate } from '../core/Translate.js';
|
|
20
|
-
import {
|
|
20
|
+
import { htmls, s } from '../core/VanillaJs.js';
|
|
21
|
+
import { getProxyPath } from '../core/Router.js';
|
|
21
22
|
import { ElementsDefault } from './ElementsDefault.js';
|
|
22
23
|
import Sortable from 'sortablejs';
|
|
23
|
-
import { RouterDefault } from './RoutesDefault.js';
|
|
24
|
+
import { RouterDefault, BannerAppTemplate } from './RoutesDefault.js';
|
|
24
25
|
import { SettingsDefault } from './SettingsDefault.js';
|
|
25
26
|
import { Badge } from '../core/Badge.js';
|
|
26
27
|
import { Docs } from '../core/Docs.js';
|
|
@@ -28,6 +29,8 @@ import { Recover } from '../core/Recover.js';
|
|
|
28
29
|
import { DefaultManagement } from '../../services/default/default.management.js';
|
|
29
30
|
import { Page500 } from '../core/500.js';
|
|
30
31
|
import { Page404 } from '../core/404.js';
|
|
32
|
+
import { PanelForm } from '../core/PanelForm.js';
|
|
33
|
+
import { Chat } from '../core/Chat.js';
|
|
31
34
|
|
|
32
35
|
const MenuDefault = {
|
|
33
36
|
Data: {},
|
|
@@ -35,7 +38,7 @@ const MenuDefault = {
|
|
|
35
38
|
const id = getId(this.Data, 'menu-');
|
|
36
39
|
this.Data[id] = {};
|
|
37
40
|
const RouterInstance = RouterDefault();
|
|
38
|
-
|
|
41
|
+
|
|
39
42
|
const { barConfig } = await Themes[Css.currentTheme]();
|
|
40
43
|
const heightTopBar = 50;
|
|
41
44
|
const heightBottomBar = 50;
|
|
@@ -159,6 +162,34 @@ const MenuDefault = {
|
|
|
159
162
|
handleContainerClass: 'handle-btn-container',
|
|
160
163
|
tooltipHtml: await Badge.Render(buildBadgeToolTipMenuOption('500')),
|
|
161
164
|
})}
|
|
165
|
+
${await BtnIcon.Render({
|
|
166
|
+
class: 'in wfa main-btn-menu main-btn-blog',
|
|
167
|
+
label: renderMenuLabel({
|
|
168
|
+
icon: html`<i class="fa-solid fa-file-invoice"></i>`,
|
|
169
|
+
text: html`<span class="menu-label-text">${Translate.Render('blog')}</span>`,
|
|
170
|
+
}),
|
|
171
|
+
attrs: `data-id="blog"`,
|
|
172
|
+
tabHref: `${getProxyPath()}blog`,
|
|
173
|
+
handleContainerClass: 'handle-btn-container',
|
|
174
|
+
tooltipHtml: await Badge.Render(buildBadgeToolTipMenuOption('blog')),
|
|
175
|
+
})}
|
|
176
|
+
${await BtnIcon.Render({
|
|
177
|
+
class: 'in wfa main-btn-menu main-btn-chat',
|
|
178
|
+
label: html`${renderMenuLabel({
|
|
179
|
+
icon: html`<i class="far fa-comments"></i>`,
|
|
180
|
+
text: html`<span class="menu-label-text">${Translate.Render('chat')}</span>`,
|
|
181
|
+
})}
|
|
182
|
+
${await Badge.Render({
|
|
183
|
+
id: 'main-btn-chat',
|
|
184
|
+
type: 'circle-red',
|
|
185
|
+
style: badgeNotificationMenuStyle,
|
|
186
|
+
classList: 'hide',
|
|
187
|
+
})}`,
|
|
188
|
+
attrs: `data-id="chat"`,
|
|
189
|
+
tabHref: `${getProxyPath()}chat`,
|
|
190
|
+
handleContainerClass: 'handle-btn-container',
|
|
191
|
+
tooltipHtml: await Badge.Render(buildBadgeToolTipMenuOption('chat')),
|
|
192
|
+
})}
|
|
162
193
|
</div>
|
|
163
194
|
`,
|
|
164
195
|
barConfig: newInstance(barConfig),
|
|
@@ -180,47 +211,7 @@ const MenuDefault = {
|
|
|
180
211
|
RouterInstance,
|
|
181
212
|
heightTopBar,
|
|
182
213
|
heightBottomBar,
|
|
183
|
-
htmlMainBody:
|
|
184
|
-
setTimeout(() => {
|
|
185
|
-
EventsUI.onClick('.get-started-button', (e) => {
|
|
186
|
-
e.preventDefault();
|
|
187
|
-
location.href = `https://www.nexodev.org/docs/?cid=src`;
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
return html`
|
|
191
|
-
<div class="landing-container">
|
|
192
|
-
<div class="content-wrapper">
|
|
193
|
-
<h1 class="animated-text">
|
|
194
|
-
<span class="greeting">Hello, World!</span>
|
|
195
|
-
<span class="subtitle">Welcome to Our Platform</span>
|
|
196
|
-
</h1>
|
|
197
|
-
|
|
198
|
-
<div class="features">
|
|
199
|
-
<div class="feature-card">
|
|
200
|
-
<i class="icon">🚀</i>
|
|
201
|
-
<h3>Fast & Reliable</h3>
|
|
202
|
-
<p>Lightning-fast performance with 99.9% uptime</p>
|
|
203
|
-
</div>
|
|
204
|
-
<div class="feature-card">
|
|
205
|
-
<i class="icon">🎨</i>
|
|
206
|
-
<h3>Beautiful UI</h3>
|
|
207
|
-
<p>Modern and intuitive user interface</p>
|
|
208
|
-
</div>
|
|
209
|
-
<div class="feature-card">
|
|
210
|
-
<i class="icon">⚡</i>
|
|
211
|
-
<h3>Powerful Features</h3>
|
|
212
|
-
<p>Everything you need in one place</p>
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
|
|
216
|
-
<button class="cta-button get-started-button">
|
|
217
|
-
Get Started
|
|
218
|
-
<span class="button-icon">→</span>
|
|
219
|
-
</button>
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
`;
|
|
223
|
-
},
|
|
214
|
+
htmlMainBody: options.htmlMainBody,
|
|
224
215
|
});
|
|
225
216
|
|
|
226
217
|
ThemeEvents['main-theme-handler'] = () => {
|
|
@@ -671,6 +662,68 @@ const MenuDefault = {
|
|
|
671
662
|
observer: true,
|
|
672
663
|
});
|
|
673
664
|
});
|
|
665
|
+
|
|
666
|
+
EventsUI.onClick(`.main-btn-blog`, async () => {
|
|
667
|
+
const { barConfig } = await Themes[Css.currentTheme]();
|
|
668
|
+
const idModal = 'modal-blog';
|
|
669
|
+
const routeModal = 'blog';
|
|
670
|
+
const idEvent = `form-panel-${idModal}`;
|
|
671
|
+
await Modal.Render({
|
|
672
|
+
id: idModal,
|
|
673
|
+
route: routeModal,
|
|
674
|
+
barConfig,
|
|
675
|
+
title: renderViewTitle({
|
|
676
|
+
icon: html`<i class="fa-solid fa-file-invoice"></i>`,
|
|
677
|
+
text: Translate.Render('blog'),
|
|
678
|
+
}),
|
|
679
|
+
observer: true,
|
|
680
|
+
html: async () => {
|
|
681
|
+
setTimeout(async () => {
|
|
682
|
+
await PanelForm.instance({
|
|
683
|
+
idPanel: 'default-blog',
|
|
684
|
+
heightTopBar,
|
|
685
|
+
heightBottomBar,
|
|
686
|
+
defaultUrlImage: `${getProxyPath()}android-chrome-96x96.png`,
|
|
687
|
+
Elements: ElementsDefault,
|
|
688
|
+
parentIdModal: idModal,
|
|
689
|
+
scrollClassContainer: `html-${idModal}`,
|
|
690
|
+
route: routeModal,
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
},
|
|
694
|
+
handleType: 'bar',
|
|
695
|
+
maximize: true,
|
|
696
|
+
mode: 'view',
|
|
697
|
+
slideMenu: 'modal-menu',
|
|
698
|
+
RouterInstance,
|
|
699
|
+
heightTopBar,
|
|
700
|
+
heightBottomBar,
|
|
701
|
+
barMode,
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
EventsUI.onClick(`.main-btn-chat`, async () => {
|
|
706
|
+
const { barConfig } = await Themes[Css.currentTheme]();
|
|
707
|
+
await Modal.Render({
|
|
708
|
+
id: 'modal-chat',
|
|
709
|
+
route: 'chat',
|
|
710
|
+
barConfig,
|
|
711
|
+
title: renderViewTitle({
|
|
712
|
+
icon: html` <i class="far fa-comments"></i>`,
|
|
713
|
+
text: Translate.Render('chat'),
|
|
714
|
+
}),
|
|
715
|
+
html: async () => await Chat.Render({ idModal: 'modal-chat' }),
|
|
716
|
+
handleType: 'bar',
|
|
717
|
+
maximize: true,
|
|
718
|
+
observer: true,
|
|
719
|
+
mode: 'view',
|
|
720
|
+
slideMenu: 'modal-menu',
|
|
721
|
+
RouterInstance,
|
|
722
|
+
heightTopBar,
|
|
723
|
+
heightBottomBar,
|
|
724
|
+
barMode,
|
|
725
|
+
});
|
|
726
|
+
});
|
|
674
727
|
},
|
|
675
728
|
};
|
|
676
729
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { loggerFactory } from '../core/Logger.js';
|
|
2
2
|
import { Modal } from '../core/Modal.js';
|
|
3
|
-
import {
|
|
3
|
+
import { s } from '../core/VanillaJs.js';
|
|
4
|
+
import { getProxyPath } from '../core/Router.js';
|
|
4
5
|
|
|
5
6
|
const logger = loggerFactory(import.meta);
|
|
6
7
|
|
|
@@ -26,6 +27,8 @@ const RoutesDefault = () => {
|
|
|
26
27
|
render: () => s(`.main-btn-account`).click(),
|
|
27
28
|
},
|
|
28
29
|
'/docs': { title: 'docs', render: () => s(`.main-btn-docs`).click() },
|
|
30
|
+
'/chat': { title: 'docs', render: () => s(`.main-btn-chat`).click() },
|
|
31
|
+
'/blog': { title: 'docs', render: () => s(`.main-btn-blog`).click() },
|
|
29
32
|
'/recover': { title: 'recover', render: () => s(`.main-btn-recover`).click() },
|
|
30
33
|
'/default-management': {
|
|
31
34
|
title: 'default-management',
|
|
@@ -39,7 +42,7 @@ const RoutesDefault = () => {
|
|
|
39
42
|
window.Routes = RoutesDefault;
|
|
40
43
|
|
|
41
44
|
const RouterDefault = () => {
|
|
42
|
-
return { Routes: RoutesDefault
|
|
45
|
+
return { Routes: RoutesDefault };
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
export { RoutesDefault, RouterDefault, BannerAppTemplate };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Auth } from '../../components/core/Auth.js';
|
|
2
2
|
import { loggerFactory } from '../../components/core/Logger.js';
|
|
3
|
-
import { getProxyPath } from '../../components/core/
|
|
3
|
+
import { getProxyPath } from '../../components/core/Router.js';
|
|
4
4
|
|
|
5
5
|
const logger = loggerFactory(import.meta);
|
|
6
6
|
|
|
@@ -33,7 +33,9 @@ const getWsBaseUrl = (options = { id: '', endpoint: '', wsBasePath: '' }) =>
|
|
|
33
33
|
}${options?.endpoint ? options.endpoint : ''}${options?.id ? `/${options.id}` : ''}`;
|
|
34
34
|
|
|
35
35
|
const headersFactory = (headerId = '') => {
|
|
36
|
-
const headers = {
|
|
36
|
+
const headers = {
|
|
37
|
+
Authorization: Auth.getJWT(),
|
|
38
|
+
};
|
|
37
39
|
switch (headerId) {
|
|
38
40
|
case 'file':
|
|
39
41
|
return headers;
|
|
@@ -67,29 +69,12 @@ const CoreService = {
|
|
|
67
69
|
return reject(error);
|
|
68
70
|
}),
|
|
69
71
|
),
|
|
70
|
-
getRandomImage: (options = { category: ['city'], mimetype: 'image/jpg' }) => {
|
|
71
|
-
const src = `https://api.api-ninjas.com/v1/randomimage?category=${options.category[0]}`;
|
|
72
|
-
return new Promise((resolve) => {
|
|
73
|
-
fetch(src, {
|
|
74
|
-
headers: { 'X-Api-Key': 'FyITmcxRXkCaUehbX6K0/g==uxZcFKL0dZUUg48G', Accept: options.mimetype },
|
|
75
|
-
})
|
|
76
|
-
.then((res) => res.blob())
|
|
77
|
-
.then(async (blob) => {
|
|
78
|
-
return resolve({
|
|
79
|
-
file: {
|
|
80
|
-
mimetype: 'image/jpg',
|
|
81
|
-
name: 'image.jpg',
|
|
82
|
-
},
|
|
83
|
-
url: URL.createObjectURL(blob),
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
72
|
post: (options = { id: '', body: {} }) =>
|
|
89
73
|
new Promise((resolve, reject) =>
|
|
90
74
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
91
75
|
method: 'POST',
|
|
92
76
|
headers: headersFactory(),
|
|
77
|
+
credentials: 'include',
|
|
93
78
|
body: payloadFactory(options.body),
|
|
94
79
|
})
|
|
95
80
|
.then(async (res) => {
|
|
@@ -109,6 +94,7 @@ const CoreService = {
|
|
|
109
94
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
110
95
|
method: 'PUT',
|
|
111
96
|
headers: headersFactory(),
|
|
97
|
+
credentials: 'include',
|
|
112
98
|
body: payloadFactory(options.body),
|
|
113
99
|
})
|
|
114
100
|
.then(async (res) => {
|
|
@@ -128,6 +114,7 @@ const CoreService = {
|
|
|
128
114
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
129
115
|
method: 'GET',
|
|
130
116
|
headers: headersFactory(),
|
|
117
|
+
credentials: 'include',
|
|
131
118
|
})
|
|
132
119
|
.then(async (res) => {
|
|
133
120
|
return await res.json();
|
|
@@ -146,6 +133,7 @@ const CoreService = {
|
|
|
146
133
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
147
134
|
method: 'DELETE',
|
|
148
135
|
headers: headersFactory(),
|
|
136
|
+
credentials: 'include',
|
|
149
137
|
body: payloadFactory(options.body),
|
|
150
138
|
})
|
|
151
139
|
.then(async (res) => {
|
|
@@ -7,6 +7,7 @@ import { loggerFactory } from '../../components/core/Logger.js';
|
|
|
7
7
|
import { Modal } from '../../components/core/Modal.js';
|
|
8
8
|
import { NotificationManager } from '../../components/core/NotificationManager.js';
|
|
9
9
|
import { Translate } from '../../components/core/Translate.js';
|
|
10
|
+
import { getQueryParams, RouterEvents, setQueryParams } from '../../components/core/Router.js';
|
|
10
11
|
import { s } from '../../components/core/VanillaJs.js';
|
|
11
12
|
import { DefaultService } from './default.service.js';
|
|
12
13
|
|
|
@@ -47,19 +48,48 @@ const columnDefFormatter = (obj, columnDefs, customFormat) => {
|
|
|
47
48
|
|
|
48
49
|
const DefaultManagement = {
|
|
49
50
|
Tokens: {},
|
|
51
|
+
loadTable: async function (id, options = { reload: true }) {
|
|
52
|
+
const { serviceId, columnDefs, customFormat } = this.Tokens[id];
|
|
53
|
+
const result = await this.Tokens[id].ServiceProvider.get({
|
|
54
|
+
page: this.Tokens[id].page,
|
|
55
|
+
limit: this.Tokens[id].limit,
|
|
56
|
+
id: this.Tokens[id].serviceOptions?.get?.id ?? undefined,
|
|
57
|
+
});
|
|
58
|
+
if (result.status === 'success') {
|
|
59
|
+
const { data, total, page, totalPages } = result.data;
|
|
60
|
+
this.Tokens[id].total = total;
|
|
61
|
+
this.Tokens[id].page = page;
|
|
62
|
+
this.Tokens[id].totalPages = totalPages;
|
|
63
|
+
const rowDataScope = data.map((row) => columnDefFormatter(row, columnDefs, customFormat));
|
|
64
|
+
if (options.reload) AgGrid.grids[this.Tokens[id].gridId].setGridOption('rowData', rowDataScope);
|
|
65
|
+
const paginationComp = s(`#ag-pagination-${this.Tokens[id].gridId}`);
|
|
66
|
+
paginationComp.setAttribute('current-page', this.Tokens[id].page);
|
|
67
|
+
paginationComp.setAttribute('total-pages', this.Tokens[id].totalPages);
|
|
68
|
+
paginationComp.setAttribute('total-items', this.Tokens[id].total);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
50
71
|
RenderTable: async function (options = DefaultOptions) {
|
|
51
72
|
if (!options) options = DefaultOptions;
|
|
52
73
|
const { serviceId, columnDefs, entity, defaultColKeyFocus, ServiceProvider, permissions } = options;
|
|
53
74
|
logger.info('DefaultManagement RenderTable', options);
|
|
54
75
|
const id = options?.idModal ? options.idModal : getId(this.Tokens, `${serviceId}-`);
|
|
55
76
|
const gridId = `${serviceId}-grid-${id}`;
|
|
56
|
-
|
|
77
|
+
const queryParams = getQueryParams();
|
|
78
|
+
const page = parseInt(queryParams.page) || 1;
|
|
79
|
+
const limit = parseInt(queryParams.limit) || 10;
|
|
80
|
+
this.Tokens[id] = {
|
|
81
|
+
...options,
|
|
82
|
+
gridId,
|
|
83
|
+
page,
|
|
84
|
+
limit,
|
|
85
|
+
total: 0,
|
|
86
|
+
totalPages: 1,
|
|
87
|
+
};
|
|
57
88
|
|
|
89
|
+
setQueryParams({ page, limit });
|
|
58
90
|
setTimeout(async () => {
|
|
59
91
|
// https://www.ag-grid.com/javascript-data-grid/data-update-transactions/
|
|
60
92
|
|
|
61
|
-
let rowDataScope = [];
|
|
62
|
-
|
|
63
93
|
class RemoveActionGridRenderer {
|
|
64
94
|
eGui;
|
|
65
95
|
tokens;
|
|
@@ -110,6 +140,16 @@ const DefaultManagement = {
|
|
|
110
140
|
});
|
|
111
141
|
if (result.status === 'success') {
|
|
112
142
|
AgGrid.grids[gridId].applyTransaction({ remove: [params.data] });
|
|
143
|
+
const token = DefaultManagement.Tokens[id];
|
|
144
|
+
// if we are on the last page and we delete the last item, go to the previous page
|
|
145
|
+
const newTotal = token.total - 1;
|
|
146
|
+
const newTotalPages = Math.ceil(newTotal / token.limit);
|
|
147
|
+
if (token.page > newTotalPages && newTotalPages > 0) {
|
|
148
|
+
token.page = newTotalPages;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// reload the current page
|
|
152
|
+
await DefaultManagement.loadTable(id, { reload: false });
|
|
113
153
|
}
|
|
114
154
|
},
|
|
115
155
|
{ context: 'modal' },
|
|
@@ -142,13 +182,14 @@ const DefaultManagement = {
|
|
|
142
182
|
: [],
|
|
143
183
|
),
|
|
144
184
|
);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
185
|
+
DefaultManagement.loadTable(id);
|
|
186
|
+
// {
|
|
187
|
+
// const result = await ServiceProvider.get();
|
|
188
|
+
// if (result.status === 'success') {
|
|
189
|
+
// rowDataScope = result.data.map((row) => columnDefFormatter(row, columnDefs, options.customFormat));
|
|
190
|
+
// AgGrid.grids[gridId].setGridOption('rowData', rowDataScope);
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
152
193
|
s(`.management-table-btn-save-${id}`).onclick = () => {
|
|
153
194
|
AgGrid.grids[gridId].stopEditing();
|
|
154
195
|
};
|
|
@@ -168,9 +209,13 @@ const DefaultManagement = {
|
|
|
168
209
|
// });
|
|
169
210
|
if (result.status === 'success') {
|
|
170
211
|
AgGrid.grids[gridId].applyTransaction({
|
|
171
|
-
add: [columnDefFormatter(
|
|
212
|
+
add: [columnDefFormatter(rowObj, columnDefs, options.customFormat)],
|
|
172
213
|
addIndex: 0,
|
|
173
214
|
});
|
|
215
|
+
// AgGrid.grids[gridId].applyTransaction({
|
|
216
|
+
// add: [columnDefFormatter(result.data, columnDefs, options.customFormat)],
|
|
217
|
+
// addIndex: 0,
|
|
218
|
+
// });
|
|
174
219
|
// AgGrid.grids[gridId].applyColumnState({
|
|
175
220
|
// state: [
|
|
176
221
|
// // { colId: 'country', sort: 'asc', sortIndex: 1 },
|
|
@@ -244,9 +289,34 @@ const DefaultManagement = {
|
|
|
244
289
|
status: result.status,
|
|
245
290
|
});
|
|
246
291
|
if (result.status === 'success') {
|
|
247
|
-
|
|
292
|
+
DefaultManagement.loadTable(id);
|
|
248
293
|
}
|
|
249
294
|
});
|
|
295
|
+
s(`#ag-pagination-${gridId}`).addEventListener('page-change', async (event) => {
|
|
296
|
+
const token = DefaultManagement.Tokens[id];
|
|
297
|
+
token.page = event.detail.page;
|
|
298
|
+
await DefaultManagement.loadTable(id);
|
|
299
|
+
});
|
|
300
|
+
s(`#ag-pagination-${gridId}`).addEventListener('limit-change', async (event) => {
|
|
301
|
+
const token = DefaultManagement.Tokens[id];
|
|
302
|
+
token.limit = event.detail.limit;
|
|
303
|
+
token.page = 1; // Reset to first page
|
|
304
|
+
await DefaultManagement.loadTable(id);
|
|
305
|
+
});
|
|
306
|
+
RouterEvents[id] = async (...args) => {
|
|
307
|
+
const queryParams = getQueryParams();
|
|
308
|
+
const page = parseInt(queryParams.page) || 1;
|
|
309
|
+
const limit = parseInt(queryParams.limit) || 10;
|
|
310
|
+
const token = DefaultManagement.Tokens[id];
|
|
311
|
+
|
|
312
|
+
// Check if the pagination state in the URL is different from the current state
|
|
313
|
+
if (token.page !== page || token.limit !== limit) {
|
|
314
|
+
token.page = page;
|
|
315
|
+
token.limit = limit;
|
|
316
|
+
// Reload the table with the new pagination state from the URL
|
|
317
|
+
await DefaultManagement.loadTable(id);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
250
320
|
}, 1);
|
|
251
321
|
return html`<div class="fl">
|
|
252
322
|
${await BtnIcon.Render({
|
|
@@ -274,6 +344,7 @@ const DefaultManagement = {
|
|
|
274
344
|
<div class="in section-mp">
|
|
275
345
|
${await AgGrid.Render({
|
|
276
346
|
id: gridId,
|
|
347
|
+
usePagination: true,
|
|
277
348
|
darkTheme,
|
|
278
349
|
gridOptions: {
|
|
279
350
|
defaultColDef: {
|
|
@@ -327,7 +398,32 @@ const DefaultManagement = {
|
|
|
327
398
|
status: result.status,
|
|
328
399
|
});
|
|
329
400
|
if (result.status === 'success') {
|
|
330
|
-
|
|
401
|
+
this.Tokens[id].page = 1;
|
|
402
|
+
await DefaultManagement.loadTable(id);
|
|
403
|
+
// const newItemId = result.data?.[entity]?._id || result.data?._id;
|
|
404
|
+
// The `event.node.id` is the temporary ID assigned by AG Grid.
|
|
405
|
+
// const rowNode = AgGrid.grids[gridId].getRowNode(event.node.id);
|
|
406
|
+
setQueryParams({ page: 1, limit: this.Tokens[id].limit });
|
|
407
|
+
|
|
408
|
+
let rowNode;
|
|
409
|
+
AgGrid.grids[gridId].forEachLeafNode((_rowNode) => {
|
|
410
|
+
if (_rowNode.data._id === result.data._id) {
|
|
411
|
+
rowNode = _rowNode;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
if (rowNode) {
|
|
415
|
+
const newRow = columnDefFormatter(result.data, columnDefs, options.customFormat);
|
|
416
|
+
// Add a temporary flag to the new row data.
|
|
417
|
+
newRow._new = true;
|
|
418
|
+
// Update the row data with the data from the server, which includes the new permanent `_id`.
|
|
419
|
+
rowNode.setData(newRow);
|
|
420
|
+
// The `rowClassRules` will automatically apply the 'row-new-highlight' class.
|
|
421
|
+
// Now, remove the flag after a delay to remove the highlight.
|
|
422
|
+
// setTimeout(() => {
|
|
423
|
+
// delete newRow._new;
|
|
424
|
+
// rowNode.setData(newRow);
|
|
425
|
+
// }, 2000);
|
|
426
|
+
}
|
|
331
427
|
}
|
|
332
428
|
} else {
|
|
333
429
|
const body = event.data ? event.data : {};
|
|
@@ -336,11 +432,12 @@ const DefaultManagement = {
|
|
|
336
432
|
html: result.status === 'error' ? result.message : `${Translate.Render('success-update-item')}`,
|
|
337
433
|
status: result.status,
|
|
338
434
|
});
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
435
|
+
if (result.status === 'success') {
|
|
436
|
+
AgGrid.grids[gridId].applyTransaction({
|
|
437
|
+
update: [event.data],
|
|
438
|
+
});
|
|
439
|
+
DefaultManagement.loadTable(id, { reload: false });
|
|
440
|
+
}
|
|
344
441
|
}
|
|
345
442
|
},
|
|
346
443
|
},
|
|
@@ -14,6 +14,7 @@ const DefaultService = {
|
|
|
14
14
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
15
|
method: 'POST',
|
|
16
16
|
headers: headersFactory(),
|
|
17
|
+
credentials: 'include',
|
|
17
18
|
body: payloadFactory(options.body),
|
|
18
19
|
})
|
|
19
20
|
.then(async (res) => {
|
|
@@ -33,6 +34,7 @@ const DefaultService = {
|
|
|
33
34
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
35
|
method: 'PUT',
|
|
35
36
|
headers: headersFactory(),
|
|
37
|
+
credentials: 'include',
|
|
36
38
|
body: payloadFactory(options.body),
|
|
37
39
|
})
|
|
38
40
|
.then(async (res) => {
|
|
@@ -47,11 +49,16 @@ const DefaultService = {
|
|
|
47
49
|
return reject(error);
|
|
48
50
|
}),
|
|
49
51
|
),
|
|
50
|
-
get: (options = { id: '', body: {} }) =>
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
get: (options = { id: '', body: {}, page: 1, limit: 10 }) => {
|
|
53
|
+
const { id, page, limit } = options;
|
|
54
|
+
const url = new URL(getApiBaseUrl({ id, endpoint }));
|
|
55
|
+
url.searchParams.append('page', page);
|
|
56
|
+
url.searchParams.append('limit', limit);
|
|
57
|
+
return new Promise((resolve, reject) =>
|
|
58
|
+
fetch(url.toString(), {
|
|
53
59
|
method: 'GET',
|
|
54
60
|
headers: headersFactory(),
|
|
61
|
+
credentials: 'include',
|
|
55
62
|
})
|
|
56
63
|
.then(async (res) => {
|
|
57
64
|
return await res.json();
|
|
@@ -64,12 +71,14 @@ const DefaultService = {
|
|
|
64
71
|
logger.error(error);
|
|
65
72
|
return reject(error);
|
|
66
73
|
}),
|
|
67
|
-
)
|
|
74
|
+
);
|
|
75
|
+
},
|
|
68
76
|
delete: (options = { id: '', body: {} }) =>
|
|
69
77
|
new Promise((resolve, reject) =>
|
|
70
78
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
71
79
|
method: 'DELETE',
|
|
72
80
|
headers: headersFactory(),
|
|
81
|
+
credentials: 'include',
|
|
73
82
|
body: payloadFactory(options.body),
|
|
74
83
|
})
|
|
75
84
|
.then(async (res) => {
|
|
@@ -0,0 +1,97 @@
|
|
|
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 = 'document';
|
|
10
|
+
|
|
11
|
+
const DocumentService = {
|
|
12
|
+
post: (options = { id: '', body: {} }) =>
|
|
13
|
+
new Promise((resolve, reject) =>
|
|
14
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: headersFactory(),
|
|
17
|
+
credentials: 'include',
|
|
18
|
+
body: payloadFactory(options.body),
|
|
19
|
+
})
|
|
20
|
+
.then(async (res) => {
|
|
21
|
+
return await res.json();
|
|
22
|
+
})
|
|
23
|
+
.then((res) => {
|
|
24
|
+
logger.info(res);
|
|
25
|
+
return resolve(res);
|
|
26
|
+
})
|
|
27
|
+
.catch((error) => {
|
|
28
|
+
logger.error(error);
|
|
29
|
+
return reject(error);
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
get: (options = { id: '' }) =>
|
|
33
|
+
new Promise((resolve, reject) => {
|
|
34
|
+
const url = new URL(getApiBaseUrl({ id: options.id, endpoint }));
|
|
35
|
+
if (options.params) {
|
|
36
|
+
Object.keys(options.params).forEach((key) => url.searchParams.append(key, options.params[key]));
|
|
37
|
+
}
|
|
38
|
+
fetch(url, {
|
|
39
|
+
method: 'GET',
|
|
40
|
+
headers: headersFactory(),
|
|
41
|
+
credentials: 'include',
|
|
42
|
+
})
|
|
43
|
+
.then(async (res) => {
|
|
44
|
+
return await res.json();
|
|
45
|
+
})
|
|
46
|
+
.then((res) => {
|
|
47
|
+
logger.info(res);
|
|
48
|
+
return resolve(res);
|
|
49
|
+
})
|
|
50
|
+
.catch((error) => {
|
|
51
|
+
logger.error(error);
|
|
52
|
+
return reject(error);
|
|
53
|
+
});
|
|
54
|
+
}),
|
|
55
|
+
delete: (options = { id: '', body: {} }) =>
|
|
56
|
+
new Promise((resolve, reject) =>
|
|
57
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
58
|
+
method: 'DELETE',
|
|
59
|
+
headers: headersFactory(),
|
|
60
|
+
credentials: 'include',
|
|
61
|
+
body: payloadFactory(options.body),
|
|
62
|
+
})
|
|
63
|
+
.then(async (res) => {
|
|
64
|
+
return await res.json();
|
|
65
|
+
})
|
|
66
|
+
.then((res) => {
|
|
67
|
+
logger.info(res);
|
|
68
|
+
return resolve(res);
|
|
69
|
+
})
|
|
70
|
+
.catch((error) => {
|
|
71
|
+
logger.error(error);
|
|
72
|
+
return reject(error);
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
75
|
+
put: (options = { id: '', body: {} }) =>
|
|
76
|
+
new Promise((resolve, reject) =>
|
|
77
|
+
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
78
|
+
method: 'PUT',
|
|
79
|
+
headers: headersFactory(),
|
|
80
|
+
credentials: 'include',
|
|
81
|
+
body: payloadFactory(options.body),
|
|
82
|
+
})
|
|
83
|
+
.then(async (res) => {
|
|
84
|
+
return await res.json();
|
|
85
|
+
})
|
|
86
|
+
.then((res) => {
|
|
87
|
+
logger.info(res);
|
|
88
|
+
return resolve(res);
|
|
89
|
+
})
|
|
90
|
+
.catch((error) => {
|
|
91
|
+
logger.error(error);
|
|
92
|
+
return reject(error);
|
|
93
|
+
}),
|
|
94
|
+
),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { DocumentService };
|
|
@@ -33,6 +33,7 @@ const FileService = {
|
|
|
33
33
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
34
|
method: 'GET',
|
|
35
35
|
headers: headersFactory(),
|
|
36
|
+
credentials: 'include',
|
|
36
37
|
})
|
|
37
38
|
.then(async (res) => {
|
|
38
39
|
return await res.json();
|
|
@@ -51,6 +52,7 @@ const FileService = {
|
|
|
51
52
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
52
53
|
method: 'DELETE',
|
|
53
54
|
headers: headersFactory(),
|
|
55
|
+
credentials: 'include',
|
|
54
56
|
body: payloadFactory(options.body),
|
|
55
57
|
})
|
|
56
58
|
.then(async (res) => {
|
|
@@ -14,6 +14,7 @@ const TestService = {
|
|
|
14
14
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
15
15
|
method: 'POST',
|
|
16
16
|
headers: headersFactory(),
|
|
17
|
+
credentials: 'include',
|
|
17
18
|
body: payloadFactory(options.body),
|
|
18
19
|
})
|
|
19
20
|
.then(async (res) => {
|
|
@@ -33,6 +34,7 @@ const TestService = {
|
|
|
33
34
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
34
35
|
method: 'GET',
|
|
35
36
|
headers: headersFactory(),
|
|
37
|
+
credentials: 'include',
|
|
36
38
|
})
|
|
37
39
|
.then(async (res) => {
|
|
38
40
|
return await res.json();
|
|
@@ -51,6 +53,7 @@ const TestService = {
|
|
|
51
53
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
52
54
|
method: 'DELETE',
|
|
53
55
|
headers: headersFactory(),
|
|
56
|
+
credentials: 'include',
|
|
54
57
|
body: payloadFactory(options.body),
|
|
55
58
|
})
|
|
56
59
|
.then(async (res) => {
|