浏览代码

first commit

placidenduwayo 1年前
当前提交
fd7472a038
共有 100 个文件被更改,包括 13649 次插入0 次删除
  1. 77
    0
      Jenkinsfile
  2. 36
    0
      README.md
  3. 16
    0
      angular-project-front/.browserslistrc
  4. 16
    0
      angular-project-front/.editorconfig
  5. 46
    0
      angular-project-front/.eslintrc.json
  6. 42
    0
      angular-project-front/.gitignore
  7. 4
    0
      angular-project-front/.vscode/extensions.json
  8. 20
    0
      angular-project-front/.vscode/launch.json
  9. 3
    0
      angular-project-front/.vscode/settings.json
  10. 42
    0
      angular-project-front/.vscode/tasks.json
  11. 7
    0
      angular-project-front/Dockerfile
  12. 155
    0
      angular-project-front/angular.json
  13. 44
    0
      angular-project-front/karma.conf.js
  14. 10413
    0
      angular-project-front/package-lock.json
  15. 56
    0
      angular-project-front/package.json
  16. 10
    0
      angular-project-front/src/app/app-routing.module.ts
  17. 2
    0
      angular-project-front/src/app/app.component.html
  18. 0
    0
      angular-project-front/src/app/app.component.scss
  19. 10
    0
      angular-project-front/src/app/app.component.ts
  20. 42
    0
      angular-project-front/src/app/app.module.ts
  21. 30
    0
      angular-project-front/src/app/pages/base-menu/base-menu.component.html
  22. 17
    0
      angular-project-front/src/app/pages/base-menu/base-menu.component.scss
  23. 21
    0
      angular-project-front/src/app/pages/base-menu/base-menu.component.ts
  24. 15
    0
      angular-project-front/src/app/pages/module-accueil/compo-accueil/compo-accueil.component.html
  25. 0
    0
      angular-project-front/src/app/pages/module-accueil/compo-accueil/compo-accueil.component.scss
  26. 15
    0
      angular-project-front/src/app/pages/module-accueil/compo-accueil/compo-accueil.component.ts
  27. 15
    0
      angular-project-front/src/app/pages/module-accueil/module-accueil-routing.module.ts
  28. 17
    0
      angular-project-front/src/app/pages/module-accueil/module-accueil.module.ts
  29. 9
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/compo-address-manager.component.html
  30. 0
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/compo-address-manager.component.scss
  31. 58
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/compo-address-manager.component.ts
  32. 84
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-create/sub-compo-address-create.component.html
  33. 0
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-create/sub-compo-address-create.component.scss
  34. 38
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-create/sub-compo-address-create.component.ts
  35. 51
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component.html
  36. 0
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component.scss
  37. 55
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component.ts
  38. 84
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-update/sub-compo-address-update.component.html
  39. 0
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-update/sub-compo-address-update.component.scss
  40. 41
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-update/sub-compo-address-update.component.ts
  41. 35
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component.html
  42. 0
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component.scss
  43. 19
    0
      angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component.ts
  44. 42
    0
      angular-project-front/src/app/pages/module-address-manager/module-address-manager-routing.module.ts
  45. 28
    0
      angular-project-front/src/app/pages/module-address-manager/module-address-manager.module.ts
  46. 10
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/compo-company-manager.component.html
  47. 0
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/compo-company-manager.component.scss
  48. 53
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/compo-company-manager.component.ts
  49. 83
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-create/sub-compo-company-create.component.html
  50. 0
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-create/sub-compo-company-create.component.scss
  51. 24
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-create/sub-compo-company-create.component.ts
  52. 58
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component.html
  53. 0
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component.scss
  54. 58
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component.ts
  55. 72
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-update/sub-compo-company-update.component.html
  56. 0
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-update/sub-compo-company-update.component.scss
  57. 55
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-update/sub-compo-company-update.component.ts
  58. 34
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component.html
  59. 0
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component.scss
  60. 20
    0
      angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component.ts
  61. 42
    0
      angular-project-front/src/app/pages/module-company-manager/module-company-manager-routing.module.ts
  62. 30
    0
      angular-project-front/src/app/pages/module-company-manager/module-company-manager.module.ts
  63. 13
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/compo-employee-manager.component.html
  64. 0
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/compo-employee-manager.component.scss
  65. 61
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/compo-employee-manager.component.ts
  66. 109
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component.html
  67. 0
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component.scss
  68. 75
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component.ts
  69. 72
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component.html
  70. 0
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component.scss
  71. 62
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component.ts
  72. 109
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component.html
  73. 0
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component.scss
  74. 76
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component.ts
  75. 34
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component.html
  76. 0
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component.scss
  77. 22
    0
      angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component.ts
  78. 42
    0
      angular-project-front/src/app/pages/module-employee-manager/module-employee-manager-routing.module.ts
  79. 30
    0
      angular-project-front/src/app/pages/module-employee-manager/module-employee-manger.module.ts
  80. 10
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/compo-project-manager.component.html
  81. 0
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/compo-project-manager.component.scss
  82. 52
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/compo-project-manager.component.ts
  83. 99
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-create/sub-compo-project-create.component.html
  84. 0
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-create/sub-compo-project-create.component.scss
  85. 85
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-create/sub-compo-project-create.component.ts
  86. 69
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component.html
  87. 0
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component.scss
  88. 46
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component.ts
  89. 97
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/subcompo-project-update/subcompo-project-update.component.html
  90. 0
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/subcompo-project-update/subcompo-project-update.component.scss
  91. 90
    0
      angular-project-front/src/app/pages/module-project-manager/compo-project-manager/subcompo-project-update/subcompo-project-update.component.ts
  92. 33
    0
      angular-project-front/src/app/pages/module-project-manager/module-project-manager-routing.module.ts
  93. 28
    0
      angular-project-front/src/app/pages/module-project-manager/module-project-manager.module.ts
  94. 43
    0
      angular-project-front/src/app/shared/events-publisher/events.publisher.ts
  95. 8
    0
      angular-project-front/src/app/shared/models/address/address.model.ts
  96. 9
    0
      angular-project-front/src/app/shared/models/company/company.model.ts
  97. 4
    0
      angular-project-front/src/app/shared/models/company/company.type.ts
  98. 13
    0
      angular-project-front/src/app/shared/models/employee/employee.model.ts
  99. 4
    0
      angular-project-front/src/app/shared/models/employee/employee.state.ts
  100. 0
    0
      angular-project-front/src/app/shared/models/employee/employee.type.ts

+ 77
- 0
Jenkinsfile 查看文件

@@ -0,0 +1,77 @@
1
+pipeline {
2
+    agent any //we tell jenkins to use any available agent
3
+    tools {
4
+        maven 'Maven'
5
+        jdk 'Java17'
6
+        nodejs 'Nodejs'
7
+    }
8
+    stages {
9
+                
10
+        stage ('Build-service-1') {
11
+            steps {
12
+                dir('./spring-project-back/microservices-config-service'){ //enter in folder to locate pom.xml
13
+                    sh 'mvn -B -DskipTests clean verify'
14
+                }
15
+            }
16
+        }
17
+        stage ('Build-service-2') {
18
+            steps {
19
+                dir('./spring-project-back/microservices-registration-service'){
20
+                    sh 'mvn -B -DskipTests clean verify'
21
+                }
22
+            }
23
+        }
24
+        stage ('Build-service-3') {
25
+            steps {
26
+                dir ('./spring-project-back/backend-frontend-gateway-service'){
27
+                     sh 'mvn -B -DskipTests clean verify'
28
+                }
29
+                
30
+            }
31
+         }
32
+
33
+        stage ('Build-service-4') {
34
+            steps {
35
+                dir('./spring-project-back/clean-archi-business-service-address/'){
36
+                      sh 'mvn -B -DskipTests clean verify'
37
+                }
38
+            }
39
+         }
40
+        stage ('Build-service-5'){
41
+            steps {
42
+                dir('./spring-project-back/clean-archi-business-service-company/'){
43
+                     sh 'mvn -B -DskipTests clean verify'
44
+                }
45
+                
46
+            }
47
+          }
48
+        stage ('Build-service-6'){
49
+            steps{
50
+                dir('./spring-project-back/clean-archi-business-service-employee/'){
51
+                     sh 'mvn -B -DskipTests clean verify'
52
+                }
53
+            }
54
+           }
55
+        stage ('Build-service-7'){
56
+            steps {
57
+                dir('./spring-project-back/clean-archi-business-service-project/'){
58
+                    sh 'mvn -B -DskipTests clean verify'
59
+                }
60
+            }
61
+        }
62
+        stage('NPM install'){
63
+            steps{
64
+                dir('./angular-project-front'){//enter in angular project to run some commands
65
+                    sh 'npm install'
66
+                }
67
+            }
68
+        }
69
+        stage('Build-frontend'){
70
+            steps{
71
+                dir('./angular-project-front'){//enter in angular project to run some commands
72
+                    sh 'ng build'
73
+                }
74
+            }
75
+        }
76
+    }
77
+}

+ 36
- 0
README.md 查看文件

@@ -0,0 +1,36 @@
1
+#Full stack application
2
+## Description
3
+
4
+- Application de gestion des employées, des projets associés à ces employées et ces projets sont crées pour des sociétés.
5
+- La partie back: architecture orientée microservices,le pattern clean-architecture et le front: Angular, le pattern RxJS
6
+- Containeurisation de chaque service de l'application avec docker et docker-compose
7
+
8
+### Backend:
9
+- framework spring boot
10
+- microservices-base application
11
+	- ***clean-archi-business-service-address***
12
+	- ***clean-archi-business-service-employee***
13
+	- ***clean-archi-business-service-project***
14
+	- ***clean-archi-business-service-company***
15
+	
16
+- communication entre microservices (1); gestion des scénarios alternatifs et la résilience (2)
17
+	- (1) spring cloud openfeign
18
+	- (2) spring cloud circuit breaker (Resilience4J)
19
+
20
+- design pattern dev pour chaque microservice métier: clean architecture
21
+- service utilitaire pour la centralisation et la gestion des configurations des services métiers et utilitaires: ***microservices-config-service***
22
+- service de passerelle entre le backend (spring-project-back) et le frontend (angular-project-front): ***backend-frontend-gateway-service***
23
+     
24
+- service d'enregistrement des microservices métiers et la gateway dans un annuaire: ***microservices-registration-service***
25
+     
26
+- Images docker des services de l'application
27
+- Déploiement de la pile des images de l'application dans des containers docker avec un docker-compose file: [docker-compose](https://github.com/placidenduwayo1/fullstack-application-springboot-angular-deployment.git)
28
+   
29
+
30
+### Frontend:
31
+
32
+- framework angular
33
+- pattern observer RxJS
34
+
35
+### Architecture globale: 
36
+[architecture](https://drive.google.com/file/d/1cl-0_Iv-YiYb8pXeH6rUK0WdogEmwGNl/view?usp=share_link)

+ 16
- 0
angular-project-front/.browserslistrc 查看文件

@@ -0,0 +1,16 @@
1
+# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+# For additional information regarding the format and rule options, please see:
3
+# https://github.com/browserslist/browserslist#queries
4
+
5
+# For the full list of supported browsers by the Angular framework, please see:
6
+# https://angular.io/guide/browser-support
7
+
8
+# You can see what browsers were selected by your queries by running:
9
+#   npx browserslist
10
+
11
+last 1 Chrome version
12
+last 1 Firefox version
13
+last 2 Edge major versions
14
+last 2 Safari major versions
15
+last 2 iOS major versions
16
+Firefox ESR

+ 16
- 0
angular-project-front/.editorconfig 查看文件

@@ -0,0 +1,16 @@
1
+# Editor configuration, see https://editorconfig.org
2
+root = true
3
+
4
+[*]
5
+charset = utf-8
6
+indent_style = space
7
+indent_size = 2
8
+insert_final_newline = true
9
+trim_trailing_whitespace = true
10
+
11
+[*.ts]
12
+quote_type = single
13
+
14
+[*.md]
15
+max_line_length = off
16
+trim_trailing_whitespace = false

+ 46
- 0
angular-project-front/.eslintrc.json 查看文件

@@ -0,0 +1,46 @@
1
+{
2
+  "root": true,
3
+  "ignorePatterns": [
4
+    "projects/**/*"
5
+  ],
6
+  "overrides": [
7
+    {
8
+      "files": [
9
+        "*.ts"
10
+      ],
11
+      "extends": [
12
+        "eslint:recommended",
13
+        "plugin:@typescript-eslint/recommended",
14
+        "plugin:@angular-eslint/recommended",
15
+        "plugin:@angular-eslint/template/process-inline-templates"
16
+      ],
17
+      "rules": {
18
+        "@angular-eslint/directive-selector": [
19
+          "error",
20
+          {
21
+            "type": "attribute",
22
+            "prefix": "app",
23
+            "style": "camelCase"
24
+          }
25
+        ],
26
+        "@angular-eslint/component-selector": [
27
+          "error",
28
+          {
29
+            "type": "element",
30
+            "prefix": "app",
31
+            "style": "kebab-case"
32
+          }
33
+        ]
34
+      }
35
+    },
36
+    {
37
+      "files": [
38
+        "*.html"
39
+      ],
40
+      "extends": [
41
+        "plugin:@angular-eslint/template/recommended"
42
+      ],
43
+      "rules": {}
44
+    }
45
+  ]
46
+}

+ 42
- 0
angular-project-front/.gitignore 查看文件

@@ -0,0 +1,42 @@
1
+# See http://help.github.com/ignore-files/ for more about ignoring files.
2
+
3
+# Compiled output
4
+/dist
5
+/tmp
6
+/out-tsc
7
+/bazel-out
8
+
9
+# Node
10
+/node_modules
11
+npm-debug.log
12
+yarn-error.log
13
+
14
+# IDEs and editors
15
+.idea/
16
+.project
17
+.classpath
18
+.c9/
19
+*.launch
20
+.settings/
21
+*.sublime-workspace
22
+
23
+# Visual Studio Code
24
+.vscode/*
25
+!.vscode/settings.json
26
+!.vscode/tasks.json
27
+!.vscode/launch.json
28
+!.vscode/extensions.json
29
+.history/*
30
+
31
+# Miscellaneous
32
+/.angular/cache
33
+.sass-cache/
34
+/connect.lock
35
+/coverage
36
+/libpeerconnection.log
37
+testem.log
38
+/typings
39
+
40
+# System files
41
+.DS_Store
42
+Thumbs.db

+ 4
- 0
angular-project-front/.vscode/extensions.json 查看文件

@@ -0,0 +1,4 @@
1
+{
2
+  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+  "recommendations": ["angular.ng-template"]
4
+}

+ 20
- 0
angular-project-front/.vscode/launch.json 查看文件

@@ -0,0 +1,20 @@
1
+{
2
+  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+  "version": "0.2.0",
4
+  "configurations": [
5
+    {
6
+      "name": "ng serve",
7
+      "type": "pwa-chrome",
8
+      "request": "launch",
9
+      "preLaunchTask": "npm: start",
10
+      "url": "http://localhost:4200/"
11
+    },
12
+    {
13
+      "name": "ng test",
14
+      "type": "chrome",
15
+      "request": "launch",
16
+      "preLaunchTask": "npm: test",
17
+      "url": "http://localhost:9876/debug.html"
18
+    }
19
+  ]
20
+}

+ 3
- 0
angular-project-front/.vscode/settings.json 查看文件

@@ -0,0 +1,3 @@
1
+{
2
+    "terminal.explorerKind": "external"
3
+}

+ 42
- 0
angular-project-front/.vscode/tasks.json 查看文件

@@ -0,0 +1,42 @@
1
+{
2
+  // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+  "version": "2.0.0",
4
+  "tasks": [
5
+    {
6
+      "type": "npm",
7
+      "script": "start",
8
+      "isBackground": true,
9
+      "problemMatcher": {
10
+        "owner": "typescript",
11
+        "pattern": "$tsc",
12
+        "background": {
13
+          "activeOnStart": true,
14
+          "beginsPattern": {
15
+            "regexp": "(.*?)"
16
+          },
17
+          "endsPattern": {
18
+            "regexp": "bundle generation complete"
19
+          }
20
+        }
21
+      }
22
+    },
23
+    {
24
+      "type": "npm",
25
+      "script": "test",
26
+      "isBackground": true,
27
+      "problemMatcher": {
28
+        "owner": "typescript",
29
+        "pattern": "$tsc",
30
+        "background": {
31
+          "activeOnStart": true,
32
+          "beginsPattern": {
33
+            "regexp": "(.*?)"
34
+          },
35
+          "endsPattern": {
36
+            "regexp": "bundle generation complete"
37
+          }
38
+        }
39
+      }
40
+    }
41
+  ]
42
+}

+ 7
- 0
angular-project-front/Dockerfile 查看文件

@@ -0,0 +1,7 @@
1
+FROM node:14.21.3
2
+WORKDIR /frontend-app
3
+COPY package.json .
4
+RUN npm install
5
+COPY . .
6
+EXPOSE 4200
7
+CMD [ "ng","serve" ]

+ 155
- 0
angular-project-front/angular.json 查看文件

@@ -0,0 +1,155 @@
1
+{
2
+  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+  "version": 1,
4
+  "newProjectRoot": "projects",
5
+  "projects": {
6
+    "angular13-project-train-front": {
7
+      "projectType": "application",
8
+      "schematics": {
9
+        "@schematics/angular:component": {
10
+          "style": "scss",
11
+          "skipTests": true
12
+        },
13
+        "@schematics/angular:class": {
14
+          "skipTests": true
15
+        },
16
+        "@schematics/angular:directive": {
17
+          "skipTests": true
18
+        },
19
+        "@schematics/angular:guard": {
20
+          "skipTests": true
21
+        },
22
+        "@schematics/angular:interceptor": {
23
+          "skipTests": true
24
+        },
25
+        "@schematics/angular:pipe": {
26
+          "skipTests": true
27
+        },
28
+        "@schematics/angular:resolver": {
29
+          "skipTests": true
30
+        },
31
+        "@schematics/angular:service": {
32
+          "skipTests": true
33
+        },
34
+        "@schematics/angular:application": {
35
+          "strict": true
36
+        }
37
+      },
38
+      "root": "",
39
+      "sourceRoot": "src",
40
+      "prefix": "app",
41
+      "architect": {
42
+        "build": {
43
+          "builder": "@angular-devkit/build-angular:browser",
44
+          "options": {
45
+            "outputPath": "dist/angular13-project-train-front",
46
+            "index": "src/index.html",
47
+            "main": "src/main.ts",
48
+            "polyfills": "src/polyfills.ts",
49
+            "tsConfig": "tsconfig.app.json",
50
+            "inlineStyleLanguage": "scss",
51
+            "assets": [
52
+              "src/favicon.ico",
53
+              "src/assets"
54
+            ],
55
+            "styles": [
56
+              "src/styles.scss",
57
+              "node_modules/bootstrap/dist/css/bootstrap.min.css",
58
+              "node_modules/font-awesome/css/font-awesome.min.css",
59
+              "node_modules/primeicons/primeicons.css",
60
+              "node_modules/primeng/resources/themes/lara-light-blue/theme.css",
61
+              "node_modules/primeng/resources/primeng.min.css"
62
+            ],
63
+            "scripts": [
64
+              "node_modules/jquery/dist/jquery.min.js",
65
+              "node_modules/bootstrap/dist/js/bootstrap.min.js"
66
+            ]
67
+          },
68
+          "configurations": {
69
+            "production": {
70
+              "budgets": [
71
+                {
72
+                  "type": "initial",
73
+                  "maximumWarning": "2mb",
74
+                  "maximumError": "5mb"
75
+                },
76
+                {
77
+                  "type": "anyComponentStyle",
78
+                  "maximumWarning": "2mb",
79
+                  "maximumError": "5mb"
80
+                }
81
+              ],
82
+              "fileReplacements": [
83
+                {
84
+                  "replace": "src/environments/environment.ts",
85
+                  "with": "src/environments/environment.prod.ts"
86
+                }
87
+              ],
88
+              "outputHashing": "all"
89
+            },
90
+            "development": {
91
+              "buildOptimizer": false,
92
+              "optimization": false,
93
+              "vendorChunk": true,
94
+              "extractLicenses": false,
95
+              "sourceMap": true,
96
+              "namedChunks": true
97
+            }
98
+          },
99
+          "defaultConfiguration": "production"
100
+        },
101
+        "serve": {
102
+          "builder": "@angular-devkit/build-angular:dev-server",
103
+          "configurations": {
104
+            "production": {
105
+              "browserTarget": "angular13-project-train-front:build:production"
106
+            },
107
+            "development": {
108
+              "browserTarget": "angular13-project-train-front:build:development"
109
+            }
110
+          },
111
+          "defaultConfiguration": "development"
112
+        },
113
+        "extract-i18n": {
114
+          "builder": "@angular-devkit/build-angular:extract-i18n",
115
+          "options": {
116
+            "browserTarget": "angular13-project-train-front:build"
117
+          }
118
+        },
119
+        "test": {
120
+          "builder": "@angular-devkit/build-angular:karma",
121
+          "options": {
122
+            "main": "src/test.ts",
123
+            "polyfills": "src/polyfills.ts",
124
+            "tsConfig": "tsconfig.spec.json",
125
+            "karmaConfig": "karma.conf.js",
126
+            "inlineStyleLanguage": "scss",
127
+            "assets": [
128
+              "src/favicon.ico",
129
+              "src/assets"
130
+            ],
131
+            "styles": [
132
+              "src/styles.scss"
133
+            ],
134
+            "scripts": []
135
+          }
136
+        },
137
+        "lint": {
138
+          "builder": "@angular-eslint/builder:lint",
139
+          "options": {
140
+            "lintFilePatterns": [
141
+              "src/**/*.ts",
142
+              "src/**/*.html"
143
+            ]
144
+          }
145
+        }
146
+      }
147
+    }
148
+  },
149
+  "cli": {
150
+    "analytics": "1a0066d5-a0ba-4af2-a9bd-5cf9ff85c677",
151
+    "schematicCollections": [
152
+      "@angular-eslint/schematics"
153
+    ]
154
+  }
155
+}

