Parcourir la source

commit modification

placidenduwayo il y a 2 ans
Parent
révision
6bac783d46
45 fichiers modifiés avec 874 ajouts et 335 suppressions
  1. 16
    6
      db_users_projects_companies.json
  2. 2
    2
      src/app/ngrx/msg.state.ts
  3. 28
    1
      src/app/ngrx/projects/effects.project.get.ts
  4. 11
    0
      src/app/ngrx/projects/project.action.types.ts
  5. 35
    1
      src/app/ngrx/projects/projects.actions.ts
  6. 82
    39
      src/app/ngrx/projects/projects.reducer.ts
  7. 1
    1
      src/app/ngrx/users/effects.user.get.search.ts
  8. 1
    1
      src/app/ngrx/users/users.effects.ts
  9. 1
    1
      src/app/pages/base-nav-menu/base-nav-menu.component.html
  10. 4
    1
      src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.html
  11. 18
    2
      src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.ts
  12. 1
    1
      src/app/pages/companies-manager/companies-management/company-update/company-update.component.html
  13. 3
    2
      src/app/pages/companies-manager/companies-manager.module.ts
  14. 124
    128
      src/app/pages/projects-manager/projects-management/project-create/project-create.component.html
  15. 3
    3
      src/app/pages/projects-manager/projects-management/project-nav-bar/project-nav-bar.component.html
  16. 6
    2
      src/app/pages/projects-manager/projects-management/project-nav-bar/project-nav-bar.component.ts
  17. 106
    94
      src/app/pages/projects-manager/projects-management/project-update/project-update.component.html
  18. 15
    4
      src/app/pages/projects-manager/projects-management/project-update/project-update.component.ts
  19. 3
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.css
  20. 47
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.html
  21. 25
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.spec.ts
  22. 17
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.ts
  23. 1
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.css
  24. 20
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.html
  25. 25
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.spec.ts
  26. 27
    0
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.ts
  27. 3
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.css
  28. 52
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.html
  29. 25
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.spec.ts
  30. 16
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.ts
  31. 0
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.css
  32. 15
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.html
  33. 25
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.spec.ts
  34. 28
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.ts
  35. 6
    3
      src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.html
  36. 19
    2
      src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.ts
  37. 1
    1
      src/app/pages/projects-manager/projects-management/projects-management.component.html
  38. 10
    0
      src/app/pages/projects-manager/projects-manager-routing.module.ts
  39. 13
    6
      src/app/pages/projects-manager/projects-manager.module.ts
  40. 0
    23
      src/app/pages/users-manager/users-management/user-nav-bar/user-nav-bar.component.html
  41. 12
    2
      src/app/pages/users-manager/users-management/users-list/users-list.component.html
  42. 24
    6
      src/app/pages/users-manager/users-management/users-list/users-list.component.ts
  43. 1
    1
      src/app/pages/users-manager/users-management/users-management.component.html
  44. 1
    1
      src/app/shared/services/projects.service.ts
  45. 1
    1
      src/app/shared/services/users.service.ts

+ 16
- 6
db_users_projects_companies.json Voir le fichier

@@ -225,9 +225,9 @@
225 225
       "projectName": "Project-3",
226 226
       "priority": 1,
227 227
       "creationDate": "03 06 2022",
228
-      "companyId": 3,
229
-      "description": "Project description for action",
230
-      "userId": 4,
228
+      "companyId": 1,
229
+      "description": "Project of training users to angular",
230
+      "userId": 3,
231 231
       "state": "END"
232 232
     },
233 233
     {
@@ -235,9 +235,9 @@
235 235
       "projectName": "Project-4",
236 236
       "priority": 1,
237 237
       "creationDate": "03 06 2022",
238
-      "companyId": 3,
238
+      "companyId": 4,
239 239
       "description": "Project description for action",
240
-      "userId": 3,
240
+      "userId": 4,
241 241
       "state": "END"
242 242
     },
243 243
     {
@@ -245,10 +245,20 @@
245 245
       "projectName": "Project-5",
246 246
       "priority": 1,
247 247
       "creationDate": "06 07 2022",
248
-      "companyId": 4,
248
+      "companyId": 1,
249 249
       "description": "Project of  creating and training models",
250 250
       "userId": 12,
251 251
       "state": "END"
252
+    },
253
+    {
254
+      "id": 6,
255
+      "projectName": "Project-test",
256
+      "priority": 1,
257
+      "creationDate": "06 08 2022",
258
+      "companyId": 4,
259
+      "description": "project for test adding ",
260
+      "userId": 12,
261
+      "state": "IN PROGRESS"
252 262
     }
253 263
   ]
254 264
 }

+ 2
- 2
src/app/ngrx/msg.state.ts Voir le fichier

@@ -6,9 +6,9 @@ export enum MsgState {
6 6
   FORM_LOADING = 'FORM LOADING',
7 7
   FORM_LOADED = 'FORM LOADED',
8 8
   FORM_LOAD_ERR= 'FORM LOADING ERROR',
9
-  CONFIRM_ADD = 'CONFIRM ADDING OF',
9
+  CONFIRM_ADD = 'CONFIRM ADDING',
10 10
   CONFIRM_UPDATE = 'CONFIRM UPDATE',
11
-  CONFIRM_DEL = 'CONFIRM DELETION OF',
11
+  CONFIRM_DEL = 'CONFIRM DELETION',
12 12
   ADDED = 'SUCCESSFULLY ADDED',
13 13
   EXIST = 'ALREADY EXISTS',
14 14
   UPDATED = ' SUCCESSFULLY UPDATED',

+ 28
- 1
src/app/ngrx/projects/effects.project.get.ts Voir le fichier

@@ -1,6 +1,6 @@
1 1
 import { Project } from './../../shared/models/project/project.model';
2 2
 import { ProjectActionTypes } from './project.action.types';
3
-import { ProjectActionUnion, GetAllProjectsActionSuccess, GetAllProjectsActionError } from './projects.actions';
3
+import { ProjectActionUnion, GetAllProjectsActionSuccess, GetAllProjectsActionError, GetProjectWithUserAssociatedActionSuccess, GetProjectWithUserAssociatedActionError, GetProjectWithCompanyAssociatedActionSuccess, GetProjectWithCompanyAssociatedActionError } from './projects.actions';
4 4
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
5 5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
6 6
 import { ProjectsService } from './../../shared/services/projects.service';
@@ -13,6 +13,7 @@ export class ProjectGet {
13 13
     private projectActions: Actions
14 14
   ) {}
15 15
 
16
+  //get all projects
16 17
   getAllProjectsEffect: Observable<ProjectActionUnion> = createEffect(
17 18
     () => this.projectActions.pipe(
18 19
       ofType(ProjectActionTypes.GET_ALL_PROJECTS),
@@ -24,4 +25,30 @@ export class ProjectGet {
24 25
       })
25 26
     )
26 27
   );
28
+
29
+  //get project with user associated
30
+  getProjectWithUserAssociated: Observable<ProjectActionUnion> = createEffect(
31
+    () => this.projectActions.pipe(
32
+      ofType(ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED),
33
+      mergeMap( (action: ProjectActionUnion)=>{
34
+        return this.projectsService.getProjectWithUserAsociated().pipe(
35
+          map((listAny:any)=> new GetProjectWithUserAssociatedActionSuccess(listAny)),
36
+          catchError(err => of(new GetProjectWithUserAssociatedActionError(err.message)))
37
+        )
38
+      })
39
+    )
40
+  );
41
+
42
+  //get project with company associated
43
+  getProjectWithCompanyAssociated: Observable<ProjectActionUnion> = createEffect(
44
+    () => this.projectActions.pipe(
45
+      ofType(ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED),
46
+      mergeMap( (action: ProjectActionUnion)=>{
47
+        return this.projectsService.getProjectWithCompanyAssociated().pipe(
48
+          map((listAny:any)=> new GetProjectWithCompanyAssociatedActionSuccess(listAny)),
49
+          catchError(err => of(new GetProjectWithCompanyAssociatedActionError(err.message)))
50
+        )
51
+      })
52
+    )
53
+  );
27 54
 }

+ 11
- 0
src/app/ngrx/projects/project.action.types.ts Voir le fichier

@@ -32,4 +32,15 @@ export enum ProjectActionTypes{
32 32
   DELETE_PROJECT = '[Project] DELETE PROJECT',
33 33
   DELETE_PROJECT_SUCCESS = '[Project] DELETE PROJECT SUCCESS',
34 34
   DELETE_PROJECT_ERROR = '[Project] DELETE PROJECT ERROR',
35
+
36
+  // get project with user associated
37
+  GET_PROJECT_WITH_USER_ASSOCIATED = 'GET PROJECT WITH USER ASSOCIATED',
38
+  GET_PROJECT_WITH_USER_ASSOCIATED_SUCCESS = 'GET PROJECT WITH USER ASSOCIATED SUCCESS',
39
+  GET_PROJECT_WITH_USER_ASSOCIATED_ERROR = 'GET PROJECT WITH USER ASSOCIATED ERROR',
40
+
41
+  // get project with company associated
42
+  GET_PROJECT_WITH_COMPANY_ASSOCIATED = 'GET PROJECT WITH COMPANY ASSOCIATED',
43
+  GET_PROJECT_WITH_COMPANY_ASSOCIATED_SUCCESS = 'GET PROJECT WITH COMPANY ASSOCIATED SUCCESS',
44
+  GET_PROJECT_WITH_COMPANY_ASSOCIATED_ERROR = 'GET PROJECT WITH COMPANY ASSOCIATED ERROR',
45
+
35 46
 }

