Removed 'date' pipe

This commit is contained in:
Nile Walker 2021-02-19 07:57:25 -05:00
parent 0db09ddf5e
commit fe82aba47c
6 changed files with 26 additions and 34 deletions

View File

@ -53,7 +53,7 @@ import {MatGridListModule} from '@angular/material/grid-list';
import {MatDividerModule} from '@angular/material/divider';
import { SidebarComponent } from './sidebar/sidebar.component';
import {MatListModule} from '@angular/material/list';
import { CustomDatePipe } from './custom-date-adapter';
import { ChangeDatePipe } from './change_date.pipe';
import {DevHeaderInterceptorInterceptor} from './dev-header-interceptor.interceptor';
@ -80,7 +80,6 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
CircleQRcodeDoubleComponent,
CircleQRcodeSingleComponent,
CountComponent,
CustomDatePipe,
FooterComponent,
LabelLayoutComponent,
LoadingComponent,
@ -96,7 +95,8 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
DepositsComponent,
GraphsComponent,
ImportedFilesComponent,
SidebarComponent
SidebarComponent,
ChangeDatePipe
],
imports: [
MatPaginatorModule,
@ -128,13 +128,13 @@ export function getBaseHref(platformLocation: PlatformLocation): string {
ReactiveFormsModule,
AppRoutingModule, // <-- This line MUST be last (https://angular.io/guide/router#module-import-order-matters)
],
providers: [
ApiService,
GraphService,
CacheService,
SettingsService,
MatDatepickerModule,
CustomDatePipe,
{provide: 'APP_ENVIRONMENT', useClass: ThisEnvironment},
{provide: APP_BASE_HREF, useFactory: getBaseHref, deps: [PlatformLocation]},
{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}},

View File

@ -1,13 +1,10 @@
import { NativeDateAdapter } from '@angular/material/core';
import {Injectable} from '@angular/core';
// @Pipe({ name: 'date' })
/** Adapts the native JS Date for use with cdk-based components that work with dates. */
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
@Pipe({ name: 'changed_date' })
export class CustomDatePipe implements PipeTransform {
export class ChangeDatePipe implements PipeTransform {
// adding a default value in case you don't want to pass the format then 'yyyy-MM-dd' will be used
transform(date: Date | string, day: number, format: string = 'yyyy-MM-dd'): string {
date = new Date(date); // if orginal type was a string
@ -16,15 +13,15 @@ export class CustomDatePipe implements PipeTransform {
}
}
@Pipe({ name: 'date' })
@Injectable()
export class CustomDateAdapter extends NativeDateAdapter implements PipeTransform {
transform(value: any, ...args: any[]) {
throw new Error('Method not implemented.');
}
// @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;
}
// getFirstDayOfWeek(): number {
// return 1;
// }
}
// }

View File

@ -29,7 +29,7 @@
<mat-datepicker #picker></mat-datepicker>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
</th>
<td mat-cell *matCellDef="let element"> {{element.date_added | date:"medium"}} </td>
<td mat-cell *matCellDef="let element"> {{element.date_added |changed_date : 0:"medium"}} </td>
</ng-container>
<!-- Name Column -->

View File

@ -1,16 +1,16 @@
<div class="full-height flex-container bg-primary">
<div class="flex-grid">
<mat-card class="col">
<h5 class="card-title text-uppercase text-muted">Total Samples within<br> {{form.startDate | date}}
<h5 class="card-title text-uppercase text-muted">Total Samples within<br> {{form.startDate |changed_date : 0}}
-
{{form.endDate | date}}</h5>
{{form.endDate |changed_date : 0}}</h5>
<span class="h2 font-weight-bold">{{topBarData[0]}}</span>
</mat-card>
<mat-card class="col">
<h5 class="card-title text-uppercase text-muted mb-0">Total Samples within <br> {{form.startDate | changed_date: 7:'mediumDate'}}
-
{{form.endDate | changed_date: 7:'mediumDate'}}</h5>
{{form.endDate | changed_date: 7: 'mediumDate'}}</h5>
<span class="h2 font-weight-bold ">{{topBarData[1]}}</span>
</mat-card>
@ -25,7 +25,7 @@
<mat-card class="col">
<h5 class="card-title text-uppercase text-muted ">Email Notifications within <br>
{{form.startDate |
date}} - {{form.endDate | date}}</h5>
changed_date : 0}} - {{form.endDate |changed_date : 0}}</h5>
<span class="h2 font-weight-bold "><span style="color:green">{{topBarData[3]}}</span>/<span
style="color:red">{{topBarData[4]}}</span></span>
</mat-card>
@ -33,7 +33,7 @@
<mat-card class="col">
<h5 class="card-title text-uppercase text-muted ">Text Notifications within <br>
{{form.startDate |
date}} - {{form.endDate | date}}</h5>
changed_date : 0}} - {{form.endDate |changed_date : 0}}</h5>
<span class="h2 font-weight-bold"><span style="color:green">{{topBarData[5]}}</span>/<span
style="color:red">{{topBarData[6]}}</span></span>
</mat-card>
@ -92,7 +92,7 @@
<mat-card class="col">
<mat-card-header>
<h1>Average Count By Weekday For {{form.startDate | date}} - {{form.endDate | date}}</h1>
<h1>Average Count By Weekday For {{form.startDate |changed_date : 0}} - {{form.endDate |changed_date : 0}}</h1>
</mat-card-header>
<div style="display: block">
@ -104,7 +104,7 @@
<mat-card class="col">
<mat-card-header>
<h1>Average Count By Hour For {{form.startDate | date}} - {{form.endDate | date}}</h1>
<h1>Average Count By Hour For {{form.startDate |changed_date : 0}} - {{form.endDate |changed_date : 0}}</h1>
</mat-card-header>
<div style="display: block">

View File

@ -8,9 +8,7 @@ import {ApiService} from '../services/api.service';
import {APP_BASE_HREF} from '@angular/common';
import {Router} from '@angular/router';
import {MockEnvironment} from '../testing/environment.mock';
import {DateAdapter} from '@angular/material/core';
import {DatePipe} from '@angular/common';
import {CustomDateAdapter, CustomDatePipe} from '../custom-date-adapter';
import { ChangeDatePipe } from '../change_date.pipe';
describe('GraphsComponent', () => {
let component: GraphsComponent;
@ -25,8 +23,7 @@ describe('GraphsComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
CustomDatePipe,
CustomDateAdapter
ChangeDatePipe
],
imports: [
HttpClientTestingModule,
@ -35,12 +32,10 @@ describe('GraphsComponent', () => {
],
providers: [
ApiService,
DatePipe,
{provide: 'APP_ENVIRONMENT', useValue: mockEnvironment},
{provide: APP_BASE_HREF, useValue: '/'},
{provide: Router, useValue: mockRouter},
{provide: Location, useValue: location},
{provide: DateAdapter, useValue: CustomDateAdapter},
]
});
httpMock = TestBed.inject(HttpTestingController);

View File

@ -20,7 +20,7 @@
<ng-container matColumnDef="position">
<th mat-header-cell *matHeaderCellDef> Date Added </th>
<td mat-cell *matCellDef="let element; let i = index;"> {{element[0] | date:"medium"}} </td>
<td mat-cell *matCellDef="let element; let i = index;"> {{element[0] |changed_date : 0:"medium"}} </td>
</ng-container>
<!-- Name Column -->