placidenduwayo před 2 roky
rodič
revize
1b8de090c9
68 změnil soubory, kde provedl 886 přidání a 577 odebrání
  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 Zobrazit soubor

@@ -4,13 +4,7 @@
4 4
       "id": 1,
5 5
       "companyName": "NATAN",
6 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 10
       "id": 4,
@@ -23,6 +17,48 @@
23 17
       "companyName": "Company-3",
24 18
       "companyType": "CLIENT",
25 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 64
   "users": [
@@ -33,7 +69,7 @@
33 69
       "email": "david.touitou@natan.fr",
34 70
       "address": {
35 71
         "numRue": 45,
36
-        "nomRue": "Rue Notre Dame de Paris",
72
+        "nomRue": "Rue Notre Dame des Victoires",
37 73
         "bp": 75002,
38 74
         "ville": "Paris",
39 75
         "pays": "France"
@@ -47,7 +83,7 @@
47 83
       "email": "nadhir.ben-mohamed@natan.fr",
48 84
       "address": {
49 85
         "numRue": 45,
50
-        "nomRue": "Rue Notre Dame de Paris",
86
+        "nomRue": "Rue Notre Dame des Victoires",
51 87
         "bp": 75002,
52 88
         "ville": "Paris",
53 89
         "pays": "France"
@@ -57,7 +93,7 @@
57 93
     {
58 94
       "address": {
59 95
         "numRue": 44,
60
-        "nomRue": "Rue Notre Dame de Paris",
96
+        "nomRue": "Rue Notre Dame des Victoires",
61 97
         "bp": 75002,
62 98
         "ville": "Paris",
63 99
         "pays": "France"
@@ -71,7 +107,7 @@
71 107
     {
72 108
       "address": {
73 109
         "numRue": 44,
74
-        "nomRue": "Rue Notre Dame de Paris",
110
+        "nomRue": "Rue Notre Dame des Victoires",
75 111
         "bp": 75002,
76 112
         "ville": "Paris",
77 113
         "pays": "France"
@@ -85,21 +121,7 @@
85 121
     {
86 122
       "address": {
87 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 125
         "bp": 75002,
104 126
         "ville": "Paris",
105 127
         "pays": "France"
@@ -113,7 +135,7 @@
113 135
     {
114 136
       "address": {
115 137
         "numRue": 44,
116
-        "nomRue": "Rue Notre Dame de Paris",
138
+        "nomRue": "Rue Notre Dame des Victoires",
117 139
         "bp": 75002,
118 140
         "ville": "Paris",
119 141
         "pays": "France"
@@ -131,7 +153,7 @@
131 153
       "email": "charles.benassaya@natan.fr",
132 154
       "address": {
133 155
         "numRue": 44,
134
-        "nomRue": "Rue Notre Dame de Paris",
156
+        "nomRue": "Rue Notre Dame des Victoires",
135 157
         "bp": 75002,
136 158
         "ville": "Paris",
137 159
         "pays": "France"
@@ -145,7 +167,7 @@
145 167
       "email": "placide.nduwayo@natan.fr",
146 168
       "address": {
147 169
         "numRue": 44,
148
-        "nomRue": "Rue Notre Dame de Paris",
170
+        "nomRue": "Rue Notre Dame des Victoires",
149 171
         "bp": 75002,
150 172
         "ville": "Paris",
151 173
         "pays": "France"
@@ -159,7 +181,7 @@
159 181
       "email": "naolie.boudouka-tete@natan.fr",
160 182
       "address": {
161 183
         "numRue": 44,
162
-        "nomRue": "Rue Notre Dame de Paris",
184
+        "nomRue": "Rue Notre Dame des Victoires",
163 185
         "bp": 75002,
164 186
         "ville": "Paris",
165 187
         "pays": "France"
@@ -173,7 +195,7 @@
173 195
       "email": "rayene.bessrour@natan.fr",
174 196
       "address": {
175 197
         "numRue": 44,
176
-        "nomRue": "Rue Notre Dame de Paris",
198
+        "nomRue": "Rue Notre Dame des Victoires",
177 199
         "bp": 75004,
178 200
         "ville": "Paris",
179 201
         "pays": "France"
@@ -181,46 +203,36 @@
181 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 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 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 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 236
       "id": 3,
225 237
       "projectName": "Project-3",
226 238
       "priority": 1,
@@ -255,10 +267,20 @@
255 267
       "projectName": "Project-test",
256 268
       "priority": 1,
257 269
       "creationDate": "06 08 2022",
258
-      "companyId": 4,
270
+      "companyId": 11,
259 271
       "description": "project for test adding ",
260 272
       "userId": 12,
261 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 Zobrazit soubor

@@ -1,2 +1,2 @@
1 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 Zobrazit soubor

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

+ 68
- 8
src/app/ngrx/companies/companies.actions.ts Zobrazit soubor

@@ -19,7 +19,38 @@ export class GetAllCompaniesActionError implements Action {
19 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 55
 //create form to update company
25 56
 export class CreateFormToUpdateCompanyAction implements Action {
@@ -58,28 +89,57 @@ export class UpdateCompanyWithFormDataActionError implements Action {
58 89
 }
59 90
 
60 91
 // detele a company
61
-export class DeleteCompany implements Action{
92
+export class DeleteCompanyAction implements Action {
62 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 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 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 124
 export type CompanyActionUnion =
77 125
   | GetAllCompaniesAction
78 126
   | GetAllCompaniesActionSuccess
79 127
   | GetAllCompaniesActionError
128
+  | CreateCompanyFormAddAction
129
+  | CreateCompanyFormAddActionSuccess
130
+  | CreateCompanyFormAddActionError
131
+  | SaveCompanyFormDataAddAction
132
+  | SaveCompanyFormDataAddActionSuccess
133
+  | SaveCompanyFormDataAddActionError
80 134
   | CreateFormToUpdateCompanyAction
81 135
   | CreateFormToUpdateCompanyActionSuccess
82 136
   | CreateFormToUpdateCompanyActionError
83 137
   | UpdateCompanyWithFormDataAction
84 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 Zobrazit soubor

@@ -1,11 +1,9 @@
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 8
 /**reducer fonction to handle actions
11 9
 a reducer function need initial state and an action to handle*/
@@ -14,31 +12,30 @@ const companyInitialState: CompanyState = {
14 12
   currentCompany: null,
15 13
   companiesList: [],
16 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 21
   switch (action.type) {
25 22
     // get all companies
26 23
     case CompanyActionTypes.GET_ALL_COMPANIES:
27 24
       return {
28
-        ...companyState,
25
+        ...state,
29 26
         msgState: MsgState.LOADING,
30 27
       };
31 28
 
32 29
     case CompanyActionTypes.GET_ALL_COMPANIES_SUCCESS:
33 30
       return {
34
-        ...companyState,
31
+        ...state,
35 32
         msgState: MsgState.LOADED,
36
-        companiesList: (<CompanyActionUnion>action).payload,
33
+        companiesList: (<CompanyActionUnion> action).payload
37 34
       };
38 35
 
39 36
     case CompanyActionTypes.GET_ALL_COMPANIES_ERROR:
40 37
       return {
41
-        ...companyState,
38
+        ...state,
42 39
         msgState: MsgState.ERR,
43 40
         serverMsgError: (<CompanyActionUnion>action).payload,
44 41
       };
@@ -46,20 +43,20 @@ export function companyReducer(
46 43
     //create form to update company
47 44
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE:
48 45
       return {
49
-        ...companyState,
46
+        ...state,
50 47
         msgState: MsgState.FORM_LOADING,
51 48
       };
52 49
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE_SUCCESS:
53 50
       let companyToUpdate: Company = (<CompanyActionUnion>action).payload;
54 51
       return {
55
-        ...companyState,
52
+        ...state,
56 53
         msgState: MsgState.FORM_LOADED,
57 54
         currentCompany: companyToUpdate,
58 55
       };
59 56
 
60 57
     case CompanyActionTypes.CREATE_COMPANY_FORM_UPDATE_ERROR:
61 58
       return {
62
-        ...companyState,
59
+        ...state,
63 60
         msgState: MsgState.FORM_LOAD_ERR,
64 61
         serverMsgError: (<CompanyActionUnion>action).payload,
65 62
       };
@@ -67,25 +64,25 @@ export function companyReducer(
67 64
     //save form data to update company
68 65
     case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA:
69 66
       return {
70
-        ...companyState,
71
-        msgState: MsgState.DEFAULT_MSG,
67
+        ...state,
68
+        msgState: MsgState.UPDATE,
72 69
       };
73 70
     case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA_SUCCESS:
74 71
       let updatedCompany: Company = (<CompanyActionUnion>action).payload;
75
-      let companiesListCopy1: Company[] = [...companyState.companiesList];
72
+      let companiesListCopy1: Company[] = [...state.companiesList];
76 73
       companiesListCopy1 = companiesListCopy1.map((company) =>
77 74
         company.id == updatedCompany.id ? updatedCompany : company
78 75
       );
79 76
 
80 77
       return{
81
-        ...companyState,
78
+        ...state,
82 79
         msgState: MsgState.UPDATED,
83 80
         companiesList: companiesListCopy1
84 81
       }
85 82
 
86 83
       case CompanyActionTypes.UPDATE_COMPANY_WITH_FORM_DATA_ERROR:
87 84
         return{
88
-          ...companyState,
85
+          ...state,
89 86
           msgState: MsgState.ERR,
90 87
           serverMsgError: (<CompanyActionUnion>action).payload
91 88
         };
@@ -93,30 +90,95 @@ export function companyReducer(
93 90
         // delete a company
94 91
       case CompanyActionTypes.DELETE_COMPANY:
95 92
         return{
96
-          ...companyState,
93
+          ...state,
97 94
           msgState: MsgState.DELETE
98 95
         }
99 96
 
100 97
       case CompanyActionTypes.DELETE_COMPANY_SUCCESS:
101 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 101
         companiesListCopy2 = companiesListCopy2.splice(deletedCompanyIndex);
105 102
 
106 103
         return{
107
-          ...companyState,
104
+          ...state,
108 105
           msgState: MsgState.DELETED,
109 106
           companiesList: companiesListCopy2
110 107
         };
111 108
 
112 109
       case CompanyActionTypes.DELETE_COMPANY_ERROR:
113 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 177
           msgState: MsgState.ERR,
116 178
           serverMsgError: (<CompanyActionUnion> action).payload
117 179
         };
118 180
 
119 181
     default:
120
-      return { ...companyState };
182
+      return { ...state };
121 183
   }
122 184
 }

+ 19
- 14
src/app/ngrx/companies/company.action.types.ts Zobrazit soubor

@@ -1,31 +1,36 @@
1
-export enum CompanyActionTypes{
1
+export enum CompanyActionTypes {
2 2
   //get all companies action
3 3
   GET_ALL_COMPANIES = '[Company] GET ALL COMPANIES',
4 4
   GET_ALL_COMPANIES_SUCCESS = '[Company] GET ALL COMPANIES SUCCESS',
5 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 7
   // create form to update a company
18 8
   CREATE_COMPANY_FORM_UPDATE = '[Company] CREATE COMPANY FORM UPDATE',
19 9
   CREATE_COMPANY_FORM_UPDATE_SUCCESS = '[Company] CREATE COMPANY FORM UPDATE SUCCESS',
20 10
   CREATE_COMPANY_FORM_UPDATE_ERROR = '[Company] CREATE COMPANY FORM UPDATE ERROR',
21 11
 
22 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 17
   //Delete a company
28 18
   DELETE_COMPANY = '[Company] DELETE COMPANY',
29 19
   DELETE_COMPANY_SUCCESS = '[Company] DELETE COMPANY SUCCESS',
30 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 Zobrazit soubor

@@ -4,5 +4,5 @@ export class CompanyState{
4 4
   currentCompany!: Company | null;
5 5
   companiesList!: Company[];
6 6
   msgState!: MsgState;
7
-  serverMsgErron!: string;
7
+  serverMsgError!: string;
8 8
 }

+ 39
- 0
src/app/ngrx/companies/effects.company.create.ts Zobrazit soubor

@@ -0,0 +1,39 @@
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 Zobrazit soubor

@@ -1,27 +0,0 @@
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 Zobrazit soubor

@@ -0,0 +1,54 @@
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 Zobrazit soubor

@@ -1,15 +1,15 @@
1 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 3
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
4 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 6
 import { Injectable } from '@angular/core';
7 7
 import { Company } from 'src/app/shared/models/company/company.model';
8 8
 
9 9
 @Injectable()
10 10
 export class CompanyUpdateDeleteEffects {
11 11
   constructor(
12
-    private companiesService: CompaniesService,
12
+    private companiesService: CompaniesServices,
13 13
     private companyActions: Actions
14 14
   ) {}
15 15
 
@@ -46,8 +46,8 @@ export class CompanyUpdateDeleteEffects {
46 46
       ofType(CompanyActionTypes.DELETE_COMPANY),
47 47
       mergeMap((action: CompanyActionUnion)=>{
48 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 Zobrazit soubor

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

+ 2
- 2
src/app/ngrx/projects/effects.project.create.ts Zobrazit soubor

@@ -1,7 +1,7 @@
1 1
 import { ProjectActionTypes } from './project.action.types';
2 2
 import { ProjectActionUnion, CreateProjectFormAddAction, SaveProjectFormDataActionSuccess, SaveProjectFormDataActionError, CreateProjectFormAddActionSuccess } from './projects.actions';
3 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 5
 import { Actions, createEffect, ofType } from '@ngrx/effects';
6 6
 import { Injectable } from '@angular/core';
7 7
 import { Project } from 'src/app/shared/models/project/project.model';
@@ -11,7 +11,7 @@ export class ProjectCreateEffects {
11 11
 
12 12
   constructor(
13 13
     private projectActions: Actions,
14
-    private projectsService: ProjectsService
14
+    private projectsService: ProjectsServices
15 15
   ) {}
16 16
 
17 17
   //create project form effect

+ 3
- 3
src/app/ngrx/projects/effects.project.get.ts Zobrazit soubor

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

+ 2
- 2
src/app/ngrx/projects/effects.project.update.delete.ts Zobrazit soubor

@@ -11,13 +11,13 @@ import {
11 11
 } from './projects.actions';
12 12
 import { Observable, mergeMap, map, catchError, of } from 'rxjs';
13 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 15
 import { Injectable } from '@angular/core';
16 16
 
17 17
 @Injectable()
18 18
 export class ProjectUpdateEffects {
19 19
   constructor(
20
-    private projectsService: ProjectsService,
20
+    private projectsService: ProjectsServices,
21 21
     private projectActions: Actions
22 22
   ) {}
23 23
 

+ 1
- 1
src/app/ngrx/projects/projects.reducer.ts Zobrazit soubor

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

+ 39
- 34
src/app/ngrx/users/effects.user.create.ts Zobrazit soubor

@@ -1,41 +1,46 @@
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 10
 import { catchError, map, mergeMap, Observable, of } from 'rxjs';
5 11
 import { Actions, createEffect, ofType } from '@ngrx/effects';
6 12
 import { UserActionTypes } from './user.action.types';
7 13
 import { User } from 'src/app/shared/models/user/user.model';
8 14
 
9 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 Zobrazit soubor

@@ -1,8 +1,14 @@
1 1
 import { Router } from '@angular/router';
2
-import { UsersService } from '../../shared/services/users.service';
2
+import { UsersServices } from '../../shared/services/users.service';
3 3
 import { Actions, createEffect, ofType } from '@ngrx/effects';
4 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 12
 import { Observable, mergeMap, map, catchError, of, tap } from 'rxjs';
7 13
 import { User } from 'src/app/shared/models/user/user.model';
8 14
 import { UserActionTypes } from './user.action.types';
@@ -11,11 +17,11 @@ import { UserActionTypes } from './user.action.types';
11 17
 export class UserGetSearchEffects {
12 18
   constructor(
13 19
     private userActions: Actions,
14
-    private usersService: UsersService,
20
+    private usersService: UsersServices,
15 21
     private router: Router
16 22
   ) {}
17 23
 
18
-  //create getAllUsers effect
24
+  //getAllUsers effect
19 25
 
20 26
   getAllUsersEffect: Observable<UserActionUnion> = createEffect(() =>
21 27
     this.userActions.pipe(
@@ -29,39 +35,29 @@ export class UserGetSearchEffects {
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 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 43
         ofType(UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS),
50 44
         tap(() => {
51
-            this.router.navigate(['/user-s-projects']);
45
+          this.router.navigate(['/user-s-projects']);
52 46
         })
53
-    ),
47
+      ),
54 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 55
       ofType(UserActionTypes.GET_USER_S_PROJECTS),
60
-      mergeMap( (action: UserActionUnion)=>{
56
+      mergeMap((action: UserActionUnion) => {
61 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 Zobrazit soubor

@@ -8,7 +8,7 @@ import {
8 8
   UpdateUserFormActionSuccess,
9 9
 } from './users.actions';
10 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 12
 import { Injectable } from '@angular/core';
13 13
 import { Actions, createEffect, ofType } from '@ngrx/effects';
14 14
 import { User } from 'src/app/shared/models/user/user.model';
@@ -19,7 +19,7 @@ import { Router } from '@angular/router';
19 19
 
20 20
 export class UserUpdateEffects {
21 21
   constructor(
22
-    private usersService: UsersService,
22
+    private usersService: UsersServices,
23 23
     private effectActions: Actions
24 24
   ) {}
25 25
 

+ 0
- 6
src/app/ngrx/users/user.action.types.ts Zobrazit soubor

@@ -7,12 +7,6 @@ export enum UserActionTypes {
7 7
   GET_ALL_USERS_SUCCESS = '[User] GET-ALL USERS SUCCESS',
8 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 10
   // action of button: create a user form
17 11
   CREATE_FORM_ADD_USER = '[User] USER FORM ADD',
18 12
   CREATE_FORM_ADD_USER_SUCCESS = '[User] USER FORM ADD SUCCESS',

+ 4
- 25
src/app/ngrx/users/users.actions.ts Zobrazit soubor

@@ -23,24 +23,6 @@ export class GetAllUsersActionError implements Action {
23 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 26
 // Actios of creating a user form to add user
45 27
 
46 28
 export class CreateFormUserAddAction implements Action {
@@ -133,12 +115,12 @@ export class GetUser_S_Projects implements Action{
133 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 119
   type: UserActionTypes = UserActionTypes.GET_USER_S_PROJECTS_SUCCESS;
138 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 124
   type: UserActionTypes = UserActionTypes.GET_USER_S_PROJECTS_ERROR;
143 125
   constructor(public payload: string){}
144 126
 }
@@ -153,9 +135,6 @@ export type UserActionUnion =
153 135
   | GetAllUsersAction
154 136
   | GetAllUsersActionSuccess
155 137
   | GetAllUsersActionError
156
-  | SearchUsersAction
157
-  | SearchUserActionSuccess
158
-  | SearchUserActionError
159 138
   | CreateFormUserAddAction
160 139
   | CreateFormUserAddActionSuccess
161 140
   | CreateFormUserAddActionError
@@ -172,6 +151,6 @@ export type UserActionUnion =
172 151
   | DeleteUserActionSuccess
173 152
   | DeleteUserActionError
174 153
   | GetUser_S_Projects
175
-  | GetUser_s_ProjectsSuccess
176
-  | GetUser_s_ProjectsError
154
+  | GetUser_S_ProjectsSuccess
155
+  | GetUser_S_ProjectsError
177 156
   | NavigateActionSuccess;

+ 0
- 158
src/app/ngrx/users/users.effects.ts Zobrazit soubor

@@ -1,158 +0,0 @@
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 Zobrazit soubor

@@ -41,28 +41,8 @@ export function userReducer(
41 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 46
     case UserActionTypes.CREATE_FORM_ADD_USER:
67 47
       return {
68 48
         ...state,
@@ -86,7 +66,7 @@ export function userReducer(
86 66
     case UserActionTypes.SAVE_USERFORM_ADD:
87 67
       return {
88 68
         ...state,
89
-        msgState: MsgState.DEFAULT_MSG
69
+        msgState: MsgState.ADD
90 70
       };
91 71
 
92 72
     case UserActionTypes.SAVE_USERFORM_ADD_SUCCESS:
@@ -134,7 +114,7 @@ export function userReducer(
134 114
     case UserActionTypes.UPDATE_USER_FORM:
135 115
       return {
136 116
         ...state,
137
-        msgState: MsgState.DEFAULT_MSG
117
+        msgState: MsgState.UPDATE
138 118
       };
139 119
 
140 120
     case UserActionTypes.UPDATE_USER_FORM_SUCCESS:
@@ -207,7 +187,7 @@ export function userReducer(
207 187
     case UserActionTypes.NAVIGATE_TO_USER_S_PROJECTS_COMPONENT_SUCCESS:
208 188
       return{
209 189
         ...state,
210
-        msgState: MsgState.DEFAULT_MSG
190
+        msgState: MsgState.UPDATE
211 191
       };
212 192
 
213 193
     default:

+ 3
- 3
src/app/pages/accueil/accueil-routing.module.ts Zobrazit soubor

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

+ 3
- 3
src/app/pages/accueil/accueil/accueil.component.html Zobrazit soubor

@@ -2,11 +2,11 @@
2 2
 <div class="container mt-5">
3 3
   <div class="row d-flex justify-content-left">
4 4
 
5
-    <div class="card bg-light" style="width: 20rem;">
5
+    <div>
6 6
       <div class="card-body">
7 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 10
       </div>
11 11
     </div>
12 12
 

+ 10
- 10
src/app/pages/base-nav-menu/base-nav-menu.component.html Zobrazit soubor

@@ -8,25 +8,25 @@
8 8
     </mat-toolbar>
9 9
 
10 10
       <mat-nav-list>
11
+        <a mat-list-item routerLink="/">Accueil</a>
11 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 15
       </mat-nav-list>
15 16
   </mat-sidenav>
16 17
 
17 18
   <mat-sidenav-content>
18 19
     <mat-toolbar>
19 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 28
       <span>Users, Projects and Companies Management</span>
28 29
     </mat-toolbar>
29 30
     <!-- Add Content Here -->
30
-    <router-outlet></router-outlet>
31 31
   </mat-sidenav-content>
32 32
 </mat-sidenav-container>

+ 0
- 1
src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.html Zobrazit soubor

@@ -1 +0,0 @@
1
-<p>companies-create works!</p>

+ 0
- 15
src/app/pages/companies-manager/companies-management/companies-create/companies-create.component.ts Zobrazit soubor

@@ -1,15 +0,0 @@
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 Zobrazit soubor

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

+ 2
- 2
src/app/pages/companies-manager/companies-management/companies-list/companies-list.component.ts Zobrazit soubor

@@ -1,5 +1,5 @@
1 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 3
 import { CompanyState } from './../../../../ngrx/companies/company.state';
4 4
 import { Router } from '@angular/router';
5 5
 import { Component, Input, OnInit } from '@angular/core';
@@ -28,7 +28,7 @@ export class CompaniesListComponent implements OnInit {
28 28
 
29 29
   onCompanyDelete(company: Company) {
30 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 Zobrazit soubor


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

@@ -0,0 +1,82 @@
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 Zobrazit soubor

@@ -1,20 +1,20 @@
1 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 9
   beforeEach(async () => {
10 10
     await TestBed.configureTestingModule({
11
-      declarations: [ CompaniesCreateComponent ]
11
+      declarations: [ CompanyCreateComponent ]
12 12
     })
13 13
     .compileComponents();
14 14
   });
15 15
 
16 16
   beforeEach(() => {
17
-    fixture = TestBed.createComponent(CompaniesCreateComponent);
17
+    fixture = TestBed.createComponent(CompanyCreateComponent);
18 18
     component = fixture.componentInstance;
19 19
     fixture.detectChanges();
20 20
   });

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

@@ -0,0 +1,70 @@
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 Zobrazit soubor

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

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

@@ -1,3 +1,4 @@
1
+import { Router } from '@angular/router';
1 2
 import { GetAllCompaniesAction } from './../../../../ngrx/companies/companies.actions';
2 3
 import { CompanyState } from './../../../../ngrx/companies/company.state';
3 4
 import { Component, OnInit } from '@angular/core';
@@ -6,23 +7,28 @@ import { Store } from '@ngrx/store';
6 7
 @Component({
7 8
   selector: 'app-company-nav-bar',
8 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 25
     this.store.dispatch(new GetAllCompaniesAction({}));
21
-    this.store.subscribe((state)=>{
26
+    this.store.subscribe((state) => {
22 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 Zobrazit soubor

@@ -0,0 +1,3 @@
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 Zobrazit soubor

@@ -0,0 +1,45 @@
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 Zobrazit soubor

@@ -0,0 +1,25 @@
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 Zobrazit soubor

@@ -0,0 +1,11 @@
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 Zobrazit soubor


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

@@ -0,0 +1,17 @@
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 Zobrazit soubor

@@ -0,0 +1,25 @@
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 Zobrazit soubor

@@ -0,0 +1,27 @@
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 Zobrazit soubor

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

+ 2
- 2
src/app/pages/companies-manager/companies-management/company-update/company-update.component.ts Zobrazit soubor

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

+ 5
- 4
src/app/pages/companies-manager/companies-manager-routing.module.ts Zobrazit soubor

@@ -1,14 +1,15 @@
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 3
 import { CompanyUpdateComponent } from './companies-management/company-update/company-update.component';
2 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 5
 import { NgModule } from '@angular/core';
6 6
 import { RouterModule, Routes } from '@angular/router';
7 7
 
8 8
 const routes: Routes = [
9
-  {path: 'company-create', component: CompaniesCreateComponent},
9
+  {path: 'company-create', component: CompanyCreateComponent},
10 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 15
 @NgModule({

+ 10
- 5
src/app/pages/companies-manager/companies-manager.module.ts Zobrazit soubor

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

+ 1
- 1
src/app/pages/projects-manager/projects-management/project-create/project-create.component.html Zobrazit soubor

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

+ 3
- 3
src/app/pages/projects-manager/projects-management/project-create/project-create.component.ts Zobrazit soubor

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

+ 1
- 1
src/app/pages/projects-manager/projects-management/project-update/project-update.component.html Zobrazit soubor

@@ -13,7 +13,7 @@
13 13
 
14 14
       <div class="card mt-3">
15 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 17
             <b>{{ projectState.currentProject?.userId }}</b>, Company ID:
18 18
             <b>{{ projectState.currentProject?.companyId }}</b>
19 19
 

+ 2
- 2
src/app/pages/projects-manager/projects-management/project-update/project-update.component.ts Zobrazit soubor

@@ -7,7 +7,7 @@ import { ProjectMsgState } from '../../../../shared/models/project/project.msgst
7 7
 import { Priority } from '../../../../shared/models/project/project.priority';
8 8
 import { MsgState } from './../../../../ngrx/msg.state';
9 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 11
 import { ProjectState } from './../../../../ngrx/projects/project.state';
12 12
 import { ActivatedRoute, Router } from '@angular/router';
13 13
 import { Component, OnInit } from '@angular/core';
@@ -27,7 +27,7 @@ export class ProjectUpdateComponent implements OnInit {
27 27
 
28 28
   constructor(
29 29
     activatedRoute: ActivatedRoute,
30
-    private projectsService: ProjectsService,
30
+    private projectsService: ProjectsServices,
31 31
     private store: Store<{
32 32
       projectReducerKey: ProjectState;
33 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 Zobrazit soubor

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

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

+ 1
- 4
src/app/pages/projects-manager/projects-management/projects-list/projects-list.component.html Zobrazit soubor

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

+ 2
- 3
src/app/pages/projects-manager/projects-manager.module.ts Zobrazit soubor

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

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

@@ -2,17 +2,10 @@
2 2
 
3 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 6
         {{state.msgState}}
7 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 9
       <ng-container *ngSwitchCase="msgState.ERR">
17 10
         <div class="alert-danger container pt-3 mt-3">
18 11
           <span> {{state.msgState}}</span> &nbsp;
@@ -20,12 +13,10 @@
20 13
         </div>
21 14
       </ng-container>
22 15
 
23
-
24
-
25 16
       <ng-container *ngSwitchCase="msgState.FORM_LOADED">
26 17
 
27 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 20
           <div class="card-body">
30 21
             <form [formGroup]="userFormGroup" (ngSubmit)="onUserSave(); userFormGroup.reset()">
31 22
 
@@ -166,7 +157,7 @@
166 157
                         </span>
167 158
                         <span
168 159
                           *ngIf="userFormGroup.controls['address'].get('nomRue')?.errors?.['maxlength']"
169
-                          >max chars 15
160
+                          >max chars 50
170 161
                         </span>
171 162
                       </div>
172 163
                     </div>
@@ -273,6 +264,13 @@
273 264
         </div>
274 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 274
     </ng-container>
277 275
 
278 276
 </div>

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

@@ -1,5 +1,7 @@
1
+import { Router } from '@angular/router';
2
+import { GetAllUsersAction } from 'src/app/ngrx/users/users.actions';
1 3
 import { DatePipe } from '@angular/common';
2
-import { UsersService } from '../../../../shared/services/users.service';
4
+import { UsersServices } from '../../../../shared/services/users.service';
3 5
 import { User } from '../../../../shared/models/user/user.model';
4 6
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
5 7
 import {
@@ -22,8 +24,9 @@ export class UserCreateComponent implements OnInit {
22 24
   constructor(
23 25
     private store: Store<{ userReducerKey: UserState }>,
24 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 31
   userState!: UserState;
29 32
   readonly msgState = MsgState;
@@ -60,7 +63,7 @@ export class UserCreateComponent implements OnInit {
60 63
             [
61 64
               Validators.required,
62 65
               Validators.minLength(3),
63
-              Validators.maxLength(25),
66
+              Validators.maxLength(50),
64 67
             ],
65 68
           ],
66 69
           bp: [0, [Validators.required, Validators.min(1)]],
@@ -81,7 +84,7 @@ export class UserCreateComponent implements OnInit {
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,7 +96,7 @@ export class UserCreateComponent implements OnInit {
93 96
     this.usersService.getUserByName(lastname).subscribe((users: User[]) => {
94 97
       if (users.length > 0) {
95 98
         alert(lastname + ' ' + this.msgState.EXIST);
96
-        return;
99
+        this.store.dispatch(new CreateFormUserAddAction({}));//pour reactualiser le formulaire
97 100
       } else {
98 101
         if (
99 102
           window.confirm(
@@ -106,8 +109,8 @@ export class UserCreateComponent implements OnInit {
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 116
   tryEgain() {

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

@@ -1,7 +1,6 @@
1 1
 import { UserState } from './../../../../ngrx/users/user.state';
2 2
 import {
3
-  NavigateActionSuccess,
4
-  SearchUsersAction,
3
+  NavigateActionSuccess
5 4
 } from './../../../../ngrx/users/users.actions';
6 5
 import { GetAllUsersAction } from '../../../../ngrx/users/users.actions';
7 6
 import { Component, OnInit } from '@angular/core';
@@ -44,7 +43,4 @@ export class UserNavBarComponent implements OnInit{
44 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 Zobrazit soubor

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

+ 1
- 1
src/app/pages/users-manager/users-management/user-update/user-update.component.html Zobrazit soubor

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

+ 3
- 3
src/app/pages/users-manager/users-management/user-update/user-update.component.ts Zobrazit soubor

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

+ 1
- 1
src/app/pages/users-manager/users-management/users-list/users-list.component.html Zobrazit soubor

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

+ 0
- 1
src/app/pages/users-manager/users-management/users-management.component.html Zobrazit soubor

@@ -19,5 +19,4 @@
19 19
     </ng-container>
20 20
 
21 21
   </ng-container>
22
-
23 22
 </div>

+ 2
- 0
src/app/pages/users-manager/users-manager.module.ts Zobrazit soubor

@@ -30,5 +30,7 @@ import { UserSProjectsComponent } from './users-management/user-s-projects/user-
30 30
     FormsModule,
31 31
     ReactiveFormsModule
32 32
   ],
33
+
34
+  providers:[DatePipe]
33 35
 })
34 36
 export class UsersManagerModule { }

+ 2
- 2
src/app/shared/services/companies.service.ts Zobrazit soubor

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

+ 1
- 1
src/app/shared/services/projects.service.ts Zobrazit soubor

@@ -7,7 +7,7 @@ import { Project } from '../models/project/project.model';
7 7
 @Injectable({
8 8
   providedIn: 'root',
9 9
 })
10
-export class ProjectsService implements OnInit {
10
+export class ProjectsServices implements OnInit {
11 11
   constructor(private http: HttpClient) {}
12 12
   ngOnInit(): void {}
13 13
 

+ 3
- 3
src/app/shared/services/users.service.ts Zobrazit soubor

@@ -7,7 +7,7 @@ import { User } from '../models/user/user.model';
7 7
 @Injectable({
8 8
   providedIn: 'root',
9 9
 })
10
-export class UsersService {
10
+export class UsersServices {
11 11
   constructor(private http: HttpClient) {}
12 12
 
13 13
   handleError(err: HttpErrorResponse) {
@@ -72,9 +72,9 @@ export class UsersService {
72 72
       .pipe(catchError(this.handleError));
73 73
   }
74 74
 
75
-  searchUser(keyword: string): Observable<User[]> {
75
+  searchUser(firstnameKeyword: string): Observable<User[]> {
76 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 80
     return users;

Powered by TurnKey Linux.