+ 44
- 0
angular-project-front/karma.conf.js 查看文件

@@ -0,0 +1,44 @@
1
+// Karma configuration file, see link for more information
2
+// https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+module.exports = function (config) {
5
+  config.set({
6
+    basePath: '',
7
+    frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+    plugins: [
9
+      require('karma-jasmine'),
10
+      require('karma-chrome-launcher'),
11
+      require('karma-jasmine-html-reporter'),
12
+      require('karma-coverage'),
13
+      require('@angular-devkit/build-angular/plugins/karma')
14
+    ],
15
+    client: {
16
+      jasmine: {
17
+        // you can add configuration options for Jasmine here
18
+        // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+        // for example, you can disable the random execution with `random: false`
20
+        // or set a specific seed with `seed: 4321`
21
+      },
22
+      clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+    },
24
+    jasmineHtmlReporter: {
25
+      suppressAll: true // removes the duplicated traces
26
+    },
27
+    coverageReporter: {
28
+      dir: require('path').join(__dirname, './coverage/angular13-project-train-front'),
29
+      subdir: '.',
30
+      reporters: [
31
+        { type: 'html' },
32
+        { type: 'text-summary' }
33
+      ]
34
+    },
35
+    reporters: ['progress', 'kjhtml'],
36
+    port: 9876,
37
+    colors: true,
38
+    logLevel: config.LOG_INFO,
39
+    autoWatch: true,
40
+    browsers: ['Chrome'],
41
+    singleRun: false,
42
+    restartOnFileChange: true
43
+  });
44
+};

+ 10413
- 0
angular-project-front/package-lock.json
文件差异内容过多而无法显示
查看文件


+ 56
- 0
angular-project-front/package.json 查看文件

@@ -0,0 +1,56 @@
1
+{
2
+  "name": "angular13-project-train-front",
3
+  "version": "0.0.0",
4
+  "scripts": {
5
+    "ng": "ng",
6
+    "start": "ng serve",
7
+    "build": "ng build",
8
+    "watch": "ng build --watch --configuration development",
9
+    "test": "ng test",
10
+    "lint": "ng lint"
11
+  },
12
+  "private": true,
13
+  "dependencies": {
14
+    "@angular-devkit/core": "^15.2.1",
15
+    "@angular/animations": "^15.2.0",
16
+    "@angular/cdk": "^15.2.0",
17
+    "@angular/common": "^15.2.0",
18
+    "@angular/compiler": "^15.2.0",
19
+    "@angular/core": "^15.2.0",
20
+    "@angular/forms": "^15.2.0",
21
+    "@angular/material": "^15.2.0",
22
+    "@angular/platform-browser": "^15.2.0",
23
+    "@angular/platform-browser-dynamic": "^15.2.0",
24
+    "@angular/router": "^15.2.0",
25
+    "bootstrap": "^5.2.3",
26
+    "font-awesome": "^4.7.0",
27
+    "jquery": "^3.6.2",
28
+    "primeicons": "^6.0.1",
29
+    "primeng": "^15.2.0",
30
+    "rxjs": "~7.5.0",
31
+    "tslib": "^2.3.0",
32
+    "zone.js": "~0.11.4"
33
+  },
34
+  "devDependencies": {
35
+    "@angular-devkit/build-angular": "^15.2.1",
36
+    "@angular-eslint/builder": "15.2.1",
37
+    "@angular-eslint/eslint-plugin": "15.2.1",
38
+    "@angular-eslint/eslint-plugin-template": "15.2.1",
39
+    "@angular-eslint/schematics": "15.2.1",
40
+    "@angular-eslint/template-parser": "15.2.1",
41
+    "@angular/cli": "^15.2.0",
42
+    "@angular/compiler-cli": "^15.2.0",
43
+    "@types/jasmine": "~3.10.0",
44
+    "@types/node": "^12.11.1",
45
+    "@typescript-eslint/eslint-plugin": "5.48.2",
46
+    "@typescript-eslint/parser": "5.48.2",
47
+    "eslint": "^8.33.0",
48
+    "jasmine-core": "~4.0.0",
49
+    "karma": "~6.3.0",
50
+    "karma-chrome-launcher": "~3.1.0",
51
+    "karma-coverage": "~2.1.0",
52
+    "karma-jasmine": "~4.0.0",
53
+    "karma-jasmine-html-reporter": "~1.7.0",
54
+    "typescript": "^4.9.5"
55
+  }
56
+}

+ 10
- 0
angular-project-front/src/app/app-routing.module.ts 查看文件

@@ -0,0 +1,10 @@
1
+import { NgModule } from '@angular/core';
2
+import { RouterModule, Routes } from '@angular/router';
3
+
4
+const routes: Routes = [];
5
+
6
+@NgModule({
7
+  imports: [RouterModule.forRoot(routes)],
8
+  exports: [RouterModule]
9
+})
10
+export class AppRoutingModule { }

+ 2
- 0
angular-project-front/src/app/app.component.html 查看文件

@@ -0,0 +1,2 @@
1
+<app-base-menu></app-base-menu>
2
+<router-outlet></router-outlet>

+ 0
- 0
angular-project-front/src/app/app.component.scss 查看文件


+ 10
- 0
angular-project-front/src/app/app.component.ts 查看文件

@@ -0,0 +1,10 @@
1
+import { Component } from '@angular/core';
2
+
3
+@Component({
4
+  selector: 'app-root',
5
+  templateUrl: './app.component.html',
6
+  styleUrls: ['./app.component.scss']
7
+})
8
+export class AppComponent {
9
+  title = 'angular training project front';
10
+}

+ 42
- 0
angular-project-front/src/app/app.module.ts 查看文件

@@ -0,0 +1,42 @@
1
+import { ModuleProjectManagerModule } from './pages/module-project-manager/module-project-manager.module';
2
+import { ModuleCompanyManagerModule } from './pages/module-company-manager/module-company-manager.module';
3
+import { ModuleEmployeeManagerModule } from './pages/module-employee-manager/module-employee-manger.module';
4
+import { ModuleAddressManagerModule } from './pages/module-address-manager/module-address-manager.module';
5
+import { ModuleAccueilModule } from './pages/module-accueil/module-accueil.module';
6
+import { NgModule } from '@angular/core';
7
+import { BrowserModule } from '@angular/platform-browser';
8
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
9
+
10
+import { AppRoutingModule } from './app-routing.module';
11
+import { AppComponent } from './app.component';
12
+import { HttpClientModule } from '@angular/common/http';
13
+import { BaseMenuComponent } from './pages/base-menu/base-menu.component';
14
+import { LayoutModule } from '@angular/cdk/layout';
15
+import { MatToolbarModule } from '@angular/material/toolbar';
16
+import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/legacy-button';
17
+import { MatSidenavModule } from '@angular/material/sidenav';
18
+import { MatIconModule } from '@angular/material/icon';
19
+import { MatLegacyListModule as MatListModule } from '@angular/material/legacy-list';
20
+
21
+@NgModule({
22
+  declarations: [AppComponent, BaseMenuComponent],
23
+  imports: [
24
+    BrowserModule,
25
+    AppRoutingModule,
26
+    HttpClientModule,
27
+    LayoutModule,
28
+    MatToolbarModule,
29
+    MatButtonModule,
30
+    MatSidenavModule,
31
+    MatIconModule,
32
+    MatListModule,
33
+    BrowserAnimationsModule,
34
+    ModuleAccueilModule,
35
+    ModuleAddressManagerModule,
36
+    ModuleEmployeeManagerModule,
37
+    ModuleCompanyManagerModule,
38
+    ModuleProjectManagerModule,
39
+  ],
40
+  bootstrap: [AppComponent],
41
+})
42
+export class AppModule {}

+ 30
- 0
angular-project-front/src/app/pages/base-menu/base-menu.component.html 查看文件

