Blacked and isorted the python files

Prettied and eslinted the typescript/html files
This commit is contained in:
2020-10-11 10:56:29 +05:30
parent b31db593c2
commit d677cfb1ea
505 changed files with 7560 additions and 5650 deletions

View File

@ -5,29 +5,41 @@
</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">
<input matInput #nameElement placeholder="Name" formControlName="name" />
</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>Address</mat-label>
<input matInput placeholder="Address" formControlName="address">
<input matInput placeholder="Address" formControlName="address" />
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Cut Code</mat-label>
<input matInput placeholder="Cut code" formControlName="cutCode">
<input matInput placeholder="Cut code" formControlName="cutCode" />
</mat-form-field>
</div>
</form>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button color="primary" (click)="save()">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>

View File

@ -1,6 +1,6 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {PrinterDetailComponent} from './printer-detail.component';
import { PrinterDetailComponent } from './printer-detail.component';
describe('PrinterDetailComponent', () => {
let component: PrinterDetailComponent;
@ -8,9 +8,8 @@ describe('PrinterDetailComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [PrinterDetailComponent]
})
.compileComponents();
declarations: [PrinterDetailComponent],
}).compileComponents();
}));
beforeEach(() => {

View File

@ -1,17 +1,17 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { PrinterService } from '../printer.service';
import { Printer } from '../../core/printer';
import { ToasterService } from '../../core/toaster.service';
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
import { PrinterService } from '../printer.service';
@Component({
selector: 'app-printer-detail',
templateUrl: './printer-detail.component.html',
styleUrls: ['./printer-detail.component.css']
styleUrls: ['./printer-detail.component.css'],
})
export class PrinterDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
@ -24,7 +24,7 @@ export class PrinterDetailComponent implements OnInit, AfterViewInit {
private dialog: MatDialog,
private fb: FormBuilder,
private toaster: ToasterService,
private ser: PrinterService
private ser: PrinterService,
) {
this.createForm();
}
@ -33,15 +33,14 @@ export class PrinterDetailComponent implements OnInit, AfterViewInit {
this.form = this.fb.group({
name: '',
address: '',
cutCode: ''
cutCode: '',
});
}
ngOnInit() {
this.route.data
.subscribe((data: { item: Printer }) => {
this.showItem(data.item);
});
this.route.data.subscribe((data: { item: Printer }) => {
this.showItem(data.item);
});
}
showItem(item: Printer) {
@ -49,7 +48,7 @@ export class PrinterDetailComponent implements OnInit, AfterViewInit {
this.form.setValue({
name: this.item.name || '',
address: this.item.address || '',
cutCode: this.item.cutCode || ''
cutCode: this.item.cutCode || '',
});
}
@ -60,35 +59,33 @@ export class PrinterDetailComponent implements OnInit, AfterViewInit {
}
save() {
this.ser.saveOrUpdate(this.getItem())
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/printers');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
this.ser.saveOrUpdate(this.getItem()).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/printers');
},
(error) => {
this.toaster.show('Danger', error.error);
},
);
}
delete() {
this.ser.delete(this.item.id)
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/printers');
},
(error) => {
this.toaster.show('Danger', error.error);
}
);
this.ser.delete(this.item.id).subscribe(
() => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/printers');
},
(error) => {
this.toaster.show('Danger', error.error);
},
);
}
confirmDelete(): void {
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
width: '250px',
data: {title: 'Delete Printer?', content: 'Are you sure? This cannot be undone.'}
data: { title: 'Delete Printer?', content: 'Are you sure? This cannot be undone.' },
});
dialogRef.afterClosed().subscribe((result: boolean) => {

View File

@ -1,11 +1,11 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {PrinterListResolver} from './printer-list-resolver.service';
import { PrinterListResolver } from './printer-list-resolver.service';
describe('PrinterListResolverService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [PrinterListResolver]
providers: [PrinterListResolver],
});
});

View File

