mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-03 11:34:12 +00:00
create permission service
This commit is contained in:
parent
6122801f90
commit
4911b0da66
@ -1,3 +1,15 @@
|
||||
/*
|
||||
* 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, Inject, OnInit} from '@angular/core';
|
||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||
import {UserService} from "@services/user.service";
|
||||
|
@ -1,3 +1,15 @@
|
||||
/*
|
||||
* 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, Inject, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {Server} from "@models/server";
|
||||
|
@ -1,3 +1,15 @@
|
||||
/*
|
||||
* 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, Inject, OnInit} from '@angular/core';
|
||||
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
|
||||
import {User} from "@models/users/user";
|
||||
|
23
src/app/models/permission.ts
Normal file
23
src/app/models/permission.ts
Normal file
@ -0,0 +1,23 @@
|
||||
export enum Methods {
|
||||
GET = 'GET',
|
||||
HEAD = 'HEAD',
|
||||
POST = 'POST',
|
||||
PATCH = 'PATCH',
|
||||
PUT = 'PUT',
|
||||
DELETE = 'DELETE'
|
||||
}
|
||||
|
||||
export enum PermissionActions {
|
||||
ALLOW = 'ALLOW',
|
||||
DENY = 'DENY'
|
||||
}
|
||||
|
||||
export interface Permission {
|
||||
methods: Methods[],
|
||||
path: string,
|
||||
action: PermissionActions,
|
||||
description: string,
|
||||
created_at: string,
|
||||
updated_at: string,
|
||||
permission_id: string
|
||||
}
|
@ -1,3 +1,15 @@
|
||||
/*
|
||||
* 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 { Injectable } from '@angular/core';
|
||||
import {
|
||||
Router, Resolve,
|
||||
|
16
src/app/services/permissions.service.spec.ts
Normal file
16
src/app/services/permissions.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PermissionsService } from './permissions.service';
|
||||
|
||||
describe('PermissionsService', () => {
|
||||
let service: PermissionsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(PermissionsService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
29
src/app/services/permissions.service.ts
Normal file
29
src/app/services/permissions.service.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {HttpServer} from "./http-server.service";
|
||||
import {Server} from "../models/server";
|
||||
import {Permission} from "../models/permission";
|
||||
import {Observable} from "rxjs/Rx";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PermissionsService {
|
||||
|
||||
constructor(private httpServer: HttpServer) { }
|
||||
|
||||
list(server: Server) {
|
||||
return this.httpServer.get<Permission[]>(server, '/permissions');
|
||||
}
|
||||
|
||||
add(server: Server, permission: Permission): Observable<Permission> {
|
||||
return this.httpServer.post<Permission>(server, '/permissions', permission);
|
||||
}
|
||||
|
||||
update(server: Server, permission: Permission): Observable<Permission> {
|
||||
return this.httpServer.put<Permission>(server, `/permissions/${permission.permission_id}`, permission);
|
||||
}
|
||||
|
||||
delete(server: Server, permission_id: string) {
|
||||
return this.httpServer.delete(server, `/permissions/${permission_id}`);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user