Browse Source

commit modif

placidenduwayo 2 years ago
parent
commit
1b8de090c9
68 changed files with 886 additions and 577 deletions
  1. 84
    62
      db_users_projects_companies.json
  2. 1
    1
      src/app/app.component.html
  3. 7
    6
      src/app/app.module.ts
  4. 68
    8
      src/app/ngrx/companies/companies.actions.ts
  5. 93
    31
      src/app/ngrx/companies/companies.reducer.ts
  6. 19
    14
      src/app/ngrx/companies/company.action.types.ts
  7. 1
    1
      src/app/ngrx/companies/company.state.ts
  8. 39
    0
      src/app/ngrx/companies/effects.company.create.ts
  9. 0
    27
      src/app/ngrx/companies/effects.company.get.search.ts
  10. 54
    0
      src/app/ngrx/companies/effects.company.get.ts
  11. 5
    5
      src/app/ngrx/companies/effects.company.update.delete.ts
  12. 2
    1
      src/app/ngrx/msg.state.ts
  13. 2
    2
      src/app/ngrx/projects/effects.project.create.ts
  14. 3
    3
      src/app/ngrx/projects/effects.project.get.ts
  15. 2
    2
      src/app/ngrx/projects/effects.project.update.delete.ts
  16. 1
    1
      src/app/ngrx/projects/projects.reducer.ts
  17. 39
    34
      src/app/ngrx/users/effects.user.create.ts
  18. 24
    28
      src/app/ngrx/users/effects.user.get.ts
  19. 2
    2
      src/app/ngrx/users/effects.user.update.delete.ts
  20. 0
    6
      src/app/ngrx/users/user.action.types.ts
  21. 4
    25
      src/app/ngrx/users/users.actions.ts
  22. 0
    158
      src/app/ngrx/users/users.effects.ts
  23. 4
    24
      src/app/ngrx/users/users.reducer.ts
  24. 3
    3
      src/app/pages/accueil/accueil-routing.module.ts
  25. 3
    3
      src/app/pages/accueil/accueil/accueil.component.html
  26. 10
    10
      src/app/pages/base-nav-menu/base-nav-menu.component.html
  27. 0
    1
      src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.html
  28. 0
    15
      src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.ts
  29. 0
    2
      src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.html
  30. 2
    2
      src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.ts
  31. 0
    0
      src/app/pages/companies-manager/companies-management/company-create/company-create.component.css
  32. 82
    0
      src/app/pages/companies-manager/companies-management/company-create/company-create.component.html
  33. 6
    6
      src/app/pages/companies-manager/companies-management/company-create/company-create.component.spec.ts
  34. 70
    0
      src/app/pages/companies-manager/companies-management/company-create/company-create.component.ts
  35. 1
    1
      src/app/pages/companies-manager/companies-management/company-nav-bar/company-nav-bar.component.html
  36. 17
    11
      src/app/pages/companies-manager/companies-management/company-nav-bar/company-nav-bar.component.ts
  37. 3
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.css
  38. 45
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.html
  39. 25
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.spec.ts
  40. 11
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.ts
  41. 0
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.css
  42. 17
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.html
  43. 25
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.spec.ts
  44. 27
    0
      src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.ts
  45. 18
    15
      src/app/pages/companies-manager/companies-management/company-update/company-update.component.html
  46. 2
    2
      src/app/pages/companies-manager/companies-management/company-update/company-update.component.ts
  47. 5
    4
      src/app/pages/companies-manager/companies-manager-routing.module.ts
  48. 10
    5
      src/app/pages/companies-manager/companies-manager.module.ts
  49. 1
    1
      src/app/pages/projects-manager/projects-management/project-create/project-create.component.html
  50. 3
    3
      src/app/pages/projects-manager/projects-management/project-create/project-create.component.ts
  51. 1
    1
      src/app/pages/projects-manager/projects-management/project-update/project-update.component.html
  52. 2
    2
      src/app/pages/projects-manager/projects-management/project-update/project-update.component.ts
  53. 3
    4
      src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.html
  54. 1
    0
      src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.html
  55. 1
    4
      src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.html
  56. 2
    3
      src/app/pages/projects-manager/projects-manager.module.ts
  57. 10
    12
      src/app/pages/users-manager/users-management/user-create/user-create.component.html
  58. 11
    8
      src/app/pages/users-manager/users-management/user-create/user-create.component.ts
  59. 1
    5
      src/app/pages/users-manager/users-management/user-nav-bar/user-nav-bar.component.ts
  60. 1
    1
      src/app/pages/users-manager/users-management/user-s-projects/user-s-projects.component.html
  61. 1
    1
      src/app/pages/users-manager/users-management/user-update/user-update.component.html
  62. 3
    3
      src/app/pages/users-manager/users-management/user-update/user-update.component.ts
  63. 1
    1
      src/app/pages/users-manager/users-management/users-list/users-list.component.html
  64. 0
    1
      src/app/pages/users-manager/users-management/users-management.component.html
  65. 2
    0
      src/app/pages/users-manager/users-manager.module.ts
  66. 2
    2
      src/app/shared/services/companies.service.ts
  67. 1
    1
      src/app/shared/services/projects.service.ts
  68. 3
    3
      src/app/shared/services/users.service.ts

+ 84
- 62
db_users_projects_companies.json View File

4
       "id": 1,
4
       "id": 1,
5
       "companyName": "NATAN",
5
       "companyName": "NATAN",
6
       "companyType": "PROSPECT",
6
       "companyType": "PROSPECT",
7
-      "creationDate": "05 17 2022"
8
-    },
9
-    {
10
-      "id": 2,
11
-      "companyName": "Company-1",
12
-      "companyType": "CLIENT",
13
-      "creationDate": "05 17 2022"
7
+      "creationDate": "01 01 2019"
14
     },
8
     },
15
     {
9
     {
16
       "id": 4,
10
       "id": 4,
23
       "companyName": "Company-3",
17
       "companyName": "Company-3",
24
       "companyType": "CLIENT",
18
       "companyType": "CLIENT",
25
       "creationDate": "05 18 2022"
19
       "creationDate": "05 18 2022"
20
+    },
21
+    {
22
+      "id": 5,
23
+      "companyName": "Company-1",
24
+      "companyType": "CLIENT",
25
+      "creationDate": "06 09 2022"
26
+    },
27
+    {
28
+      "id": 6,
29
+      "companyName": "Company-2",
30
+      "companyType": "CLIENT",
31
+      "creationDate": "06 09 2022"
32
+    },
33
+    {
34
+      "id": 7,
35
+      "companyName": "Company-5",
36
+      "companyType": "CLIENT",
37
+      "creationDate": "06 09 2022"
38
+    },
39
+    {
40
+      "id": 8,
41
+      "companyName": "company-6",
42
+      "companyType": "PROSPECT",
43
+      "creationDate": "06 09 2022"
44
+    },
45
+    {
46
+      "id": 9,
47
+      "companyName": "Company-7",
48
+      "companyType": "PROSPECT",
49
+      "creationDate": "06 09 2022"
50
+    },
51
+    {
52
+      "id": 10,
53
+      "companyName": "Company-8",
54
+      "companyType": "CLIENT",
55
+      "creationDate": "06 09 2022"
56
+    },
57
+    {
58
+      "id": 11,
59
+      "companyName": "Company-9",
60
+      "companyType": "PROSPECT",
61
+      "creationDate": "06 09 2022"
26
     }
62
     }
27
   ],
63
   ],
