Skip to content

Commit

Permalink
fix: minor code issues
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryT-CG committed Jan 22, 2024
1 parent a21d73b commit 0ac5eb2
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file removed src/app/app.component.scss
Empty file.
3 changes: 1 addition & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class ProductDetailComponent implements OnInit {
}
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) {
Expand All @@ -225,7 +225,7 @@ export class ProductDetailComponent implements OnInit {
this.close()
} else {
this.getProduct()
this.changeMode === 'VIEW'
this.changeMode = 'VIEW'
this.prepareTranslations()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,79 +72,3 @@
</div>
</div>
</div>

<!--
<div class="surface-section grid grid-nogutter">
<div class="col-12 md:col-6">
<div class="col-12 md:col-6 p-3">
<span class="p-float-label">
<input
pInputText
type="text"
readonly
id="portal_detail_item_creationDate"
class="w-full pt-3 pb-2"
[value]="product?.creationDate | date : dateFormat"
[pTooltip]="'INTERNAL.TOOLTIPS.CREATION_DATE' | translate"
tooltipPosition="top"
tooltipEvent="focus"
/>
<label for="portal_detail_item_creationDate">{{ 'INTERNAL.CREATION_DATE' | translate }}</label>
</span>
</div>
<div class="col-12 md:col-6 p-3">
<span class="p-float-label">
<input
pInputText
type="text"
readonly
id="portal_detail_item_creationUser"
class="w-full pt-3 pb-2"
[value]="product?.creationUser"
[pTooltip]="'INTERNAL.TOOLTIPS.CREATION_USER' | translate"
tooltipPosition="top"
tooltipEvent="focus"
/>
<label for="portal_detail_item_creationUser">{{ 'INTERNAL.CREATION_USER' | translate }}</label>
</span>
</div>
</div>
<div class="col-12 md:col-6">
<div class="col-12 md:col-3 p-3">
<span class="p-float-label">
<input
pInputText
type="text"
readonly
id="portal_detail_item_modificationDate"
class="w-full pt-3 pb-2"
[value]="product?.modificationDate | date : dateFormat"
[pTooltip]="'INTERNAL.TOOLTIPS.MODIFICATION_DATE' | translate"
tooltipPosition="top"
tooltipEvent="focus"
/>
<label for="portal_detail_item_modificationDate">{{ 'INTERNAL.MODIFICATION_DATE' | translate }}</label>
</span>
</div>
<div class="col-12 md:col-3 p-3">
<span class="p-float-label">
<input
pInputText
type="text"
readonly
id="portal_detail_item_modificationUser"
class="w-full pt-3 pb-2"
[value]="product?.modificationUser"
[pTooltip]="'INTERNAL.TOOLTIPS.MODIFICATION_USER' | translate"
tooltipPosition="top"
tooltipEvent="focus"
/>
<label for="portal_detail_item_modificationUser">{{ 'INTERNAL.MODIFICATION_USER' | translate }}</label>
</span>
</div>
</div>
</div>
-->
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
},
Expand All @@ -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 && err.error.errorCode && 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
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/can-active-guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DEFAULT_LANG = 'en'
export class CanActivateGuard implements CanActivate {
constructor(private txService: TranslateService, private config: ConfigurationService) {}

/* eslint-disable @typescript-eslint/no-unused-vars */ /* TODO: is route and state needed */
/* eslint-disable @typescript-eslint/no-unused-vars */
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ImageContainerComponent implements OnChanges {

// if image Url does not start with a http the api-prefix ...
// ...then it stored in the backend. So we need to put prefix in front
if (this.imageUrl && !this.imageUrl.match(/^(http|https)/g) && this.imageUrl.indexOf(this.apiPrefix) !== 0) {
if (this.imageUrl && !this.imageUrl.match(/^(http|https)/g) && !this.imageUrl.startsWith(this.apiPrefix)) {
this.imageUrl = this.apiPrefix + this.imageUrl
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/label.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/r
import { TranslateService } from '@ngx-translate/core'
import { Observable } from 'rxjs'

//dont use `providedIn root` - wont work when we are in shell
// don't use 'providedIn root' - wont work when we are in shell
@Injectable()
export class LabelResolver implements Resolve<string> {
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<string> | Promise<string> {
return route.data['breadcrumb'] ? this.translate.instant(route.data['breadcrumb']) : route.routeConfig?.path
}
Expand Down
6 changes: 5 additions & 1 deletion src/assets/silent-check-sso.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Post Message</title>
</head>
<body>
<script>
parent.postMessage(location.href, location.origin)
Expand Down
9 changes: 0 additions & 9 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,3 @@ export const environment = {
skipRemoteConfigLoad: true,
apiPrefix: 'product-store-bff'
}

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.

0 comments on commit 0ac5eb2

Please sign in to comment.