@@ -0,0 +1,30 @@
1
+<mat-sidenav-container class="sidenav-container">
2
+  <mat-sidenav #drawer class="sidenav" fixedInViewport
3
+      [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
4
+      [mode]="(isHandset$ | async) ? 'over' : 'side'"
5
+      [opened]="(isHandset$ | async) === false">
6
+    <mat-toolbar><a mat-list-item routerLink="/"><img src="../assets/natan.png" width="100"/></a></mat-toolbar>
7
+    <mat-nav-list>
8
+      <a mat-list-item routerLink="/">Welcome</a>
9
+      <a mat-list-item routerLink="/addresses-management">addresses</a>
10
+      <a mat-list-item routerLink="/employees-management">employees</a>
11
+      <a mat-list-item routerLink="/companies-management">companies</a>
12
+      <a mat-list-item routerLink="/projects-management">projects</a>
13
+    </mat-nav-list>
14
+  </mat-sidenav>
15
+  <mat-sidenav-content>
16
+    <mat-toolbar>
17
+      <button
18
+        type="button"
19
+        aria-label="Toggle sidenav"
20
+        mat-icon-button
21
+        (click)="drawer.toggle()"
22
+        *ngIf="isHandset$ | async">
23
+        <mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
24
+      </button>
25
+
26
+      full stack application microservices-oriented demo: clean architecture-spring cloud-microservices registration-rxjs angular
27
+    </mat-toolbar>
28
+    <!-- Add Content Here -->
29
+  </mat-sidenav-content>
30
+</mat-sidenav-container>

+ 17
- 0
angular-project-front/src/app/pages/base-menu/base-menu.component.scss 查看文件

@@ -0,0 +1,17 @@
1
+.sidenav-container {
2
+  height: 100%;
3
+}
4
+
5
+.sidenav {
6
+  width: 200px;
7
+}
8
+
9
+.sidenav .mat-toolbar {
10
+  background: inherit;
11
+}
12
+
13
+.mat-toolbar.mat-primary {
14
+  position: sticky;
15
+  top: 0;
16
+  z-index: 1;
17
+}

+ 21
- 0
angular-project-front/src/app/pages/base-menu/base-menu.component.ts 查看文件

@@ -0,0 +1,21 @@
1
+import { Component } from '@angular/core';
2
+import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
3
+import { Observable } from 'rxjs';
4
+import { map, shareReplay } from 'rxjs/operators';
5
+
6
+@Component({
7
+  selector: 'app-base-menu',
8
+  templateUrl: './base-menu.component.html',
9
+  styleUrls: ['./base-menu.component.scss']
10
+})
11
+export class BaseMenuComponent {
12
+
13
+  isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
14
+    .pipe(
15
+      map(result => result.matches),
16
+      shareReplay()
17
+    );
18
+
19
+  constructor(private breakpointObserver: BreakpointObserver) {}
20
+
21
+}

+ 15
- 0
angular-project-front/src/app/pages/module-accueil/compo-accueil/compo-accueil.component.html 查看文件

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

+ 0
- 0
angular-project-front/src/app/pages/module-accueil/compo-accueil/compo-accueil.component.scss 查看文件


+ 15
- 0
angular-project-front/src/app/pages/module-accueil/compo-accueil/compo-accueil.component.ts 查看文件

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

+ 15
- 0
angular-project-front/src/app/pages/module-accueil/module-accueil-routing.module.ts 查看文件

@@ -0,0 +1,15 @@
1
+import { CompoAccueilComponent } from './compo-accueil/compo-accueil.component';
2
+import { NgModule } from '@angular/core';
3
+import { RouterModule, Routes } from '@angular/router';
4
+
5
+const routes: Routes = [
6
+  {
7
+    path:"", component: CompoAccueilComponent
8
+  }
9
+];
10
+
11
+@NgModule({
12
+  imports: [RouterModule.forChild(routes)],
13
+  exports: [RouterModule]
14
+})
15
+export class ModuleAccueilRoutingModule { }

+ 17
- 0
angular-project-front/src/app/pages/module-accueil/module-accueil.module.ts 查看文件

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+
4
+import { ModuleAccueilRoutingModule } from './module-accueil-routing.module';
5
+import { CompoAccueilComponent } from './compo-accueil/compo-accueil.component';
6
+
7
+
8
+@NgModule({
9
+  declarations: [
10
+    CompoAccueilComponent
11
+  ],
12
+  imports: [
13
+    CommonModule,
14
+    ModuleAccueilRoutingModule
15
+  ]
16
+})
17
+export class ModuleAccueilModule { }

+ 9
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/compo-address-manager.component.html 查看文件

@@ -0,0 +1,9 @@
1
+
2
+<header>
3
+  <div class="container mt-2">
4
+    <button class="btn btn-outline-info" (click)="onPrintAddresses()">print addresses</button> &nbsp;
5
+    <button class="btn btn-outline-info" (click)="onCreateAddress()">create address</button>
6
+  </div>
7
+</header>
8
+
9
+<app-sub-compo-address-printer [addressesList]="addressesList"></app-sub-compo-address-printer>

+ 0
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/compo-address-manager.component.scss 查看文件


+ 58
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/compo-address-manager.component.ts 查看文件

@@ -0,0 +1,58 @@
1
+import { AddressService } from '../../../shared/services/service-REST/addresses.service';
2
+import { Address } from '../../../shared/models/address/address.model';
3
+import { AddressEvent } from '../../../shared/models/events.model';
4
+import { AddressEventPublisher } from '../../../shared/events-publisher/events.publisher';
5
+import { Component, OnInit } from '@angular/core';
6
+import { ActivatedRoute, Router } from '@angular/router';
7
+
8
+@Component({
9
+  selector: 'app-compo-address-manager',
10
+  templateUrl: './compo-address-manager.component.html',
11
+  styleUrls: ['./compo-address-manager.component.scss']
12
+})
13
+export class CompoAddressPrinterComponent implements OnInit {
14
+
15
+  constructor(
16
+    private activatedRoute: ActivatedRoute,
17
+    private addressEventPubliser : AddressEventPublisher,
18
+    private addressService: AddressService,
19
+    private router: Router) { }
20
+
21
+  addressesList!: Array<Address>;
22
+
23
+  ngOnInit(): void {
24
+    this.addressEventPubliser.addressEventObservable.subscribe((addressEvent: AddressEvent)=>{
25
+      switch(addressEvent){
26
+
27
+        case AddressEvent.GET_ALL_ADDRESSES:
28
+          this.activatedRoute.data.subscribe(addresses=>{
29
+            this.addressesList = addresses["getAllAddressesResolve"];
30
+            console.log(addresses)
31
+            console.log(AddressEvent.GET_ALL_ADDRESSES)
32
+          });
33
+          console.log(addressEvent);
34
+          break;
35
+
36
+        case AddressEvent.CREATE_ADDRESS_FORM:
37
+          console.log(addressEvent);
38
+          this.router.navigateByUrl("address-form-create");
39
+          break;
40
+
41
+        case AddressEvent.REFRESH:
42
+          this.addressService.getAllAddresses().subscribe((addresses: Array<Address>)=>{
43
+            this.addressesList=addresses
44
+          });
45
+          break;
46
+      }
47
+    });
48
+  }
49
+
50
+  onPrintAddresses(){
51
+    this.addressEventPubliser.publishAddressEvent(AddressEvent.GET_ALL_ADDRESSES)
52
+  }
53
+
54
+  onCreateAddress(){
55
+    this.addressEventPubliser.publishAddressEvent(AddressEvent.CREATE_ADDRESS_FORM);
56
+  }
57
+
58
+}

+ 84
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-create/sub-compo-address-create.component.html 查看文件

@@ -0,0 +1,84 @@
1
+<div class="container mt-2">
2
+  <div class="card">
3
+    <div class="card-header">Address infos</div>
4
+    <div class="card-body">
5
+      <form [formGroup]="addressForm" (ngSubmit)="onAddressFormSubmit(); addressForm.reset()">
6
+        <label for="num">num</label>
7
+        <input
8
+          type="text"
9
+          formControlName="num"
10
+          class="form-control"
11
+          [ngClass]="{
12
+            'is-invalid':
13
+              addressForm.controls['num'].touched &&
14
+              addressForm.controls['num'].invalid
15
+          }"
16
+        />
17
+        <div class="invalid-feedback">
18
+          <span *ngIf="addressForm.controls['num'].errors?.['required']">
19
+            num required
20
+          </span>
21
+          <span *ngIf="addressForm.controls['num'].errors?.['min']">
22
+            invalid num
23
+          </span>
24
+        </div>
25
+
26
+        <label for="street">street</label>
27
+        <input
28
+          type="text"
29
+          formControlName="street"
30
+          class="form-control"
31
+          [ngClass]="{
32
+            'is-invalid':
33
+              addressForm.controls['street'].touched &&
34
+              addressForm.controls['street'].invalid
35
+          }"
36
+        />
37
+
38
+        <div class="invalid-feedback">
39
+          <span *ngIf="addressForm.controls['street'].errors?.['required']">
40
+            street name required
41
+          </span>
42
+          <span *ngIf="addressForm.controls['street'].errors?.['minlength']">
43
+            street name length is short
44
+          </span>
45
+        </div>
46
+
47
+
48
+        <label for="pb">pb</label>
49
+        <input type="text" formControlName="pb" class="form-control"
50
+        [ngClass]="{'is-invalid':addressForm.controls['pb'].touched && addressForm.controls['pb'].invalid}"/>
51
+
52
+        <div class="invalid-feedback">
53
+          <span *ngIf="addressForm.controls['pb'].errors?.['required']"> zip code required</span>
54
+          <span *ngIf="addressForm.controls['pb'].errors?.['min']"> zip code not for France</span>
55
+        </div>
56
+
57
+        <label for="city">city</label>
58
+        <input type="text" formControlName="city" class="form-control"
59
+        [ngClass]="{'is-invalid':addressForm.controls['city'].touched && addressForm.controls['city'].invalid}"
60
+        />
61
+
62
+        <div class="invalid-feedback">
63
+          <span *ngIf="addressForm.controls['city'].errors?.['required']"> city required</span>
64
+          <span *ngIf="addressForm.controls['city'].errors?.['minlength']"> city length invalid</span>
65
+        </div>
66
+
67
+        <label for="country">country</label>
68
+        <input type="text" formControlName="country" class="form-control"
69
+        [ngClass]="{'is-invalid':addressForm.controls['country'].touched && addressForm.controls['country'].invalid}"
70
+        />
71
+
72
+        <div class="invalid-feedback">
73
+          <span *ngIf="addressForm.controls['country'].errors?.['required']"> country required</span>
74
+          <span *ngIf="addressForm.controls['country'].errors?.['minlength']"> country length very short</span>
75
+          <span *ngIf="addressForm.controls['country'].errors?.['maxlength']"> country length very long</span>
76
+        </div>
77
+
78
+        <div class="text-center mt-2">
79
+          <button type="submit" class="btn btn-outline-primary">save</button>
80
+        </div>
81
+      </form>
82
+    </div>
83
+  </div>
84
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-create/sub-compo-address-create.component.scss 查看文件


+ 38
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-create/sub-compo-address-create.component.ts 查看文件

@@ -0,0 +1,38 @@
1
+import { Address } from '../../../../shared/models/address/address.model';
2
+import { AddressService } from '../../../../shared/services/service-REST/addresses.service';
3
+import { Component, OnInit } from '@angular/core';
4
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
5
+
6
+@Component({
7
+  selector: 'app-sub-compo-address-create',
8
+  templateUrl: './sub-compo-address-create.component.html',
9
+  styleUrls: ['./sub-compo-address-create.component.scss']
10
+})
11
+export class SubCompoAddressCreateComponent implements OnInit {
12
+
13
+  addressForm!: FormGroup;
14
+  constructor(private formBuilder: FormBuilder,
15
+    private addressService: AddressService) { }
16
+
17
+  ngOnInit(): void {
18
+    this.addressForm = this.formBuilder.group({
19
+      addressID:['', Validators.required],
20
+      num:['', [Validators.required, Validators.min(1)]],
21
+      street: ['', [Validators.required, Validators.minLength(5)]],
22
+      pb: ['',[Validators.required, Validators.min(10000)]],
23
+      city: ['', [Validators.required, Validators.minLength(5)]],
24
+      country: ['', [Validators.required, Validators.minLength(5), Validators.maxLength(50)]]
25
+    });
26
+
27
+  }
28
+
29
+  onAddressFormSubmit(){
30
+    if(window.confirm("CONFIRM")){
31
+      this.addressService.createAddress(this.addressForm.value).subscribe((newAddress: Address)=>{
32
+        console.log(newAddress);
33
+      })
34
+    }
35
+
36
+  }
37
+
38
+}

+ 51
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component.html 查看文件

@@ -0,0 +1,51 @@
1
+<div class="container mt-3">
2
+<p-table
3
+[value]="addressesList"
4
+responsiveLayout="scroll"
5
+styleClass="p-datatable-striped"
6
+*ngIf="addressesList"
7
+[paginator]="true"
8
+[rows]="10"
9
+[showCurrentPageReport]="true"
10
+currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
11
+[rowsPerPageOptions]="[10, 20, 30]"
12
+class="p-3"
13
+>
14
+<ng-template pTemplate="body" let-address>
15
+  <tr>
16
+    <td>{{ address.num }}</td>
17
+    <td>{{ address.street }}</td>
18
+    <td>{{ address.pb }}</td>
19
+    <td>{{ address.city }}</td>
20
+    <td>{{ address.country }}</td>
21
+    <td>
22
+      <button class="btn">
23
+        <i
24
+          class="fa fa-pencil"
25
+          style="color: mediumturquoise"
26
+          (click)="onAddressUpdate(address)"
27
+        ></i>
28
+      </button>
29
+    </td>
30
+    <td>
31
+      <button class="btn">
32
+        <i
33
+          class="fa fa-trash"
34
+          style="color: red"
35
+          (click)="onAddressDelete(address.addressID)"
36
+        ></i>
37
+      </button>
38
+    </td>
39
+    <td>
40
+      <button class="btn">
41
+        <i
42
+        class="fa fa-search"
43
+        style="color: mediumturquoise"
44
+        (click)="onPrintEmployeesLivigOnThisAddress(address.addressID)"
45
+      > employees </i>
46
+      </button>
47
+    </td>
48
+  </tr>
49
+</ng-template>
50
+
51
+</p-table>

+ 0
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component.scss 查看文件


+ 55
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component.ts 查看文件

@@ -0,0 +1,55 @@
1
+import { AddressEventPublisher } from '../../../../shared/events-publisher/events.publisher';
2
+import {  Router } from '@angular/router';
3
+import { AddressService } from '../../../../shared/services/service-REST/addresses.service';
4
+import { Address } from '../../../../shared/models/address/address.model';
5
+import { Component, Input, OnInit } from '@angular/core';
6
+import { AddressEvent } from 'src/app/shared/models/events.model';
7
+
8
+@Component({
9
+  selector: 'app-sub-compo-address-printer',
10
+  templateUrl: './sub-compo-address-printer.component.html',
11
+  styleUrls: ['./sub-compo-address-printer.component.scss'],
12
+})
13
+export class SubCompoAddressPrinterComponent implements OnInit{
14
+  @Input() addressesList!: Address[];
15
+
16
+  constructor(
17
+    private addressService: AddressService,
18
+    private router: Router,
19
+    private addressEventPublisher: AddressEventPublisher,
20
+  ) {}
21
+
22
+
23
+  ngOnInit(): void {
24
+    this.addressEventPublisher.addressEventObservable.subscribe((addressEvent: AddressEvent)=>{
25
+      switch(addressEvent) {
26
+        case AddressEvent.EMPLOYEES_AT_ADDRESS:
27
+          this.router.navigateByUrl('employees-at-address/'+this.addressEmployeesRelated);
28
+          console.log(addressEvent);
29
+          break;
30
+      }
31
+    })
32
+  }
33
+
34
+
35
+  onAddressUpdate(address: Address) {
36
+    this.router.navigateByUrl('address-form-update/' + address.addressID);
37
+  }
38
+
39
+  onAddressDelete(addressID: string) {
40
+    if (window.confirm('CONFIRM DELETE')) {
41
+      this.addressService
42
+        .deleteAddress(addressID)
43
+        .subscribe(()=>{
44
+          this.addressEventPublisher.publishAddressEvent(AddressEvent.REFRESH);
45
+        });
46
+    }
47
+  }
48
+
49
+  addressEmployeesRelated!: number;
50
+
51
+  onPrintEmployeesLivigOnThisAddress(addressID: number){
52
+    this.addressEmployeesRelated = addressID;
53
+    this.addressEventPublisher.publishAddressEvent(AddressEvent.EMPLOYEES_AT_ADDRESS);
54
+  }
55
+}

+ 84
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-update/sub-compo-address-update.component.html 查看文件

@@ -0,0 +1,84 @@
1
+<div class="container mt-2" *ngIf="addressForm">
2
+ <div class="card">
3
+  <div class="card-header">Address infos</div>
4
+  <div class="card-body">
5
+
6
+    <form [formGroup]="addressForm" (ngSubmit)="onAddressFormSubmit(); addressForm.reset()">
7
+      <label for="num">num</label>
8
+      <input
9
+        type="text"
10
+        formControlName="num"
11
+        class="form-control"
12
+        [ngClass]="{
13
+          'is-invalid':
14
+            addressForm.controls['num'].touched &&
15
+            addressForm.controls['num'].invalid
16
+        }"
17
+      />
18
+      <div class="invalid-feedback">
19
+        <span *ngIf="addressForm.controls['num'].errors?.['required']">
20
+          num required
21
+        </span>
22
+        <span *ngIf="addressForm.controls['num'].errors?.['min']">
23
+          invalid num
24
+        </span>
25
+      </div>
26
+
27
+      <label for="street">street</label>
28
+      <input
29
+        type="text"
30
+        formControlName="street"
31
+        class="form-control"
32
+        [ngClass]="{
33
+          'is-invalid':
34
+            addressForm.controls['street'].touched &&
35
+            addressForm.controls['street'].invalid
36
+        }"
37
+      />
38
+
39
+      <div class="invalid-feedback">
40
+        <span *ngIf="addressForm.controls['street'].errors?.['required']">
41
+          street name required
42
+        </span>
43
+        <span *ngIf="addressForm.controls['street'].errors?.['minlength']">
44
+          street name length is short
45
+        </span>
46
+      </div>
47
+
48
+
49
+      <label for="pb">pb</label>
50
+      <input type="text" formControlName="pb" class="form-control"
51
+      [ngClass]="{'is-invalid':addressForm.controls['pb'].touched && addressForm.controls['pb'].invalid}"/>
52
+
53
+      <div class="invalid-feedback">
54
+        <span *ngIf="addressForm.controls['pb'].errors?.['required']"> zip code required</span>
55
+        <span *ngIf="addressForm.controls['pb'].errors?.['min']"> zip code not for France</span>
56
+      </div>
57
+
58
+      <label for="city">city</label>
59
+      <input type="text" formControlName="city" class="form-control"
60
+      [ngClass]="{'is-invalid':addressForm.controls['city'].touched && addressForm.controls['city'].invalid}"
61
+      />
62
+
63
+      <div class="invalid-feedback">
64
+        <span *ngIf="addressForm.controls['city'].errors?.['required']"> city required</span>
65
+        <span *ngIf="addressForm.controls['city'].errors?.['minlength']"> city length invalid</span>
66
+      </div>
67
+
68
+      <label for="country">country</label>
69
+      <input type="text" formControlName="country" class="form-control"
70
+      [ngClass]="{'is-invalid':addressForm.controls['country'].touched && addressForm.controls['country'].invalid}"
71
+      />
72
+
73
+      <div class="invalid-feedback">
74
+        <span *ngIf="addressForm.controls['country'].errors?.['required']"> country required</span>
75
+        <span *ngIf="addressForm.controls['country'].errors?.['minlength']"> country length very short</span>
76
+        <span *ngIf="addressForm.controls['country'].errors?.['maxlength']"> country length very long</span>
77
+      </div>
78
+
79
+      <button class="btn btn-outline-info mt-2" [disabled]="addressForm.invalid">save</button>
80
+    </form>
81
+
82
+  </div>
83
+ </div>
84
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-update/sub-compo-address-update.component.scss 查看文件


+ 41
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-address-update/sub-compo-address-update.component.ts 查看文件

@@ -0,0 +1,41 @@
1
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
2
+import { ActivatedRoute } from '@angular/router';
3
+import { AddressService } from '../../../../shared/services/service-REST/addresses.service';
4
+import { Component, OnInit } from '@angular/core';
5
+
6
+@Component({
7
+  selector: 'app-sub-compo-address-update',
8
+  templateUrl: './sub-compo-address-update.component.html',
9
+  styleUrls: ['./sub-compo-address-update.component.scss']
10
+})
11
+export class SubCompoAddressUpdateComponent implements OnInit {
12
+  addressForm!: FormGroup;
13
+
14
+  constructor(private addressService: AddressService,
15
+    private activatedRoute: ActivatedRoute,
16
+    private formBuilder: FormBuilder) {}
17
+
18
+  ngOnInit(): void {
19
+
20
+    this.activatedRoute.data.subscribe((data)=>{
21
+      let address = data['getAddressByIDResolve'];
22
+      this.addressForm = this.formBuilder.group({
23
+        addressID:[address.addressID],
24
+        num:[address.num, [Validators.required, Validators.min(1)]],
25
+        street: [address.street, [Validators.required, Validators.minLength(5)]],
26
+        pb: [address.pb,[Validators.required, Validators.min(10000)]],
27
+        city: [address.city, [Validators.required, Validators.minLength(5)]],
28
+        country: [address.country, [Validators.required, Validators.minLength(5), Validators.maxLength(50)]]
29
+      });
30
+    });
31
+  }
32
+
33
+  onAddressFormSubmit(){
34
+    if(window.confirm("COMFIRM ADDRESS UPDATE")){
35
+      this.addressService.updateAddress(this.addressForm.value).subscribe(updatedAddress=>{
36
+        console.log(updatedAddress);
37
+      });
38
+    }
39
+  }
40
+
41
+}