28
   "users": [
64
   "users": [
33
       "email": "david.touitou@natan.fr",
69
       "email": "david.touitou@natan.fr",
34
       "address": {
70
       "address": {
35
         "numRue": 45,
71
         "numRue": 45,
36
-        "nomRue": "Rue Notre Dame de Paris",
72
+        "nomRue": "Rue Notre Dame des Victoires",
37
         "bp": 75002,
73
         "bp": 75002,
38
         "ville": "Paris",
74
         "ville": "Paris",
39
         "pays": "France"
75
         "pays": "France"
47
       "email": "nadhir.ben-mohamed@natan.fr",
83
       "email": "nadhir.ben-mohamed@natan.fr",
48
       "address": {
84
       "address": {
49
         "numRue": 45,
85
         "numRue": 45,
50
-        "nomRue": "Rue Notre Dame de Paris",
86
+        "nomRue": "Rue Notre Dame des Victoires",
51
         "bp": 75002,
87
         "bp": 75002,
52
         "ville": "Paris",
88
         "ville": "Paris",
53
         "pays": "France"
89
         "pays": "France"
57
     {
93
     {
58
       "address": {
94
       "address": {
59
         "numRue": 44,
95
         "numRue": 44,
60
-        "nomRue": "Rue Notre Dame de Paris",
96
+        "nomRue": "Rue Notre Dame des Victoires",
61
         "bp": 75002,
97
         "bp": 75002,
62
         "ville": "Paris",
98
         "ville": "Paris",
63
         "pays": "France"
99
         "pays": "France"
71
     {
107
     {
72
       "address": {
108
       "address": {
73
         "numRue": 44,
109
         "numRue": 44,
74
-        "nomRue": "Rue Notre Dame de Paris",
110
+        "nomRue": "Rue Notre Dame des Victoires",
75
         "bp": 75002,
111
         "bp": 75002,
76
         "ville": "Paris",
112
         "ville": "Paris",
77
         "pays": "France"
113
         "pays": "France"
85
     {
121
     {
86
       "address": {
122
       "address": {
87
         "numRue": 44,
123
         "numRue": 44,
88
-        "nomRue": "Rue Notre Dame de Paris",
89
-        "bp": 75002,
90
-        "ville": "Paris",
91
-        "pays": "France"
92
-      },
93
-      "creationDate": "05 15 2022",
94
-      "firstname": "Syrine",
95
-      "lastname": "Ait Haddad",
96
-      "email": "syrine.ait-haddadene@natan.fr",
97
-      "id": 8
98
-    },
99
-    {
100
-      "address": {
101
-        "numRue": 44,
102
-        "nomRue": "Rue Notre Dame de Paris",
124
+        "nomRue": "Rue Notre Dame des Victoires",
103
         "bp": 75002,
125
         "bp": 75002,
104
         "ville": "Paris",
126
         "ville": "Paris",
105
         "pays": "France"
127
         "pays": "France"
113
     {
135
     {
114
       "address": {
136
       "address": {
115
         "numRue": 44,
137
         "numRue": 44,
116
-        "nomRue": "Rue Notre Dame de Paris",
138
+        "nomRue": "Rue Notre Dame des Victoires",
117
         "bp": 75002,
139
         "bp": 75002,
118
         "ville": "Paris",
140
         "ville": "Paris",
119
         "pays": "France"
141
         "pays": "France"
131
       "email": "charles.benassaya@natan.fr",
153
       "email": "charles.benassaya@natan.fr",
132
       "address": {
154
       "address": {
133
         "numRue": 44,
155
         "numRue": 44,
134
-        "nomRue": "Rue Notre Dame de Paris",
156
+        "nomRue": "Rue Notre Dame des Victoires",
135
         "bp": 75002,
157
         "bp": 75002,
136
         "ville": "Paris",
158
         "ville": "Paris",
137
         "pays": "France"
159
         "pays": "France"
145
       "email": "placide.nduwayo@natan.fr",
167
       "email": "placide.nduwayo@natan.fr",
146
       "address": {
168
       "address": {
147
         "numRue": 44,
169
         "numRue": 44,
148
-        "nomRue": "Rue Notre Dame de Paris",
170
+        "nomRue": "Rue Notre Dame des Victoires",
149
         "bp": 75002,
171
         "bp": 75002,
150
         "ville": "Paris",
172
         "ville": "Paris",
151
         "pays": "France"
173
         "pays": "France"
159
       "email": "naolie.boudouka-tete@natan.fr",
181
       "email": "naolie.boudouka-tete@natan.fr",
160
       "address": {
182
       "address": {
161
         "numRue": 44,
183
         "numRue": 44,
162
-        "nomRue": "Rue Notre Dame de Paris",
184
+        "nomRue": "Rue Notre Dame des Victoires",
163
         "bp": 75002,
185
         "bp": 75002,
164
         "ville": "Paris",
186
         "ville": "Paris",
165
         "pays": "France"
187
         "pays": "France"
173
       "email": "rayene.bessrour@natan.fr",
195
       "email": "rayene.bessrour@natan.fr",
174
       "address": {
196
       "address": {
175
         "numRue": 44,
197
         "numRue": 44,
176
-        "nomRue": "Rue Notre Dame de Paris",
198
+        "nomRue": "Rue Notre Dame des Victoires",
177
         "bp": 75004,
199
         "bp": 75004,
178
         "ville": "Paris",
200
         "ville": "Paris",
179
         "pays": "France"
201
         "pays": "France"
181
       "creationDate": "05 15 2022"
203
       "creationDate": "05 15 2022"
182
     },
204
     },
183
     {
205
     {
184
-      "id": 17,
185
-      "firstname": "user test",
186
-      "lastname": "user test",
187
-      "email": "user.test@test",
206
+      "id": 19,
207
+      "firstname": "Syrine",
208
+      "lastname": "Ait Haddadene",
209
+      "email": "syrine.ait-haddadene@natan.fr",
188
       "address": {
210
       "address": {
189
-        "numRue": 952,
190
-        "nomRue": "user test",
191
-        "bp": 45,
192
-        "ville": "user test",
193
-        "pays": "user test"
211
+        "numRue": 44,
212
+        "nomRue": "Rue Notre Dame des Victoires",
213
+        "bp": 75002,
214
+        "ville": "Paris",
215
+        "pays": "France"
194
       },
216
       },
195
-      "creationDate": "05 15 2022"
217
+      "creationDate": "06 09 2022"
196
     },
218
     },
197
     {
219
     {
198
-      "id": 18,
199
-      "firstname": "test2",
200
-      "lastname": "test2",
201
-      "email": "test2@test2",
220
+      "id": 20,
221
+      "firstname": "test",
222
+      "lastname": "test",
223
+      "email": "test@test",
202
       "address": {
224
       "address": {
203
-        "numRue": 121,
204
-        "nomRue": "test2",
205
-        "bp": 120,
206
-        "ville": "test2",
207
-        "pays": "test2"
225
+        "numRue": 21,
226
+        "nomRue": "test",
227
+        "bp": 21,
228
+        "ville": "test",
229
+        "pays": "test"
208
       },
230
       },
209
-      "createDate": "06 07 2022"
231
+      "creationDate": "06 09 2022"
210
     }
232
     }
211
   ],
233
   ],
212
   "projects": [
234
   "projects": [
213
     {
235
     {
214
-      "id": 2,
215
-      "projectName": "Project-2",
216
-      "priority": 3,
217
-      "creationDate": "03 06 2022",
218
-      "companyId": 2,
219
-      "description": "Project description for action",
220
-      "userId": 12,
221
-      "state": "END"
222
-    },
223
-    {
224
       "id": 3,
236
       "id": 3,
225
       "projectName": "Project-3",
237
       "projectName": "Project-3",
226
       "priority": 1,
238
       "priority": 1,
255
       "projectName": "Project-test",
267
       "projectName": "Project-test",
256
       "priority": 1,
268
       "priority": 1,
257
       "creationDate": "06 08 2022",
269
       "creationDate": "06 08 2022",
258
-      "companyId": 4,
270
+      "companyId": 11,
259
       "description": "project for test adding ",
271
       "description": "project for test adding ",
260
       "userId": 12,
272
       "userId": 12,
261
       "state": "IN PROGRESS"
273
       "state": "IN PROGRESS"
274
+    },
275
+    {
276
+      "id": 7,
277
+      "projectName": "Project-1",
278
+      "priority": 1,
279
+      "creationDate": "06 09 2022",
280
+      "companyId": 8,
281
+      "description": "Project description here",
282
+      "userId": 3,
283
+      "state": "IN PROGRESS"
262
     }
284
     }
263
   ]
285
   ]
264
 }
286
 }

+ 1
- 1
src/app/app.component.html View File

1
 <app-base-nav-menu></app-base-nav-menu>
1
 <app-base-nav-menu></app-base-nav-menu>
2
-<!-- <router-outlet></router-outlet> -->
2
+<router-outlet></router-outlet>

+ 7
- 6
src/app/app.module.ts View File

1
+import { CompanyCreateEffects } from './ngrx/companies/effects.company.create';
1
 import { CompanyUpdateDeleteEffects } from './ngrx/companies/effects.company.update.delete';
2
 import { CompanyUpdateDeleteEffects } from './ngrx/companies/effects.company.update.delete';
2
-import { CompanyGetSearchEffects } from './ngrx/companies/effects.company.get.search';
3
+import { CompanyGetSearchEffects } from './ngrx/companies/effects.company.get';
3
 import { BaseNavMenuComponent } from './pages/base-nav-menu/base-nav-menu.component';
4
 import { BaseNavMenuComponent } from './pages/base-nav-menu/base-nav-menu.component';
4
 import { FormsModule } from '@angular/forms';
5
 import { FormsModule } from '@angular/forms';
5
 import { AccueilModule } from './pages/accueil/accueil.module';
6
 import { AccueilModule } from './pages/accueil/accueil.module';
24
 import { StoreModule } from '@ngrx/store';
25
 import { StoreModule } from '@ngrx/store';
25
 import { StoreDevtoolsModule } from '@ngrx/store-devtools';
26
 import { StoreDevtoolsModule } from '@ngrx/store-devtools';
26
 import { UserCreateEffects } from './ngrx/users/effects.user.create';
27
 import { UserCreateEffects } from './ngrx/users/effects.user.create';
27
-import { UserGetSearchEffects } from './ngrx/users/effects.user.get.search';
28
+import { UserGetSearchEffects } from './ngrx/users/effects.user.get';
28
 import { UserUpdateEffects } from './ngrx/users/effects.user.update.delete';
29
 import { UserUpdateEffects } from './ngrx/users/effects.user.update.delete';
29
 import { userReducer } from './ngrx/users/users.reducer';
30
 import { userReducer } from './ngrx/users/users.reducer';
30
 import { projectReducer } from './ngrx/projects/projects.reducer';
31
 import { projectReducer } from './ngrx/projects/projects.reducer';
31
 import { ProjectUpdateEffects } from './ngrx/projects/effects.project.update.delete';
32
 import { ProjectUpdateEffects } from './ngrx/projects/effects.project.update.delete';
32
 import { ProjectCreateEffects } from './ngrx/projects/effects.project.create';
33
 import { ProjectCreateEffects } from './ngrx/projects/effects.project.create';
33
-import { ProjectGet } from './ngrx/projects/effects.project.get';
34
+import { ProjectGetEffects } from './ngrx/projects/effects.project.get';
34
 import { DatePipe } from '@angular/common';
35
 import { DatePipe } from '@angular/common';
35
 import { companyReducer } from './ngrx/companies/companies.reducer';
36
 import { companyReducer } from './ngrx/companies/companies.reducer';
36
 
37
 
63
       UserGetSearchEffects,
64
       UserGetSearchEffects,
64
       UserUpdateEffects,
65
       UserUpdateEffects,
65
       ProjectCreateEffects,
66
       ProjectCreateEffects,
66
-      ProjectGet,
67
+      ProjectGetEffects,
67
       ProjectUpdateEffects,
68
       ProjectUpdateEffects,
68
       CompanyGetSearchEffects,
69
       CompanyGetSearchEffects,
69
-      CompanyUpdateDeleteEffects
70
+      CompanyUpdateDeleteEffects,
71
+      CompanyCreateEffects
70
     ]),
72
     ]),
71
     StoreDevtoolsModule.instrument(),
73
     StoreDevtoolsModule.instrument(),
72
   ],
74
   ],
73
-  providers: [DatePipe],
74
   bootstrap: [AppComponent],
75
   bootstrap: [AppComponent],
75
 })
76
 })
76
 export class AppModule {}
77
 export class AppModule {}

+ 68
- 8
src/app/ngrx/companies/companies.actions.ts View File

19
   constructor(public payload: string) {}
19
   constructor(public payload: string) {}
20
 }
20
 }
21
 
21
 
22
-//create form to create campany
22
+//create form to create company
23
+export class CreateCompanyFormAddAction implements Action {
24
+  type: CompanyActionTypes = CompanyActionTypes.CREATE_COMPANY_FORM_ADD;
25
+  constructor(public payload: void) {}
26
+}
27
+
28
+export class CreateCompanyFormAddActionSuccess implements Action {
29
+  type: CompanyActionTypes = CompanyActionTypes.CREATE_COMPANY_FORM_ADD_SUCCESS;
30
+  constructor(public payload: void) {}
31
+}
32
+
33
+export class CreateCompanyFormAddActionError implements Action {
34
+  type: CompanyActionTypes = CompanyActionTypes.CREATE_COMPANY_FORM_ADD_ERROR;
35
+  constructor(public payload: string) {}
36
+}
37
+
38
+// save company with form data
39
+export class SaveCompanyFormDataAddAction implements Action {
40
+  type: CompanyActionTypes = CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD;
41
+  constructor(public payload: Company) {}
42
+}
43
+export class SaveCompanyFormDataAddActionSuccess implements Action {
44
+  type: CompanyActionTypes =
45
+    CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD_SUCCESS;
46
+  constructor(public payload: Company) {}
47
+}
48
+
49
+export class SaveCompanyFormDataAddActionError implements Action {
50
+  type: CompanyActionTypes =
51
+    CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD_ERROR;
52
+  constructor(public payload: string) {}
53
+}
23
 
54
 
24
 //create form to update company
55
 //create form to update company
25
 export class CreateFormToUpdateCompanyAction implements Action {
56
 export class CreateFormToUpdateCompanyAction implements Action {
58
 }
89
 }
59
 
90
 
60
 // detele a company
91
 // detele a company
61
-export class DeleteCompany implements Action{
92
+export class DeleteCompanyAction implements Action {
62
   type: CompanyActionTypes = CompanyActionTypes.DELETE_COMPANY;
93
   type: CompanyActionTypes = CompanyActionTypes.DELETE_COMPANY;
63
-  constructor(public payload: Company){}
94
+  constructor(public payload: Company) {}
64
 }
95
 }
65
 
96
 
66
-export class DeleteCompanySuccess implements Action{
97
+export class DeleteCompanyActionSuccess implements Action {
67
   type: CompanyActionTypes = CompanyActionTypes.DELETE_COMPANY_SUCCESS;
98
   type: CompanyActionTypes = CompanyActionTypes.DELETE_COMPANY_SUCCESS;
68
-  constructor(public payload: Company){}
99
+  constructor(public payload: Company) {}
69
 }
100
 }
70
 
101
 
71
-export class DeleteCompanyError implements Action{
102
+export class DeleteCompanyActionError implements Action {
72
   type: CompanyActionTypes = CompanyActionTypes.DELETE_COMPANY_ERROR;
103
   type: CompanyActionTypes = CompanyActionTypes.DELETE_COMPANY_ERROR;
73
-  constructor(public payload: string){}
104
+  constructor(public payload: string) {}
105
+}
106
+
107
+// Get company's projects
108
+export class GetCompany_S_Projects implements Action {
109
+  type: CompanyActionTypes = CompanyActionTypes.GET_COMPANY_S_PROJECTS;
110
+  constructor(public payload: any) {}
74
 }
111
 }
75
 
112
 
113
+export class GetCompany_S_ProjectsSuccess implements Action {
114
+  type: CompanyActionTypes = CompanyActionTypes.GET_COMPANY_S_PROJECTS_SUCCESS;
115
+  constructor(public payload: any) {}
116
+}
117
+
118
+export class GetCompany_S_ProjectsError implements Action {
119
+  type: CompanyActionTypes = CompanyActionTypes.GET_COMPANY_S_PROJECTS_ERROR;
120
+  constructor(public payload: string) {}
121
+}
122
+
123
+
76
 export type CompanyActionUnion =
124
 export type CompanyActionUnion =
77
   | GetAllCompaniesAction
125
   | GetAllCompaniesAction
78
   | GetAllCompaniesActionSuccess
126
   | GetAllCompaniesActionSuccess
79
   | GetAllCompaniesActionError
127
   | GetAllCompaniesActionError
128
+  | CreateCompanyFormAddAction
129
+  | CreateCompanyFormAddActionSuccess
130
+  | CreateCompanyFormAddActionError
131
+  | SaveCompanyFormDataAddAction
132
+  | SaveCompanyFormDataAddActionSuccess
133
+  | SaveCompanyFormDataAddActionError
80
   | CreateFormToUpdateCompanyAction
134
   | CreateFormToUpdateCompanyAction
81
   | CreateFormToUpdateCompanyActionSuccess
135
   | CreateFormToUpdateCompanyActionSuccess
82
   | CreateFormToUpdateCompanyActionError
136
   | CreateFormToUpdateCompanyActionError
83
   | UpdateCompanyWithFormDataAction
137
   | UpdateCompanyWithFormDataAction
84
   | UpdateCompanyWithFormDataActionSuccess
138
   | UpdateCompanyWithFormDataActionSuccess
85
-  | UpdateCompanyWithFormDataActionError;
139
+  | UpdateCompanyWithFormDataActionError
140
+  | DeleteCompanyAction
141
+  | DeleteCompanyActionSuccess
142
+  | DeleteCompanyActionError
143
+  | GetCompany_S_Projects
144
+  | GetCompany_S_ProjectsSuccess
145
+  | GetCompany_S_ProjectsError;

+ 93
- 31
src/app/ngrx/companies/companies.reducer.ts View File

1
-import { ProjectActionTypes } from './../projects/project.action.types';
2
-import { CompanyActionUnion } from './companies.actions';
3
-import { CompanyActionTypes } from './company.action.types';
4
-import { Action } from '@ngrx/store';
5
-import { MsgState } from '../msg.state';
6
-import { CompanyState } from './company.state';
7
-import { state } from '@angular/animations';
8
-import { Company } from 'src/app/shared/models/company/company.model';
1
+import { Action } from "@ngrx/store";
2
+import { Company } from "src/app/shared/models/company/company.model";
3
+import { MsgState } from "../msg.state";
4
+import { CompanyActionUnion } from "./companies.actions";
5
+import { CompanyActionTypes } from "./company.action.types";
6
+import { CompanyState } from "./company.state";
9
 
7
 
10
 /**reducer fonction to handle actions
8
 /**reducer fonction to handle actions
11
 a reducer function need initial state and an action to handle*/
9
 a reducer function need initial state and an action to handle*/
14
   currentCompany: null,
12
   currentCompany: null,
15
   companiesList: [],
13
   companiesList: [],
16
   msgState: MsgState.INIT_STATE,
14
   msgState: MsgState.INIT_STATE,
17
-  serverMsgErron: 'no error msg',
15
+  serverMsgError: 'no error msg'
18
 };
16
 };
19
 
17
 
20
-export function companyReducer(
21
-  companyState: CompanyState = companyInitialState,
22
-  action: Action
23
-) {
18
+export function companyReducer(state: CompanyState = companyInitialState, action: Action
19
+) : CompanyState {
20
+
24
   switch (action.type) {
21
   switch (action.type) {
25
     // get all companies
22
     // get all companies
26
     case CompanyActionTypes.GET_ALL_COMPANIES:
23
     case CompanyActionTypes.GET_ALL_COMPANIES:
27
       return {
24
       return {
28
-        ...companyState,
25
+        ...state,
29
         msgState: MsgState.LOADING,
26
         msgState: MsgState.LOADING,
30
       };
27
       };
31
 
28
 
32
     case CompanyActionTypes.GET_ALL_COMPANIES_SUCCESS:
29
     case CompanyActionTypes.GET_ALL_COMPANIES_SUCCESS:
33
       return {
30
       return {
34
-        ...companyState,
31
+        ...state,
35
         msgState: MsgState.LOADED,
32
         msgState: MsgState.LOADED,
36
-        companiesList: (<CompanyActionUnion>action).payload,
33
+        companiesList: (<CompanyActionUnion> action).payload
37
       };
34
       };
38
 
35
 
39
     case CompanyActionTypes.GET_ALL_COMPANIES_ERROR:
36
     case CompanyActionTypes.GET_ALL_COMPANIES_ERROR:
40
       return {
37
       return {
41
-        ...companyState,
38
+        ...state,
42
         msgState: MsgState.ERR,
39
         msgState: MsgState.ERR,
43
         serverMsgError: (<CompanyActionUnion>action).payload,
40
         serverMsgError: (<CompanyActionUnion>action).payload,
44
       };
41
       };
46
     //create form to update company
43
     //create form to update company
47
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE:
44
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE:
48
       return {
45
       return {
49
-        ...companyState,
46
+        ...state,
50
         msgState: MsgState.FORM_LOADING,
47
         msgState: MsgState.FORM_LOADING,
51
       };
48
       };
52
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE_SUCCESS:
49
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE_SUCCESS:
53
       let companyToUpdate: Company = (<CompanyActionUnion>action).payload;
50
       let companyToUpdate: Company = (<CompanyActionUnion>action).payload;
54
       return {
51
       return {
55
-        ...companyState,
52
+        ...state,
56
         msgState: MsgState.FORM_LOADED,
53
         msgState: MsgState.FORM_LOADED,
57
         currentCompany: companyToUpdate,
54
         currentCompany: companyToUpdate,
58
       };
55
       };
59
 
56
 
60
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE_ERROR:
57
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE_ERROR:
61
       return {
58
       return {
62
-        ...companyState,
59
+        ...state,
63
         msgState: MsgState.FORM_LOAD_ERR,
60
         msgState: MsgState.FORM_LOAD_ERR,
64
         serverMsgError: (<CompanyActionUnion>action).payload,
61
         serverMsgError: (<CompanyActionUnion>action).payload,
65
       };
62
       };
67
     //save form data to update company
64
     //save form data to update company
68
     case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA:
65
     case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA:
69
       return {
66
       return {
70
-        ...companyState,
71
-        msgState: MsgState.DEFAULT_MSG,
67
+        ...state,
68
+        msgState: MsgState.UPDATE,
72
       };
69
       };
73
     case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA_SUCCESS:
70
     case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA_SUCCESS:
74
       let updatedCompany: Company = (<CompanyActionUnion>action).payload;
71
       let updatedCompany: Company = (<CompanyActionUnion>action).payload;
75
-      let companiesListCopy1: Company[] = [...companyState.companiesList];
72
+      let companiesListCopy1: Company[] = [...state.companiesList];
76
       companiesListCopy1 = companiesListCopy1.map((company) =>
73
       companiesListCopy1 = companiesListCopy1.map((company) =>
77
         company.id == updatedCompany.id ? updatedCompany : company
74
         company.id == updatedCompany.id ? updatedCompany : company
78
       );
75
       );
79
 
76
 
80
       return{
77
       return{
81
-        ...companyState,
78
+        ...state,
82
         msgState: MsgState.UPDATED,
79
         msgState: MsgState.UPDATED,
83
         companiesList: companiesListCopy1
80
         companiesList: companiesListCopy1
84
       }
81
       }
85
 
82
 
86
       case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA_ERROR:
83
       case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA_ERROR:
87
         return{
84
         return{
88
-          ...companyState,
85
+          ...state,
89
           msgState: MsgState.ERR,
86
           msgState: MsgState.ERR,
90
           serverMsgError: (<CompanyActionUnion>action).payload
87
           serverMsgError: (<CompanyActionUnion>action).payload
91
         };
88
         };
93
         // delete a company
90
         // delete a company
94
       case CompanyActionTypes.DELETE_COMPANY:
91
       case CompanyActionTypes.DELETE_COMPANY:
95
         return{
92
         return{
96
-          ...companyState,
93
+          ...state,
97
           msgState: MsgState.DELETE
94
           msgState: MsgState.DELETE
98
         }
95
         }
99
 
96
 
100
       case CompanyActionTypes.DELETE_COMPANY_SUCCESS:
97
       case CompanyActionTypes.DELETE_COMPANY_SUCCESS:
101
         let deletedCompany: Company = (<CompanyActionUnion> action).payload;
98
         let deletedCompany: Company = (<CompanyActionUnion> action).payload;
102
-        let deletedCompanyIndex = companyState.companiesList.indexOf(deletedCompany);
103
-        let companiesListCopy2: Company[] = [...companyState.companiesList];
99
+        let deletedCompanyIndex = state.companiesList.indexOf(deletedCompany);
100
+        let companiesListCopy2: Company[] = [...state.companiesList];
104
         companiesListCopy2 = companiesListCopy2.splice(deletedCompanyIndex);
101
         companiesListCopy2 = companiesListCopy2.splice(deletedCompanyIndex);
105
 
102
 
106
         return{
103
         return{
107
-          ...companyState,
104
+          ...state,
108
           msgState: MsgState.DELETED,
105
           msgState: MsgState.DELETED,
109
           companiesList: companiesListCopy2
106
           companiesList: companiesListCopy2
110
         };
107
         };
111
 
108
 
112
       case CompanyActionTypes.DELETE_COMPANY_ERROR:
109
       case CompanyActionTypes.DELETE_COMPANY_ERROR:
113
         return{
110
         return{
114
-          ... companyState,
111
+          ... state,
112
+          msgState: MsgState.ERR,
113
+          serverMsgError: (<CompanyActionUnion> action).payload
114
+        };
115
+
116
+      // Get company's projects
117
+      case CompanyActionTypes.GET_COMPANY_S_PROJECTS:
118
+        return{
119
+          ...state,
120
+          msgState: MsgState.LOADING
121
+        };
122
+
123
+      case CompanyActionTypes.GET_COMPANY_S_PROJECTS_SUCCESS:
124
+        return{
125
+          ...state,
126
+          msgState: MsgState.LOADED,
127
+          companiesList: (<CompanyActionUnion> action).payload
128
+        };
129
+
130
+      case CompanyActionTypes.GET_COMPANY_S_PROJECTS_ERROR:
131
+        return{
132
+          ...state,
133
+          msgState: MsgState.ERR,
134
+          serverMsgError: (<CompanyActionUnion> action).payload
135
+        };
136
+
137
+      //create form to add company
138
+      case CompanyActionTypes.CREATE_COMPANY_FORM_ADD:
139
+        return{
140
+          ...state,
141
+          msgState: MsgState.FORM_LOADING,
142
+        };
143
+
144
+      case CompanyActionTypes.CREATE_COMPANY_FORM_ADD_SUCCESS:
145
+        return{
146
+          ...state,
147
+          msgState: MsgState.FORM_LOADED
148
+        };
149
+      case CompanyActionTypes.CREATE_COMPANY_FORM_ADD_ERROR:
150
+        return{
151
+          ...state,
152
+          msgState: MsgState.ERR,
153
+          serverMsgError: (<CompanyActionUnion> action).payload
154
+        };
155
+
156
+      // save company with form data
157
+      case CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD:
158
+        return{
159
+          ...state,
160
+          msgState: MsgState.ADD
161
+        };
162
+
163
+      case CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD_SUCCESS:
164
+        let createdCompany: Company = (<CompanyActionUnion> action).payload;
165
+        let companiesListCopy3 : Company[] = [...state.companiesList];
166
+        companiesListCopy3.push(createdCompany);
167
+
168
+        return{
169
+          ...state,
170
+          msgState: MsgState.ADDED,
171
+          companiesList: companiesListCopy3
172
+        };
173
+
174
+      case CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD_ERROR:
175
+        return{
176
+          ...state,
115
           msgState: MsgState.ERR,
177
           msgState: MsgState.ERR,
116
           serverMsgError: (<CompanyActionUnion> action).payload
178
           serverMsgError: (<CompanyActionUnion> action).payload
117
         };
179
         };
118
 
180
 
119
     default:
181
     default:
120
-      return { ...companyState };
182
+      return { ...state };
121
   }
183
   }
122
 }
184
 }

+ 19
- 14
src/app/ngrx/companies/company.action.types.ts View File

1
-export enum CompanyActionTypes{
1
+export enum CompanyActionTypes {
2
   //get all companies action
2
   //get all companies action
3
   GET_ALL_COMPANIES = '[Company] GET ALL COMPANIES',
3
   GET_ALL_COMPANIES = '[Company] GET ALL COMPANIES',
4
   GET_ALL_COMPANIES_SUCCESS = '[Company] GET ALL COMPANIES SUCCESS',
4
   GET_ALL_COMPANIES_SUCCESS = '[Company] GET ALL COMPANIES SUCCESS',
5
   GET_ALL_COMPANIES_ERROR = '[Company] GET ALL COMPANIES ERROR',
5
   GET_ALL_COMPANIES_ERROR = '[Company] GET ALL COMPANIES ERROR',
6
 
6
 
7
-  //create a company form to add a project
8
-  CREATE_COMPANY_FORM_ADD = '[Company] CREATE COMPANY FORM ADD',
9
-  CREATE_COMPANY_FORM_ADD_SUCCESS = '[Company] CREATE COMPANY FORM ADD SUCCESS',
10
-  CREATE_COMPANY_FORM_ADD_ERROR = '[Company] CREATE COMPANY FORM ADD ERROR',
11
-
12
-  //save a company form data
13
-  SAVE_COMPANY_FORM_DATA ='[Company] SAVE COMPANY FORM DATA',
14
-  SAVE_COMPANY_FORM_DATA_SUCCESS ='[Company] SAVE COMPANY FORM DATA SUCCESS',
15
-  SAVE_COMPANY_FORM_DATA_ERROR ='[Company] SAVE COMPANY FORM DATA ERROR',
16
-
17
   // create form to update a company
7
   // create form to update a company
18
   CREATE_COMPANY_FORM_UPDATE = '[Company] CREATE COMPANY FORM UPDATE',
8
   CREATE_COMPANY_FORM_UPDATE = '[Company] CREATE COMPANY FORM UPDATE',
19
   CREATE_COMPANY_FORM_UPDATE_SUCCESS = '[Company] CREATE COMPANY FORM UPDATE SUCCESS',
9
   CREATE_COMPANY_FORM_UPDATE_SUCCESS = '[Company] CREATE COMPANY FORM UPDATE SUCCESS',
20
   CREATE_COMPANY_FORM_UPDATE_ERROR = '[Company] CREATE COMPANY FORM UPDATE ERROR',
10
   CREATE_COMPANY_FORM_UPDATE_ERROR = '[Company] CREATE COMPANY FORM UPDATE ERROR',
21
 
11
 
22
   //update a company with form data
12
   //update a company with form data
23
-  UPDATE_COMPANY_WITH_FORM_DATA ='[Company] UPDATE COMPANY WITH FORM DATA',
24
-  UPDATE_COMPANY_WITH_FORM_DATA_SUCCESS ='[Company] UPDATE COMPANY WITH FORM DATA SUCCESS',
25
-  UPDATE_COMPANY_WITH_FORM_DATA_ERROR ='[Company] UPDATE COMPANY WITH FORM DATA ERROR',
13
+  UPDATE_COMPANY_WITH_FORM_DATA = '[Company] UPDATE COMPANY WITH FORM DATA',
14
+  UPDATE_COMPANY_WITH_FORM_DATA_SUCCESS = '[Company] UPDATE COMPANY WITH FORM DATA SUCCESS',
15
+  UPDATE_COMPANY_WITH_FORM_DATA_ERROR = '[Company] UPDATE COMPANY WITH FORM DATA ERROR',
26
 
16
 
27
   //Delete a company
17
   //Delete a company
28
   DELETE_COMPANY = '[Company] DELETE COMPANY',
18
   DELETE_COMPANY = '[Company] DELETE COMPANY',
29
   DELETE_COMPANY_SUCCESS = '[Company] DELETE COMPANY SUCCESS',
19
   DELETE_COMPANY_SUCCESS = '[Company] DELETE COMPANY SUCCESS',
30
   DELETE_COMPANY_ERROR = '[Company] DELETE COMPANY ERROR',
20
   DELETE_COMPANY_ERROR = '[Company] DELETE COMPANY ERROR',
21
+
22
+  // Get company's pprjects
23
+  GET_COMPANY_S_PROJECTS = 'GET COMPANY\'S PROJECT',
24
+  GET_COMPANY_S_PROJECTS_SUCCESS = 'GET COMPANY\'S PROJECT SUCCESS',
25
+  GET_COMPANY_S_PROJECTS_ERROR = 'GET COMPANY\'S PROJECT ERROR',
26
+
27
+  //create a company form to add a project
28
+  CREATE_COMPANY_FORM_ADD = '[Company] CREATE COMPANY FORM ADD',
29
+  CREATE_COMPANY_FORM_ADD_SUCCESS = '[Company] CREATE COMPANY FORM ADD SUCCESS',
30
+  CREATE_COMPANY_FORM_ADD_ERROR = '[Company] CREATE COMPANY FORM ADD ERROR',
31
+
32
+  //save a company form data
33
+  SAVE_COMPANY_FORM_DATA_ADD = '[Company] SAVE COMPANY FORM DATA ADD',
34
+  SAVE_COMPANY_FORM_DATA_ADD_SUCCESS = '[Company] SAVE COMPANY FORM DATA ADD SUCCESS',
35
+  SAVE_COMPANY_FORM_DATA_ADD_ERROR = '[Company] SAVE COMPANY FORM DATA ADD ERROR'
31
 }
36
 }

+ 1
- 1
src/app/ngrx/companies/company.state.ts View File

4
   currentCompany!: Company | null;
4
   currentCompany!: Company | null;
5
   companiesList!: Company[];
5
   companiesList!: Company[];
6
   msgState!: MsgState;
6
   msgState!: MsgState;
7
-  serverMsgErron!: string;
7
+  serverMsgError!: string;
8
 }
8
 }

+ 39
- 0
src/app/ngrx/companies/effects.company.create.ts View File

1
+import { Company } from 'src/app/shared/models/company/company.model';
2
+import { CompanyActionTypes } from './company.action.types';
3
+import { CompanyActionUnion, CreateCompanyFormAddActionSuccess, SaveCompanyFormDataAddActionSuccess, SaveCompanyFormDataAddActionError } from './companies.actions';
4
+import { map, Observable, mergeMap, catchError, of } from 'rxjs';
5
+import { CompaniesServices } from './../../shared/services/companies.service';
6
+import { Actions, createEffect, ofType } from '@ngrx/effects';
7
+import { Injectable } from '@angular/core';
8
+
9
+@Injectable()
10
+export class CompanyCreateEffects {
11
+  constructor(
12
+    private companyActions: Actions,
13
+    private companiesService: CompaniesServices
14
+  ) {}
15
+
16
+  // create company form to add company
17
+  createFormToAddCompanyEffect: Observable<CompanyActionUnion> = createEffect(
18
+    () => this.companyActions.pipe(
19
+        ofType(CompanyActionTypes.CREATE_COMPANY_FORM_ADD),
20
+        map((action: CompanyActionUnion) =>{
21
+          return new CreateCompanyFormAddActionSuccess()
22
+        })
23
+      )
24
+  );
25
+
26
+  // save company form data
27
+  saveCompanyFormDataAddEffect : Observable<CompanyActionUnion> = createEffect(
28
+    () => this.companyActions.pipe(
29
+      ofType(CompanyActionTypes.SAVE_COMPANY_FORM_DATA_ADD),
30
+      mergeMap( (action : CompanyActionUnion)  =>{
31
+        return this.companiesService.createCompany(action.payload).pipe(
32
+          map ( (company: Company) => new SaveCompanyFormDataAddActionSuccess(company)),
33
+          catchError( err => of(new SaveCompanyFormDataAddActionError( err.message)))
34
+        )
35
+      })
36
+    )
37
+  );
38
+
39
+}

+ 0
- 27
src/app/ngrx/companies/effects.company.get.search.ts View File

1
-import { Injectable } from '@angular/core';
2
-import { CompanyActionTypes } from './company.action.types';
3
-import { CompanyActionUnion, GetAllCompaniesActionSuccess, GetAllCompaniesActionError } from './companies.actions';
4
-import { Observable, mergeMap, catchError, map, of } from 'rxjs';
5
-import { CompaniesService } from './../../shared/services/companies.service';
6
-import { Actions, createEffect, ofType } from '@ngrx/effects';
7
-import { Company } from 'src/app/shared/models/company/company.model';
8
-
9
-@Injectable()
10
-export class CompanyGetSearchEffects {
11
-  constructor(
12
-    private companyActions: Actions,
13
-    private companiesService: CompaniesService
14
-  ) {}
15
-
16
-  getAllCompaniesEffect : Observable<CompanyActionUnion> = createEffect(
17
-    () => this.companyActions.pipe(
18
-      ofType(CompanyActionTypes.GET_ALL_COMPANIES),
19
-      mergeMap(()=>{
20
-        return this.companiesService.getAllCompanies().pipe(
21
-          map( (companies: Company[])=> new GetAllCompaniesActionSuccess(companies)),
22
-          catchError(err=> of(new GetAllCompaniesActionError(err.message)))
23
-        )
24
-      })
25
-    )
26
-  );
27
-}

+ 54
- 0
src/app/ngrx/companies/effects.company.get.ts View File

1
+import { Injectable } from '@angular/core';
2
+import { CompanyActionTypes } from './company.action.types';
3
+import {
4
+  CompanyActionUnion,
5
+  GetAllCompaniesActionSuccess,
6
+  GetAllCompaniesActionError,
7
+  GetCompany_S_ProjectsSuccess,
8
+  GetCompany_S_ProjectsError,
9
+} from './companies.actions';
10
+import { Observable, mergeMap, catchError, map, of } from 'rxjs';
11
+import { CompaniesServices } from '../../shared/services/companies.service';
12
+import { Actions, createEffect, ofType } from '@ngrx/effects';
13
+import { Company } from 'src/app/shared/models/company/company.model';
14
+
15
+@Injectable()
16
+export class CompanyGetSearchEffects {
17
+  constructor(
18
+    private companyActions: Actions,
19
+    private companiesService: CompaniesServices
20
+  ) {}
21
+
22
+  // get all companies effect
23
+  getAllCompaniesEffect: Observable<CompanyActionUnion> = createEffect(() =>
24
+    this.companyActions.pipe(
25
+      ofType(CompanyActionTypes.GET_ALL_COMPANIES),
26
+      mergeMap(() => {
27
+        return this.companiesService.getAllCompanies().pipe(
28
+          map(
29
+            (companies: Company[]) =>
30
+              new GetAllCompaniesActionSuccess(companies)
31
+          ),
32
+          catchError((err) => of(new GetAllCompaniesActionError(err.message)))
33
+        );
34
+      })
35
+    )
36
+  );
37
+
38
+  // get company's projects effect
39
+  getCompany_s_ProjectEffect: Observable<CompanyActionUnion> = createEffect(
40
+    () =>
41
+      this.companyActions.pipe(
42
+        ofType(CompanyActionTypes.GET_COMPANY_S_PROJECTS),
43
+        mergeMap((action: CompanyActionUnion) => {
44
+          return this.companiesService.getCompany_s_Projects().pipe(
45
+            map(
46
+              (company_s_ProjectsList: any) =>
47
+                new GetCompany_S_ProjectsSuccess(company_s_ProjectsList)
48
+            ),
49
+            catchError((err) => of(new GetCompany_S_ProjectsError(err.message)))
50
+          );
51
+        })
52
+      )
53
+  );
54
+}

+ 5
- 5
src/app/ngrx/companies/effects.company.update.delete.ts View File

1
 import { CompanyActionTypes } from './company.action.types';
1
 import { CompanyActionTypes } from './company.action.types';
2
-import { CompanyActionUnion, CreateFormToUpdateCompanyActionSuccess, CreateFormToUpdateCompanyActionError, UpdateCompanyWithFormDataActionSuccess, UpdateCompanyWithFormDataActionError, DeleteCompany, DeleteCompanySuccess, DeleteCompanyError } from './companies.actions';
2
+import { CompanyActionUnion, CreateFormToUpdateCompanyActionSuccess, CreateFormToUpdateCompanyActionError, UpdateCompanyWithFormDataActionSuccess, UpdateCompanyWithFormDataActionError, DeleteCompanyAction, DeleteCompanyActionSuccess, DeleteCompanyActionError } from './companies.actions';
3
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
3
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
4
 import { Actions, createEffect, ofType } from '@ngrx/effects';
4
 import { Actions, createEffect, ofType } from '@ngrx/effects';
5
-import { CompaniesService } from './../../shared/services/companies.service';
5
+import { CompaniesServices } from './../../shared/services/companies.service';
6
 import { Injectable } from '@angular/core';
6
 import { Injectable } from '@angular/core';
7
 import { Company } from 'src/app/shared/models/company/company.model';
7
 import { Company } from 'src/app/shared/models/company/company.model';
8
 
8
 
9
 @Injectable()
9
 @Injectable()
10
 export class CompanyUpdateDeleteEffects {
10
 export class CompanyUpdateDeleteEffects {
11
   constructor(
11
   constructor(
12
-    private companiesService: CompaniesService,
12
+    private companiesService: CompaniesServices,
13
     private companyActions: Actions
13
     private companyActions: Actions
14
   ) {}
14
   ) {}
15
 
15
 
46
       ofType(CompanyActionTypes.DELETE_COMPANY),
46
       ofType(CompanyActionTypes.DELETE_COMPANY),
47
       mergeMap((action: CompanyActionUnion)=>{
47
       mergeMap((action: CompanyActionUnion)=>{
48
         return this.companiesService.deleteCompany(action.payload.id).pipe(
48
         return this.companiesService.deleteCompany(action.payload.id).pipe(
49
-          map(()=>new DeleteCompanySuccess(action.payload)),
50
-          catchError(err=> of(new DeleteCompanyError(err.message)))
49
+          map(()=>new DeleteCompanyActionSuccess(action.payload)),
50
+          catchError(err=> of(new DeleteCompanyActionError(err.message)))
51
         )
51
         )
52
       })
52
       })
53
     )
53
     )

+ 2
- 1
src/app/ngrx/msg.state.ts View File

9
   CONFIRM_ADD = 'CONFIRM ADDING',
9
   CONFIRM_ADD = 'CONFIRM ADDING',
10
   CONFIRM_UPDATE = 'CONFIRM UPDATE',
10
   CONFIRM_UPDATE = 'CONFIRM UPDATE',
11
   CONFIRM_DEL = 'CONFIRM DELETION',
11
   CONFIRM_DEL = 'CONFIRM DELETION',
12
+  ADD ='IS ADDING',
12
   ADDED = 'SUCCESSFULLY ADDED',
13
   ADDED = 'SUCCESSFULLY ADDED',
13
   EXIST = 'ALREADY EXISTS',
14
   EXIST = 'ALREADY EXISTS',
15
+  UPDATE = 'IS UPDATING',
14
   UPDATED = ' SUCCESSFULLY UPDATED',
16
   UPDATED = ' SUCCESSFULLY UPDATED',
15
-  DEFAULT_MSG = 'DEFAULT MSG LOADING',
16
   DELETE = 'DELETE',
17
   DELETE = 'DELETE',
17
   DELETED = 'SUCCESSFULLY DELETED'
18
   DELETED = 'SUCCESSFULLY DELETED'
18
 }
19
 }

+ 2
- 2
src/app/ngrx/projects/effects.project.create.ts View File

1
 import { ProjectActionTypes } from './project.action.types';
1
 import { ProjectActionTypes } from './project.action.types';
2
 import { ProjectActionUnion, CreateProjectFormAddAction, SaveProjectFormDataActionSuccess, SaveProjectFormDataActionError, CreateProjectFormAddActionSuccess } from './projects.actions';
2
 import { ProjectActionUnion, CreateProjectFormAddAction, SaveProjectFormDataActionSuccess, SaveProjectFormDataActionError, CreateProjectFormAddActionSuccess } from './projects.actions';
3
 import { map, Observable, mergeMap, catchError, of } from 'rxjs';
3
 import { map, Observable, mergeMap, catchError, of } from 'rxjs';
4
-import { ProjectsService } from './../../shared/services/projects.service';
4
+import { ProjectsServices } from './../../shared/services/projects.service';
5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
6
 import { Injectable } from '@angular/core';
6
 import { Injectable } from '@angular/core';
7
 import { Project } from 'src/app/shared/models/project/project.model';
7
 import { Project } from 'src/app/shared/models/project/project.model';
11
 
11
 
12
   constructor(
12
   constructor(
13
     private projectActions: Actions,
13
     private projectActions: Actions,
14
-    private projectsService: ProjectsService
14
+    private projectsService: ProjectsServices
15
   ) {}
15
   ) {}
16
 
16
 
17
   //create project form effect
17
   //create project form effect

+ 3
- 3
src/app/ngrx/projects/effects.project.get.ts View File

3
 import { ProjectActionUnion, GetAllProjectsActionSuccess, GetAllProjectsActionError, GetProjectWithUserAssociatedActionSuccess, GetProjectWithUserAssociatedActionError, GetProjectWithCompanyAssociatedActionSuccess, GetProjectWithCompanyAssociatedActionError } from './projects.actions';
3
 import { ProjectActionUnion, GetAllProjectsActionSuccess, GetAllProjectsActionError, GetProjectWithUserAssociatedActionSuccess, GetProjectWithUserAssociatedActionError, GetProjectWithCompanyAssociatedActionSuccess, GetProjectWithCompanyAssociatedActionError } from './projects.actions';
4
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
4
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
6
-import { ProjectsService } from './../../shared/services/projects.service';
6
+import { ProjectsServices } from './../../shared/services/projects.service';
7
 import { Injectable } from '@angular/core';
7
 import { Injectable } from '@angular/core';
8
 
8
 
9
 @Injectable()
9
 @Injectable()
10
-export class ProjectGet {
10
+export class ProjectGetEffects {
11
   constructor(
11
   constructor(
12
-    private projectsService: ProjectsService,
12
+    private projectsService: ProjectsServices,
13
     private projectActions: Actions
13
     private projectActions: Actions
14
   ) {}
14
   ) {}
15
 
15
 

+ 2
- 2
src/app/ngrx/projects/effects.project.update.delete.ts View File

11
 } from './projects.actions';
11
 } from './projects.actions';
12
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
12
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
13
 import { Actions, createEffect, ofType } from '@ngrx/effects';
13
 import { Actions, createEffect, ofType } from '@ngrx/effects';
14
-import { ProjectsService } from '../../shared/services/projects.service';
14
+import { ProjectsServices } from '../../shared/services/projects.service';
15
 import { Injectable } from '@angular/core';
15
 import { Injectable } from '@angular/core';
16
 
16
 
17
 @Injectable()
17
 @Injectable()
18
 export class ProjectUpdateEffects {
18
 export class ProjectUpdateEffects {
19
   constructor(
19
   constructor(
20
-    private projectsService: ProjectsService,
20
+    private projectsService: ProjectsServices,
21
     private projectActions: Actions
21
     private projectActions: Actions
22
   ) {}
22
   ) {}
23
 
23
 

+ 1
- 1
src/app/ngrx/projects/projects.reducer.ts View File

109
     case ProjectActionTypes.UPDATE_PROJECT_WITH_FORM_DATA:
109
     case ProjectActionTypes.UPDATE_PROJECT_WITH_FORM_DATA:
110
       return {
110
       return {
111
         ...state,
111
         ...state,
112
-        msgState: MsgState.DEFAULT_MSG,
112
+        msgState: MsgState.UPDATE,
113
       };
113
       };
114
 
114
 
115
     case ProjectActionTypes.UPDATE_PROJECT_WITH_FORM_DATA_SUCCESS:
115
     case ProjectActionTypes.UPDATE_PROJECT_WITH_FORM_DATA_SUCCESS:

+ 39
- 34
src/app/ngrx/users/effects.user.create.ts View File

1
-import { UsersService } from '../../shared/services/users.service';
2
-import { CreateFormUserAddActionError, CreateFormUserAddActionSuccess, SaveUserFormAddActionError, SaveUserFormAddActionSuccess, UserActionUnion } from './users.actions';
3
-import { Injectable } from "@angular/core";
1
+import { UsersServices } from '../../shared/services/users.service';
2
+import {
3
+  CreateFormUserAddActionError,
4
+  CreateFormUserAddActionSuccess,
5
+  SaveUserFormAddActionError,
6
+  SaveUserFormAddActionSuccess,
7
+  UserActionUnion,
8
+} from './users.actions';
9
+import { Injectable } from '@angular/core';
4
 import { catchError, map, mergeMap, Observable, of } from 'rxjs';
10
 import { catchError, map, mergeMap, Observable, of } from 'rxjs';
5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
11
 import { Actions, createEffect, ofType } from '@ngrx/effects';
6
 import { UserActionTypes } from './user.action.types';
12
 import { UserActionTypes } from './user.action.types';
7
 import { User } from 'src/app/shared/models/user/user.model';
13
 import { User } from 'src/app/shared/models/user/user.model';
8
 
14
 
9
 @Injectable()
15
 @Injectable()
10
-export class UserCreateEffects{
11
-
12
-  constructor(private userActions: Actions, private usersService: UsersService){}
13
-
14
-
15
-
16
-   //create a user add form effect
17
-   createAddUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
18
-   this.userActions.pipe(
19
-     ofType(UserActionTypes.CREATE_FORM_ADD_USER),
20
-     map((userAction: UserActionUnion) => {
21
-       return new CreateFormUserAddActionSuccess(userAction.payload);
22
-     }),
23
-     catchError((err) => of(new CreateFormUserAddActionError(err.message)))
24
-   )
25
- );
26
-
27
- //saving user form data effect
28
-
29
- saveUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
30
-   this.userActions.pipe(
31
-     ofType(UserActionTypes.SAVE_USERFORM_ADD),
32
-     mergeMap((userAction: UserActionUnion) => {
33
-       return this.usersService.createUser(userAction.payload).pipe(
34
-         map((user:User) => new SaveUserFormAddActionSuccess(user)),
35
-         catchError((err) => of(new SaveUserFormAddActionError(err.message)))
36
-       );
37
-     })
38
-   )
39
- );
40
-
16
+export class UserCreateEffects {
17
+  constructor(
18
+    private userActions: Actions,
19
+    private usersService: UsersServices
20
+  ) {}
21
+
22
+  //create a user add form effect
23
+  createAddUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
24
+    this.userActions.pipe(
25
+      ofType(UserActionTypes.CREATE_FORM_ADD_USER),
26
+      map((userAction: UserActionUnion) => {
27
+        return new CreateFormUserAddActionSuccess(userAction.payload);
28
+      }),
29
+      catchError((err) => of(new CreateFormUserAddActionError(err.message)))
30
+    )
31
+  );
32
+
33
+  //saving user form data effect
34
+
35
+  saveUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
36
+    this.userActions.pipe(
37
+      ofType(UserActionTypes.SAVE_USERFORM_ADD),
38
+      mergeMap((userAction: UserActionUnion) => {
39
+        return this.usersService.createUser(userAction.payload).pipe(
40
+          map((user: User) => new SaveUserFormAddActionSuccess(user)),
41
+          catchError((err) => of(new SaveUserFormAddActionError(err.message)))
42
+        );
43
+      })
44
+    )
45
+  );
41
 }
46
 }

src/app/ngrx/users/effects.user.get.search.ts → src/app/ngrx/users/effects.user.get.ts View File

1
 import { Router } from '@angular/router';
1
 import { Router } from '@angular/router';
2
-import { UsersService } from '../../shared/services/users.service';
2
+import { UsersServices } from '../../shared/services/users.service';
3
 import { Actions, createEffect, ofType } from '@ngrx/effects';
3
 import { Actions, createEffect, ofType } from '@ngrx/effects';
4
 import { Injectable } from '@angular/core';
4
 import { Injectable } from '@angular/core';
5
-import { GetAllUsersActionError, GetAllUsersActionSuccess, GetUser_s_ProjectsError, GetUser_s_ProjectsSuccess, SearchUserActionError, SearchUserActionSuccess, UserActionUnion } from './users.actions';
5
+import {
6
+  GetAllUsersActionError,
7
+  GetAllUsersActionSuccess,
8
+  GetUser_S_ProjectsError,
9
+  GetUser_S_ProjectsSuccess,
10
+  UserActionUnion,
11
+} from './users.actions';
6
 import { Observable, mergeMap, map, catchError, of, tap } from 'rxjs';
12
 import { Observable, mergeMap, map, catchError, of, tap } from 'rxjs';
7
 import { User } from 'src/app/shared/models/user/user.model';
13
 import { User } from 'src/app/shared/models/user/user.model';
8
 import { UserActionTypes } from './user.action.types';
14
 import { UserActionTypes } from './user.action.types';
11
 export class UserGetSearchEffects {
17
 export class UserGetSearchEffects {
12
   constructor(
18
   constructor(
13
     private userActions: Actions,
19
     private userActions: Actions,
14
-    private usersService: UsersService,
20
+    private usersService: UsersServices,
15
     private router: Router
21
     private router: Router
16
   ) {}
22
   ) {}
17
 
23
 
18
-  //create getAllUsers effect
24
+  //getAllUsers effect
19
 
25
 
20
   getAllUsersEffect: Observable<UserActionUnion> = createEffect(() =>
26
   getAllUsersEffect: Observable<UserActionUnion> = createEffect(() =>
21
     this.userActions.pipe(
27
     this.userActions.pipe(
29
     )
35
     )
30
   );
36
   );
31
 
37
 
32
-  //create searchUser effect
33
-
34
-  searchUserEffect: Observable<UserActionUnion> = createEffect(() =>
35
-    this.userActions.pipe(
36
-      ofType(UserActionTypes.SEARCH_A_USER),
37
-      mergeMap((userAction: UserActionUnion) => {
38
-        return this.usersService.searchUser(userAction.payload).pipe(
39
-          map((users: User[]) => new SearchUserActionSuccess(users)),
40
-          catchError((err) => of(new SearchUserActionError(err.message)))
41
-        );
42
-      })
43
-    )
44
-  );
45
 
38
 
46
   // navigate to another component effect
39
   // navigate to another component effect
47
-  navigate:Observable<UserActionUnion> = createEffect(
48
-    () => this.userActions.pipe(
40
+  navigate: Observable<UserActionUnion> = createEffect(
41
+    () =>
42
+      this.userActions.pipe(
49
         ofType(UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS),
43
         ofType(UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS),
50
         tap(() => {
44
         tap(() => {
51
-            this.router.navigate(['/user-s-projects']);
45
+          this.router.navigate(['/user-s-projects']);
52
         })
46
         })
53
-    ),
47
+      ),
54
     { dispatch: false }
48
     { dispatch: false }
55
-);
49
+  );
50
+
51
+  // get user's projects
56
 
52
 
57
-  loadUserSProjectsEffect : Observable<UserActionUnion> = createEffect(
58
-    ()=> this.userActions.pipe(
53
+  loadUserSProjectsEffect: Observable<UserActionUnion> = createEffect(() =>
54
+    this.userActions.pipe(
59
       ofType(UserActionTypes.GET_USER_S_PROJECTS),
55
       ofType(UserActionTypes.GET_USER_S_PROJECTS),
60
-      mergeMap( (action: UserActionUnion)=>{
56
+      mergeMap((action: UserActionUnion) => {
61
         return this.usersService.getUser_s_Projects().pipe(
57
         return this.usersService.getUser_s_Projects().pipe(
62
-          map( (users: any)=> new GetUser_s_ProjectsSuccess(users)),
63
-          catchError(err => of(new GetUser_s_ProjectsError(err.message)))
64
-        )
58
+          map((users: any) => new GetUser_S_ProjectsSuccess(users)),
59
+          catchError((err) => of(new GetUser_S_ProjectsError(err.message)))
60
+        );
65
       })
61
       })
66
     )
62
     )
67
   );
63
   );

+ 2
- 2
src/app/ngrx/users/effects.user.update.delete.ts View File

8
   UpdateUserFormActionSuccess,
8
   UpdateUserFormActionSuccess,
9
 } from './users.actions';
9
 } from './users.actions';
10
 import { map, mergeMap, Observable, catchError, of } from 'rxjs';
10
 import { map, mergeMap, Observable, catchError, of } from 'rxjs';
11
-import { UsersService } from '../../shared/services/users.service';
11
+import { UsersServices } from '../../shared/services/users.service';
12
 import { Injectable } from '@angular/core';
12
 import { Injectable } from '@angular/core';
13
 import { Actions, createEffect, ofType } from '@ngrx/effects';
13
 import { Actions, createEffect, ofType } from '@ngrx/effects';
14
 import { User } from 'src/app/shared/models/user/user.model';
14
 import { User } from 'src/app/shared/models/user/user.model';
19
 
19
 
20
 export class UserUpdateEffects {
20
 export class UserUpdateEffects {
21
   constructor(
21
   constructor(
22
-    private usersService: UsersService,
22
+    private usersService: UsersServices,
23
     private effectActions: Actions
23
     private effectActions: Actions
24
   ) {}
24
   ) {}
25
 
25
 

+ 0
- 6
src/app/ngrx/users/user.action.types.ts View File

7
   GET_ALL_USERS_SUCCESS = '[User] GET-ALL USERS SUCCESS',
7
   GET_ALL_USERS_SUCCESS = '[User] GET-ALL USERS SUCCESS',
8
   GET_ALL_USERS_ERROR = '[User] GET ALL USERS ERROR',
8
   GET_ALL_USERS_ERROR = '[User] GET ALL USERS ERROR',
9
 
9
 
10
-  // action: search a user
11
-  SEARCH_A_USER = '[User] SEARCH A USER',
12
-  SEARCH_A_USER_SUCCESS = '[User] SEARCH A USER SUCCESS',
13
-  SEARCH_A_USER_ERROR = '[User] SEARCH A USER ERROR',
14
-
15
-
16
   // action of button: create a user form
10
   // action of button: create a user form
17
   CREATE_FORM_ADD_USER = '[User] USER FORM ADD',
11
   CREATE_FORM_ADD_USER = '[User] USER FORM ADD',
18
   CREATE_FORM_ADD_USER_SUCCESS = '[User] USER FORM ADD SUCCESS',
12
   CREATE_FORM_ADD_USER_SUCCESS = '[User] USER FORM ADD SUCCESS',

+ 4
- 25
src/app/ngrx/users/users.actions.ts View File

23
   constructor(public payload: string) {}
23
   constructor(public payload: string) {}
24
 }
24
 }
25
 
25
 
26
- // Actios of searching a user
27
-
28
-export class SearchUsersAction implements Action {
29
-  type: UserActionTypes = UserActionTypes.SEARCH_A_USER;
30
-
31
-  constructor(public payload: any) {}
32
-}
33
-
34
-export class SearchUserActionSuccess implements Action {
35
-  type: UserActionTypes = UserActionTypes.SEARCH_A_USER_SUCCESS;
36
-  constructor(public payload: User[]) {}
37
-}
38
-
39
-export class SearchUserActionError implements Action {
40
-  type: UserActionTypes = UserActionTypes.SEARCH_A_USER_ERROR;
41
-  constructor(public payload: string) {}
42
-}
43
-
44
 // Actios of creating a user form to add user
26
 // Actios of creating a user form to add user
45
 
27
 
46
 export class CreateFormUserAddAction implements Action {
28
 export class CreateFormUserAddAction implements Action {
133
   constructor(public payload: any){}
115
   constructor(public payload: any){}
134
 }
116
 }
135
 
117
 
136
-export class GetUser_s_ProjectsSuccess implements Action{
118
+export class GetUser_S_ProjectsSuccess implements Action{
137
   type: UserActionTypes = UserActionTypes.GET_USER_S_PROJECTS_SUCCESS;
119
   type: UserActionTypes = UserActionTypes.GET_USER_S_PROJECTS_SUCCESS;
138
   constructor(public payload: any){}
120
   constructor(public payload: any){}
139
 }
121
 }
140
 
122
 
141
-export class GetUser_s_ProjectsError implements Action{
123
+export class GetUser_S_ProjectsError implements Action{
142
   type: UserActionTypes = UserActionTypes.GET_USER_S_PROJECTS_ERROR;
124
   type: UserActionTypes = UserActionTypes.GET_USER_S_PROJECTS_ERROR;
143
   constructor(public payload: string){}
125
   constructor(public payload: string){}
144
 }
126
 }
153
   | GetAllUsersAction
135
   | GetAllUsersAction
154
   | GetAllUsersActionSuccess
136
   | GetAllUsersActionSuccess
155
   | GetAllUsersActionError
137
   | GetAllUsersActionError
156
-  | SearchUsersAction
157
-  | SearchUserActionSuccess
158
-  | SearchUserActionError
159
   | CreateFormUserAddAction
138
   | CreateFormUserAddAction
160
   | CreateFormUserAddActionSuccess
139
   | CreateFormUserAddActionSuccess
161
   | CreateFormUserAddActionError
140
   | CreateFormUserAddActionError
172
   | DeleteUserActionSuccess
151
   | DeleteUserActionSuccess
173
   | DeleteUserActionError
152
   | DeleteUserActionError
174
   | GetUser_S_Projects
153
   | GetUser_S_Projects
175
-  | GetUser_s_ProjectsSuccess
176
-  | GetUser_s_ProjectsError
154
+  | GetUser_S_ProjectsSuccess
155
+  | GetUser_S_ProjectsError
177
   | NavigateActionSuccess;
156
   | NavigateActionSuccess;

+ 0
- 158
src/app/ngrx/users/users.effects.ts View File

1
-import { Injectable } from '@angular/core';
2
-import { Router } from '@angular/router';
3
-import { Actions, createEffect, ofType } from '@ngrx/effects';
4
-import { Observable, mergeMap, map, catchError, of, tap } from 'rxjs';
5
-import { User } from 'src/app/shared/models/user/user.model';
6
-import { UsersService } from 'src/app/shared/services/users.service';
7
-import { UserActionTypes } from './user.action.types';
8
-import {
9
-  UserActionUnion,
10
-  GetAllUsersActionSuccess,
11
-  GetAllUsersActionError,
12
-  SearchUserActionSuccess,
13
-  SearchUserActionError,
14
-  GetUser_s_ProjectsSuccess,
15
-  GetUser_s_ProjectsError,
16
-  CreateFormUserAddActionError,
17
-  CreateFormUserAddActionSuccess,
18
-  SaveUserFormAddActionError,
19
-  SaveUserFormAddActionSuccess,
20
-  CreareFormUserEditActionActionError,
21
-  CreareFormUserEditActionSuccess,
22
-  DeleteUserActionError,
23
-  DeleteUserActionSuccess,
24
-  UpdateUserFormActionError,
25
-  UpdateUserFormActionSuccess,
26
-} from './users.actions';
27
-@Injectable()
28
-export class UsersEffects {
29
-  effectActions: any;
30
-  constructor(
31
-    private userActions: Actions,
32
-    private usersService: UsersService,
33
-    private router: Router
34
-  ) {}
35
-
36
-  //create getAllUsers effect
37
-
38
-  getAllUsersEffect: Observable<UserActionUnion> = createEffect(() =>
39
-    this.userActions.pipe(
40
-      ofType(UserActionTypes.GET_ALL_USERS),
41
-      mergeMap(() => {
42
-        return this.usersService.getAllUsers().pipe(
43
-          map((users: User[]) => new GetAllUsersActionSuccess(users)),
44
-          catchError((err) => of(new GetAllUsersActionError(err.message)))
45
-        );
46
-      })
47
-    )
48
-  );
49
-
50
-  //create searchUser effect
51
-
52
-  searchUserEffect: Observable<UserActionUnion> = createEffect(() =>
53
-    this.userActions.pipe(
54
-      ofType(UserActionTypes.SEARCH_A_USER),
55
-      mergeMap((userAction: UserActionUnion) => {
56
-        return this.usersService.searchUser(userAction.payload).pipe(
57
-          map((users: User[]) => new SearchUserActionSuccess(users)),
58
-          catchError((err) => of(new SearchUserActionError(err.message)))
59
-        );
60
-      })
61
-    )
62
-  );
63
-
64
-  // navigate to another component effect
65
-  navigate: Observable<UserActionUnion> = createEffect(
66
-    () =>
67
-      this.userActions.pipe(
68
-        ofType(UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS),
69
-        tap(() => {
70
-          this.router.navigate(['/user-s-projects']);
71
-        })
72
-      ),
73
-    { dispatch: false }
74
-  );
75
-
76
-  loadUserSProjectsEffect: Observable<UserActionUnion> = createEffect(() =>
77
-    this.userActions.pipe(
78
-      ofType(UserActionTypes.GET_USER_S_PROJECTS),
79
-      mergeMap((action: UserActionUnion) => {
80
-        return this.usersService.getUser_s_Projects().pipe(
81
-          map((users: any) => new GetUser_s_ProjectsSuccess(users)),
82
-          catchError((err) => of(new GetUser_s_ProjectsError(err.message)))
83
-        );
84
-      })
85
-    )
86
-  );
87
-
88
-
89
-   //create a user add form effect
90
-   createAddUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
91
-   this.userActions.pipe(
92
-     ofType(UserActionTypes.CREATE_FORM_ADD_USER),
93
-     map((userAction: UserActionUnion) => {
94
-       return new CreateFormUserAddActionSuccess(userAction.payload);
95
-     }),
96
-     catchError((err) => of(new CreateFormUserAddActionError(err.message)))
97
-   )
98
- );
99
-
100
- //saving user form data effect
101
-
102
- saveUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
103
-   this.userActions.pipe(
104
-     ofType(UserActionTypes.SAVE_USERFORM_ADD),
105
-     mergeMap((userAction: UserActionUnion) => {
106
-       return this.usersService.createUser(userAction.payload).pipe(
107
-         map((user:User) => new SaveUserFormAddActionSuccess(user)),
108
-         catchError((err) => of(new SaveUserFormAddActionError(err.message)))
109
-       );
110
-     })
111
-   )
112
- );
113
-
114
- // create an update user form effect and fill it with data of a user to update
115
-
116
- createUpdateUserFormEffect: Observable<UserActionUnion> = createEffect(() =>
117
- this.effectActions.pipe(
118
-   ofType(UserActionTypes.CREATE_FORM_USER_EDIT),
119
-   mergeMap((userAction: UserActionUnion) => {
120
-     return this.usersService.getUserById(userAction.payload.id).pipe(
121
-       map((user: User) => new CreareFormUserEditActionSuccess(user)),
122
-       catchError((err) =>
123
-         of(new CreareFormUserEditActionActionError(err.message))
124
-       )
125
-     );
126
-   })
127
- )
128
-);
129
-
130
-// update a user with data of form effect
131
-
132
-updateUserFormDataEffect: Observable<UserActionUnion> = createEffect(() =>
133
- this.effectActions.pipe(
134
-   ofType(UserActionTypes.UPDATE_USER_FORM),
135
-   mergeMap((userAction: UserActionUnion) => {
136
-     return this.usersService.updateUser(userAction.payload).pipe(
137
-       map((user: User) => new UpdateUserFormActionSuccess(user)),
138
-       catchError((err) => of(new UpdateUserFormActionError(err.message)))
139
-     );
140
-   })
141
- )
142
-);
143
-
144
-//deleteUser effect
145
-
146
-deleteUserEffect: Observable<UserActionUnion> = createEffect(() =>
147
- this.effectActions.pipe(
148
-   ofType(UserActionTypes.DELETE_A_USER),
149
-   mergeMap((userAction: UserActionUnion) => {
150
-     return this.usersService.deleteUser(userAction.payload.id).pipe(
151
-       map(() => new DeleteUserActionSuccess(userAction.payload)),
152
-       catchError((err) => of(new DeleteUserActionError(err.message)))
153
-     );
154
-   })
155
- )
156
-);
157
-
158
-}

+ 4
- 24
src/app/ngrx/users/users.reducer.ts View File

41
         serverMsgError: (<UserActionUnion>action).payload
41
         serverMsgError: (<UserActionUnion>action).payload
42
       };
42
       };
