From 1ef18fb480ec70b1cc42860eea74d0eca7311850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20T=C3=A4schner?= <129834483+HenryT-CG@users.noreply.github.com> Date: Mon, 22 Jan 2024 07:33:47 +0100 Subject: [PATCH] Fix/minor code issues (#11) * fix: minor code issues * fix: minor code issues * fix: minor code issues --- Dockerfile | 2 +- src/app/app.component.scss | 0 src/app/app.component.ts | 4 +- .../product-detail.component.html | 2 +- .../product-detail.component.ts | 15 ++-- .../product-intern.component.html | 76 ------------------- .../product-props/product-props.component.ts | 15 ++-- .../product.detail.component.spec.ts | 2 +- .../product-search.component.html | 3 +- src/app/shared/can-active-guard.service.ts | 2 +- .../image-container.component.ts | 2 +- src/app/shared/label.resolver.ts | 4 +- src/assets/i18n/de.json | 16 +++- src/assets/i18n/en.json | 16 +++- src/assets/silent-check-sso.html | 6 +- src/environments/environment.ts | 9 --- 16 files changed, 59 insertions(+), 115 deletions(-) delete mode 100644 src/app/app.component.scss diff --git a/Dockerfile b/Dockerfile index 2178163..f3c7326 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,5 @@ COPY dist/onecx-product-store-ui/ $DIR_HTML ENV BFF_URL http://onecx-product-store-bff:8080/ ENV APP_BASE_HREF /product-store/ -RUN chmod 775 -R $DIR_HTML/assets +RUN chmod 775 -R "$DIR_HTML"/assets USER 1001 diff --git a/src/app/app.component.scss b/src/app/app.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 254f014..bb7b23b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,8 +1,8 @@ import { Component } from '@angular/core' + @Component({ selector: 'ps-root', - templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + templateUrl: './app.component.html' }) export class AppComponent { title = 'product-store-ui' diff --git a/src/app/product-store/product-detail/product-detail.component.html b/src/app/product-store/product-detail/product-detail.component.html index 227954b..4a499b5 100644 --- a/src/app/product-store/product-detail/product-detail.component.html +++ b/src/app/product-store/product-detail/product-detail.component.html @@ -10,7 +10,7 @@
- +
diff --git a/src/app/product-store/product-detail/product-detail.component.ts b/src/app/product-store/product-detail/product-detail.component.ts index 9f8d9be..6aeb9da 100644 --- a/src/app/product-store/product-detail/product-detail.component.ts +++ b/src/app/product-store/product-detail/product-detail.component.ts @@ -46,7 +46,6 @@ export class ProductDetailComponent implements OnInit { } ngOnInit(): void { - console.log('product detail ngOnInit()') if (this.productName !== '') { this.changeMode = 'VIEW' this.loadProduct() @@ -75,9 +74,10 @@ export class ProductDetailComponent implements OnInit { this.prepareTranslations() }, error: (err: any) => { + console.error('search: ', err) this.msgService.error({ - summaryKey: 'DIALOG.LOAD_ERROR' - // detailKey: err.error.indexOf('was not found') > 1 ? 'DIALOG.NOT_FOUND' : err.error + summaryKey: 'ACTIONS.SEARCH.PRODUCT.LOAD_ERROR' + // detailKey: err.error.indexOf('was not found') > 1 ? 'SEARCH.NOT_FOUND' : err.error }) this.close() } @@ -196,6 +196,7 @@ export class ProductDetailComponent implements OnInit { public onClose() { this.close() } + public onEdit() { this.getProduct() this.changeMode = 'EDIT' @@ -214,21 +215,23 @@ export class ProductDetailComponent implements OnInit { public onSave() { this.productPropsComponent.onSubmit() } + public onCreate(data: any) { this.product = data - this.changeMode === 'VIEW' + this.changeMode = 'VIEW' this.router.navigate(['./../', this.product?.name], { relativeTo: this.route }) } + public onChange(nameChanged: boolean) { - console.log('detail.onChange ') if (nameChanged) { this.close() } else { this.getProduct() - this.changeMode === 'VIEW' + this.changeMode = 'VIEW' this.prepareTranslations() } } + public onDelete(ev: MouseEvent, item: Product): void { ev.stopPropagation() this.product = item diff --git a/src/app/product-store/product-detail/product-intern/product-intern.component.html b/src/app/product-store/product-detail/product-intern/product-intern.component.html index 1a527a4..a29face 100644 --- a/src/app/product-store/product-detail/product-intern/product-intern.component.html +++ b/src/app/product-store/product-detail/product-intern/product-intern.component.html @@ -72,79 +72,3 @@ - - diff --git a/src/app/product-store/product-detail/product-props/product-props.component.ts b/src/app/product-store/product-detail/product-props/product-props.component.ts index 9f244b9..bfd4ffb 100644 --- a/src/app/product-store/product-detail/product-props/product-props.component.ts +++ b/src/app/product-store/product-detail/product-props/product-props.component.ts @@ -139,7 +139,6 @@ export class ProductPropertyComponent implements OnChanges { }) .subscribe({ next: () => { - this.changeMode === 'VIEW' this.msgService.success({ summaryKey: 'ACTIONS.EDIT.PRODUCT.OK' }) this.productChanged.emit(this.productName !== this.formGroup.value['name']) }, @@ -148,12 +147,14 @@ export class ProductPropertyComponent implements OnChanges { } private displaySaveError(err: any) { - err.error && err.error.errorCode && err.error.errorCode === 'MERGE_ENTITY_FAILED' // 'PERSIST_ENTITY_FAILED' - ? this.msgService.error({ - summaryKey: 'ACTIONS.' + this.changeMode + '.PRODUCT.NOK', - detailKey: 'VALIDATION.PRODUCT.UNIQUE_CONSTRAINT' - }) - : this.msgService.error({ summaryKey: 'ACTIONS.' + this.changeMode + '.PRODUCT.NOK' }) + if (err.error?.errorCode === 'MERGE_ENTITY_FAILED') { + this.msgService.error({ + summaryKey: 'ACTIONS.' + this.changeMode + '.PRODUCT.NOK', + detailKey: 'VALIDATION.PRODUCT.UNIQUE_CONSTRAINT' + }) + } else { + this.msgService.error({ summaryKey: 'ACTIONS.' + this.changeMode + '.PRODUCT.NOK' }) + } } /** File Handling diff --git a/src/app/product-store/product-detail/product.detail.component.spec.ts b/src/app/product-store/product-detail/product.detail.component.spec.ts index 89cc3e5..ec1e488 100644 --- a/src/app/product-store/product-detail/product.detail.component.spec.ts +++ b/src/app/product-store/product-detail/product.detail.component.spec.ts @@ -97,7 +97,7 @@ describe('ProductDetailComponent', () => { component.ngOnInit() expect(msgServiceSpy.error).toHaveBeenCalledWith({ - summaryKey: 'DIALOG.LOAD_ERROR' + summaryKey: 'ACTIONS.SEARCH.PRODUCT.LOAD_ERROR' }) }) diff --git a/src/app/product-store/product-search/product-search.component.html b/src/app/product-store/product-search/product-search.component.html index 4372ce4..6d870bb 100644 --- a/src/app/product-store/product-search/product-search.component.html +++ b/src/app/product-store/product-search/product-search.component.html @@ -20,7 +20,7 @@
- +
{ constructor(private translate: TranslateService) {} - /* eslint-disable @typescript-eslint/no-unused-vars */ /* TODO: is state needed */ + /* eslint-disable @typescript-eslint/no-unused-vars */ resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): string | Observable | Promise { return route.data['breadcrumb'] ? this.translate.instant(route.data['breadcrumb']) : route.routeConfig?.path } diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 8f98b31..67f966f 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -76,6 +76,19 @@ "VIEW_MODE_LIST": "Listenansicht", "VIEW_MODE_TABLE": "Tabellenansicht" }, + "SEARCH": { + "NOT_FOUND": "Keine Daten gefunden", + "APP": { + "NOT_EXISTS": "Eine App mit diesem Namen konnte nicht gefunden werden.", + "LOAD_ERROR": "App konnte nicht geladen werden", + "NOT_FOUND": "App nicht gefunden" + }, + "PRODUCT": { + "NOT_EXISTS": "Ein Produkt mit diesem Namen konnte nicht gefunden werden.", + "LOAD_ERROR": "Produkt konnte nicht geladen werden", + "NOT_FOUND": "Produkt nicht gefunden" + } + }, "CANCEL": "Abbrechen", "CHOOSE": "Auswählen", "SAVE": "Speichern", @@ -115,8 +128,6 @@ "SEARCH.HEADER": "Product Store", "SEARCH.SUBHEADER": "Produkte und deren Apps verwalten", "DETAIL.SUBHEADER": "Produkt Details", - "LOAD_ERROR": "Produkt konnte nicht geladen werden", - "NOT_FOUND": "Produkt nicht gefunden", "TABS": { "APPS": "Apps", "INTERN": "Intern", @@ -172,7 +183,6 @@ "VALIDATION": { "FORM_INVALID": "Die Daten sind nicht bereit zum Speichern.", "PRODUCT.UNIQUE_CONSTRAINT": "Ein Produkt mit diesem Namen existiert bereits.", - "PRODUCT.NOT_EXISTS": "Ein Produkt mit diesem Namen konnte nicht gefunden werden.", "PRODUCT.INVALID_NAME": "Dieser Namen kann nicht verwendet werden.", "ERRORS": { "PARSE_ERROR": "Parserfehler: Die enthaltene Struktur entspricht nicht dem erwarteten Format.", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 9950c72..1cb80a7 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -80,6 +80,19 @@ "VIEW_MODE_LIST": "List view", "VIEW_MODE_TABLE": "Table view" }, + "SEARCH": { + "NOT_FOUND": "No data found", + "APP": { + "PRODUCT.NOT_EXISTS": "An App with this name could not be found.", + "LOAD_ERROR": "Failed to load App", + "NOT_FOUND": "App was not found" + }, + "PRODUCT": { + "PRODUCT.NOT_EXISTS": "A Product with this name could not be found.", + "LOAD_ERROR": "Failed to load Product", + "NOT_FOUND": "Product was not found" + } + }, "CANCEL": "Cancel", "CHOOSE": "Choose", "SAVE": "Save", @@ -119,8 +132,6 @@ "SEARCH.HEADER": "Product Store", "SEARCH.SUBHEADER": "Viewing and Managing Products and their Apps", "DETAIL.SUBHEADER": "Product Details", - "LOAD_ERROR": "Failed to load Product", - "NOT_FOUND": "Product was not found", "TABS": { "APPS": "Apps", "INTERN": "Internal", @@ -176,7 +187,6 @@ "VALIDATION": { "FORM_INVALID": "The data are not ready to store.", "PRODUCT.UNIQUE_CONSTRAINT": "A Product with this name exists already.", - "PRODUCT.NOT_EXISTS": "A product with this name could not be found.", "PRODUCT.INVALID_NAME": "This name is a reserved term and cannot be used.", "ERRORS": { "PARSE_ERROR": "Parse error: The contained structure does not match the expected format.", diff --git a/src/assets/silent-check-sso.html b/src/assets/silent-check-sso.html index ffe492c..d243dec 100644 --- a/src/assets/silent-check-sso.html +++ b/src/assets/silent-check-sso.html @@ -1,4 +1,8 @@ - + + + + Post Message +