diff --git a/AMW_angular/io/src/app/apps/apps.component.ts b/AMW_angular/io/src/app/apps/apps.component.ts
index 88dc877a1..a543c4717 100644
--- a/AMW_angular/io/src/app/apps/apps.component.ts
+++ b/AMW_angular/io/src/app/apps/apps.component.ts
@@ -70,8 +70,8 @@ export class AppsComponent implements OnInit, OnDestroy {
permissions = computed(() => {
if (this.authService.restrictions().length > 0) {
return {
- canCreateApp: this.authService.hasResourcePermission('RESOURCE', 'CREATE', 'APPLICATION'),
- canCreateAppServer: this.authService.hasResourcePermission('RESOURCE', 'CREATE', 'APPLICATIONSERVER'),
+ canCreateApp: this.authService.hasResourceTypePermission('RESOURCE', 'CREATE', 'APPLICATION'),
+ canCreateAppServer: this.authService.hasResourceTypePermission('RESOURCE', 'CREATE', 'APPLICATIONSERVER'),
canViewAppList: this.authService.hasPermission('APP_AND_APPSERVER_LIST', 'READ'),
};
} else {
diff --git a/AMW_angular/io/src/app/auth/auth.service.ts b/AMW_angular/io/src/app/auth/auth.service.ts
index ef5593823..8683fec38 100644
--- a/AMW_angular/io/src/app/auth/auth.service.ts
+++ b/AMW_angular/io/src/app/auth/auth.service.ts
@@ -7,6 +7,14 @@ import { Restriction } from '../settings/permission/restriction';
import { toSignal } from '@angular/core/rxjs-interop';
import { DefaultResourceType } from './defaultResourceType';
+export enum Action {
+ READ = 'READ',
+ CREATE = 'CREATE',
+ UPDATE = 'UPDATE',
+ DELETE = 'DELETE',
+ ALL = 'ALL',
+}
+
@Injectable({ providedIn: 'root' })
export class AuthService extends BaseService {
private http = inject(HttpClient);
@@ -42,17 +50,33 @@ export class AuthService extends BaseService {
hasPermission(permissionName: string, action: string): boolean {
return (
- this.getActionsForPermission(permissionName).find((value) => value === 'ALL' || value === action) !== undefined
+ this.getActionsForPermission(permissionName).find((value) => value === Action.ALL || value === action) !==
+ undefined
+ );
+ }
+
+ hasResourceGroupPermission(permissionName: string, action: string, resourceGroupId: number): boolean {
+ return (
+ this.restrictions()
+ .filter((entry) => entry.permission.name === permissionName)
+ .filter((entry) => entry.resourceGroupId === resourceGroupId || entry.resourceGroupId === null)
+ .map((entry) => entry.action)
+ .find((entry) => entry === Action.ALL || entry === action) !== undefined
);
}
- hasResourcePermission(permissionName: string, action: string, resourceType: string): boolean {
+ hasResourceTypePermission(permissionName: string, action: string, resourceTypeName: string): boolean {
return (
this.restrictions()
.filter((entry) => entry.permission.name === permissionName)
- .filter((entry) => entry.resourceTypeName === resourceType || this.isDefaultType(entry, resourceType))
+ .filter(
+ (entry) =>
+ entry.resourceTypeName === resourceTypeName ||
+ this.isDefaultType(entry, resourceTypeName) ||
+ entry.resourceTypeName === null,
+ )
.map((entry) => entry.action)
- .find((entry) => entry === 'ALL' || entry === action) !== undefined
+ .find((entry) => entry === Action.ALL || entry === action) !== undefined
);
}
@@ -67,6 +91,6 @@ export class AuthService extends BaseService {
// usage example: actions.some(isAllowed("CREATE"))
export function isAllowed(role: string) {
return (action: string) => {
- return action === 'ALL' || action === role;
+ return action === Action.ALL || action === role;
};
}
diff --git a/AMW_angular/io/src/app/resource/resource.ts b/AMW_angular/io/src/app/resource/resource.ts
index 766f767bc..5d0b661a3 100644
--- a/AMW_angular/io/src/app/resource/resource.ts
+++ b/AMW_angular/io/src/app/resource/resource.ts
@@ -8,4 +8,6 @@ export interface Resource {
defaultRelease: Release;
releases: Release[];
defaultResourceId?: number;
+ resourceGroupId?: number;
+ resourceTypeId?: number;
}
diff --git a/AMW_angular/io/src/app/resources/resource-edit-page/resource-edit-page.component.html b/AMW_angular/io/src/app/resources/resource-edit/resource-edit.component.html
similarity index 58%
rename from AMW_angular/io/src/app/resources/resource-edit-page/resource-edit-page.component.html
rename to AMW_angular/io/src/app/resources/resource-edit/resource-edit.component.html
index 505f1ed1d..48bbb36a5 100644
--- a/AMW_angular/io/src/app/resources/resource-edit-page/resource-edit-page.component.html
+++ b/AMW_angular/io/src/app/resources/resource-edit/resource-edit.component.html
@@ -12,21 +12,16 @@
Please provide a resource-id to edit a resource.
} @else {
-
- Loaded resource:
- {{ this.resource()?.name }}
-
-
+
+
}
diff --git a/AMW_angular/io/src/app/resources/resource-type-edit-page/resource-type-edit-page.component.spec.ts b/AMW_angular/io/src/app/resources/resource-edit/resource-edit.component.spec.ts
similarity index 74%
rename from AMW_angular/io/src/app/resources/resource-type-edit-page/resource-type-edit-page.component.spec.ts
rename to AMW_angular/io/src/app/resources/resource-edit/resource-edit.component.spec.ts
index 0ff2f88fd..709bedd18 100644
--- a/AMW_angular/io/src/app/resources/resource-type-edit-page/resource-type-edit-page.component.spec.ts
+++ b/AMW_angular/io/src/app/resources/resource-edit/resource-edit.component.spec.ts
@@ -1,14 +1,14 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
-import { ResourceTypeEditPageComponent } from './resource-type-edit-page.component';
+import { ResourceEditComponent } from './resource-edit.component';
import { ActivatedRoute } from '@angular/router';
import { of, Subject } from 'rxjs';
import { RouterTestingModule } from '@angular/router/testing';
describe('ResourceEditPageComponent', () => {
- let component: ResourceTypeEditPageComponent;
- let fixture: ComponentFixture;
+ let component: ResourceEditComponent;
+ let fixture: ComponentFixture;
const mockRoute: any = { queryParamMap: of() };
mockRoute.queryParamMap = new Subject