43
 
43
 
44
-    // search a user actions
45
-    case UserActionTypes.SEARCH_A_USER:
46
-      return {
47
-        ...state,
48
-        msgState: MsgState.LOADING
49
-      };
50
-
51
-    case UserActionTypes.SEARCH_A_USER_SUCCESS:
52
-      return {
53
-        ...state,
54
-        msgState: MsgState.LOADED,
55
-        usersList: (<UserActionUnion>action).payload
56
-      };
57
-
58
-    case UserActionTypes.SEARCH_A_USER_ERROR:
59
-      return {
60
-        ...state,
61
-        msgState: MsgState.ERR,
62
-        serverMsgError: (<UserActionUnion>action).payload
63
-      };
64
 
44
 
65
-    // create a user form actions
45
+    // create a user form action to add a suer
66
     case UserActionTypes.CREATE_FORM_ADD_USER:
46
     case UserActionTypes.CREATE_FORM_ADD_USER:
67
       return {
47
       return {
68
         ...state,
48
         ...state,
86
     case UserActionTypes.SAVE_USERFORM_ADD:
66
     case UserActionTypes.SAVE_USERFORM_ADD:
87
       return {
67
       return {
88
         ...state,
68
         ...state,
89
-        msgState: MsgState.DEFAULT_MSG
69
+        msgState: MsgState.ADD
90
       };
70
       };
91
 
71
 
92
     case UserActionTypes.SAVE_USERFORM_ADD_SUCCESS:
72
     case UserActionTypes.SAVE_USERFORM_ADD_SUCCESS:
134
     case UserActionTypes.UPDATE_USER_FORM:
114
     case UserActionTypes.UPDATE_USER_FORM:
135
       return {
115
       return {
136
         ...state,
116
         ...state,
137
-        msgState: MsgState.DEFAULT_MSG
117
+        msgState: MsgState.UPDATE
138
       };
118
       };
139
 
119
 
140
     case UserActionTypes.UPDATE_USER_FORM_SUCCESS:
120
     case UserActionTypes.UPDATE_USER_FORM_SUCCESS:
207
     case UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS:
187
     case UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS:
208
       return{
188
       return{
209
         ...state,
189
         ...state,
210
-        msgState: MsgState.DEFAULT_MSG
190
+        msgState: MsgState.UPDATE
211
       };
191
       };
212
 
192
 
213
     default:
193
     default:

+ 3
- 3
src/app/pages/accueil/accueil-routing.module.ts View File

3
 import { AccueilComponent } from './accueil/accueil.component';
3
 import { AccueilComponent } from './accueil/accueil.component';
4
 
4
 
5
 const routes: Routes = [
5
 const routes: Routes = [
6
-  // {
7
-  //   path:'', component: AccueilComponent
8
-  // }
6
+  {
7
+    path:'', component: AccueilComponent
8
+  }
9
 ];
9
 ];
10
 
10
 
11
 @NgModule({
11
 @NgModule({

+ 3
- 3
src/app/pages/accueil/accueil/accueil.component.html View File

2
 <div class="container mt-5">
2
 <div class="container mt-5">
3
   <div class="row d-flex justify-content-left">
3
   <div class="row d-flex justify-content-left">
4
 
4
 
5
-    <div class="card bg-light" style="width: 20rem;">
5
+    <div>
6
       <div class="card-body">
6
       <div class="card-body">
7
         <h4 class="card-title">Welcome to Natan</h4>
7
         <h4 class="card-title">Welcome to Natan</h4>
8
-        <p class="card-text">NATAN est palindrome</p>
9
-        <p>Ce qui fait de NATAN le meilleur</p>
8
+        <p class="card-text p-2">NATAN est palindrome</p>
9
+        <p class="card-text">Ce qui fait de NATAN le meilleur</p>
10
       </div>
10
       </div>
11
     </div>
11
     </div>
12
 
12
 

+ 10
- 10
src/app/pages/base-nav-menu/base-nav-menu.component.html View File

8
     </mat-toolbar>
8
     </mat-toolbar>
9
 
9
 
10
       <mat-nav-list>
10
       <mat-nav-list>
11
+        <a mat-list-item routerLink="/">Accueil</a>
11
         <a mat-list-item routerLink="/users-management"> User Manager</a>
12
         <a mat-list-item routerLink="/users-management"> User Manager</a>
12
-        <a mat-list-item routerLink="/projects-management">project Manager</a>
13
-        <a mat-list-item routerLink="/companies-management">company Manager</a>
13
+        <a mat-list-item routerLink="/projects-management">Project Manager</a>
14
+        <a mat-list-item routerLink="/companies-management">Company Manager</a>
14
       </mat-nav-list>
15
       </mat-nav-list>
15
   </mat-sidenav>
16
   </mat-sidenav>
16
 
17
 
17
   <mat-sidenav-content>
18
   <mat-sidenav-content>
18
     <mat-toolbar>
19
     <mat-toolbar>
19
       <button
20
       <button
20
-        type="button"
21
-        aria-label="Toggle sidenav"
22
-        mat-icon-button
23
-        (click)="drawer.toggle()"
24
-        *ngIf="isHandset$ | async">
25
-        <mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
26
-      </button>
21
+      type="button"
22
+      aria-label="Toggle sidenav"
23
+      mat-icon-button
24
+      (click)="drawer.toggle()"
25
+      *ngIf="isHandset$ | async">
26
+      <mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
27
+    </button>
27
       <span>Users, Projects and Companies Management</span>
28
       <span>Users, Projects and Companies Management</span>
28
     </mat-toolbar>
29
     </mat-toolbar>
29
     <!-- Add Content Here -->
30
     <!-- Add Content Here -->
30
-    <router-outlet></router-outlet>
31
   </mat-sidenav-content>
31
   </mat-sidenav-content>
32
 </mat-sidenav-container>
32
 </mat-sidenav-container>

+ 0
- 1
src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.html View File

1
-<p>companies-create works!</p>

+ 0
- 15
src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.ts View File

1
-import { Component, OnInit } from '@angular/core';
2
-
3
-@Component({
4
-  selector: 'app-companies-create',
5
-  templateUrl: './companies-create.component.html',
6
-  styleUrls: ['./companies-create.component.css']
7
-})
8
-export class CompaniesCreateComponent implements OnInit {
9
-
10
-  constructor() { }
11
-
12
-  ngOnInit(): void {
13
-  }
14
-
15
-}

+ 0
- 2
src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.html View File

1
-<div class="container">
2
   <div *ngIf="inputCompaniesList">
1
   <div *ngIf="inputCompaniesList">
3
     <input
2
     <input
4
       type="text"
3
       type="text"
60
       </tr>
59
       </tr>
61
     </ng-template>
60
     </ng-template>
62
   </p-table>
61
   </p-table>
63
-</div>

+ 2
- 2
src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.ts View File

1
 import { MsgState } from 'src/app/ngrx/msg.state';
1
 import { MsgState } from 'src/app/ngrx/msg.state';
2
-import { DeleteCompany, GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
2
+import { DeleteCompanyAction, GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
3
 import { CompanyState } from './../../../../ngrx/companies/company.state';
3
 import { CompanyState } from './../../../../ngrx/companies/company.state';
4
 import { Router } from '@angular/router';
4
 import { Router } from '@angular/router';
5
 import { Component, Input, OnInit } from '@angular/core';
5
 import { Component, Input, OnInit } from '@angular/core';
28
 
28
 
29
   onCompanyDelete(company: Company) {
29
   onCompanyDelete(company: Company) {
30
     if (window.confirm(this.msgState.CONFIRM_DEL)) {
30
     if (window.confirm(this.msgState.CONFIRM_DEL)) {
31
-      this.store.dispatch(new DeleteCompany(company));
31
+      this.store.dispatch(new DeleteCompanyAction(company));
32
     }
32
     }
33
   }
33
   }
34
 
34
 

src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.css → src/app/pages/companies-manager/companies-management/company-create/company-create.component.css View File


+ 82
- 0
src/app/pages/companies-manager/companies-management/company-create/company-create.component.html View File

1
+<div class="container p-3" *ngIf="companyFormGroup">
2
+  <ng-container [ngSwitch]="companyState.msgState">
3
+    <ng-container *ngSwitchCase="msgState.FORM_LOADING">
4
+      {{ companyState.msgState }}
5
+    </ng-container>
6
+
7
+    <ng-container *ngSwitchCase="msgState.FORM_LOAD_ERR">
8
+      {{ companyState.msgState }}
9
+    </ng-container>
10
+
11
+    <ng-container *ngSwitchCase="msgState.FORM_LOADED">
12
+      <div class="card">
13
+        <div class="card-header"><b>Company informations to Create</b></div>
14
+
15
+        <div class="card-body">
16
+          <form
17
+            [formGroup]="companyFormGroup"
18
+            (ngSubmit)="onCompanyCreate(); companyFormGroup.reset()"
19
+          >
20
+            <div class="col-md-auto mb-3">
21
+              <label for="companyName">Company name</label>
22
+              <input
23
+                type="text"
24
+                formControlName="companyName"
25
+                class="form-control"
26
+                [ngClass]="{
27
+                  'is-invalid':
28
+                    companyFormGroup.controls['companyName'].touched &&
29
+                    !companyFormGroup.controls['companyName'].valid
30
+                }"
31
+              />
32
+              <div class="invalid-feedback">
33
+                <span
34
+                  *ngIf="companyFormGroup.controls['companyName'].errors?.['required']"
35
+                >
36
+                  required
37
+                </span>
38
+                <span
39
+                  *ngIf="companyFormGroup.controls['companyName'].errors?.['minlength']"
40
+                >
41
+                  min nbr chars 5
42
+                </span>
43
+              </div>
44
+            </div>
45
+
46
+            <div class="col-md-auto mb-3">
47
+              <label for="type">Company type</label>
48
+              <select formControlName="companyType" class="form-control">
49
+                <option
50
+                  *ngFor="let companyType of compTypes | keyvalue"
51
+                  [ngValue]="companyType.value"
52
+                >
53
+                  {{ companyType.value }}
54
+                </option>
55
+              </select>
56
+            </div>
57
+
58
+            <div class="text-center col-md-auto mt-3">
59
+              <button
60
+                class="btn btn-outline-primary"
61
+                type="submit"
62
+                [disabled]="!companyFormGroup.valid"
63
+              >
64
+                save
65
+              </button>
66
+              &nbsp;
67
+              <button class="btn btn-outline-danger" type="reset">reset</button>
68
+            </div>
69
+          </form>
70
+        </div>
71
+      </div>
72
+    </ng-container>
73
+
74
+    <ng-container *ngSwitchCase="msgState.ADDED">
75
+      <div class="alert-success container p-3 m-3" style="width: 30em">
76
+        <span> {{ companyState.msgState }}</span> &nbsp;&nbsp;
77
+        <button class="btn btn-success" (click)="onSaveOk()">OK</button>
78
+      </div>
79
+    </ng-container>
80
+
81
+  </ng-container>
82
+</div>

src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.spec.ts → src/app/pages/companies-manager/companies-management/company-create/company-create.component.spec.ts View File

1
 import { ComponentFixture, TestBed } from '@angular/core/testing';
1
 import { ComponentFixture, TestBed } from '@angular/core/testing';
2
 
2
 
3
-import { CompaniesCreateComponent } from './companies-create.component';
3
+import { CompanyCreateComponent } from './company-create.component';
4
 
4
 
5
-describe('CompaniesCreateComponent', () => {
6
-  let component: CompaniesCreateComponent;
7
-  let fixture: ComponentFixture<CompaniesCreateComponent>;
5
+describe('CompanyCreateComponent', () => {
6
+  let component: CompanyCreateComponent;
7
+  let fixture: ComponentFixture<CompanyCreateComponent>;
8
 
8
 
9
   beforeEach(async () => {
9
   beforeEach(async () => {
10
     await TestBed.configureTestingModule({
10
     await TestBed.configureTestingModule({
11
-      declarations: [ CompaniesCreateComponent ]
11
+      declarations: [ CompanyCreateComponent ]
12
     })
12
     })
13
     .compileComponents();
13
     .compileComponents();
14
   });
14
   });
15
 
15
 
16
   beforeEach(() => {
16
   beforeEach(() => {
17
-    fixture = TestBed.createComponent(CompaniesCreateComponent);
17
+    fixture = TestBed.createComponent(CompanyCreateComponent);
18
     component = fixture.componentInstance;
18
     component = fixture.componentInstance;
19
     fixture.detectChanges();
19
     fixture.detectChanges();
20
   });
20
   });

+ 70
- 0
src/app/pages/companies-manager/companies-management/company-create/company-create.component.ts View File

1
+import { SaveCompanyFormDataAddAction } from './../../../../ngrx/companies/companies.actions';
2
+import { Company } from './../../../../shared/models/company/company.model';
3
+import { CompaniesServices } from './../../../../shared/services/companies.service';
4
+import { DatePipe } from '@angular/common';
5
+import { Component, OnInit } from '@angular/core';
6
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
7
+import { Router } from '@angular/router';
8
+import { Store } from '@ngrx/store';
9
+import { CreateCompanyFormAddAction } from 'src/app/ngrx/companies/companies.actions';
10
+import { CompanyState } from 'src/app/ngrx/companies/company.state';
11
+import { MsgState } from 'src/app/ngrx/msg.state';
12
+import { CompanyType } from 'src/app/shared/models/company/company.type';
13
+
14
+@Component({
15
+  selector: 'app-company-create',
16
+  templateUrl: './company-create.component.html',
17
+  styleUrls: ['./company-create.component.css']
18
+})
19
+export class CompanyCreateComponent implements OnInit {
20
+
21
+  constructor(
22
+    private store: Store<{ companyReducerKey: CompanyState }>,
23
+    private fb: FormBuilder,
24
+    private datePipe: DatePipe,
25
+    private router: Router,
26
+    private companiesService: CompaniesServices
27
+  ) {}
28
+
29
+  companyState!: CompanyState;
30
+  companyFormGroup!: FormGroup;
31
+  msgState = MsgState;
32
+  compTypes = CompanyType;
33
+
34
+  ngOnInit(): void {
35
+    this.store.dispatch(new CreateCompanyFormAddAction());
36
+    this.store.subscribe( (state)=>{
37
+      this.companyState = state.companyReducerKey;
38
+
39
+      this.companyFormGroup = this.fb.group({
40
+        id: [0, Validators.required],
41
+        companyName:['', [Validators.required, Validators.minLength(5), Validators.maxLength(20)]],
42
+        companyType:['', Validators.required],
43
+        creationDate:[this.datePipe.transform(new Date(),'MM dd yyyy')]
44
+      })
45
+    });
46
+  }
47
+
48
+
49
+  onCompanyCreate(){
50
+     let company: Company = this.companyFormGroup.value;
51
+     this.companiesService.getCompanyByCompanyName(company.companyName).subscribe(
52
+       (companies: Company[]) => {
53
+         if( companies.length > 0){
54
+           alert(this.msgState.EXIST);
55
+           this.store.dispatch(new CreateCompanyFormAddAction());
56
+         }
57
+         else{
58
+           if(window.confirm(this.msgState.CONFIRM_ADD)){
59
+            this.store.dispatch(new SaveCompanyFormDataAddAction(company));
60
+           }
61
+         }
62
+       }
63
+     )
64
+
65
+  }
66
+  onSaveOk(){
67
+    this.router.navigateByUrl('/companies-management');
68
+  }
69
+
70
+}

+ 1
- 1
src/app/pages/companies-manager/companies-management/company-nav-bar/company-nav-bar.component.html View File

23
         type="button"
23
         type="button"
24
         label="company's projects"
24
         label="company's projects"
25
         class="btn btn-outline-primary"
25
         class="btn btn-outline-primary"
26
-        (click)="onProjectsOfCampany()"
26
+        (click)="onCompany_s_Projects()"
27
       ></button>
27
       ></button>
28
     </div>
28
     </div>
29
   </nav>
29
   </nav>

+ 17
- 11
src/app/pages/companies-manager/companies-management/company-nav-bar/company-nav-bar.component.ts View File

1
+import { Router } from '@angular/router';
1
 import { GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
2
 import { GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
2
 import { CompanyState } from './../../../../ngrx/companies/company.state';
3
 import { CompanyState } from './../../../../ngrx/companies/company.state';
3
 import { Component, OnInit } from '@angular/core';
4
 import { Component, OnInit } from '@angular/core';
6
 @Component({
7
 @Component({
7
   selector: 'app-company-nav-bar',
8
   selector: 'app-company-nav-bar',
8
   templateUrl: './company-nav-bar.component.html',
9
   templateUrl: './company-nav-bar.component.html',
9
-  styleUrls: ['./company-nav-bar.component.css']
10
+  styleUrls: ['./company-nav-bar.component.css'],
10
 })
11
 })
11
-export class CompanyNavBarComponent{
12
+export class CompanyNavBarComponent {
13
+  constructor(
14
+    private store: Store<{ companyReducerKey: CompanyState }>,
15
+    private router: Router
16
+  ) {}
12
 
17
 
13
-  constructor(private store: Store<{companyReducerKey: CompanyState}>){}
18
+  companyState!: CompanyState;
14
 
19
 
15
-  companyState!: CompanyState
16
-
17
-  onCompanyCreate(){}
20
+  onCompanyCreate() {
21
+    this.router.navigateByUrl('/company-create');
22
+  }
18
 
23
 
19
-  onCompaniesGetAll(){
24
+  onCompaniesGetAll() {
20
     this.store.dispatch(new GetAllCompaniesAction({}));
25
     this.store.dispatch(new GetAllCompaniesAction({}));
21
-    this.store.subscribe((state)=>{
26
+    this.store.subscribe((state) => {
22
       this.companyState = state.companyReducerKey;
27
       this.companyState = state.companyReducerKey;
23
-    })
28
+    });
24
   }
29
   }
25
 
30
 
26
-  onProjectsOfCampany(){}
27
-
31
+  onCompany_s_Projects() {
32
+    this.router.navigateByUrl('/company-s-projects');
33
+  }
28
 }
34
 }

+ 3
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.css View File

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

+ 45
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.html View File

1
+<p-table
2
+        [value]="inputCompany_s_ProjectsList"
3
+        responsiveLayout="scroll"
4
+        styleClass="p-datatable-striped"
5
+        [paginator]="true"
6
+        [rows]="1"
7
+        [showCurrentPageReport]="true"
8
+        currentPageReportTemplate="{first} - {last} of {totalRecords} users"
9
+        [rowsPerPageOptions]="[1, 3, 5]"
10
+        class="p-3"
11
+      >
12
+        <ng-template pTemplate="header">
13
+          <tr>
14
+            <th>ID</th>
15
+            <th>Company name</th>
16
+            <th>Projects of company</th>
17
+            <th>Company type</th>
18
+            <th>Creation Date</th>
19
+          </tr>
20
+        </ng-template>
21
+        <ng-template pTemplate="body" let-company>
22
+          <tr>
23
+            <td>{{ company.id }}</td>
24
+            <td>{{ company.companyName }}</td>
25
+            <td>
26
+              <ul *ngFor="let project of company.projects">
27
+                <li>
28
+                  <span style="font-weight: bold"
29
+                    >Project ID: {{ project.id }}</span
30
+                  >
31
+                </li>
32
+                <li>Project Name: {{ project.projectName }}</li>
33
+                <li>Priority: {{ project.priority }}</li>
34
+                <li>Creation Date: {{ project.creationDate }}</li>
35
+                <li>Company ID: {{ project.companyId }}</li>
36
+                <li>Description: {{ project.description }}</li>
37
+                <li>User ID: {{ project.userId }}</li>
38
+                <li>Project State: {{ project.state }}</li>
39
+              </ul>
40
+            </td>
41
+            <td>{{ company.companyType }}</td>
42
+            <td>{{company.creationDate}}</td>
43
+          </tr>
44
+        </ng-template>
45
+      </p-table>

+ 25
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.spec.ts View File

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

+ 11
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component.ts View File

1
+import { Component, Input } from '@angular/core';
2
+
3
+@Component({
4
+  selector: 'app-company-s-projects-list',
5
+  templateUrl: './company-s-projects-list.component.html',
6
+  styleUrls: ['./company-s-projects-list.component.css']
7
+})
8
+export class CompanySProjectsListComponent{
9
+
10
+  @Input () inputCompany_s_ProjectsList!: any
11
+}

+ 0
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.css View File


+ 17
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.html View File

1
+<div class="container" *ngIf="companyState$ | async as companyState">
2
+  <ng-container [ngSwitch]="companyState.msgState">
3
+    <ng-container *ngSwitchCase="msgState.LOADING">
4
+      {{ companyState.msgState }}
5
+    </ng-container>
6
+
7
+    <ng-container *ngSwitchCase="msgState.ERR">
8
+      {{ companyState.msgState }}
9
+    </ng-container>
10
+
11
+    <ng-container *ngSwitchCase="msgState.LOADED">
12
+      <app-company-s-projects-list
13
+        [inputCompany_s_ProjectsList]="companyState.companiesList"
14
+      ></app-company-s-projects-list>
15
+    </ng-container>
16
+  </ng-container>
17
+</div>

+ 25
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.spec.ts View File

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

+ 27
- 0
src/app/pages/companies-manager/companies-management/company-s-projects/company-s-projects.component.ts View File

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

+ 18
- 15
src/app/pages/companies-manager/companies-management/company-update/company-update.component.html View File

1
 <div class="container" *ngIf="companyFormGroup">
1
 <div class="container" *ngIf="companyFormGroup">
2
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOADING">
2
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOADING">
3
-    {{companyState.msgState}}
3
+    {{ companyState.msgState }}
4
   </ng-container>
4
   </ng-container>
5
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOAD_ERR">
5
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOAD_ERR">
6
-    {{companyState.msgState}}
6
+    {{ companyState.msgState }}
7
   </ng-container>
7
   </ng-container>
8
 
8
 
9
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOADED">
9
   <ng-container *ngIf="companyState.msgState == msgState.FORM_LOADED">
10
-
11
-    <div class="card mt-3" style="width: 18rem">
12
-      <div class="card-header">Company informations to update</div>
10
+    <div class="card mt-3">
11
+      <div class="card-header">
12
+        <b>Company informations to update</b>: Company ID:
13
+        <b>{{ companyState.currentCompany?.id }}</b
14
+        >, Creation Date: <b>{{ companyState.currentCompany?.creationDate }}</b>
15
+      </div>
13
 
16
 
14
       <div class="card-body">
17
       <div class="card-body">
15
-        <form [formGroup]="companyFormGroup"
18
+        <form
19
+          [formGroup]="companyFormGroup"
16
           (ngSubmit)="onCompanyUpdate(); companyFormGroup.reset()"
20
           (ngSubmit)="onCompanyUpdate(); companyFormGroup.reset()"
17
         >
21
         >
18
           <div class="col-md-auto mb-3">
22
           <div class="col-md-auto mb-3">
23
               class="form-control"
27
               class="form-control"
24
               [ngClass]="{
28
               [ngClass]="{
25
                 'is-invalid':
29
                 'is-invalid':
26
-                companyFormGroup.controls['companyName'].touched &&
30
+                  companyFormGroup.controls['companyName'].touched &&
27
                   !companyFormGroup.controls['companyName'].valid
31
                   !companyFormGroup.controls['companyName'].valid
28
               }"
32
               }"
29
             />
33
             />
44
           <div class="col-md-auto mb-3">
48
           <div class="col-md-auto mb-3">
45
             <label for="type">Company type</label>
49
             <label for="type">Company type</label>
46
             <select formControlName="companyType" class="form-control">
50
             <select formControlName="companyType" class="form-control">
47
-
48
-              <option *ngFor="let companyType of companyTypes | keyvalue " [ngValue]="companyType.value">
49
-                  {{companyType.value}}
51
+              <option
52
+                *ngFor="let companyType of companyTypes | keyvalue"
53
+                [ngValue]="companyType.value"
54
+              >
55
+                {{ companyType.value }}
50
               </option>
56
               </option>
51
-
52
             </select>
57
             </select>
53
           </div>
58
           </div>
54
 
59
 
55
           <div class="text-center col-md-auto mt-3">
60
           <div class="text-center col-md-auto mt-3">
56
             <button
61
             <button
57
               class="btn btn-outline-primary"
62
               class="btn btn-outline-primary"
58
-              type="submit" [disabled]="!companyFormGroup.valid"
63
+              type="submit"
64
+              [disabled]="!companyFormGroup.valid"
59
             >
65
             >
60
               update
66
               update
61
             </button>
67
             </button>
62
           </div>
68
           </div>
63
-
64
         </form>
69
         </form>
65
       </div>
70
       </div>
66
     </div>
71
     </div>
67
   </ng-container>
72
   </ng-container>
68
 
73
 
69
-
70
   <ng-container *ngIf="companyState.msgState == msgState.UPDATED">
74
   <ng-container *ngIf="companyState.msgState == msgState.UPDATED">
71
     <div class="alert-success container p-3 m-3" style="width: 30em">
75
     <div class="alert-success container p-3 m-3" style="width: 30em">
72
       <span> {{ msgState.UPDATED }}</span> &nbsp;&nbsp;
76
       <span> {{ msgState.UPDATED }}</span> &nbsp;&nbsp;
73
       <button class="btn btn-success" (click)="onUpdateOk()">OK</button>
77
       <button class="btn btn-success" (click)="onUpdateOk()">OK</button>
74
     </div>
78
     </div>
75
   </ng-container>
79
   </ng-container>
76
-
77
 </div>
80
 </div>

+ 2
- 2
src/app/pages/companies-manager/companies-management/company-update/company-update.component.ts View File

4
   CreateFormToUpdateCompanyAction,
4
   CreateFormToUpdateCompanyAction,
5
   UpdateCompanyWithFormDataAction,
5
   UpdateCompanyWithFormDataAction,
6
 } from './../../../../ngrx/companies/companies.actions';
6
 } from './../../../../ngrx/companies/companies.actions';
7
-import { CompaniesService } from './../../../../shared/services/companies.service';
7
+import { CompaniesServices } from './../../../../shared/services/companies.service';
8
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
8
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
9
 import { CompanyState } from './../../../../ngrx/companies/company.state';
9
 import { CompanyState } from './../../../../ngrx/companies/company.state';
10
 import { ActivatedRoute, Router } from '@angular/router';
10
 import { ActivatedRoute, Router } from '@angular/router';
28
     activatedRoute: ActivatedRoute,
28
     activatedRoute: ActivatedRoute,
29
     private store: Store<{ companyReducerKey: CompanyState }>,
29
     private store: Store<{ companyReducerKey: CompanyState }>,
30
     private formBuilder: FormBuilder,
30
     private formBuilder: FormBuilder,
31
-    private companiesService: CompaniesService,
31
+    private companiesService: CompaniesServices,
32
     private router: Router
32
     private router: Router
33
   ) {
33
   ) {
34
     this.companyId = activatedRoute.snapshot.params['companyId'];
34
     this.companyId = activatedRoute.snapshot.params['companyId'];

+ 5
- 4
src/app/pages/companies-manager/companies-manager-routing.module.ts View File

1
+import { CompanyCreateComponent } from './companies-management/company-create/company-create.component';
2
+import { CompanySProjectsComponent } from './companies-management/company-s-projects/company-s-projects.component';
1
 import { CompanyUpdateComponent } from './companies-management/company-update/company-update.component';
3
 import { CompanyUpdateComponent } from './companies-management/company-update/company-update.component';
2
 import { CompaniesManagementComponent } from './companies-management/companies-management.component';
4
 import { CompaniesManagementComponent } from './companies-management/companies-management.component';
3
-import { CompanyNavBarComponent } from './companies-management/company-nav-bar/company-nav-bar.component';
4
-import { CompaniesCreateComponent } from './companies-management/companies-create/companies-create.component';
5
 import { NgModule } from '@angular/core';
5
 import { NgModule } from '@angular/core';
6
 import { RouterModule, Routes } from '@angular/router';
6
 import { RouterModule, Routes } from '@angular/router';
7
 
7
 
8
 const routes: Routes = [
8
 const routes: Routes = [
9
-  {path: 'company-create', component: CompaniesCreateComponent},
9
+  {path: 'company-create', component: CompanyCreateComponent},
10
   {path: 'companies-management', component: CompaniesManagementComponent},
10
   {path: 'companies-management', component: CompaniesManagementComponent},
11
-  {path:'company-update/:companyId', component: CompanyUpdateComponent}
11
+  {path:'company-update/:companyId', component: CompanyUpdateComponent},
12
+  { path:'company-s-projects', component: CompanySProjectsComponent}
12
 ];
13
 ];
13
 
14
 
14
 @NgModule({
15
 @NgModule({

+ 10
- 5
src/app/pages/companies-manager/companies-manager.module.ts View File

2
 import { TableModule } from 'primeng/table';
2
 import { TableModule } from 'primeng/table';
3
 import { ButtonModule } from 'primeng/button';
3
 import { ButtonModule } from 'primeng/button';
4
 import { NgModule } from '@angular/core';
4
 import { NgModule } from '@angular/core';
5
-import { CommonModule } from '@angular/common';
5
+import { CommonModule, DatePipe } from '@angular/common';
6
 
6
 
7
 import { CompaniesManagerRoutingModule } from './companies-manager-routing.module';
7
 import { CompaniesManagerRoutingModule } from './companies-manager-routing.module';
8
-import { CompaniesCreateComponent } from './companies-management/companies-create/companies-create.component';
9
 import { CompanyNavBarComponent } from './companies-management/company-nav-bar/company-nav-bar.component';
8
 import { CompanyNavBarComponent } from './companies-management/company-nav-bar/company-nav-bar.component';
10
 import { CompaniesManagementComponent } from './companies-management/companies-management.component';
9
 import { CompaniesManagementComponent } from './companies-management/companies-management.component';
11
 import { CompaniesListComponent } from './companies-management/companies-list/companies-list.component';
10
 import { CompaniesListComponent } from './companies-management/companies-list/companies-list.component';
12
 import { CompanyUpdateComponent } from './companies-management/company-update/company-update.component';
11
 import { CompanyUpdateComponent } from './companies-management/company-update/company-update.component';
12
+import { CompanySProjectsComponent } from './companies-management/company-s-projects/company-s-projects.component';
13
+import { CompanySProjectsListComponent } from './companies-management/company-s-projects/company-s-projects-list/company-s-projects-list.component';
14
+import { CompanyCreateComponent } from './companies-management/company-create/company-create.component';
13
 
15
 
14
 
16
 
15
 @NgModule({
17
 @NgModule({
16
   declarations: [
18
   declarations: [
17
-    CompaniesCreateComponent,
18
     CompanyNavBarComponent,
19
     CompanyNavBarComponent,
19
     CompaniesManagementComponent,
20
     CompaniesManagementComponent,
20
     CompaniesListComponent,
21
     CompaniesListComponent,
21
-    CompanyUpdateComponent
22
+    CompanyUpdateComponent,
23
+    CompanySProjectsComponent,
24
+    CompanySProjectsListComponent,
25
+    CompanyCreateComponent
22
   ],
26
   ],
23
   imports: [
27
   imports: [
24
     CommonModule,
28
     CommonModule,
27
     TableModule,
31
     TableModule,
28
     ReactiveFormsModule,
32
     ReactiveFormsModule,
29
     FormsModule
33
     FormsModule
30
-  ]
34
+  ],
35
+  providers:[DatePipe]
31
 })
36
 })
32
 export class CompaniesManagerModule { }
37
 export class CompaniesManagerModule { }

+ 1
- 1
src/app/pages/projects-manager/projects-management/project-create/project-create.component.html View File

140
                 save
140
                 save
141
               </button>
141
               </button>
142
               &nbsp;
142
               &nbsp;
143
-              <button class="btn btn-outline-primary" type="reset">
143
+              <button class="btn btn-outline-danger" type="reset">
144
                 reset
144
                 reset
145
               </button>
145
               </button>
146
             </div>
146
             </div>

+ 3
- 3
src/app/pages/projects-manager/projects-management/project-create/project-create.component.ts View File

1
 import { GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
1
 import { GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
2
 import { CompanyState } from './../../../../ngrx/companies/company.state';
2
 import { CompanyState } from './../../../../ngrx/companies/company.state';
3
 import { Router } from '@angular/router';
3
 import { Router } from '@angular/router';
4
-import { ProjectsService } from './../../../../shared/services/projects.service';
4
+import { ProjectsServices } from './../../../../shared/services/projects.service';
5
 import { MsgState } from './../../../../ngrx/msg.state';
5
 import { MsgState } from './../../../../ngrx/msg.state';
6
 import { DatePipe } from '@angular/common';
6
 import { DatePipe } from '@angular/common';
7
 import { GetAllUsersAction } from './../../../../ngrx/users/users.actions';
7
 import { GetAllUsersAction } from './../../../../ngrx/users/users.actions';
46
       companyReducerKey: CompanyState
46
       companyReducerKey: CompanyState
47
     }>,
47
     }>,
48
     private datePipe: DatePipe,
48
     private datePipe: DatePipe,
49
-    private projectsServices: ProjectsService,
49
+    private projectsServices: ProjectsServices,
50
     private router: Router
50
     private router: Router
51
   ) {}
51
   ) {}
52
 
52
 
94
     this.projectsServices.getProjectByName(projectName).subscribe((projects: Project[])=>{
94
     this.projectsServices.getProjectByName(projectName).subscribe((projects: Project[])=>{
95
       if(projects.length>0){
95
       if(projects.length>0){
96
         alert(projectName+' '+this.msgState.EXIST);
96
         alert(projectName+' '+this.msgState.EXIST);
97
-        return;
97
+        this.store.dispatch(new CreateProjectFormAddAction({})); //pour reactualiser le formulaire
98
       }
98
       }
99
       else{
99
       else{
100
         if(window.confirm(this.msgState.CONFIRM_ADD)){
100
         if(window.confirm(this.msgState.CONFIRM_ADD)){

+ 1
- 1
src/app/pages/projects-manager/projects-management/project-update/project-update.component.html View File

13
 
13
 
14
       <div class="card mt-3">
14
       <div class="card mt-3">
15
         <div class="card-header bg-light">
15
         <div class="card-header bg-light">
16
-          Project informations to Update>> Project ID: <b>{{ projectState.currentProject?.id }}</b>, User ID:
16
+          <b>Project informations to Update </b>>> Project ID: <b>{{ projectState.currentProject?.id }}</b>, User ID:
17
             <b>{{ projectState.currentProject?.userId }}</b>, Company ID:
17
             <b>{{ projectState.currentProject?.userId }}</b>, Company ID:
18
             <b>{{ projectState.currentProject?.companyId }}</b>
18
             <b>{{ projectState.currentProject?.companyId }}</b>
19
 
19
 

+ 2
- 2
src/app/pages/projects-manager/projects-management/project-update/project-update.component.ts View File

7
 import { Priority } from '../../../../shared/models/project/project.priority';
7
 import { Priority } from '../../../../shared/models/project/project.priority';
8
 import { MsgState } from './../../../../ngrx/msg.state';
8
 import { MsgState } from './../../../../ngrx/msg.state';
9
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
9
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
10
-import { ProjectsService } from './../../../../shared/services/projects.service';
10
+import { ProjectsServices } from './../../../../shared/services/projects.service';
11
 import { ProjectState } from './../../../../ngrx/projects/project.state';
11
 import { ProjectState } from './../../../../ngrx/projects/project.state';
12
 import { ActivatedRoute, Router } from '@angular/router';
12
 import { ActivatedRoute, Router } from '@angular/router';
13
 import { Component, OnInit } from '@angular/core';
13
 import { Component, OnInit } from '@angular/core';
27
 
27
 
28
   constructor(
28
   constructor(
29
     activatedRoute: ActivatedRoute,
29
     activatedRoute: ActivatedRoute,
30
-    private projectsService: ProjectsService,
30
+    private projectsService: ProjectsServices,
31
     private store: Store<{
31
     private store: Store<{
32
       projectReducerKey: ProjectState;
32
       projectReducerKey: ProjectState;
33
       userReducerKey: UserState;
33
       userReducerKey: UserState;

+ 3
- 4
src/app/pages/projects-manager/projects-management/project-with-company-associated/project-with-company-associated-list/project-with-company-associated-list.component.html View File

1
-<div class="container">
2
   <p-table
1
   <p-table
3
     [value]="inputProjectCompanyAssociated"
2
     [value]="inputProjectCompanyAssociated"
4
     responsiveLayout="scroll"
3
     responsiveLayout="scroll"
9
     [showCurrentPageReport]="true"
8
     [showCurrentPageReport]="true"
10
     currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
9
     currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
11
     [rowsPerPageOptions]="[4, 6, 10]"
10
     [rowsPerPageOptions]="[4, 6, 10]"
11
+    class="p-3"
12
   >
12
   >
13
     <ng-template pTemplate="header">
13
     <ng-template pTemplate="header">
14
       <tr>
14
       <tr>
17
         <th>Prioriy</th>
17
         <th>Prioriy</th>
18
         <th>State</th>
18
         <th>State</th>
19
         <th>Description</th>
19
         <th>Description</th>
20
-        <th>Company related</th>
20
+        <th>Company</th>
21
         <th>Company ID</th>
21
         <th>Company ID</th>
22
-        <th>Project User ID</th>
22
+        <th>User ID</th>
23
         <th>Creation Date</th>
23
         <th>Creation Date</th>
24
       </tr>
24
       </tr>
25
     </ng-template>
25
     </ng-template>
44
       </tr>
44
       </tr>
45
     </ng-template>
45
     </ng-template>
46
   </p-table>
46
   </p-table>
47
-</div>

+ 1
- 0
src/app/pages/projects-manager/projects-management/project-with-user-associated/project-with-user-associated-list/project-with-user-associated-list.component.html View File

8
     [showCurrentPageReport]="true"
8
     [showCurrentPageReport]="true"
9
     currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
9
     currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"
10
     [rowsPerPageOptions]="[3, 5, 10]"
10
     [rowsPerPageOptions]="[3, 5, 10]"
11
+    class="p-3"
11
   >
12
   >
12
     <ng-template pTemplate="header">
13
     <ng-template pTemplate="header">
13
       <tr>
14
       <tr>

+ 1
- 4
src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.html View File

1
-<div class="container">
1
+
2
   <div *ngIf="inputProjectsList" style="position:relative">
2
   <div *ngIf="inputProjectsList" style="position:relative">
3
     <input
3
     <input
4
       type="text"
4
       type="text"
9
       (ngModelChange)="onSearch()"
9
       (ngModelChange)="onSearch()"
10
     />
10
     />
11
   </div>
11
   </div>
12
-</div>
13
 
12
 
14
-<div class="container">
15
   <p-table
13
   <p-table
16
     [value]="inputProjectsList"
14
     [value]="inputProjectsList"
17
     responsiveLayout="scroll"
15
     responsiveLayout="scroll"
61
       </tr>
59
       </tr>
62
     </ng-template>
60
     </ng-template>
63
   </p-table>
61
   </p-table>
64
-</div>

+ 2
- 3
src/app/pages/projects-manager/projects-manager.module.ts View File

1
 import { TableModule } from 'primeng/table';
1
 import { TableModule } from 'primeng/table';
2
 import { ButtonModule } from 'primeng/button';
2
 import { ButtonModule } from 'primeng/button';
3
 import { NgModule } from '@angular/core';
3
 import { NgModule } from '@angular/core';
4
-import { CommonModule } from '@angular/common';
4
+import { CommonModule, DatePipe } from '@angular/common';
5
 
5
 
6
 import { ProjectsManagerRoutingModule } from './projects-manager-routing.module';
6
 import { ProjectsManagerRoutingModule } from './projects-manager-routing.module';
7
 import { ProjectCreateComponent } from './projects-management/project-create/project-create.component';
7
 import { ProjectCreateComponent } from './projects-management/project-create/project-create.component';
37
     ReactiveFormsModule,
37
     ReactiveFormsModule,
38
     FormsModule
38
     FormsModule
39
   ],
39
   ],
40
-  providers:[
41
-  ]
40
+  providers:[DatePipe]
42
 })
41
 })
43
 
42
 
44
 export class ProjectsManagerModule { }
43
 export class ProjectsManagerModule { }

+ 10
- 12
src/app/pages/users-manager/users-management/user-create/user-create.component.html View File

2
 
2
 
3
     <ng-container *ngIf="userState as state" [ngSwitch]="state.msgState">
3
     <ng-container *ngIf="userState as state" [ngSwitch]="state.msgState">
4
 
4
 
5
-      <ng-container *ngSwitchCase="msgState.DEFAULT_MSG">
5
+      <ng-container *ngSwitchCase="msgState.FORM_LOADING">
6
         {{state.msgState}}
6
         {{state.msgState}}
7
       </ng-container>
7
       </ng-container>
8
 
8
 
9
-      <ng-container *ngSwitchCase="msgState.ADDED">
10
-        <div class="alert-success container p-3 m-3">
11
-          <span> {{state.msgState}}</span> &nbsp;
12
-          <button class="btn btn-success" (click)="onNewUser()"> create user</button>
13
-        </div>
14
-      </ng-container>
15
-
16
       <ng-container *ngSwitchCase="msgState.ERR">
9
       <ng-container *ngSwitchCase="msgState.ERR">
17
         <div class="alert-danger container pt-3 mt-3">
10
         <div class="alert-danger container pt-3 mt-3">
18
           <span> {{state.msgState}}</span> &nbsp;
11
           <span> {{state.msgState}}</span> &nbsp;
20
         </div>
13
         </div>
21
       </ng-container>
14
       </ng-container>
22
 
15
 
23
-
24
-
25
       <ng-container *ngSwitchCase="msgState.FORM_LOADED">
16
       <ng-container *ngSwitchCase="msgState.FORM_LOADED">
26
 
17
 
27
         <div class="card mt-3">
18
         <div class="card mt-3">
28
-          <div class="card-header bg-light">Input form of User information</div>
19
+          <div class="card-header bg-light"><b>User Informations to Create</b></div>
29
           <div class="card-body">
20
           <div class="card-body">
30
             <form [formGroup]="userFormGroup" (ngSubmit)="onUserSave(); userFormGroup.reset()">
21
             <form [formGroup]="userFormGroup" (ngSubmit)="onUserSave(); userFormGroup.reset()">
31
 
22
 
166
                         </span>
157
                         </span>
167
                         <span
158
                         <span
168
                           *ngIf="userFormGroup.controls['address'].get('nomRue')?.errors?.['maxlength']"
159
                           *ngIf="userFormGroup.controls['address'].get('nomRue')?.errors?.['maxlength']"
169
-                          >max chars 15
160
+                          >max chars 50
170
                         </span>
161
                         </span>
171
                       </div>
162
                       </div>
172
                     </div>
163
                     </div>
273
         </div>
264
         </div>
274
       </ng-container>
265
       </ng-container>
275
 
266
 
267
+      <ng-container *ngSwitchCase="msgState.ADDED">
268
+        <div class="alert-success container p-3 m-3">
269
+          <span> {{state.msgState}}</span> &nbsp;
270
+          <button class="btn btn-success" (click)="onSaveSuccess()"> OK</button>
271
+        </div>
272
+      </ng-container>
273
+
276
     </ng-container>
274
     </ng-container>
277
 
275
 
278
 </div>
276
 </div>

+ 11
- 8
src/app/pages/users-manager/users-management/user-create/user-create.component.ts View File

1
+import { Router } from '@angular/router';
2
+import { GetAllUsersAction } from 'src/app/ngrx/users/users.actions';
1
 import { DatePipe } from '@angular/common';
3
 import { DatePipe } from '@angular/common';
2
-import { UsersService } from '../../../../shared/services/users.service';
4
+import { UsersServices } from '../../../../shared/services/users.service';
3
 import { User } from '../../../../shared/models/user/user.model';
5
 import { User } from '../../../../shared/models/user/user.model';
4
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
6
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
5
 import {
7
 import {
22
   constructor(
24
   constructor(
23
     private store: Store<{ userReducerKey: UserState }>,
25
     private store: Store<{ userReducerKey: UserState }>,
24
     private fb: FormBuilder,
26
     private fb: FormBuilder,
25
-    private usersService: UsersService,
26
-    private datePipe: DatePipe
27
+    private usersService: UsersServices,
28
+    private datePipe: DatePipe,
29
+    private router: Router
27
   ) {}
30
   ) {}
28
   userState!: UserState;
31
   userState!: UserState;
29
   readonly msgState = MsgState;
32
   readonly msgState = MsgState;
60
             [
63
             [
61
               Validators.required,
64
               Validators.required,
62
               Validators.minLength(3),
65
               Validators.minLength(3),
63
-              Validators.maxLength(25),
66
+              Validators.maxLength(50),
64
             ],
67
             ],
65
           ],
68
           ],
66
           bp: [0, [Validators.required, Validators.min(1)]],
69
           bp: [0, [Validators.required, Validators.min(1)]],
81
             ],
84
             ],
82
           ],
85
           ],
83
         }),
86
         }),
84
-        createDate: [this.datePipe.transform(new Date(), 'MM dd yyyy')],
87
+        creationDate: [this.datePipe.transform(new Date(), 'MM dd yyyy')],
85
       });
88
       });
86
     });
89
     });
87
   }
