From 31b140fe80484542ecb1af6933767fe1eabfbf6c Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 13:22:07 -0500 Subject: [PATCH 1/9] =?UTF-8?q?L'utilisateur=20est=20maintenant=20d=C3=A9c?= =?UTF-8?q?onnect=C3=A9=20lorsque=20sa=20connexion=20est=20expir=C3=A9e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/modules/accounts/services/account.service.ts | 4 +--- src/app/modules/shared/app-state.ts | 7 +++++++ src/app/modules/shared/service/api.service.ts | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/modules/accounts/services/account.service.ts b/src/app/modules/accounts/services/account.service.ts index 572d2ce..6d02458 100644 --- a/src/app/modules/accounts/services/account.service.ts +++ b/src/app/modules/accounts/services/account.service.ts @@ -73,9 +73,7 @@ export class AccountService implements OnDestroy { ) .subscribe({ next: () => { - this.appState.isAuthenticated = false - this.appState.authenticationExpiration = -1 - this.appState.authenticatedEmployee = null + this.appState.resetAuthenticatedEmployee() this.checkAuthenticationStatus() success() }, diff --git a/src/app/modules/shared/app-state.ts b/src/app/modules/shared/app-state.ts index 968559c..772bd25 100644 --- a/src/app/modules/shared/app-state.ts +++ b/src/app/modules/shared/app-state.ts @@ -13,6 +13,13 @@ export class AppState { authenticatedUser$ = new Subject<{ authenticated: boolean, authenticatedUser: Employee }>() serverOnline$ = new Subject() + resetAuthenticatedEmployee() { + this.isAuthenticated = false + this.authenticationExpiration = -1 + this.authenticatedEmployee = null + + } + set isServerOnline(isOnline: boolean) { if (!isOnline) this.authenticatedEmployee = null this.serverOnline$.next(isOnline); diff --git a/src/app/modules/shared/service/api.service.ts b/src/app/modules/shared/service/api.service.ts index 4d083d7..3deff1e 100644 --- a/src/app/modules/shared/service/api.service.ts +++ b/src/app/modules/shared/service/api.service.ts @@ -7,6 +7,7 @@ import {Router} from '@angular/router' import {map, share, takeUntil} from 'rxjs/operators' import {valueOr} from '../utils/utils' import {ErrorService} from './error.service' +import {AccountService} from '../../accounts/services/account.service' @Injectable({ providedIn: 'root' @@ -77,17 +78,16 @@ export class ApiService implements OnDestroy { console.error('httpOptions need to be specified to use credentials in HTTP methods.') } } else { + this.appState.resetAuthenticatedEmployee() this.navigateToLogin() } } - const result$ = requestOptions.takeFullResponse + return requestOptions.takeFullResponse ? requestFn(httpOptions) .pipe(takeUntil(this._destroy$), share()) : requestFn(httpOptions) .pipe(takeUntil(this._destroy$), map(r => r.body), share()) - - return result$ } private checkAuthenticated(): boolean { From 8ca3516ae6d39189b3a2f084373bbe0fcef4d9ec Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 13:47:29 -0500 Subject: [PATCH 2/9] =?UTF-8?q?La=20couleur=20de=20fond=20=C3=A9tait=20au?= =?UTF-8?q?=20dessus=20de=20certains=20=C3=A9l=C3=A9ments=20et=20emp=C3=AA?= =?UTF-8?q?chait=20de=20cliquer=20ces=20=C3=A9l=C3=A9ments.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige #7 --- src/app/modules/employees/pages/list/list.component.html | 2 +- src/styles.sass | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/app/modules/employees/pages/list/list.component.html b/src/app/modules/employees/pages/list/list.component.html index 670196a..15f11bb 100644 --- a/src/app/modules/employees/pages/list/list.component.html +++ b/src/app/modules/employees/pages/list/list.component.html @@ -48,7 +48,7 @@
+ [@detailExpand]="employee === expandedElement ? 'expanded' : 'collapsed'">
diff --git a/src/styles.sass b/src/styles.sass index 51e8189..5ece4d2 100644 --- a/src/styles.sass +++ b/src/styles.sass @@ -172,12 +172,6 @@ div.empty height: 2.3rem border: solid 1px white - //&.light-mode - // color: black - // width: 2.3rem - // height: 2.3rem - // border: solid 1px black - div position: absolute width: 2rem @@ -196,6 +190,7 @@ div.empty left: 0 background-color: black opacity: 0.05 + z-index: -1 .darker-background position: fixed @@ -205,6 +200,7 @@ div.empty left: 0 background-color: black opacity: 0.4 + z-index: -1 .color-warning color: #fdd835 From abb63a54cf4c3bc9c098c0fec8d3835a845e5c59 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 13:58:57 -0500 Subject: [PATCH 3/9] =?UTF-8?q?La=20liste=20des=20groupes=20affiche=20main?= =?UTF-8?q?tenant=20les=20permission=20du=20groupe=20dans=20ces=20d=C3=A9t?= =?UTF-8?q?ails.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/groups/pages/list/list.component.html | 3 ++- .../permissions-list.component.html | 2 +- .../permissions-list/permissions-list.component.ts | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/modules/groups/pages/list/list.component.html b/src/app/modules/groups/pages/list/list.component.html index 302a5a6..3234e68 100644 --- a/src/app/modules/groups/pages/list/list.component.html +++ b/src/app/modules/groups/pages/list/list.component.html @@ -48,7 +48,8 @@
- + +
diff --git a/src/app/modules/shared/components/permissions-list/permissions-list.component.html b/src/app/modules/shared/components/permissions-list/permissions-list.component.html index 530ebfb..7077bda 100644 --- a/src/app/modules/shared/components/permissions-list/permissions-list.component.html +++ b/src/app/modules/shared/components/permissions-list/permissions-list.component.html @@ -1,5 +1,5 @@
-
+

