@uxland/primary-shell 7.2.2 → 7.4.0
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/dist/index.js +135 -72
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +7 -7
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/UI/internal-views/upper-nav-views.d.ts +3 -2
- package/dist/primary/shell/src/api/api.d.ts +2 -0
- package/dist/primary/shell/src/api/user-manager/user-manager.d.ts +12 -0
- package/dist/primary/shell/src/handle-plugins.d.ts +1 -1
- package/package.json +1 -1
- package/src/UI/internal-views/handle-views.ts +7 -7
- package/src/UI/internal-views/upper-nav-views.ts +28 -5
- package/src/api/api.ts +4 -0
- package/src/api/user-manager/user-manager.ts +45 -0
- package/src/handle-plugins.ts +6 -5
- package/dist/primary/shell/src/UI/internal-views/lower-nav-menu-views.d.ts +0 -1
- package/src/UI/internal-views/lower-nav-menu-views.ts +0 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const registerDoctorNavMenuViews: () => void;
|
|
2
|
+
export declare const registerAdministrativeNavMenuViews: () => void;
|
|
3
|
+
export declare const registerCommunicationNavMenu: () => void;
|
|
3
4
|
export declare const registerCommunicationMenuActions: () => void;
|
|
@@ -9,6 +9,7 @@ import { PdfViewerManager } from './pdf-viewer-manager/pdf-viewer-manager';
|
|
|
9
9
|
import { PluginBusyManager } from './plugin-busy-manager/plugin-busy-manager';
|
|
10
10
|
import { PrimariaRegionManager } from './region-manager/region-manager';
|
|
11
11
|
import { TokenManager } from './token-manager/token-manager';
|
|
12
|
+
import { UserManager } from './user-manager/user-manager';
|
|
12
13
|
export interface PrimariaApi extends HarmonixApi {
|
|
13
14
|
httpClient: HttpClient;
|
|
14
15
|
interactionService: PrimariaInteractionService;
|
|
@@ -17,6 +18,7 @@ export interface PrimariaApi extends HarmonixApi {
|
|
|
17
18
|
regionManager: PrimariaRegionManager;
|
|
18
19
|
globalStateManager: PrimariaGlobalStateManager;
|
|
19
20
|
tokenManager: TokenManager;
|
|
21
|
+
userManager: UserManager;
|
|
20
22
|
ecapEventManager: EcapEventManager;
|
|
21
23
|
pluginBusyManager: PluginBusyManager;
|
|
22
24
|
pdfViewerManager: PdfViewerManager;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TokenManager } from '../token-manager/token-manager';
|
|
2
|
+
export interface UserManager {
|
|
3
|
+
getRole: () => string | undefined;
|
|
4
|
+
isUserRoleAdministrative: () => boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class UserManagerImpl implements UserManager {
|
|
7
|
+
private tokenManager;
|
|
8
|
+
constructor(tokenManager: TokenManager);
|
|
9
|
+
getRole: () => string | undefined;
|
|
10
|
+
isUserRoleAdministrative: () => boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const createUserManager: (tokenManager: TokenManager) => UserManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginDefinition, Plugin as PluginType } from '@uxland/harmonix';
|
|
2
2
|
import { PrimariaApi } from './api/api';
|
|
3
3
|
export type { PluginDefinition, PluginInfo } from '@uxland/harmonix';
|
|
4
|
-
export declare const bootstrapPlugins: (plugins: PluginDefinition[]
|
|
4
|
+
export declare const bootstrapPlugins: (plugins: PluginDefinition[]) => Promise<void>;
|
|
5
5
|
export declare const disposePlugins: () => Promise<void[]>;
|
|
6
6
|
export type Plugin = PluginType<PrimariaApi>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { shellApi } from "../../api/api";
|
|
1
2
|
import { registerPDFVisorMainView } from "../../api/pdf-viewer-manager/handle-views";
|
|
2
|
-
import {
|
|
3
|
-
import { registerCommunicationMenuActions, registerCommunicationNavMenuItem, registerUpperNavMenuViews } from "./upper-nav-views";
|
|
3
|
+
import { registerAdministrativeNavMenuViews, registerDoctorNavMenuViews } from "./upper-nav-views";
|
|
4
4
|
|
|
5
5
|
const registerMainViews = () => {
|
|
6
6
|
registerPDFVisorMainView();
|
|
@@ -8,9 +8,9 @@ const registerMainViews = () => {
|
|
|
8
8
|
|
|
9
9
|
export const useInternalViews = () => {
|
|
10
10
|
registerMainViews();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const isUserRoleAdministrative = shellApi.userManager.isUserRoleAdministrative();
|
|
12
|
+
if((isUserRoleAdministrative))
|
|
13
|
+
registerAdministrativeNavMenuViews();
|
|
14
|
+
else
|
|
15
|
+
registerDoctorNavMenuViews();
|
|
16
16
|
};
|
|
@@ -30,7 +30,16 @@ type MenuItemConfig =
|
|
|
30
30
|
}[];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const commonNavMenuItems = [{
|
|
34
|
+
id: "landing",
|
|
35
|
+
icon: "home",
|
|
36
|
+
label: "Pàgina inici",
|
|
37
|
+
type: "item",
|
|
38
|
+
sortHint: "0010",
|
|
39
|
+
callbackFn: () => shellApi.broker.send(new ExitShell("OBRIR_PI")),
|
|
40
|
+
}];
|
|
41
|
+
|
|
42
|
+
const doctorNavMenuItems: MenuItemConfig[] = [
|
|
34
43
|
{
|
|
35
44
|
id: "landing",
|
|
36
45
|
icon: "home",
|
|
@@ -213,8 +222,20 @@ const upperNavMenuItems: MenuItemConfig[] = [
|
|
|
213
222
|
},
|
|
214
223
|
];
|
|
215
224
|
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
const administrativeNavMenuItems = [] as any;
|
|
226
|
+
|
|
227
|
+
export const registerDoctorNavMenuViews = () => {
|
|
228
|
+
registerCommunicationNavMenu();
|
|
229
|
+
registerNavMenuViews(doctorNavMenuItems);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const registerAdministrativeNavMenuViews = () => {
|
|
233
|
+
registerNavMenuViews(administrativeNavMenuItems);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const registerNavMenuViews = (views: MenuItemConfig[]) => {
|
|
237
|
+
const finalViews = [...commonNavMenuItems, ...views];
|
|
238
|
+
for (const item of finalViews) {
|
|
218
239
|
shellApi.regionManager.registerView(shellApi.regionManager.regions.shell.navigationMenu, {
|
|
219
240
|
id: item.id,
|
|
220
241
|
sortHint: item.sortHint,
|
|
@@ -236,9 +257,9 @@ export const registerUpperNavMenuViews = () => {
|
|
|
236
257
|
},
|
|
237
258
|
});
|
|
238
259
|
}
|
|
239
|
-
}
|
|
260
|
+
}
|
|
240
261
|
|
|
241
|
-
export const
|
|
262
|
+
export const registerCommunicationNavMenu = () => {
|
|
242
263
|
shellApi.regionManager.registerView(shellApi.regionManager.regions.shell.navigationMenu, {
|
|
243
264
|
id: "communication",
|
|
244
265
|
sortHint: "0120",
|
|
@@ -248,6 +269,8 @@ export const registerCommunicationNavMenuItem = () => {
|
|
|
248
269
|
return Promise.resolve(menuItem);
|
|
249
270
|
},
|
|
250
271
|
});
|
|
272
|
+
|
|
273
|
+
registerCommunicationMenuActions();
|
|
251
274
|
};
|
|
252
275
|
|
|
253
276
|
export const registerCommunicationMenuActions = () => {
|
package/src/api/api.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from "./plugin-busy-manager/plugin-busy-manager";
|
|
25
25
|
import { PrimariaRegionManager, createRegionManagerProxy } from "./region-manager/region-manager";
|
|
26
26
|
import { TokenManager, createTokenManager } from "./token-manager/token-manager";
|
|
27
|
+
import { UserManager, createUserManager } from "./user-manager/user-manager";
|
|
27
28
|
|
|
28
29
|
const broker = createBroker();
|
|
29
30
|
|
|
@@ -35,6 +36,7 @@ export interface PrimariaApi extends HarmonixApi {
|
|
|
35
36
|
regionManager: PrimariaRegionManager;
|
|
36
37
|
globalStateManager: PrimariaGlobalStateManager;
|
|
37
38
|
tokenManager: TokenManager;
|
|
39
|
+
userManager: UserManager;
|
|
38
40
|
ecapEventManager: EcapEventManager;
|
|
39
41
|
pluginBusyManager: PluginBusyManager;
|
|
40
42
|
pdfViewerManager: PdfViewerManager;
|
|
@@ -43,6 +45,7 @@ export interface PrimariaApi extends HarmonixApi {
|
|
|
43
45
|
const regionManager: RegionManager = createRegionManager("primaria");
|
|
44
46
|
export const PrimariaRegionHost: any = createRegionHost(regionManager as any);
|
|
45
47
|
const tokenManager = createTokenManager();
|
|
48
|
+
const userManager = createUserManager(tokenManager);
|
|
46
49
|
const globalStateManager: PrimariaGlobalStateManager = createGlobalStateManager(broker);
|
|
47
50
|
const pluginBusyManager = new PluginBusyManagerImpl(broker);
|
|
48
51
|
const interactionService = new ParimariaInteractionServiceImpl();
|
|
@@ -69,6 +72,7 @@ export const primariaApiFactory: ApiFactory<PrimariaApi> = (
|
|
|
69
72
|
createLocaleManager: createLocaleManager(pluginInfo.pluginId) as any,
|
|
70
73
|
globalStateManager,
|
|
71
74
|
tokenManager,
|
|
75
|
+
userManager,
|
|
72
76
|
ecapEventManager,
|
|
73
77
|
pluginBusyManager,
|
|
74
78
|
interactionService,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jwtDecode } from "jwt-decode";
|
|
2
|
+
import { TokenManager } from "../token-manager/token-manager";
|
|
3
|
+
|
|
4
|
+
interface JWTPayload {
|
|
5
|
+
access_info?: {
|
|
6
|
+
role_type?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface UserManager {
|
|
11
|
+
getRole: () => string | undefined;
|
|
12
|
+
isUserRoleAdministrative: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class UserManagerImpl implements UserManager {
|
|
16
|
+
constructor(private tokenManager: TokenManager) {}
|
|
17
|
+
|
|
18
|
+
getRole = (): string | undefined => {
|
|
19
|
+
const token = this.tokenManager.getToken();
|
|
20
|
+
if (!token) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const payload = jwtDecode<JWTPayload>(token);
|
|
26
|
+
const role = payload.access_info?.role_type;
|
|
27
|
+
return role;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error("Error decoding JWT token:", error);
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
isUserRoleAdministrative = (): boolean => {
|
|
35
|
+
const userRole = this.getRole();
|
|
36
|
+
return userRole === "ADM";
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let userManager: UserManager;
|
|
41
|
+
export const createUserManager = (tokenManager: TokenManager): UserManager => {
|
|
42
|
+
if (userManager) return userManager;
|
|
43
|
+
userManager = new UserManagerImpl(tokenManager);
|
|
44
|
+
return userManager;
|
|
45
|
+
};
|
package/src/handle-plugins.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
initialize as adminClinicalMonitoringInitialize,
|
|
14
14
|
dispose as adminClinicalMonitoringDispose,
|
|
15
15
|
} from "../../../plugins/admin-clinical-monitoring/src/plugin";
|
|
16
|
-
import { PrimariaApi, primariaApiFactory } from "./api/api";
|
|
16
|
+
import { PrimariaApi, primariaApiFactory, shellApi } from "./api/api";
|
|
17
17
|
|
|
18
18
|
let bootstrappedPlugins = [] as BootstrappedPlugin[];
|
|
19
19
|
|
|
@@ -50,15 +50,16 @@ const administrativeInternalPlugins: PluginDefinition[] = [
|
|
|
50
50
|
},
|
|
51
51
|
];
|
|
52
52
|
|
|
53
|
-
const getPluginsByUserRole = (
|
|
54
|
-
if (
|
|
53
|
+
const getPluginsByUserRole = (isUserRoleAdministrative: boolean) => {
|
|
54
|
+
if (isUserRoleAdministrative) {
|
|
55
55
|
return commonPlugins.concat(administrativeInternalPlugins);
|
|
56
56
|
}
|
|
57
57
|
return commonPlugins.concat(doctorInternalPlugins);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
export const bootstrapPlugins = async (plugins: PluginDefinition[]
|
|
61
|
-
const
|
|
60
|
+
export const bootstrapPlugins = async (plugins: PluginDefinition[]) => {
|
|
61
|
+
const isUserRoleAdministrative = shellApi.userManager.isUserRoleAdministrative();
|
|
62
|
+
const internalPlugins = getPluginsByUserRole(isUserRoleAdministrative);
|
|
62
63
|
const finalPlugins = internalPlugins.concat(plugins || []);
|
|
63
64
|
bootstrappedPlugins = await pluginBootstrapper(finalPlugins, primariaApiFactory);
|
|
64
65
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const registerLowerNavMenuViews: () => void;
|