90
   }
93
     this.usersService.getUserByName(lastname).subscribe((users: User[]) => {
96
     this.usersService.getUserByName(lastname).subscribe((users: User[]) => {
94
       if (users.length > 0) {
97
       if (users.length > 0) {
95
         alert(lastname + ' ' + this.msgState.EXIST);
98
         alert(lastname + ' ' + this.msgState.EXIST);
96
-        return;
99
+        this.store.dispatch(new CreateFormUserAddAction({}));//pour reactualiser le formulaire
97
       } else {
100
       } else {
98
         if (
101
         if (
99
           window.confirm(
102
           window.confirm(
106
     });
109
     });
107
   }
110
   }
108
 
111
 
109
-  onNewUser() {
110
-    this.store.dispatch(new CreateFormUserAddAction({}));
112
+  onSaveSuccess() {
113
+   this.router.navigate(['/users-management'])
111
   }
114
   }
112
 
115
 
113
   tryEgain() {
116
   tryEgain() {

+ 1
- 5
src/app/pages/users-manager/users-management/user-nav-bar/user-nav-bar.component.ts View File

1
 import { UserState } from './../../../../ngrx/users/user.state';
1
 import { UserState } from './../../../../ngrx/users/user.state';
2
 import {
2
 import {
3
-  NavigateActionSuccess,
4
-  SearchUsersAction,
3
+  NavigateActionSuccess
5
 } from './../../../../ngrx/users/users.actions';
4
 } from './../../../../ngrx/users/users.actions';
6
 import { GetAllUsersAction } from '../../../../ngrx/users/users.actions';
5
 import { GetAllUsersAction } from '../../../../ngrx/users/users.actions';
7
 import { Component, OnInit } from '@angular/core';
6
 import { Component, OnInit } from '@angular/core';
44
    this.store.dispatch(new NavigateActionSuccess({}))
43
    this.store.dispatch(new NavigateActionSuccess({}))
45
   }
44
   }
46
 
45
 
47
-  onSearch(searchForm: any) {
48
-    this.store.dispatch(new SearchUsersAction(searchForm.keyword));
49
-  }
50
 }
46
 }

+ 1
- 1
src/app/pages/users-manager/users-management/user-s-projects/user-s-projects.component.html View File

1
-<div class="container m-3 p-3">
1
+<div class="container p-3">
2
   <ng-container
2
   <ng-container
3
     *ngIf="usersState$ | async as userState"
3
     *ngIf="usersState$ | async as userState"
4
     [ngSwitch]="userState.msgState"
4
     [ngSwitch]="userState.msgState"

+ 1
- 1
src/app/pages/users-manager/users-management/user-update/user-update.component.html View File

166
                       </span>
166
                       </span>
167
                       <span
167
                       <span
168
                         *ngIf="userFormGrp.controls['address'].get('nomRue')?.errors?.['maxlength']"
168
                         *ngIf="userFormGrp.controls['address'].get('nomRue')?.errors?.['maxlength']"
169
-                        >max chars 15
169
+                        >max chars 50
170
                       </span>
170
                       </span>
171
                     </div>
171
                     </div>
172
                   </div>
172
                   </div>

+ 3
- 3
src/app/pages/users-manager/users-management/user-update/user-update.component.ts View File

1
 import { MsgState } from 'src/app/ngrx/msg.state';
1
 import { MsgState } from 'src/app/ngrx/msg.state';
2
-import { UsersService } from '../../../../shared/services/users.service';
2
+import { UsersServices } from '../../../../shared/services/users.service';
3
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
3
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
4
 import { CreareFormUserEditAction, UpdateUserFormAction } from '../../../../ngrx/users/users.actions';
4
 import { CreareFormUserEditAction, UpdateUserFormAction } from '../../../../ngrx/users/users.actions';
5
 import { UserState } from 'src/app/ngrx/users/user.state';
5
 import { UserState } from 'src/app/ngrx/users/user.state';
19
 
19
 
20
   constructor(
20
   constructor(
21
     activatedRoute: ActivatedRoute,
21
     activatedRoute: ActivatedRoute,
22
-    private usersService: UsersService,
22
+    private usersService: UsersServices,
23
     private store: Store<{ userReducerKey: UserState }>,
23
     private store: Store<{ userReducerKey: UserState }>,
24
     private fb: FormBuilder,
24
     private fb: FormBuilder,
25
     private router: Router
25
     private router: Router
68
                 [
68
                 [
69
                   Validators.required,
69
                   Validators.required,
70
                   Validators.minLength(3),
70
                   Validators.minLength(3),
71
-                  Validators.maxLength(25),
71
+                  Validators.maxLength(50),
72
                 ],
72
                 ],
73
               ],
73
               ],
74
               bp: [
74
               bp: [

+ 1
- 1
src/app/pages/users-manager/users-management/users-list/users-list.component.html View File

3
     type="text"
3
     type="text"
4
     class="form-control"
4
     class="form-control"
5
     id="search"
5
     id="search"
6
-    placeholder="search a project by name"
6
+    placeholder="search a user by firstname"
7
     [(ngModel)]="firstname"
7
     [(ngModel)]="firstname"
8
     (ngModelChange)="onSearch()"
8
     (ngModelChange)="onSearch()"
9
   />
9
   />

+ 0
- 1
src/app/pages/users-manager/users-management/users-management.component.html View File

19
     </ng-container>
19
     </ng-container>
20
 
20
 
21
   </ng-container>
21
   </ng-container>
22
-
23
 </div>
22
 </div>

+ 2
- 0
src/app/pages/users-manager/users-manager.module.ts View File

30
     FormsModule,
30
     FormsModule,
31
     ReactiveFormsModule
31
     ReactiveFormsModule
32
   ],
32
   ],
33
+
34
+  providers:[DatePipe]
33
 })