+ 35
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component.html 查看文件

@@ -0,0 +1,35 @@
1
+<div class="container">
2
+
3
+  <p-table
4
+  [value]="employeesAtAddress"
5
+  responsiveLayout="scroll"
6
+  styleClass="p-datatable-striped"
7
+  [paginator]="true"
8
+  [rows]="4"
9
+  [showCurrentPageReport]="true"
10
+  currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
11
+  [rowsPerPageOptions]="[4, 8, 12]"
12
+  class="p-3"
13
+>
14
+<ng-template pTemplate="header">
15
+  <tr>
16
+    <th>ID</th><th>firstname</th><th>lastname</th><th>email</th><th>hire date</th>
17
+    <th>state</th> <th>type</th>
18
+  </tr>
19
+</ng-template>
20
+
21
+<ng-template pTemplate="body" let-employee>
22
+  <tr>
23
+    <td>{{ employee.employeeID }}</td>
24
+      <td>{{ employee.firstname | titlecase}}</td>
25
+      <td>{{ employee.lastname | titlecase}}</td>
26
+      <td>{{ employee.email | lowercase }}</td>
27
+      <td>{{ employee.hireDate | date : "dd-MM-yyyy:HH:mm" }}</td>
28
+      <td>{{ employee.employeeState }}</td>
29
+      <td>{{ employee.employeeType}}</td>
30
+
31
+  </tr>
32
+</ng-template>
33
+</p-table>
34
+
35
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component.scss 查看文件


+ 19
- 0
angular-project-front/src/app/pages/module-address-manager/compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component.ts 查看文件

@@ -0,0 +1,19 @@
1
+import { ActivatedRoute } from '@angular/router';
2
+import { Component, OnInit } from '@angular/core';
3
+
4
+@Component({
5
+  selector: 'app-sub-compo-print-employees-at-address',
6
+  templateUrl: './sub-compo-print-employees-at-address.component.html',
7
+  styleUrls: ['./sub-compo-print-employees-at-address.component.scss']
8
+})
9
+export class SubCompoPrintEmployeesAtAddressComponent implements OnInit{
10
+  employeesAtAddress!: Array<any>;
11
+  constructor(private activatedRoute: ActivatedRoute){}
12
+  ngOnInit(): void {
13
+    this.activatedRoute.data.subscribe(data=>{
14
+      this.employeesAtAddress = data['getEmployeesAtAddressResolve'];
15
+    });
16
+  }
17
+
18
+
19
+}

+ 42
- 0
angular-project-front/src/app/pages/module-address-manager/module-address-manager-routing.module.ts 查看文件

@@ -0,0 +1,42 @@
1
+import { SubCompoPrintEmployeesAtAddressComponent } from './compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component';
2
+import { GetAddressByIDResolve, GetEmployeesAtAddressResolve } from './../../shared/services/service-route-resolve/address-resolve/addresse.route.resolve';
3
+import { CompoAddressPrinterComponent as CompoAddressManagerComponent } from './compo-address-manager/compo-address-manager.component';
4
+import { NgModule } from '@angular/core';
5
+import { RouterModule, Routes } from '@angular/router';
6
+import { SubCompoAddressCreateComponent } from './compo-address-manager/sub-compo-address-create/sub-compo-address-create.component';
7
+import { SubCompoAddressUpdateComponent } from './compo-address-manager/sub-compo-address-update/sub-compo-address-update.component';
8
+import { GetAllAddressesResolve } from 'src/app/shared/services/service-route-resolve/address-resolve/addresse.route.resolve';
9
+
10
+const routes: Routes = [
11
+  {
12
+    path :"addresses-management", component: CompoAddressManagerComponent,
13
+    resolve:{
14
+      getAllAddressesResolve: GetAllAddressesResolve
15
+    }
16
+  }
17
+  ,
18
+  {
19
+    path:"address-form-create",
20
+    component: SubCompoAddressCreateComponent
21
+  },
22
+  {
23
+    path:'address-form-update/:addressID',
24
+    component: SubCompoAddressUpdateComponent,
25
+    resolve:{
26
+      getAddressByIDResolve: GetAddressByIDResolve
27
+    }
28
+  },
29
+  {
30
+    path:'employees-at-address/:addressID',
31
+    component: SubCompoPrintEmployeesAtAddressComponent,
32
+    resolve:{
33
+      getEmployeesAtAddressResolve: GetEmployeesAtAddressResolve
34
+    }
35
+  }
36
+];
37
+
38
+@NgModule({
39
+  imports: [RouterModule.forChild(routes)],
40
+  exports: [RouterModule]
41
+})
42
+export class ModuleAddressManagerRoutingModule { }

+ 28
- 0
angular-project-front/src/app/pages/module-address-manager/module-address-manager.module.ts 查看文件

@@ -0,0 +1,28 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { TableModule } from 'primeng/table';
4
+import { ModuleAddressManagerRoutingModule } from './module-address-manager-routing.module';
5
+import { CompoAddressPrinterComponent as CompoAddressManagerComponent } from './compo-address-manager/compo-address-manager.component';
6
+import { SubCompoAddressPrinterComponent } from './compo-address-manager/sub-compo-address-printer/sub-compo-address-printer.component';
7
+import { ReactiveFormsModule } from '@angular/forms';
8
+import { SubCompoAddressCreateComponent } from './compo-address-manager/sub-compo-address-create/sub-compo-address-create.component';
9
+import { SubCompoAddressUpdateComponent } from './compo-address-manager/sub-compo-address-update/sub-compo-address-update.component';
10
+import { SubCompoPrintEmployeesAtAddressComponent } from './compo-address-manager/sub-compo-print-employees-at-address/sub-compo-print-employees-at-address.component';
11
+
12
+
13
+@NgModule({
14
+  declarations: [
15
+    CompoAddressManagerComponent,
16
+    SubCompoAddressPrinterComponent,
17
+    SubCompoAddressCreateComponent,
18
+    SubCompoAddressUpdateComponent,
19
+    SubCompoPrintEmployeesAtAddressComponent
20
+  ],
21
+  imports: [
22
+    CommonModule,
23
+    ModuleAddressManagerRoutingModule,
24
+    ReactiveFormsModule,
25
+    TableModule
26
+  ]
27
+})
28
+export class ModuleAddressManagerModule { }

+ 10
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/compo-company-manager.component.html 查看文件

@@ -0,0 +1,10 @@
1
+<div class="container">
2
+  <button class="btn btn-outline-info" (click)="onPrintCompanies()">
3
+    print companies
4
+  </button>
5
+  &nbsp;
6
+  <button class="btn btn-outline-info" (click)="onCreateCompany()">
7
+    create a company
8
+  </button>
9
+</div>
10
+<app-sub-compo-company-printer [companies]="companies"></app-sub-compo-company-printer>

+ 0
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/compo-company-manager.component.scss 查看文件


+ 53
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/compo-company-manager.component.ts 查看文件

@@ -0,0 +1,53 @@
1
+import { CompanyEventPublisher } from '../../../shared/events-publisher/events.publisher';
2
+import { Company } from '../../../shared/models/company/company.model';
3
+import { ActivatedRoute, Router } from '@angular/router';
4
+import { Component, OnInit } from '@angular/core';
5
+import { CompanyEvent } from 'src/app/shared/models/events.model';
6
+import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
7
+
8
+@Component({
9
+  selector: 'app-compo-company-manager',
10
+  templateUrl: './compo-company-manager.component.html',
11
+  styleUrls: ['./compo-company-manager.component.scss'],
12
+})
13
+export class CompoCompanyManagerComponent implements OnInit {
14
+  constructor(
15
+    private activatedRoute: ActivatedRoute,
16
+    private companyEventPublisher: CompanyEventPublisher,
17
+    private router: Router,
18
+    private companyService: CompanyService
19
+  ) {}
20
+
21
+  companies!: Array<Company>;
22
+
23
+  ngOnInit(): void {
24
+    this.companyEventPublisher.companyEventObservable.subscribe(
25
+      (companyEvent: CompanyEvent) => {
26
+        switch (companyEvent) {
27
+          case CompanyEvent.GET_ALL_COMPANIES:
28
+            this.activatedRoute.data.subscribe((data) => {
29
+              console.log(companyEvent);
30
+              this.companies = data['getAllCompaniesResolve'];
31
+              console.log(this.companies);
32
+            });
33
+            break;
34
+
35
+          case CompanyEvent.COMPANY_DELETED:
36
+            this.companyService.getAllCompanies().subscribe((data: Array<Company>)=>{
37
+              this.companies=data;
38
+            })
39
+            break;
40
+        }
41
+      }
42
+    );
43
+  }
44
+  onPrintCompanies() {
45
+    this.companyEventPublisher.publishCompanyEvent(
46
+      CompanyEvent.GET_ALL_COMPANIES
47
+    );
48
+  }
49
+
50
+  onCreateCompany() {
51
+    this.router.navigate(['/company-create']);
52
+  }
53
+}

+ 83
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-create/sub-compo-company-create.component.html 查看文件

@@ -0,0 +1,83 @@
1
+<div class="container">
2
+  <div class="card">
3
+    <div class="card-header">Company infos</div>
4
+    <div class="card-body">
5
+      <form
6
+        #companyForm="ngForm"
7
+        (ngSubmit)="onCompanyCreate(); companyForm.resetForm()"
8
+      >
9
+        <label for="companyName">company name</label>
10
+        <input
11
+          type="text"
12
+          class="form-control"
13
+          name="companyName"
14
+          #companyName="ngModel"
15
+          [(ngModel)]="company.companyName"
16
+          [ngClass]="{
17
+            'is-invalid': companyName.touched && companyName.invalid
18
+          }"
19
+          required
20
+          minlength="4"
21
+          maxlength="20"
22
+        />
23
+
24
+        <div class="invalid-feedback">
25
+          <span *ngIf="companyName.errors?.['required']">required</span>
26
+          <span *ngIf="companyName.errors?.['minlength']"
27
+            >very short company name</span
28
+          >
29
+          <span *ngIf="companyName.errors?.['maxlength']"
30
+            >too long company name</span
31
+          >
32
+        </div>
33
+
34
+        <label for="companyType">type of company</label>
35
+        <select
36
+          class="form-control"
37
+          required
38
+          name="companyType"
39
+          #companyType="ngModel"
40
+          [(ngModel)]="company.companyType"
41
+        >
42
+          <option
43
+            *ngFor="let type of companyTypes | keyvalue"
44
+            [ngValue]="type.key"
45
+          >
46
+            {{ type.value }}
47
+          </option>
48
+        </select>
49
+
50
+        <div class="invalid-feedback">
51
+          <span *ngIf="companyType.errors?.['required']">required</span>
52
+        </div>
53
+
54
+        <label for="agency">agency</label>
55
+        <input
56
+          type="text"
57
+          class="form-control"
58
+          name="agency"
59
+          #agency="ngModel"
60
+          [(ngModel)]="company.agency"
61
+          [ngClass]="{
62
+            'is-invalid': agency.touched && agency.invalid
63
+          }"
64
+          required
65
+        />
66
+
67
+        <div class="invalid-feedback">
68
+          <span *ngIf="agency.errors?.['required']"> required</span>
69
+        </div>
70
+
71
+        <div class="text-center mt-2">
72
+          <button
73
+            type="submit"
74
+            class="btn btn-outline-primary"
75
+            [disabled]="companyForm.invalid"
76
+          >
77
+            save
78
+          </button>
79
+        </div>
80
+      </form>
81
+    </div>
82
+  </div>
83
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-create/sub-compo-company-create.component.scss 查看文件


+ 24
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-create/sub-compo-company-create.component.ts 查看文件

@@ -0,0 +1,24 @@
1
+import { Company } from '../../../../shared/models/company/company.model';
2
+import { Component } from '@angular/core';
3
+import { CompanyType } from 'src/app/shared/models/company/company.type';
4
+import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
5
+
6
+@Component({
7
+  selector: 'app-sub-compo-company-create',
8
+  templateUrl: './sub-compo-company-create.component.html',
9
+  styleUrls: ['./sub-compo-company-create.component.scss']
10
+})
11
+export class SubCompoCompanyCreateComponent  {
12
+
13
+  constructor(private companyService: CompanyService) { }
14
+  companyTypes = CompanyType;
15
+
16
+  company: Company = new Company();
17
+  onCompanyCreate(){
18
+    if(window.confirm("COMFIRM COMPANY CREATE")){
19
+      this.companyService.createCompany(this.company).subscribe((newCompany: Company)=>{
20
+        console.log(newCompany)
21
+      })
22
+    }
23
+  }
24
+}

+ 58
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component.html 查看文件

@@ -0,0 +1,58 @@
1
+<div class="container mt-3">
2
+  <p-table
3
+  [value]="companies"
4
+  responsiveLayout="scroll"
5
+  styleClass="p-datatable-striped"
6
+  *ngIf="companies"
7
+  [paginator]="true"
8
+  [rows]="9"
9
+  [showCurrentPageReport]="true"
10
+  currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
11
+  [rowsPerPageOptions]="[9, 10, 11]"
12
+  class="p-3"
13
+  >
14
+  <ng-template pTemplate="header">
15
+    <tr>
16
+      <th>ID</th><th>name</th><th>type</th><th>connected date</th> <th>agency</th>
17
+      <th></th><th></th><th></th>
18
+    </tr>
19
+  </ng-template>
20
+  <ng-template pTemplate="body" let-company>
21
+    <tr>
22
+      <td>{{ company.companyID }}</td>
23
+      <td>{{ company.companyName }}</td>
24
+      <td>{{ company.companyType }}</td>
25
+      <td>{{company.connectedDate}} </td>
26
+      <td> {{company.agency}} </td>
27
+      <td>
28
+        <button class="btn">
29
+          <i
30
+            class="fa fa-pencil"
31
+            style="color: mediumturquoise"
32
+            (click)="onCompanyUpdate(company)"
33
+          ></i>
34
+        </button>
35
+      </td>
36
+      <td>
37
+        <button class="btn">
38
+          <i
39
+            class="fa fa-trash"
40
+            style="color: red"
41
+            (click)="onCompanyDelete(company.companyID)"
42
+          ></i>
43
+        </button>
44
+      </td>
45
+      <td>
46
+        <button class="btn">
47
+          <i
48
+            class="fa fa-search"
49
+            style="color: mediumturquoise"
50
+            (click)="onPrintProjectsRelated(company.companyID)"
51
+          > projects</i>
52
+        </button>
53
+      </td>
54
+    </tr>
55
+  </ng-template>
56
+
57
+  </p-table>
58
+

+ 0
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component.scss 查看文件


+ 58
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component.ts 查看文件

@@ -0,0 +1,58 @@
1
+import { Router } from '@angular/router';
2
+import { CompanyEventPublisher } from '../../../../shared/events-publisher/events.publisher';
3
+import { Company } from '../../../../shared/models/company/company.model';
4
+import { Component, Input, OnInit } from '@angular/core';
5
+import { CompanyEvent } from 'src/app/shared/models/events.model';
6
+import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
7
+
8
+@Component({
9
+  selector: 'app-sub-compo-company-printer',
10
+  templateUrl: './sub-compo-company-printer.component.html',
11
+  styleUrls: ['./sub-compo-company-printer.component.scss']
12
+})
13
+export class SubCompoCompanyPrinterComponent implements OnInit {
14
+
15
+  constructor(private companyEventPublisher: CompanyEventPublisher,
16
+    private companyService: CompanyService,
17
+    private router : Router) { }
18
+
19
+  @Input () companies!: Array<Company>;
20
+
21
+  ngOnInit(): void {
22
+    this.companyEventPublisher.companyEventObservable.subscribe((companyEvent: CompanyEvent)=>{
23
+      switch(companyEvent) {
24
+        case CompanyEvent.UPDATE_COMPANY_FORM:
25
+          this.router.navigateByUrl('company-update/'+this.idToUpdate);
26
+          console.log(companyEvent);
27
+          break;
28
+        case CompanyEvent.PROJECTS_ASSIGNEDTO_COMPANY:
29
+          this.router.navigateByUrl('projects-assignedto-company/'+this.companyIDProjectsRelated);
30
+          console.log(companyEvent);
31
+          break;
32
+      }
33
+    })
34
+  }
35
+
36
+  idToUpdate!: string;
37
+
38
+  onCompanyUpdate(company: Company){
39
+    this.idToUpdate = company.companyID;
40
+    this.companyEventPublisher.publishCompanyEvent(CompanyEvent.UPDATE_COMPANY_FORM)
41
+  }
42
+
43
+  onCompanyDelete(companyID: string){
44
+    if(window.confirm('CONFIRM COMPANY DELETE')){
45
+      this.companyService.deleteCompany(companyID).subscribe(
46
+        ()=>{
47
+          this.companyEventPublisher.publishCompanyEvent(CompanyEvent.REFRESH);
48
+        }
49
+      );
50
+    }
51
+  }
52
+
53
+  companyIDProjectsRelated!: string;
54
+  onPrintProjectsRelated(companyID: string){
55
+    this.companyIDProjectsRelated = companyID;
56
+    this.companyEventPublisher.publishCompanyEvent(CompanyEvent.PROJECTS_ASSIGNEDTO_COMPANY)
57
+  }
58
+}

