create permission service

This commit is contained in:
Lebeau Elise 2022-01-07 09:42:20 +00:00 committed by Sylvain MATHIEU
parent 6122801f90
commit 4911b0da66
7 changed files with 116 additions and 0 deletions

View File

@ -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";

View File

@ -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";

View File

@ -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";

View 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
}

View File

@ -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,

View 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();
});
});

View 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}`);
}
}