@ -1,18 +1,18 @@
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
import {Printer} from '../core/printer';
import {Observable} from 'rxjs/internal/Observable';
import {PrinterService} from './printer.service';
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { Printer } from '../core/printer';
import { PrinterService } from './printer.service';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class PrinterListResolver implements Resolve<Printer[]> {
constructor(private ser: PrinterService) {}
constructor(private ser: PrinterService, private router: Router) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Printer[]> {
resolve(): Observable<Printer[]> {
return this.ser.list();
}
}

View File

@ -1,9 +1,9 @@
import {DataSource} from '@angular/cdk/collections';
import {Observable, of as observableOf} from 'rxjs';
import {Printer} from '../../core/printer';
import { DataSource } from '@angular/cdk/collections';
import { Observable, of as observableOf } from 'rxjs';
import { Printer } from '../../core/printer';
export class PrinterListDataSource extends DataSource<Printer> {
constructor(public data: Printer[]) {
super();
}
@ -12,6 +12,5 @@ export class PrinterListDataSource extends DataSource<Printer> {
return observableOf(this.data);
}
disconnect() {
}
disconnect() {}
}

View File

@ -8,28 +8,28 @@
</mat-card-title-group>
<mat-card-content>
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
<mat-cell *matCellDef="let row"><a [routerLink]="['/printers', row.id]">{{row.name}}</a></mat-cell>
<mat-cell *matCellDef="let row"
><a [routerLink]="['/printers', row.id]">{{ row.name }}</a></mat-cell
>
</ng-container>
<!-- Address Column -->
<ng-container matColumnDef="address">
<mat-header-cell *matHeaderCellDef>Address</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.address}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.address }}</mat-cell>
</ng-container>
<!-- Cut Code Column -->
<ng-container matColumnDef="cutCode">
<mat-header-cell *matHeaderCellDef>Cut Code</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.cutCode}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.cutCode }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
</mat-table>
</mat-card-content>
</mat-card>

View File

@ -1,6 +1,6 @@
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import {PrinterListComponent} from './printer-list.component';
import { PrinterListComponent } from './printer-list.component';
describe('PrinterListComponent', () => {
let component: PrinterListComponent;
@ -8,9 +8,8 @@ describe('PrinterListComponent', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
declarations: [PrinterListComponent]
})
.compileComponents();
declarations: [PrinterListComponent],
}).compileComponents();
fixture = TestBed.createComponent(PrinterListComponent);
component = fixture.componentInstance;

View File

@ -1,12 +1,14 @@
import { Component, OnInit } from '@angular/core';
import { PrinterListDataSource } from './printer-list-datasource';
import { Printer } from '../../core/printer';
import { ActivatedRoute } from '@angular/router';
import { Printer } from '../../core/printer';
import { PrinterListDataSource } from './printer-list-datasource';
@Component({
selector: 'app-printer-list',
templateUrl: './printer-list.component.html',
styleUrls: ['./printer-list.component.css']
styleUrls: ['./printer-list.component.css'],
})
export class PrinterListComponent implements OnInit {
dataSource: PrinterListDataSource;
@ -14,14 +16,12 @@ export class PrinterListComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'address', 'cutCode'];
constructor(private route: ActivatedRoute) {
}
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.data
.subscribe((data: { list: Printer[] }) => {
this.list = data.list;
});
this.route.data.subscribe((data: { list: Printer[] }) => {
this.list = data.list;
});
this.dataSource = new PrinterListDataSource(this.list);
}
}

View File

@ -1,11 +1,11 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {PrinterResolver} from './printer-resolver.service';
import { PrinterResolver } from './printer-resolver.service';
describe('PrinterResolver', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [PrinterResolver]
providers: [PrinterResolver],
});
});

View File

@ -1,18 +1,18 @@
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
import {PrinterService} from './printer.service';
import {Printer} from '../core/printer';
import {Observable} from 'rxjs/internal/Observable';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { Printer } from '../core/printer';
import { PrinterService } from './printer.service';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class PrinterResolver implements Resolve<Printer> {
constructor(private ser: PrinterService) {}
constructor(private ser: PrinterService, private router: Router) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Printer> {
resolve(route: ActivatedRouteSnapshot): Observable<Printer> {
const id = route.paramMap.get('id');
return this.ser.get(id);
}

View File

@ -1,11 +1,11 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {PrinterService} from './printer.service';
import { PrinterService } from './printer.service';
describe('PrinterService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [PrinterService]
providers: [PrinterService],
});
});

View File