+ 72
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-update/sub-compo-company-update.component.html 查看文件

@@ -0,0 +1,72 @@
1
+<div class="container" *ngIf="companyForm">
2
+  <div class="card">
3
+    <div class="card-header">Company infos</div>
4
+    <div class="card-body">
5
+      <form [formGroup]="companyForm"
6
+        (ngSubmit)="onCompanyUpdate(); companyForm.reset()"
7
+      >
8
+        <label for="companyName">company name</label>
9
+        <input
10
+          type="text"
11
+          class="form-control"
12
+          formControlName="companyName"
13
+          [ngClass]="{
14
+            'is-invalid': companyForm.controls['companyName'].touched && companyForm.controls['companyName'].invalid
15
+          }"
16
+        />
17
+
18
+        <div class="invalid-feedback">
19
+          <span *ngIf="companyForm.controls['companyName'].errors?.['required']">required</span>
20
+          <span *ngIf="companyForm.controls['companyName'].errors?.['minlength']"
21
+            >very short company name</span
22
+          >
23
+          <span *ngIf="companyForm.controls['companyName'].errors?.['maxlength']"
24
+            >too long company name</span
25
+          >
26
+        </div>
27
+
28
+        <label for="companyType">type of company</label>
29
+        <select
30
+          class="form-control" formControlName="companyType"
31
+        >
32
+          <option
33
+            *ngFor="let type of companyTypes | keyvalue"
34
+            [ngValue]="type.value"
35
+          >
36
+            {{ type.value }}
37
+          </option>
38
+        </select>
39
+
40
+        <div class="invalid-feedback">
41
+          <span *ngIf="companyForm.controls['companyType'].errors?.['required']">required</span>
42
+        </div>
43
+
44
+        <label for="agency">agency</label>
45
+        <input
46
+          type="text"
47
+          class="form-control"
48
+          formControlName="agency"
49
+          [ngClass]="{
50
+            'is-invalid': companyForm.controls['agency'].touched && companyForm.controls['agency'].invalid
51
+          }"
52
+        />
53
+
54
+        <div class="invalid-feedback">
55
+          <span *ngIf="companyForm.controls['agency'].errors?.['required']"> required</span>
56
+          <span *ngIf="companyForm.controls['agency'].errors?.['minlength']"> required</span>
57
+        </div>
58
+
59
+        <div class="text-center mt-2">
60
+          <button
61
+            type="submit"
62
+            class="btn btn-outline-primary"
63
+            [disabled]="companyForm.invalid"
64
+          >
65
+            save
66
+          </button>
67
+        </div>
68
+      </form>
69
+    </div>
70
+  </div>
71
+</div>
72
+

+ 0
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-update/sub-compo-company-update.component.scss 查看文件


+ 55
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-company-update/sub-compo-company-update.component.ts 查看文件

@@ -0,0 +1,55 @@
1
+import { Company } from './../../../../shared/models/company/company.model';
2
+import { CompanyEventPublisher } from '../../../../shared/events-publisher/events.publisher';
3
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
4
+import { ActivatedRoute } from '@angular/router';
5
+import { Component, OnInit } from '@angular/core';
6
+import { CompanyEvent } from 'src/app/shared/models/events.model';
7
+import { CompanyType } from 'src/app/shared/models/company/company.type';
8
+import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
9
+
10
+@Component({
11
+  selector: 'app-sub-compo-company-update',
12
+  templateUrl: './sub-compo-company-update.component.html',
13
+  styleUrls: ['./sub-compo-company-update.component.scss'],
14
+})
15
+export class SubCompoCompanyUpdateComponent implements OnInit {
16
+  companyForm!: FormGroup;
17
+  constructor(
18
+    private activatedRoute: ActivatedRoute,
19
+    private fbuilder: FormBuilder,
20
+    private companyService: CompanyService,
21
+    private companyEventPublisher: CompanyEventPublisher
22
+  ) {}
23
+
24
+  companyTypes = CompanyType;
25
+
26
+  ngOnInit(): void {
27
+    this.activatedRoute.data.subscribe(data=>{
28
+      let company: Company = data['getCompanyByIDResolve'];
29
+      console.log(company);
30
+      this.companyForm = this.fbuilder.group({
31
+        companyID: [company.companyID],
32
+        companyName: [
33
+          company.companyName,
34
+          [
35
+            Validators.required,
36
+            Validators.minLength(4),
37
+            Validators.maxLength(20),
38
+          ],
39
+        ],
40
+        companyType: [company.companyType, Validators.required],
41
+        agency: [company.agency,[Validators.required, Validators.minLength(5)]]
42
+      });
43
+    });
44
+  }
45
+
46
+  onCompanyUpdate() {
47
+    let company:Company = this.companyForm.value;
48
+    if(window.confirm("COMPANY CONFIRM UPDATE")){
49
+      this.companyService.updateCompany(company).subscribe((updatedCompany: Company)=>{
50
+        this.companyEventPublisher.publishCompanyEvent(CompanyEvent.UPDATE_COMPANY);
51
+        console.log(updatedCompany);
52
+      })
53
+    }
54
+  }
55
+}

+ 34
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component.html 查看文件

@@ -0,0 +1,34 @@
1
+<div class="container">
2
+  <p-table
3
+    [value]="projects"
4
+    responsiveLayout="scroll"
5
+    styleClass="p-datatable-striped"
6
+    *ngIf="projects"
7
+    [paginator]="true"
8
+    [rows]="5"
9
+    [showCurrentPageReport]="true"
10
+    currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
11
+    [rowsPerPageOptions]="[5, 10, 15]"
12
+    class="p-3"
13
+  >
14
+    <ng-template pTemplate="header">
15
+      <tr>
16
+        <th>ID</th>
17
+        <th>project name</th>
18
+        <th>description</th>
19
+        <th>priority</th>
20
+        <th>state</th>
21
+      </tr>
22
+    </ng-template>
23
+
24
+    <ng-template pTemplate="body" let-project>
25
+      <tr>
26
+        <td>{{ project.projectID }}</td>
27
+        <td>{{ project.projectName }}</td>
28
+        <td>{{ project.description }}</td>
29
+        <td>{{ project.priority }}</td>
30
+        <td>{{ project.projectState }}</td>
31
+      </tr>
32
+    </ng-template>
33
+  </p-table>
34
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component.scss 查看文件


+ 20
- 0
angular-project-front/src/app/pages/module-company-manager/compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component.ts 查看文件

@@ -0,0 +1,20 @@
1
+import { ActivatedRoute } from '@angular/router';
2
+import { Component, OnInit } from '@angular/core';
3
+
4
+@Component({
5
+  selector: 'app-sub-compo-print-projects-for-company',
6
+  templateUrl: './sub-compo-print-projects-for-company.component.html',
7
+  styleUrls: ['./sub-compo-print-projects-for-company.component.scss']
8
+})
9
+export class SubCompoPrintProjectsForCompanyComponent implements OnInit {
10
+
11
+  constructor(private route: ActivatedRoute) { }
12
+  projects!: Array<any>
13
+
14
+  ngOnInit(): void {
15
+    this.route.data.subscribe(data=>{
16
+      this.projects = data['getProjectsAssignedToCompanyResolve'];
17
+    })
18
+  }
19
+
20
+}

+ 42
- 0
angular-project-front/src/app/pages/module-company-manager/module-company-manager-routing.module.ts 查看文件

@@ -0,0 +1,42 @@
1
+import { SubCompoPrintProjectsForCompanyComponent } from './compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component';
2
+import { GetCompanyByIDResolve, GetProjectsAssignedToCompanyResolve } from './../../shared/services/service-route-resolve/company-resolve/company.route.resolve';
3
+import { SubCompoCompanyUpdateComponent } from './compo-company-manager/sub-compo-company-update/sub-compo-company-update.component';
4
+import { SubCompoCompanyCreateComponent } from './compo-company-manager/sub-compo-company-create/sub-compo-company-create.component';
5
+import { CompoCompanyManagerComponent } from './compo-company-manager/compo-company-manager.component';
6
+import { NgModule } from '@angular/core';
7
+import { RouterModule, Routes } from '@angular/router';
8
+import { GetAllCompaniesResolve } from 'src/app/shared/services/service-route-resolve/company-resolve/company.route.resolve';
9
+
10
+const routes: Routes = [
11
+  {
12
+    path:'companies-management',
13
+    component: CompoCompanyManagerComponent,
14
+    resolve:{
15
+      getAllCompaniesResolve: GetAllCompaniesResolve
16
+    }
17
+  },
18
+  {
19
+    path:'company-create',
20
+    component: SubCompoCompanyCreateComponent
21
+  },
22
+  {
23
+    path:'company-update/:companyID',
24
+    component: SubCompoCompanyUpdateComponent,
25
+    resolve:{
26
+      getCompanyByIDResolve: GetCompanyByIDResolve
27
+    }
28
+  },
29
+  {
30
+    path: 'projects-assignedto-company/:companyID',
31
+    component: SubCompoPrintProjectsForCompanyComponent,
32
+    resolve:{
33
+      getProjectsAssignedToCompanyResolve: GetProjectsAssignedToCompanyResolve
34
+    }
35
+  }
36
+];
37
+
38
+@NgModule({
39
+  imports: [RouterModule.forChild(routes)],
40
+  exports: [RouterModule]
41
+})
42
+export class ModuleCompanyManagerRoutingModule { }

+ 30
- 0
angular-project-front/src/app/pages/module-company-manager/module-company-manager.module.ts 查看文件

@@ -0,0 +1,30 @@
1
+import { TableModule } from 'primeng/table';
2
+import { NgModule } from '@angular/core';
3
+import { CommonModule } from '@angular/common';
4
+
5
+import { ModuleCompanyManagerRoutingModule } from './module-company-manager-routing.module';
6
+import { CompoCompanyManagerComponent } from './compo-company-manager/compo-company-manager.component';
7
+import { SubCompoCompanyPrinterComponent } from './compo-company-manager/sub-compo-company-printer/sub-compo-company-printer.component';
8
+import { SubCompoCompanyCreateComponent } from './compo-company-manager/sub-compo-company-create/sub-compo-company-create.component';
9
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
10
+import { SubCompoCompanyUpdateComponent } from './compo-company-manager/sub-compo-company-update/sub-compo-company-update.component';
11
+import { SubCompoPrintProjectsForCompanyComponent } from './compo-company-manager/sub-compo-print-projects-for-company/sub-compo-print-projects-for-company.component';
12
+
13
+
14
+@NgModule({
15
+  declarations: [
16
+    CompoCompanyManagerComponent,
17
+    SubCompoCompanyPrinterComponent,
18
+    SubCompoCompanyCreateComponent,
19
+    SubCompoCompanyUpdateComponent,
20
+    SubCompoPrintProjectsForCompanyComponent
21
+  ],
22
+  imports: [
23
+    CommonModule,
24
+    ModuleCompanyManagerRoutingModule,
25
+    TableModule,
26
+    FormsModule,
27
+    ReactiveFormsModule
28
+  ]
29
+})
30
+export class ModuleCompanyManagerModule { }

+ 13
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/compo-employee-manager.component.html 查看文件

@@ -0,0 +1,13 @@
1
+<div class="container mt-2">
2
+  <button class="btn btn-outline-info" (click)="onPrintEmployees()">
3
+    List all employees
4
+  </button>
5
+  &nbsp;
6
+  <button class="btn btn-outline-info" (click)="onCreateEmployee()">
7
+    create employee
8
+  </button>
9
+</div>
10
+
11
+<app-sub-compo-employee-printer
12
+  [employeesList]="employeesList"
13
+></app-sub-compo-employee-printer>

+ 0
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/compo-employee-manager.component.scss 查看文件


+ 61
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/compo-employee-manager.component.ts 查看文件

@@ -0,0 +1,61 @@
1
+import { EmployeeEventPublisher } from '../../../shared/events-publisher/events.publisher';
2
+import { ActivatedRoute, Router } from '@angular/router';
3
+import { Component, OnInit } from '@angular/core';
4
+import { EmployeeEvent } from 'src/app/shared/models/events.model';
5
+import { Employee } from 'src/app/shared/models/employee/employee.model';
6
+import { EmployeeService } from 'src/app/shared/services/service-REST/employees.service';
7
+
8
+@Component({
9
+  selector: 'app-compo-employee-manager',
10
+  templateUrl: './compo-employee-manager.component.html',
11
+  styleUrls: ['./compo-employee-manager.component.scss'],
12
+})
13
+export class CompoEmployeeManagerComponent implements OnInit {
14
+  constructor(
15
+    private activatedRoute: ActivatedRoute,
16
+    private employeeEventPubliser: EmployeeEventPublisher,
17
+    private employeeService: EmployeeService,
18
+    private router : Router
19
+  ) {}
20
+
21
+  employeesList!: Array<Employee>;
22
+
23
+  onPrintEmployees() {
24
+    this.employeeEventPubliser.publishEmployeeEvent(
25
+      EmployeeEvent.GET_ALL_EMPLOYEES
26
+    );
27
+  }
28
+
29
+  ngOnInit(): void {
30
+
31
+    this.employeeEventPubliser.employeeEnventObservable.subscribe(
32
+      (employeeEvent: EmployeeEvent) => {
33
+
34
+        switch (employeeEvent) {
35
+          case EmployeeEvent.GET_ALL_EMPLOYEES:
36
+            this.activatedRoute.data.subscribe((employees) => {
37
+              this.employeesList = employees['getAllEmployeesResolve'];
38
+            });
39
+            console.log(employeeEvent);
40
+            break;
41
+
42
+          case EmployeeEvent.CREATE_EMPLOYEE_FORM:
43
+            console.log(employeeEvent);
44
+            this.router.navigateByUrl("/employee-form-create")
45
+            break;
46
+
47
+          case EmployeeEvent.REFRESH:
48
+            this.employeeService.getAllEmployees().subscribe((employees: Array<Employee>)=>{
49
+              this.employeesList = employees;
50
+            })
51
+            console.log(employeeEvent);
52
+            break;
53
+        }
54
+      }
55
+    );
56
+  }
57
+
58
+  onCreateEmployee(){
59
+    this.employeeEventPubliser.publishEmployeeEvent(EmployeeEvent.CREATE_EMPLOYEE_FORM);
60
+  }
61
+}

+ 109
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component.html 查看文件

@@ -0,0 +1,109 @@
1
+<div class="container mt-2">
2
+
3
+  <div class="card">
4
+    <div class="card-header">Employee infos</div>
5
+    <div class="card-body">
6
+
7
+      <form
8
+      [formGroup]="employeeForm"
9
+      (ngSubmit)="onSaveEmployeeFormData(); employeeForm.reset()"
10
+    >
11
+
12
+          <label for="firstname">firstname</label>
13
+          <input
14
+            type="text"
15
+            class="form-control"
16
+            formControlName="firstname"
17
+            [ngClass]="{
18
+              'is-invalid':
19
+                employeeForm.controls['firstname'].touched &&
20
+                employeeForm.controls['firstname'].invalid
21
+            }"
22
+          />
23
+
24
+          <div class="invalid-feedback">
25
+            <span *ngIf="employeeForm.controls['firstname'].errors?.['required']">
26
+              firstname is required</span
27
+            >
28
+          </div>
29
+
30
+          <label for="lastname">lastname</label>
31
+          <input
32
+            type="text"
33
+            class="form-control"
34
+            formControlName="lastname"
35
+            [ngClass]="{
36
+              'is-invalid':
37
+                employeeForm.controls['lastname'].touched &&
38
+                employeeForm.controls['lastname'].invalid
39
+            }"
40
+          />
41
+
42
+          <div class="invalid-feedback">
43
+            <span *ngIf="employeeForm.controls['lastname'].errors?.['required']"
44
+              >lastname is required</span
45
+            >
46
+          </div>
47
+
48
+          <label for="employeeState">Employee state </label>
49
+          <select formControlName="employeeState" class="form-control">
50
+            <option
51
+              *ngFor="let state of employeeState | keyvalue"
52
+              [ngValue]="state.value"
53
+            >
54
+              {{ state.value }}
55
+            </option>
56
+          </select>
57
+
58
+          <div class="invalid-feedback">
59
+            <span *ngIf="employeeForm.controls['employeeState'].errors?.['required']"
60
+              >state is required</span
61
+            >
62
+          </div>
63
+
64
+          <label for="employeeType">Employee type </label>
65
+          <select formControlName="employeeType" class="form-control">
66
+            <option
67
+              *ngFor="let type of employeeType | keyvalue"
68
+              [ngValue]="type.value"
69
+            >
70
+              {{ type.value }}
71
+            </option>
72
+          </select>
73
+
74
+          <div class="invalid-feedback">
75
+            <span *ngIf="employeeForm.controls['employeeType'].errors?.['required']"
76
+              >type is required</span
77
+            >
78
+          </div>
79
+
80
+          <label for="addressID">Address ID for the employee</label>
81
+          <select formControlName="addressID" class="form-control">
82
+            <option
83
+              *ngFor="let addressMap of addressesMap | keyvalue" [ngValue]="addressMap.key"
84
+            >
85
+              {{addressMap.value}}
86
+            </option>
87
+          </select>
88
+
89
+          <div class="invalid-feedback">
90
+            <span *ngIf="employeeForm.controls['addressID'].errors?.['required']"
91
+              >address is required</span
92
+            >
93
+          </div>
94
+
95
+      <div class="text-center mt-2">
96
+        <button
97
+          type="submit"
98
+          class="btn btn-outline-primary"
99
+          [disabled]="employeeForm.invalid"
100
+        >
101
+          save
102
+        </button>
103
+      </div>
104
+    </form>
105
+
106
+    </div>
107
+  </div>
108
+
109
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component.scss 查看文件