+ 35
- 1
src/app/ngrx/projects/projects.actions.ts Voir le fichier

@@ -97,6 +97,34 @@ export class DeleteProjectActionError implements Action{
97 97
   constructor(public payload: string){}
98 98
 }
99 99
 
100
+// get project with user associated
101
+export class GetProjectWithUserAssociatedAction implements Action{
102
+  type: ProjectActionTypes = ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED;
103
+  constructor(public payload: any){}
104
+}
105
+export class GetProjectWithUserAssociatedActionSuccess implements Action{
106
+  type: ProjectActionTypes = ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED_SUCCESS;
107
+  constructor(public payload: any){}
108
+}
109
+export class GetProjectWithUserAssociatedActionError implements Action{
110
+  type: ProjectActionTypes = ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED_ERROR;
111
+  constructor(public payload: string){}
112
+}
113
+
114
+// get project with company associated
115
+export class GetProjectWithCompanyAssociatedAction implements Action{
116
+  type: ProjectActionTypes = ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED;
117
+  constructor(public payload: any){}
118
+}
119
+export class GetProjectWithCompanyAssociatedActionSuccess implements Action{
120
+  type: ProjectActionTypes = ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED_SUCCESS;
121
+  constructor(public payload: any){}
122
+}
123
+export class GetProjectWithCompanyAssociatedActionError implements Action{
124
+  type: ProjectActionTypes = ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED_ERROR;
125
+  constructor(public payload: string){}
126
+}
127
+
100 128
 export type ProjectActionUnion =
101 129
   | GetAllProjectsAction
102 130
   | GetAllProjectsActionSuccess
@@ -115,4 +143,10 @@ export type ProjectActionUnion =
115 143
   | UpdateProjectWithFormDataActionError
116 144
   | DeleteProjectAction
117 145
   | DeleteProjectActionSuccess
118
-  | DeleteProjectActionError;
146
+  | DeleteProjectActionError
147
+  | GetProjectWithUserAssociatedAction
148
+  | GetProjectWithUserAssociatedActionSuccess
149
+  | GetProjectWithUserAssociatedActionError
150
+  | GetProjectWithCompanyAssociatedAction
151
+  | GetProjectWithCompanyAssociatedActionSuccess
152
+  | GetProjectWithCompanyAssociatedActionError;

+ 82
- 39
src/app/ngrx/projects/projects.reducer.ts Voir le fichier

@@ -11,14 +11,15 @@ const projectInitState: ProjectState = {
11 11
   currentProject: null,
12 12
   projectsList: [],
13 13
   msgState: MsgState.INIT_STATE,
14
-  serverErrorMsg: 'no error massage'
14
+  serverErrorMsg: 'no error massage',
15 15
 };
16 16
 