Permissions

diff --git a/src/app/modules/shared/components/permissions-list/permissions-list.component.ts b/src/app/modules/shared/components/permissions-list/permissions-list.component.ts index 837edd0..7595864 100644 --- a/src/app/modules/shared/components/permissions-list/permissions-list.component.ts +++ b/src/app/modules/shared/components/permissions-list/permissions-list.component.ts @@ -1,13 +1,14 @@ -import {Component, Input, OnInit} from '@angular/core'; -import {Employee, EmployeePermission, mapped_permissions} from "../../model/employee"; +import {Component, Input, OnInit} from '@angular/core' +import {Employee, EmployeeGroup, EmployeePermission, mapped_permissions} from '../../model/employee' @Component({ selector: 'cre-permissions-list', templateUrl: './permissions-list.component.html', styleUrls: ['./permissions-list.component.sass'] }) -export class PermissionsListComponent implements OnInit { +export class PermissionsListComponent { @Input() employee: Employee + @Input() group: EmployeeGroup // @ts-ignore private _permissions = Object.values(mapped_permissions).flatMap(p => p) @@ -15,10 +16,11 @@ export class PermissionsListComponent implements OnInit { constructor() { } - ngOnInit(): void { + get permissions(): EmployeePermission[] { + return this.filterPermissions(this.employee ? this.employee.permissions : this.group.permissions) } - get permissions(): EmployeePermission[] { - return this._permissions.filter(p => this.employee.permissions.indexOf(p.permission) >= 0).map(p => p.description) + private filterPermissions(permissions: EmployeePermission[]) { + return this._permissions.filter(p => permissions.indexOf(p.permission) >= 0).map(p => p.description) } } From ada99b58bc0ee1378c3c71195e19d93ba28ab1fb Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 19:44:10 -0500 Subject: [PATCH 4/9] Ajout d'un padding sous la page pour ne pas couper le contenu long. --- src/app/app.component.html | 2 +- src/app/modules/groups/pages/list/list.component.html | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 00031de..14ce919 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,6 +1,6 @@ -
+
diff --git a/src/app/modules/groups/pages/list/list.component.html b/src/app/modules/groups/pages/list/list.component.html index 3234e68..b3bf546 100644 --- a/src/app/modules/groups/pages/list/list.component.html +++ b/src/app/modules/groups/pages/list/list.component.html @@ -48,7 +48,6 @@
-
From 07a2c44af92fea1638424231ab980709ba154eb1 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 20:03:36 -0500 Subject: [PATCH 5/9] =?UTF-8?q?L'=C3=A9diteur=20de=20m=C3=A9lange=20n'est?= =?UTF-8?q?=20plus=20centr=C3=A9=20verticalement=20pour=20emp=C3=AAcher=20?= =?UTF-8?q?les=20m=C3=A9langes=20de=20sortir=20de=20la=20page=20lorsqu'il?= =?UTF-8?q?=20y=20a=20trop=20d'ingr=C3=A9dients.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../colors/components/mix-editor/mix-editor.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/colors/components/mix-editor/mix-editor.component.html b/src/app/modules/colors/components/mix-editor/mix-editor.component.html index 3c5f35e..f5c2d65 100644 --- a/src/app/modules/colors/components/mix-editor/mix-editor.component.html +++ b/src/app/modules/colors/components/mix-editor/mix-editor.component.html @@ -1,4 +1,4 @@ - + Création d'un mélange pour la recette {{recipe.company.name}} - {{recipe.name}} From 3d7bb13d20d0f319db789fa655dec09d697eab6a Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 20:19:48 -0500 Subject: [PATCH 6/9] =?UTF-8?q?Les=20m=C3=A9langes,=20=C3=A9tapes=20et=20i?= =?UTF-8?q?mages=20d'une=20recette=20ne=20s'affichent=20plus=20lorsqu'ils?= =?UTF-8?q?=20sont=20vide=20dans=20l'explorateur.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit De plus un avertissement s'affiche lorsque la recette n'a pas de mélange ou d'étape. --- .../components/images-editor/images-editor.component.html | 2 +- .../components/images-editor/images-editor.component.ts | 6 ++++++ src/app/modules/colors/pages/explore/explore.component.html | 4 ++-- src/app/modules/colors/pages/explore/explore.component.ts | 4 ++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/modules/colors/components/images-editor/images-editor.component.html b/src/app/modules/colors/components/images-editor/images-editor.component.html index 4408b14..c738cd5 100644 --- a/src/app/modules/colors/components/images-editor/images-editor.component.html +++ b/src/app/modules/colors/components/images-editor/images-editor.component.html @@ -1,4 +1,4 @@ - + Images diff --git a/src/app/modules/colors/components/images-editor/images-editor.component.ts b/src/app/modules/colors/components/images-editor/images-editor.component.ts index c53a23b..42c4499 100644 --- a/src/app/modules/colors/components/images-editor/images-editor.component.ts +++ b/src/app/modules/colors/components/images-editor/images-editor.component.ts @@ -18,6 +18,7 @@ export class ImagesEditorComponent extends SubscribingComponent { imageIds$: Observable backendUrl = environment.apiUrl + hasImages = false constructor( private recipeImageService: RecipeImageService, @@ -32,6 +33,11 @@ export class ImagesEditorComponent extends SubscribingComponent { super.ngOnInit() this.loadImagesIds() + this.subscribe( + this.imageIds$, + ids => this.hasImages = ids.length > 0, + 1 + ) } submit(event) { diff --git a/src/app/modules/colors/pages/explore/explore.component.html b/src/app/modules/colors/pages/explore/explore.component.html index 9ee5eec..89b077b 100644 --- a/src/app/modules/colors/pages/explore/explore.component.html +++ b/src/app/modules/colors/pages/explore/explore.component.html @@ -24,7 +24,7 @@
-
+
-
+
diff --git a/src/app/modules/colors/pages/explore/explore.component.ts b/src/app/modules/colors/pages/explore/explore.component.ts index 610f44c..5f68076 100644 --- a/src/app/modules/colors/pages/explore/explore.component.ts +++ b/src/app/modules/colors/pages/explore/explore.component.ts @@ -50,6 +50,10 @@ export class ExploreComponent extends ErrorHandlingComponent { r => { this.recipe = r this.note = r.note + + if (this.recipe.mixes.length <= 0 || this.recipe.steps.length <= 0) { + this.alertService.pushWarning("Cette recette n'est pas complète") + } }, '/colors/list' ) From 7d85053d81a793413103dcad18a98eee3b6bdf56 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 20:27:55 -0500 Subject: [PATCH 7/9] =?UTF-8?q?Correction=20de=20la=20cr=C3=A9ation=20d'un?= =?UTF-8?q?=20employ=C3=A9=20qui=20n'avait=20pas=20le=20bon=20nom=20pour?= =?UTF-8?q?=20le=20groupe=20dans=20le=20corps=20de=20la=20requ=C3=AAte.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige #12 --- src/app/modules/employees/services/employee.service.ts | 2 +- .../permissions-field/permissions-field.component.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/modules/employees/services/employee.service.ts b/src/app/modules/employees/services/employee.service.ts index 1303068..9fc7c1c 100644 --- a/src/app/modules/employees/services/employee.service.ts +++ b/src/app/modules/employees/services/employee.service.ts @@ -21,7 +21,7 @@ export class EmployeeService { } save(id: number, firstName: string, lastName: string, password: string, group: number, permissions: EmployeePermission[]): Observable { - const employee = {id, firstName, lastName, password, group, permissions} + const employee = {id, firstName, lastName, password, groupId: group, permissions} return this.api.post('/employee', employee) } diff --git a/src/app/modules/shared/components/permissions-field/permissions-field.component.html b/src/app/modules/shared/components/permissions-field/permissions-field.component.html index 21e6656..cf7ef40 100644 --- a/src/app/modules/shared/components/permissions-field/permissions-field.component.html +++ b/src/app/modules/shared/components/permissions-field/permissions-field.component.html @@ -6,7 +6,7 @@
- Un group doit avoir au moins une permission + Vous devez sélectionner au moins une permission
Date: Sat, 13 Mar 2021 20:32:55 -0500 Subject: [PATCH 8/9] =?UTF-8?q?Employ=C3=A9=20->=20Utilisateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/modules/employees/pages/add/add.component.html | 2 +- src/app/modules/employees/pages/edit/edit.component.html | 2 +- .../pages/password-edit/password-edit.component.html | 2 +- src/app/modules/groups/pages/list/list.component.html | 2 +- .../modules/shared/components/header/header.component.ts | 2 +- src/app/modules/shared/model/employee.ts | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/modules/employees/pages/add/add.component.html b/src/app/modules/employees/pages/add/add.component.html index 951e943..6c528f7 100644 --- a/src/app/modules/employees/pages/add/add.component.html +++ b/src/app/modules/employees/pages/add/add.component.html @@ -1,6 +1,6 @@ - Création d'un employé + Création d'un utilisateur
diff --git a/src/app/modules/employees/pages/edit/edit.component.html b/src/app/modules/employees/pages/edit/edit.component.html index 73bc07f..9cec7fb 100644 --- a/src/app/modules/employees/pages/edit/edit.component.html +++ b/src/app/modules/employees/pages/edit/edit.component.html @@ -1,6 +1,6 @@ - Modification de l'employé #{{employee.id}} + Modification de l'utilisateur #{{employee.id}} diff --git a/src/app/modules/employees/pages/password-edit/password-edit.component.html b/src/app/modules/employees/pages/password-edit/password-edit.component.html index 31c1aa6..8f2d735 100644 --- a/src/app/modules/employees/pages/password-edit/password-edit.component.html +++ b/src/app/modules/employees/pages/password-edit/password-edit.component.html @@ -1,7 +1,7 @@ - Modification du mot de passe de l'employé #{{employee.id}} + Modification du mot de passe de l'utilisateur #{{employee.id}} diff --git a/src/app/modules/groups/pages/list/list.component.html b/src/app/modules/groups/pages/list/list.component.html index b3bf546..be59f51 100644 --- a/src/app/modules/groups/pages/list/list.component.html +++ b/src/app/modules/groups/pages/list/list.component.html @@ -12,7 +12,7 @@ {{group.permissions.length}} - Nombre d'employés + Nombre d'utilisateurs {{group.employeeCount}} diff --git a/src/app/modules/shared/components/header/header.component.ts b/src/app/modules/shared/components/header/header.component.ts index 469c697..9e256bb 100644 --- a/src/app/modules/shared/components/header/header.component.ts +++ b/src/app/modules/shared/components/header/header.component.ts @@ -15,7 +15,7 @@ export class HeaderComponent extends SubscribingComponent { links: HeaderLink[] = [ {route: '/color', title: 'Couleurs', requiredPermission: EmployeePermission.VIEW_RECIPE}, {route: '/catalog', title: 'Catalogue', enabled: true}, - {route: '/employee', title: 'Employés', requiredPermission: EmployeePermission.VIEW_EMPLOYEE}, + {route: '/employee', title: 'Utilisateurs', requiredPermission: EmployeePermission.VIEW_EMPLOYEE}, {route: '/group', title: 'Groupes', requiredPermission: EmployeePermission.VIEW_EMPLOYEE_GROUP}, {route: '/account/login', title: 'Connexion', enabled: true}, {route: '/account/logout', title: 'Déconnexion', enabled: false}, diff --git a/src/app/modules/shared/model/employee.ts b/src/app/modules/shared/model/employee.ts index a4db062..711e30b 100644 --- a/src/app/modules/shared/model/employee.ts +++ b/src/app/modules/shared/model/employee.ts @@ -65,7 +65,7 @@ export const mapped_permissions = { description: 'Voir', impliedPermissions: [EmployeePermission.VIEW_MATERIAL, EmployeePermission.VIEW_MATERIAL_TYPE, EmployeePermission.VIEW_COMPANY, EmployeePermission.VIEW_RECIPE] }, - {permission: EmployeePermission.VIEW_EMPLOYEE, description: 'Voir les employés', impliedPermissions: []}, + {permission: EmployeePermission.VIEW_EMPLOYEE, description: 'Voir les utilisateurs', impliedPermissions: []}, {permission: EmployeePermission.VIEW_EMPLOYEE_GROUP, description: 'Voir les groupes', impliedPermissions: []}, ], edit: [ @@ -96,7 +96,7 @@ export const mapped_permissions = { }, { permission: EmployeePermission.EDIT_EMPLOYEE, - description: 'Modifier les employés', + description: 'Modifier les utilisateurs', impliedPermissions: [EmployeePermission.VIEW_EMPLOYEE] }, { @@ -138,7 +138,7 @@ export const mapped_permissions = { }, { permission: EmployeePermission.REMOVE_EMPLOYEE, - description: 'Supprimer des employés', + description: 'Supprimer des utilisateurs', impliedPermissions: [EmployeePermission.EDIT_EMPLOYEE] }, { From e0a6dfffaef64a6f84958ed844da223dc8f42838 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Mar 2021 20:41:31 -0500 Subject: [PATCH 9/9] =?UTF-8?q?L'onglet=20catalogue=20ne=20s'affiche=20plu?= =?UTF-8?q?s=20lorsque=20l'utilisateur=20n'a=20pas=20les=20permissions=20n?= =?UTF-8?q?=C3=A9cessaires.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/header/header.component.html | 16 +++++++++------- .../shared/components/header/header.component.ts | 6 ++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/modules/shared/components/header/header.component.html b/src/app/modules/shared/components/header/header.component.html index 20bda30..8c37227 100644 --- a/src/app/modules/shared/components/header/header.component.html +++ b/src/app/modules/shared/components/header/header.component.html @@ -3,13 +3,15 @@
diff --git a/src/app/modules/shared/components/header/header.component.ts b/src/app/modules/shared/components/header/header.component.ts index 9e256bb..9f3585f 100644 --- a/src/app/modules/shared/components/header/header.component.ts +++ b/src/app/modules/shared/components/header/header.component.ts @@ -12,6 +12,8 @@ import {ErrorService} from '../../service/error.service' styleUrls: ['./header.component.sass'] }) export class HeaderComponent extends SubscribingComponent { + catalogEnabled = false + links: HeaderLink[] = [ {route: '/color', title: 'Couleurs', requiredPermission: EmployeePermission.VIEW_RECIPE}, {route: '/catalog', title: 'Catalogue', enabled: true}, @@ -81,6 +83,10 @@ export class HeaderComponent extends SubscribingComponent { l.enabled = employee && employee.permissions.indexOf(l.requiredPermission) >= 0 } }) + + this.catalogEnabled = this.accountService.hasPermission(EmployeePermission.VIEW_MATERIAL_TYPE) || + this.accountService.hasPermission(EmployeePermission.VIEW_MATERIAL) || + this.accountService.hasPermission(EmployeePermission.VIEW_COMPANY) } private link(route: string) {