From f9b847b305192506b2fc8109f187f6a45afeccd3 Mon Sep 17 00:00:00 2001 From: seraph Date: Tue, 16 Jun 2020 18:40:48 +0200 Subject: [PATCH] replace primeng by material && improvments --- mocks/db.json | 4 +- package.json | 228 ++++++++--------- src/app/app.component.html | 32 +-- .../dev-navbar/dev-navbar.component.html | 52 ++++ .../dev-navbar/dev-navbar.component.scss} | 0 .../dev-navbar/dev-navbar.component.spec.ts} | 12 +- .../dev-navbar/dev-navbar.component.ts | 35 +++ .../components/header/header.component.html | 52 +--- .../components/header/header.component.ts | 26 +- .../core/components/home/home.component.html | 3 + .../navigation/navigation.component.html | 71 ++++-- .../navigation/navigation.component.ts | 15 +- src/app/core/core.module.ts | 10 +- src/app/core/models/configuration.model.ts | 14 +- src/app/core/models/poll.model.ts | 6 +- .../date.service.spec.ts} | 6 +- .../date.service.ts} | 2 +- .../services/message-displayer.service.ts | 19 -- src/app/core/services/mocking.service.ts | 9 +- src/app/core/services/modal.service.ts | 28 +-- src/app/core/services/poll.service.ts | 25 +- ....service.spec.ts => toast.service.spec.ts} | 6 +- src/app/core/services/toast.service.ts | 14 ++ src/app/core/services/user.service.ts | 3 +- .../uuid.service.spec.ts} | 8 +- src/app/core/services/uuid.service.ts | 13 + src/app/core/utils/poll-utils.service.ts | 47 ---- .../administration-routing.module.ts | 28 +-- .../administration.component.html | 29 ++- .../administration.component.ts | 25 +- .../administration/administration.module.ts | 16 +- .../edit-configuration.component.html | 1 - .../edit-configuration.component.spec.ts | 24 -- .../edit-configuration.component.ts | 12 - .../edit-description.component.html | 40 --- .../edit-description.component.spec.ts | 24 -- .../edit-description.component.ts | 41 --- .../edit-options/edit-options.component.html | 1 - .../edit-options/edit-options.component.ts | 12 - .../poll-edit/poll-edit.component.html | 33 --- .../poll-edit/poll-edit.component.scss | 0 .../poll-edit/poll-edit.component.ts | 41 --- .../profile/profile.component.scss | 0 .../stepper/stepper.component.html | 125 ++++++++- .../stepper/stepper.component.ts | 89 ++++--- .../user-polls.component.html} | 0 .../user-polls.component.scss} | 0 .../user-polls.component.spec.ts} | 12 +- .../user-polls.component.ts} | 8 +- .../consultation-routing.module.ts | 2 +- .../consultation/consultation.component.html | 6 +- .../consultation/consultation.component.ts | 3 +- .../poll-results-compact.component.ts | 9 +- .../features/old-stuff/old-stuff.module.ts | 6 +- .../old-stuff/pages/dates/dates.component.ts | 17 +- .../end-confirmation.component.ts | 15 +- .../old-stuff/services/config.service.ts | 63 ++--- .../ui/copy-text/copy-text.component.ts | 11 +- .../add-answer/add-answer.component.html | 14 +- .../add-answer/add-answer.component.ts | 19 +- .../participation.component.html | 6 +- .../participation/participation.component.ts | 3 +- .../choice-details.component.ts | 16 +- .../language-selector.component.html | 2 +- .../theme-selector.component.html | 2 +- .../settings/settings.component.html | 54 ++-- .../components/settings/settings.component.ts | 6 +- .../components/spinner/spinner.component.html | 5 + .../spinner/spinner.component.scss} | 0 .../spinner/spinner.component.spec.ts} | 12 +- .../components/spinner/spinner.component.ts | 8 + src/app/shared/shared.module.ts | 82 +++--- src/index.html | 2 + src/styles.scss | 36 ++- src/theme-contrast.scss | 16 ++ src/theme-dark.scss | 16 ++ src/theme-light.scss | 16 ++ yarn.lock | 238 +++++++++--------- 78 files changed, 996 insertions(+), 990 deletions(-) create mode 100644 src/app/core/components/dev-navbar/dev-navbar.component.html rename src/app/{features/administration/edit-configuration/edit-configuration.component.scss => core/components/dev-navbar/dev-navbar.component.scss} (100%) rename src/app/{features/administration/poll-edit/poll-edit.component.spec.ts => core/components/dev-navbar/dev-navbar.component.spec.ts} (54%) create mode 100644 src/app/core/components/dev-navbar/dev-navbar.component.ts rename src/app/core/{utils/date-utils.service.spec.ts => services/date.service.spec.ts} (62%) rename src/app/core/{utils/date-utils.service.ts => services/date.service.ts} (95%) delete mode 100644 src/app/core/services/message-displayer.service.ts rename src/app/core/services/{message-displayer.service.spec.ts => toast.service.spec.ts} (57%) create mode 100644 src/app/core/services/toast.service.ts rename src/app/core/{utils/poll-utils.service.spec.ts => services/uuid.service.spec.ts} (52%) create mode 100644 src/app/core/services/uuid.service.ts delete mode 100644 src/app/core/utils/poll-utils.service.ts delete mode 100644 src/app/features/administration/edit-configuration/edit-configuration.component.html delete mode 100644 src/app/features/administration/edit-configuration/edit-configuration.component.spec.ts delete mode 100644 src/app/features/administration/edit-configuration/edit-configuration.component.ts delete mode 100644 src/app/features/administration/edit-description/edit-description.component.html delete mode 100644 src/app/features/administration/edit-description/edit-description.component.spec.ts delete mode 100644 src/app/features/administration/edit-description/edit-description.component.ts delete mode 100644 src/app/features/administration/edit-options/edit-options.component.html delete mode 100644 src/app/features/administration/edit-options/edit-options.component.ts delete mode 100644 src/app/features/administration/poll-edit/poll-edit.component.html delete mode 100644 src/app/features/administration/poll-edit/poll-edit.component.scss delete mode 100644 src/app/features/administration/poll-edit/poll-edit.component.ts delete mode 100644 src/app/features/administration/profile/profile.component.scss rename src/app/features/administration/{profile/profile.component.html => user-polls/user-polls.component.html} (100%) rename src/app/features/administration/{edit-description/edit-description.component.scss => user-polls/user-polls.component.scss} (100%) rename src/app/features/administration/{edit-options/edit-options.component.spec.ts => user-polls/user-polls.component.spec.ts} (53%) rename src/app/features/administration/{profile/profile.component.ts => user-polls/user-polls.component.ts} (73%) create mode 100644 src/app/shared/components/spinner/spinner.component.html rename src/app/{features/administration/edit-options/edit-options.component.scss => shared/components/spinner/spinner.component.scss} (100%) rename src/app/{features/administration/profile/profile.component.spec.ts => shared/components/spinner/spinner.component.spec.ts} (55%) create mode 100644 src/app/shared/components/spinner/spinner.component.ts create mode 100644 src/theme-contrast.scss create mode 100644 src/theme-dark.scss create mode 100644 src/theme-light.scss diff --git a/mocks/db.json b/mocks/db.json index a9756ba2..258abf4f 100644 --- a/mocks/db.json +++ b/mocks/db.json @@ -17,7 +17,7 @@ "isMaybeAnswerAvailable": true, "areResultsPublic": true, "dateCreated": "2020-05-17", - "expires": "2020-06-17" + "expires": "2020-12-31" }, "ownerId": 1, "question": "Quelle date pour le picnic ?", @@ -35,7 +35,7 @@ "isMaybeAnswerAvailable": true, "areResultsPublic": true, "dateCreated": "2020-05-17", - "expires": "2020-06-17" + "expires": "2020-11-30" }, "ownerId": 2, "question": "On fait quoi pendant les vacances ?", diff --git a/package.json b/package.json index 65cbb1d9..ef9d01a0 100644 --- a/package.json +++ b/package.json @@ -1,116 +1,116 @@ { - "name": "framadate-funky-frontend", - "version": "1.0.0", - "license": "AGPL-3.0-or-later", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build:prod": "ng build --prod", - "build:prod:stats": "ng build --prod --stats-json", - "build:prod:gitlabpage": "ng build --prod --baseHref=/framadate/funky-framadate-front/", - "build:prod:demobliss": "ng build --prod --baseHref=https://framadate-api.cipherbliss.com", - "test": "jest", - "test:watch": "jest --watch", - "test:ci": "jest --ci", - "lint": "prettier --write \"src/**/*.{js,jsx,ts,tsx,md,html,css,scss}\"", - "e2e": "ng e2e", - "format:check": "prettier --list-different \"src/{app,environments,assets}/**/*{.ts,.js,.json,.css,.scss}\"", - "format:all": "prettier --write \"src/**/*.{js,jsx,ts,tsx,md,html,css,scss}\"", - "trans": "ng xi18n --output-path=src/locale --i18n-locale=fr", - "compodoc": "compodoc -p tsconfig.app.json", - "mock:server": "json-server --port 8000 --watch ./mocks/db.json --routes ./mocks/routes.json", - "start:proxy": "ng serve --proxy-config proxy.conf.json", - "start:proxymock": "concurrently --kill-others \"yarn mock:server\" \"yarn start:proxy\"" - }, - "private": false, - "dependencies": { - "@angular/animations": "^9.1.1", - "@angular/cdk": "^9.2.2", - "@angular/common": "^9.0.7", - "@angular/compiler": "^9.0.7", - "@angular/core": "^9.0.7", - "@angular/forms": "^9.0.7", - "@angular/localize": "^9.1.1", - "@angular/platform-browser": "^9.0.7", - "@angular/platform-browser-dynamic": "^9.0.7", - "@angular/router": "^9.0.7", - "@fullcalendar/core": "^4.4.0", - "@ngx-translate/core": "^12.1.2", - "@ngx-translate/http-loader": "^4.0.0", - "angular-date-value-accessor": "^1.0.2", - "axios": "^0.19.2", - "bulma": "^0.9.0", - "bulma-switch": "^2.0.0", - "chart.js": "^2.9.3", - "fork-awesome": "^1.1.7", - "ng2-charts": "^2.3.0", - "ngx-clipboard": "^13.0.0", - "ngx-markdown": "^9.0.0", - "ngx-webstorage": "^5.0.0", - "primeng": "^9.0.6", - "quill": "^1.3.7", - "rxjs": "^6.5.5", - "rxjs-compat": "^6.5.5", - "tslib": "<2.0.0", - "uuid": "^8.0.0", - "zone.js": "^0.10.3" - }, - "devDependencies": { - "@angular-builders/jest": "^9.0.1", - "@angular-devkit/build-angular": "^0.901.2", - "@angular/cli": "^9.1.2", - "@angular/compiler-cli": "^9.1.1", - "@angular/language-service": "^9.0.7", - "@babel/core": "^7.9.0", - "@babel/preset-env": "^7.9.5", - "@babel/preset-typescript": "^7.9.0", - "@compodoc/compodoc": "^1.1.11", - "@types/jest": "^26.0.0", - "@types/node": "^14.0.1", - "@types/uuid": "^8.0.0", - "@typescript-eslint/eslint-plugin": "^3.0.0", - "@typescript-eslint/parser": "^3.0.0", - "babel-jest": "^26.0.0", - "concurrently": "^5.2.0", - "eslint": "^7.0.0", - "eslint-config-prettier": "^6.11.0", - "eslint-plugin-prettier": "^3.1.3", - "husky": "^4.2.5", - "jest": "^26.0.0", - "jest-environment-jsdom-sixteen": "^1.0.3", - "jest-preset-angular": "^8.1.3", - "json-server": "^0.16.1", - "lint-staged": "^10.1.7", - "prettier": "^2.0.5", - "protractor": "~7.0.0", - "ts-jest": "^26.0.0", - "ts-mockito": "^2.5.0", - "ts-node": "^8.10.1", - "typescript": "<3.9.0" - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, - "lint-staged": { - "src/**/*.{js,jsx,ts,tsx,md,html,css,scss}": [ - "prettier --write", - "git add" - ], - "*.js": [ - "prettier --write" - ] - }, - "jest": { - "preset": "jest-preset-angular", - "setupFilesAfterEnv": [ - "/src/jest.setup.ts" - ], - "testEnvironment": "jest-environment-jsdom-sixteen", - "transform": { - "^.+\\.(ts|html)$": "ts-jest", - "^.+\\.jsx?$": "babel-jest" - } - } + "name": "framadate-funky-frontend", + "version": "1.0.0", + "license": "AGPL-3.0-or-later", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build:prod": "ng build --prod", + "build:prod:stats": "ng build --prod --stats-json", + "build:prod:gitlabpage": "ng build --prod --baseHref=/framadate/funky-framadate-front/", + "build:prod:demobliss": "ng build --prod --baseHref=https://framadate-api.cipherbliss.com", + "test": "jest", + "test:watch": "jest --watch", + "test:ci": "jest --ci", + "lint": "prettier --write \"src/**/*.{js,jsx,ts,tsx,md,html,css,scss}\"", + "e2e": "ng e2e", + "format:check": "prettier --list-different \"src/{app,environments,assets}/**/*{.ts,.js,.json,.css,.scss}\"", + "format:all": "prettier --write \"src/**/*.{js,jsx,ts,tsx,md,html,css,scss}\"", + "trans": "ng xi18n --output-path=src/locale --i18n-locale=fr", + "compodoc": "compodoc -p tsconfig.app.json", + "mock:server": "json-server --port 8000 --watch ./mocks/db.json --routes ./mocks/routes.json", + "start:proxy": "ng serve --proxy-config proxy.conf.json", + "start:proxymock": "concurrently --kill-others \"yarn mock:server\" \"yarn start:proxy\"" + }, + "private": false, + "dependencies": { + "@angular/animations": "^9.1.1", + "@angular/cdk": "^9.2.2", + "@angular/common": "^9.0.7", + "@angular/compiler": "^9.0.7", + "@angular/core": "^9.0.7", + "@angular/forms": "^9.0.7", + "@angular/localize": "^9.1.1", + "@angular/material": "^9.2.4", + "@angular/platform-browser": "^9.0.7", + "@angular/platform-browser-dynamic": "^9.0.7", + "@angular/router": "^9.0.7", + "@fullcalendar/core": "^4.4.0", + "@ngx-translate/core": "^12.1.2", + "@ngx-translate/http-loader": "^5.0.0", + "angular-date-value-accessor": "^1.0.2", + "axios": "^0.19.2", + "bulma": "^0.9.0", + "bulma-switch": "^2.0.0", + "chart.js": "^2.9.3", + "fork-awesome": "^1.1.7", + "ng2-charts": "^2.3.0", + "ngx-clipboard": "^13.0.0", + "ngx-markdown": "^9.0.0", + "ngx-webstorage": "^5.0.0", + "primeng": "^9.0.6", + "quill": "^1.3.7", + "rxjs": "^6.5.5", + "rxjs-compat": "^6.5.5", + "short-unique-id": "^3.0.3", + "tslib": "<2.0.0", + "zone.js": "^0.10.3" + }, + "devDependencies": { + "@angular-builders/jest": "^9.0.1", + "@angular-devkit/build-angular": "^0.901.2", + "@angular/cli": "^9.1.2", + "@angular/compiler-cli": "^9.1.1", + "@angular/language-service": "^9.0.7", + "@babel/core": "^7.9.0", + "@babel/preset-env": "^7.9.5", + "@babel/preset-typescript": "^7.9.0", + "@compodoc/compodoc": "^1.1.11", + "@types/jest": "^26.0.0", + "@types/node": "^14.0.1", + "@typescript-eslint/eslint-plugin": "^3.0.0", + "@typescript-eslint/parser": "^3.0.0", + "babel-jest": "^26.0.0", + "concurrently": "^5.2.0", + "eslint": "^7.0.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-prettier": "^3.1.3", + "husky": "^4.2.5", + "jest": "^26.0.0", + "jest-environment-jsdom-sixteen": "^1.0.3", + "jest-preset-angular": "^8.1.3", + "json-server": "^0.16.1", + "lint-staged": "^10.1.7", + "prettier": "^2.0.5", + "protractor": "~7.0.0", + "ts-jest": "^26.0.0", + "ts-mockito": "^2.5.0", + "ts-node": "^8.10.1", + "typescript": "<3.9.0" + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "src/**/*.{js,jsx,ts,tsx,md,html,css,scss}": [ + "prettier --write", + "git add" + ], + "*.js": [ + "prettier --write" + ] + }, + "jest": { + "preset": "jest-preset-angular", + "setupFilesAfterEnv": [ + "/src/jest.setup.ts" + ], + "testEnvironment": "jest-environment-jsdom-sixteen", + "transform": { + "^.+\\.(ts|html)$": "ts-jest", + "^.+\\.jsx?$": "babel-jest" + } + } } diff --git a/src/app/app.component.html b/src/app/app.component.html index acb5e667..1f3736f5 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,15 +1,19 @@ -
-
- -
- -
- - -
-
+ + + + - - - - + +
+
+ Dev Menu + +
+ +
+ + +
+
+
+
diff --git a/src/app/core/components/dev-navbar/dev-navbar.component.html b/src/app/core/components/dev-navbar/dev-navbar.component.html new file mode 100644 index 00000000..12403cf0 --- /dev/null +++ b/src/app/core/components/dev-navbar/dev-navbar.component.html @@ -0,0 +1,52 @@ + diff --git a/src/app/features/administration/edit-configuration/edit-configuration.component.scss b/src/app/core/components/dev-navbar/dev-navbar.component.scss similarity index 100% rename from src/app/features/administration/edit-configuration/edit-configuration.component.scss rename to src/app/core/components/dev-navbar/dev-navbar.component.scss diff --git a/src/app/features/administration/poll-edit/poll-edit.component.spec.ts b/src/app/core/components/dev-navbar/dev-navbar.component.spec.ts similarity index 54% rename from src/app/features/administration/poll-edit/poll-edit.component.spec.ts rename to src/app/core/components/dev-navbar/dev-navbar.component.spec.ts index a3e3e6f8..50b465b6 100644 --- a/src/app/features/administration/poll-edit/poll-edit.component.spec.ts +++ b/src/app/core/components/dev-navbar/dev-navbar.component.spec.ts @@ -1,19 +1,19 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { PollEditComponent } from './poll-edit.component'; +import { DevNavbarComponent } from './dev-navbar.component'; -describe('PollEditComponent', () => { - let component: PollEditComponent; - let fixture: ComponentFixture; +describe('DevNavbarComponent', () => { + let component: DevNavbarComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [PollEditComponent], + declarations: [DevNavbarComponent], }).compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(PollEditComponent); + fixture = TestBed.createComponent(DevNavbarComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/core/components/dev-navbar/dev-navbar.component.ts b/src/app/core/components/dev-navbar/dev-navbar.component.ts new file mode 100644 index 00000000..93e3e1f5 --- /dev/null +++ b/src/app/core/components/dev-navbar/dev-navbar.component.ts @@ -0,0 +1,35 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Observable } from 'rxjs'; + +import { User } from '../../models/user.model'; +import { ApiService } from '../../services/api.service'; +import { UserService } from '../../services/user.service'; + +@Component({ + selector: 'app-dev-navbar', + templateUrl: './dev-navbar.component.html', + styleUrls: ['./dev-navbar.component.scss'], +}) +export class DevNavbarComponent implements OnInit { + @Input() isSidebarOpened: boolean; + @Output() toggleSidebarEE = new EventEmitter(); + + public _user: Observable = this.userService.user; + + public slugsAvailables: string[] = []; + + constructor(private apiService: ApiService, private userService: UserService) {} + + public ngOnInit(): void { + this.getSlugs(); + } + + public async getSlugs(): Promise { + this.slugsAvailables = await this.apiService.getAllPollsSlugs(); + } + + public toggleSidebarOpening(): void { + this.isSidebarOpened = !this.isSidebarOpened; + this.toggleSidebarEE.emit(this.isSidebarOpened); + } +} diff --git a/src/app/core/components/header/header.component.html b/src/app/core/components/header/header.component.html index 432ec7e3..85520b37 100644 --- a/src/app/core/components/header/header.component.html +++ b/src/app/core/components/header/header.component.html @@ -1,9 +1,7 @@