17 17
 export function projectReducer(
18 18
   state: ProjectState = projectInitState,
19
-  projectAction: Action
19
+  action: Action
20 20
 ): ProjectState {
21
-  switch (projectAction.type) {
21
+
22
+  switch (action.type) {
22 23
     // get all projects action reducer
23 24
     case ProjectActionTypes.GET_ALL_PROJECTS:
24 25
       return {
@@ -30,14 +31,14 @@ export function projectReducer(
30 31
       return {
31 32
         ...state,
32 33
         msgState: MsgState.LOADED,
33
-        projectsList: (<ProjectActionUnion>projectAction).payload,
34
+        projectsList: (<ProjectActionUnion>action).payload,
34 35
       };
35 36
 
36 37
     case ProjectActionTypes.GET_ALL_PROJECTS_ERROR:
37 38
       return {
38 39
         ...state,
39 40
         msgState: MsgState.ERR,
40
-        serverErrorMsg: (<ProjectActionUnion>projectAction).payload,
41
+        serverErrorMsg: (<ProjectActionUnion>action).payload,
41 42
       };
42 43
 
43 44
     // create project form to add action reducer
@@ -58,7 +59,7 @@ export function projectReducer(
58 59
       return {
59 60
         ...state,
60 61
         msgState: MsgState.ERR,
61
-        serverErrorMsg: (<ProjectActionUnion>projectAction).payload,
62
+        serverErrorMsg: (<ProjectActionUnion>action).payload,
62 63
       };
63 64
 
64 65
     //saving project form data
@@ -70,7 +71,7 @@ export function projectReducer(
70 71
       };
71 72
 
72 73
     case ProjectActionTypes.CREATE_PROJECT_FORM_ADD_SUCCESS:
73
-      let createdProject: Project = (<ProjectActionUnion>projectAction).payload;
74
+      let createdProject: Project = (<ProjectActionUnion>action).payload;
74 75
       let projectsListCopy1: Project[] = [...state.projectsList];
75 76
       projectsListCopy1.push(createdProject);
76 77
 
@@ -88,7 +89,7 @@ export function projectReducer(
88 89
       };
89 90
 
90 91
     case ProjectActionTypes.CREATE_PROJECT_FORM_UPDATE_SUCCESS:
91
-      let projectToUpdate: Project = (<ProjectActionUnion>projectAction)
92
+      let projectToUpdate: Project = (<ProjectActionUnion>action)
92 93
         .payload;
93 94
       return {
94 95
         ...state,
@@ -100,7 +101,7 @@ export function projectReducer(
100 101
       return {
101 102
         ...state,
102 103
         msgState: MsgState.FORM_LOAD_ERR,
103
-        serverErrorMsg: (<ProjectActionUnion>projectAction).payload,
104
+        serverErrorMsg: (<ProjectActionUnion>action).payload,
104 105
       };
105 106
 
106 107
     //update project with form data
@@ -112,43 +113,85 @@ export function projectReducer(
112 113
       };
113 114
 
114 115
     case ProjectActionTypes.UPDATE_PROJECT_WITH_FORM_DATA_SUCCESS:
115
-      let updatedProject: Project = (<ProjectActionUnion>projectAction).payload;
116
+      let updatedProject: Project = (<ProjectActionUnion>action).payload;
116 117
       let projectsListCopy2 = [...state.projectsList];
117 118
       projectsListCopy2 = projectsListCopy2.map((project) =>
118 119
         project.id == updatedProject.id ? updatedProject : project
119 120
       );
120 121
 
121
-      return{
122
+      return {
122 123
         ...state,
123 124
         msgState: MsgState.UPDATED,
124
-        projectsList : projectsListCopy2
125
-      }
126
-
127
-      // delete project
128
-      case ProjectActionTypes.DELETE_PROJECT:
129
-        return {
130
-          ...state,
131
-          msgState: MsgState.DELETE
132
-        }
133
-
134
-      case ProjectActionTypes.DELETE_PROJECT_SUCCESS:
135
-        let deletedProject = (<ProjectActionUnion> projectAction).payload;
136
-        let deletedProjectIndex = state.projectsList.indexOf(deletedProject);
137
-        let projectsListCopy3 : Project[] = [...state.projectsList];
138
-        projectsListCopy3 = projectsListCopy3.splice(deletedProjectIndex);
139
-
140
-        return{
141
-          ...state,
142
-          msgState: MsgState.DELETED,
143
-          projectsList: projectsListCopy3
144
-        };
145
-
146
-      case ProjectActionTypes.DELETE_PROJECT_ERROR:
147
-        return{
148
-          ...state,
149
-          msgState: MsgState.ERR,
150
-          serverErrorMsg: (<ProjectActionUnion>projectAction).payload
151
-        };
125
+        projectsList: projectsListCopy2,
126
+      };
127
+
128
+    // delete project
129
+    case ProjectActionTypes.DELETE_PROJECT:
130
+      return {
131
+        ...state,
132
+        msgState: MsgState.DELETE,
133
+      };
134
+
135
+    case ProjectActionTypes.DELETE_PROJECT_SUCCESS:
136
+      let deletedProject = (<ProjectActionUnion>action).payload;
137
+      let deletedProjectIndex = state.projectsList.indexOf(deletedProject);
138
+      let projectsListCopy3: Project[] = [...state.projectsList];
139
+      projectsListCopy3 = projectsListCopy3.splice(deletedProjectIndex);
140
+
141
+      return {
142
+        ...state,
143
+        msgState: MsgState.DELETED,
144
+        projectsList: projectsListCopy3,
145
+      };
146
+
147
+    case ProjectActionTypes.DELETE_PROJECT_ERROR:
148
+      return {
149
+        ...state,
150
+        msgState: MsgState.ERR,
151
+        serverErrorMsg: (<ProjectActionUnion>action).payload,
152
+      };
153
+
154
+    // get project with user associated
155
+    case ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED:
156
+      return {
157
+        ...state,
158
+        msgState: MsgState.LOADING,
159
+      };
160
+
161
+    case ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED_SUCCESS:
162
+      return{
163
+        ...state,
164
+        msgState: MsgState.LOADED,
165
+        projectsList: (<ProjectActionUnion> action).payload
166
+      };
167
+
168
+    case ProjectActionTypes.GET_PROJECT_WITH_USER_ASSOCIATED_ERROR:
169
+      return{
170
+        ...state,
171
+        msgState: MsgState.ERR,
172
+        serverErrorMsg: (<ProjectActionUnion> action).payload
173
+      };
174
+
175
+    // get project with company associated
176
+    case ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED:
177
+      return {
178
+        ...state,
179
+        msgState: MsgState.LOADING,
180
+      };
181
+
182
+    case ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED_SUCCESS:
183
+      return{
184
+        ...state,
185
+        msgState: MsgState.LOADED,
186
+        projectsList: (<ProjectActionUnion> action).payload
187
+      };
188
+
189
+    case ProjectActionTypes.GET_PROJECT_WITH_COMPANY_ASSOCIATED_ERROR:
190
+      return{
191
+        ...state,
192
+        msgState: MsgState.ERR,
193
+        serverErrorMsg: (<ProjectActionUnion> action).payload
194
+      };
152 195
 
153 196
     default:
154 197
       return { ...state };

+ 1
- 1
src/app/ngrx/users/effects.user.get.search.ts Voir le fichier

@@ -58,7 +58,7 @@ export class UserGetSearchEffects {
58 58
     ()=> this.userActions.pipe(
59 59
       ofType(UserActionTypes.GET_USER_S_PROJECTS),
60 60
       mergeMap( (action: UserActionUnion)=>{
61
-        return this.usersService.getUser_sProjects().pipe(
61
+        return this.usersService.getUser_s_Projects().pipe(
62 62
           map( (users: any)=> new GetUser_s_ProjectsSuccess(users)),
63 63
           catchError(err => of(new GetUser_s_ProjectsError(err.message)))
64 64
         )

+ 1
- 1
src/app/ngrx/users/users.effects.ts Voir le fichier

@@ -77,7 +77,7 @@ export class UsersEffects {
77 77
     this.userActions.pipe(
78 78
       ofType(UserActionTypes.GET_USER_S_PROJECTS),
79 79
       mergeMap((action: UserActionUnion) => {
80
-        return this.usersService.getUser_sProjects().pipe(
80
+        return this.usersService.getUser_s_Projects().pipe(
81 81
           map((users: any) => new GetUser_s_ProjectsSuccess(users)),
82 82
           catchError((err) => of(new GetUser_s_ProjectsError(err.message)))
83 83
         );

+ 1
- 1
src/app/pages/base-nav-menu/base-nav-menu.component.html Voir le fichier

@@ -1,5 +1,5 @@
1 1
 <mat-sidenav-container class="sidenav-container">
2
-  <mat-sidenav #drawer class="sidenav" fixedInViewport
2
+  <mat-sidenav #drawer class="sidenav bg-light" fixedInViewport
3 3
       [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
4 4
       [mode]="(isHandset$ | async) ? 'over' : 'side'"
5 5
       [opened]="(isHandset$ | async) === false">

+ 4
- 1
src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.html Voir le fichier

@@ -1,10 +1,12 @@
1 1
 <div class="container">
2
-  <div *ngIf="inputCompaniesList && inputCompaniesList.length>0">
2
+  <div *ngIf="inputCompaniesList">
3 3
     <input
4 4
       type="text"
5 5
       class="form-control"
6 6
       id="search"
7 7
       placeholder="search a company by name"
8
+      [(ngModel)]="companyName"
9
+      (ngModelChange)="onSearch()"
8 10
     />
9 11
   </div>
10 12
 
@@ -12,6 +14,7 @@
12 14
   <p-table
13 15
     [value]="inputCompaniesList"
14 16
     responsiveLayout="scroll"
17
+    *ngIf="inputCompaniesList.length>0"
15 18
     styleClass="p-datatable-striped"
16 19
     [paginator]="true"
17 20
     [rows]="4"

+ 18
- 2
src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.ts Voir le fichier

@@ -1,5 +1,5 @@
1 1
 import { MsgState } from 'src/app/ngrx/msg.state';
2
-import { DeleteCompany } from './../../../../ngrx/companies/companies.actions';
2
+import { DeleteCompany, GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
3 3
 import { CompanyState } from './../../../../ngrx/companies/company.state';
4 4
 import { Router } from '@angular/router';
5 5
 import { Component, Input, OnInit } from '@angular/core';
@@ -27,9 +27,25 @@ export class CompaniesListComponent implements OnInit {
27 27
   }
28 28
 
29 29
   onCompanyDelete(company: Company) {
30
-    if(window.confirm(this.msgState.CONFIRM_DEL)){
30
+    if (window.confirm(this.msgState.CONFIRM_DEL)) {
31 31
       this.store.dispatch(new DeleteCompany(company));
32 32
     }
33 33
   }
34 34
 
35
+  companyName!: string;
36
+
37
+  onSearch() {
38
+    if(this.companyName==''){
39
+      this.store.dispatch(new GetAllCompaniesAction({})); //to refresh list
40
+    }
41
+    else{
42
+      this.inputCompaniesList = this.inputCompaniesList.filter(
43
+        (company: Company) => {
44
+          return company.companyName
45
+            .toLocaleLowerCase()
46
+            .match(this.companyName.toLocaleLowerCase());
47
+        }
48
+      );
49
+    }
50
+  }
35 51
 }

+ 1
- 1
src/app/pages/companies-manager/companies-management/company-update/company-update.component.html Voir le fichier

@@ -9,7 +9,7 @@
9 9
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOADED">
10 10
 
11 11
     <div class="card mt-3" style="width: 18rem">
12
-      <div class="card-header">Update company informations</div>
12
+      <div class="card-header">Company informations to update</div>
13 13
 
14 14
       <div class="card-body">
15 15
         <form [formGroup]="companyFormGroup"

+ 3
- 2
src/app/pages/companies-manager/companies-manager.module.ts Voir le fichier

@@ -1,4 +1,4 @@
1
-import { ReactiveFormsModule } from '@angular/forms';
1
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
2 2
 import { TableModule } from 'primeng/table';
3 3
 import { ButtonModule } from 'primeng/button';
4 4
 import { NgModule } from '@angular/core';
@@ -25,7 +25,8 @@ import { CompanyUpdateComponent } from './companies-management/company-update/co
25 25
     CompaniesManagerRoutingModule,
26 26
     ButtonModule,
27 27
     TableModule,
28
-    ReactiveFormsModule
28
+    ReactiveFormsModule,
29
+    FormsModule
29 30
   ]
30 31
 })
31 32
 export class CompaniesManagerModule { }

+ 124
- 128
src/app/pages/projects-manager/projects-management/project-create/project-create.component.html Voir le fichier

@@ -12,143 +12,139 @@
12 12
       <!-- create form -->
13 13
       <div class="card mt-3">
14 14
         <div class="card-header bg-light">
15
-          <b>Informations Card for Project to Create </b>
15
+          <b>Project Informations to Create </b>
16 16
         </div>
17 17
         <div class="card-body">
18
-
19 18
           <form
20
-        [formGroup]="projectFormGroup"
21
-        (ngSubmit)="onProjectSave(); projectFormGroup.reset()"
22
-      >
23
-        <div class="row">
24
-          <!-- 1ère colonne -->
25
-          <div class="col">
26
-            <div class="col-md-auto mb-3">
27
-              <label for="projectName">Project name</label>
28
-              <input
29
-                type="text"
30
-                formControlName="projectName"
31
-                class="form-control"
32
-                [ngClass]="{
33
-                  'is-invalid':
34
-                    projectFormGroup.controls['projectName'].touched &&
35
-                    !projectFormGroup.controls['projectName'].valid
36
-                }"
37
-              />
38
-              <div class="invalid-feedback">
39
-                <span
40
-                  *ngIf="projectFormGroup.controls['projectName'].errors?.['required']"
41
-                  >required</span
42
-                >
43
-                <span
44
-                  *ngIf="projectFormGroup.controls['projectName'].errors?.['minlength']"
45
-                  >min nbr chars 5</span
46
-                >
47
-                <span
48
-                  *ngIf="projectFormGroup.controls['projectName'].errors?.['maxlength']"
49
-                  >min nbr chars 20</span
50
-                >
19
+            [formGroup]="projectFormGroup"
20
+            (ngSubmit)="onProjectSave(); projectFormGroup.reset()"
21
+          >
22
+            <div class="row">
23
+              <!-- 1ère colonne -->
24
+              <div class="col">
25
+                <div class="col-md-auto mb-3">
26
+                  <label for="projectName">Project name</label>
27
+                  <input
28
+                    type="text"
29
+                    formControlName="projectName"
30
+                    class="form-control"
31
+                    [ngClass]="{
32
+                      'is-invalid':
33
+                        projectFormGroup.controls['projectName'].touched &&
34
+                        !projectFormGroup.controls['projectName'].valid
35
+                    }"
36
+                  />
37
+                  <div class="invalid-feedback">
38
+                    <span
39
+                      *ngIf="projectFormGroup.controls['projectName'].errors?.['required']"
40
+                      >required</span
41
+                    >
42
+                    <span
43
+                      *ngIf="projectFormGroup.controls['projectName'].errors?.['minlength']"
44
+                      >min nbr chars 5</span
45
+                    >
46
+                    <span
47
+                      *ngIf="projectFormGroup.controls['projectName'].errors?.['maxlength']"
48
+                      >min nbr chars 20</span
49
+                    >
50
+                  </div>
51
+                </div>
52
+
53
+                <div class="col-md-auto mb-3">
54
+                  <label for="priority">Priority</label>
55
+                  <select formControlName="priority" class="form-control">
56
+                    <option value="" disabled>select a priority</option>
57
+                    <option
58
+                      *ngFor="let priority of priorities"
59
+                      [ngValue]="priority"
60
+                    >
61
+                      {{ priority }}
62
+                    </option>
63
+                  </select>
64
+                </div>
65
+
66
+                <div class="col-md-auto mb-3">
67
+                  <label for="companyId">Company ID</label>
68
+                  <select formControlName="companyId" class="form-control">
69
+                    <option value="" disabled>select company ID</option>
70
+                    <option
71
+                      *ngFor="let company of companyState.companiesList"
72
+                      [ngValue]="company.id"
73
+                    >
74
+                      {{ company.id }}
75
+                    </option>
76
+                  </select>
77
+                </div>
51 78
               </div>
52
-            </div>
53
-
54
-            <div class="col-md-auto mb-3">
55
-              <label for="priority">Priority</label>
56
-              <select formControlName="priority" class="form-control">
57
-                <option value="" disabled> select a priority</option>
58
-                <option
59
-                  *ngFor="let priority of priorities"
60
-                  [ngValue]="priority"
61
-                >
62
-                  {{ priority }}
63
-                </option>
64
-              </select>
65
-            </div>
66 79
 
67
-
68
-
69
-
70
-            <div class="col-md-auto mb-3">
71
-              <label for="companyId">Company ID</label>
72
-              <select formControlName="companyId" class="form-control">
73
-                <option value="" disabled>select company ID</option>
74
-                <option
75
-                  *ngFor="let company of companyState.companiesList" [ngValue]="company.id"
76
-
77
-                >
78
-                  {{ company.id }}
79
-                </option>
80
-              </select>
81
-            </div>
82
-          </div>
83
-
84
-          <!-- 2ème colonne -->
85
-          <div class="col">
86
-            <div class="col-md-auto mb-3">
87
-              <label for="description">Description</label>
88
-              <textarea
89
-                type="text"
90
-                formControlName="description"
91
-                class="form-control"
92
-                [ngClass]="{
93
-                  'is-invalid':
94
-                    projectFormGroup.controls['description'].touched &&
95
-                    !projectFormGroup.controls['description'].valid
96
-                }"
97
-
98
-                rows="2"
99
-              ></textarea>
100
-              <div class="invalid-feedback">
101
-                <span
102
-                  *ngIf="projectFormGroup.controls['description'].errors?.['required']"
103
-                  >required</span
104
-                >
105
-                <span
106
-                  *ngIf="projectFormGroup.controls['description'].errors?.['minlength']"
107
-                  >min desc chars 25</span
108
-                >
80
+              <!-- 2ème colonne -->
81
+              <div class="col">
82
+                <div class="col-md-auto mb-3">
83
+                  <label for="description">Description</label>
84
+                  <textarea
85
+                    type="text"
86
+                    formControlName="description"
87
+                    class="form-control"
88
+                    [ngClass]="{
89
+                      'is-invalid':
90
+                        projectFormGroup.controls['description'].touched &&
91
+                        !projectFormGroup.controls['description'].valid
92
+                    }"
93
+                    rows="2"
94
+                  ></textarea>
95
+                  <div class="invalid-feedback">
96
+                    <span
97
+                      *ngIf="projectFormGroup.controls['description'].errors?.['required']"
98
+                      >required</span
99
+                    >
100
+                    <span
101
+                      *ngIf="projectFormGroup.controls['description'].errors?.['minlength']"
102
+                      >min desc chars 25</span
103
+                    >
104
+                  </div>
105
+                </div>
106
+
107
+                <div class="col-md-auto mb-3">
108
+                  <label for="userId">User ID</label>
109
+                  <select formControlName="userId" class="form-control">
110
+                    <option value="" disabled>select user ID</option>
111
+                    <option
112
+                      *ngFor="let user of userState.usersList" [ngValue]="user.id"
113
+                    >
114
+                      {{ user.id }}
115
+                    </option>
116
+                  </select>
117
+                </div>
118
+
119
+                <div class="col-md-auto mb-3">
120
+                  <label for="state">State</label>
121
+                  <select formControlName="state" class="form-control">
122
+                    <option value="" desabled>select project state</option>
123
+                    <option
124
+                      *ngFor="let state of projectMsgState | keyvalue"
125
+                      [ngValue]="state.value"
126
+                    >
127
+                      {{ state.value }}
128
+                    </option>
129
+                  </select>
130
+                </div>
109 131
               </div>
110 132
             </div>
111 133
 
112
-            <div class="col-md-auto mb-3">
113
-              <label for="userId">User ID</label>
114
-              <select formControlName="userId" class="form-control">
115
-                <option value="" disabled>select user ID</option>
116
-                <option *ngFor="let user of userState.usersList" [ngValue]="user.id">
117
-                  {{ user.id }}
118
-                </option>
119
-              </select>
134
+            <div class="text-center col-md-auto mt-3">
135
+              <button
136
+                class="btn btn-outline-primary"
137
+                type="submit"
138
+                [disabled]="!projectFormGroup.valid"
139
+              >
140
+                save
141
+              </button>
142
+              &nbsp;
143
+              <button class="btn btn-outline-primary" type="reset">
144
+                reset
145
+              </button>
120 146
             </div>
121
-
122
-            <div class="col-md-auto mb-3">
123
-              <label for="state">State</label>
124
-              <select formControlName="state" class="form-control">
125
-                <option value="" desabled>
126
-                  select project state
127
-                </option>
128
-                <option
129
-                  *ngFor="let state of projectMsgState | keyvalue"
130
-                  [ngValue]="state.value"
131
-                >
132
-                  {{ state.value }}
133
-                </option>
134
-              </select>
135
-            </div>
136
-          </div>
137
-        </div>
138
-
139
-        <div class="text-center col-md-auto mt-3">
140
-          <button
141
-            class="btn btn-outline-primary"
142
-            type="submit"
143
-            [disabled]="(!projectFormGroup.valid)"
144
-          >
145
-            save
146
-          </button>
147
-          &nbsp;
148
-          <button class="btn btn-outline-primary" type="reset">reset</button>
149
-        </div>
150
-      </form>
151
-
147
+          </form>
152 148
         </div>
153 149
       </div>
154 150
     </ng-container>

+ 3
- 3
src/app/pages/projects-manager/projects-management/project-nav-bar/project-nav-bar.component.html Voir le fichier

@@ -20,9 +20,9 @@
20 20
       <button
21 21
         pButton
22 22
         type="button"
23
-        label="project->user involved"
23
+        label="project-user-associated"
24 24
         class="btn btn-outline-primary"
25
-        (click)="onProjectsVsUsersGet()"
25
+        (click)="onGetProjectWithUserAssociated()"
26 26
       ></button>
27 27
       &nbsp;
28 28
       <button
@@ -30,7 +30,7 @@
30 30
         type="button"
31 31
         label="project->company"
32 32
         class="btn btn-outline-primary"
33
-        (click)="onProjectCompanyAssociated()"
33
+        (click)="onGetProjectWithCompanyAssociated()"
34 34
       ></button>
35 35
     </div>
36 36
   </nav>

+ 6
- 2
src/app/pages/projects-manager/projects-management/project-nav-bar/project-nav-bar.component.ts Voir le fichier

@@ -21,7 +21,11 @@ export class ProjectNavBarComponent {
21 21
     this.store.dispatch(new GetAllProjectsAction({}));
22 22
   }
23 23
 
24
-  onProjectsVsUsersGet() {}
24
+  onGetProjectWithUserAssociated() {
25
+    this.router.navigate(['/project-user-asscociated'])
26
+  }
25 27
 
26
-  onProjectCompanyAssociated() {}
28
+  onGetProjectWithCompanyAssociated() {
29
+    this.router.navigate(['/project-company-asscociated'])
30
+  }
27 31
 }

+ 106
- 94
src/app/pages/projects-manager/projects-management/project-update/project-update.component.html Voir le fichier

@@ -13,7 +13,7 @@
13 13
 
14 14
       <div class="card mt-3">
15 15
         <div class="card-header bg-light">
16
-          >> Project ID: <b>{{ projectState.currentProject?.id }}</b>, User ID:
16
+          Project informations to Update>> Project ID: <b>{{ projectState.currentProject?.id }}</b>, User ID:
17 17
             <b>{{ projectState.currentProject?.userId }}</b>, Company ID:
18 18
             <b>{{ projectState.currentProject?.companyId }}</b>
19 19
 
@@ -23,107 +23,118 @@
23 23
             [formGroup]="projectFormGroup"
24 24
             (ngSubmit)="onProjectUpdate(); projectFormGroup.reset()"
25 25
           >
26
-            <div class="row">
27
-              <!-- 1ère colonne -->
28
-              <div class="col">
29
-                <div class="col-md-auto mb-3">
30
-                  <label for="projectName">Project name</label>
31
-                  <input
32
-                    type="text"
33
-                    formControlName="projectName"
34
-                    class="form-control"
35
-                    [ngClass]="{
36
-                      'is-invalid':
37
-                        projectFormGroup.controls['projectName'].touched &&
38
-                        !projectFormGroup.controls['projectName'].valid
39
-                    }"
40
-                  />
41
-                  <div class="invalid-feedback">
42
-                    <span
43
-                      *ngIf="projectFormGroup.controls['projectName'].errors?.['required']"
44
-                      >required</span
45
-                    >
46
-                    <span
47
-                      *ngIf="projectFormGroup.controls['projectName'].errors?.['minlength']"
48
-                      >min nbr chars 5</span
49
-                    >
50
-                    <span
51
-                      *ngIf="projectFormGroup.controls['projectName'].errors?.['maxlength']"
52
-                      >min nbr chars 20</span
53
-                    >
54
-                  </div>
26
+          <div class="row">
27
+            <!-- 1ère colonne -->
28
+            <div class="col">
29
+              <div class="col-md-auto mb-3">
30
+                <label for="projectName">Project name</label>
31
+                <input
32
+                  type="text"
33
+                  formControlName="projectName"
34
+                  class="form-control"
35
+                  [ngClass]="{
36
+                    'is-invalid':
37
+                      projectFormGroup.controls['projectName'].touched &&
38
+                      !projectFormGroup.controls['projectName'].valid
39
+                  }"
40
+                />
41
+                <div class="invalid-feedback">
42
+                  <span
43
+                    *ngIf="projectFormGroup.controls['projectName'].errors?.['required']"
44
+                    >required</span
45
+                  >
46
+                  <span
47
+                    *ngIf="projectFormGroup.controls['projectName'].errors?.['minlength']"
48
+                    >min nbr chars 5</span
49
+                  >
50
+                  <span
51
+                    *ngIf="projectFormGroup.controls['projectName'].errors?.['maxlength']"
52
+                    >min nbr chars 20</span
53
+                  >
55 54
                 </div>
55
+              </div>
56 56
 
57
-                <div class="col-md-auto mb-3">
58
-                  <label for="priority">Priority</label>
59
-                  <select formControlName="priority" class="form-control">
60
-                    <option value="Choose a priority" disabled>
61
-                      Choose a priority
62
-                    </option>
63
-                    <option
64
-                      *ngFor="let priority of priorities"
65
-                      [ngValue]="priority"
66
-                    >
67
-                      {{ priority }}
68
-                    </option>
69
-                  </select>
70
-                </div>
57
+              <div class="col-md-auto mb-3">
58
+                <label for="priority">Priority</label>
59
+                <select formControlName="priority" class="form-control">
60
+                  <option value="" disabled>select a priority</option>
61
+                  <option
62
+                    *ngFor="let priority of priorities"
63
+                    [ngValue]="priority"
64
+                  >
65
+                    {{ priority }}
66
+                  </option>
67
+                </select>
71 68
               </div>
72 69
 
73
-              <!-- 2ème colonne -->
74
-              <div class="col">
75
-                <div class="col-md-auto mb-3">
76
-                  <label for="description">Description</label>
77
-                  <input
78
-                    type="text"
79
-                    formControlName="description"
80
-                    class="form-control"
81
-                    [ngClass]="{
82
-                      'is-invalid':
83
-                        projectFormGroup.controls['description'].touched &&
84
-                        !projectFormGroup.controls['description'].valid
85
-                    }"
86
-                  />
87
-                  <div class="invalid-feedback">
88
-                    <span
89
-                      *ngIf="projectFormGroup.controls['description'].errors?.['required']"
90
-                      >required</span
91
-                    >
92
-                    <span
93
-                      *ngIf="projectFormGroup.controls['description'].errors?.['minlength']"
94
-                      >min desc chars 25</span
95
-                    >
96
-                  </div>
97
-                </div>
70
+              <div class="col-md-auto mb-3">
71
+                <label for="companyId">Company ID</label>
72
+                <select formControlName="companyId" class="form-control">
73
+                  <option value="" disabled>select company ID</option>
74
+                  <option
75
+                    *ngFor="let company of companySate.companiesList"
76
+                    [ngValue]="company.id"
77
+                  >
78
+                    {{ company.id }}
79
+                  </option>
80
+                </select>
81
+              </div>
82
+            </div>
98 83
 
99
-                <div class="col-md-auto mb-3">
100
-                  <label for="state">State</label>
101
-                  <select formControlName="state" class="form-control">
102
-                    <option
103
-                      *ngFor="let state of projectMsgState | keyvalue"
104
-                      [ngValue]="state.value"
105
-                    >
106
-                      {{ state.value }}
107
-                    </option>
108
-                  </select>
84
+            <!-- 2ème colonne -->
85
+            <div class="col">
86
+              <div class="col-md-auto mb-3">
87
+                <label for="description">Description</label>
88
+                <textarea
89
+                  type="text"
90
+                  formControlName="description"
91
+                  class="form-control"
92
+                  [ngClass]="{
93
+                    'is-invalid':
94
+                      projectFormGroup.controls['description'].touched &&
95
+                      !projectFormGroup.controls['description'].valid
96
+                  }"
97
+                  rows="2"
98
+                ></textarea>
99
+                <div class="invalid-feedback">
100
+                  <span
101
+                    *ngIf="projectFormGroup.controls['description'].errors?.['required']"
102
+                    >required</span
103
+                  >
104
+                  <span
105
+                    *ngIf="projectFormGroup.controls['description'].errors?.['minlength']"
106
+                    >min desc chars 25</span
107
+                  >
109 108
                 </div>
110 109
               </div>
111
-            </div>
112 110
 
113
-            <div class="col-md-auto mb-3">
114
-              <label for="userId"
115
-                >ReAssign project to another user, choose user ID</label
116
-              >
117
-              <select formControlName="userId" class="form-control">
118
-                <option [ngValue]="null" desabled>choose user ID</option>
119
-                <option
120
-                  *ngFor="let user of userState.usersList"
121
-                  [ngValue]="user.id"
122
-                >
123
-                  {{ user.id }}
124
-                </option>
125
-              </select>
111
+              <div class="col-md-auto mb-3">
112
+                <label for="userId">User ID</label>
113
+                <select formControlName="userId" class="form-control">
114
+                  <option value="" disabled>select user ID</option>
115
+                  <option
116
+                    *ngFor="let user of userState.usersList"
117
+                    [ngValue]="user.id"
118
+                  >
119
+                    {{ user.id }}
120
+                  </option>
121
+                </select>
122
+              </div>
123
+
124
+              <div class="col-md-auto mb-3">
125
+                <label for="state">State</label>
126
+                <select formControlName="state" class="form-control">
127
+                  <option value="" desabled>select project state</option>
128
+                  <option
129
+                    *ngFor="let state of projectMsgState | keyvalue"
130
+                    [ngValue]="state.value"
131
+                  >
132
+                    {{ state.value }}
133
+                  </option>
134
+                </select>
135
+              </div>
126 136
             </div>
137
+          </div>
127 138
 
128 139
             <div class="text-center col-md-auto mt-3">
129 140
               <button
@@ -141,8 +152,9 @@
141 152
 
142 153
     <ng-container *ngSwitchCase="msgState.UPDATED">
143 154
       <div class="alert-success container p-3 m-3" style="width: 30em">
155
+        {{ projectState.msgState }}
144 156
         <button class="btn btn-success" (click)="onUpdateOk()">
145
-          {{ projectState.msgState }}
157
+          Ok
146 158
         </button>
147 159
       </div>
148 160
     </ng-container>

+ 15
- 4
src/app/pages/projects-manager/projects-management/project-update/project-update.component.ts Voir le fichier

@@ -1,3 +1,5 @@
1
+import { GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
2
+import { CompanyState } from './../../../../ngrx/companies/company.state';
1 3
 import { UpdateProjectWithFormDataAction } from './../../../../ngrx/projects/projects.actions';
2 4
 import { GetAllUsersAction } from 'src/app/ngrx/users/users.actions';
3 5
 import { UserState } from './../../../../ngrx/users/user.state';
@@ -12,7 +14,6 @@ import { Component, OnInit } from '@angular/core';
12 14
 import { Store } from '@ngrx/store';
13 15
 import { CreateProjectFormUpdateAction } from 'src/app/ngrx/projects/projects.actions';
14 16
 
15
-
16 17
 @Component({
17 18
   selector: 'app-project-update',
18 19
   templateUrl: './project-update.component.html',
@@ -30,6 +31,7 @@ export class ProjectUpdateComponent implements OnInit {
30 31
     private store: Store<{
31 32
       projectReducerKey: ProjectState;
32 33
       userReducerKey: UserState;
34
+      companyReducerKey: CompanyState;
33 35
     }>,
34 36
     private fb: FormBuilder,
35 37
     private router: Router
@@ -48,13 +50,20 @@ export class ProjectUpdateComponent implements OnInit {
48 50
   projectMsgState = ProjectMsgState;
49 51
 
50 52
   userState!: UserState;
53
+  companySate!: CompanyState;
51 54
 
52 55
   ngOnInit(): void {
56
+
53 57
     this.store.dispatch(new GetAllUsersAction({}));
54 58
     this.store
55 59
       .select('userReducerKey')
56 60
       .subscribe((userState) => (this.userState = userState));
57 61
 
62
+    this.store.dispatch(new GetAllCompaniesAction({}));
63
+    this.store.subscribe(
64
+      (companyState) => (this.companySate = companyState.companyReducerKey)
65
+    );
66
+
58 67
     this.projectsService.getProjectById(this.projectId).subscribe((project) => {
59 68
       this.store.dispatch(new CreateProjectFormUpdateAction(project));
60 69
 
@@ -98,9 +107,11 @@ export class ProjectUpdateComponent implements OnInit {
98 107
   }
99 108
 
100 109
   onProjectUpdate() {
101
-    this.store.dispatch(
102
-      new UpdateProjectWithFormDataAction(this.projectFormGroup.value)
103
-    );
110
+    if(window.confirm(this.msgState.CONFIRM_UPDATE)){
111
+      this.store.dispatch(
112
+        new UpdateProjectWithFormDataAction(this.projectFormGroup.value)
113
+      );
114
+    }
104 115
   }
105 116
 
106 117
   onUpdateOk() {

+ 3
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.css Voir le fichier

@@ -0,0 +1,3 @@
1
+ul{
2
+  list-style-type: none;
3
+}

+ 47
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.html Voir le fichier

@@ -0,0 +1,47 @@
1
+<div class="container">
2
+  <p-table
3
+    [value]="inputProjectCompanyAssociated"
4
+    responsiveLayout="scroll"
5
+    styleClass="p-datatable-striped"
6
+    *ngIf="inputProjectCompanyAssociated && inputProjectCompanyAssociated.length > 0"
7
+    [paginator]="true"
8
+    [rows]="4"
9
+    [showCurrentPageReport]="true"
10
+    currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
11
+    [rowsPerPageOptions]="[4, 6, 10]"
12
+  >
13
+    <ng-template pTemplate="header">
14
+      <tr>
15
+        <th>ID</th>
16
+        <th>Name</th>
17
+        <th>Prioriy</th>
18
+        <th>State</th>
19
+        <th>Description</th>
20
+        <th>Company related</th>
21
+        <th>Company ID</th>
22
+        <th>Project User ID</th>
23
+        <th>Creation Date</th>
24
+      </tr>
25
+    </ng-template>
26
+    <ng-template pTemplate="body" let-project>
27
+      <tr>
28
+        <td>{{ project.id }}</td>
29
+        <td>{{ project.projectName }}</td>
30
+        <td>{{ project.priority }}</td>
31
+        <td>{{ project.state }}</td>
32
+        <td>{{ project.description }}</td>
33
+        <td>
34
+          <ul>
35
+            <li>Company ID: {{ project.company.id}}</li>
36
+            <li>Company Name: {{ project.company.companyName}}</li>
37
+            <li>Company Type: {{ project.company.companyType}}</li>
38
+            <li>Creation Date: {{ project.company.creationDate}}</li>
39
+          </ul>
40
+        </td>
41
+        <td>{{ project.companyId }}</td>
42
+        <td>{{ project.userId }}</td>
43
+        <td>{{ project.creationDate | date:'dd MM yyyy' }}</td>
44
+      </tr>
45
+    </ng-template>
46
+  </p-table>
47
+</div>

+ 25
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.spec.ts Voir le fichier

@@ -0,0 +1,25 @@
1
+import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+import { ProjectWithCompanyAssociatedListComponent } from './project-with-company-associated-list.component';
4
+
5
+describe('ProjectWithCompanyAssociatedListComponent', () => {
6
+  let component: ProjectWithCompanyAssociatedListComponent;
7
+  let fixture: ComponentFixture<ProjectWithCompanyAssociatedListComponent>;
8
+
9
+  beforeEach(async () => {
10
+    await TestBed.configureTestingModule({
11
+      declarations: [ ProjectWithCompanyAssociatedListComponent ]
12
+    })
13
+    .compileComponents();
14
+  });
15
+
16
+  beforeEach(() => {
17
+    fixture = TestBed.createComponent(ProjectWithCompanyAssociatedListComponent);
18
+    component = fixture.componentInstance;
19
+    fixture.detectChanges();
20
+  });
21
+
22
+  it('should create', () => {
23
+    expect(component).toBeTruthy();
24
+  });
25
+});

+ 17
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.ts Voir le fichier

@@ -0,0 +1,17 @@
1
+import { Component, Input, OnInit } from '@angular/core';
2
+
3
+@Component({
4
+  selector: 'app-project-with-company-associated-list',
5
+  templateUrl: './project-with-company-associated-list.component.html',
6
+  styleUrls: ['./project-with-company-associated-list.component.css']
7
+})
8
+export class ProjectWithCompanyAssociatedListComponent implements OnInit {
9
+
10
+  constructor() { }
11
+
12
+  @Input() inputProjectCompanyAssociated!: any;
13
+
14
+  ngOnInit(): void {
15
+  }
16
+
17
+}

+ 1
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.css Voir le fichier

@@ -0,0 +1 @@
1
+

+ 20
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.html Voir le fichier

@@ -0,0 +1,20 @@
1
+<div class="container">
2
+  <ng-container
3
+    *ngIf="projectState$ | async as projectState"
4
+    [ngSwitch]="projectState.msgState"
5
+  >
6
+    <ng-container *ngSwitchCase="msgState.LOADING">
7
+      {{ projectState.msgState }}
8
+    </ng-container>
9
+
10
+    <ng-container *ngSwitchCase="msgState.ERR">
11
+      {{ projectState.msgState }}
12
+    </ng-container>
13
+
14
+    <ng-container *ngSwitchCase="msgState.LOADED">
15
+      <app-project-with-company-associated-list
16
+        [inputProjectCompanyAssociated]="projectState.projectsList"
17
+      ></app-project-with-company-associated-list>
18
+    </ng-container>
19
+  </ng-container>
20
+</div>

+ 25
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.spec.ts Voir le fichier

@@ -0,0 +1,25 @@
1
+import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+import { ProjectWithCompanyAssociatedComponent } from './project-with-company-associated.component';
4
+
5
+describe('ProjectWithCompanyAssociatedComponent', () => {
6
+  let component: ProjectWithCompanyAssociatedComponent;
7
+  let fixture: ComponentFixture<ProjectWithCompanyAssociatedComponent>;
8
+
9
+  beforeEach(async () => {
10
+    await TestBed.configureTestingModule({
11
+      declarations: [ ProjectWithCompanyAssociatedComponent ]
12
+    })
13
+    .compileComponents();
14
+  });
15
+
16
+  beforeEach(() => {
17
+    fixture = TestBed.createComponent(ProjectWithCompanyAssociatedComponent);
18
+    component = fixture.componentInstance;
19
+    fixture.detectChanges();
20
+  });
21
+
22
+  it('should create', () => {
23
+    expect(component).toBeTruthy();
24
+  });
25
+});

+ 27
- 0
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated.component.ts Voir le fichier

@@ -0,0 +1,27 @@
1
+import { GetProjectWithCompanyAssociatedAction } from './../../../../ngrx/projects/projects.actions';
2
+import { Observable } from 'rxjs';
3
+import { MsgState } from 'src/app/ngrx/msg.state';
4
+import { ProjectState } from 'src/app/ngrx/projects/project.state';
5
+import { Component, OnInit } from '@angular/core';
6
+import { Store } from '@ngrx/store';
7
+
8
+@Component({
9
+  selector: 'app-project-with-company-associated',
10
+  templateUrl: './project-with-company-associated.component.html',
11
+  styleUrls: ['./project-with-company-associated.component.css']
12
+})
13
+export class ProjectWithCompanyAssociatedComponent implements OnInit {
14
+
15
+  projectState$!: Observable<ProjectState>;
16
+  msgState = MsgState;
17
+
18
+  constructor(private store: Store<{projectReducerKey: ProjectState}>) { }
19
+
20
+  ngOnInit(): void {
21
+
22
+
23
+    this.store.dispatch(new GetProjectWithCompanyAssociatedAction({}));
24
+    this.projectState$= this.store.select('projectReducerKey');
25
+  }
26
+
27
+}

+ 3
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.css Voir le fichier

@@ -0,0 +1,3 @@
1
+ul{
2
+  list-style-type: none;
3
+}

+ 52
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.html Voir le fichier

@@ -0,0 +1,52 @@
1
+<p-table
2
+    [value]="inputProjectsListWithUserAssociated"
3
+    responsiveLayout="scroll"
4
+    styleClass="p-datatable-striped"
5
+    *ngIf="inputProjectsListWithUserAssociated && inputProjectsListWithUserAssociated.length > 0"
6
+    [paginator]="true"
7
+    [rows]="3"
8
+    [showCurrentPageReport]="true"
9
+    currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
10
+    [rowsPerPageOptions]="[3, 5, 10]"
11
+  >
12
+    <ng-template pTemplate="header">
13
+      <tr>
14
+        <th>ID</th>
15
+        <th>Name</th>
16
+        <th>Priority</th>
17
+        <th>Project state</th>
18
+        <th>Company ID</th>
19
+        <th>Description</th>
20
+        <th>Involved user</th>
21
+        <th>User ID</th>
22
+        <th>Creation Date</th>
23
+      </tr>
24
+    </ng-template>
25
+    <ng-template pTemplate="body" let-project>
26
+      <tr>
27
+        <td>{{ project.id }}</td>
28
+        <td>{{ project.projectName }}</td>
29
+        <td>{{ project.priority }}</td>
30
+        <td>{{ project.state }}</td>
31
+        <td>{{ project.companyId }}</td>
32
+        <td>{{ project.description }}</td>
33
+        <td>
34
+          <ul>
35
+            <li>User ID: {{ project.user.id }}</li>
36
+            <li>{{ project.user.firstname }} {{ project.user.lastname }}</li>
37
+            <li>{{ project.user.email }}</li>
38
+            <li>
39
+              {{ project.user.address.numRue }}
40
+              {{ project.user.address.nomRue }}
41
+            </li>
42
+            <li>
43
+              {{ project.user.address.bp }} {{ project.user.address.ville }},
44
+              {{ project.user.address.pays }}
45
+            </li>
46
+          </ul>
47
+        </td>
48
+        <td>{{ project.userId }}</td>
49
+        <td>{{ project.creationDate | date: "dd MM yyyy" }}</td>
50
+      </tr>
51
+    </ng-template>
52
+  </p-table>

+ 25
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.spec.ts Voir le fichier

@@ -0,0 +1,25 @@
1
+import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+import { ProjectWithUserAssociatedListComponent } from './project-with-user-associated-list.component';
4
+
5
+describe('ProjectWithUserAssociatedListComponent', () => {
6
+  let component: ProjectWithUserAssociatedListComponent;
7
+  let fixture: ComponentFixture<ProjectWithUserAssociatedListComponent>;
8
+
9
+  beforeEach(async () => {
10
+    await TestBed.configureTestingModule({
11
+      declarations: [ ProjectWithUserAssociatedListComponent ]
12
+    })
13
+    .compileComponents();
14
+  });
15
+
16
+  beforeEach(() => {
17
+    fixture = TestBed.createComponent(ProjectWithUserAssociatedListComponent);
18
+    component = fixture.componentInstance;
19
+    fixture.detectChanges();
20
+  });
21
+
22
+  it('should create', () => {
23
+    expect(component).toBeTruthy();
24
+  });
25
+});

+ 16
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.ts Voir le fichier

@@ -0,0 +1,16 @@
1
+import { Component, Input, OnInit } from '@angular/core';
2
+
3
+@Component({
4
+  selector: 'app-project-with-user-associated-list',
5
+  templateUrl: './project-with-user-associated-list.component.html',
6
+  styleUrls: ['./project-with-user-associated-list.component.css']
7
+})
8
+export class ProjectWithUserAssociatedListComponent implements OnInit {
9
+
10
+  constructor() { }
11
+  @Input() inputProjectsListWithUserAssociated!: any;
12
+
13
+  ngOnInit(): void {
14
+  }
15
+
16
+}

+ 0
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.css Voir le fichier


+ 15
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.html Voir le fichier

@@ -0,0 +1,15 @@
1
+<div class="container" *ngIf="projectState">
2
+  <ng-container *ngIf="projectState.msgState == msgState.LOADING">
3
+    {{ msgState.LOADING }}
4
+  </ng-container>
5
+
6
+  <ng-container *ngIf="projectState.msgState == msgState.ERR">
7
+    {{ msgState.ERR }}
8
+  </ng-container>
9
+
10
+  <ng-container *ngIf="projectState.msgState == msgState.LOADED">
11
+    <app-project-with-user-associated-list
12
+      [inputProjectsListWithUserAssociated]="projectState.projectsList"
13
+    ></app-project-with-user-associated-list>
14
+  </ng-container>
15
+</div>

+ 25
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.spec.ts Voir le fichier

@@ -0,0 +1,25 @@
1
+import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+import { ProjectWithUserAssociatedComponent } from './project-with-user-associated.component';
4
+
5
+describe('ProjectWithUserAssociatedComponent', () => {
6
+  let component: ProjectWithUserAssociatedComponent;
7
+  let fixture: ComponentFixture<ProjectWithUserAssociatedComponent>;
8
+
9
+  beforeEach(async () => {
10
+    await TestBed.configureTestingModule({
11
+      declarations: [ ProjectWithUserAssociatedComponent ]
12
+    })
13
+    .compileComponents();
14
+  });
15
+
16
+  beforeEach(() => {
17
+    fixture = TestBed.createComponent(ProjectWithUserAssociatedComponent);
18
+    component = fixture.componentInstance;
19
+    fixture.detectChanges();
20
+  });
21
+
22
+  it('should create', () => {
23
+    expect(component).toBeTruthy();
24
+  });
25
+});

+ 28
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated.component.ts Voir le fichier

@@ -0,0 +1,28 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { Store } from '@ngrx/store';
3
+import { MsgState } from 'src/app/ngrx/msg.state';
4
+import { ProjectState } from 'src/app/ngrx/projects/project.state';
5
+import { GetProjectWithUserAssociatedAction } from 'src/app/ngrx/projects/projects.actions';
6
+
7
+@Component({
8
+  selector: 'app-project-with-user-associated',
9
+  templateUrl: './project-with-user-associated.component.html',
10
+  styleUrls: ['./project-with-user-associated.component.css']
11
+})
12
+export class ProjectWithUserAssociatedComponent implements OnInit {
13
+
14
+
15
+  projectState!: ProjectState;
16
+  msgState = MsgState;
17
+  constructor(private store:Store<{projectReducerKey: ProjectState}>) { }
18
+
19
+  ngOnInit(): void {
20
+
21
+    this.store.dispatch(new GetProjectWithUserAssociatedAction({}));
22
+    this.store.subscribe(projectState => {
23
+      this.projectState = projectState.projectReducerKey;
24
+    })
25
+  }
26
+
27
+
28
+}

+ 6
- 3
src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.html Voir le fichier

@@ -1,25 +1,28 @@
1 1
 <div class="container">
2
-  <div *ngIf="inputProjectState.projectsList && inputProjectState.projectsList.length>0" style="position:relative">
2
+  <div *ngIf="inputProjectsList" style="position:relative">
3 3
     <input
4 4
       type="text"
5 5
       class="form-control"
6 6
       id="search"
7 7
       placeholder="search a project by name"
8
-      width="20"
8
+      [(ngModel)]="projectName"
9
+      (ngModelChange)="onSearch()"
9 10
     />
10 11
   </div>
11 12
 </div>
12 13
 
13 14
 <div class="container">
14 15
   <p-table
15
-    [value]="inputProjectState.projectsList"
16
+    [value]="inputProjectsList"
16 17
     responsiveLayout="scroll"
18
+    *ngIf="inputProjectsList.length>0"
17 19
     styleClass="p-datatable-striped"
18 20
     [paginator]="true"
19 21
     [rows]="5"
20 22
     [showCurrentPageReport]="true"
21 23
     currentPageReportTemplate="{first} - {last} of {totalRecords} projects"
22 24
     [rowsPerPageOptions]="[5, 8, 10]"
25
+
23 26
   >
24 27
     <ng-template pTemplate="header">
25 28
       <tr>

+ 19
- 2
src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.ts Voir le fichier

@@ -1,3 +1,4 @@
1
+import { GetAllProjectsAction } from './../../../../ngrx/projects/projects.actions';
1 2
 import { MsgState } from 'src/app/ngrx/msg.state';
2 3
 import { Store } from '@ngrx/store';
3 4
 import { Router } from '@angular/router';
@@ -17,7 +18,7 @@ export class ProjectsListComponent implements OnInit {
17 18
     private store: Store<{ projectReducerKey: ProjectState }>
18 19
   ) {}
19 20
 
20
-  @Input() inputProjectState!: ProjectState;
21
+  @Input() inputProjectsList!: Project[];
21 22
 
22 23
   ngOnInit(): void {}
23 24
 
@@ -26,8 +27,24 @@ export class ProjectsListComponent implements OnInit {
26 27
   }
27 28
 
28 29
   onProjectDelete(project: Project) {
29
-    if(window.confirm(MsgState.CONFIRM_DEL)){
30
+    if (window.confirm(MsgState.CONFIRM_DEL)) {
30 31
       this.store.dispatch(new DeleteProjectAction(project));
31 32
     }
32 33
   }
34
+
35
+  projectName!: string;
36
+  onSearch() {
37
+   if(this.projectName==''){
38
+     this.store.dispatch(new GetAllProjectsAction({}));
39
+   }
40
+   else{
41
+    this.inputProjectsList = this.inputProjectsList.filter(
42
+      (project: Project) => {
43
+        return project.projectName
44
+          .toLocaleLowerCase()
45
+          .match(this.projectName.toLocaleLowerCase());
46
+      }
47
+    );
48
+   }
49
+  }
33 50
 }

+ 1
- 1
src/app/pages/projects-manager/projects-management/projects-management.component.html Voir le fichier

@@ -17,7 +17,7 @@
17 17
     </ng-container>
18 18
 
19 19
     <ng-container *ngSwitchCase="msgState.LOADED">
20
-      <app-projects-list [inputProjectState]="projectState"></app-projects-list>
20
+      <app-projects-list [inputProjectsList]="projectState.projectsList"></app-projects-list>
21 21
     </ng-container>
22 22
 
23 23
   </ng-container>

+ 10
- 0
src/app/pages/projects-manager/projects-manager-routing.module.ts Voir le fichier

@@ -1,3 +1,5 @@
1
+import { ProjectWithCompanyAssociatedComponent } from './projects-management/project-with-company-associated/project-with-company-associated.component';
2
+import { ProjectWithUserAssociatedComponent } from './projects-management/project-with-user-associated/project-with-user-associated.component';
1 3
 import { ProjectUpdateComponent } from './projects-management/project-update/project-update.component';
2 4
 import { ProjectsManagementComponent } from './projects-management/projects-management.component';
3 5
 import { ProjectCreateComponent } from './projects-management/project-create/project-create.component';
@@ -8,6 +10,14 @@ const routes: Routes = [
8 10
   { path: 'project-create', component: ProjectCreateComponent },
9 11
   { path: 'projects-management', component: ProjectsManagementComponent },
10 12
   { path: 'project-update/:projectId', component: ProjectUpdateComponent },
13
+  {
14
+    path: 'project-user-asscociated',
15
+    component: ProjectWithUserAssociatedComponent,
16
+  },
17
+  {
18
+    path: 'project-company-asscociated',
19
+    component: ProjectWithCompanyAssociatedComponent,
20
+  },
11 21
 ];
12 22
 
13 23
 @NgModule({

+ 13
- 6
src/app/pages/projects-manager/projects-manager.module.ts Voir le fichier

@@ -1,7 +1,7 @@
1 1
 import { TableModule } from 'primeng/table';
2 2
 import { ButtonModule } from 'primeng/button';
3 3
 import { NgModule } from '@angular/core';
4
-import { CommonModule, DatePipe } from '@angular/common';
4
+import { CommonModule } from '@angular/common';
5 5
 
6 6
 import { ProjectsManagerRoutingModule } from './projects-manager-routing.module';
7 7
 import { ProjectCreateComponent } from './projects-management/project-create/project-create.component';
@@ -9,9 +9,11 @@ import { ProjectNavBarComponent } from './projects-management/project-nav-bar/pr
9 9
 import { ProjectsManagementComponent } from './projects-management/projects-management.component';
10 10
 import { ProjectsListComponent } from './projects-management/projects-list/projects-list.component';
11 11
 import { ProjectUpdateComponent } from './projects-management/project-update/project-update.component';
12
-import { ReactiveFormsModule } from '@angular/forms';
13
-
14
-
12
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
13
+import { ProjectWithUserAssociatedComponent } from './projects-management/project-with-user-associated/project-with-user-associated.component';
14
+import { ProjectWithUserAssociatedListComponent } from './projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component';
15
+import { ProjectWithCompanyAssociatedComponent } from './projects-management/project-with-company-associated/project-with-company-associated.component';
16
+import { ProjectWithCompanyAssociatedListComponent } from './projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component';
15 17
 
16 18
 
17 19
 @NgModule({
@@ -20,7 +22,11 @@ import { ReactiveFormsModule } from '@angular/forms';
20 22
     ProjectNavBarComponent,
21 23
     ProjectsManagementComponent,
22 24
     ProjectsListComponent,
23
-    ProjectUpdateComponent
25
+    ProjectUpdateComponent,
26
+    ProjectWithUserAssociatedComponent,
27
+    ProjectWithUserAssociatedListComponent,
28
+    ProjectWithCompanyAssociatedComponent,
29
+    ProjectWithCompanyAssociatedListComponent,
24 30
 
25 31
   ],
26 32
   imports: [
@@ -28,7 +34,8 @@ import { ReactiveFormsModule } from '@angular/forms';
28 34
     ProjectsManagerRoutingModule,
29 35
     ButtonModule,
30 36
     TableModule,
31
-    ReactiveFormsModule
37
+    ReactiveFormsModule,
38
+    FormsModule
32 39
   ],
33 40
   providers:[
34 41
   ]

+ 0
- 23
src/app/pages/users-manager/users-management/user-nav-bar/user-nav-bar.component.html Voir le fichier

@@ -25,28 +25,5 @@
25 25
         (click)="onGetUser_s_Projects()"
26 26
       ></button>
27 27
     </div>
28
-
29
-    <ul class="navbar-nav ml-auto">
30
-      <li>
31
-        <form #form="ngForm" (ngSubmit)="onSearch(form.value)" novalidate>
32
-          <div class="input-group">
33
-            <input
34
-              type="text"
35
-              class="form-control"
36
-              name="keyword"
37
-              ngModel
38
-              placeholder="firstname keyword"
39
-            />
40
-            <div class="input-group-append">
41
-              <span class="input-group-text" id="basic-addon2">
42
-                <button class="btn" type="submit" [disabled]="!form.valid">
43
-                  <i class="fa fa-search"></i>search
44
-                </button>
45
-              </span>
46
-            </div>
47
-          </div>
48
-        </form>
49
-      </li>
50
-    </ul>
51 28
   </nav>
52 29
 </div>

+ 12
- 2
src/app/pages/users-manager/users-management/users-list/users-list.component.html Voir le fichier

@@ -1,7 +1,17 @@
1
+<div *ngIf="inputUsersList" style="position:relative">
2
+  <input
3
+    type="text"
4
+    class="form-control"
5
+    id="search"
6
+    placeholder="search a project by name"
7
+    [(ngModel)]="firstname"
8
+    (ngModelChange)="onSearch()"
9
+  />
10
+</div>
1 11
 <p-table
2
-[value]="inputState.usersList"
12
+[value]="inputUsersList"
3 13
 responsiveLayout="scroll"
4
-*ngIf="inputState.usersList && inputState.usersList.length > 0"
14
+*ngIf="inputUsersList.length > 0"
5 15
 styleClass="p-datatable-striped"
6 16
 [paginator]="true"
7 17
 [rows]="5"

+ 24
- 6
src/app/pages/users-manager/users-management/users-list/users-list.component.ts Voir le fichier

@@ -1,7 +1,6 @@
1
+import { GetAllUsersAction } from 'src/app/ngrx/users/users.actions';
1 2
 import { Router } from '@angular/router';
2
-import {
3
-  DeleteUsersAction,
4
-} from './../../../../ngrx/users/users.actions';
3
+import { DeleteUsersAction } from './../../../../ngrx/users/users.actions';
5 4
 import { User } from 'src/app/shared/models/user/user.model';
6 5
 import { Input } from '@angular/core';
7 6
 import { Component } from '@angular/core';
@@ -15,7 +14,7 @@ import { MsgState } from 'src/app/ngrx/msg.state';
15 14
   styleUrls: ['./users-list.component.css'],
16 15
 })
17 16
 export class UsersListComponent {
18
-  @Input() inputState!: UserState;
17
+  @Input() inputUsersList!: User[];
19 18
 
20 19
   constructor(
21 20
     private store: Store<{ userReducerKey: UserState }>,
@@ -23,12 +22,31 @@ export class UsersListComponent {
23 22
   ) {}
24 23
 
25 24
   onUserEdit(user: User) {
26
-    this.router.navigateByUrl('/user-update/'+user.id)
25
+    this.router.navigateByUrl('/user-update/' + user.id);
27 26
   }
28 27
 
29 28
   onUserDelete(user: User) {
30
-    if (window.confirm(MsgState.CONFIRM_DEL+' '+user.firstname+' '+user.lastname)) {
29
+    if (
30
+      window.confirm(
31
+        MsgState.CONFIRM_DEL + ' ' + user.firstname + ' ' + user.lastname
32
+      )
33
+    ) {
31 34
       this.store.dispatch(new DeleteUsersAction(user));
32 35
     }
33 36
   }
37
+
38
+  firstname!: string;
39
+
40
+  onSearch() {
41
+    if(this.firstname==''){
42
+      this.store.dispatch(new GetAllUsersAction({})); //refresh
43
+    }
44
+    else{
45
+      this.inputUsersList = this.inputUsersList.filter((user: User) => {
46
+        return user.firstname
47
+          .toLocaleLowerCase()
48
+          .match(this.firstname.toLocaleLowerCase());
49
+      });
50
+    }
51
+  }
34 52
 }

+ 1
- 1
src/app/pages/users-manager/users-management/users-management.component.html Voir le fichier

@@ -15,7 +15,7 @@
15 15
     </ng-container>
16 16
 
17 17
     <ng-container *ngSwitchCase="msgState.LOADED">
18
-      <app-users-list [inputState]="userState"></app-users-list>
18
+      <app-users-list [inputUsersList]="userState.usersList"></app-users-list>
19 19
     </ng-container>
20 20
 
21 21
   </ng-container>

+ 1
- 1
src/app/shared/services/projects.service.ts Voir le fichier

@@ -33,7 +33,7 @@ export class ProjectsService implements OnInit {
33 33
     return this.http.get<Project[]>(this.baseUrl + '/projects');
34 34
   }
35 35
 
36
-  getAllProjectsWithUsersAsociated(): Observable<Project[]> {
36
+  getProjectWithUserAsociated(): Observable<Project[]> {
37 37
     return this.http
38 38
       .get<Project[]>(this.baseUrl + '/projects?_expand=user')
39 39
       .pipe(catchError(this.handleError));

+ 1
- 1
src/app/shared/services/users.service.ts Voir le fichier

@@ -36,7 +36,7 @@ export class UsersService {
36 36
     return allUsers$;
37 37
   }
38 38
 
39
-  getUser_sProjects(): Observable<any> {
39
+  getUser_s_Projects(): Observable<any> {
40 40
     return this.http
41 41
       .get<any>(this.baseUrl + '/users?_embed=projects')
42 42
       .pipe(catchError(this.handleError));

Powered by TurnKey Linux.