From 9c08231d63a2f8dea36a557f1adb0ef9af2e7764 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 12 Oct 2020 22:31:43 +0200 Subject: [PATCH 01/25] Recovered replacements --- .../resources/archetype-resources/package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/archetype-resources/package.json b/src/main/resources/archetype-resources/package.json index 9d49271..5e90830 100644 --- a/src/main/resources/archetype-resources/package.json +++ b/src/main/resources/archetype-resources/package.json @@ -1,19 +1,19 @@ { - "name": "test", - "version": "0.0.1-SNAPSHOT", - "description": "A Spring MVC project using React+Redux for the views.", - "author": "Bernardo Martínez Garrido", - "homepage": "https://github.com/bernardo-mg/test", + "name": "${artifactId}", + "version": "${version}", + "description": "${projectDescription}", + "author": "${developerName}", + "homepage": "https://github.com/${repoUserId}/${artifactId}", "license": "MIT", "keywords": [ - "keywords" + ${keywords} ], "repository": { "type": "git", - "url": "git@github.com:bernardo-mg/test.git" + "url": "git@github.com:${repoUserId}/${artifactId}.git" }, "bugs": { - "url": "https://www.github.com/bernardo-mg/test/issues" + "url": "https://www.github.com/${repoUserId}/${artifactId}/issues" }, "scripts": { "ng": "ng", From 844c5be5031e6f2eead22268741fd47b77e89cef Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 12 Oct 2020 22:38:21 +0200 Subject: [PATCH 02/25] Registered files --- .../META-INF/maven/archetype-metadata.xml | 12 ++++++++---- .../resources/archetype-resources/angular.json | 18 +++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml index e2a0a1f..1870f66 100644 --- a/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -166,6 +166,7 @@ + angular.json package.json @@ -173,10 +174,13 @@ - webpack.*.js - .babelrc - .eslintrc - .nvmrc + .browserslistrc + .editorconfig + tsconfig.app.json + tsconfig.base.json + tsconfig.json + tsconfig.spec.json + tslint.json diff --git a/src/main/resources/archetype-resources/angular.json b/src/main/resources/archetype-resources/angular.json index f9df31f..81ef513 100644 --- a/src/main/resources/archetype-resources/angular.json +++ b/src/main/resources/archetype-resources/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "dnd5-api-angular-client": { + "${artifactId}": { "projectType": "application", "schematics": { "@schematics/angular:component": { @@ -66,18 +66,18 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "dnd5-api-angular-client:build" + "browserTarget": "${artifactId}:build" }, "configurations": { "production": { - "browserTarget": "dnd5-api-angular-client:build:production" + "browserTarget": "${artifactId}:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "dnd5-api-angular-client:build" + "browserTarget": "${artifactId}:build" } }, "test": { @@ -98,7 +98,7 @@ }, "configurations": { "production": { - "devServerTarget": "dnd5-api-angular-client:serve:production" + "devServerTarget": "${artifactId}:serve:production" }, "ci": { "watch": false, @@ -124,14 +124,14 @@ "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "src/main/js/e2e/protractor.conf.js", - "devServerTarget": "dnd5-api-angular-client:serve" + "devServerTarget": "${artifactId}:serve" }, "configurations": { "production": { - "devServerTarget": "dnd5-api-angular-client:serve:production" + "devServerTarget": "${artifactId}:serve:production" }, "ci": { - "devServerTarget": "dnd5-api-angular-client:serve:production", + "devServerTarget": "${artifactId}:serve:production", "protractorConfig": "src/main/js/e2e/protractor-ci.conf.js" } } @@ -139,5 +139,5 @@ } } }, - "defaultProject": "dnd5-api-angular-client" + "defaultProject": "${artifactId}" } \ No newline at end of file From 85d5a164a390ec0ca5b95cdcfa2124d95fcc36de Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 12 Oct 2020 22:49:31 +0200 Subject: [PATCH 03/25] Registered more files --- src/main/resources/META-INF/maven/archetype-metadata.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml index 1870f66..26ba429 100644 --- a/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -57,8 +57,11 @@ src/main/js **/*.js - **/*.scss **/*.json + **/*.sass + **/*.ts + **/*.html + **/*.gitkeep From 33081739eb30c2dabeead6fd67c3fbc492e1daf5 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 12 Oct 2020 22:55:11 +0200 Subject: [PATCH 04/25] Registered file --- src/main/resources/META-INF/maven/archetype-metadata.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml index 26ba429..bf3efe9 100644 --- a/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -179,6 +179,7 @@ .browserslistrc .editorconfig + karma.conf.js tsconfig.app.json tsconfig.base.json tsconfig.json From ddd6b081761d5746846f21af0a41882db0bbba1b Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 12 Oct 2020 23:09:21 +0200 Subject: [PATCH 05/25] Chrome update --- .github/workflows/testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index dc3e150..4edd50b 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,5 +17,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }} + - name: Update Chrome + run: sudo apt-get update + run: sudo apt-get upgrade google-chrome-stable -y - name: Run all tests run: mvn clean verify From 632c0f01ac91551ca41def392bf4411906bb11b9 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 18:28:53 +0200 Subject: [PATCH 06/25] Corrected index --- .../src/main/resources/static/css/index.css | 13 ------------- .../src/main/resources/templates/index.html | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 21 deletions(-) delete mode 100644 src/main/resources/archetype-resources/src/main/resources/static/css/index.css diff --git a/src/main/resources/archetype-resources/src/main/resources/static/css/index.css b/src/main/resources/archetype-resources/src/main/resources/static/css/index.css deleted file mode 100644 index 603d126..0000000 --- a/src/main/resources/archetype-resources/src/main/resources/static/css/index.css +++ /dev/null @@ -1,13 +0,0 @@ -.loader { - border: 16px solid #f3f3f3; /* Light grey */ - border-top: 16px solid #3498db; /* Blue */ - border-radius: 50%; - width: 120px; - height: 120px; - animation: spin 2s linear infinite; -} - -@keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } -} diff --git a/src/main/resources/archetype-resources/src/main/resources/templates/index.html b/src/main/resources/archetype-resources/src/main/resources/templates/index.html index 034c909..bf116de 100644 --- a/src/main/resources/archetype-resources/src/main/resources/templates/index.html +++ b/src/main/resources/archetype-resources/src/main/resources/templates/index.html @@ -6,6 +6,9 @@ @project.name@ + + + @@ -25,20 +28,19 @@ - + - + -
-
-
- - - + + + + + \ No newline at end of file From acbc3a932b625e4b76fb0a06b6aff1636849e281 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 18:40:24 +0200 Subject: [PATCH 07/25] Corrected workflow --- .github/workflows/testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 4edd50b..d1b21f5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,8 +17,9 @@ jobs: uses: actions/setup-java@v1 with: java-version: ${{ matrix.jdk }} - - name: Update Chrome + - name: Update apt-get run: sudo apt-get update + - name: Update Chrome run: sudo apt-get upgrade google-chrome-stable -y - name: Run all tests run: mvn clean verify From fc277fc924678b42865cbd258743119b7a2df243 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 19:05:08 +0200 Subject: [PATCH 08/25] Organized files --- .../archetype-resources/{ => src/main/js}/tsconfig.app.json | 0 .../archetype-resources/{ => src/main/js}/tsconfig.base.json | 0 .../resources/archetype-resources/{ => src/main/js}/tsconfig.json | 0 .../archetype-resources/{ => src/main/js}/tsconfig.spec.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/archetype-resources/{ => src/main/js}/tsconfig.app.json (100%) rename src/main/resources/archetype-resources/{ => src/main/js}/tsconfig.base.json (100%) rename src/main/resources/archetype-resources/{ => src/main/js}/tsconfig.json (100%) rename src/main/resources/archetype-resources/{ => src/main/js}/tsconfig.spec.json (100%) diff --git a/src/main/resources/archetype-resources/tsconfig.app.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.app.json similarity index 100% rename from src/main/resources/archetype-resources/tsconfig.app.json rename to src/main/resources/archetype-resources/src/main/js/tsconfig.app.json diff --git a/src/main/resources/archetype-resources/tsconfig.base.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.base.json similarity index 100% rename from src/main/resources/archetype-resources/tsconfig.base.json rename to src/main/resources/archetype-resources/src/main/js/tsconfig.base.json diff --git a/src/main/resources/archetype-resources/tsconfig.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.json similarity index 100% rename from src/main/resources/archetype-resources/tsconfig.json rename to src/main/resources/archetype-resources/src/main/js/tsconfig.json diff --git a/src/main/resources/archetype-resources/tsconfig.spec.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json similarity index 100% rename from src/main/resources/archetype-resources/tsconfig.spec.json rename to src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json From 593c63f4e56d6af2d90f2b5abd21ee031757c31d Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 19:47:06 +0200 Subject: [PATCH 09/25] Relocated files --- src/main/resources/archetype-resources/angular.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/archetype-resources/angular.json b/src/main/resources/archetype-resources/angular.json index 81ef513..e33b0cd 100644 --- a/src/main/resources/archetype-resources/angular.json +++ b/src/main/resources/archetype-resources/angular.json @@ -21,7 +21,7 @@ "index": "src/main/js/index.html", "main": "src/main/js/main.ts", "polyfills": "src/main/js/polyfills.ts", - "tsConfig": "tsconfig.app.json", + "tsConfig": "src/main/js/tsconfig.app.json", "aot": true, "assets": [ "src/main/js/assets" @@ -111,8 +111,8 @@ "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ - "tsconfig.app.json", - "tsconfig.spec.json", + "src/main/js/tsconfig.app.json", + "src/main/js/tsconfig.spec.json", "src/main/js/e2e/tsconfig.json" ], "exclude": [ From 296c1b3412d1d5231185fe5e4aa383a20781b00d Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 20:24:32 +0200 Subject: [PATCH 10/25] Relocated files --- src/main/resources/archetype-resources/angular.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/archetype-resources/angular.json b/src/main/resources/archetype-resources/angular.json index e33b0cd..3bc1628 100644 --- a/src/main/resources/archetype-resources/angular.json +++ b/src/main/resources/archetype-resources/angular.json @@ -10,8 +10,8 @@ "style": "sass" } }, - "root": "", - "sourceRoot": "src/main/js", + "root": "src/main/js", + "sourceRoot": ".", "prefix": "app", "architect": { "build": { From 9044f677dee875c4fd85fb45a2a8ede55410e91d Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 22:46:34 +0200 Subject: [PATCH 11/25] Changed paths --- src/main/resources/META-INF/maven/archetype-metadata.xml | 4 ---- src/main/resources/archetype-resources/angular.json | 2 +- .../archetype-resources/src/main/js/tsconfig.spec.json | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml index bf3efe9..5695134 100644 --- a/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -180,10 +180,6 @@ .browserslistrc .editorconfig karma.conf.js - tsconfig.app.json - tsconfig.base.json - tsconfig.json - tsconfig.spec.json tslint.json
diff --git a/src/main/resources/archetype-resources/angular.json b/src/main/resources/archetype-resources/angular.json index 3bc1628..41f3eea 100644 --- a/src/main/resources/archetype-resources/angular.json +++ b/src/main/resources/archetype-resources/angular.json @@ -85,7 +85,7 @@ "options": { "main": "src/main/js/test.ts", "polyfills": "src/main/js/polyfills.ts", - "tsConfig": "tsconfig.spec.json", + "tsConfig": "src/main/js/tsconfig.spec.json", "karmaConfig": "karma.conf.js", "assets": [ "src/main/js/assets" diff --git a/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json index ccf0604..5540ed4 100644 --- a/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json +++ b/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json @@ -8,8 +8,8 @@ ] }, "files": [ - "src/main/js/test.ts", - "src/main/js/polyfills.ts" + "test.ts", + "polyfills.ts" ], "include": [ "src/main/js/**/*.spec.ts", From c66e358771511617bf43b268738fbd0d96ece662 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 22:51:04 +0200 Subject: [PATCH 12/25] Corrrected paths --- .../archetype-resources/src/main/js/tsconfig.spec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json index 5540ed4..3305892 100644 --- a/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json +++ b/src/main/resources/archetype-resources/src/main/js/tsconfig.spec.json @@ -12,7 +12,7 @@ "polyfills.ts" ], "include": [ - "src/main/js/**/*.spec.ts", - "src/main/js/**/*.d.ts" + "**/*.spec.ts", + "**/*.d.ts" ] } From a837b1bde23a2f47488a8a0a484d772ac0036635 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 18 Oct 2020 23:07:53 +0200 Subject: [PATCH 13/25] Corrrected paths --- .../archetype-resources/src/main/js/tsconfig.app.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/archetype-resources/src/main/js/tsconfig.app.json b/src/main/resources/archetype-resources/src/main/js/tsconfig.app.json index 9ac4d92..14d3bb9 100644 --- a/src/main/resources/archetype-resources/src/main/js/tsconfig.app.json +++ b/src/main/resources/archetype-resources/src/main/js/tsconfig.app.json @@ -6,10 +6,10 @@ "types": [] }, "files": [ - "src/main/js/main.ts", - "src/main/js/polyfills.ts" + "main.ts", + "polyfills.ts" ], "include": [ - "src/main/js/**/*.d.ts" + "**/*.d.ts" ] } From 5e16ce9e13b436be42856440b9bd95bc506eb225 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 25 Oct 2020 18:02:45 +0100 Subject: [PATCH 14/25] Data is loaded into the view --- .../src/main/js/app/api-page.ts | 11 ++++++ .../src/main/js/app/api-response.ts | 6 ++- .../src/main/js/app/app-routing.module.ts | 7 ++-- .../src/main/js/app/app.module.ts | 8 ++-- .../charclass-detail.component.html | 13 ------- .../charclass-detail.component.sass | 0 .../charclass-detail.component.spec.ts | 29 --------------- .../charclass-detail.component.ts | 37 ------------------- .../charclass-list.component.html | 8 ---- .../charclass-list.component.spec.ts | 28 -------------- .../charclass-list.component.ts | 24 ------------ .../charclass/charclass.component.html | 8 ---- .../charclass/charclass.component.sass | 2 - .../charclass/charclass.component.ts | 12 ------ .../src/main/js/app/charclass.ts | 17 --------- .../data-list/data-list.component.html | 8 ++++ .../data-list/data-list.component.sass} | 0 .../data-list/data-list.component.spec.ts} | 12 +++--- .../data-list/data-list.component.ts | 24 ++++++++++++ .../data-view.module.ts} | 14 ++----- ...s.service.spec.ts => data.service.spec.ts} | 8 ++-- .../{charclass.service.ts => data.service.ts} | 21 ++++------- .../src/main/js/app/data.ts | 5 +++ .../app/navigation/navigation.component.html | 2 +- .../src/main/js/app/proficiency-choice.ts | 7 ---- .../src/main/js/app/proficiency.ts | 4 -- .../src/main/js/app/saving-throw.ts | 4 -- .../src/main/js/app/subclass.ts | 4 -- 28 files changed, 83 insertions(+), 240 deletions(-) create mode 100644 src/main/resources/archetype-resources/src/main/js/app/api-page.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.html delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.sass delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.spec.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.html delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.spec.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.html delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.sass delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/charclass.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html rename src/main/resources/archetype-resources/src/main/js/app/{charclass-view/charclass-list/charclass-list.component.sass => data-view/data-list/data-list.component.sass} (100%) rename src/main/resources/archetype-resources/src/main/js/app/{charclass-view/charclass/charclass.component.spec.ts => data-view/data-list/data-list.component.spec.ts} (60%) create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts rename src/main/resources/archetype-resources/src/main/js/app/{charclass-view/charclass-view.module.ts => data-view/data-view.module.ts} (52%) rename src/main/resources/archetype-resources/src/main/js/app/{charclass.service.spec.ts => data.service.spec.ts} (62%) rename src/main/resources/archetype-resources/src/main/js/app/{charclass.service.ts => data.service.ts} (57%) create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/proficiency-choice.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/proficiency.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/saving-throw.ts delete mode 100644 src/main/resources/archetype-resources/src/main/js/app/subclass.ts diff --git a/src/main/resources/archetype-resources/src/main/js/app/api-page.ts b/src/main/resources/archetype-resources/src/main/js/app/api-page.ts new file mode 100644 index 0000000..de3a803 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/api-page.ts @@ -0,0 +1,11 @@ +export interface ApiPage { + content: T; + empty: boolean; + first: boolean; + last: boolean; + number: number; + numberOfElements: number; + size: number; + totalElements: number; + totalPages: number; +} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/api-response.ts b/src/main/resources/archetype-resources/src/main/js/app/api-response.ts index 25095b6..b1740b1 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/api-response.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/api-response.ts @@ -1,4 +1,6 @@ +import { ApiPage } from './api-page'; + export interface ApiResponse { - count: number; - results: T; + content: ApiPage; + status: T; } \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts index 984d9b3..1ec94f4 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts @@ -1,11 +1,10 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { CharclassComponent } from './charclass-view/charclass/charclass.component'; +import { DataListComponent } from './data-view/data-list/data-list.component'; const routes: Routes = [ - { path: '', redirectTo: '/classes', pathMatch: 'full' }, - { path: 'classes', redirectTo: 'classes/', pathMatch: 'full' }, - { path: 'classes/:id', component: CharclassComponent } + { path: '', redirectTo: '/data', pathMatch: 'full' }, + { path: 'data', component: DataListComponent } ]; @NgModule({ diff --git a/src/main/resources/archetype-resources/src/main/js/app/app.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app.module.ts index 4848cf3..36b4143 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app.module.ts @@ -6,13 +6,14 @@ import { LayoutModule } from '@angular/cdk/layout'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; +import { MatListModule } from '@angular/material/list'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatToolbarModule } from '@angular/material/toolbar'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; -import { CharclassViewModule } from './charclass-view/charclass-view.module'; import { NavigationComponent } from './navigation/navigation.component'; +import { DataViewModule } from './data-view/data-view.module'; @NgModule({ declarations: [ @@ -25,11 +26,12 @@ import { NavigationComponent } from './navigation/navigation.component'; HttpClientModule, BrowserAnimationsModule, LayoutModule, - CharclassViewModule, MatButtonModule, MatIconModule, + MatListModule, MatSidenavModule, - MatToolbarModule + MatToolbarModule, + DataViewModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.html b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.html deleted file mode 100644 index 3905abb..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
-

{{charclass.name}}

-
hit_die: {{charclass.hit_die}}
-
sub_classes: {{asList(charclass.subclasses).join(', ')}}
-

proficiencies

-
saving_throws: {{asList(charclass.saving_throws).join(', ')}}
-
proficiencies: {{asList(charclass.proficiencies).join(', ')}}
-

picks

-
-
pick {{choice.choose}} of {{asList(choice.from).join(', ')}}
- -
-
\ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.sass b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.sass deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.spec.ts deleted file mode 100644 index e938804..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AppRoutingModule } from '../../app-routing.module'; -import { HttpClientModule } from '@angular/common/http'; - -import { CharclassDetailComponent } from './charclass-detail.component'; - -describe('CharclassDetailComponent', () => { - let component: CharclassDetailComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [AppRoutingModule, HttpClientModule], - declarations: [ CharclassDetailComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CharclassDetailComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.ts b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.ts deleted file mode 100644 index e96ac34..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-detail/charclass-detail.component.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { Charclass } from '../../charclass'; -import { ActivatedRoute } from '@angular/router'; -import { CharclassService } from '../../charclass.service'; - -@Component({ - selector: 'app-charclass-detail', - templateUrl: './charclass-detail.component.html', - styleUrls: ['./charclass-detail.component.sass'] -}) -export class CharclassDetailComponent implements OnInit { - - @Input() charclass: Charclass; - - constructor( - private route: ActivatedRoute, - private charclassService: CharclassService - ) { } - - ngOnInit(): void { - this.route.params.subscribe(params => { - this.getCharClass(params['id']); - }); - } - - getCharClass(id: string): void { - if (id) { - this.charclassService.getCharClass(id) - .subscribe(charclass => this.charclass = charclass); - } - } - - asList(data: any[]) { - return data.map(obj => obj.name); - } - -} diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.html b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.html deleted file mode 100644 index 6c70161..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - {{charclass.name}} - - - - \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.spec.ts deleted file mode 100644 index ced3e8a..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HttpClientModule } from '@angular/common/http'; - -import { CharclassListComponent } from './charclass-list.component'; - -describe('CharclassComponent', () => { - let component: CharclassListComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [HttpClientModule], - declarations: [ CharclassListComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CharclassListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.ts b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.ts deleted file mode 100644 index f27e7a1..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Charclass } from '../../charclass'; -import { CharclassService } from '../../charclass.service'; - -@Component({ - selector: 'app-charclass-list', - templateUrl: './charclass-list.component.html', - styleUrls: ['./charclass-list.component.sass'] -}) -export class CharclassListComponent implements OnInit { - - charclasses: Charclass[]; - - constructor(private charclassService: CharclassService) { } - - ngOnInit(): void { - this.getCharClasses(); - } - - getCharClasses(): void { - this.charclassService.getCharClasses().subscribe(charclasses => this.charclasses = charclasses); - } - -} diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.html b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.html deleted file mode 100644 index db055bf..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
- -
-
- -
-
\ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.sass b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.sass deleted file mode 100644 index 72b96f5..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.sass +++ /dev/null @@ -1,2 +0,0 @@ -.selection-item:hover - font-weight: bold \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.ts b/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.ts deleted file mode 100644 index 2a4780d..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Charclass } from '../../charclass'; -import { CharclassService } from '../../charclass.service'; - -@Component({ - selector: 'app-charclass', - templateUrl: './charclass.component.html', - styleUrls: ['./charclass.component.sass'] -}) -export class CharclassComponent { - -} diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass.ts b/src/main/resources/archetype-resources/src/main/js/app/charclass.ts deleted file mode 100644 index 73135bf..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Proficiency } from './proficiency'; -import { ProficiencyChoice } from './proficiency-choice'; -import { SavingThrow } from './saving-throw'; -import { Subclass } from './subclass'; - -export interface Charclass { - index: string; - name: string; - hit_die: number; - proficiency_choices: ProficiencyChoice[]; - proficiencies: Proficiency[]; - saving_throws: SavingThrow[]; - starting_equipment: any; - class_levels: any; - subclasses: Subclass[]; - url: string; -} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html new file mode 100644 index 0000000..453bc97 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html @@ -0,0 +1,8 @@ + + + + {{data.name}} + + + + \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.sass b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.sass similarity index 100% rename from src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-list/charclass-list.component.sass rename to src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.sass diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.spec.ts similarity index 60% rename from src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.spec.ts rename to src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.spec.ts index f1915a5..97bdb65 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass/charclass.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.spec.ts @@ -2,22 +2,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpClientModule } from '@angular/common/http'; -import { CharclassComponent } from './charclass.component'; +import { DataListComponent } from './data-list.component'; -describe('CharclassComponent', () => { - let component: CharclassComponent; - let fixture: ComponentFixture; +describe('DataComponent', () => { + let component: DataListComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [HttpClientModule], - declarations: [ CharclassComponent ] + declarations: [ DataListComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(CharclassComponent); + fixture = TestBed.createComponent(DataListComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts new file mode 100644 index 0000000..358aa1c --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { Data } from '../../data'; +import { DataService } from '../../data.service'; + +@Component({ + selector: 'app-data-list', + templateUrl: './data-list.component.html', + styleUrls: ['./data-list.component.sass'] +}) +export class DataListComponent implements OnInit { + + shownData: Data[]; + + constructor(private dataService: DataService) { } + + ngOnInit(): void { + this.getAllData(); + } + + getAllData(): void { + this.dataService.getData().subscribe(data => this.shownData = data); + } + +} diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-view.module.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts similarity index 52% rename from src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-view.module.ts rename to src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts index c30cf91..198629c 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass-view/charclass-view.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts @@ -6,15 +6,11 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { MatListModule } from '@angular/material/list'; -import { CharclassListComponent } from './charclass-list/charclass-list.component'; -import { CharclassComponent } from './charclass/charclass.component'; -import { CharclassDetailComponent } from './charclass-detail/charclass-detail.component'; +import { DataListComponent } from './data-list/data-list.component'; @NgModule({ declarations: [ - CharclassComponent, - CharclassDetailComponent, - CharclassListComponent + DataListComponent ], imports: [ CommonModule, @@ -27,9 +23,7 @@ import { CharclassDetailComponent } from './charclass-detail/charclass-detail.co RouterModule, FlexLayoutModule, MatListModule, - CharclassListComponent, - CharclassComponent, - CharclassDetailComponent + DataListComponent ] }) -export class CharclassViewModule { } +export class DataViewModule { } diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass.service.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data.service.spec.ts similarity index 62% rename from src/main/resources/archetype-resources/src/main/js/app/charclass.service.spec.ts rename to src/main/resources/archetype-resources/src/main/js/app/data.service.spec.ts index 17a893e..0475e11 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass.service.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data.service.spec.ts @@ -2,16 +2,16 @@ import { TestBed } from '@angular/core/testing'; import { HttpClientModule } from '@angular/common/http'; -import { CharclassService } from './charclass.service'; +import { DataService } from './data.service'; -describe('CharclassService', () => { - let service: CharclassService; +describe('DataService', () => { + let service: DataService; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientModule] }); - service = TestBed.inject(CharclassService); + service = TestBed.inject(DataService); }); it('should be created', () => { diff --git a/src/main/resources/archetype-resources/src/main/js/app/charclass.service.ts b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts similarity index 57% rename from src/main/resources/archetype-resources/src/main/js/app/charclass.service.ts rename to src/main/resources/archetype-resources/src/main/js/app/data.service.ts index 2b7814f..b1be4bf 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/charclass.service.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Charclass } from './charclass'; +import { Data } from './data'; import { ApiResponse } from './api-response'; import { Observable, of } from 'rxjs'; import { catchError, map, tap } from 'rxjs/operators'; @@ -8,28 +8,23 @@ import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) -export class CharclassService { +export class DataService { - private charclassesUrl = 'https://www.dnd5eapi.co/api/classes'; // URL to web api + private endpoint = 'http://localhost:8080/rest/entity'; // URL to web api constructor( private http: HttpClient ) { } - getCharClasses(): Observable { - return this.http.get>(this.charclassesUrl).pipe( - map((response: ApiResponse) => { return response.results }), - catchError(this.handleError('getCharClasses', [])) + getData(): Observable { + return this.http.get>(this.endpoint).pipe( + map((response: ApiResponse) => { return response.content.content }), + catchError(this.handleError('getData', [])) ).pipe( - catchError(this.handleError('getCharClasses', [])) + catchError(this.handleError('getData', [])) ); } - getCharClass(id: string): Observable { - const url = `${this.charclassesUrl}/${id}`; - return this.http.get(url); - } - /** * Handle Http operation that failed. * Let the app continue. diff --git a/src/main/resources/archetype-resources/src/main/js/app/data.ts b/src/main/resources/archetype-resources/src/main/js/app/data.ts new file mode 100644 index 0000000..cdb6920 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data.ts @@ -0,0 +1,5 @@ + +export interface Data { + id: number; + name: string; +} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html b/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html index 6fab72d..993ba11 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html @@ -3,7 +3,7 @@ [mode]="(isHandset$ | async) ? 'over' : 'side'" [opened]="(isHandset$ | async) === false"> Menu - Classes + Data diff --git a/src/main/resources/archetype-resources/src/main/js/app/proficiency-choice.ts b/src/main/resources/archetype-resources/src/main/js/app/proficiency-choice.ts deleted file mode 100644 index 0400ee4..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/proficiency-choice.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Proficiency } from './proficiency'; - -export interface ProficiencyChoice { - choose: number; - type: string; - from: Proficiency[]; -} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/proficiency.ts b/src/main/resources/archetype-resources/src/main/js/app/proficiency.ts deleted file mode 100644 index 2a5dc6e..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/proficiency.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Proficiency { - name: string; - url: string; -} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/saving-throw.ts b/src/main/resources/archetype-resources/src/main/js/app/saving-throw.ts deleted file mode 100644 index a672438..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/saving-throw.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface SavingThrow { - name: string; - url: string; -} \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/subclass.ts b/src/main/resources/archetype-resources/src/main/js/app/subclass.ts deleted file mode 100644 index bf135af..0000000 --- a/src/main/resources/archetype-resources/src/main/js/app/subclass.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface Subclass { - name: string; - url: string; -} \ No newline at end of file From 4eacb4bc60590e48769a5645383f322f43a701da Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 25 Oct 2020 22:19:58 +0100 Subject: [PATCH 15/25] Added search option --- .../src/main/js/app/app-routing.module.ts | 4 +-- .../data-list/data-list.component.html | 6 ++-- .../data-list/data-list.component.ts | 17 +++-------- .../data-view-search-form.component.html | 6 ++++ .../data-view-search-form.component.sass | 0 .../data-view-search-form.component.spec.ts | 25 +++++++++++++++++ .../data-view-search-form.component.ts | 18 ++++++++++++ .../data-view-search.component.html | 2 ++ .../data-view-search.component.sass | 0 .../data-view-search.component.spec.ts | 25 +++++++++++++++++ .../data-view-search.component.ts | 28 +++++++++++++++++++ .../main/js/app/data-view/data-view.module.ts | 6 +++- .../src/main/js/app/data.service.ts | 5 ++-- 13 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.sass create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.html create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.sass create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.ts diff --git a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts index 1ec94f4..5988b67 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { DataListComponent } from './data-view/data-list/data-list.component'; +import { DataViewSearchComponent } from './data-view/data-view-search/data-view-search.component'; const routes: Routes = [ { path: '', redirectTo: '/data', pathMatch: 'full' }, - { path: 'data', component: DataListComponent } + { path: 'data', component: DataViewSearchComponent } ]; @NgModule({ diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html index 453bc97..49eb1bf 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.html @@ -1,8 +1,8 @@ - + - {{data.name}} - + {{d.name}} + \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts index 358aa1c..f500d1a 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-list/data-list.component.ts @@ -1,24 +1,15 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { Data } from '../../data'; -import { DataService } from '../../data.service'; @Component({ selector: 'app-data-list', templateUrl: './data-list.component.html', styleUrls: ['./data-list.component.sass'] }) -export class DataListComponent implements OnInit { +export class DataListComponent { - shownData: Data[]; + @Input() data: Data[]; - constructor(private dataService: DataService) { } - - ngOnInit(): void { - this.getAllData(); - } - - getAllData(): void { - this.dataService.getData().subscribe(data => this.shownData = data); - } + constructor() { } } diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html new file mode 100644 index 0000000..07c44c8 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html @@ -0,0 +1,6 @@ +
+
+ + +
+
diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.sass b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.sass new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts new file mode 100644 index 0000000..ddfc0d1 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DataViewSearchFormComponent } from './data-view-search-form.component'; + +describe('DataViewSearchFormComponent', () => { + let component: DataViewSearchFormComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DataViewSearchFormComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DataViewSearchFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.ts new file mode 100644 index 0000000..5c9efed --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.ts @@ -0,0 +1,18 @@ +import { Component, EventEmitter, Output } from '@angular/core'; + +@Component({ + selector: 'app-data-view-search-form', + templateUrl: './data-view-search-form.component.html', + styleUrls: ['./data-view-search-form.component.sass'] +}) +export class DataViewSearchFormComponent { + + @Output() update: EventEmitter = new EventEmitter(); + + constructor() {} + + public handleClick(value: string): void { + this.update.next({ value: value }); + } + +} diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.html new file mode 100644 index 0000000..974f0d0 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.html @@ -0,0 +1,2 @@ + + diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.sass b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.sass new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts new file mode 100644 index 0000000..f8e51ee --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DataViewSearchComponent } from './data-view-search.component'; + +describe('DataViewSearchComponent', () => { + let component: DataViewSearchComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DataViewSearchComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DataViewSearchComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.ts new file mode 100644 index 0000000..050326c --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.ts @@ -0,0 +1,28 @@ +import { Component, OnInit } from '@angular/core'; +import { Data } from '../../data'; +import { DataService } from '../../data.service'; + +@Component({ + selector: 'app-data-view-search', + templateUrl: './data-view-search.component.html', + styleUrls: ['./data-view-search.component.sass'] +}) +export class DataViewSearchComponent implements OnInit { + + shownData: Data[]; + + constructor(private dataService: DataService) { } + + ngOnInit(): void { + this.getAllData(); + } + + getAllData(): void { + this.dataService.search("").subscribe(data => this.shownData = data); + } + + handleSearch(query): void { + this.dataService.search(query.value).subscribe(data => this.shownData = data); + } + +} diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts index 198629c..7394198 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts @@ -7,10 +7,14 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { MatListModule } from '@angular/material/list'; import { DataListComponent } from './data-list/data-list.component'; +import { DataViewSearchComponent } from './data-view-search/data-view-search.component'; +import { DataViewSearchFormComponent } from './data-view-search-form/data-view-search-form.component'; @NgModule({ declarations: [ - DataListComponent + DataListComponent, + DataViewSearchComponent, + DataViewSearchFormComponent ], imports: [ CommonModule, diff --git a/src/main/resources/archetype-resources/src/main/js/app/data.service.ts b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts index b1be4bf..9fa6a15 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data.service.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts @@ -16,8 +16,9 @@ export class DataService { private http: HttpClient ) { } - getData(): Observable { - return this.http.get>(this.endpoint).pipe( + search(query: string): Observable { + const params = { query }; + return this.http.get>(this.endpoint, { params: params }).pipe( map((response: ApiResponse) => { return response.content.content }), catchError(this.handleError('getData', [])) ).pipe( From 6cf32a659b85e912d3c53d681a6606859cec6ebc Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 25 Oct 2020 22:30:35 +0100 Subject: [PATCH 16/25] Replaced project name on frontend --- src/main/resources/archetype-resources/karma.conf.js | 2 +- .../src/main/js/app/app.component.spec.ts | 6 +++--- .../archetype-resources/src/main/js/app/app.component.ts | 2 +- .../archetype-resources/src/main/js/e2e/src/app.e2e-spec.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/archetype-resources/karma.conf.js b/src/main/resources/archetype-resources/karma.conf.js index 1dd50c8..60cb018 100644 --- a/src/main/resources/archetype-resources/karma.conf.js +++ b/src/main/resources/archetype-resources/karma.conf.js @@ -16,7 +16,7 @@ module.exports = function (config) { clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { - dir: require('path').join(__dirname, './coverage/dnd5-api-angular-client'), + dir: require('path').join(__dirname, './coverage/${artifactId}'), reports: ['html', 'lcovonly', 'text-summary'], fixWebpackSourcePaths: true }, diff --git a/src/main/resources/archetype-resources/src/main/js/app/app.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/app.component.spec.ts index 56ca2fa..e802fca 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app.component.spec.ts @@ -20,16 +20,16 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have as title 'dnd5-api-angular-client'`, () => { + it(`should have as title '${artifactId}'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; - expect(app.title).toEqual('dnd5-api-angular-client'); + expect(app.title).toEqual('${artifactId}'); }); // it('should render title', () => { // const fixture = TestBed.createComponent(AppComponent); // fixture.detectChanges(); // const compiled = fixture.nativeElement; - // expect(compiled.querySelector('.content span').textContent).toContain('dnd5-api-angular-client app is running!'); + // expect(compiled.querySelector('.content span').textContent).toContain('${artifactId} app is running!'); // }); }); diff --git a/src/main/resources/archetype-resources/src/main/js/app/app.component.ts b/src/main/resources/archetype-resources/src/main/js/app/app.component.ts index 139e9e0..5bee928 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app.component.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app.component.ts @@ -6,5 +6,5 @@ import { Component } from '@angular/core'; styleUrls: ['./app.component.sass'] }) export class AppComponent { - title = 'dnd5-api-angular-client'; + title = '${artifactId}'; } diff --git a/src/main/resources/archetype-resources/src/main/js/e2e/src/app.e2e-spec.ts b/src/main/resources/archetype-resources/src/main/js/e2e/src/app.e2e-spec.ts index 4dd3d81..de0f658 100644 --- a/src/main/resources/archetype-resources/src/main/js/e2e/src/app.e2e-spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/e2e/src/app.e2e-spec.ts @@ -10,7 +10,7 @@ describe('workspace-project App', () => { // it('should display welcome message', () => { // page.navigateTo(); - // expect(page.getTitleText()).toEqual('dnd5-api-angular-client app is running!'); + // expect(page.getTitleText()).toEqual('${artifactId} app is running!'); // }); afterEach(async () => { From d53fbb7a5a8b1053f161ab31465fcd1557aa8dfc Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 25 Oct 2020 23:00:09 +0100 Subject: [PATCH 17/25] Corrected missing symbol --- .../unit/controller/rest/TestExampleEntityController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/archetype-resources/src/test/java/test/unit/controller/rest/TestExampleEntityController.java b/src/main/resources/archetype-resources/src/test/java/test/unit/controller/rest/TestExampleEntityController.java index 3032554..3bf7f8b 100644 --- a/src/main/resources/archetype-resources/src/test/java/test/unit/controller/rest/TestExampleEntityController.java +++ b/src/main/resources/archetype-resources/src/test/java/test/unit/controller/rest/TestExampleEntityController.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - +#set( $symbol_dollar = '$' ) package ${package}.test.unit.controller.rest; import java.util.ArrayList; @@ -92,7 +92,7 @@ public final void testGet_ExpectedResults() throws Exception { result.andExpect(MockMvcResultMatchers.status().isOk()); // The response model contains the expected attributes - result.andExpect(MockMvcResultMatchers.jsonPath("$.content", + result.andExpect(MockMvcResultMatchers.jsonPath("${symbol_dollar}.content", Matchers.hasSize(3))); } From 1bbe538a9c58f010de2e11682b4d594eef97a232 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 25 Oct 2020 23:31:13 +0100 Subject: [PATCH 18/25] Importing HTTPClient --- .../data-view-search-form.component.spec.ts | 3 +++ .../data-view-search/data-view-search.component.spec.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts index ddfc0d1..54b20af 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.spec.ts @@ -1,5 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpClientModule } from '@angular/common/http'; + import { DataViewSearchFormComponent } from './data-view-search-form.component'; describe('DataViewSearchFormComponent', () => { @@ -8,6 +10,7 @@ describe('DataViewSearchFormComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule], declarations: [ DataViewSearchFormComponent ] }) .compileComponents(); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts index f8e51ee..17e88c1 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search/data-view-search.component.spec.ts @@ -1,5 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpClientModule } from '@angular/common/http'; + import { DataViewSearchComponent } from './data-view-search.component'; describe('DataViewSearchComponent', () => { @@ -8,6 +10,7 @@ describe('DataViewSearchComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule], declarations: [ DataViewSearchComponent ] }) .compileComponents(); From 6ab0528befd506ad710bfec361f4a801c181d77c Mon Sep 17 00:00:00 2001 From: Bernardo Date: Tue, 27 Oct 2020 21:46:19 +0100 Subject: [PATCH 19/25] Added data form --- .../src/main/js/app/app-routing.module.ts | 4 ++- .../src/main/js/app/app.module.ts | 4 ++- .../data-form-view.component.html | 1 + .../data-form-view.component.sass | 0 .../data-form-view.component.spec.ts | 25 +++++++++++++++++++ .../data-form-view.component.ts | 12 +++++++++ .../main/js/app/data-form/data-form.module.ts | 24 ++++++++++++++++++ .../data-input/data-input.component.html | 16 ++++++++++++ .../data-input/data-input.component.sass | 0 .../data-input/data-input.component.spec.ts | 25 +++++++++++++++++++ .../data-input/data-input.component.ts | 20 +++++++++++++++ .../src/main/js/app/data.service.ts | 11 ++++++-- .../src/main/js/app/dataForm.ts | 7 ++++++ .../app/navigation/navigation.component.html | 1 + 14 files changed, 146 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.html create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.sass create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.sass create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/dataForm.ts diff --git a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts index 5988b67..5ef9025 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts @@ -1,10 +1,12 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { DataViewSearchComponent } from './data-view/data-view-search/data-view-search.component'; +import { DataFormViewComponent } from './data-form/data-form-view/data-form-view.component'; const routes: Routes = [ { path: '', redirectTo: '/data', pathMatch: 'full' }, - { path: 'data', component: DataViewSearchComponent } + { path: 'data', component: DataViewSearchComponent }, + { path: 'form', component: DataFormViewComponent } ]; @NgModule({ diff --git a/src/main/resources/archetype-resources/src/main/js/app/app.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app.module.ts index 36b4143..b631536 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app.module.ts @@ -14,6 +14,7 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { NavigationComponent } from './navigation/navigation.component'; import { DataViewModule } from './data-view/data-view.module'; +import { DataFormModule } from './data-form/data-form.module'; @NgModule({ declarations: [ @@ -31,7 +32,8 @@ import { DataViewModule } from './data-view/data-view.module'; MatListModule, MatSidenavModule, MatToolbarModule, - DataViewModule + DataViewModule, + DataFormModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.html new file mode 100644 index 0000000..038ce8d --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.html @@ -0,0 +1 @@ + diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.sass b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.sass new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts new file mode 100644 index 0000000..7bbfb86 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DataFormViewComponent } from './data-form-view.component'; + +describe('DataFormViewComponent', () => { + let component: DataFormViewComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DataFormViewComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DataFormViewComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.ts new file mode 100644 index 0000000..cb4a845 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-data-form-view', + templateUrl: './data-form-view.component.html', + styleUrls: ['./data-form-view.component.sass'] +}) +export class DataFormViewComponent { + + constructor() { } + +} diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts new file mode 100644 index 0000000..b6cd908 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts @@ -0,0 +1,24 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { DataInputComponent } from './data-input/data-input.component'; +import { DataFormViewComponent } from './data-form-view/data-form-view.component'; + + + +@NgModule({ + declarations: [ + DataInputComponent, + DataFormViewComponent + ], + imports: [ + CommonModule, + FormsModule + ], + exports: [ + DataInputComponent, + DataFormViewComponent + ] +}) +export class DataFormModule { } diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html new file mode 100644 index 0000000..6e45742 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html @@ -0,0 +1,16 @@ +
+

Input Form

+
+
+ + +
+ Name is required +
+
+ + + +
+
\ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.sass b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.sass new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts new file mode 100644 index 0000000..ae17bb7 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DataInputComponent } from './data-input.component'; + +describe('DataInputComponent', () => { + let component: DataInputComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DataInputComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DataInputComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.ts new file mode 100644 index 0000000..f7e0ea4 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.ts @@ -0,0 +1,20 @@ +import { Component } from '@angular/core'; +import { DataService } from 'app/data.service'; +import { DataForm } from '../../dataForm'; + +@Component({ + selector: 'app-data-input', + templateUrl: './data-input.component.html', + styleUrls: ['./data-input.component.sass'] +}) +export class DataInputComponent { + + model = new DataForm(""); + + constructor(private dataService: DataService) { } + + onSubmit() { + this.dataService.save(this.model); + } + +} diff --git a/src/main/resources/archetype-resources/src/main/js/app/data.service.ts b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts index 9fa6a15..edf5461 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data.service.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts @@ -4,6 +4,7 @@ import { ApiResponse } from './api-response'; import { Observable, of } from 'rxjs'; import { catchError, map, tap } from 'rxjs/operators'; import { HttpClient } from '@angular/common/http'; +import { DataForm } from './dataForm'; @Injectable({ providedIn: 'root' @@ -20,12 +21,18 @@ export class DataService { const params = { query }; return this.http.get>(this.endpoint, { params: params }).pipe( map((response: ApiResponse) => { return response.content.content }), - catchError(this.handleError('getData', [])) + catchError(this.handleError('search', [])) ).pipe( - catchError(this.handleError('getData', [])) + catchError(this.handleError('search', [])) ); } + save(data: DataForm): void { + this.http.post(this.endpoint, data).pipe( + catchError(this.handleError('getData', data)) + ).subscribe(); + } + /** * Handle Http operation that failed. * Let the app continue. diff --git a/src/main/resources/archetype-resources/src/main/js/app/dataForm.ts b/src/main/resources/archetype-resources/src/main/js/app/dataForm.ts new file mode 100644 index 0000000..bcfff96 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/dataForm.ts @@ -0,0 +1,7 @@ +export class DataForm { + + constructor( + public name: string + ) { } + + } \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html b/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html index 993ba11..03a06d7 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html @@ -4,6 +4,7 @@ Menu Data + Form From e806fd9551edbdd0b523444a5e825026ba196ab9 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Tue, 27 Oct 2020 22:41:47 +0100 Subject: [PATCH 20/25] Added report download --- .../src/main/js/app/app-routing.module.ts | 4 ++- .../src/main/js/app/app.module.ts | 4 ++- .../data-report/data-report.component.html | 1 + .../data-report/data-report.component.sass | 0 .../data-report/data-report.component.spec.ts | 25 +++++++++++++++++++ .../app/data-report/data-report.component.ts | 17 +++++++++++++ .../src/main/js/app/data.service.ts | 21 ++++++++++++++-- .../app/navigation/navigation.component.html | 1 + 8 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.sass create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts create mode 100644 src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.ts diff --git a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts index 5ef9025..3acdf38 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app-routing.module.ts @@ -2,11 +2,13 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { DataViewSearchComponent } from './data-view/data-view-search/data-view-search.component'; import { DataFormViewComponent } from './data-form/data-form-view/data-form-view.component'; +import { DataReportComponent } from './data-report/data-report.component'; const routes: Routes = [ { path: '', redirectTo: '/data', pathMatch: 'full' }, { path: 'data', component: DataViewSearchComponent }, - { path: 'form', component: DataFormViewComponent } + { path: 'form', component: DataFormViewComponent }, + { path: 'report', component: DataReportComponent } ]; @NgModule({ diff --git a/src/main/resources/archetype-resources/src/main/js/app/app.module.ts b/src/main/resources/archetype-resources/src/main/js/app/app.module.ts index b631536..c4577f8 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/app.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/app.module.ts @@ -15,11 +15,13 @@ import { AppComponent } from './app.component'; import { NavigationComponent } from './navigation/navigation.component'; import { DataViewModule } from './data-view/data-view.module'; import { DataFormModule } from './data-form/data-form.module'; +import { DataReportComponent } from './data-report/data-report.component'; @NgModule({ declarations: [ AppComponent, - NavigationComponent + NavigationComponent, + DataReportComponent ], imports: [ AppRoutingModule, diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html new file mode 100644 index 0000000..80a5ca4 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html @@ -0,0 +1 @@ + diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.sass b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.sass new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts new file mode 100644 index 0000000..090f8bf --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DataReportComponent } from './data-report.component'; + +describe('DataReportComponent', () => { + let component: DataReportComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DataReportComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DataReportComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.ts b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.ts new file mode 100644 index 0000000..bc92c52 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.ts @@ -0,0 +1,17 @@ +import { Component, OnInit } from '@angular/core'; +import { DataService } from 'app/data.service'; + +@Component({ + selector: 'app-data-report', + templateUrl: './data-report.component.html', + styleUrls: ['./data-report.component.sass'] +}) +export class DataReportComponent { + + constructor(private dataService: DataService) { } + + public download(): void { + this.dataService.report(); + } + +} diff --git a/src/main/resources/archetype-resources/src/main/js/app/data.service.ts b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts index edf5461..3224c4d 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data.service.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data.service.ts @@ -3,7 +3,7 @@ import { Data } from './data'; import { ApiResponse } from './api-response'; import { Observable, of } from 'rxjs'; import { catchError, map, tap } from 'rxjs/operators'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; import { DataForm } from './dataForm'; @Injectable({ @@ -11,7 +11,9 @@ import { DataForm } from './dataForm'; }) export class DataService { - private endpoint = 'http://localhost:8080/rest/entity'; // URL to web api + private endpoint = 'http://localhost:8080/rest/entity'; + + private reportEndpoint = 'http://localhost:8080/rest/entity/pdf'; constructor( private http: HttpClient @@ -33,6 +35,21 @@ export class DataService { ).subscribe(); } + report(): void { + let headers = new HttpHeaders(); + headers = headers.set('Accept', 'application/pdf'); + this.http.get(this.reportEndpoint, { headers: headers, responseType: 'blob' }).subscribe(response => this.downLoadFile(response, 'application/pdf')); + } + + downLoadFile(data: any, type: string) { + let blob = new Blob([data], { type: type }); + let url = window.URL.createObjectURL(blob); + let pwa = window.open(url); + if (!pwa || pwa.closed || typeof pwa.closed == 'undefined') { + alert('Please disable your Pop-up blocker and try again.'); + } + } + /** * Handle Http operation that failed. * Let the app continue. diff --git a/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html b/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html index 03a06d7..2d119d4 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/navigation/navigation.component.html @@ -5,6 +5,7 @@ Data Form + Report From 9e7ff71e795a16026e3e596ff0c9d05d10cee53e Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 28 Oct 2020 14:33:49 +0100 Subject: [PATCH 21/25] Added missing imports --- .../data-form/data-form-view/data-form-view.component.spec.ts | 2 ++ .../js/app/data-form/data-input/data-input.component.spec.ts | 2 ++ .../src/main/js/app/data-report/data-report.component.spec.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts index 7bbfb86..af0128b 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts @@ -1,3 +1,4 @@ +import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DataFormViewComponent } from './data-form-view.component'; @@ -8,6 +9,7 @@ describe('DataFormViewComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule], declarations: [ DataFormViewComponent ] }) .compileComponents(); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts index ae17bb7..d3381cf 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts @@ -1,3 +1,4 @@ +import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DataInputComponent } from './data-input.component'; @@ -8,6 +9,7 @@ describe('DataInputComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule], declarations: [ DataInputComponent ] }) .compileComponents(); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts index 090f8bf..6aaacf2 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.spec.ts @@ -1,3 +1,4 @@ +import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DataReportComponent } from './data-report.component'; @@ -8,6 +9,7 @@ describe('DataReportComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ + imports: [HttpClientModule], declarations: [ DataReportComponent ] }) .compileComponents(); From 909ae8dfe15f493f9689b851f38c2557ecb8dd45 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Wed, 28 Oct 2020 15:19:23 +0100 Subject: [PATCH 22/25] Added missing imports --- .../data-form-view/data-form-view.component.spec.ts | 3 ++- .../app/data-form/data-input/data-input.component.spec.ts | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts index af0128b..8ab5d3e 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form-view/data-form-view.component.spec.ts @@ -1,5 +1,6 @@ import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormsModule } from '@angular/forms'; import { DataFormViewComponent } from './data-form-view.component'; @@ -9,7 +10,7 @@ describe('DataFormViewComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [HttpClientModule], + imports: [HttpClientModule, FormsModule], declarations: [ DataFormViewComponent ] }) .compileComponents(); diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts index d3381cf..894c120 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.spec.ts @@ -1,5 +1,6 @@ import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormsModule } from '@angular/forms'; import { DataInputComponent } from './data-input.component'; @@ -9,10 +10,10 @@ describe('DataInputComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [HttpClientModule], - declarations: [ DataInputComponent ] + imports: [HttpClientModule, FormsModule], + declarations: [DataInputComponent] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { From 666a4cb991649e4ea6302906bdaf23f1d1810e9c Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 1 Nov 2020 17:04:34 +0100 Subject: [PATCH 23/25] Using material components --- .../main/js/app/data-form/data-form.module.ts | 11 +++++++++-- .../data-input/data-input.component.html | 18 +++++++++--------- .../app/data-report/data-report.component.html | 2 +- .../data-view-search-form.component.html | 7 +++++-- .../main/js/app/data-view/data-view.module.ts | 6 ++++++ 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts index b6cd908..ddb7116 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-form.module.ts @@ -2,6 +2,9 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { MatInputModule } from '@angular/material/input'; + import { DataInputComponent } from './data-input/data-input.component'; import { DataFormViewComponent } from './data-form-view/data-form-view.component'; @@ -14,11 +17,15 @@ import { DataFormViewComponent } from './data-form-view/data-form-view.component ], imports: [ CommonModule, - FormsModule + FormsModule, + MatButtonModule, + MatInputModule ], exports: [ DataInputComponent, - DataFormViewComponent + DataFormViewComponent, + MatButtonModule, + MatInputModule ] }) export class DataFormModule { } diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html index 6e45742..1d2e689 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/data-form/data-input/data-input.component.html @@ -2,15 +2,15 @@

Input Form

- - -
- Name is required -
+ + Name + +
+ Name is required +
+
- - - +
\ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html index 80a5ca4..4bc8d45 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/data-report/data-report.component.html @@ -1 +1 @@ - + diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html index 07c44c8..fb27d65 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view-search-form/data-view-search-form.component.html @@ -1,6 +1,9 @@
- - + + Search criteria + + +
diff --git a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts index 7394198..0b57648 100644 --- a/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts +++ b/src/main/resources/archetype-resources/src/main/js/app/data-view/data-view.module.ts @@ -4,6 +4,8 @@ import { RouterModule } from '@angular/router'; import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatButtonModule } from '@angular/material/button'; +import { MatInputModule } from '@angular/material/input'; import { MatListModule } from '@angular/material/list'; import { DataListComponent } from './data-list/data-list.component'; @@ -20,12 +22,16 @@ import { DataViewSearchFormComponent } from './data-view-search-form/data-view-s CommonModule, RouterModule, FlexLayoutModule, + MatButtonModule, + MatInputModule, MatListModule ], exports: [ CommonModule, RouterModule, FlexLayoutModule, + MatButtonModule, + MatInputModule, MatListModule, DataListComponent ] From fd135b0ecf355b4fb6144909f58a7672cfda26c8 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 1 Nov 2020 19:18:08 +0100 Subject: [PATCH 24/25] Corrected value replacement --- src/main/resources/archetype-resources/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml index 1b0aa26..c981c1a 100644 --- a/src/main/resources/archetype-resources/pom.xml +++ b/src/main/resources/archetype-resources/pom.xml @@ -809,6 +809,12 @@ clean package + + + src/main/resources + true + + From 78e9ec627e52090dd6c7b40aaf26c86eba3703da Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 1 Nov 2020 19:21:49 +0100 Subject: [PATCH 25/25] Release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5625006..8db0eef 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ com.bernardomg.maven.archetypes spring-mvc-angular-archetype - 1.0.0-SNAPSHOT + 1.0.0 maven-archetype Spring MVC with Angular Maven Archetype