Skip to content

Commit

Permalink
feat: updated pia (#12)
Browse files Browse the repository at this point in the history
* feat: updated pia

* fix: tests
  • Loading branch information
JordenReuter authored May 27, 2024
1 parent 179c7bd commit 72385a8
Show file tree
Hide file tree
Showing 15 changed files with 1,691 additions and 1,701 deletions.
3,226 changes: 1,619 additions & 1,607 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@
"@ngneat/falso": "^6.4.0",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@onecx/accelerator": "^4.5.1",
"@onecx/integration-interface": "^4.5.1",
"@onecx/keycloak-auth": "^4.5.1",
"@onecx/portal-integration-angular": "^4.5.1",
"@onecx/portal-layout-styles": "^4.5.1",
"@onecx/accelerator": "^4.23.0",
"@onecx/integration-interface": "^4.23.0",
"@onecx/keycloak-auth": "^4.23.0",
"@onecx/portal-integration-angular": "^4.23.0",
"@onecx/portal-layout-styles": "^4.23.0",
"keycloak-angular": "^13.1.0",
"@ngrx/router-store": "^15.4.0",
"@ngrx/effects": "^15.4.0",
"file-saver": "^2.0.5",
"i18n-iso-countries": "^7.6.0",
"ngx-color": "^8.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { ParameterCreateComponent } from './parameter-create.component'
import { RouterTestingModule } from '@angular/router/testing'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
import { MessageService } from 'primeng/api'
import { APP_CONFIG } from '@onecx/portal-integration-angular'
import { APP_CONFIG, PortalMessageService } from '@onecx/portal-integration-angular'
import { TranslateServiceMock } from '../../../shared/TranslateServiceMock'
import { environment } from '../../../../environments/environment'
import { SharedModule } from '../../../shared/shared.module'
Expand All @@ -21,7 +20,7 @@ describe('ParameterCreateComponent', () => {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: TranslateService, useClass: TranslateServiceMock },
{ provide: MessageService, useClass: MessageService },
{ provide: PortalMessageService, useClass: PortalMessageService },
{ provide: APP_CONFIG, useValue: environment }
]
}).compileComponents()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, OnInit, ViewChild } from '@angular/core'

import { MessageService } from 'primeng/api'
import { ParameterDetailFormComponent } from '../parameter-detail-form/parameter-detail-form.component'
import { TranslateService } from '@ngx-translate/core'
import { ApplicationParameterCreate, ParametersAPIService } from 'src/app/shared/generated'
import { PortalMessageService } from '@onecx/angular-integration-interface'

