diff --git a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts index 8ac5030..0efcd55 100644 --- a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts +++ b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts @@ -3,9 +3,10 @@ import { HttpClient } from '@angular/common/http'; import { Router } from "@angular/router"; import { ToastrService } from "ngx-toastr"; import { ConfigService } from '@services/config.service'; -import {BootSoPartitionComponent} from "./boot-so-partition/boot-so-partition.component"; -import {MatDialog} from "@angular/material/dialog"; -import {RemoveCacheImageComponent} from "./remove-cache-image/remove-cache-image.component"; +import { BootSoPartitionComponent } from "./boot-so-partition/boot-so-partition.component"; +import { MatDialog } from "@angular/material/dialog"; +import { RemoveCacheImageComponent } from "./remove-cache-image/remove-cache-image.component"; +import { AuthService } from '@services/auth.service'; @Component({ selector: 'app-execute-command', @@ -44,6 +45,7 @@ export class ExecuteCommandComponent implements OnInit { private router: Router, private configService: ConfigService, private toastService: ToastrService, + public auth: AuthService, private dialog: MatDialog, ) { this.baseUrl = this.configService.apiUrl; @@ -51,6 +53,9 @@ export class ExecuteCommandComponent implements OnInit { ngOnInit(): void { this.clientData = this.clientData || []; + const allowed = this.getAllowedCommandsByRole(); + this.arrayCommands = this.arrayCommands.filter(c => allowed.includes(c.slug)); + this.updateCommandStates(); } @@ -58,6 +63,34 @@ export class ExecuteCommandComponent implements OnInit { this.updateCommandStates(); } + private getAllowedCommandsByRole(): string[] { + const role = this.auth.userCategory; + + const permissions: Record = { + 'super-admin': ['*'], + 'ou-admin': ['*'], + 'ou-operator': [ + 'power-on', + 'power-off', + 'reboot', + 'login', + 'deploy-image', + 'software-inventory', + 'hardware-inventory', + 'remove-cache-image', + 'partition' + ], + 'ou-minimal': [ + 'power-on', + 'power-off' + ] + }; + + const allowed = permissions[role] || []; + return allowed.includes('*') ? this.arrayCommands.map(c => c.slug) : allowed; + } + + private updateCommandStates(): void { let states: string[] = []; diff --git a/ogWebconsole/src/app/components/groups/groups.component.html b/ogWebconsole/src/app/components/groups/groups.component.html index 1d7f19f..fde3d27 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.html +++ b/ogWebconsole/src/app/components/groups/groups.component.html @@ -11,11 +11,12 @@
- - + - diff --git a/ogWebconsole/src/app/layout/sidebar/sidebar.component.html b/ogWebconsole/src/app/layout/sidebar/sidebar.component.html index 1aab78b..3272552 100644 --- a/ogWebconsole/src/app/layout/sidebar/sidebar.component.html +++ b/ogWebconsole/src/app/layout/sidebar/sidebar.component.html @@ -1,9 +1,9 @@ @@ -18,7 +18,7 @@ + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> playlist_play {{ 'actions' | translate }} @@ -28,7 +28,7 @@ + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> chevron_right {{ 'commands' | translate }} @@ -44,7 +44,7 @@ --> + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> chevron_right {{ 'tasks' | translate }} @@ -53,15 +53,15 @@ + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> lan {{ 'subnets' | translate }} - + desktop_windows {{ 'boot' | translate }} @@ -94,7 +94,7 @@ + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> calendar_month {{ 'calendars' | translate }} @@ -102,7 +102,7 @@ + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> terminal {{ 'software' | translate }} @@ -135,7 +135,8 @@ + matTooltip="{{ 'TOOLTIP_REPOSITORIES' | translate }}" matTooltipShowDelay="1000" + *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> warehouse {{ 'repositories' | translate }} @@ -143,10 +144,10 @@ + matTooltipShowDelay="1000" *ngIf="auth.userCategory !== 'ou-operator' && auth.userCategory !== 'ou-minimal'"> list {{ 'menus' | translate }} - + \ No newline at end of file diff --git a/ogWebconsole/src/app/layout/sidebar/sidebar.component.ts b/ogWebconsole/src/app/layout/sidebar/sidebar.component.ts index ccb7ac9..7abcc59 100644 --- a/ogWebconsole/src/app/layout/sidebar/sidebar.component.ts +++ b/ogWebconsole/src/app/layout/sidebar/sidebar.component.ts @@ -1,5 +1,4 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { jwtDecode } from 'jwt-decode'; import { MatDialog } from '@angular/material/dialog'; import { AuthService } from '@services/auth.service';