From 2a288b981c099881eb03d47405ae5db579b6eb8c Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Wed, 21 Aug 2024 13:48:03 +0300 Subject: [PATCH] added planstatus permissions and routing structure --- .../opencdmp/authorization/Permission.java | 1 + .../planstatus/PlanStatusServiceImpl.java | 2 + .../src/main/resources/config/permissions.yml | 33 ++++++++++++ frontend/src/app/app-routing.module.ts | 10 +++- .../app/core/common/enum/permission.enum.ts | 5 ++ .../admin/plan-status/plan-status.module.ts | 15 ++++++ .../admin/plan-status/plan-status.routing.ts | 54 +++++++++++++++++++ 7 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 frontend/src/app/ui/admin/plan-status/plan-status.module.ts create mode 100644 frontend/src/app/ui/admin/plan-status/plan-status.routing.ts diff --git a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java index f41393fc5..ad0c78e38 100644 --- a/backend/core/src/main/java/org/opencdmp/authorization/Permission.java +++ b/backend/core/src/main/java/org/opencdmp/authorization/Permission.java @@ -245,5 +245,6 @@ public final class Permission { public static String ViewMineInAppNotificationPage = "ViewMineInAppNotificationPage"; public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage"; public static String ViewStatusPage = "ViewStatusPage"; + public static String ViewPlanStatusPage = "ViewPlanStatusPage"; } diff --git a/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java index 8ba9cf16e..e95e4fdee 100644 --- a/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/planstatus/PlanStatusServiceImpl.java @@ -34,6 +34,7 @@ import org.opencdmp.service.tag.TagServiceImpl; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Service; import javax.management.InvalidApplicationException; import java.time.Instant; @@ -41,6 +42,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +@Service public class PlanStatusServiceImpl implements PlanStatusService { private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(PlanStatusServiceImpl.class)); diff --git a/backend/web/src/main/resources/config/permissions.yml b/backend/web/src/main/resources/config/permissions.yml index 631b1f164..0b264b4d2 100644 --- a/backend/web/src/main/resources/config/permissions.yml +++ b/backend/web/src/main/resources/config/permissions.yml @@ -115,6 +115,31 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + + #PlanStatus + BrowsePlanStatus: + roles: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + EditPlanStatus: + roles: + - Admin + - TenantAdmin + - TenantConfigManager + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + DeletePlanStatus: + roles: + - Admin + - TenantAdmin + - TenantConfigManager + claims: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + # NotificationTemplate BrowseNotificationTemplate: roles: [ ] @@ -1294,4 +1319,12 @@ permissions: - TenantAdmin clients: [ ] allowAnonymous: false + allowAuthenticated: false + ViewPlanStatusPage: + roles: + - Admin + - TenantAdmin + - TenantConfigManager + clients: [ ] + allowAnonymous: false allowAuthenticated: false \ No newline at end of file diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 8f46be4f9..6321f794b 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -396,6 +396,15 @@ const appRoutes: Routes = [ }) }, }, + { + path: 'plan-statuses', + loadChildren: () => import('./ui/admin/plan-status/plan-status.module').then(m => m.PlanStatusModule), + data: { + authContext: { + permissions: [AppPermission.ViewMaintenancePage] + }, + } + }, { path: 'login', loadChildren: () => import('./ui/auth/login/login.module').then(m => m.LoginModule), @@ -436,4 +445,3 @@ const tenantEnrichedRoutes: Routes = [ exports: [RouterModule], }) export class AppRoutingModule { } - diff --git a/frontend/src/app/core/common/enum/permission.enum.ts b/frontend/src/app/core/common/enum/permission.enum.ts index d6516d5f1..1a3b26a27 100644 --- a/frontend/src/app/core/common/enum/permission.enum.ts +++ b/frontend/src/app/core/common/enum/permission.enum.ts @@ -85,6 +85,11 @@ export enum AppPermission { InvitePlanUsers = "InvitePlanUsers", AnnotatePlan = "AnnotatePlan", + //PlanStatus + BrowsePlanStatus = "BrowsePlanStatus", + EditPlanStatus = "EditPlanStatus", + DeletePlanStatus = "DeletePlanStatus", + //PlanBlueprint BrowsePlanBlueprint = "BrowsePlanBlueprint", EditPlanBlueprint = "EditPlanBlueprint", diff --git a/frontend/src/app/ui/admin/plan-status/plan-status.module.ts b/frontend/src/app/ui/admin/plan-status/plan-status.module.ts new file mode 100644 index 000000000..99e0743f5 --- /dev/null +++ b/frontend/src/app/ui/admin/plan-status/plan-status.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from "@angular/core"; +import { CommonFormsModule } from '@common/forms/common-forms.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { PlanStatusRoutingModule } from "./plan-status.routing"; + +@NgModule({ + imports: [ + CommonUiModule, + CommonFormsModule, + PlanStatusRoutingModule, + ], + declarations: [ + ] +}) +export class PlanStatusModule { } diff --git a/frontend/src/app/ui/admin/plan-status/plan-status.routing.ts b/frontend/src/app/ui/admin/plan-status/plan-status.routing.ts new file mode 100644 index 000000000..439c9c961 --- /dev/null +++ b/frontend/src/app/ui/admin/plan-status/plan-status.routing.ts @@ -0,0 +1,54 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { AppPermission } from '@app/core/common/enum/permission.enum'; +import { AuthGuard } from '@app/core/auth-guard.service'; +import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service'; +import { PendingChangesGuard } from '@common/forms/pending-form-changes/pending-form-changes-guard.service'; + +const routes: Routes = [ + { + path: '', + // component:, + canActivate: [AuthGuard] + }, + { + path: 'new', + canActivate: [AuthGuard], + // component:, + canDeactivate: [PendingChangesGuard], + data: { + authContext: { + permissions: [AppPermission.EditPlanStatus] + }, + ...BreadcrumbService.generateRouteDataConfiguration({ + title: 'BREADCRUMBS.NEW-LANGUAGE' + }), + getFromTitleService: true, + usePrefix: false + } + }, + { + path: ':id', + canActivate: [AuthGuard], + // component:, + canDeactivate: [PendingChangesGuard], + // resolve: { + // 'entity': + // }, + data: { + authContext: { + permissions: [AppPermission.EditPlanStatus] + }, + getFromTitleService: true, + usePrefix: false + } + + }, + { path: '**', loadChildren: () => import('@common/modules/page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class PlanStatusRoutingModule { }