@Component({
selector: 'app-parameter-create',
Expand All @@ -17,7 +17,7 @@ export class ParameterCreateComponent implements OnInit {
public translatedData: Record<string, string> | undefined

constructor(
private readonly messageService: MessageService,
private readonly messageService: PortalMessageService,
private readonly translateService: TranslateService,
private readonly parametersApiService: ParametersAPIService
) {}
Expand All @@ -29,15 +29,13 @@ export class ParameterCreateComponent implements OnInit {
public onSubmit(parameterCreate: ApplicationParameterCreate): void {
this.parametersApiService.createParameterValue({ applicationParameterCreate: parameterCreate }).subscribe(
() => {
this.messageService.add({
severity: 'success',
summary: this.translatedData!['CREATE.CREATE_SUCCESS']
this.messageService.success({
data: this.translatedData!['CREATE.CREATE_SUCCESS']
})
},
() => {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['CREATE.CREATE_ERROR']
this.messageService.error({
data: this.translatedData!['CREATE.CREATE_ERROR']
})
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { RouterTestingModule } from '@angular/router/testing'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { APP_CONFIG } from '@onecx/portal-integration-angular'
import { MessageService } from 'primeng/api'
import { APP_CONFIG, PortalMessageService } from '@onecx/portal-integration-angular'
import { TranslateServiceMock } from '../../../shared/TranslateServiceMock'
import { environment } from '../../../../environments/environment'

Expand All @@ -22,7 +21,7 @@ describe('ParameterDetailFormComponent', () => {
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: TranslateService, useClass: TranslateServiceMock },
{ provide: MessageService, useClass: MessageService },
{ provide: PortalMessageService, useClass: PortalMessageService },
{ provide: APP_CONFIG, useValue: environment }
]
}).compileComponents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'
import { ActivatedRoute } from '@angular/router'
import { TranslateService } from '@ngx-translate/core'
import { PortalMessageService } from '@onecx/portal-integration-angular'

import { MessageService } from 'primeng/api'
import { finalize } from 'rxjs'
import {
ApplicationParameter,
Expand Down Expand Up @@ -40,7 +40,7 @@ export class ParameterDetailFormComponent implements OnInit {
constructor(
private readonly route: ActivatedRoute,
private readonly fb: UntypedFormBuilder,
private readonly messageService: MessageService,
private readonly messageService: PortalMessageService,
private readonly translateService: TranslateService,
private readonly paramterApiService: ParametersAPIService,
private readonly paramtersHistoryApiService: HistoriesAPIService
Expand Down Expand Up @@ -76,9 +76,8 @@ export class ParameterDetailFormComponent implements OnInit {

public emitFormCreate(): void {
if (!this.isValidValueType()) {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['DETAILS.VALUE_HAS_WRONG_TYPE']
this.messageService.error({
data: this.translatedData!['DETAILS.VALUE_HAS_WRONG_TYPE']
})
} else if (this.parameterForm.valid) {
let parameter: ApplicationParameterCreate = {
Expand Down Expand Up @@ -146,9 +145,8 @@ export class ParameterDetailFormComponent implements OnInit {
this.loadChartData()
},
error: () => {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['SEARCH.MSG_SEARCH_FAILED']
this.messageService.error({
data: this.translatedData!['SEARCH.MSG_SEARCH_FAILED']
})
}
})
Expand All @@ -167,9 +165,8 @@ export class ParameterDetailFormComponent implements OnInit {
this.parameterHistoryArray = results.stream as any[]
},
error: () => {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['SEARCH.MSG_SEARCH_FAILED']
this.messageService.error({
data: this.translatedData!['SEARCH.MSG_SEARCH_FAILED']
})
}
})
Expand All @@ -183,10 +180,8 @@ export class ParameterDetailFormComponent implements OnInit {
}
})
if (errors.length > 0) {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['DETAILS.FORM_MANDATORY'],
detail: errors.join(', ')
this.messageService.error({
data: this.translatedData!['DETAILS.FORM_MANDATORY']
})
}
}
Expand Down Expand Up @@ -271,16 +266,14 @@ export class ParameterDetailFormComponent implements OnInit {
this.chartData = data
this.setChartData()
if (data.length == 0) {
this.messageService.add({
severity: 'success',
summary: this.translatedData!['SEARCH.MSG_NO_RESULTS']
this.messageService.success({
data: this.translatedData!['SEARCH.MSG_NO_RESULTS']
})
}
},
error: () => {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['SEARCH.MSG_SEARCH_FAILED']
this.messageService.error({
data: this.translatedData!['SEARCH.MSG_SEARCH_FAILED']
})
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, OnInit, ViewChild } from '@angular/core'
import { ParameterDetailFormComponent } from '../parameter-detail-form/parameter-detail-form.component'
import { MessageService } from 'primeng/api'
import { TranslateService } from '@ngx-translate/core'
import { ParametersAPIService } from 'src/app/shared/generated'
import { PortalMessageService } from '@onecx/angular-integration-interface'

@Component({
selector: 'app-parameter-detail',
Expand All @@ -16,7 +16,7 @@ export class ParameterDetailComponent implements OnInit {
public translatedData: Record<string, string> | undefined

constructor(
private readonly messageService: MessageService,
private readonly messageService: PortalMessageService,
private readonly translateService: TranslateService,
private readonly parametersApiService: ParametersAPIService
) {}
Expand All @@ -28,16 +28,14 @@ export class ParameterDetailComponent implements OnInit {
public onSubmit(parameterWrapper: any): void {
this.parametersApiService.updateParameterValue(parameterWrapper.id, parameterWrapper.parameter).subscribe(
() => {
this.messageService.add({
severity: 'success',
summary: this.translatedData!['EDIT.UPDATE_SUCCESS']
this.messageService.success({
data: this.translatedData!['EDIT.UPDATE_SUCCESS']
})
this.parameterDetailFormComponent?.switchMode()
},
() => {
this.messageService.add({
severity: 'error',
summary: this.translatedData!['EDIT.UPDATE_ERROR']
this.messageService.error({
data: this.translatedData!['EDIT.UPDATE_ERROR']
})
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { MessageService } from 'primeng/api'

import { CriteriaComponent } from './criteria.component'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { RouterTestingModule } from '@angular/router/testing'
import { APP_CONFIG } from '@onecx/portal-integration-angular'
import { APP_CONFIG, PortalMessageService, providePortalDialogService } from '@onecx/portal-integration-angular'
import { TranslateServiceMock } from '../../../shared/TranslateServiceMock'
import { environment } from '../../../../environments/environment'
import { SharedModule } from '../../../shared/shared.module'
import { DialogService } from 'primeng/dynamicdialog'

describe('CriteriaComponent', () => {
let component: CriteriaComponent
Expand All @@ -21,9 +19,9 @@ describe('CriteriaComponent', () => {
imports: [HttpClientTestingModule, TranslateModule, RouterTestingModule, SharedModule],
providers: [
{ provide: TranslateService, useClass: TranslateServiceMock },
{ provide: DialogService, useClass: DialogService },
{ provide: APP_CONFIG, useValue: environment },
MessageService
PortalMessageService,
providePortalDialogService()
]
}).compileComponents()
}))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'
import { TranslateService } from '@ngx-translate/core'
import { MessageService, SelectItem } from 'primeng/api'
import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog'
import { SelectItem } from 'primeng/api'
import { DynamicDialogRef } from 'primeng/dynamicdialog'
import { ApplicationParameter, ApplicationParameterHistoryCriteria } from 'src/app/shared/generated'
import { ParameterListComponent } from './parameter-list.component'
import { Action } from '@onecx/portal-integration-angular'
import { Action, PortalDialogService, PortalMessageService } from '@onecx/portal-integration-angular'

@Component({
selector: 'app-criteria',
Expand All @@ -32,9 +32,9 @@ export class CriteriaComponent implements OnInit, OnDestroy {

constructor(
private readonly fb: UntypedFormBuilder,
private readonly messageService: MessageService,
private readonly messageService: PortalMessageService,
private translateService: TranslateService,
public dialogService: DialogService
public dialogService: PortalDialogService
) {}

public ngOnInit(): void {
Expand All @@ -57,9 +57,8 @@ export class CriteriaComponent implements OnInit, OnDestroy {
console.log('criteria submit')

if (this.criteriaGroup.controls['applicationId'].invalid) {
this.messageService.add({
severity: 'error',
summary: this.translatedData['SEARCH.APPLICATION_ID_IS_MANDATORY']
this.messageService.error({
detailParameters: this.translatedData['SEARCH.APPLICATION_ID_IS_MANDATORY']
})
return
}
Expand Down
25 changes: 10 additions & 15 deletions src/app/parameter/parameter-search/parameter-search.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { provideParent, PortalSearchPage, Action } from '@onecx/portal-integration-angular'
import { provideParent, PortalSearchPage, Action, PortalMessageService } from '@onecx/portal-integration-angular'

import { MessageService } from 'primeng/api'
import { finalize, map, tap } from 'rxjs/operators'
import { CriteriaComponent } from './criteria/criteria.component'
import { Observable } from 'rxjs'
Expand All @@ -29,7 +28,7 @@ export class ParameterSearchComponent extends PortalSearchPage<ApplicationParame
criteriaComponent: CriteriaComponent | undefined

constructor(
private readonly messageService: MessageService,
private readonly messageService: PortalMessageService,
private translateService: TranslateService,
private readonly parametersApi: ParametersAPIService,
private router: Router,
Expand All @@ -50,17 +49,15 @@ export class ParameterSearchComponent extends PortalSearchPage<ApplicationParame
tap({
next: (data: any) => {
if (data.totalElements == 0) {
this.messageService.add({
severity: 'success',
summary: this.translatedData['SEARCH.MSG_NO_RESULTS']
this.messageService.success({
data: this.translatedData['SEARCH.MSG_NO_RESULTS']
})
return data.size
}
},
error: () => {
this.messageService.add({
severity: 'error',
summary: this.translatedData['SEARCH.MSG_SEARCH_FAILED']
this.messageService.error({
data: this.translatedData['SEARCH.MSG_SEARCH_FAILED']
})
}
}),
Expand All @@ -84,16 +81,14 @@ export class ParameterSearchComponent extends PortalSearchPage<ApplicationParame
public deleteParameter(id: string): void {
this.parametersApi.deleteParameter({ id }).subscribe(
() => {
this.messageService.add({
severity: 'success',
summary: this.translatedData['PARAMETER_DELETE.DELETE_SUCCESS']
this.messageService.success({
data: this.translatedData['PARAMETER_DELETE.DELETE_SUCCESS']
})
this.searchData(this.criteria!)
},
() => {
this.messageService.add({
severity: 'error',
summary: this.translatedData['PARAMETER_DELETE.DELETE_ERROR']
this.messageService.error({
data: this.translatedData['PARAMETER_DELETE.DELETE_ERROR']
})
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
*ocxIfPermission="'PARAMETER#VIEW'"
[id]="'parameter_search_table_row_' + results + '_view_action'"
[routerLink]="['./edit', results.id]"
[title]="'ACTIONS.DELETE.PARAMETER.TOOLTIP' | translate"
[title]="'PARAMETER.DELETE.PARAMETER.TOOLTIP' | translate"
class="my-0 p-1 p-button-rounded font-medium p-button-text p-button p-component p-button-icon-only"
>
<span class="text-primary font-medium p-button-icon pi pi-pencil" aria-hidden="true"></span>
Expand All @@ -98,7 +98,7 @@
*ocxIfPermission="'PARAMETER#DELETE'"
[id]="'parameter_search_table_row_' + results + '_delete_action'"
(click)="deleteDialogVisible = true; setSelectedParameter(results)"
[title]="'ACTIONS.DELETE.PARAMETER.TOOLTIP' | translate"
[title]="'PARAMETER.DELETE.PARAMETER.TOOLTIP' | translate"
class="my-0 p-1 p-button-rounded font-medium p-button-text p-button p-component p-button-icon-only"
>
<span class="danger-action-text font-medium p-button-icon pi pi-trash" aria-hidden="true"></span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'
import { ReactiveFormsModule } from '@angular/forms'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { MessageService } from 'primeng/api'
import { ResultsComponent } from './results.component'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { TranslateServiceMock } from '../../../shared/TranslateServiceMock'
import { APP_CONFIG } from '@onecx/portal-integration-angular'
import { APP_CONFIG, PortalMessageService } from '@onecx/portal-integration-angular'
import { environment } from '../../../../environments/environment'
import { SharedModule } from '../../../shared/shared.module'

Expand All @@ -20,7 +19,7 @@ describe('ResultsComponent', () => {
providers: [
{ provide: APP_CONFIG, useValue: environment },
{ provide: TranslateService, useClass: TranslateServiceMock },
{ provide: MessageService, useClass: MessageService }
{ provide: PortalMessageService, useClass: PortalMessageService }
]
}).compileComponents()
}))
Expand Down
Loading

0 comments on commit 72385a8

Please sign in to comment.