35
 })
34
 export class UsersManagerModule { }
36
 export class UsersManagerModule { }

+ 2
- 2
src/app/shared/services/companies.service.ts View File

7
 @Injectable({
7
 @Injectable({
8
   providedIn: 'root'
8
   providedIn: 'root'
9
 })
9
 })
10
-export class CompaniesService {
10
+export class CompaniesServices {
11
 
11
 
12
   constructor(private http: HttpClient) { }
12
   constructor(private http: HttpClient) { }
13
 
13
 
33
     return this.http.get<Company[]>(this.baseUrl + '/companies');
33
     return this.http.get<Company[]>(this.baseUrl + '/companies');
34
   }
34
   }
35
 
35
 
36
-  getAllProjectsOfCompany(): Observable<Company[]> {
36
+  getCompany_s_Projects(): Observable<Company[]> {
37
     return this.http
37
     return this.http
38
       .get<Company[]>(this.baseUrl + '/companies?_embed=projects')
38
       .get<Company[]>(this.baseUrl + '/companies?_embed=projects')
39
       .pipe(catchError(this.handleError));
39
       .pipe(catchError(this.handleError));

+ 1
- 1
src/app/shared/services/projects.service.ts View File

7
 @Injectable({
7
 @Injectable({
8
   providedIn: 'root',
8
   providedIn: 'root',
9
 })
9
 })
10
-export class ProjectsService implements OnInit {
10
+export class ProjectsServices implements OnInit {
11
   constructor(private http: HttpClient) {}
11
   constructor(private http: HttpClient) {}
12
   ngOnInit(): void {}
12
   ngOnInit(): void {}
13
 
13
 

+ 3
- 3
src/app/shared/services/users.service.ts View File

7
 @Injectable({
7
 @Injectable({
8
   providedIn: 'root',
8
   providedIn: 'root',
9
 })
9
 })
10
-export class UsersService {
10
+export class UsersServices {
11
   constructor(private http: HttpClient) {}
11
   constructor(private http: HttpClient) {}
12
 
12
 
13
   handleError(err: HttpErrorResponse) {
13
   handleError(err: HttpErrorResponse) {
72
       .pipe(catchError(this.handleError));
72
       .pipe(catchError(this.handleError));
73
   }
73
   }
74
 
74
 
75
-  searchUser(keyword: string): Observable<User[]> {
75
+  searchUser(firstnameKeyword: string): Observable<User[]> {
76
    let users = this.http.get<User[]>(
76
    let users = this.http.get<User[]>(
77
-      this.baseUrl + '/users?firstname_like=' + keyword
77
+      this.baseUrl + '/users?firstname_like=' + firstnameKeyword
78
     );
78
     );
79
 
79
 
80
     return users;
80
     return users;

Powered by TurnKey Linux.