@urga-panel/ur-panels-core 1.0.17 → 1.0.19
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.
|
@@ -16,6 +16,7 @@ export type ProjectsPages = {
|
|
|
16
16
|
service?: PageService;
|
|
17
17
|
serviceRef: any;
|
|
18
18
|
userGroup?: string;
|
|
19
|
+
onlyForGroup?: boolean;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
export type ProjectInfoOts = ServiceOts & {
|
|
@@ -37,7 +38,7 @@ export declare abstract class ProjectInfoService extends Service {
|
|
|
37
38
|
getMenuPages(userGroup?: string): {
|
|
38
39
|
[key: string]: ProjectsPages[string];
|
|
39
40
|
};
|
|
40
|
-
getMobilePages(limit?: number): {
|
|
41
|
+
getMobilePages(userGroup?: string, limit?: number): {
|
|
41
42
|
[key: string]: ProjectsPages[string];
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -45,7 +45,10 @@ export class ProjectInfoService extends Service {
|
|
|
45
45
|
Object.entries(this.pages).forEach(([key, page]) => {
|
|
46
46
|
if (page.showInMenu) {
|
|
47
47
|
if (userGroup && userGroup == 'admin') {
|
|
48
|
-
|
|
48
|
+
// If onlyForGroup is true, admin cannot see this page
|
|
49
|
+
if (page.onlyForGroup !== true) {
|
|
50
|
+
result[key] = page;
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
else {
|
|
51
54
|
if (userGroup) {
|
|
@@ -62,13 +65,30 @@ export class ProjectInfoService extends Service {
|
|
|
62
65
|
});
|
|
63
66
|
return result;
|
|
64
67
|
}
|
|
65
|
-
getMobilePages(limit = 4) {
|
|
68
|
+
getMobilePages(userGroup, limit = 4) {
|
|
66
69
|
const result = {};
|
|
67
70
|
let count = 0;
|
|
68
71
|
for (const [key, page] of Object.entries(this.pages)) {
|
|
69
72
|
if (page.showInMobile) {
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
// Apply the same group access control logic as getMenuPages
|
|
74
|
+
if (userGroup && userGroup == 'admin') {
|
|
75
|
+
// If onlyForGroup is true, admin cannot see this page
|
|
76
|
+
if (page.onlyForGroup !== true) {
|
|
77
|
+
result[key] = page;
|
|
78
|
+
count++;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (userGroup) {
|
|
82
|
+
// Check if the page is accessible by the user group
|
|
83
|
+
if (page.userGroup === userGroup) {
|
|
84
|
+
result[key] = page;
|
|
85
|
+
count++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
result[key] = page;
|
|
90
|
+
count++;
|
|
91
|
+
}
|
|
72
92
|
if (count >= limit)
|
|
73
93
|
break;
|
|
74
94
|
}
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ export type ProjectsPages = {
|
|
|
17
17
|
service?: PageService; // Optional service name for custom handling
|
|
18
18
|
serviceRef: any;
|
|
19
19
|
userGroup?: string; // Optional user group for access control
|
|
20
|
+
onlyForGroup?: boolean; // If true, only the specified userGroup can see this page (admin excluded)
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -85,7 +86,10 @@ export abstract class ProjectInfoService extends Service {
|
|
|
85
86
|
Object.entries(this.pages).forEach(([key, page]) => {
|
|
86
87
|
if (page.showInMenu) {
|
|
87
88
|
if (userGroup && userGroup == 'admin') {
|
|
88
|
-
|
|
89
|
+
// If onlyForGroup is true, admin cannot see this page
|
|
90
|
+
if (page.onlyForGroup !== true) {
|
|
91
|
+
result[key] = page;
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
94
|
else {
|
|
91
95
|
if (userGroup) {
|
|
@@ -103,13 +107,28 @@ export abstract class ProjectInfoService extends Service {
|
|
|
103
107
|
return result;
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
getMobilePages(limit: number = 4): { [key: string]: ProjectsPages[string] } {
|
|
110
|
+
getMobilePages(userGroup?: string, limit: number = 4): { [key: string]: ProjectsPages[string] } {
|
|
107
111
|
const result: { [key: string]: ProjectsPages[string] } = {};
|
|
108
112
|
let count = 0;
|
|
109
113
|
for (const [key, page] of Object.entries(this.pages)) {
|
|
110
114
|
if (page.showInMobile) {
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
// Apply the same group access control logic as getMenuPages
|
|
116
|
+
if (userGroup && userGroup == 'admin') {
|
|
117
|
+
// If onlyForGroup is true, admin cannot see this page
|
|
118
|
+
if (page.onlyForGroup !== true) {
|
|
119
|
+
result[key] = page;
|
|
120
|
+
count++;
|
|
121
|
+
}
|
|
122
|
+
} else if (userGroup) {
|
|
123
|
+
// Check if the page is accessible by the user group
|
|
124
|
+
if (page.userGroup === userGroup) {
|
|
125
|
+
result[key] = page;
|
|
126
|
+
count++;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
result[key] = page;
|
|
130
|
+
count++;
|
|
131
|
+
}
|
|
113
132
|
if (count >= limit) break;
|
|
114
133
|
}
|
|
115
134
|
}
|