@memberjunction/ng-resource-permissions 2.32.2 → 2.33.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/README.md +295 -0
- package/package.json +8 -8
package/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Resource Permissions Components
|
|
2
|
+
|
|
3
|
+
A suite of Angular components for managing and displaying permissions for resources in MemberJunction applications. This package provides components for viewing and managing resource permissions, viewing available resources, and requesting access to restricted resources.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Permission Management**: View, add, edit, and delete permissions for resources
|
|
8
|
+
- **Available Resources Display**: Show resources available to a specific user
|
|
9
|
+
- **Access Requests**: Allow users to request access to resources they don't have permission for
|
|
10
|
+
- **Multiple Permission Types**: Support for both user and role-based permissions
|
|
11
|
+
- **Configurable Permission Levels**: Customizable permission levels (View, Edit, Owner)
|
|
12
|
+
- **Transaction Support**: Changes are grouped in transactions for data integrity
|
|
13
|
+
- **Filtering Options**: Filter available resources with custom criteria
|
|
14
|
+
- **Resource Type Support**: Works with all MemberJunction resource types
|
|
15
|
+
- **Responsive Design**: Adapts to different screen sizes and layouts
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @memberjunction/ng-resource-permissions
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Import the Module
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { ResourcePermissionsModule } from '@memberjunction/ng-resource-permissions';
|
|
29
|
+
|
|
30
|
+
@NgModule({
|
|
31
|
+
imports: [
|
|
32
|
+
ResourcePermissionsModule,
|
|
33
|
+
// other imports
|
|
34
|
+
],
|
|
35
|
+
// ...
|
|
36
|
+
})
|
|
37
|
+
export class YourModule { }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Resource Permissions Component
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<!-- Component for managing permissions for a resource -->
|
|
44
|
+
<mj-resource-permissions
|
|
45
|
+
[ResourceTypeID]="reportResourceTypeID"
|
|
46
|
+
[ResourceRecordID]="reportID"
|
|
47
|
+
[ShowSaveButton]="true"
|
|
48
|
+
[AllowAddPermissions]="true"
|
|
49
|
+
[AllowEditPermissions]="true"
|
|
50
|
+
[AllowDeletePermissions]="true">
|
|
51
|
+
</mj-resource-permissions>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Available Resources Component
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<!-- Component for displaying resources available to a user -->
|
|
58
|
+
<mj-available-resources
|
|
59
|
+
[User]="currentUser"
|
|
60
|
+
[ResourceTypeID]="dashboardResourceTypeID"
|
|
61
|
+
[ResourceExtraFilter]="'IsActive = 1'"
|
|
62
|
+
[SelectionMode]="'Multiple'"
|
|
63
|
+
[ExtraColumns]="'CreatedAt,LastUpdatedAt'"
|
|
64
|
+
(SelectionChanged)="onResourceSelectionChanged($event)">
|
|
65
|
+
</mj-available-resources>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Request Access Component
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<!-- Component for requesting access to a resource -->
|
|
72
|
+
<mj-request-resource-access
|
|
73
|
+
[ResourceType]="'Report'"
|
|
74
|
+
[ResourceName]="'Sales Dashboard'"
|
|
75
|
+
[ResourceRecordID]="reportID"
|
|
76
|
+
[PermissionLevel]="'View'"
|
|
77
|
+
[ShowPermissionLevelDropdown]="true"
|
|
78
|
+
(AccessRequested)="onAccessRequested($event)">
|
|
79
|
+
</mj-request-resource-access>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### TypeScript Component Example
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { Component, OnInit } from '@angular/core';
|
|
86
|
+
import { ResourceData, ResourcePermissionEntity } from '@memberjunction/core-entities';
|
|
87
|
+
import { UserInfo } from '@memberjunction/core';
|
|
88
|
+
import { MJNotificationService } from '@memberjunction/ng-notifications';
|
|
89
|
+
|
|
90
|
+
@Component({
|
|
91
|
+
selector: 'app-resource-access-manager',
|
|
92
|
+
template: `
|
|
93
|
+
<div class="resource-manager">
|
|
94
|
+
<h2>Resource Access Manager</h2>
|
|
95
|
+
|
|
96
|
+
<!-- Tab navigation -->
|
|
97
|
+
<ul class="nav-tabs">
|
|
98
|
+
<li [class.active]="activeTab === 'permissions'">
|
|
99
|
+
<a (click)="activeTab = 'permissions'">Manage Permissions</a>
|
|
100
|
+
</li>
|
|
101
|
+
<li [class.active]="activeTab === 'available'">
|
|
102
|
+
<a (click)="activeTab = 'available'">Available Resources</a>
|
|
103
|
+
</li>
|
|
104
|
+
</ul>
|
|
105
|
+
|
|
106
|
+
<!-- Permissions management tab -->
|
|
107
|
+
<div *ngIf="activeTab === 'permissions'" class="tab-content">
|
|
108
|
+
<h3>Manage Report Permissions</h3>
|
|
109
|
+
<p>Control who can access this report and at what permission level.</p>
|
|
110
|
+
|
|
111
|
+
<mj-resource-permissions
|
|
112
|
+
[ResourceTypeID]="reportResourceTypeID"
|
|
113
|
+
[ResourceRecordID]="selectedReportID"
|
|
114
|
+
[ShowSaveButton]="true"
|
|
115
|
+
[ShowPermissionLevels]="true"
|
|
116
|
+
[PermissionTypes]="['User', 'Role']"
|
|
117
|
+
[ExcludedRoleNames]="['System Administrator']">
|
|
118
|
+
</mj-resource-permissions>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<!-- Available resources tab -->
|
|
122
|
+
<div *ngIf="activeTab === 'available'" class="tab-content">
|
|
123
|
+
<h3>Resources Available to User</h3>
|
|
124
|
+
<p>Select a user to view their accessible resources:</p>
|
|
125
|
+
|
|
126
|
+
<select [(ngModel)]="selectedUser">
|
|
127
|
+
<option *ngFor="let user of users" [ngValue]="user">
|
|
128
|
+
{{user.Name}} ({{user.Email}})
|
|
129
|
+
</option>
|
|
130
|
+
</select>
|
|
131
|
+
|
|
132
|
+
<mj-available-resources
|
|
133
|
+
*ngIf="selectedUser"
|
|
134
|
+
[User]="selectedUser"
|
|
135
|
+
[ResourceTypeID]="reportResourceTypeID"
|
|
136
|
+
[ExtraColumns]="'CreatedAt,ModifiedAt'"
|
|
137
|
+
(SelectionChanged)="onAvailableResourcesChanged($event)">
|
|
138
|
+
</mj-available-resources>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
`,
|
|
142
|
+
styles: [`
|
|
143
|
+
.resource-manager {
|
|
144
|
+
padding: 20px;
|
|
145
|
+
}
|
|
146
|
+
.nav-tabs {
|
|
147
|
+
display: flex;
|
|
148
|
+
list-style: none;
|
|
149
|
+
padding: 0;
|
|
150
|
+
border-bottom: 1px solid #ccc;
|
|
151
|
+
}
|
|
152
|
+
.nav-tabs li {
|
|
153
|
+
padding: 10px 20px;
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
}
|
|
156
|
+
.nav-tabs li.active {
|
|
157
|
+
border-bottom: 2px solid #0066cc;
|
|
158
|
+
font-weight: bold;
|
|
159
|
+
}
|
|
160
|
+
.tab-content {
|
|
161
|
+
padding: 20px 0;
|
|
162
|
+
}
|
|
163
|
+
`]
|
|
164
|
+
})
|
|
165
|
+
export class ResourceAccessManagerComponent implements OnInit {
|
|
166
|
+
activeTab = 'permissions';
|
|
167
|
+
reportResourceTypeID = '1'; // Resource type ID for reports
|
|
168
|
+
selectedReportID = '123'; // ID of the selected report
|
|
169
|
+
selectedUser?: UserInfo;
|
|
170
|
+
users: UserInfo[] = [];
|
|
171
|
+
|
|
172
|
+
constructor(private notificationService: MJNotificationService) {}
|
|
173
|
+
|
|
174
|
+
async ngOnInit() {
|
|
175
|
+
// Load users
|
|
176
|
+
// This would typically come from your user service
|
|
177
|
+
this.users = await this.loadUsers();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async loadUsers(): Promise<UserInfo[]> {
|
|
181
|
+
// Implementation for loading users
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
onAvailableResourcesChanged(resources: ResourceData[]) {
|
|
186
|
+
console.log('Selected resources:', resources);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
onAccessRequested(permission: ResourcePermissionEntity) {
|
|
190
|
+
this.notificationService.CreateSimpleNotification(
|
|
191
|
+
`Access request submitted for ${permission.Get('ResourceType')}`,
|
|
192
|
+
'success',
|
|
193
|
+
3000
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## API Reference
|
|
200
|
+
|
|
201
|
+
### ResourcePermissionsComponent
|
|
202
|
+
|
|
203
|
+
Component for managing permissions for a specific resource.
|
|
204
|
+
|
|
205
|
+
#### Inputs
|
|
206
|
+
|
|
207
|
+
- `ResourceTypeID`: string - ID of the resource type record (required)
|
|
208
|
+
- `ResourceRecordID`: string - ID of the resource record (required)
|
|
209
|
+
- `ShowSaveButton`: boolean - Whether to show the Save button (default: false)
|
|
210
|
+
- `ShowPermissionLevels`: boolean - Whether to show permission level options (default: true)
|
|
211
|
+
- `ShowUserErrorMessages`: boolean - Whether to show error messages to the user (default: false)
|
|
212
|
+
- `AllowAddPermissions`: boolean - Whether the user can add permissions (default: true)
|
|
213
|
+
- `AllowEditPermissions`: boolean - Whether the user can edit permissions (default: true)
|
|
214
|
+
- `AllowDeletePermissions`: boolean - Whether the user can delete permissions (default: true)
|
|
215
|
+
- `PermissionLevels`: string[] - Available permission levels (default: ['View', 'Edit', 'Owner'])
|
|
216
|
+
- `PermissionTypes`: string[] - Available permission types (default: ['User', 'Role'])
|
|
217
|
+
- `ExcludedRoleNames`: string[] - Role names to exclude from selection
|
|
218
|
+
- `ExcludedUserEmails`: string[] - User emails to exclude from selection
|
|
219
|
+
|
|
220
|
+
#### Methods
|
|
221
|
+
|
|
222
|
+
- `SavePermissions()`: Promise<boolean> - Saves all permission changes
|
|
223
|
+
- `UpdateResourceRecordID(ResourceRecordID: string)`: Updates the resource record ID
|
|
224
|
+
|
|
225
|
+
### AvailableResourcesComponent
|
|
226
|
+
|
|
227
|
+
Component for displaying resources available to a specific user.
|
|
228
|
+
|
|
229
|
+
#### Inputs
|
|
230
|
+
|
|
231
|
+
- `User`: UserInfo - The user to show resources for (required)
|
|
232
|
+
- `ResourceTypeID`: string - ID of the resource type (required)
|
|
233
|
+
- `ResourceExtraFilter`: string - Additional filter for resources
|
|
234
|
+
- `SelectionMode`: 'Single' | 'Multiple' - Selection mode for the grid (default: 'Single')
|
|
235
|
+
- `ExtraColumns`: string - Comma-delimited list of additional columns to display
|
|
236
|
+
- `SelectedResources`: ResourceData[] - Array of currently selected resources
|
|
237
|
+
|
|
238
|
+
#### Outputs
|
|
239
|
+
|
|
240
|
+
- `SelectionChanged`: EventEmitter<ResourceData[]> - Emitted when resource selection changes
|
|
241
|
+
|
|
242
|
+
#### Methods
|
|
243
|
+
|
|
244
|
+
- `Refresh()`: Promise<void> - Refreshes the component data
|
|
245
|
+
|
|
246
|
+
### RequestResourceAccessComponent
|
|
247
|
+
|
|
248
|
+
Component for requesting access to a resource.
|
|
249
|
+
|
|
250
|
+
#### Inputs
|
|
251
|
+
|
|
252
|
+
- `ResourceType`: string - The name of the resource type (required)
|
|
253
|
+
- `ResourceName`: string - The name of the resource to display
|
|
254
|
+
- `ResourceRecordID`: string - ID of the resource record (required)
|
|
255
|
+
- `PermissionLevel`: 'View' | 'Edit' | 'Owner' - Default permission level (default: 'View')
|
|
256
|
+
- `ShowPermissionLevelDropdown`: boolean - Whether to show permission level selection (default: true)
|
|
257
|
+
|
|
258
|
+
#### Outputs
|
|
259
|
+
|
|
260
|
+
- `AccessRequested`: EventEmitter<ResourcePermissionEntity> - Emitted when access is requested
|
|
261
|
+
|
|
262
|
+
#### Methods
|
|
263
|
+
|
|
264
|
+
- `requestAccess()`: Promise<void> - Submits the access request
|
|
265
|
+
|
|
266
|
+
## Permission Workflow
|
|
267
|
+
|
|
268
|
+
1. **Managing Permissions**: Use the ResourcePermissionsComponent to add, edit, or remove permissions for users and roles
|
|
269
|
+
2. **Viewing Available Resources**: Use the AvailableResourcesComponent to display resources a user has access to
|
|
270
|
+
3. **Requesting Access**: Use the RequestResourceAccessComponent to allow users to request access to resources they don't have permission for
|
|
271
|
+
|
|
272
|
+
## Resource Types
|
|
273
|
+
|
|
274
|
+
The resource permissions system works with any resource type defined in MemberJunction, including:
|
|
275
|
+
|
|
276
|
+
- Reports
|
|
277
|
+
- Dashboards
|
|
278
|
+
- Queries
|
|
279
|
+
- Documents
|
|
280
|
+
- Other custom resource types
|
|
281
|
+
|
|
282
|
+
## Styling
|
|
283
|
+
|
|
284
|
+
The components include basic CSS that can be customized to match your application's design.
|
|
285
|
+
|
|
286
|
+
## Dependencies
|
|
287
|
+
|
|
288
|
+
- `@memberjunction/core`: For metadata and entity access
|
|
289
|
+
- `@memberjunction/core-entities`: For resource and permission entity types
|
|
290
|
+
- `@memberjunction/global`: For global utilities
|
|
291
|
+
- `@memberjunction/ng-base-types`: For Angular component base classes
|
|
292
|
+
- `@memberjunction/ng-notifications`: For notification services
|
|
293
|
+
- `@progress/kendo-angular-grid`: For grid components
|
|
294
|
+
- `@progress/kendo-angular-buttons`: For UI buttons
|
|
295
|
+
- `@progress/kendo-angular-dropdowns`: For dropdown selectors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-resource-permissions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.0",
|
|
4
4
|
"description": "MemberJunction: Generic Angular components for displaying/editing permissions for a resource",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"@angular/router": "18.0.2"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@memberjunction/global": "2.
|
|
29
|
-
"@memberjunction/core": "2.
|
|
30
|
-
"@memberjunction/core-entities": "2.
|
|
31
|
-
"@memberjunction/ng-container-directives": "2.
|
|
32
|
-
"@memberjunction/ng-notifications": "2.
|
|
33
|
-
"@memberjunction/ng-generic-dialog": "2.
|
|
34
|
-
"@memberjunction/ng-base-types": "2.
|
|
28
|
+
"@memberjunction/global": "2.33.0",
|
|
29
|
+
"@memberjunction/core": "2.33.0",
|
|
30
|
+
"@memberjunction/core-entities": "2.33.0",
|
|
31
|
+
"@memberjunction/ng-container-directives": "2.33.0",
|
|
32
|
+
"@memberjunction/ng-notifications": "2.33.0",
|
|
33
|
+
"@memberjunction/ng-generic-dialog": "2.33.0",
|
|
34
|
+
"@memberjunction/ng-base-types": "2.33.0",
|
|
35
35
|
"@progress/kendo-angular-dropdowns": "16.2.0",
|
|
36
36
|
"@progress/kendo-angular-grid": "16.2.0",
|
|
37
37
|
"@progress/kendo-angular-buttons": "16.2.0",
|