@ -1,64 +1,68 @@
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 { Printer } from '../core/printer';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/printers';
const serviceName = 'PrinterService';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class PrinterService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(id: string): Observable<Printer> {
const getUrl: string = (id === null) ? url : `${url}/${id}`;
return <Observable<Printer>>this.http.get<Printer>(getUrl)
.pipe(
catchError(this.log.handleError(serviceName, `get id=${id}`))
);
const getUrl: string = id === null ? url : `${url}/${id}`;
return <Observable<Printer>>(
this.http
.get<Printer>(getUrl)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
);
}
list(): Observable<Printer[]> {
return <Observable<Printer[]>>this.http.get<Printer[]>(`${url}/list`)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
return <Observable<Printer[]>>(
this.http
.get<Printer[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
}
save(printer: Printer): Observable<Printer> {
return <Observable<Printer>>this.http.post<Printer>(url, printer, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'save'))
);
return <Observable<Printer>>(
this.http
.post<Printer>(url, printer, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'save')))
);
}
update(printer: Printer): Observable<Printer> {
return <Observable<Printer>>this.http.put<Printer>(`${url}/${printer.id}`, printer, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'update'))
);
return <Observable<Printer>>(
this.http
.put<Printer>(`${url}/${printer.id}`, printer, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update')))
);
}
saveOrUpdate(printer: Printer): Observable<Printer> {
if (!printer.id) {
return this.save(printer);
} else {
return this.update(printer);
}
return this.update(printer);
}
delete(id: string): Observable<Printer> {
return <Observable<Printer>>this.http.delete<Printer>(`${url}/${id}`, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'delete'))
);
return <Observable<Printer>>(
this.http
.delete<Printer>(`${url}/${id}`, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
);
}
}

View File

@ -1,4 +1,4 @@
import {PrintersRoutingModule} from './printers-routing.module';
import { PrintersRoutingModule } from './printers-routing.module';
describe('PrintersRoutingModule', () => {
let printersRoutingModule: PrintersRoutingModule;

View File

@ -1,11 +1,13 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from '@angular/router';
import {PrinterListResolver} from './printer-list-resolver.service';
import {PrinterResolver} from './printer-resolver.service';
import {PrinterListComponent} from './printer-list/printer-list.component';
import {PrinterDetailComponent} from './printer-detail/printer-detail.component';
import {AuthGuard} from '../auth/auth-guard.service';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '../auth/auth-guard.service';
import { PrinterDetailComponent } from './printer-detail/printer-detail.component';
import { PrinterListResolver } from './printer-list-resolver.service';
import { PrinterListComponent } from './printer-list/printer-list.component';
import { PrinterResolver } from './printer-resolver.service';
const printersRoutes: Routes = [
{
@ -13,49 +15,39 @@ const printersRoutes: Routes = [
component: PrinterListComponent,
canActivate: [AuthGuard],
data: {
permission: 'Printers'
permission: 'Printers',
},
resolve: {
list: PrinterListResolver
}
list: PrinterListResolver,
},
},
{
path: 'new',
component: PrinterDetailComponent,
canActivate: [AuthGuard],
data: {
permission: 'Printers'
permission: 'Printers',
},
resolve: {
item: PrinterResolver
}
item: PrinterResolver,
},
},
{
path: ':id',
component: PrinterDetailComponent,
canActivate: [AuthGuard],
data: {
permission: 'Printers'
permission: 'Printers',
},
resolve: {
item: PrinterResolver
}
}
item: PrinterResolver,
},
},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(printersRoutes)
],
exports: [
RouterModule
],
providers: [
PrinterListResolver,
PrinterResolver
]
imports: [CommonModule, RouterModule.forChild(printersRoutes)],
exports: [RouterModule],
providers: [PrinterListResolver, PrinterResolver],
})
export class PrintersRoutingModule {
}
export class PrintersRoutingModule {}

View File

@ -1,4 +1,4 @@
import {PrintersModule} from './printers.module';
import { PrintersModule } from './printers.module';
describe('PrintersModule', () => {
let printersModule: PrintersModule;

View File

@ -1,18 +1,18 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {PrinterListComponent} from './printer-list/printer-list.component';
import {PrinterDetailComponent} from './printer-detail/printer-detail.component';
import {PrintersRoutingModule} from './printers-routing.module';
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 { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTableModule } from '@angular/material/table';
import {CdkTableModule} from '@angular/cdk/table';
import {ReactiveFormsModule} from '@angular/forms';
import {FlexLayoutModule} from '@angular/flex-layout';
import { PrinterDetailComponent } from './printer-detail/printer-detail.component';
import { PrinterListComponent } from './printer-list/printer-list.component';
import { PrintersRoutingModule } from './printers-routing.module';
@NgModule({
imports: [
@ -26,12 +26,8 @@ import {FlexLayoutModule} from '@angular/flex-layout';
MatProgressSpinnerModule,
MatTableModule,
ReactiveFormsModule,
PrintersRoutingModule
PrintersRoutingModule,
],
declarations: [
PrinterListComponent,
PrinterDetailComponent
]
declarations: [PrinterListComponent, PrinterDetailComponent],
})
export class PrintersModule {
}
export class PrintersModule {}