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

@ -1,10 +1,9 @@
import { DataSource } from '@angular/cdk/collections';
import { Observable, of as observableOf } from 'rxjs';
import { SaleReportItem } from './sale-report';
import { SaleReportItem } from './sale-report-item';
export class SaleReportDatasource extends DataSource<SaleReportItem> {
constructor(public data: SaleReportItem[]) {
super();
}
@ -13,6 +12,5 @@ export class SaleReportDatasource extends DataSource<SaleReportItem> {
return observableOf(this.data);
}
disconnect() {
}
disconnect() {}
}

View File

@ -0,0 +1,4 @@
export class SaleReportItem {
name: string;
amount: number;
}

View File

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

View File

@ -1,18 +1,17 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { Observable } from 'rxjs/internal/Observable';
import { SaleReport } from './sale-report';
import { SaleReportService } from './sale-report.service';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class SaleReportResolver implements Resolve<SaleReport> {
constructor(private ser: SaleReportService) {}
constructor(private ser: SaleReportService) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<SaleReport> {
resolve(route: ActivatedRouteSnapshot): Observable<SaleReport> {
const startDate = route.queryParamMap.get('startDate') || null;
const finishDate = route.queryParamMap.get('finishDate') || null;
return this.ser.get(startDate, finishDate);

View File

@ -1,4 +1,4 @@
import {SaleReportRoutingModule} from './sale-report-routing.module';
import { SaleReportRoutingModule } from './sale-report-routing.module';
describe('SaleReportRoutingModule', () => {
let saleReportRoutingModule: SaleReportRoutingModule;

View File

@ -1,8 +1,10 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SaleReportResolver } from './sale-report-resolver.service';
import { AuthGuard } from '../auth/auth-guard.service';
import { SaleReportResolver } from './sale-report-resolver.service';
import { SaleReportComponent } from './sale-report.component';
const saleReportRoutes: Routes = [
@ -11,27 +13,18 @@ const saleReportRoutes: Routes = [
component: SaleReportComponent,
canActivate: [AuthGuard],
data: {
permission: 'Sale Report'
permission: 'Sale Report',
},
resolve: {
info: SaleReportResolver
info: SaleReportResolver,
},
runGuardsAndResolvers: 'always'
}
runGuardsAndResolvers: 'always',
},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(saleReportRoutes)
],
exports: [
RouterModule
],
providers: [
SaleReportResolver
]
imports: [CommonModule, RouterModule.forChild(saleReportRoutes)],
exports: [RouterModule],
providers: [SaleReportResolver],
})
export class SaleReportRoutingModule {
}
export class SaleReportRoutingModule {}

View File

@ -7,17 +7,34 @@
</mat-card-title-group>
<mat-card-content>
<form [formGroup]="form" fxLayout="column">
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutGap.lt-md="0px"
fxLayoutAlign="space-around start">
<div
fxLayout="row"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
fxLayoutAlign="space-around start"
>
<mat-form-field fxFlex="40">
<input matInput [matDatepicker]="startDate" (focus)="startDate.open()" placeholder="Start Date"
formControlName="startDate" autocomplete="off">
<input
matInput
[matDatepicker]="startDate"
(focus)="startDate.open()"
placeholder="Start Date"
formControlName="startDate"
autocomplete="off"
/>
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
<mat-datepicker #startDate></mat-datepicker>
</mat-form-field>
<mat-form-field fxFlex="40">
<input matInput [matDatepicker]="finishDate" (focus)="finishDate.open()" placeholder="Finish Date"
formControlName="finishDate" autocomplete="off">
<input
matInput
[matDatepicker]="finishDate"
(focus)="finishDate.open()"
placeholder="Finish Date"
formControlName="finishDate"
autocomplete="off"
/>
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
<mat-datepicker #finishDate></mat-datepicker>
</mat-form-field>
@ -25,20 +42,19 @@
</div>
</form>
<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">{{row.name}}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.name }}</mat-cell>
</ng-container>
<!-- Amount Column -->
<ng-container matColumnDef="amount">
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{row.amount | currency:'INR'}}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency: 'INR' }}</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 {async, ComponentFixture, TestBed} from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {SaleReportComponent} from './sale-report.component';
import { SaleReportComponent } from './sale-report.component';
describe('SaleReportComponent', () => {
let component: SaleReportComponent;
@ -8,9 +8,8 @@ describe('SaleReportComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [SaleReportComponent]
})
.compileComponents();
declarations: [SaleReportComponent],
}).compileComponents();
}));
beforeEach(() => {

View File

@ -2,14 +2,16 @@ import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
import { SaleReportDatasource } from './sale-report-datasource';
import { SaleReport } from './sale-report';
import { ToCsvService } from '../shared/to-csv.service';
import { SaleReport } from './sale-report';
import { SaleReportDatasource } from './sale-report-datasource';
@Component({
selector: 'app-sale-report',
templateUrl: './sale-report.component.html',
styleUrls: ['./sale-report.component.css']
styleUrls: ['./sale-report.component.css'],
})
export class SaleReportComponent implements OnInit {
dataSource: SaleReportDatasource;
@ -19,27 +21,24 @@ export class SaleReportComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'amount'];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private toCsv: ToCsvService
private toCsv: ToCsvService,
) {
this.createForm();
}
ngOnInit() {
this.route.data
.subscribe((data: { info: SaleReport }) => {
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
});
this.dataSource = new SaleReportDatasource(this.info.amounts);
this.route.data.subscribe((data: { info: SaleReport }) => {
this.info = data.info;
this.form.setValue({
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
});
this.dataSource = new SaleReportDatasource(this.info.amounts);
});
}
show() {
@ -47,15 +46,15 @@ export class SaleReportComponent implements OnInit {
this.router.navigate(['sale-report'], {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate
}
finishDate: info.finishDate,
},
});
}
createForm() {
this.form = this.fb.group({
startDate: '',
finishDate: ''
finishDate: '',
});
}
@ -64,16 +63,18 @@ export class SaleReportComponent implements OnInit {
return {
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
};
}
exportCsv() {
const headers = {
Name: 'name',
Amount: 'amount'
Amount: 'amount',
};
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {
type: 'text/csv;charset=utf-8;',
});
const link = document.createElement('a');
link.href = window.URL.createObjectURL(csvData);
link.setAttribute('download', 'sale-report.csv');

