Switched Date Picker to make the first dow in

date picker to monday
This commit is contained in:
Nile Walker 2021-03-03 08:19:52 -05:00
parent 2b64d3028c
commit 99f56af4ef
5 changed files with 22 additions and 17 deletions

View File

@ -55,6 +55,7 @@ import { SidebarComponent } from './sidebar/sidebar.component';
import {MatListModule} from '@angular/material/list'; import {MatListModule} from '@angular/material/list';
import { ChangeDatePipe } from './change_date.pipe'; import { ChangeDatePipe } from './change_date.pipe';
import {DevHeaderInterceptorInterceptor} from './dev-header-interceptor.interceptor'; import {DevHeaderInterceptorInterceptor} from './dev-header-interceptor.interceptor';
import { TestWeekDateAdapter } from './test-week-date-adapter';
@ -138,7 +139,8 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
{provide: 'APP_ENVIRONMENT', useClass: ThisEnvironment}, {provide: 'APP_ENVIRONMENT', useClass: ThisEnvironment},
{provide: APP_BASE_HREF, useFactory: getBaseHref, deps: [PlatformLocation]}, {provide: APP_BASE_HREF, useFactory: getBaseHref, deps: [PlatformLocation]},
{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}}, {provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}},
{provide: HTTP_INTERCEPTORS, useClass: DevHeaderInterceptorInterceptor, multi: true} {provide: HTTP_INTERCEPTORS, useClass: DevHeaderInterceptorInterceptor, multi: true},
{ provide: DateAdapter, useClass: TestWeekDateAdapter },
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
entryComponents: [] entryComponents: []

View File

@ -13,15 +13,3 @@ export class ChangeDatePipe implements PipeTransform {
} }
} }
// @Pipe({ name: 'date' })
// @Injectable()
// export class CustomDateAdapter extends NativeDateAdapter implements PipeTransform {
// transform(value: any, ...args: any[]) {
// throw new Error('Method not implemented.');
// }
// getFirstDayOfWeek(): number {
// return 1;
// }
// }

View File

@ -49,7 +49,12 @@ export class GraphsComponent implements OnInit {
}, },
legend: { legend: {
onClick: (e, i) => { onClick: (e, i) => {
if (!this.ChartName.includes('Station')){
this.form.location = String(i.text); this.form.location = String(i.text);
}
else {
this.form.location = '';
}
this.updateGraphData(); this.updateGraphData();
} }
}, },
@ -110,8 +115,8 @@ export class GraphsComponent implements OnInit {
this.pageSize = event.pageSize; this.pageSize = event.pageSize;
this.pageIndex = event.pageIndex; this.pageIndex = event.pageIndex;
this.pageIndex = event.pageIndex; this.pageIndex = event.pageIndex;
this.graphService.getRawSearchData(this.form, this.pageIndex).subscribe( this.graphService.getRawSearchData(this.form, this.pageIndex, this.pageSize).subscribe(
searchResult => {this.searchResult = searchResult; searchResult => {this.searchResult = searchResult;
}); });
} }
@ -188,7 +193,7 @@ export class GraphsComponent implements OnInit {
this.topBarData = tempData; this.topBarData = tempData;
this.totalItems = this.topBarData[0]; this.totalItems = this.topBarData[0];
}); });
this.graphService.getRawSearchData(this.form, 0).subscribe(searchResult => this.searchResult = searchResult); this.graphService.getRawSearchData(this.form, 0, this.pageSize).subscribe(searchResult => this.searchResult = searchResult);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@ -32,9 +32,10 @@ export class GraphService {
}); });
} }
getRawSearchData(form: SearchForm, page: number): Observable<Sample[]> { getRawSearchData(form: SearchForm, page: number, itemsPerPage: number ): Observable<Sample[]> {
let params = this.createParams(form); let params = this.createParams(form);
params = params.set('page', String(page)); params = params.set('page', String(page));
params = params.set('items_per_page', String(itemsPerPage));
return this.httpClient return this.httpClient
.get<Sample[]>(this.apiRoot + `/dashboard/search`, { params }) .get<Sample[]>(this.apiRoot + `/dashboard/search`, { params })

View File

@ -0,0 +1,9 @@
import { NativeDateAdapter } from '@angular/material/core';
/** Adapts the native JS Date for use with cdk-based components that work with dates. */
export class TestWeekDateAdapter extends NativeDateAdapter {
getFirstDayOfWeek(): number {
return 1;
}
}