Moved from tslint to eslint as tslint was depreciated.

Added prettier and also prettied all the typescript files using prettier

ESLint is using the AirBnB rules which are the most strict to lint the files.
This commit is contained in:
tanshu committed 2020-10-01 21:28:12 +05:30
1 parent 40e79ff949
commit 1350870f9e
545 files changed
+8455 -7036

No files matched your search

@@ -5,11 +5,22 @@
</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>
</form>
@@ -1,6 +1,6 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {CostCentreDetailComponent} from './cost-centre-detail.component';
import { CostCentreDetailComponent } from './cost-centre-detail.component';
describe('CostCentreDetailComponent', () => {
let component: CostCentreDetailComponent;
@@ -8,9 +8,8 @@ describe('CostCentreDetailComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CostCentreDetailComponent]
})
.compileComponents();
declarations: [CostCentreDetailComponent],
}).compileComponents();
}));
beforeEach(() => {
@@ -1,15 +1,15 @@
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import {CostCentreService} from '../cost-centre.service';
import {CostCentre} from '../../core/cost-centre';
import {ActivatedRoute, Router} from '@angular/router';
import {ToasterService} from '../../core/toaster.service';
import {FormBuilder, FormGroup} from '@angular/forms';
import { CostCentreService } from '../cost-centre.service';
import { CostCentre } from '../../core/cost-centre';
import { ActivatedRoute, Router } from '@angular/router';
import { ToasterService } from '../../core/toaster.service';
import { FormBuilder, FormGroup } from '@angular/forms';
@Component({
selector: 'app-cost-centre-detail',
templateUrl: './cost-centre-detail.component.html',
styleUrls: ['./cost-centre-detail.component.css']
styleUrls: ['./cost-centre-detail.component.css'],
})
export class CostCentreDetailComponent implements OnInit, AfterViewInit {
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
@@ -21,22 +21,21 @@ export class CostCentreDetailComponent implements OnInit, AfterViewInit {
private router: Router,
private fb: FormBuilder,
private toaster: ToasterService,
private ser: CostCentreService
private ser: CostCentreService,
) {
this.createForm();
}
createForm() {
this.form = this.fb.group({
name: ''
name: '',
});
}
ngOnInit() {
this.route.data
.subscribe((data: { item: CostCentre }) => {
this.showItem(data.item);
});
this.route.data.subscribe((data: { item: CostCentre }) => {
this.showItem(data.item);
});
}
showItem(item: CostCentre) {
@@ -53,16 +52,15 @@ export class CostCentreDetailComponent implements OnInit, AfterViewInit {
}
save() {
this.ser.saveOrUpdate(this.getItem())
.subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/cost-centres');
},
(error) => {
this.toaster.show('Danger', error);
}
);
this.ser.saveOrUpdate(this.getItem()).subscribe(
(result) => {
this.toaster.show('Success', '');
this.router.navigateByUrl('/cost-centres');
},
(error) => {
this.toaster.show('Danger', error);
},
);
}
getItem(): CostCentre {
@@ -1,15 +1,18 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {CostCentreListResolverService} from './cost-centre-list-resolver.service';
import { CostCentreListResolverService } from './cost-centre-list-resolver.service';
describe('CostCentreListResolverService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CostCentreListResolverService]
providers: [CostCentreListResolverService],
});
});
it('should be created', inject([CostCentreListResolverService], (service: CostCentreListResolverService) => {
expect(service).toBeTruthy();
}));
it('should be created', inject(
[CostCentreListResolverService],
(service: CostCentreListResolverService) => {
expect(service).toBeTruthy();
},
));
});
@@ -1,16 +1,14 @@
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
import {CostCentre} from '../core/cost-centre';
import {Observable} from 'rxjs/internal/Observable';
import {CostCentreService} from './cost-centre.service';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
import { CostCentre } from '../core/cost-centre';
import { Observable } from 'rxjs/internal/Observable';
import { CostCentreService } from './cost-centre.service';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class CostCentreListResolver implements Resolve<CostCentre[]> {
constructor(private ser: CostCentreService, private router: Router) {
}
constructor(private ser: CostCentreService, private router: Router) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CostCentre[]> {
return this.ser.list();
@@ -1,33 +1,29 @@
import {DataSource} from '@angular/cdk/collections';
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 {CostCentre} from '../../core/cost-centre';
import { map } from 'rxjs/operators';
import { merge, Observable, of as observableOf } from 'rxjs';
import { CostCentre } from '../../core/cost-centre';
export class CostCentreListDataSource extends DataSource<CostCentre> {
constructor(private paginator: MatPaginator, private sort: MatSort, public data: CostCentre[]) {
super();
}
connect(): Observable<CostCentre[]> {
const dataMutations = [
observableOf(this.data),
this.paginator.page,
this.sort.sortChange
];
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]));
}));
return merge(...dataMutations).pipe(
map(() => {
return this.getPagedData(this.getSortedData([...this.data]));
}),
);
}
disconnect() {
}
disconnect() {}
private getPagedData(data: CostCentre[]) {
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
@@ -8,28 +8,31 @@
</mat-card-title-group>
<mat-card-content>
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell *matCellDef="let row"><a [routerLink]="['/cost-centres', row.id]">{{row.name}}</a></mat-cell>
<mat-cell *matCellDef="let row"
><a [routerLink]="['/cost-centres', row.id]">{{ row.name }}</a></mat-cell
>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="isFixture">
<mat-header-cell *matHeaderCellDef mat-sort-header>Is Fixture?</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.isFixture}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.isFixture }}</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-paginator #paginator
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250]">
<mat-paginator
#paginator
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250]"
>
</mat-paginator>
</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 {CostCentreListComponent} from './cost-centre-list.component';
import { CostCentreListComponent } from './cost-centre-list.component';
describe('CostCentreListComponent', () => {
let component: CostCentreListComponent;
@@ -8,9 +8,8 @@ describe('CostCentreListComponent', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
declarations: [CostCentreListComponent]
})
.compileComponents();
declarations: [CostCentreListComponent],
}).compileComponents();
fixture = TestBed.createComponent(CostCentreListComponent);
component = fixture.componentInstance;
@@ -1,14 +1,14 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import {CostCentreListDataSource} from './cost-centre-list-datasource';
import {CostCentre} from '../../core/cost-centre';
import {ActivatedRoute} from '@angular/router';
import { CostCentreListDataSource } from './cost-centre-list-datasource';
import { CostCentre } from '../../core/cost-centre';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-cost-centre-list',
templateUrl: './cost-centre-list.component.html',
styleUrls: ['./cost-centre-list.component.css']
styleUrls: ['./cost-centre-list.component.css'],
})
export class CostCentreListComponent implements OnInit {
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@@ -18,14 +18,12 @@ export class CostCentreListComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'isFixture'];
constructor(private route: ActivatedRoute) {
}
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.data
.subscribe((data: { list: CostCentre[] }) => {
this.list = data.list;
});
this.route.data.subscribe((data: { list: CostCentre[] }) => {
this.list = data.list;
});
this.dataSource = new CostCentreListDataSource(this.paginator, this.sort, this.list);
}
}
@@ -1,15 +1,18 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {CostCentreResolverService} from './cost-centre-resolver.service';
import { CostCentreResolverService } from './cost-centre-resolver.service';
describe('CostCentreResolverService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CostCentreDetailResolverService]
providers: [CostCentreDetailResolverService],
});
});
it('should be created', inject([CostCentreDetailResolverService], (service: CostCentreDetailResolverService) => {
expect(service).toBeTruthy();
}));
it('should be created', inject(
[CostCentreDetailResolverService],
(service: CostCentreDetailResolverService) => {
expect(service).toBeTruthy();
},
));
});
@@ -1,16 +1,14 @@
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
import {CostCentreService} from './cost-centre.service';
import {CostCentre} from '../core/cost-centre';
import {Observable} from 'rxjs/internal/Observable';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
import { CostCentreService } from './cost-centre.service';
import { CostCentre } from '../core/cost-centre';
import { Observable } from 'rxjs/internal/Observable';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class CostCentreResolver implements Resolve<CostCentre> {
constructor(private ser: CostCentreService, private router: Router) {
}
constructor(private ser: CostCentreService, private router: Router) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<CostCentre> {
const id = route.paramMap.get('id');
@@ -1,4 +1,4 @@
import {CostCentreRoutingModule} from './cost-centre-routing.module';
import { CostCentreRoutingModule } from './cost-centre-routing.module';
describe('CostCentreRoutingModule', () => {
let costCentreRoutingModule: CostCentreRoutingModule;
@@ -1,11 +1,11 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from '@angular/router';
import {CostCentreListResolver} from './cost-centre-list-resolver.service';
import {CostCentreResolver} from './cost-centre-resolver.service';
import {CostCentreListComponent} from './cost-centre-list/cost-centre-list.component';
import {CostCentreDetailComponent} from './cost-centre-detail/cost-centre-detail.component';
import {AuthGuard} from '../auth/auth-guard.service';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { CostCentreListResolver } from './cost-centre-list-resolver.service';
import { CostCentreResolver } from './cost-centre-resolver.service';
import { CostCentreListComponent } from './cost-centre-list/cost-centre-list.component';
import { CostCentreDetailComponent } from './cost-centre-detail/cost-centre-detail.component';
import { AuthGuard } from '../auth/auth-guard.service';
const costCentreRoutes: Routes = [
{
@@ -13,49 +13,39 @@ const costCentreRoutes: Routes = [
component: CostCentreListComponent,
canActivate: [AuthGuard],
data: {
permission: 'Cost Centres'
permission: 'Cost Centres',
},
resolve: {
list: CostCentreListResolver
}
list: CostCentreListResolver,
},
},
{
path: 'new',
component: CostCentreDetailComponent,
canActivate: [AuthGuard],
data: {
permission: 'Cost Centres'
permission: 'Cost Centres',
},
resolve: {
item: CostCentreResolver
}
item: CostCentreResolver,
},
},
{
path: ':id',
component: CostCentreDetailComponent,
canActivate: [AuthGuard],
data: {
permission: 'Cost Centres'
permission: 'Cost Centres',
},
resolve: {
item: CostCentreResolver
}
}
item: CostCentreResolver,
},
},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(costCentreRoutes)
],
exports: [
RouterModule
],
providers: [
CostCentreListResolver,
CostCentreResolver
]
imports: [CommonModule, RouterModule.forChild(costCentreRoutes)],
exports: [RouterModule],
providers: [CostCentreListResolver, CostCentreResolver],
})
export class CostCentreRoutingModule {
}
export class CostCentreRoutingModule {}
@@ -1,4 +1,4 @@
import {CostCentreModule} from './cost-centre.module';
import { CostCentreModule } from './cost-centre.module';
describe('CostCentreModule', () => {
let costCentreModule: CostCentreModule;
@@ -1,9 +1,9 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {CostCentreListComponent} from './cost-centre-list/cost-centre-list.component';
import {CostCentreDetailComponent} from './cost-centre-detail/cost-centre-detail.component';
import {CostCentreRoutingModule} from './cost-centre-routing.module';
import { CostCentreListComponent } from './cost-centre-list/cost-centre-list.component';
import { CostCentreDetailComponent } from './cost-centre-detail/cost-centre-detail.component';
import { CostCentreRoutingModule } from './cost-centre-routing.module';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
@@ -12,9 +12,9 @@ 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 {FlexLayoutModule} from '@angular/flex-layout';
import { CdkTableModule } from '@angular/cdk/table';
import { ReactiveFormsModule } from '@angular/forms';
import { FlexLayoutModule } from '@angular/flex-layout';
@NgModule({
imports: [
@@ -30,12 +30,8 @@ import {FlexLayoutModule} from '@angular/flex-layout';
MatSortModule,
MatTableModule,
ReactiveFormsModule,
CostCentreRoutingModule
CostCentreRoutingModule,
],
declarations: [
CostCentreListComponent,
CostCentreDetailComponent
]
declarations: [CostCentreListComponent, CostCentreDetailComponent],
})
export class CostCentreModule {
}
export class CostCentreModule {}
@@ -1,11 +1,11 @@
import {inject, TestBed} from '@angular/core/testing';
import { inject, TestBed } from '@angular/core/testing';
import {CostCentreService} from './cost-centre.service';
import { CostCentreService } from './cost-centre.service';
describe('CostCentreService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [CostCentreService]
providers: [CostCentreService],
});
});
@@ -1,50 +1,53 @@
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 {CostCentre} from '../core/cost-centre';
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 { CostCentre } from '../core/cost-centre';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/cost-centres';
const serviceName = 'CostCentreService';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class CostCentreService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(id: string): Observable<CostCentre> {
const getUrl: string = (id === null) ? `${url}` : `${url}/${id}`;
return <Observable<CostCentre>>this.http.get<CostCentre>(getUrl)
.pipe(
catchError(this.log.handleError(serviceName, `get id=${id}`))
);
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
return <Observable<CostCentre>>(
this.http
.get<CostCentre>(getUrl)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
);
}
list(): Observable<CostCentre[]> {
return <Observable<CostCentre[]>>this.http.get<CostCentre[]>(`${url}/list`)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
return <Observable<CostCentre[]>>(
this.http
.get<CostCentre[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list')))
);
}
save(costCentre: CostCentre): Observable<CostCentre> {
return <Observable<CostCentre>>this.http.post<CostCentre>(`${url}`, costCentre, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'save'))
);
return <Observable<CostCentre>>(
this.http
.post<CostCentre>(`${url}`, costCentre, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'save')))
);
}
update(costCentre: CostCentre): Observable<CostCentre> {
return <Observable<CostCentre>>this.http.put<CostCentre>(`${url}/${costCentre.id}`, costCentre, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'update'))
);
return <Observable<CostCentre>>(
this.http
.put<CostCentre>(`${url}/${costCentre.id}`, costCentre, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update')))
);
}
saveOrUpdate(costCentre: CostCentre): Observable<CostCentre> {
@@ -56,9 +59,10 @@ export class CostCentreService {
}
delete(id: string): Observable<CostCentre> {
return <Observable<CostCentre>>this.http.delete<CostCentre>(`${url}/${id}`, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'delete'))
);
return <Observable<CostCentre>>(
this.http
.delete<CostCentre>(`${url}/${id}`, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
);
}
}