Prettied, Linted and updated angular.json according to the latest schematic of Angular CLI.
Now all that is needed is to make it ready for strict compiling. Removed eslint-plugin-prettier as it is not recommended and causes errors for both eslint and prettier Bumped to v8.0.0
This commit is contained in:
5
overlord/src/app/role/permission.ts
Normal file
5
overlord/src/app/role/permission.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class Permission {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { RoleService } from '../role.service';
|
||||
import { Role } from '../role';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { Role } from '../role';
|
||||
import { RoleService } from '../role.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-role-detail',
|
||||
@ -61,7 +61,7 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
(result) => {
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/roles');
|
||||
},
|
||||
@ -73,7 +73,7 @@ export class RoleDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
(result) => {
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/roles');
|
||||
},
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { Role } from './role';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Role } from './role';
|
||||
import { RoleService } from './role.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RoleListResolver implements Resolve<Role[]> {
|
||||
constructor(private ser: RoleService, private router: Router) {}
|
||||
constructor(private ser: RoleService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Role[]> {
|
||||
resolve(): Observable<Role[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
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 { map } from 'rxjs/operators';
|
||||
|
||||
import { Role } from '../role';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
function compare(a, b, isAsc) {
|
||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
}
|
||||
|
||||
export class RoleListDatasource extends DataSource<Role> {
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, public data: Role[]) {
|
||||
super();
|
||||
@ -17,9 +23,7 @@ export class RoleListDatasource extends DataSource<Role> {
|
||||
this.paginator.length = this.data.length;
|
||||
|
||||
return merge(...dataMutations).pipe(
|
||||
map(() => {
|
||||
return this.getPagedData(this.getSortedData([...this.data]));
|
||||
}),
|
||||
map(() => this.getPagedData(this.getSortedData([...this.data]))),
|
||||
);
|
||||
}
|
||||
|
||||
@ -48,8 +52,3 @@ export class RoleListDatasource extends DataSource<Role> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { RoleListDatasource } from './role-list-datasource';
|
||||
import { Role } from '../role';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { Role } from '../role';
|
||||
|
||||
import { RoleListDatasource } from './role-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-role-list',
|
||||
templateUrl: './role-list.component.html',
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { Role } from './role';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Role } from './role';
|
||||
import { RoleService } from './role.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class RoleResolver implements Resolve<Role> {
|
||||
constructor(private ser: RoleService, private router: Router) {}
|
||||
constructor(private ser: RoleService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Role> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Role> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { RoleListResolver } from './role-list-resolver.service';
|
||||
import { RoleResolver } from './role-resolver.service';
|
||||
import { RoleListComponent } from './role-list/role-list.component';
|
||||
import { RoleDetailComponent } from './role-detail/role-detail.component';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { RoleDetailComponent } from './role-detail/role-detail.component';
|
||||
import { RoleListResolver } from './role-list-resolver.service';
|
||||
import { RoleListComponent } from './role-list/role-list.component';
|
||||
import { RoleResolver } from './role-resolver.service';
|
||||
|
||||
const roleRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { RoleListComponent } from './role-list/role-list.component';
|
||||
import { RoleDetailComponent } from './role-detail/role-detail.component';
|
||||
import { RoleRoutingModule } from './role-routing.module';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
@ -14,10 +13,12 @@ import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
import { RoleDetailComponent } from './role-detail/role-detail.component';
|
||||
import { RoleListComponent } from './role-list/role-list.component';
|
||||
import { RoleRoutingModule } from './role-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { Role } from './role';
|
||||
|
||||
const httpOptions = {
|
||||
@ -53,9 +55,8 @@ export class RoleService {
|
||||
saveOrUpdate(role: Role): Observable<Role> {
|
||||
if (!role.id) {
|
||||
return this.save(role);
|
||||
} else {
|
||||
return this.update(role);
|
||||
}
|
||||
return this.update(role);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Role> {
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import { Permission } from './permission';
|
||||
|
||||
export class Role {
|
||||
id: string;
|
||||
name: string;
|
||||
permissions: Permission[];
|
||||
}
|
||||
|
||||
export class Permission {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user