View File

@ -1,4 +1,4 @@
import {SaleReportModule} from './sale-report.module';
import { SaleReportModule } from './sale-report.module';
describe('SaleReportModule', () => {
let saleReportModule: SaleReportModule;

View File

@ -1,22 +1,29 @@
import { NgModule } from '@angular/core';
import { A11yModule } from '@angular/cdk/a11y';
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 { MomentDateAdapter } from '@angular/material-moment-adapter';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatNativeDateModule } from '@angular/material/core';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
MatNativeDateModule,
} from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTableModule } from '@angular/material/table';
import { SharedModule} from '../shared/shared.module';
import { ReactiveFormsModule } from '@angular/forms';
import { CdkTableModule } from '@angular/cdk/table';
import { SharedModule } from '../shared/shared.module';
import { SaleReportRoutingModule } from './sale-report-routing.module';
import { SaleReportComponent } from './sale-report.component';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { A11yModule } from '@angular/cdk/a11y';
import { FlexLayoutModule } from '@angular/flex-layout';
export const MY_FORMATS = {
parse: {
@ -47,15 +54,12 @@ export const MY_FORMATS = {
MatTableModule,
ReactiveFormsModule,
SharedModule,
SaleReportRoutingModule
],
declarations: [
SaleReportComponent
SaleReportRoutingModule,
],
declarations: [SaleReportComponent],
providers: [
{provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE]},
{provide: MAT_DATE_FORMATS, useValue: MY_FORMATS},
]
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
],
})
export class SaleReportModule {
}
export class SaleReportModule {}

View File

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

View File

@ -1,36 +1,33 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { catchError } from 'rxjs/operators';
import { Observable } from 'rxjs/internal/Observable';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { SaleReport } from './sale-report';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
import { SaleReport } from './sale-report';
const url = '/api/sale-report';
const serviceName = 'SaleReportService';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class SaleReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {
}
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(startDate: string, finishDate): Observable<SaleReport> {
const options = {params: new HttpParams()};
const options = { params: new HttpParams() };
if (startDate !== null) {
options.params = options.params.set('s', startDate);
}
if (finishDate !== null) {
options.params = options.params.set('f', finishDate);
}
return <Observable<SaleReport>>this.http.get<SaleReport>(url, options)
.pipe(
catchError(this.log.handleError(serviceName, 'get'))
);
return <Observable<SaleReport>>(
this.http
.get<SaleReport>(url, options)
.pipe(catchError(this.log.handleError(serviceName, 'get')))
);
}
}

View File

@ -1,7 +1,4 @@
export class SaleReportItem {
name: string;
amount: number;
}
import { SaleReportItem } from './sale-report-item';
export class SaleReport {
startDate: string;