diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 16e2056..7a4fe40 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,6 +1,7 @@ -import {NgModule} from '@angular/core'; -import {Routes, RouterModule} from '@angular/router'; -import {CatalogComponent} from "./pages/catalog/catalog.component"; +import {NgModule} from '@angular/core' +import {Routes, RouterModule} from '@angular/router' +import {CatalogComponent} from './pages/catalog/catalog.component' +import {AdministrationComponent} from './pages/administration/administration.component' const routes: Routes = [{ @@ -9,39 +10,46 @@ const routes: Routes = [{ }, { path: 'account', loadChildren: () => import('./modules/accounts/accounts.module').then(m => m.AccountsModule) -}, { - path: 'employee', - loadChildren: () => import('./modules/employees/employees.module').then(m => m.EmployeesModule) -}, { - path: 'group', - loadChildren: () => import('./modules/groups/groups.module').then(m => m.GroupsModule) }, { path: 'catalog', component: CatalogComponent, + children: [{ + path: 'materialtype', + loadChildren: () => import('./modules/material-type/material-type.module').then(m => m.MaterialTypeModule), + }, { + path: 'material', + loadChildren: () => import('./modules/material/material.module').then(m => m.MaterialModule) + }, { + path: 'company', + loadChildren: () => import('./modules/company/company.module').then(m => m.CompanyModule) + }, { + path: '', + pathMatch: 'full', + redirectTo: 'materialtype' + }] +}, { + path: 'admin', + component: AdministrationComponent, children: [ { - path: 'materialtype', - loadChildren: () => import('./modules/material-type/material-type.module').then(m => m.MaterialTypeModule), - }, - { - path: 'material', - loadChildren: () => import('./modules/material/material.module').then(m => m.MaterialModule) - }, - { - path: 'company', - loadChildren: () => import('./modules/company/company.module').then(m => m.CompanyModule) - }, - { + path: 'user', + loadChildren: () => import('./modules/users/user.module').then(m => m.UserModule) + }, { + path: 'group', + loadChildren: () => import('./modules/groups/group.module').then(m => m.GroupModule) + }, { path: '', pathMatch: 'full', - redirectTo: 'materialtype' + redirectTo: 'user' } ] -}, - {path: 'material', loadChildren: () => import('./modules/material/material.module').then(m => m.MaterialModule)}]; +}, { + path: 'material', + loadChildren: () => import('./modules/material/material.module').then(m => m.MaterialModule) +}] @NgModule({ - imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })], + imports: [RouterModule.forRoot(routes, {relativeLinkResolution: 'legacy'})], exports: [RouterModule] }) export class AppRoutingModule { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 323f08e..09374d6 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,11 +8,13 @@ import {SharedModule} from "./modules/shared/shared.module"; import {BrowserAnimationsModule} from "@angular/platform-browser/animations"; import {CatalogComponent} from './pages/catalog/catalog.component'; import {CompanyModule} from './modules/company/company.module'; +import { AdministrationComponent } from './pages/administration/administration.component'; @NgModule({ declarations: [ AppComponent, - CatalogComponent + CatalogComponent, + AdministrationComponent ], imports: [ AppRoutingModule, diff --git a/src/app/modules/accounts/pages/login/login.component.html b/src/app/modules/accounts/pages/login/login.component.html index 4f10431..28aa77c 100644 --- a/src/app/modules/accounts/pages/login/login.component.html +++ b/src/app/modules/accounts/pages/login/login.component.html @@ -5,12 +5,12 @@ - Numéro d'employé + Numéro d'utilisateur person - Un numéro d'employé est requis - Le numéro d'employé doit être un nombre + Un numéro d'utilisateur est requis + Le numéro d'utilisateur doit être un nombre diff --git a/src/app/modules/colors/pages/list/list.component.html b/src/app/modules/colors/pages/list/list.component.html index 7390a47..f30d90d 100644 --- a/src/app/modules/colors/pages/list/list.component.html +++ b/src/app/modules/colors/pages/list/list.component.html @@ -83,7 +83,7 @@ *ngIf="isRecipeApprobationExpired(recipe)" svgIcon="clock-alert" class="color-warning" - title="L'approbation de cette recette est expirée (il y a plus de 4 ans)"> + title="L'approbation de l'échantillon est expirée (il y a plus de 4 ans)"> diff --git a/src/app/modules/employees/employees-routing.module.ts b/src/app/modules/employees/employees-routing.module.ts deleted file mode 100644 index f800e7c..0000000 --- a/src/app/modules/employees/employees-routing.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; - -import { ListComponent } from './pages/list/list.component'; -import {AddComponent} from "./pages/add/add.component"; -import {EditComponent} from "./pages/edit/edit.component"; -import {PasswordEditComponent} from "./pages/password-edit/password-edit.component"; - -const routes: Routes = [{ path: 'list', component: ListComponent }, {path: 'add', component: AddComponent}, {path: 'edit/:id', component: EditComponent}, {path: 'password/edit/:id', component: PasswordEditComponent}, {path: '', redirectTo: 'list'}]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class EmployeesRoutingModule { } diff --git a/src/app/modules/groups/components/employees-list/employees-list.component.html b/src/app/modules/groups/components/employees-list/employees-list.component.html deleted file mode 100644 index f26acaa..0000000 --- a/src/app/modules/groups/components/employees-list/employees-list.component.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - -
Numéro d'employé{{employee.id}}Prénom{{employee.firstName}}Nom{{employee.lastName}} - -
test
- - -
-

Il n'y a aucun employé dans ce groupe

-
-
-
diff --git a/src/app/modules/groups/components/employees-list/employees-list.component.sass b/src/app/modules/groups/components/employees-list/employees-list.component.sass deleted file mode 100644 index cde651d..0000000 --- a/src/app/modules/groups/components/employees-list/employees-list.component.sass +++ /dev/null @@ -1,2 +0,0 @@ -.d-flex - gap: 2rem diff --git a/src/app/modules/groups/components/employees-list/employees-list.component.ts b/src/app/modules/groups/components/employees-list/employees-list.component.ts deleted file mode 100644 index fce4f06..0000000 --- a/src/app/modules/groups/components/employees-list/employees-list.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core' -import {Employee, EmployeeGroup, EmployeePermission} from '../../../shared/model/employee' -import {GroupService} from '../../services/group.service' -import {AccountService} from '../../../accounts/services/account.service' -import {Observable} from 'rxjs' - -@Component({ - selector: 'cre-employees-list', - templateUrl: './employees-list.component.html', - styleUrls: ['./employees-list.component.sass'] -}) -export class EmployeesListComponent implements OnInit { - @Input() group: EmployeeGroup - - employees$: Observable | null - columns = ['id', 'firstName', 'lastName', 'edit'] - - constructor( - private accountService: AccountService, - private groupService: GroupService - ) { - } - - ngOnInit(): void { - this.employees$ = this.groupService.getEmployeesForGroup(this.group.id) - } - - get canEditEmployee(): boolean { - return this.accountService.hasPermission(EmployeePermission.EDIT_USERS) - } -} diff --git a/src/app/modules/groups/group-routing.module.ts b/src/app/modules/groups/group-routing.module.ts new file mode 100644 index 0000000..a3567d3 --- /dev/null +++ b/src/app/modules/groups/group-routing.module.ts @@ -0,0 +1,23 @@ +import {NgModule} from '@angular/core' +import {RouterModule, Routes} from '@angular/router' + +import {ListComponent} from './pages/list/list.component' +import {AddComponent} from './pages/add/add.component' +import {EditComponent} from './pages/edit/edit.component' + +const routes: Routes = [{ + path: 'list', component: ListComponent +}, { + path: 'add', component: AddComponent +}, { + path: 'edit/:id', component: EditComponent +}, { + path: '', redirectTo: 'list' +}] + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class GroupRoutingModule { +} diff --git a/src/app/modules/groups/groups.module.ts b/src/app/modules/groups/group.module.ts similarity index 52% rename from src/app/modules/groups/groups.module.ts rename to src/app/modules/groups/group.module.ts index 75a5f24..7938a5b 100644 --- a/src/app/modules/groups/groups.module.ts +++ b/src/app/modules/groups/group.module.ts @@ -1,18 +1,17 @@ import {NgModule} from '@angular/core'; -import {GroupsRoutingModule} from './groups-routing.module'; +import {GroupRoutingModule} from './group-routing.module'; import {ListComponent} from './pages/list/list.component'; import {SharedModule} from "../shared/shared.module"; import {AddComponent} from './pages/add/add.component'; import {EditComponent} from './pages/edit/edit.component'; -import {EmployeesListComponent} from './components/employees-list/employees-list.component'; @NgModule({ - declarations: [ListComponent, AddComponent, EditComponent, EmployeesListComponent], + declarations: [ListComponent, AddComponent, EditComponent], imports: [ - GroupsRoutingModule, + GroupRoutingModule, SharedModule ] }) -export class GroupsModule { } +export class GroupModule { } diff --git a/src/app/modules/groups/groups-routing.module.ts b/src/app/modules/groups/groups-routing.module.ts deleted file mode 100644 index 5f93f42..0000000 --- a/src/app/modules/groups/groups-routing.module.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule, Routes} from '@angular/router'; - -import {ListComponent} from './pages/list/list.component'; -import {AddComponent} from "./pages/add/add.component"; -import {EditComponent} from "./pages/edit/edit.component"; - -const routes: Routes = [{path: 'list', component: ListComponent}, {path: 'add', component: AddComponent}, {path: 'edit/:id', component: EditComponent}, {path: '', redirectTo: 'list'}]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class GroupsRoutingModule { -} diff --git a/src/app/modules/groups/pages/add/add.component.html b/src/app/modules/groups/pages/add/add.component.html index 3693e17..8b64a53 100644 --- a/src/app/modules/groups/pages/add/add.component.html +++ b/src/app/modules/groups/pages/add/add.component.html @@ -1,6 +1,6 @@ diff --git a/src/app/modules/groups/pages/add/add.component.ts b/src/app/modules/groups/pages/add/add.component.ts index 743c0a2..e632fb9 100644 --- a/src/app/modules/groups/pages/add/add.component.ts +++ b/src/app/modules/groups/pages/add/add.component.ts @@ -57,7 +57,7 @@ export class AddComponent extends ErrorHandlingComponent { if (permissionsField.valid()) { this.subscribeAndNavigate( this.groupService.save(values.name, permissionsField.allEnabledPermissions), - '/group/list' + '/admin/group/list' ) } } diff --git a/src/app/modules/groups/pages/edit/edit.component.html b/src/app/modules/groups/pages/edit/edit.component.html index 4ea243e..9e12e69 100644 --- a/src/app/modules/groups/pages/edit/edit.component.html +++ b/src/app/modules/groups/pages/edit/edit.component.html @@ -1,7 +1,7 @@ error.type === 'notfound-employeegroup-id', - consumer: error => this.urlUtils.navigateTo('/group/list') + consumer: error => this.urlUtils.navigateTo('/admin/group/list') }, { filter: error => error.type === 'exists-employeegroup-name', messageProducer: error => `Un groupe avec le nom '${error.name}' existe déjà` @@ -69,7 +69,7 @@ export class EditComponent extends ErrorHandlingComponent { if (permissionsField.valid()) { this.subscribeAndNavigate( this.groupService.update(this.group.id, values.name, permissionsField.allEnabledPermissions), - '/group/list' + '/admin/group/list' ) } } @@ -77,7 +77,7 @@ export class EditComponent extends ErrorHandlingComponent { delete() { this.subscribeAndNavigate( this.groupService.delete(this.group.id), - '/group/list' + '/admin/group/list' ) } } diff --git a/src/app/modules/groups/pages/list/list.component.html b/src/app/modules/groups/pages/list/list.component.html index 12b7c04..59ea8dc 100644 --- a/src/app/modules/groups/pages/list/list.component.html +++ b/src/app/modules/groups/pages/list/list.component.html @@ -1,5 +1,5 @@ this.isDefaultGroup(group) }, { text: 'Modifier', - linkFn: group => `/group/edit/${group.id}`, + linkFn: group => `/admin/group/edit/${group.id}`, permission: EmployeePermission.EDIT_USERS }] diff --git a/src/app/modules/material-type/material-type-routing.module.ts b/src/app/modules/material-type/material-type-routing.module.ts index 8543072..c9f7e1f 100644 --- a/src/app/modules/material-type/material-type-routing.module.ts +++ b/src/app/modules/material-type/material-type-routing.module.ts @@ -1,28 +1,23 @@ -import {NgModule} from '@angular/core'; -import {RouterModule, Routes} from '@angular/router'; -import {ListComponent} from "./pages/list/list.component"; -import {AddComponent} from "./pages/add/add.component"; -import {EditComponent} from "./pages/edit/edit.component"; +import {NgModule} from '@angular/core' +import {RouterModule, Routes} from '@angular/router' +import {ListComponent} from './pages/list/list.component' +import {AddComponent} from './pages/add/add.component' +import {EditComponent} from './pages/edit/edit.component' -const routes: Routes = [ - { - path: 'list', - component: ListComponent - }, - { - path: 'add', - component: AddComponent - }, - { - path: 'edit/:id', - component: EditComponent - }, - { - path: '', - redirectTo: 'list' - } -]; +const routes: Routes = [{ + path: 'list', + component: ListComponent +}, { + path: 'add', + component: AddComponent +}, { + path: 'edit/:id', + component: EditComponent +}, { + path: '', + redirectTo: 'list' +}] @NgModule({ imports: [RouterModule.forChild(routes)], diff --git a/src/app/modules/shared/components/header/header.component.ts b/src/app/modules/shared/components/header/header.component.ts index 135eeb7..34e2495 100644 --- a/src/app/modules/shared/components/header/header.component.ts +++ b/src/app/modules/shared/components/header/header.component.ts @@ -14,9 +14,8 @@ import {ErrorService} from '../../service/error.service' export class HeaderComponent extends SubscribingComponent { links: HeaderLink[] = [ {route: '/color', title: 'Couleurs', requiredPermission: EmployeePermission.VIEW_RECIPES}, - {route: '/catalog', title: 'Catalogue', enabled: true, requiredPermission: EmployeePermission.VIEW_CATALOG}, - {route: '/employee', title: 'Utilisateurs', requiredPermission: EmployeePermission.VIEW_USERS}, - {route: '/group', title: 'Groupes', requiredPermission: EmployeePermission.VIEW_USERS}, + {route: '/catalog', title: 'Catalogue', requiredPermission: EmployeePermission.VIEW_CATALOG}, + {route: '/admin', title: 'Administration', requiredPermission: EmployeePermission.VIEW_USERS}, {route: '/account/login', title: 'Connexion', enabled: true}, {route: '/account/logout', title: 'Déconnexion', enabled: false}, ] diff --git a/src/app/modules/shared/components/sub-menu/sub-menu.component.ts b/src/app/modules/shared/components/sub-menu/sub-menu.component.ts new file mode 100644 index 0000000..76af681 --- /dev/null +++ b/src/app/modules/shared/components/sub-menu/sub-menu.component.ts @@ -0,0 +1,16 @@ +import {Injectable, OnDestroy, OnInit} from '@angular/core' +import {GlobalAlertHandlerComponent} from '../global-alert-handler/global-alert-handler.component' +import {NavLink} from '../nav/nav.component' + +@Injectable() +export abstract class SubMenuComponent implements OnInit, OnDestroy { + abstract links: NavLink[] + + ngOnInit(): void { + GlobalAlertHandlerComponent.extraTopMarginMultiplier = 1 + } + + ngOnDestroy(): void { + GlobalAlertHandlerComponent.extraTopMarginMultiplier = 0 + } +} diff --git a/src/app/modules/employees/pages/add/add.component.html b/src/app/modules/users/pages/add/add.component.html similarity index 100% rename from src/app/modules/employees/pages/add/add.component.html rename to src/app/modules/users/pages/add/add.component.html diff --git a/src/app/modules/employees/pages/add/add.component.sass b/src/app/modules/users/pages/add/add.component.sass similarity index 100% rename from src/app/modules/employees/pages/add/add.component.sass rename to src/app/modules/users/pages/add/add.component.sass diff --git a/src/app/modules/employees/pages/add/add.component.ts b/src/app/modules/users/pages/add/add.component.ts similarity index 87% rename from src/app/modules/employees/pages/add/add.component.ts rename to src/app/modules/users/pages/add/add.component.ts index 60033cd..44d8a71 100644 --- a/src/app/modules/employees/pages/add/add.component.ts +++ b/src/app/modules/users/pages/add/add.component.ts @@ -1,11 +1,8 @@ -import {Component, ContentChildren, ViewChild, ViewContainerRef} from '@angular/core' +import {Component, ViewChild} from '@angular/core' import {Validators} from '@angular/forms' -import { - currentPermissionsFieldComponent, - PermissionsFieldComponent -} from '../../../shared/components/permissions-field/permissions-field.component' +import {currentPermissionsFieldComponent} from '../../../shared/components/permissions-field/permissions-field.component' import {GroupService} from '../../../groups/services/group.service' -import {EmployeeService} from '../../services/employee.service' +import {UserService} from '../../services/user.service' import {ActivatedRoute, Router} from '@angular/router' import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component' import {ErrorHandler, ErrorService} from '../../../shared/service/error.service' @@ -22,14 +19,14 @@ export class AddComponent extends ErrorHandlingComponent { formFields: FormField[] = [{ name: 'id', - label: 'Numéro d\'employé', + label: 'Numéro d\'utilisateur', icon: 'pound', type: 'number', required: true, validator: Validators.compose([Validators.pattern(new RegExp('^[0-9]+$')), Validators.min(0)]), errorMessages: [ - {conditionFn: errors => errors.required, message: 'Un numéro d\'employé est requis'}, - {conditionFn: errors => errors.pattern, message: 'Le numéro d\'employé doit être un nombre'} + {conditionFn: errors => errors.required, message: 'Un numéro d\'utilisateur est requis'}, + {conditionFn: errors => errors.pattern, message: 'Le numéro d\'utilisateur doit être un nombre'} ] }, { name: 'firstName', @@ -84,7 +81,7 @@ export class AddComponent extends ErrorHandlingComponent { }] constructor( - private employeeService: EmployeeService, + private employeeService: UserService, private groupService: GroupService, errorService: ErrorService, router: Router, @@ -112,7 +109,7 @@ export class AddComponent extends ErrorHandlingComponent { groupId, permissionsField.allEnabledPermissions ), - '/employee/list' + '/admin/user/list' ) } } diff --git a/src/app/modules/employees/pages/edit/edit.component.html b/src/app/modules/users/pages/edit/edit.component.html similarity index 100% rename from src/app/modules/employees/pages/edit/edit.component.html rename to src/app/modules/users/pages/edit/edit.component.html diff --git a/src/app/modules/employees/pages/edit/edit.component.sass b/src/app/modules/users/pages/edit/edit.component.sass similarity index 100% rename from src/app/modules/employees/pages/edit/edit.component.sass rename to src/app/modules/users/pages/edit/edit.component.sass diff --git a/src/app/modules/employees/pages/edit/edit.component.ts b/src/app/modules/users/pages/edit/edit.component.ts similarity index 77% rename from src/app/modules/employees/pages/edit/edit.component.ts rename to src/app/modules/users/pages/edit/edit.component.ts index 97fd9e2..f835a4a 100644 --- a/src/app/modules/employees/pages/edit/edit.component.ts +++ b/src/app/modules/users/pages/edit/edit.component.ts @@ -1,6 +1,6 @@ import {Component, ViewChild} from '@angular/core' import {currentPermissionsFieldComponent} from '../../../shared/components/permissions-field/permissions-field.component' -import {EmployeeService} from '../../services/employee.service' +import {UserService} from '../../services/user.service' import {GroupService} from '../../../groups/services/group.service' import {ActivatedRoute, Router} from '@angular/router' import {Employee} from '../../../shared/model/employee' @@ -21,7 +21,7 @@ export class EditComponent extends ErrorHandlingComponent { employee: Employee | null formFields: FormField[] = [{ name: 'id', - label: 'Numéro d\'employé', + label: 'Numéro d\'utilisateur', icon: 'pound', type: 'number', readonly: true @@ -44,7 +44,7 @@ export class EditComponent extends ErrorHandlingComponent { {conditionFn: errors => errors.required, message: 'Un nom est requis'} ] }, { - name: 'groupId', + name: 'group', label: 'Groupe', icon: 'account-multiple', type: 'select', @@ -60,7 +60,7 @@ export class EditComponent extends ErrorHandlingComponent { errorHandlers: ErrorHandler[] = [{ filter: error => error.type === 'notfound-employee-id', - consumer: error => this.urlUtils.navigateTo('/employee/list') + consumer: error => this.urlUtils.navigateTo('/admin/user/list') }, { filter: error => error.type === 'exists-employee-fullName', messageProducer: error => `Un utilisateur nommé '${error.fullName}' existe déjà` @@ -68,7 +68,7 @@ export class EditComponent extends ErrorHandlingComponent { constructor( private accountService: AccountService, - private employeeService: EmployeeService, + private employeeService: UserService, private groupService: GroupService, errorService: ErrorService, router: Router, @@ -96,26 +96,11 @@ export class EditComponent extends ErrorHandlingComponent { parseInt(values.id), values.firstName, values.lastName, + values.group, permissionsField.allEnabledPermissions ), () => { - // TODO de-comment when backend will be ready - // const group = values.groupId - // if (group >= 0) { - // this.subscribeAndNavigate( - // this.groupService.addEmployeeToGroup(group, this.employee), - // '/employee/list' - // ) - // } else { - // if (this.employee.group) { - // this.subscribeAndNavigate( - // this.groupService.removeEmployeeFromGroup(this.employee), - // '/employee/list' - // ) - // } else { - this.urlUtils.navigateTo('/employee/list') - // } - // } + this.urlUtils.navigateTo('/admin/user/list') } ) } @@ -124,7 +109,7 @@ export class EditComponent extends ErrorHandlingComponent { delete() { this.subscribeAndNavigate( this.employeeService.delete(this.employee.id), - '/employee/list' + '/admin/user/list' ) } } diff --git a/src/app/modules/employees/pages/list/list.component.html b/src/app/modules/users/pages/list/list.component.html similarity index 92% rename from src/app/modules/employees/pages/list/list.component.html rename to src/app/modules/users/pages/list/list.component.html index 1190b10..bb5d917 100644 --- a/src/app/modules/employees/pages/list/list.component.html +++ b/src/app/modules/users/pages/list/list.component.html @@ -1,5 +1,5 @@ columns = [ - {def: 'id', title: 'Numéro d\'employé', valueFn: e => e.id}, + {def: 'id', title: 'Numéro d\'utilisateur', valueFn: e => e.id}, {def: 'name', title: 'Nom', valueFn: e => `${e.firstName} ${e.lastName}`}, {def: 'group', title: 'Groupe', valueFn: e => e.group ? e.group.name : 'Aucun'}, {def: 'permissionCount', title: 'Nombre de permissions', valueFn: e => e.permissions.length}, @@ -32,16 +32,16 @@ export class ListComponent extends ErrorHandlingComponent { ] buttons = [{ text: 'Modifier', - linkFn: employee => `/employee/edit/${employee.id}`, + linkFn: employee => `/admin/user/edit/${employee.id}`, permission: EmployeePermission.EDIT_USERS }, { text: 'Modifier mot de passe', - linkFn: employee => `/employee/password/edit/${employee.id}`, + linkFn: employee => `/admin/user/password/edit/${employee.id}`, permission: EmployeePermission.EDIT_USERS }] constructor( - private employeeService: EmployeeService, + private employeeService: UserService, private accountService: AccountService, errorService: ErrorService, router: Router, diff --git a/src/app/modules/employees/pages/password-edit/password-edit.component.html b/src/app/modules/users/pages/password-edit/password-edit.component.html similarity index 100% rename from src/app/modules/employees/pages/password-edit/password-edit.component.html rename to src/app/modules/users/pages/password-edit/password-edit.component.html diff --git a/src/app/modules/employees/pages/password-edit/password-edit.component.sass b/src/app/modules/users/pages/password-edit/password-edit.component.sass similarity index 100% rename from src/app/modules/employees/pages/password-edit/password-edit.component.sass rename to src/app/modules/users/pages/password-edit/password-edit.component.sass diff --git a/src/app/modules/employees/pages/password-edit/password-edit.component.ts b/src/app/modules/users/pages/password-edit/password-edit.component.ts similarity index 88% rename from src/app/modules/employees/pages/password-edit/password-edit.component.ts rename to src/app/modules/users/pages/password-edit/password-edit.component.ts index 4670eae..65684c8 100644 --- a/src/app/modules/employees/pages/password-edit/password-edit.component.ts +++ b/src/app/modules/users/pages/password-edit/password-edit.component.ts @@ -1,6 +1,6 @@ import {Component} from '@angular/core' import {ErrorHandlingComponent} from '../../../shared/components/subscribing.component' -import {EmployeeService} from '../../services/employee.service' +import {UserService} from '../../services/user.service' import {Employee} from '../../../shared/model/employee' import {ActivatedRoute, Router} from '@angular/router' import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms' @@ -19,11 +19,11 @@ export class PasswordEditComponent extends ErrorHandlingComponent { errorHandlers: ErrorHandler[] = [{ filter: error => error.type === 'notfound-employee-id', - consumer: error => this.urlUtils.navigateTo('/employee/list') + consumer: error => this.urlUtils.navigateTo('/admin/user/list') }] constructor( - private employeeService: EmployeeService, + private employeeService: UserService, private formBuilder: FormBuilder, errorService: ErrorService, router: Router, @@ -49,7 +49,7 @@ export class PasswordEditComponent extends ErrorHandlingComponent { if (this.form.valid) { this.subscribeAndNavigate( this.employeeService.updatePassword(this.employee.id, this.passwordControl.value), - '/employee/list' + '/admin/user/list' ) } } diff --git a/src/app/modules/employees/services/employee.service.ts b/src/app/modules/users/services/user.service.ts similarity index 83% rename from src/app/modules/employees/services/employee.service.ts rename to src/app/modules/users/services/user.service.ts index 9fc7c1c..3047bb6 100644 --- a/src/app/modules/employees/services/employee.service.ts +++ b/src/app/modules/users/services/user.service.ts @@ -6,7 +6,7 @@ import {Observable} from "rxjs"; @Injectable({ providedIn: 'root' }) -export class EmployeeService { +export class UserService { constructor( private api: ApiService ) { @@ -25,8 +25,8 @@ export class EmployeeService { return this.api.post('/employee', employee) } - update(id: number, firstName: string, lastName: string, permissions: EmployeePermission[]): Observable { - const employee = {id, firstName, lastName, permissions} + update(id: number, firstName: string, lastName: string, group: number, permissions: EmployeePermission[]): Observable { + const employee = {id, firstName, lastName, groupId: group, permissions} return this.api.put('/employee', employee) } diff --git a/src/app/modules/users/user-routing.module.ts b/src/app/modules/users/user-routing.module.ts new file mode 100644 index 0000000..19a3c54 --- /dev/null +++ b/src/app/modules/users/user-routing.module.ts @@ -0,0 +1,28 @@ +import {NgModule} from '@angular/core' +import {Routes, RouterModule} from '@angular/router' + +import {ListComponent} from './pages/list/list.component' +import {AddComponent} from './pages/add/add.component' +import {EditComponent} from './pages/edit/edit.component' +import {PasswordEditComponent} from './pages/password-edit/password-edit.component' + +const routes: Routes = [{ + path: 'list', + component: ListComponent +}, { + path: 'add', component: AddComponent +}, { + path: 'edit/:id', + component: EditComponent +}, { + path: 'password/edit/:id', component: PasswordEditComponent +}, { + path: '', redirectTo: 'list' +}] + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class UserRoutingModule { +} diff --git a/src/app/modules/employees/employees.module.ts b/src/app/modules/users/user.module.ts similarity index 81% rename from src/app/modules/employees/employees.module.ts rename to src/app/modules/users/user.module.ts index 47211be..d4d7565 100644 --- a/src/app/modules/employees/employees.module.ts +++ b/src/app/modules/users/user.module.ts @@ -1,6 +1,6 @@ import {NgModule} from '@angular/core'; -import {EmployeesRoutingModule} from './employees-routing.module'; +import {UserRoutingModule} from './user-routing.module'; import {ListComponent} from './pages/list/list.component'; import {SharedModule} from "../shared/shared.module"; import { AddComponent } from './pages/add/add.component'; @@ -12,9 +12,9 @@ import { PasswordEditComponent } from './pages/password-edit/password-edit.compo @NgModule({ declarations: [ListComponent, AddComponent, EditComponent, PasswordEditComponent], imports: [ - EmployeesRoutingModule, + UserRoutingModule, SharedModule, MatSelectModule ] }) -export class EmployeesModule { } +export class UserModule { } diff --git a/src/app/pages/administration/administration.component.html b/src/app/pages/administration/administration.component.html new file mode 100644 index 0000000..2c65c9d --- /dev/null +++ b/src/app/pages/administration/administration.component.html @@ -0,0 +1,2 @@ + + diff --git a/src/app/pages/administration/administration.component.sass b/src/app/pages/administration/administration.component.sass new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/administration/administration.component.ts b/src/app/pages/administration/administration.component.ts new file mode 100644 index 0000000..44683f8 --- /dev/null +++ b/src/app/pages/administration/administration.component.ts @@ -0,0 +1,16 @@ +import {Component} from '@angular/core' +import {SubMenuComponent} from '../../modules/shared/components/sub-menu/sub-menu.component' +import {NavLink} from '../../modules/shared/components/nav/nav.component' +import {EmployeePermission} from '../../modules/shared/model/employee' + +@Component({ + selector: 'cre-administration', + templateUrl: './administration.component.html', + styleUrls: ['./administration.component.sass'] +}) +export class AdministrationComponent extends SubMenuComponent { + links: NavLink[] = [ + {route: '/admin/user', title: 'Utilisateurs', permission: EmployeePermission.VIEW_USERS}, + {route: '/admin/group', title: 'Groupes', permission: EmployeePermission.VIEW_USERS}, + ] +} diff --git a/src/app/pages/catalog/catalog.component.ts b/src/app/pages/catalog/catalog.component.ts index ab3bfe6..30981b0 100644 --- a/src/app/pages/catalog/catalog.component.ts +++ b/src/app/pages/catalog/catalog.component.ts @@ -1,25 +1,17 @@ -import {Component, OnDestroy, OnInit} from '@angular/core' +import {Component} from '@angular/core' import {NavLink} from '../../modules/shared/components/nav/nav.component' import {EmployeePermission} from '../../modules/shared/model/employee' -import {GlobalAlertHandlerComponent} from '../../modules/shared/components/global-alert-handler/global-alert-handler.component' +import {SubMenuComponent} from '../../modules/shared/components/sub-menu/sub-menu.component' @Component({ selector: 'cre-inventory-page', templateUrl: './catalog.component.html', styleUrls: ['./catalog.component.sass'] }) -export class CatalogComponent implements OnInit, OnDestroy { +export class CatalogComponent extends SubMenuComponent { links: NavLink[] = [ {route: '/catalog/materialtype', title: 'Types de produit', permission: EmployeePermission.VIEW_CATALOG}, {route: '/catalog/material', title: 'Inventaire', permission: EmployeePermission.VIEW_CATALOG}, {route: '/catalog/company', title: 'Bannières', permission: EmployeePermission.VIEW_CATALOG} ] - - ngOnInit(): void { - GlobalAlertHandlerComponent.extraTopMarginMultiplier = 1 - } - - ngOnDestroy(): void { - GlobalAlertHandlerComponent.extraTopMarginMultiplier = 0 - } }