]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/form-input-disable.directive.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / directives / form-input-disable.directive.ts
CommitLineData
f91f0fd5
TL
1import { AfterViewInit, Directive, ElementRef, Optional } from '@angular/core';
2
3import { Permissions } from '../models/permissions';
4import { AuthStorageService } from '../services/auth-storage.service';
5import { FormScopeDirective } from './form-scope.directive';
6
7@Directive({
8 selector:
f67539c2 9 'input:not([cdNoFormInputDisable]), select:not([cdNoFormInputDisable]), button:not([cdNoFormInputDisable]), [cdFormInputDisable]'
f91f0fd5
TL
10})
11export class FormInputDisableDirective implements AfterViewInit {
12 permissions: Permissions;
f91f0fd5
TL
13
14 constructor(
15 @Optional() private formScope: FormScopeDirective,
16 private authStorageService: AuthStorageService,
17 private elementRef: ElementRef
18 ) {}
19
20 ngAfterViewInit() {
21 this.permissions = this.authStorageService.getPermissions();
f67539c2
TL
22 const service_name = this.formScope?.cdFormScope;
23 if (service_name && !this.permissions?.[service_name]?.update) {
f91f0fd5
TL
24 this.elementRef.nativeElement.disabled = true;
25 }
26 }
27}