Merge branch 'feature/libraries_config_moment_chartjs' into 'develop'

replace date-fns by momentJS & install ng2-chart

See merge request framasoft/framadate/funky-framadate-front!36
This commit is contained in:
ty kayn 2020-05-05 11:55:01 +02:00
commit 967d5bcc0c
8 changed files with 55 additions and 40 deletions

View File

@ -1,26 +1,27 @@
## LIBRARIES USED ## LIBRARIES USED
| status | lib name | usage | | status | lib name | usage |
| ------- | -------------------------------------------------------------- | -------------------------------------- | | --------------- | -------------------------------------------------------------- | ---------------------------------------- |
| | [axios](https://github.com/axios/axios) | http client | | | [axios](https://github.com/axios/axios) | http client |
| | [bulma](https://bulma.io/) | CSS framework | | | [bulma](https://bulma.io/) | CSS framework |
| | [chart.js](https://www.chartjs.org/) | Display graphs. (Commes with MomentJS) | | | [chart.js](https://www.chartjs.org/) | Display graphs. (Comes with MomentJS) |
| | [compodoc](https://compodoc.app/) | Generate technic documentation | | | [compodoc](https://compodoc.app/) | Generate technic documentation |
| | [date-fns](https://date-fns.org) | manipulate dates | | | ESlint, Prettier, Lint-staged | Format & lint code |
| | ESlint, Prettier, Lint-staged | Format & lint code | | | [fork-awesome](https://forkaweso.me) | Icons collection |
| | [fork-awesome](https://forkaweso.me) | Icons collection | | | [fullcalendar](https://fullcalendar.io/docs/initialize-es6) | Manage & display calendars |
| | [fullcalendar](https://fullcalendar.io/docs/initialize-es6) | Manage & display calendars | | | [husky](https://www.npmjs.com/package/husky) | Hook actions on commit |
| | [husky](https://www.npmjs.com/package/husky) | Hook actions on commit | | | [jest](https://jestjs.io/) | test engine |
| | [jest](https://jestjs.io/) | test engine | | removed | [locale-enum](https://www.npmjs.com/package/locale-enum) | enum of all locales |
| removed | [locale-enum](https://www.npmjs.com/package/locale-enum) | enum of all locales | | | [momentJS](https://momentjs.com/) | manipulate dates. (chartJSs dependency) |
| | [ngx-clipboard](https://www.npmjs.com/package/ngx-clipboard) | Handle clipboard | | to be installed | [ng2-charts](https://valor-software.com/ng2-charts/) | Manipulate graphs along with chart.js |
| | [ngx-markdown](https://www.npmjs.com/package/ngx-markdown) | markdown parser | | | [ngx-clipboard](https://www.npmjs.com/package/ngx-clipboard) | Handle clipboard |
| | [ngx-webstorage](https://www.npmjs.com/package/ngx-webstorage) | handle localStorage & webStorage | | | [ngx-markdown](https://www.npmjs.com/package/ngx-markdown) | markdown parser |
| | [primeNG](https://www.primefaces.org/primeng/) | UI components collection | | | [ngx-webstorage](https://www.npmjs.com/package/ngx-webstorage) | handle localStorage & webStorage |
| | [quill](https://www.npmjs.com/package/quill) | powerful rich text editor. WYSIWYG. | | | [primeNG](https://www.primefaces.org/primeng/) | UI components collection |
| removed | [storybook](https://storybook.js.org/) | StyleGuide UI | | | [quill](https://www.npmjs.com/package/quill) | powerful rich text editor. WYSIWYG. |
| | [ts-mockito](https://www.npmjs.com/package/ts-mockito) | Mocks for testing. | | removed | [storybook](https://storybook.js.org/) | StyleGuide UI |
| | [uuid](https://www.npmjs.com/package/uuid) | handle client-side generation of uuids | | | [ts-mockito](https://www.npmjs.com/package/ts-mockito) | Mocks for testing. |
| | [uuid](https://www.npmjs.com/package/uuid) | handle client-side generation of uuids |
--- ---

View File

@ -31,6 +31,7 @@
"src/styles.scss" "src/styles.scss"
], ],
"scripts": [ "scripts": [
"node_modules/chart.js/dist/Chart.min.js",
"node_modules/marked/lib/marked.js", "node_modules/marked/lib/marked.js",
"node_modules/prismjs/prism.js", "node_modules/prismjs/prism.js",
"node_modules/prismjs/components/prism-css.min.js" "node_modules/prismjs/components/prism-css.min.js"

View File

@ -36,8 +36,8 @@
"axios": "^0.19.2", "axios": "^0.19.2",
"bulma": "^0.8.2", "bulma": "^0.8.2",
"chart.js": "^2.9.3", "chart.js": "^2.9.3",
"date-fns": "^2.12.0",
"fork-awesome": "^1.1.7", "fork-awesome": "^1.1.7",
"ng2-charts": "^2.3.0",
"ngx-clipboard": "^13.0.0", "ngx-clipboard": "^13.0.0",
"ngx-markdown": "^9.0.0", "ngx-markdown": "^9.0.0",
"ngx-webstorage": "^5.0.0", "ngx-webstorage": "^5.0.0",
@ -78,7 +78,7 @@
"protractor": "~5.4.3", "protractor": "~5.4.3",
"ts-jest": "^25.4.0", "ts-jest": "^25.4.0",
"ts-mockito": "^2.5.0", "ts-mockito": "^2.5.0",
"ts-node": "~8.9.0", "ts-node": "^8.10.1",
"typescript": "~3.8.3" "typescript": "~3.8.3"
}, },
"husky": { "husky": {

View File

@ -1,9 +1,9 @@
import { isValid } from 'date-fns'; import * as moment from 'moment';
export class PollOption { export class PollOption {
constructor(public label: string, public url?: string, public subOptions?: PollOption[]) {} constructor(public label: string, public url?: string, public subOptions?: PollOption[]) {}
public isDatePoll(): boolean { public isDatePoll(): boolean {
return isValid(this.label); return moment(this.label).isValid();
} }
} }

View File

@ -1,20 +1,20 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { addDays, differenceInDays, format } from 'date-fns'; import * as moment from 'moment';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class DateUtilsService { export class DateUtilsService {
public static addDaysToDate(days: number, date: Date): Date { public static addDaysToDate(days: number, date: Date): Date {
return addDays(date, days); return moment(date).add(days, 'days').toDate();
} }
public static diffInDays(dateLeft: Date, dateRight: Date): number { public static diffInDays(dateLeft: Date, dateRight: Date): number {
return differenceInDays(dateLeft, dateRight); return moment(dateLeft).diff(moment(dateRight));
} }
public static formatDate(date): string { public static formatDate(date): string {
return format(date, 'yyyy-MM-dd'); return moment(date).format('yyyy-MM-dd');
} }
public static orderDates(): Date[] { public static orderDates(): Date[] {

View File

@ -1,12 +1,11 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { AdminComponent } from './pages/admin/admin.component'; import { AdminComponent } from './pages/admin/admin.component';
import { AnswersComponent } from './pages/answers/answers.component'; import { AnswersComponent } from './pages/answers/answers.component';
import { CreateOrRetrieveComponent } from './pages/create-or-retrieve/create-or-retrieve.component'; import { CreateOrRetrieveComponent } from './pages/create-or-retrieve/create-or-retrieve.component';
import { DatesComponent } from './pages/dates/dates.component'; import { DatesComponent } from './pages/dates/dates.component';
import { EndConfirmationComponent } from './pages/end-confirmation/end-confirmation.component'; import { EndConfirmationComponent } from './pages/end-confirmation/end-confirmation.component';
import { BaseComponent } from './pages/example/base-page/base.component';
import { KindComponent } from './pages/example/kind/kind.component'; import { KindComponent } from './pages/example/kind/kind.component';
import { PicturesComponent } from './pages/example/pictures/pictures.component'; import { PicturesComponent } from './pages/example/pictures/pictures.component';
import { HomeComponent } from './pages/home/home.component'; import { HomeComponent } from './pages/home/home.component';

View File

@ -1,6 +1,7 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ChartsModule } from 'ng2-charts';
import { import {
ConfirmDialogModule, ConfirmDialogModule,
DialogModule, DialogModule,
@ -21,6 +22,7 @@ import { PollPageComponent } from './components/poll-page/poll-page.component';
declarations: [PageNotFoundComponent, PollPageComponent], declarations: [PageNotFoundComponent, PollPageComponent],
imports: [ imports: [
CommonModule, CommonModule,
ChartsModule,
ConfirmDialogModule, ConfirmDialogModule,
DialogModule, DialogModule,
InputSwitchModule, InputSwitchModule,
@ -33,6 +35,7 @@ import { PollPageComponent } from './components/poll-page/poll-page.component';
], ],
exports: [ exports: [
TranslateModule, TranslateModule,
ChartsModule,
ConfirmDialogModule, ConfirmDialogModule,
DialogModule, DialogModule,
InputSwitchModule, InputSwitchModule,

View File

@ -1530,6 +1530,13 @@
dependencies: dependencies:
"@babel/types" "^7.3.0" "@babel/types" "^7.3.0"
"@types/chart.js@^2.7.48":
version "2.9.20"
resolved "https://registry.yarnpkg.com/@types/chart.js/-/chart.js-2.9.20.tgz#db503fc0d478d1d2a99eb0099d5c2b9c77599931"
integrity sha512-Xv4dd+DYqtTdUWbDIwaDEFtUIFwoQN44wiDDrWXdJtfGtOFlFIxXrsu8D+XJCS9o7mZbW29X8vPptwVrduz4JA==
dependencies:
moment "^2.10.2"
"@types/color-name@^1.1.1": "@types/color-name@^1.1.1":
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
@ -3765,11 +3772,6 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0" whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0" whatwg-url "^8.0.0"
date-fns@^2.12.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.12.0.tgz#01754c8a2f3368fc1119cf4625c3dad8c1845ee6"
integrity sha512-qJgn99xxKnFgB1qL4jpxU7Q2t0LOn1p8KMIveef3UZD7kqjT3tpFNNdXJelEHhE+rUgffriXriw/sOSU+cS1Hw==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3: debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9" version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@ -7671,6 +7673,15 @@ next-tick@~1.0.0:
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
ng2-charts@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/ng2-charts/-/ng2-charts-2.3.0.tgz#e4dd1f7fe12dc2635d5e8c4f101a8d4c4f433754"
integrity sha512-D5K7OqF0m5lOBYvNOsraoEo4OPHja9zfGNj+HWy2nUcP0LP2s+Y/QaQlkG/1rHlwXq9HPm8rLxzSutA0eLHxGQ==
dependencies:
"@types/chart.js" "^2.7.48"
lodash "^4.17.11"
tslib "^1.9.0"
ngx-clipboard@^13.0.0: ngx-clipboard@^13.0.0:
version "13.0.0" version "13.0.0"
resolved "https://registry.yarnpkg.com/ngx-clipboard/-/ngx-clipboard-13.0.0.tgz#cbfc25b0fa5fbaaa76ee1229ebc7a6ed2ef0318b" resolved "https://registry.yarnpkg.com/ngx-clipboard/-/ngx-clipboard-13.0.0.tgz#cbfc25b0fa5fbaaa76ee1229ebc7a6ed2ef0318b"
@ -10931,10 +10942,10 @@ ts-mockito@^2.5.0:
dependencies: dependencies:
lodash "^4.17.5" lodash "^4.17.5"
ts-node@~8.9.0: ts-node@^8.10.1:
version "8.9.1" version "8.10.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.9.1.tgz#2f857f46c47e91dcd28a14e052482eb14cfd65a5" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.1.tgz#77da0366ff8afbe733596361d2df9a60fc9c9bd3"
integrity sha512-yrq6ODsxEFTLz0R3BX2myf0WBCSQh9A+py8PBo1dCzWIOcvisbyH6akNKqDHMgXePF2kir5mm5JXJTH3OUJYOQ== integrity sha512-bdNz1L4ekHiJul6SHtZWs1ujEKERJnHs4HxN7rjTyyVOFf3HaJ6sLqe6aPG62XTzAB/63pKRh5jTSWL0D7bsvw==
dependencies: dependencies:
arg "^4.1.0" arg "^4.1.0"
diff "^4.0.1" diff "^4.0.1"