Skip to content

Commit

Permalink
fix(dependencies): removing more moment dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed Nov 30, 2018
1 parent 2fba272 commit 61426b2
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 202 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular

live [Demo](https://xmlking.github.io/ngx-starter-kit/index.html)

**PANTS** (_PostgreSQL_ - _Angular_ - _NestJS_ - _TypeScript_) Stack
**PANTS** (:elephant: _PostgreSQL_ - :a: _Angular_ - :rocket: _NestJS_ - _TypeScript_) Stack in :dolphin: NX workspace

## Install

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Account, Gender } from '../../models/account.model';
import { states } from './states';
import { Observable } from 'rxjs';
import { EntityFormComponent } from '@ngx-starter-kit/shared';
import * as moment from 'moment';
import { subYears } from 'date-fns/esm';

@Component({
selector: 'ngx-account-edit',
Expand All @@ -19,8 +19,8 @@ export class AccountEditComponent extends EntityFormComponent<Account> {
readonly states: string[] = states;
filteredStates: Observable<string[]>;

readonly maxDate = moment();
readonly minDate = moment().subtract(100, 'years');
readonly maxDate = new Date();
readonly minDate = subYears(this.maxDate, 100);

constructor(
@Inject(MAT_DIALOG_DATA) public data: { title: string; payload: Account },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import { AppConfirmService } from '@ngx-starter-kit/app-confirm';
import { MatDialog, MatSnackBar } from '@angular/material';
import { catchError, tap, concatMap, filter, map, mergeMap } from 'rxjs/operators';
import { throwError } from 'rxjs';

import { format } from 'date-fns/esm';
import { AccountEditComponent } from '../../components/account-edit/account-edit.component';
import * as moment from 'moment';
import { Navigate } from '@ngxs/router-plugin';
import { Store } from '@ngxs/store';
import { Crumb } from '@ngx-starter-kit/breadcrumbs';
Expand Down Expand Up @@ -37,7 +36,7 @@ export class AccountsTableComponent extends EntitiesComponent<Account, AccountSe
new EntityColumnDef<Account>({ property: 'Name', header: 'Name', displayFn: (entity) => `${entity.first_name} ${entity.last_name}` }),
new EntityColumnDef<Account>({ property: 'gender', header: 'Gender' }),
// prettier-ignore
new EntityColumnDef<Account>({ property: 'dob', header: 'DoB', displayFn: (entity) => `${moment(entity.dob).format('LL')}` }),
new EntityColumnDef<Account>({ property: 'dob', header: 'DoB', displayFn: (entity) => `${format(entity.dob, 'MMMM dd, yyyy')}` }),
new EntityColumnDef<Account>({ property: 'city', header: 'City', displayFn: entity => `${entity.address.city}` }),
new EntityColumnDef<Account>({
property: 'state',
Expand Down
3 changes: 1 addition & 2 deletions libs/grid/src/lib/models/account.model.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Entity } from '@ngx-starter-kit/shared';
import * as moment from 'moment';

export class Account extends Entity {
public id = 0;
public first_name?: string;
public last_name?: string;
public gender?: Gender;
public dob?: moment.Moment;
public dob?: Date;
public email?: string;
public phone?: string;
public company?: string;
Expand Down
1 change: 0 additions & 1 deletion libs/quickpanel/src/lib/quickpanel.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import * as moment from 'moment';

@Component({
selector: 'ngx-quickpanel',
Expand Down
8 changes: 4 additions & 4 deletions libs/shared/src/lib/containers/entity/entity.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { Observable, BehaviorSubject, throwError } from 'rxjs';
import { BehaviorSubject, Observable, throwError } from 'rxjs';
import { environment } from '@env/environment';
import { Entity } from './entity.model';
import { map, retry, catchError, finalize } from 'rxjs/operators';
import * as moment from 'moment';
import { catchError, finalize, retry } from 'rxjs/operators';
import { format } from 'date-fns/esm';

export interface Filter {
[name: string]: string | string[];
Expand Down Expand Up @@ -93,7 +93,7 @@ export abstract class EntityService<T extends Entity> {
protected convertToJson(body: any) {
const temporalFunctionToJson = Date.prototype.toJSON;
Date.prototype.toJSON = function() {
return moment(this).format('YYYY-MM-DD');
return format(this, 'YYYY-MM-DD');
};

const jsonBody = JSON.stringify(body);
Expand Down
6 changes: 3 additions & 3 deletions libs/widgets/src/lib/containers/wizdash/wizdash.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ChartData } from 'chart.js';
import * as moment from 'moment';
import { Observable } from 'rxjs/internal/Observable';
import { ReplaySubject } from 'rxjs/internal/ReplaySubject';
import { fadeOutAnimation } from '@ngx-starter-kit/animations';
Expand All @@ -17,6 +16,7 @@ import {
import { RecentSalesWidgetOptions } from '../../components/recent-sales-widget/recent-sales-widget-options.interface';
import { SalesSummaryWidgetOptions } from '../../components/sales-summary-widget/sales-summary-widget-options.interface';
import { WizdashService } from './wizdash.service';
import { formatDistance } from 'date-fns/esm';

@Component({
selector: 'ngx-wizdash',
Expand Down Expand Up @@ -185,15 +185,15 @@ export class WizdashComponent implements OnInit {
// Prefill realtimeUsersData with 30 random values
for (let i = 0; i < 30; i++) {
this._realtimeUsersDataSubject.next({
label: moment().fromNow(),
label: formatDistance(new Date(), new Date()),
value: Math.round(Math.random() * (100 - 10) + 10),
} as RealtimeUsersWidgetData);
}

// Simulate incoming values for Realtime Users Widget
setInterval(() => {
this._realtimeUsersDataSubject.next({
label: moment().fromNow(),
label: formatDistance(new Date(), new Date()),
value: Math.round(Math.random() * (100 - 10) + 10),
} as RealtimeUsersWidgetData);
}, 5000);
Expand Down

0 comments on commit 61426b2

Please sign in to comment.