Add permission management

This commit is contained in:
Lebeau Elise
2022-01-07 09:43:10 +00:00
committed by Sylvain MATHIEU
parent 65172c18b5
commit 2664911455
44 changed files with 1044 additions and 1 deletions

View File

@ -0,0 +1,6 @@
<button [ngClass]="{allow: action === 'ALLOW', deny: action === 'DENY'}"
mat-button
[disabled]="disabled"
(click)="change()">
{{action}}
</button>

View File

@ -0,0 +1,8 @@
.allow {
background-color: green;
border-radius: unset !important;
}
.deny {
background-color: darkred;
}

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActionButtonComponent } from './action-button.component';
describe('ActionButtonComponent', () => {
let component: ActionButtonComponent;
let fixture: ComponentFixture<ActionButtonComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ActionButtonComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ActionButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,38 @@
/*
* Software Name : GNS3 Web UI
* Version: 3
* SPDX-FileCopyrightText: Copyright (c) 2022 Orange Business Services
* SPDX-License-Identifier: GPL-3.0-or-later
*
* This software is distributed under the GPL-3.0 or any later version,
* the text of which is available at https://www.gnu.org/licenses/gpl-3.0.txt
* or see the "LICENSE" file for more details.
*
* Author: Sylvain MATHIEU, Elise LEBEAU
*/
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {PermissionActions} from "@models/api/permission";
@Component({
selector: 'app-action-button',
templateUrl: './action-button.component.html',
styleUrls: ['./action-button.component.scss']
})
export class ActionButtonComponent implements OnInit {
readonly DENY = 'DENY';
readonly ALLOW = 'ALLOW';
@Input() action: PermissionActions;
@Input() disabled = true;
@Output() update = new EventEmitter<PermissionActions>();
constructor() { }
ngOnInit(): void {
}
change() {
this.action === PermissionActions.DENY ? this.action = PermissionActions.ALLOW : this.action = PermissionActions.DENY;
this.update.emit(this.action);
}
}