Roles
This commit is contained in:
parent
63f5f60842
commit
2b2624c9c2
|
@ -87,11 +87,11 @@ def includeme(config):
|
||||||
config.add_route('users_id', '/users/{id}')
|
config.add_route('users_id', '/users/{id}')
|
||||||
|
|
||||||
config.add_route('v1_roles_new', '/v1/roles/new')
|
config.add_route('v1_roles_new', '/v1/roles/new')
|
||||||
config.add_route('v1_roles_list', '/v1/roles/list')
|
|
||||||
config.add_route('v1_roles_id', '/v1/roles/{id}')
|
config.add_route('v1_roles_id', '/v1/roles/{id}')
|
||||||
|
config.add_route('v1_roles_list', '/v1/roles')
|
||||||
config.add_route('roles_new', '/roles/new')
|
config.add_route('roles_new', '/roles/new')
|
||||||
config.add_route('roles_list', '/roles/list')
|
|
||||||
config.add_route('roles_id', '/roles/{id}')
|
config.add_route('roles_id', '/roles/{id}')
|
||||||
|
config.add_route('roles_list', '/roles')
|
||||||
|
|
||||||
config.add_route('v1_guest_book_new', '/v1/guest-book/new')
|
config.add_route('v1_guest_book_new', '/v1/guest-book/new')
|
||||||
config.add_route('v1_guest_book_list', '/v1/guest-book/list')
|
config.add_route('v1_guest_book_list', '/v1/guest-book/list')
|
||||||
|
|
|
@ -7,7 +7,7 @@ from pyramid.view import view_config
|
||||||
from barker.models import Permission, Role
|
from barker.models import Permission, Role
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='PUT', route_name='v1_roles_new', renderer='json', permission='Users', trans=True)
|
@view_config(request_method='POST', route_name='v1_roles_new', renderer='json', permission='Users', trans=True)
|
||||||
def save(request):
|
def save(request):
|
||||||
item = Role(request.json_body['name'])
|
item = Role(request.json_body['name'])
|
||||||
request.dbsession.add(item)
|
request.dbsession.add(item)
|
||||||
|
@ -18,7 +18,7 @@ def save(request):
|
||||||
return role_info(item, permissions)
|
return role_info(item, permissions)
|
||||||
|
|
||||||
|
|
||||||
@view_config(request_method='POST', route_name='v1_roles_id', renderer='json', permission='Users', trans=True)
|
@view_config(request_method='PUT', route_name='v1_roles_id', renderer='json', permission='Users', trans=True)
|
||||||
def update(request):
|
def update(request):
|
||||||
id_ = request.matchdict['id']
|
id_ = request.matchdict['id']
|
||||||
item = request.dbsession.query(Role).filter(Role.id == uuid.UUID(id_)).one()
|
item = request.dbsession.query(Role).filter(Role.id == uuid.UUID(id_)).one()
|
||||||
|
|
|
@ -21,6 +21,10 @@ const routes: Routes = [
|
||||||
path: 'product-groups',
|
path: 'product-groups',
|
||||||
loadChildren: () => import('./product-group/product-groups.module').then(mod => mod.ProductGroupsModule)
|
loadChildren: () => import('./product-group/product-groups.module').then(mod => mod.ProductGroupsModule)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'roles',
|
||||||
|
loadChildren: () => import('./roles/roles.module').then(mod => mod.RolesModule)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'running-tables',
|
path: 'running-tables',
|
||||||
loadChildren: () => import('./running-tables/running-tables.module').then(mod => mod.RunningTablesModule)
|
loadChildren: () => import('./running-tables/running-tables.module').then(mod => mod.RunningTablesModule)
|
||||||
|
|
|
@ -22,7 +22,6 @@ import {CoreModule} from "./core/core.module";
|
||||||
import {ReactiveFormsModule} from "@angular/forms";
|
import {ReactiveFormsModule} from "@angular/forms";
|
||||||
import {SharedModule} from "./shared/shared.module";
|
import {SharedModule} from "./shared/shared.module";
|
||||||
import {UserModule} from "./user/user.module";
|
import {UserModule} from "./user/user.module";
|
||||||
import {RoleModule} from "./role/role.module";
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -49,7 +48,6 @@ import {RoleModule} from "./role/role.module";
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
CoreModule,
|
CoreModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
RoleModule,
|
|
||||||
UserModule
|
UserModule
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||||
|
import {Observable} from 'rxjs/internal/Observable';
|
||||||
|
import {Table} from "../core/table";
|
||||||
|
import {TableService} from "../tables/table.service";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BillResolver implements Resolve<Table[]> {
|
||||||
|
|
||||||
|
constructor(private ser: TableService, private router: Router) {
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Table[]> {
|
||||||
|
return this.ser.list();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
import { AuthGuard } from "../auth/auth-guard.service";
|
||||||
|
import { BillsComponent } from "./bills.component";
|
||||||
|
import { BillResolver } from "./bill-resolver.service";
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: 'new',
|
||||||
|
component: BillsComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
permission: 'Guest Book'
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
list: BillResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: ':id',
|
||||||
|
component: BillsComponent,
|
||||||
|
canActivate: [AuthGuard],
|
||||||
|
data: {
|
||||||
|
permission: 'Guest Book'
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
item: BillResolver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [],
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule],
|
||||||
|
providers: [
|
||||||
|
BillResolver
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class BillsRoutingModule { }
|
|
@ -0,0 +1,10 @@
|
||||||
|
.kot {
|
||||||
|
background-color: red;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.square-button {
|
||||||
|
min-width: 150px;
|
||||||
|
max-width: 150px;
|
||||||
|
min-height: 150px;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<mat-card>
|
||||||
|
<mat-card-title-group>
|
||||||
|
<mat-card-title>Bill</mat-card-title>
|
||||||
|
</mat-card-title-group>
|
||||||
|
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||||
|
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||||
|
<!-- Info Column -->
|
||||||
|
<ng-container matColumnDef="info">
|
||||||
|
<mat-cell *matCellDef="let row" [class.kot]="row.isKot">{{row.info}}</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||||
|
</mat-table>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { BillsComponent } from './bills.component';
|
||||||
|
|
||||||
|
describe('BillsComponent', () => {
|
||||||
|
let component: BillsComponent;
|
||||||
|
let fixture: ComponentFixture<BillsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ BillsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(BillsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from "@angular/router";
|
||||||
|
import { Table } from "../core/table";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-bills',
|
||||||
|
templateUrl: './bills.component.html',
|
||||||
|
styleUrls: ['./bills.component.css']
|
||||||
|
})
|
||||||
|
export class BillsComponent implements OnInit {
|
||||||
|
list: Table[];
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.route.data
|
||||||
|
.subscribe((data: { list: Table[] }) => {
|
||||||
|
this.list = data.list;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
|
import { BillsRoutingModule } from './bills-routing.module';
|
||||||
|
import { BillsComponent } from './bills.component';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { MatTableModule } from '@angular/material/table';
|
||||||
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [BillsComponent],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
FlexLayoutModule,
|
||||||
|
MatButtonModule,
|
||||||
|
MatCardModule,
|
||||||
|
MatTableModule,
|
||||||
|
BillsRoutingModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class BillsModule { }
|
|
@ -19,6 +19,9 @@
|
||||||
<a mat-raised-button routerLink="/taxes">
|
<a mat-raised-button routerLink="/taxes">
|
||||||
Taxes
|
Taxes
|
||||||
</a>
|
</a>
|
||||||
|
<a mat-raised-button routerLink="/roles">
|
||||||
|
Roles
|
||||||
|
</a>
|
||||||
<a mat-raised-button routerLink="/logout" *ngIf="nameObject | async as name">
|
<a mat-raised-button routerLink="/logout" *ngIf="nameObject | async as name">
|
||||||
<mat-icon>account_box</mat-icon>
|
<mat-icon>account_box</mat-icon>
|
||||||
Logout {{name}}
|
Logout {{name}}
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
import {DataSource} from '@angular/cdk/collections';
|
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
|
||||||
import { MatSort } from '@angular/material/sort';
|
|
||||||
import {map} from 'rxjs/operators';
|
|
||||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
|
||||||
import {Role} from '../role';
|
|
||||||
|
|
||||||
export class RoleListDataSource extends DataSource<Role> {
|
|
||||||
|
|
||||||
constructor(private paginator: MatPaginator, private sort: MatSort, public data: Role[]) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(): Observable<Role[]> {
|
|
||||||
const dataMutations = [
|
|
||||||
observableOf(this.data),
|
|
||||||
this.paginator.page,
|
|
||||||
this.sort.sortChange
|
|
||||||
];
|
|
||||||
|
|
||||||
// Set the paginators length
|
|
||||||
this.paginator.length = this.data.length;
|
|
||||||
|
|
||||||
return merge(...dataMutations).pipe(map(() => {
|
|
||||||
return this.getPagedData(this.getSortedData([...this.data]));
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnect() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private getPagedData(data: Role[]) {
|
|
||||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
|
||||||
return data.splice(startIndex, this.paginator.pageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getSortedData(data: Role[]) {
|
|
||||||
if (!this.sort.active || this.sort.direction === '') {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data.sort((a, b) => {
|
|
||||||
const isAsc = this.sort.direction === 'asc';
|
|
||||||
switch (this.sort.active) {
|
|
||||||
case 'name':
|
|
||||||
return compare(a.name, b.name, isAsc);
|
|
||||||
case 'id':
|
|
||||||
return compare(+a.id, +b.id, isAsc);
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Simple sort comparator for example ID/Name columns (for user-side sorting). */
|
|
||||||
function compare(a, b, isAsc) {
|
|
||||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {RoleDetailComponent} from './role-detail.component';
|
||||||
|
|
||||||
|
describe('RoleDetailComponent', () => {
|
||||||
|
let component: RoleDetailComponent;
|
||||||
|
let fixture: ComponentFixture<RoleDetailComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [RoleDetailComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(RoleDetailComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,12 +1,11 @@
|
||||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { RoleService } from '../role.service';
|
||||||
import {RoleService} from '../role.service';
|
import { Role } from '../role';
|
||||||
import {Role} from '../role';
|
import { ToasterService } from '../../core/toaster.service';
|
||||||
import {ToasterService} from '../../core/toaster.service';
|
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
|
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-role-detail',
|
selector: 'app-role-detail',
|
||||||
|
@ -62,7 +61,7 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(result) => {
|
(result) => {
|
||||||
this.toaster.show('Success', '');
|
this.toaster.show('Success', '');
|
||||||
this.router.navigateByUrl('/roles/list');
|
this.router.navigateByUrl('/roles');
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.toaster.show('Danger', error.error);
|
this.toaster.show('Danger', error.error);
|
||||||
|
@ -75,7 +74,7 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(result) => {
|
(result) => {
|
||||||
this.toaster.show('Success', '');
|
this.toaster.show('Success', '');
|
||||||
this.router.navigateByUrl('/Roles');
|
this.router.navigateByUrl('/roles');
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.toaster.show('Danger', error.error);
|
this.toaster.show('Danger', error.error);
|
|
@ -0,0 +1,15 @@
|
||||||
|
import {inject, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {RoleListResolver} from './role-list-resolver.service';
|
||||||
|
|
||||||
|
describe('RoleListResolver', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [RoleListResolver]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([RoleListResolver], (service: RoleListResolver) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { DataSource } from '@angular/cdk/collections';
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { Role } from '../role';
|
||||||
|
|
||||||
|
export class RoleListDataSource extends DataSource<Role> {
|
||||||
|
|
||||||
|
constructor(public data: Role[]) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(): Observable<Role[]> {
|
||||||
|
return observableOf(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {RoleListComponent} from './role-list.component';
|
||||||
|
|
||||||
|
describe('RoleListComponent', () => {
|
||||||
|
let component: RoleListComponent;
|
||||||
|
let fixture: ComponentFixture<RoleListComponent>;
|
||||||
|
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [RoleListComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(RoleListComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should compile', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,9 +1,7 @@
|
||||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { MatPaginator } from '@angular/material/paginator';
|
import { RoleListDataSource } from './role-list-datasource';
|
||||||
import { MatSort } from '@angular/material/sort';
|
import { Role } from '../role';
|
||||||
import {RoleListDataSource} from './role-list-datasource';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import {Role} from '../role';
|
|
||||||
import {ActivatedRoute} from '@angular/router';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-role-list',
|
selector: 'app-role-list',
|
||||||
|
@ -11,8 +9,6 @@ import {ActivatedRoute} from '@angular/router';
|
||||||
styleUrls: ['./role-list.component.css']
|
styleUrls: ['./role-list.component.css']
|
||||||
})
|
})
|
||||||
export class RoleListComponent implements OnInit {
|
export class RoleListComponent implements OnInit {
|
||||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
|
||||||
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
|
||||||
dataSource: RoleListDataSource;
|
dataSource: RoleListDataSource;
|
||||||
list: Role[];
|
list: Role[];
|
||||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||||
|
@ -26,6 +22,6 @@ export class RoleListComponent implements OnInit {
|
||||||
.subscribe((data: { list: Role[] }) => {
|
.subscribe((data: { list: Role[] }) => {
|
||||||
this.list = data.list;
|
this.list = data.list;
|
||||||
});
|
});
|
||||||
this.dataSource = new RoleListDataSource(this.paginator, this.sort, this.list);
|
this.dataSource = new RoleListDataSource(this.list);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
import {inject, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {RoleResolver} from './role-resolver.service';
|
||||||
|
|
||||||
|
describe('RoleResolver', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [RoleResolver]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([RoleResolver], (service: RoleResolver) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
|
@ -0,0 +1,15 @@
|
||||||
|
import {inject, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
import {RoleService} from './role.service';
|
||||||
|
|
||||||
|
describe('RoleService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [RoleService]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', inject([RoleService], (service: RoleService) => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
}));
|
||||||
|
});
|
|
@ -28,21 +28,29 @@ export class RoleService {
|
||||||
|
|
||||||
list(): Observable<Role[]> {
|
list(): Observable<Role[]> {
|
||||||
const options = {params: new HttpParams().set('l', '')};
|
const options = {params: new HttpParams().set('l', '')};
|
||||||
return <Observable<Role[]>>this.http.get<Role[]>(`${url}/list`, options)
|
return <Observable<Role[]>>this.http.get<Role[]>(url, options)
|
||||||
|
.pipe(
|
||||||
|
catchError(this.log.handleError(serviceName, 'list'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
listOfNames(): Observable<string[]> {
|
||||||
|
const options = {params: new HttpParams().set('n', '')};
|
||||||
|
return <Observable<string[]>>this.http.get<string[]>(url, options)
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(this.log.handleError(serviceName, 'list'))
|
catchError(this.log.handleError(serviceName, 'list'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(role: Role): Observable<Role> {
|
save(role: Role): Observable<Role> {
|
||||||
return <Observable<Role>>this.http.put<Role>(`${url}/new`, role, httpOptions)
|
return <Observable<Role>>this.http.post<Role>(`${url}/new`, role, httpOptions)
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(this.log.handleError(serviceName, 'save'))
|
catchError(this.log.handleError(serviceName, 'save'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(role: Role): Observable<Role> {
|
update(role: Role): Observable<Role> {
|
||||||
return <Observable<Role>>this.http.post<Role>(`${url}/${role.id}`, role, httpOptions)
|
return <Observable<Role>>this.http.put<Role>(`${url}/${role.id}`, role, httpOptions)
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(this.log.handleError(serviceName, 'update'))
|
catchError(this.log.handleError(serviceName, 'update'))
|
||||||
);
|
);
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { RolesRoutingModule } from './roles-routing.module';
|
||||||
|
|
||||||
|
describe('RolesRoutingModule', () => {
|
||||||
|
let rolesRoutingModule: RolesRoutingModule;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
rolesRoutingModule = new RolesRoutingModule();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(rolesRoutingModule).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -9,7 +9,7 @@ import {AuthGuard} from '../auth/auth-guard.service';
|
||||||
|
|
||||||
const roleRoutes: Routes = [
|
const roleRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'roles/list',
|
path: '',
|
||||||
component: RoleListComponent,
|
component: RoleListComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
|
@ -20,7 +20,7 @@ const roleRoutes: Routes = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'roles/new',
|
path: 'new',
|
||||||
component: RoleDetailComponent,
|
component: RoleDetailComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
|
@ -31,7 +31,7 @@ const roleRoutes: Routes = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'roles/:id',
|
path: ':id',
|
||||||
component: RoleDetailComponent,
|
component: RoleDetailComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {
|
data: {
|
||||||
|
@ -57,5 +57,5 @@ const roleRoutes: Routes = [
|
||||||
RoleResolver
|
RoleResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class RoleRoutingModule {
|
export class RolesRoutingModule {
|
||||||
}
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { RolesModule } from './roles.module';
|
||||||
|
|
||||||
|
describe('RolesModule', () => {
|
||||||
|
let rolesModule: RolesModule;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
rolesModule = new RolesModule();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(rolesModule).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -3,7 +3,7 @@ import {CommonModule} from '@angular/common';
|
||||||
|
|
||||||
import {RoleListComponent} from './role-list/role-list.component';
|
import {RoleListComponent} from './role-list/role-list.component';
|
||||||
import {RoleDetailComponent} from './role-detail/role-detail.component';
|
import {RoleDetailComponent} from './role-detail/role-detail.component';
|
||||||
import {RoleRoutingModule} from './role-routing.module';
|
import {RolesRoutingModule} from './roles-routing.module';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
|
@ -36,12 +36,12 @@ import {FlexLayoutModule} from '@angular/flex-layout';
|
||||||
MatTableModule,
|
MatTableModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
RoleRoutingModule
|
RolesRoutingModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
RoleListComponent,
|
RoleListComponent,
|
||||||
RoleDetailComponent
|
RoleDetailComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class RoleModule {
|
export class RolesModule {
|
||||||
}
|
}
|
Loading…
Reference in New Issue