+ 75
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component.ts 查看文件

@@ -0,0 +1,75 @@
1
+import { AddressService } from '../../../../shared/services/service-REST/addresses.service';
2
+import { EmployeeEventPublisher } from '../../../../shared/events-publisher/events.publisher';
3
+import { Employee } from '../../../../shared/models/employee/employee.model';
4
+import { Component, OnInit } from '@angular/core';
5
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
6
+import { EmployeeEvent } from 'src/app/shared/models/events.model';
7
+import { Address } from 'src/app/shared/models/address/address.model';
8
+import { EmployeeState } from 'src/app/shared/models/employee/employee.state';
9
+import { EmployeeType } from 'src/app/shared/models/employee/employee.type';
10
+import { EmployeeService } from 'src/app/shared/services/service-REST/employees.service';
11
+
12
+@Component({
13
+  selector: 'app-sub-compo-employee-create',
14
+  templateUrl: './sub-compo-employee-create.component.html',
15
+  styleUrls: ['./sub-compo-employee-create.component.scss'],
16
+})
17
+export class SubCompoEmployeeCreateComponent implements OnInit {
18
+  employeeForm!: FormGroup;
19
+
20
+  constructor(
21
+    private employeeFormBuilder: FormBuilder,
22
+    private employeeEventPublisher: EmployeeEventPublisher,
23
+    private employeeService: EmployeeService,
24
+    private addressService: AddressService,
25
+  ) {}
26
+
27
+  employeeState = EmployeeState;
28
+  employeeType = EmployeeType;
29
+
30
+  addresses!: Array<Address>;
31
+  addressesMap: Map<number, string> = new Map();
32
+
33
+  ngOnInit(): void {
34
+    this.addressService.getAllAddresses().subscribe(data=>{
35
+      this.addresses = data;
36
+      this.addresses.forEach(address=>{
37
+        this.addressesMap.set(
38
+          address.addressID,
39
+          address.num +
40
+            ' ' +
41
+            address.street +
42
+            ', ' +
43
+            address.pb +
44
+            ' ' +
45
+            address.city +
46
+            ', ' +
47
+            address.country
48
+        );
49
+      })
50
+    })
51
+    this.employeeForm = this.employeeFormBuilder.group({
52
+      employeeID: [0, Validators.required],
53
+      firstname: ['', Validators.required],
54
+      lastname: ['', Validators.required],
55
+      employeeState: [, Validators.required],
56
+      employeeType: [, Validators.required],
57
+      addressID: [, Validators.required],
58
+    });
59
+  }
60
+
61
+  onSaveEmployeeFormData() {
62
+    this.employeeEventPublisher.publishEmployeeEvent(
63
+      EmployeeEvent.SAVE_EMPLOYEE_FORM_DATA
64
+    );
65
+    let employee: Employee = this.employeeForm.value;
66
+
67
+    if (window.confirm('CONFIRM SAVING NEW EMPLOYEE')) {
68
+      this.employeeService
69
+        .createEmployee(employee)
70
+        .subscribe((newEmployee: Employee) => {
71
+          console.log(newEmployee);
72
+        });
73
+    }
74
+  }
75
+}

+ 72
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component.html 查看文件

@@ -0,0 +1,72 @@
1
+<div class="container">
2
+
3
+  <p-table
4
+  [value]="employeesList"
5
+  responsiveLayout="scroll"
6
+  styleClass="p-datatable-striped"
7
+  *ngIf="employeesList"
8
+  [paginator]="true"
9
+  [rows]="4"
10
+  [showCurrentPageReport]="true"
11
+  currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
12
+  [rowsPerPageOptions]="[4, 8, 12]"
13
+  class="p-3"
14
+>
15
+<ng-template pTemplate="header">
16
+  <tr>
17
+    <th>ID</th><th>firstname</th><th>lastname</th><th>email</th><th>address</th><th>hire date</th>
18
+    <th>state</th> <th>type</th> <th></th><th></th><th></th>
19
+  </tr>
20
+</ng-template>
21
+
22
+<ng-template pTemplate="body" let-employee>
23
+  <tr>
24
+      <td>{{ employee.employeeID }}</td>
25
+      <td>{{ employee.firstname | titlecase}}</td>
26
+      <td>{{ employee.lastname | titlecase}}</td>
27
+      <td>{{ employee.email | lowercase }}</td>
28
+      <td>
29
+        <ul>
30
+          <li>{{ employee.address.num }}{{ employee.address.street }}</li>
31
+          <li>
32
+            {{ employee.address.pb }}
33
+            {{ employee.address.city }}
34
+          </li>
35
+        </ul>
36
+      </td>
37
+      <td>{{ employee.hireDate | date : "dd-MM-yyyy" }}</td>
38
+      <td>{{ employee.employeeState }}</td>
39
+      <td>{{ employee.employeeType}}</td>
40
+      <td>
41
+        <button class="btn">
42
+          <i
43
+            class="fa fa-pencil"
44
+            style="color: mediumturquoise"
45
+            (click)="onEmployeeUpdate(employee)"
46
+          ></i>
47
+        </button>
48
+      </td>
49
+      <td>
50
+        <button class="btn">
51
+          <i
52
+            class="fa fa-trash"
53
+            style="color: red"
54
+            (click)="onEmployeeDelete(employee.employeeID)"
55
+          ></i>
56
+        </button>
57
+      </td>
58
+      <td>
59
+        <button class="btn">
60
+          <i
61
+            class="fa fa-search"
62
+            style="color: mediumturquoise"
63
+            (click)="onPrintProjectsAssigned(employee.employeeID)">&nbsp;projects
64
+          </i>
65
+        </button>
66
+      </td>
67
+
68
+  </tr>
69
+</ng-template>
70
+</p-table>
71
+
72
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component.scss 查看文件


+ 62
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component.ts 查看文件

@@ -0,0 +1,62 @@
1
+import { Router } from '@angular/router';
2
+import { EmployeeEventPublisher } from '../../../../shared/events-publisher/events.publisher';
3
+import { Employee } from '../../../../shared/models/employee/employee.model';
4
+import { Component, Input, OnInit } from '@angular/core';
5
+import { EmployeeEvent } from 'src/app/shared/models/events.model';
6
+import { EmployeeService } from 'src/app/shared/services/service-REST/employees.service';
7
+
8
+@Component({
9
+  selector: 'app-sub-compo-employee-printer',
10
+  templateUrl: './sub-compo-employee-printer.component.html',
11
+  styleUrls: ['./sub-compo-employee-printer.component.scss']
12
+})
13
+export class SubCompoEmployeePrinterComponent implements OnInit{
14
+
15
+  @Input () employeesList!: Array<Employee>
16
+
17
+  constructor(private employeeService: EmployeeService,
18
+   private employeeEventPublisher: EmployeeEventPublisher,
19
+   private router: Router){}
20
+
21
+  ngOnInit(): void {
22
+    this.employeeEventPublisher.employeeEnventObservable.subscribe((employeeEvent: EmployeeEvent)=>{
23
+
24
+      switch(employeeEvent) {
25
+
26
+        case EmployeeEvent.UPDATE_EMPLOYEE_FORM:
27
+          this.router.navigateByUrl('/employee-form-update/'+this.idToUpdate);
28
+          console.log(employeeEvent)
29
+          break;
30
+        case EmployeeEvent.PROJECTS_ASSIGNEDTO_EMPLOYEE:
31
+          this.router.navigateByUrl('/projects-assignedto-employees/'+this.employeeIDProjectsRelated);
32
+          console.log(employeeEvent);
33
+          break;
34
+      }
35
+    })
36
+  }
37
+
38
+
39
+  idToUpdate!: string;
40
+  onEmployeeUpdate(employee: Employee){
41
+    this.idToUpdate = employee.employeeID;
42
+    this.employeeEventPublisher.publishEmployeeEvent(EmployeeEvent.UPDATE_EMPLOYEE_FORM);
43
+  }
44
+
45
+  idToDelete!: string;
46
+
47
+  onEmployeeDelete(employeeID: string){
48
+    if(window.confirm("CONFIRM EMPLOYEE DELETE!!")){
49
+      this.employeeService.deleteEmployee(employeeID).subscribe(()=>{
50
+        this.employeeEventPublisher.publishEmployeeEvent(EmployeeEvent.REFRESH);
51
+      });
52
+    }
53
+  }
54
+
55
+  employeeIDProjectsRelated!: string;
56
+
57
+  onPrintProjectsAssigned(employeeID: string){
58
+    this.employeeIDProjectsRelated=employeeID;
59
+    this.employeeEventPublisher.publishEmployeeEvent(EmployeeEvent.PROJECTS_ASSIGNEDTO_EMPLOYEE);
60
+  }
61
+
62
+}

+ 109
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component.html 查看文件

@@ -0,0 +1,109 @@
1
+<div class="container mt-2" *ngIf="employeeForm">
2
+  <div class="card">
3
+    <div class="card-header">Employee infos</div>
4
+    <div class="card-body">
5
+
6
+      <form
7
+    [formGroup]="employeeForm"
8
+    (ngSubmit)="onSaveEmployeeFormData(); employeeForm.reset()"
9
+  >
10
+        <label for="firstname">firstname</label>
11
+        <input
12
+          type="text"
13
+          class="form-control"
14
+          formControlName="firstname"
15
+          [ngClass]="{
16
+            'is-invalid':
17
+              employeeForm.controls['firstname'].touched &&
18
+              employeeForm.controls['firstname'].invalid
19
+          }"
20
+        />
21
+
22
+        <div class="invalid-feedback">
23
+          <span *ngIf="employeeForm.controls['firstname'].errors?.['required']">
24
+            firstname is required</span
25
+          >
26
+        </div>
27
+
28
+        <label for="lastname">lastname</label>
29
+        <input
30
+          type="text"
31
+          class="form-control"
32
+          formControlName="lastname"
33
+          [ngClass]="{
34
+            'is-invalid':
35
+              employeeForm.controls['lastname'].touched &&
36
+              employeeForm.controls['lastname'].invalid
37
+          }"
38
+        />
39
+
40
+        <div class="invalid-feedback">
41
+          <span *ngIf="employeeForm.controls['lastname'].errors?.['required']"
42
+            >lastname is required</span
43
+          >
44
+        </div>
45
+
46
+        <label for="employeeState">Employee state </label>
47
+        <select formControlName="employeeState" class="form-control">
48
+          <option
49
+            *ngFor="let state of employeeState | keyvalue"
50
+            [ngValue]="state.value"
51
+          >
52
+            {{ state.value }}
53
+          </option>
54
+        </select>
55
+
56
+        <div class="invalid-feedback">
57
+          <span
58
+            *ngIf="employeeForm.controls['employeeState'].errors?.['required']"
59
+            >state is required</span
60
+          >
61
+        </div>
62
+
63
+        <label for="employeeType">Employee type </label>
64
+        <select formControlName="employeeType" class="form-control">
65
+          <option
66
+            *ngFor="let type of employeeType | keyvalue"
67
+            [ngValue]="type.value"
68
+          >
69
+            {{ type.value }}
70
+          </option>
71
+        </select>
72
+
73
+        <div class="invalid-feedback">
74
+          <span
75
+            *ngIf="employeeForm.controls['employeeType'].errors?.['required']"
76
+            >type is required</span
77
+          >
78
+        </div>
79
+
80
+        <label for="addressID">Address ID for the employee</label>
81
+        <select class="form-control" formControlName="addressID">
82
+          <option
83
+            *ngFor="let addressMap of addressesMap | keyvalue" [ngValue]="addressMap.key"
84
+          >
85
+           {{addressMap.value}}
86
+          </option>
87
+        </select>
88
+
89
+        <div class="invalid-feedback">
90
+          <span *ngIf="employeeForm.controls['addressID'].errors?.['required']"
91
+            >address is required</span
92
+          >
93
+        </div>
94
+
95
+    <div class="text-center mt-2">
96
+      <button
97
+        type="submit"
98
+        class="btn btn-outline-primary"
99
+        [disabled]="employeeForm.invalid"
100
+      >
101
+        save
102
+      </button>
103
+    </div>
104
+  </form>
105
+
106
+    </div>
107
+  </div>
108
+
109
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component.scss 查看文件


+ 76
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component.ts 查看文件

@@ -0,0 +1,76 @@
1
+import { AddressService } from '../../../../shared/services/service-REST/addresses.service';
2
+import { Address } from '../../../../shared/models/address/address.model';
3
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
4
+import { ActivatedRoute } from '@angular/router';
5
+import { Component, OnInit } from '@angular/core';
6
+import { EmployeeEvent } from 'src/app/shared/models/events.model';
7
+import { Employee } from 'src/app/shared/models/employee/employee.model';
8
+import { EmployeeState } from 'src/app/shared/models/employee/employee.state';
9
+import { EmployeeType } from 'src/app/shared/models/employee/employee.type';
10
+import { EmployeeService } from 'src/app/shared/services/service-REST/employees.service';
11
+
12
+@Component({
13
+  selector: 'app-sub-compo-employee-update',
14
+  templateUrl: './sub-compo-employee-update.component.html',
15
+  styleUrls: ['./sub-compo-employee-update.component.scss'],
16
+})
17
+export class SubCompoEmployeeUpdateComponent implements OnInit {
18
+
19
+  constructor(
20
+    private activatedRoute: ActivatedRoute,
21
+    private employeeService: EmployeeService,
22
+    private fbuilder: FormBuilder,
23
+    private addressService: AddressService
24
+  ) {}
25
+
26
+  employeeForm!: FormGroup;
27
+  employeeType = EmployeeType;
28
+  employeeState = EmployeeState;
29
+  addresses!: Array<Address>;
30
+  addressesMap: Map<number, string> = new Map();
31
+
32
+  ngOnInit(): void {
33
+    this.addressService.getAllAddresses().subscribe((data: Array<Address>) => {
34
+      this.addresses = data;
35
+      this.addresses.forEach((address: Address) => {
36
+        this.addressesMap.set(
37
+          address.addressID,
38
+          address.num +
39
+            ' ' +
40
+            address.street +
41
+            ', ' +
42
+            address.pb +
43
+            ' ' +
44
+            address.city +
45
+            ', ' +
46
+            address.country
47
+        );
48
+      });
49
+    });
50
+
51
+    this.activatedRoute
52
+      .data.subscribe((data) => {
53
+        let employee: Employee = data['getEmployeeByIDResolve'];
54
+        console.log(employee);
55
+        this.employeeForm = this.fbuilder.group({
56
+          employeeID: [employee.employeeID],
57
+          firstname: [employee.firstname, Validators.required],
58
+          lastname: [employee.lastname, Validators.required],
59
+          employeeState: [employee.employeeState, Validators.required],
60
+          employeeType: [employee.employeeType, Validators.required],
61
+          addressID: [employee.addressID, Validators.required],
62
+        });
63
+      });
64
+  }
65
+
66
+  onSaveEmployeeFormData() {
67
+    if (window.confirm('COMFIRM EMPLOYEE UPDATE')) {
68
+      this.employeeService
69
+        .updateEmployee(this.employeeForm.value)
70
+        .subscribe((employee: Employee) => {
71
+          console.log(employee);
72
+          console.log(EmployeeEvent.UPDATE_EMPLOYEE);
73
+        });
74
+    }
75
+  }
76
+}

+ 34
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component.html 查看文件

@@ -0,0 +1,34 @@
1
+<div class="container">
2
+  <p-table
3
+    [value]="projects"
4
+    responsiveLayout="scroll"
5
+    styleClass="p-datatable-striped"
6
+    *ngIf="projects"
7
+    [paginator]="true"
8
+    [rows]="5"
9
+    [showCurrentPageReport]="true"
10
+    currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
11
+    [rowsPerPageOptions]="[5, 10, 15]"
12
+    class="p-3"
13
+  >
14
+    <ng-template pTemplate="header">
15
+      <tr>
16
+        <th>ID</th>
17
+        <th>project name</th>
18
+        <th>description</th>
19
+        <th>priority</th>
20
+        <th>state</th>
21
+      </tr>
22
+    </ng-template>
23
+
24
+    <ng-template pTemplate="body" let-project>
25
+      <tr>
26
+        <td>{{ project.projectID }}</td>
27
+        <td>{{ project.projectName }}</td>
28
+        <td>{{ project.description }}</td>
29
+        <td>{{ project.priority }}</td>
30
+        <td>{{ project.projectState }}</td>
31
+      </tr>
32
+    </ng-template>
33
+  </p-table>
34
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component.scss 查看文件


