Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -5,40 +5,68 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" (keyup.enter)="save()">
|
||||
<input
|
||||
matInput
|
||||
#nameElement
|
||||
placeholder="Name"
|
||||
formControlName="name"
|
||||
(keyup.enter)="save()"
|
||||
/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Seats</mat-label>
|
||||
<input matInput type="number" placeholder="Seats" formControlName="seats">
|
||||
<input matInput type="number" placeholder="Seats" formControlName="seats" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Section</mat-label>
|
||||
<mat-select placeholder="Section" formControlName="section">
|
||||
<mat-option *ngFor="let s of sections" [value]="s.id">
|
||||
{{ s.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button (click)="save()" color="primary">Save</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">
|
||||
Delete
|
||||
</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {TableDetailComponent} from './tables-detail.component';
|
||||
import { TableDetailComponent } from './tables-detail.component';
|
||||
|
||||
describe('TableDetailComponent', () => {
|
||||
let component: TableDetailComponent;
|
||||
@ -8,9 +8,8 @@ describe('TableDetailComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TableDetailComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [TableDetailComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
|
||||
import {TableService} from '../table.service';
|
||||
import {Table} from '../../core/table';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {Section} from '../../core/section';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { Section } from '../../core/section';
|
||||
import { Table } from '../../core/table';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { TableService } from '../table.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-table-detail',
|
||||
templateUrl: './table-detail.component.html',
|
||||
styleUrls: ['./table-detail.component.css']
|
||||
styleUrls: ['./table-detail.component.css'],
|
||||
})
|
||||
export class TableDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
@ -26,7 +26,7 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: TableService
|
||||
private ser: TableService,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
@ -36,16 +36,15 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
|
||||
name: '',
|
||||
seats: '',
|
||||
section: '',
|
||||
isActive: ''
|
||||
isActive: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Table, sections: Section[] }) => {
|
||||
this.showItem(data.item);
|
||||
this.sections = data.sections;
|
||||
});
|
||||
this.route.data.subscribe((data: { item: Table; sections: Section[] }) => {
|
||||
this.showItem(data.item);
|
||||
this.sections = data.sections;
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: Table) {
|
||||
@ -54,7 +53,7 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
|
||||
name: this.item.name,
|
||||
seats: this.item.seats,
|
||||
section: this.item.section.id ? this.item.section.id : '',
|
||||
isActive: this.item.isActive
|
||||
isActive: this.item.isActive,
|
||||
});
|
||||
}
|
||||
|
||||
@ -65,35 +64,33 @@ export class TableDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/tables');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/tables');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/tables');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/tables');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Account?', content: 'Are you sure? This cannot be undone.'}
|
||||
data: { title: 'Delete Account?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {TableListResolver} from './table-list-resolver.service';
|
||||
import { TableListResolver } from './table-list-resolver.service';
|
||||
|
||||
describe('TableListResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TableListResolver]
|
||||
providers: [TableListResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Table} from '../core/table';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {TableService} from './table.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Table } from '../core/table';
|
||||
|
||||
import { TableService } from './table.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TableListResolver implements Resolve<Table[]> {
|
||||
constructor(private ser: TableService) {}
|
||||
|
||||
constructor(private ser: TableService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Table[]> {
|
||||
resolve(): Observable<Table[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
import { Table } from '../../core/table';
|
||||
|
||||
export class TableListDataSource extends DataSource<Table> {
|
||||
@ -9,7 +10,9 @@ export class TableListDataSource extends DataSource<Table> {
|
||||
constructor(private readonly dataObs: Observable<Table[]>) {
|
||||
super();
|
||||
this.dataObs = dataObs.pipe(
|
||||
tap(x => this.data = x)
|
||||
tap((x) => {
|
||||
this.data = x;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@ -17,6 +20,5 @@ export class TableListDataSource extends DataSource<Table> {
|
||||
return this.dataObs;
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
}
|
||||
|
||||
@ -1,43 +1,53 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Tables</mat-card-title>
|
||||
<button mat-button (click)="updateSortOrder()">
|
||||
Update Order
|
||||
</button>
|
||||
<button mat-button (click)="updateSortOrder()">Update Order</button>
|
||||
<a mat-button [routerLink]="['/tables', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<mat-table #table cdkDropList [dataSource]="dataSource" [cdkDropListData]="dataSource" aria-label="Elements" (cdkDropListDropped)="dropTable($event)">
|
||||
|
||||
<mat-table
|
||||
#table
|
||||
cdkDropList
|
||||
[dataSource]="dataSource"
|
||||
[cdkDropListData]="dataSource"
|
||||
aria-label="Elements"
|
||||
(cdkDropListDropped)="dropTable($event)"
|
||||
>
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/tables', row.id]">{{row.name}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="['/tables', row.id]">{{ row.name }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Seats Column -->
|
||||
<ng-container matColumnDef="seats">
|
||||
<mat-header-cell *matHeaderCellDef>Seats</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.seats}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.seats }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Section Column -->
|
||||
<ng-container matColumnDef="section">
|
||||
<mat-header-cell *matHeaderCellDef>Section</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.section.name}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.section.name }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Active Column -->
|
||||
<ng-container matColumnDef="isActive">
|
||||
<mat-header-cell *matHeaderCellDef>Is Active?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.isActive}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.isActive }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;" cdkDrag [cdkDragData]="row"></mat-row>
|
||||
<mat-row
|
||||
*matRowDef="let row; columns: displayedColumns"
|
||||
cdkDrag
|
||||
[cdkDragData]="row"
|
||||
></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {TableListComponent} from './table-list.component';
|
||||
import { TableListComponent } from './table-list.component';
|
||||
|
||||
describe('TableListComponent', () => {
|
||||
let component: TableListComponent;
|
||||
@ -8,9 +8,8 @@ describe('TableListComponent', () => {
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TableListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [TableListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TableListComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { TableListDataSource } from './table-list-datasource';
|
||||
import { Table } from '../../core/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatTable } from '@angular/material/table';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
import { Table } from '../../core/table';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { TableService } from '../table.service';
|
||||
|
||||
import { TableListDataSource } from './table-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-table-list',
|
||||
templateUrl: './table-list.component.html',
|
||||
styleUrls: ['./table-list.component.css']
|
||||
styleUrls: ['./table-list.component.css'],
|
||||
})
|
||||
export class TableListComponent implements OnInit {
|
||||
@ViewChild('table', { static: true }) table: MatTable<MenuCategory>;
|
||||
@ -26,7 +28,7 @@ export class TableListComponent implements OnInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private ser: TableService
|
||||
private ser: TableService,
|
||||
) {
|
||||
this.data = new BehaviorSubject([]);
|
||||
this.data.subscribe((data: Table[]) => {
|
||||
@ -35,23 +37,21 @@ export class TableListComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Table[] }) => {
|
||||
this.data.next(data.list);
|
||||
});
|
||||
this.route.data.subscribe((data: { list: Table[] }) => {
|
||||
this.data.next(data.list);
|
||||
});
|
||||
this.dataSource = new TableListDataSource(this.data);
|
||||
}
|
||||
|
||||
updateSortOrder() {
|
||||
this.ser.updateSortOrder(this.list)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.updateSortOrder(this.list).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
dropTable(event: CdkDragDrop<TableListDataSource>) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {TableResolver} from './table-resolver.service';
|
||||
import { TableResolver } from './table-resolver.service';
|
||||
|
||||
describe('TableResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TableResolver]
|
||||
providers: [TableResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {TableService} from './table.service';
|
||||
import {Table} from '../core/table';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { Table } from '../core/table';
|
||||
|
||||
import { TableService } from './table.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TableResolver implements Resolve<Table> {
|
||||
constructor(private ser: TableService) {}
|
||||
|
||||
constructor(private ser: TableService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Table> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Table> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {TableService} from './table.service';
|
||||
import { TableService } from './table.service';
|
||||
|
||||
describe('TableService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [TableService]
|
||||
providers: [TableService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,78 +1,84 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { Table } from '../core/table';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
const url = '/api/tables';
|
||||
const serviceName = 'TableService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class TableService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(id: string): Observable<Table> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
return <Observable<Table>>this.http.get<Table>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
);
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
return <Observable<Table>>(
|
||||
this.http
|
||||
.get<Table>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
}
|
||||
|
||||
list(): Observable<Table[]> {
|
||||
return <Observable<Table[]>>this.http.get<Table[]>(`${url}/list`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
return <Observable<Table[]>>(
|
||||
this.http
|
||||
.get<Table[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
running(): Observable<Table[]> {
|
||||
return <Observable<Table[]>>this.http.get<Table[]>(`${url}/running`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'running'))
|
||||
);
|
||||
return <Observable<Table[]>>(
|
||||
this.http
|
||||
.get<Table[]>(`${url}/running`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'running')))
|
||||
);
|
||||
}
|
||||
|
||||
save(tables: Table): Observable<Table> {
|
||||
return <Observable<Table>>this.http.post<Table>(url, tables, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
return <Observable<Table>>(
|
||||
this.http
|
||||
.post<Table>(url, tables, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
}
|
||||
|
||||
update(tables: Table): Observable<Table> {
|
||||
return <Observable<Table>>this.http.put<Table>(`${url}/${tables.id}`, tables, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'update'))
|
||||
);
|
||||
return <Observable<Table>>(
|
||||
this.http
|
||||
.put<Table>(`${url}/${tables.id}`, tables, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
}
|
||||
|
||||
updateSortOrder(list: Table[]): Observable<boolean> {
|
||||
return <Observable<boolean>>this.http.post<Table[]>(`${url}/list`, list, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'updateSortOrder'))
|
||||
);
|
||||
return <Observable<boolean>>(
|
||||
this.http
|
||||
.post<Table[]>(`${url}/list`, list, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'updateSortOrder')))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(tables: Table): Observable<Table> {
|
||||
if (!tables.id) {
|
||||
return this.save(tables);
|
||||
} else {
|
||||
return this.update(tables);
|
||||
}
|
||||
return this.update(tables);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Table> {
|
||||
return <Observable<Table>>this.http.delete<Table>(`${url}/${id}`, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'delete'))
|
||||
);
|
||||
return <Observable<Table>>(
|
||||
this.http
|
||||
.delete<Table>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {TableRoutingModule} from './tables-routing.module';
|
||||
import { TableRoutingModule } from './tables-routing.module';
|
||||
|
||||
describe('TableRoutingModule', () => {
|
||||
let tablesRoutingModule: TableRoutingModule;
|
||||
|
||||
@ -1,64 +1,56 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { TableListResolver } from './table-list-resolver.service';
|
||||
import { TableResolver } from './table-resolver.service';
|
||||
import { TableListComponent } from './table-list/table-list.component';
|
||||
import { TableDetailComponent } from './table-detail/table-detail.component';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { SectionListResolver } from '../sections/section-list-resolver.service';
|
||||
|
||||
import { TableDetailComponent } from './table-detail/table-detail.component';
|
||||
import { TableListResolver } from './table-list-resolver.service';
|
||||
import { TableListComponent } from './table-list/table-list.component';
|
||||
import { TableResolver } from './table-resolver.service';
|
||||
|
||||
const tablesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: TableListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tables'
|
||||
permission: 'Tables',
|
||||
},
|
||||
resolve: {
|
||||
list: TableListResolver
|
||||
}
|
||||
list: TableListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: TableDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tables'
|
||||
permission: 'Tables',
|
||||
},
|
||||
resolve: {
|
||||
item: TableResolver,
|
||||
sections: SectionListResolver
|
||||
}
|
||||
sections: SectionListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: TableDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tables'
|
||||
permission: 'Tables',
|
||||
},
|
||||
resolve: {
|
||||
item: TableResolver,
|
||||
sections: SectionListResolver
|
||||
}
|
||||
}
|
||||
sections: SectionListResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(tablesRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
TableListResolver,
|
||||
TableResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(tablesRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [TableListResolver, TableResolver],
|
||||
})
|
||||
export class TableRoutingModule {
|
||||
}
|
||||
export class TableRoutingModule {}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {TableModule} from './tables.module';
|
||||
import { TableModule } from './tables.module';
|
||||
|
||||
describe('TableModule', () => {
|
||||
let tablesModule: TableModule;
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
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';
|
||||
import { MatOptionModule } from '@angular/material/core';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatOptionModule } from '@angular/material/core';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { TableListComponent } from './table-list/table-list.component';
|
||||
|
||||
import { TableDetailComponent } from './table-detail/table-detail.component';
|
||||
import { TableListComponent } from './table-list/table-list.component';
|
||||
import { TableRoutingModule } from './tables-routing.module';
|
||||
|
||||
@NgModule({
|
||||
@ -33,12 +34,8 @@ import { TableRoutingModule } from './tables-routing.module';
|
||||
MatSelectModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
TableRoutingModule
|
||||
TableRoutingModule,
|
||||
],
|
||||
declarations: [
|
||||
TableListComponent,
|
||||
TableDetailComponent
|
||||
]
|
||||
declarations: [TableListComponent, TableDetailComponent],
|
||||
})
|
||||
export class TableModule {
|
||||
}
|
||||
export class TableModule {}
|
||||
|
||||
Reference in New Issue
Block a user