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:
@ -1,34 +1,33 @@
|
||||
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 {PurchaseEntriesItem} from './purchase-entries';
|
||||
|
||||
import { map } from 'rxjs/operators';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { PurchaseEntriesItem } from './purchase-entries';
|
||||
|
||||
export class PurchaseEntriesDataSource extends DataSource<PurchaseEntriesItem> {
|
||||
|
||||
constructor(private paginator: MatPaginator, private sort: MatSort, public data: PurchaseEntriesItem[]) {
|
||||
constructor(
|
||||
private paginator: MatPaginator,
|
||||
private sort: MatSort,
|
||||
public data: PurchaseEntriesItem[],
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<PurchaseEntriesItem[]> {
|
||||
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: PurchaseEntriesItem[]) {
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {PurchaseEntriesResolver} from './purchase-entries-resolver.service';
|
||||
import { PurchaseEntriesResolver } from './purchase-entries-resolver.service';
|
||||
|
||||
describe('PurchaseEntriesResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [PurchaseEntriesResolver]
|
||||
providers: [PurchaseEntriesResolver],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {PurchaseEntries} from './purchase-entries';
|
||||
import {PurchaseEntriesService} from './purchase-entries.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { PurchaseEntries } from './purchase-entries';
|
||||
import { PurchaseEntriesService } from './purchase-entries.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PurchaseEntriesResolver implements Resolve<PurchaseEntries> {
|
||||
|
||||
constructor(private ser: PurchaseEntriesService) {
|
||||
}
|
||||
constructor(private ser: PurchaseEntriesService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<PurchaseEntries> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {PurchaseEntriesRoutingModule} from './purchase-entries-routing.module';
|
||||
import { PurchaseEntriesRoutingModule } from './purchase-entries-routing.module';
|
||||
|
||||
describe('PurchaseEntriesRoutingModule', () => {
|
||||
let purchaseEntriesRoutingModule: PurchaseEntriesRoutingModule;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {PurchaseEntriesResolver} from './purchase-entries-resolver.service';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {PurchaseEntriesComponent} from './purchase-entries.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { PurchaseEntriesResolver } from './purchase-entries-resolver.service';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
import { PurchaseEntriesComponent } from './purchase-entries.component';
|
||||
|
||||
const purchaseEntriesRoutes: Routes = [
|
||||
{
|
||||
@ -11,27 +11,18 @@ const purchaseEntriesRoutes: Routes = [
|
||||
component: PurchaseEntriesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Purchase Entries'
|
||||
permission: 'Purchase Entries',
|
||||
},
|
||||
resolve: {
|
||||
info: PurchaseEntriesResolver
|
||||
info: PurchaseEntriesResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always'
|
||||
}
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(purchaseEntriesRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
PurchaseEntriesResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(purchaseEntriesRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [PurchaseEntriesResolver],
|
||||
})
|
||||
export class PurchaseEntriesRoutingModule {
|
||||
}
|
||||
export class PurchaseEntriesRoutingModule {}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.selected{
|
||||
background: #fff3cd
|
||||
.selected {
|
||||
background: #fff3cd;
|
||||
}
|
||||
|
||||
.unposted{
|
||||
background: #f8d7da
|
||||
.unposted {
|
||||
background: #f8d7da;
|
||||
}
|
||||
|
||||
@ -4,17 +4,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>
|
||||
@ -22,65 +39,71 @@
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
|
||||
<!-- Date Column -->
|
||||
<ng-container matColumnDef="date">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Date</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.date}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.date }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Supplier Column -->
|
||||
<ng-container matColumnDef="supplier">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Supplier</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="row.url">{{row.supplier}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="row.url">{{ row.supplier }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Product Column -->
|
||||
<ng-container matColumnDef="product">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Product</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.product}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.product }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<!-- Quantity Column -->
|
||||
<ng-container matColumnDef="quantity">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Quantity</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.quantity | number:'1.2-2'}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{
|
||||
row.quantity | number: '1.2-2'
|
||||
}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Rate Column -->
|
||||
<ng-container matColumnDef="rate">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Rate</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.rate | currency:'INR'}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{ row.rate | currency: 'INR' }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Tax Column -->
|
||||
<ng-container matColumnDef="tax">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Tax</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.tax | percent:'1.2-2'}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{ row.tax | percent: '1.2-2' }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Discount Column -->
|
||||
<ng-container matColumnDef="discount">
|
||||
<mat-header-cell *matHeaderCellDef class="right">Discount</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{row.discount | percent:'1.2-2'}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row" class="right">{{
|
||||
row.discount | percent: '1.2-2'
|
||||
}}</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-paginator #paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250, 300]">
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250, 300]"
|
||||
>
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {PurchaseEntriesComponent} from './purchase-entries.component';
|
||||
import { PurchaseEntriesComponent } from './purchase-entries.component';
|
||||
|
||||
describe('PurchaseEntriesComponent', () => {
|
||||
let component: PurchaseEntriesComponent;
|
||||
@ -8,9 +8,8 @@ describe('PurchaseEntriesComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PurchaseEntriesComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [PurchaseEntriesComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import {PurchaseEntriesDataSource} from './purchase-entries-datasource';
|
||||
import {PurchaseEntries} from './purchase-entries';
|
||||
import {map} from 'rxjs/operators';
|
||||
import { PurchaseEntriesDataSource } from './purchase-entries-datasource';
|
||||
import { PurchaseEntries } from './purchase-entries';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-purchase-entries',
|
||||
templateUrl: './purchase-entries.component.html',
|
||||
styleUrls: ['./purchase-entries.component.css']
|
||||
styleUrls: ['./purchase-entries.component.css'],
|
||||
})
|
||||
export class PurchaseEntriesComponent implements OnInit {
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
@ -21,25 +21,30 @@ export class PurchaseEntriesComponent implements OnInit {
|
||||
info: PurchaseEntries;
|
||||
selectedRowId: string;
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['date', 'supplier', 'product', 'quantity', 'rate', 'tax', 'discount', 'amount'];
|
||||
displayedColumns = [
|
||||
'date',
|
||||
'supplier',
|
||||
'product',
|
||||
'quantity',
|
||||
'rate',
|
||||
'tax',
|
||||
'discount',
|
||||
'amount',
|
||||
];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private fb: FormBuilder
|
||||
) {
|
||||
constructor(private route: ActivatedRoute, private router: Router, private fb: FormBuilder) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { info: PurchaseEntries }) => {
|
||||
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 PurchaseEntriesDataSource(this.paginator, this.sort, this.info.body);
|
||||
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 PurchaseEntriesDataSource(this.paginator, this.sort, this.info.body);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
@ -47,8 +52,8 @@ export class PurchaseEntriesComponent implements OnInit {
|
||||
this.router.navigate(['purchase-entries'], {
|
||||
queryParams: {
|
||||
startDate: l.startDate,
|
||||
finishDate: l.finishDate
|
||||
}
|
||||
finishDate: l.finishDate,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -65,7 +70,7 @@ export class PurchaseEntriesComponent implements OnInit {
|
||||
return {
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
body: []
|
||||
body: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {PurchaseEntriesModule} from './purchase-entries.module';
|
||||
import { PurchaseEntriesModule } from './purchase-entries.module';
|
||||
|
||||
describe('PurchaseEntriesModule', () => {
|
||||
let purchaseEntriesModule: PurchaseEntriesModule;
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
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';
|
||||
@ -13,14 +18,14 @@ 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 {SharedModule} from '../shared/shared.module';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {CdkTableModule} from '@angular/cdk/table';
|
||||
import {PurchaseEntriesRoutingModule} from './purchase-entries-routing.module';
|
||||
import {PurchaseEntriesComponent} from './purchase-entries.component';
|
||||
import {MomentDateAdapter} from '@angular/material-moment-adapter';
|
||||
import {A11yModule} from '@angular/cdk/a11y';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { PurchaseEntriesRoutingModule } from './purchase-entries-routing.module';
|
||||
import { PurchaseEntriesComponent } from './purchase-entries.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: {
|
||||
@ -55,15 +60,12 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
PurchaseEntriesRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
PurchaseEntriesComponent
|
||||
PurchaseEntriesRoutingModule,
|
||||
],
|
||||
declarations: [PurchaseEntriesComponent],
|
||||
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 PurchaseEntriesModule {
|
||||
}
|
||||
export class PurchaseEntriesModule {}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {PurchaseEntriesService} from './purchase-entries.service';
|
||||
import { PurchaseEntriesService } from './purchase-entries.service';
|
||||
|
||||
describe('PurchaseEntriesService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [PurchaseEntriesService]
|
||||
providers: [PurchaseEntriesService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -1,32 +1,30 @@
|
||||
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 {PurchaseEntries} from './purchase-entries';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
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 { PurchaseEntries } from './purchase-entries';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
|
||||
const url = '/api/purchase-entries';
|
||||
const serviceName = 'PurchaseEntriesService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PurchaseEntriesService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(startDate: string, finishDate): Observable<PurchaseEntries> {
|
||||
startDate = startDate ? `/${startDate}` : '';
|
||||
finishDate = finishDate ? `/${finishDate}` : '';
|
||||
return <Observable<PurchaseEntries>>this.http.get<PurchaseEntries>(`${url}${startDate}${finishDate}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
return <Observable<PurchaseEntries>>(
|
||||
this.http
|
||||
.get<PurchaseEntries>(`${url}${startDate}${finishDate}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
export class PurchaseEntriesItem {
|
||||
id: string;
|
||||
date: string;
|
||||
|
||||
Reference in New Issue
Block a user