+ 22
- 0
angular-project-front/src/app/pages/module-employee-manager/compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component.ts 查看文件

@@ -0,0 +1,22 @@
1
+import { ActivatedRoute } from '@angular/router';
2
+import { Component, OnInit } from '@angular/core';
3
+
4
+@Component({
5
+  selector: 'app-sub-compo-print-projects-assignedto-employee',
6
+  templateUrl: './sub-compo-print-projects-assignedto-employee.component.html',
7
+  styleUrls: ['./sub-compo-print-projects-assignedto-employee.component.scss']
8
+})
9
+export class SubCompoPrintProjectsAssignedtoEmployeeComponent implements OnInit {
10
+
11
+  constructor(private route: ActivatedRoute) { }
12
+
13
+  projects!: Array<any>;
14
+
15
+  ngOnInit(): void {
16
+    this.route.data.subscribe(data=>{
17
+      this.projects = data['getProjectsAssignedToEmployeeResolve'];
18
+      console.log(this.projects);
19
+    })
20
+  }
21
+
22
+}

+ 42
- 0
angular-project-front/src/app/pages/module-employee-manager/module-employee-manager-routing.module.ts 查看文件

@@ -0,0 +1,42 @@
1
+import { GetProjectsAssignedToEmployeeResolve } from './../../shared/services/service-route-resolve/employee-resolve/employee.route.resolve';
2
+import { SubCompoPrintProjectsAssignedtoEmployeeComponent } from './compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component';
3
+import { SubCompoEmployeeUpdateComponent } from './compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component';
4
+import { SubCompoEmployeeCreateComponent } from './compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component';
5
+import { CompoEmployeeManagerComponent } from './compo-employee-manager/compo-employee-manager.component';
6
+import { NgModule } from '@angular/core';
7
+import { RouterModule, Routes } from '@angular/router';
8
+import { GetAllEmployeesResolve, GetEmployeeByIDResolve } from 'src/app/shared/services/service-route-resolve/employee-resolve/employee.route.resolve';
9
+
10
+const routes: Routes = [
11
+  {
12
+    path: 'employees-management',
13
+    component: CompoEmployeeManagerComponent,
14
+    resolve: {
15
+      getAllEmployeesResolve: GetAllEmployeesResolve,
16
+    },
17
+  },
18
+  {
19
+    path: 'employee-form-create',
20
+    component: SubCompoEmployeeCreateComponent,
21
+  },
22
+  {
23
+    path: 'employee-form-update/:employeeID',
24
+    component: SubCompoEmployeeUpdateComponent,
25
+    resolve:{
26
+      getEmployeeByIDResolve:GetEmployeeByIDResolve
27
+    }
28
+  },
29
+  {
30
+    path:'projects-assignedto-employees/:employeeID',
31
+    component: SubCompoPrintProjectsAssignedtoEmployeeComponent,
32
+    resolve:{
33
+      getProjectsAssignedToEmployeeResolve: GetProjectsAssignedToEmployeeResolve
34
+    }
35
+  }
36
+];
37
+
38
+@NgModule({
39
+  imports: [RouterModule.forChild(routes)],
40
+  exports: [RouterModule],
41
+})
42
+export class ModuleEmployeeManagerRoutingModule {}

+ 30
- 0
angular-project-front/src/app/pages/module-employee-manager/module-employee-manger.module.ts 查看文件

@@ -0,0 +1,30 @@
1
+import { TableModule } from 'primeng/table';
2
+import { ReactiveFormsModule } from '@angular/forms';
3
+import { NgModule } from '@angular/core';
4
+import { CommonModule } from '@angular/common';
5
+
6
+import { ModuleEmployeeManagerRoutingModule } from './module-employee-manager-routing.module';
7
+import { CompoEmployeeManagerComponent } from './compo-employee-manager/compo-employee-manager.component';
8
+import { SubCompoEmployeePrinterComponent } from './compo-employee-manager/sub-compo-employee-printer/sub-compo-employee-printer.component';
9
+import { SubCompoEmployeeCreateComponent } from './compo-employee-manager/sub-compo-employee-create/sub-compo-employee-create.component';
10
+import { SubCompoEmployeeUpdateComponent } from './compo-employee-manager/sub-compo-employee-update/sub-compo-employee-update.component';
11
+import { SubCompoPrintProjectsAssignedtoEmployeeComponent } from './compo-employee-manager/sub-compo-print-projects-assignedto-employee/sub-compo-print-projects-assignedto-employee.component';
12
+
13
+
14
+@NgModule({
15
+  declarations: [
16
+    CompoEmployeeManagerComponent,
17
+    SubCompoEmployeePrinterComponent,
18
+    SubCompoEmployeeCreateComponent,
19
+    SubCompoEmployeeUpdateComponent,
20
+    SubCompoPrintProjectsAssignedtoEmployeeComponent
21
+  ],
22
+  imports: [
23
+    CommonModule,
24
+    ModuleEmployeeManagerRoutingModule,
25
+    ReactiveFormsModule,
26
+    TableModule
27
+  ]
28
+
29
+})
30
+export class ModuleEmployeeManagerModule { }

+ 10
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/compo-project-manager.component.html 查看文件

@@ -0,0 +1,10 @@
1
+<div class="container mt-2">
2
+  <button class="btn btn-outline-info" (click)="onPrintProjects()">
3
+    List all projects
4
+  </button>
5
+  &nbsp;
6
+  <button class="btn btn-outline-info" (click)="onCreateProject()">
7
+    Create a project
8
+  </button>
9
+</div>
10
+<app-sub-compo-project-printer [projects]="projects"></app-sub-compo-project-printer>

+ 0
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/compo-project-manager.component.scss 查看文件


+ 52
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/compo-project-manager.component.ts 查看文件

@@ -0,0 +1,52 @@
1
+import { ProjectEventPublisher } from '../../../shared/events-publisher/events.publisher';
2
+import { ActivatedRoute, Router } from '@angular/router';
3
+import { Component, OnInit } from '@angular/core';
4
+import { ProjectEvent } from 'src/app/shared/models/events.model';
5
+import { Project } from 'src/app/shared/models/project/project.model';
6
+import { ProjectService } from 'src/app/shared/services/service-REST/projects.service';
7
+
8
+@Component({
9
+  selector: 'app-compo-project-manager',
10
+  templateUrl: './compo-project-manager.component.html',
11
+  styleUrls: ['./compo-project-manager.component.scss']
12
+})
13
+export class CompoProjectManagerComponent implements OnInit {
14
+
15
+  constructor(private activatedRoute: ActivatedRoute,
16
+    private projectEventPublisher: ProjectEventPublisher,
17
+    private projectService: ProjectService,
18
+    private router: Router) { }
19
+
20
+    projects!: Array<Project>;
21
+
22
+  ngOnInit(): void {
23
+    this.projectEventPublisher.projectEventObservable.subscribe((projectEvent: ProjectEvent)=>{
24
+      switch(projectEvent) {
25
+        case ProjectEvent.GET_ALL_PROJECTS :
26
+          this.activatedRoute.data.subscribe(data=>{
27
+            this.projects = data['getAllProjectsResolve']
28
+            console.log(this.projects.length)
29
+          })
30
+          console.log(projectEvent);
31
+          break;
32
+        case ProjectEvent.CREATE_PROJECT_FORM:
33
+          this.router.navigateByUrl('/project-create')
34
+          break;
35
+        case ProjectEvent.REFRESH:
36
+          this.projectService.getAllProjects().subscribe((data: Array<Project>)=>{
37
+            this.projects = data;
38
+            console.log(projectEvent);
39
+          });
40
+          break;
41
+      }
42
+    })
43
+  }
44
+
45
+  onPrintProjects(){
46
+    this.projectEventPublisher.publishProjectEvent(ProjectEvent.GET_ALL_PROJECTS);
47
+  }
48
+  onCreateProject(){
49
+    this.projectEventPublisher.publishProjectEvent(ProjectEvent.CREATE_PROJECT_FORM);
50
+  }
51
+
52
+}

+ 99
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-create/sub-compo-project-create.component.html 查看文件

@@ -0,0 +1,99 @@
1
+<div class="container mt-3">
2
+
3
+  <div class="card">
4
+    <div class="card-header">Project info</div>
5
+    <div class="card-body">
6
+
7
+      <form [formGroup]="projectForm" (ngSubmit)="onSaveProjectForm(); projectForm.reset()">
8
+        <label for="projectName">project name</label>
9
+        <input type="text" class="form-control" formControlName="projectName"
10
+        [ngClass]="{'is-invalid': projectForm.controls['projectName'].touched && projectForm.controls['projectName'].invalid}">
11
+
12
+
13
+        <div class="invalid-feedback">
14
+          <span *ngIf="projectForm.controls['projectName'].errors?.['required']"
15
+            >required</span
16
+          >
17
+        </div>
18
+
19
+        <label for="description"> description</label>
20
+        <input type="text" class="form-control" formControlName="description"
21
+        [ngClass]="{'is-invalid': projectForm.controls['description'].touched && projectForm.controls['description'].invalid}">
22
+
23
+        <div class="invalid-feedback">
24
+          <span *ngIf="projectForm.controls['description'].errors?.['required']"
25
+            >required</span
26
+          >
27
+          <span *ngIf="projectForm.controls['description'].errors?.['minlength']"
28
+          >very short description</span
29
+        >
30
+        </div>
31
+
32
+        <label for="priority">priority</label>
33
+        <select class="form-control" formControlName="priority">
34
+          <option *ngFor="let priority of priorities | keyvalue" [ngValue]="priority.value">
35
+              {{ priority.value }}
36
+          </option>
37
+        </select>
38
+       <div class="invalid-feedback">
39
+        <span *ngIf="projectForm.controls['priority'].errors?.['required']">required</span>
40
+       </div>
41
+        <label for="projectState">project state</label>
42
+        <select
43
+        class="form-control" formControlName="projectState">
44
+        <option
45
+          *ngFor="let state of states | keyvalue"
46
+          [ngValue]="state.value"
47
+        >
48
+          {{ state.value }}
49
+        </option>
50
+        </select>
51
+
52
+        <div class="invalid-feedback">
53
+          <span *ngIf="projectForm.controls['projectState'].errors?.['required']"
54
+            >required</span
55
+          >
56
+        </div>
57
+
58
+        <label for="employeeID"> employee</label>
59
+        <select formControlName="employeeID" class="form-control">
60
+          <option
61
+            *ngFor="let employeeMap of employeesMap | keyvalue" [ngValue]="employeeMap.key"
62
+          >
63
+            {{employeeMap.value}}
64
+          </option>
65
+        </select>
66
+        <div class="invalid-feedback">
67
+          <span *ngIf="projectForm.controls['employeeID'].errors?.['required']"
68
+            >required</span
69
+          >
70
+        </div>
71
+
72
+        <label for="companyID"> company</label>
73
+        <select formControlName="companyID" class="form-control">
74
+          <option
75
+            *ngFor="let companyMap of companiesMap | keyvalue" [ngValue]="companyMap.key"
76
+          >
77
+            {{companyMap.value}}
78
+          </option>
79
+        </select>
80
+        <div class="invalid-feedback">
81
+          <span *ngIf="projectForm.controls['projectState'].errors?.['required']"
82
+            >required</span
83
+          >
84
+        </div>
85
+
86
+        <div class="text-center mt-2">
87
+          <button
88
+            type="submit"
89
+            class="btn btn-outline-primary"
90
+          >
91
+            save
92
+          </button>
93
+        </div>
94
+      </form>
95
+
96
+    </div>
97
+  </div>
98
+
99
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-create/sub-compo-project-create.component.scss 查看文件


+ 85
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-create/sub-compo-project-create.component.ts 查看文件

@@ -0,0 +1,85 @@
1
+import { Company } from './../../../../shared/models/company/company.model';
2
+import { Employee } from './../../../../shared/models/employee/employee.model';
3
+import { ProjectState } from './../../../../shared/models/project/project.state';
4
+import { Priority } from './../../../../shared/models/project/project.priority';
5
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
6
+import { Component, OnInit } from '@angular/core';
7
+import { Project } from 'src/app/shared/models/project/project.model';
8
+import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
9
+import { EmployeeService } from 'src/app/shared/services/service-REST/employees.service';
10
+import { ProjectService } from 'src/app/shared/services/service-REST/projects.service';
11
+
12
+@Component({
13
+  selector: 'app-sub-compo-project-create',
14
+  templateUrl: './sub-compo-project-create.component.html',
15
+  styleUrls: ['./sub-compo-project-create.component.scss'],
16
+})
17
+export class SubCompoProjectCreateComponent implements OnInit {
18
+  projectForm!: FormGroup;
19
+
20
+  constructor(
21
+    private fBuilder: FormBuilder,
22
+    private employeeService: EmployeeService,
23
+    private companyService: CompanyService,
24
+    private projectService: ProjectService
25
+  ) {}
26
+
27
+  priorities = Priority;
28
+  states = ProjectState;
29
+
30
+  employees!: Array<Employee>;
31
+  employeesMap: Map<string, string> = new Map();
32
+  companies!: Array<Company>;
33
+  companiesMap: Map<string, string> = new Map();
34
+
35
+  ngOnInit(): void {
36
+    this.employeeService
37
+      .getAllEmployees()
38
+      .subscribe((data: Array<Employee>) => {
39
+        this.employees = data;
40
+        this.employees.forEach((employee: Employee) => {
41
+          this.employeesMap.set(
42
+            employee.employeeID,
43
+            employee.firstname +
44
+              ' ' +
45
+              employee.lastname +
46
+              ' email: ' +
47
+              employee.email
48
+          );
49
+        });
50
+      });
51
+
52
+    this.companyService.getAllCompanies().subscribe((data: Array<Company>) => {
53
+      this.companies = data;
54
+      this.companies.forEach((company: Company) => {
55
+        this.companiesMap.set(
56
+          company.companyID,
57
+          company.companyName +
58
+            ' ' +
59
+            company.agency
60
+        );
61
+      });
62
+    });
63
+
64
+    this.projectForm = this.fBuilder.group({
65
+      projectID: ['', Validators.required],
66
+      projectName: ['', [Validators.required, Validators.minLength(4)]],
67
+      description: ['', [Validators.required, Validators.minLength(10)]],
68
+      priority: ['', Validators.required],
69
+      projectState: ['', Validators.required],
70
+      employeeID: ['', Validators.required],
71
+      companyID: ['', Validators.required],
72
+    });
73
+  }
74
+
75
+  onSaveProjectForm() {
76
+    let project: Project = this.projectForm.value;
77
+    if (window.confirm('CONFIRM PROJECT CREATE')) {
78
+      this.projectService
79
+        .createProject(project)
80
+        .subscribe((newProject: Project) => {
81
+          console.log(newProject);
82
+        });
83
+    }
84
+  }
85
+}

+ 69
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component.html 查看文件

@@ -0,0 +1,69 @@
1
+<div class="container">
2
+  <p-table
3
+    [value]="projects"
4
+    responsiveLayout="scroll"
5
+    styleClass="p-datatable-striped"
6
+    *ngIf="projects"
7
+    [paginator]="true"
8
+    [rows]="5"
9
+    [showCurrentPageReport]="true"
10
+    currentPageReportTemplate="{first} - {last} of {totalRecords} entries"
11
+    [rowsPerPageOptions]="[5, 10, 15]"
12
+    class="p-3"
13
+  >
14
+    <ng-template pTemplate="header">
15
+      <tr>
16
+        <th>ID</th>
17
+        <th>project name</th>
18
+        <th>description</th>
19
+        <th>priority</th>
20
+        <th>state</th>
21
+        <th>user assigned</th>
22
+        <th>company related</th>
23
+        <th></th><th></th>
24
+      </tr>
25
+    </ng-template>
26
+
27
+    <ng-template pTemplate="body" let-project>
28
+      <tr>
29
+        <td>{{ project.projectID }}</td>
30
+        <td>{{ project.projectName }}</td>
31
+        <td>{{ project.description }}</td>
32
+        <td>{{ project.priority }}</td>
33
+        <td>{{ project.projectState }}</td>
34
+        <td>
35
+          <ul>
36
+            <li>User ID: {{project.employee.employeeID}}</li>
37
+            <li>{{ project.employee.firstname }} {{ project.employee.lastname }}</li>
38
+            <li>{{ project.employee.email }}</li>
39
+            <li>{{ project.employee.employeeType }}, {{ project.employee.employeeState }}</li>
40
+          </ul>
41
+        </td>
42
+        <td>
43
+          <ul>
44
+            <li>{{ project.company.companyName }} {{ project.company.agency }}</li>
45
+            <li>{{ project.company.companyType }}</li>
46
+          </ul>
47
+        </td>
48
+        <td>
49
+          <button class="btn">
50
+            <i
51
+              class="fa fa-pencil"
52
+              style="color: mediumturquoise"
53
+              (click)="onProjectUpdate(project)"
54
+            ></i>
55
+          </button>
56
+        </td>
57
+        <td>
58
+          <button class="btn">
59
+            <i
60
+              class="fa fa-trash"
61
+              style="color: red"
62
+              (click)="onProjectDelete(project.projectID)"
63
+            ></i>
64
+          </button>
65
+        </td>
66
+      </tr>
67
+    </ng-template>
68
+  </p-table>
69
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component.scss 查看文件


+ 46
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component.ts 查看文件

@@ -0,0 +1,46 @@
1
+import { Router } from '@angular/router';
2
+import { ProjectEventPublisher } from '../../../../shared/events-publisher/events.publisher';
3
+import { Component, Input, OnInit } from '@angular/core';
4
+import { Project } from 'src/app/shared/models/project/project.model';
5
+import { ProjectEvent } from 'src/app/shared/models/events.model';
6
+import { ProjectService } from 'src/app/shared/services/service-REST/projects.service';
7
+
8
+@Component({
9
+  selector: 'app-sub-compo-project-printer',
10
+  templateUrl: './sub-compo-project-printer.component.html',
11
+  styleUrls: ['./sub-compo-project-printer.component.scss']
12
+})
13
+export class SubCompoProjectPrinterComponent implements OnInit {
14
+
15
+  constructor(private projectService: ProjectService,
16
+    private projectEventPublisher: ProjectEventPublisher,
17
+    private router: Router) { }
18
+
19
+  @Input () projects!: Array<Project>;
20
+
21
+  ngOnInit(): void {
22
+    this.projectEventPublisher.projectEventObservable.subscribe((projectEvent: ProjectEvent)=>{
23
+      switch(projectEvent){
24
+        case ProjectEvent.UPDATE_PROJECT_FORM:
25
+          this.router.navigateByUrl('/project-update/'+this.projectID);
26
+          break;
27
+      }
28
+    })
29
+  }
30
+
31
+projectID!: string;
32
+onProjectUpdate(project: Project){
33
+  this.projectID = project.projectID;
34
+  this.projectEventPublisher.publishProjectEvent(ProjectEvent.UPDATE_PROJECT_FORM);
35
+}
36
+onProjectDelete(projectID: string){
37
+  if(window.confirm('COMFIRM PROJECT DELETE')){
38
+    this.projectService.deleteProject(projectID).subscribe(
39
+      ()=>{
40
+        this.projectEventPublisher.publishProjectEvent(ProjectEvent.REFRESH);
41
+      }
42
+    );
43
+  }
44
+}
45
+
46
+}

+ 97
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/subcompo-project-update/subcompo-project-update.component.html 查看文件

@@ -0,0 +1,97 @@
1
+<div class="container mt-3">
2
+  <div class="card">
3
+    <div class="card-header">Project info</div>
4
+    <div class="card-body">
5
+
6
+      <form [formGroup]="projectForm" (ngSubmit)="onSaveProjectForm(); projectForm.reset()">
7
+        <label for="projectName">project name</label>
8
+        <input type="text" class="form-control" formControlName="projectName"
9
+        [ngClass]="{'is-invalid': projectForm.controls['projectName'].touched && projectForm.controls['projectName'].invalid}">
10
+
11
+
12
+        <div class="invalid-feedback">
13
+          <span *ngIf="projectForm.controls['projectName'].errors?.['required']"
14
+            >required</span
15
+          >
16
+        </div>
17
+
18
+        <label for="description"> description</label>
19
+        <input type="text" class="form-control" formControlName="description"
20
+        [ngClass]="{'is-invalid': projectForm.controls['description'].touched && projectForm.controls['description'].invalid}">
21
+
22
+        <div class="invalid-feedback">
23
+          <span *ngIf="projectForm.controls['description'].errors?.['required']"
24
+            >required</span
25
+          >
26
+          <span *ngIf="projectForm.controls['description'].errors?.['minlength']"
27
+          >very short description</span
28
+        >
29
+        </div>
30
+
31
+        <label for="priority">priority</label>
32
+        <select class="form-control" formControlName="priority">
33
+          <option *ngFor="let priority of priorities | keyvalue" [ngValue]="priority.value">
34
+              {{ priority.value }}
35
+          </option>
36
+        </select>
37
+       <div class="invalid-feedback">
38
+        <span *ngIf="projectForm.controls['priority'].errors?.['required']">required</span>
39
+       </div>
40
+        <label for="projectState">project state</label>
41
+        <select
42
+        class="form-control" formControlName="projectState">
43
+        <option
44
+          *ngFor="let state of states | keyvalue"
45
+          [ngValue]="state.value"
46
+        >
47
+          {{ state.value }}
48
+        </option>
49
+        </select>
50
+
51
+        <div class="invalid-feedback">
52
+          <span *ngIf="projectForm.controls['projectState'].errors?.['required']"
53
+            >required</span
54
+          >
55
+        </div>
56
+
57
+        <label for="employeeID"> employee</label>
58
+        <select formControlName="employeeID" class="form-control">
59
+          <option
60
+            *ngFor="let employeeMap of employeesMap | keyvalue" [ngValue]="employeeMap.key"
61
+          >
62
+            {{employeeMap.value}}
63
+          </option>
64
+        </select>
65
+        <div class="invalid-feedback">
66
+          <span *ngIf="projectForm.controls['employeeID'].errors?.['required']"
67
+            >required</span
68
+          >
69
+        </div>
70
+
71
+        <label for="companyID"> company</label>
72
+        <select formControlName="companyID" class="form-control">
73
+          <option
74
+            *ngFor="let companyMap of companiesMap | keyvalue" [ngValue]="companyMap.key" disabled
75
+          >
76
+            {{companyMap.value}}
77
+          </option>
78
+        </select>
79
+        <div class="invalid-feedback">
80
+          <span *ngIf="projectForm.controls['projectState'].errors?.['required']"
81
+            >required</span
82
+          >
83
+        </div>
84
+
85
+        <div class="text-center mt-2">
86
+          <button
87
+            type="submit"
88
+            class="btn btn-outline-primary"
89
+          >
90
+            save
91
+          </button>
92
+        </div>
93
+      </form>
94
+
95
+    </div>
96
+  </div>
97
+</div>

+ 0
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/subcompo-project-update/subcompo-project-update.component.scss 查看文件


+ 90
- 0
angular-project-front/src/app/pages/module-project-manager/compo-project-manager/subcompo-project-update/subcompo-project-update.component.ts 查看文件

@@ -0,0 +1,90 @@
1
+import { CompanyService } from 'src/app/shared/services/service-REST/companies.service';
2
+import { Project } from './../../../../shared/models/project/project.model';
3
+import { ActivatedRoute } from '@angular/router';
4
+import { Component, OnInit } from '@angular/core';
5
+import { FormGroup, FormBuilder, Validators } from '@angular/forms';
6
+import { Company } from 'src/app/shared/models/company/company.model';
7
+import { Employee } from 'src/app/shared/models/employee/employee.model';
8
+import { Priority } from 'src/app/shared/models/project/project.priority';
9
+import { ProjectState } from 'src/app/shared/models/project/project.state';
10
+import { EmployeeService } from 'src/app/shared/services/service-REST/employees.service';
11
+import { ProjectService } from 'src/app/shared/services/service-REST/projects.service';
12
+
13
+
14
+@Component({
15
+  selector: 'app-subcompo-project-update',
16
+  templateUrl: './subcompo-project-update.component.html',
17
+  styleUrls: ['./subcompo-project-update.component.scss']
18
+})
19
+export class SubcompoProjectUpdateComponent implements OnInit {
20
+
21
+  projectForm!: FormGroup;
22
+
23
+  constructor(private fBuilder: FormBuilder,private employeeService: EmployeeService,
24
+    private companyService: CompanyService, private activatedRoute: ActivatedRoute,
25
+    private projectService: ProjectService) {}
26
+
27
+  priorities = Priority;
28
+  states = ProjectState;
29
+
30
+  employees!: Array<Employee>;
31
+  employeesMap:Map<string, string> = new Map();
32
+  companies!: Array<Company>
33
+  companiesMap:Map<string, string> = new Map();
34
+  project!: Project;
35
+
36
+  ngOnInit(): void {
37
+    this.employeeService
38
+    .getAllEmployees()
39
+    .subscribe((data: Array<Employee>) => {
40
+      this.employees = data;
41
+      this.employees.forEach((employee: Employee) => {
42
+        this.employeesMap.set(
43
+          employee.employeeID,
44
+          employee.firstname +
45
+            ' ' +
46
+            employee.lastname +
47
+            ' email: ' +
48
+            employee.email
49
+        );
50
+      });
51
+    });
52
+
53
+    this.companyService.getAllCompanies().subscribe((data: Array<Company>) => {
54
+      this.companies = data;
55
+      this.companies.forEach((company: Company) => {
56
+        this.companiesMap.set(
57
+          company.companyID,
58
+          company.companyName +
59
+            ' ' +
60
+            company.agency
61
+        );
62
+      });
63
+    });
64
+
65
+    this.activatedRoute.data.subscribe(data=>{
66
+      let project: Project = data['getProjectByIDResolve'];
67
+      console.log(project);
68
+
69
+      this.projectForm = this.fBuilder.group({
70
+        projectID: [project.projectID, Validators.required],
71
+        projectName: [project.projectName, [Validators.required, Validators.minLength(4)]],
72
+        description: [project.description, [Validators.required, Validators.minLength(10)]],
73
+        priority: [project.priority, Validators.required],
74
+        projectState: [project.projectState, Validators.required],
75
+        employeeID: [project.employeeID, Validators.required],
76
+        companyID: [project.companyID, Validators.required],
77
+      });
78
+
79
+    });
80
+  }
81
+
82
+  onSaveProjectForm(){
83
+    if(window.confirm("CONFIRM PROJECT UPDATE")){
84
+      this.projectService.updateProject(this.projectForm.value).subscribe((newProject: Project)=>{
85
+        console.log(newProject);
86
+      })
87
+    }
88
+  }
89
+
90
+}

+ 33
- 0
angular-project-front/src/app/pages/module-project-manager/module-project-manager-routing.module.ts 查看文件

@@ -0,0 +1,33 @@
1
+import { SubcompoProjectUpdateComponent } from './compo-project-manager/subcompo-project-update/subcompo-project-update.component';
2
+import { SubCompoProjectCreateComponent } from './compo-project-manager/sub-compo-project-create/sub-compo-project-create.component';
3
+import { CompoProjectManagerComponent } from './compo-project-manager/compo-project-manager.component';
4
+import { NgModule } from '@angular/core';
5
+import { RouterModule, Routes } from '@angular/router';
6
+import { GetAllProjectsResolve, GetProjectByIDResolve } from 'src/app/shared/services/service-route-resolve/project-resolve/route.resolve';
7
+
8
+const routes: Routes = [
9
+  {
10
+    path:'projects-management',
11
+    component: CompoProjectManagerComponent,
12
+    resolve:{
13
+      getAllProjectsResolve: GetAllProjectsResolve
14
+    }
15
+  },
16
+  {
17
+    path:'project-create',
18
+    component: SubCompoProjectCreateComponent
19
+  },
20
+  {
21
+    path:'project-update/:projectID',
22
+    component: SubcompoProjectUpdateComponent,
23
+    resolve:{
24
+      getProjectByIDResolve:GetProjectByIDResolve
25
+    }
26
+  }
27
+];
28
+
29
+@NgModule({
30
+  imports: [RouterModule.forChild(routes)],
31
+  exports: [RouterModule]
32
+})
33
+export class ModuleProjectManagerRoutingModule { }

+ 28
- 0
angular-project-front/src/app/pages/module-project-manager/module-project-manager.module.ts 查看文件

@@ -0,0 +1,28 @@
1
+import { GetEmployeeByIDResolve } from 'src/app/shared/services/service-route-resolve/employee-resolve/employee.route.resolve';
2
+import { ReactiveFormsModule } from '@angular/forms';
3
+import { TableModule } from 'primeng/table';
4
+import { NgModule } from '@angular/core';
5
+import { CommonModule } from '@angular/common';
6
+
7
+import { ModuleProjectManagerRoutingModule } from './module-project-manager-routing.module';
8
+import { CompoProjectManagerComponent } from './compo-project-manager/compo-project-manager.component';
9
+import { SubCompoProjectPrinterComponent } from './compo-project-manager/sub-compo-project-printer/sub-compo-project-printer.component';
10
+import { SubCompoProjectCreateComponent } from './compo-project-manager/sub-compo-project-create/sub-compo-project-create.component';
11
+import { SubcompoProjectUpdateComponent } from './compo-project-manager/subcompo-project-update/subcompo-project-update.component';
12
+
13
+
14
+@NgModule({
15
+  declarations: [
16
+    CompoProjectManagerComponent,
17
+    SubCompoProjectPrinterComponent,
18
+    SubCompoProjectCreateComponent,
19
+    SubcompoProjectUpdateComponent
20
+  ],
21
+  imports: [
22
+    CommonModule,
23
+    ModuleProjectManagerRoutingModule,
24
+    TableModule,
25
+    ReactiveFormsModule
26
+  ],
27
+})
28
+export class ModuleProjectManagerModule { }

+ 43
- 0
angular-project-front/src/app/shared/events-publisher/events.publisher.ts 查看文件

@@ -0,0 +1,43 @@
1
+import { ProjectEvent } from '../models/events.model';
2
+import { EmployeeEvent, AddressEvent, CompanyEvent } from '../models/events.model';
3
+import { Injectable } from "@angular/core";
4
+import { Observable, Subject } from "rxjs";
5
+
6
+@Injectable({providedIn:"root"})
7
+export class EmployeeEventPublisher {
8
+
9
+  private employeeEventSubject: Subject<EmployeeEvent> = new Subject<EmployeeEvent>();
10
+  employeeEnventObservable: Observable<EmployeeEvent> = this.employeeEventSubject.asObservable();
11
+
12
+  publishEmployeeEvent(employeeEvent: EmployeeEvent){
13
+    this.employeeEventSubject.next(employeeEvent);
14
+  }
15
+}
16
+
17
+@Injectable({providedIn: "root"})
18
+export class AddressEventPublisher {
19
+
20
+  addressEventSubject: Subject<AddressEvent> = new Subject<AddressEvent>();
21
+  addressEventObservable: Observable<AddressEvent> = this.addressEventSubject.asObservable();
22
+  publishAddressEvent(addressEvent: AddressEvent){
23
+    this.addressEventSubject.next(addressEvent);
24
+  }
25
+}
26
+
27
+@Injectable({providedIn:'root'})
28
+export class CompanyEventPublisher {
29
+  companyEventSubject: Subject<CompanyEvent> = new Subject<CompanyEvent>();
30
+  companyEventObservable: Observable<CompanyEvent> = this.companyEventSubject.asObservable();
31
+  publishCompanyEvent(companyEvent: CompanyEvent){
32
+    this.companyEventSubject.next(companyEvent);
33
+  }
34
+}
35
+
36
+@Injectable({providedIn:'root'})
37
+export class ProjectEventPublisher {
38
+  projectEventSubject : Subject<ProjectEvent> = new Subject<ProjectEvent>();
39
+  projectEventObservable: Observable<ProjectEvent> = this.projectEventSubject.asObservable();
40
+  publishProjectEvent(projectEvent: ProjectEvent){
41
+    this.projectEventSubject.next(projectEvent);
42
+  }
43
+}

+ 8
- 0
angular-project-front/src/app/shared/models/address/address.model.ts 查看文件

@@ -0,0 +1,8 @@
1
+export class Address {
2
+  addressID!: number;
3
+  num!: number;
4
+  street!: string;
5
+  pb!: number;
6
+  city!: string;
7
+  country!: string;
8
+}

+ 9
- 0
angular-project-front/src/app/shared/models/company/company.model.ts 查看文件

@@ -0,0 +1,9 @@
1
+import { CompanyType } from "./company.type";
2
+
3
+export class Company {
4
+  companyID!: string;
5
+  companyName!: string;
6
+  agency!: string;
7
+  companyType!: CompanyType;
8
+  connectedDate!: Date;
9
+}

+ 4
- 0
angular-project-front/src/app/shared/models/company/company.type.ts 查看文件

@@ -0,0 +1,4 @@
1
+export enum CompanyType {
2
+  CLIENT ="CLIENT",
3
+  PROSPECT="PROSPECT"
4
+}

+ 13
- 0
angular-project-front/src/app/shared/models/employee/employee.model.ts 查看文件

@@ -0,0 +1,13 @@
1
+import { EmployeeType } from './employee.type';
2
+import { EmployeeState } from './employee.state';
3
+
4
+export class Employee {
5
+  employeeID!: string;
6
+  firstname!:string;
7
+  lastname!: string;
8
+  email!: string;
9
+  hireDate!: Date;
10
+  employeeState!: EmployeeState
11
+  employeeType!: EmployeeType
12
+  addressID!: string
13
+}

+ 4
- 0
angular-project-front/src/app/shared/models/employee/employee.state.ts 查看文件

@@ -0,0 +1,4 @@
1
+export enum EmployeeState {
2
+  ACTIVE ="ACTIVE",
3
+  HISTORIZED = "HISTORIZED"
4
+}

+ 0
- 0
angular-project-front/src/app/shared/models/employee/employee.type.ts 查看文件


部分文件因为文件数量过多而无法显示

Powered by TurnKey Linux.