From 265b7cb2c327fea39e3b7cbc3a68a71dd6503835 Mon Sep 17 00:00:00 2001 From: Floris Thijssen Date: Mon, 21 Oct 2024 10:09:59 +0200 Subject: [PATCH] work on file generation --- backend/app/.env.properties | 31 +++++ backend/app/build.gradle | 15 +++ .../app.pluginconfig.json | 65 +++++++++ backend/plugin/build.gradle | 3 + .../xential/domain/DocumentCreatedMessage.kt | 10 ++ .../valtimo/xential/domain/FileFormat.kt | 5 + .../domain/GenerateDocumentProperties.kt | 5 +- .../valtimo/xential/domain/XentialToken.kt | 2 + .../valtimo/xential/plugin/XentialPlugin.kt | 16 ++- .../service/DocumentGenerationService.kt | 92 +++++++++++++ .../xential/web/rest/DocumentResource.kt | 31 +++++ .../changelog/20241010-add-xential_tokens.xml | 1 + .../xential-configuration.component.html | 28 ++++ .../xential-configuration.component.ts | 127 ++++++++++++------ .../valtimo/xential/src/lib/models/config.ts | 2 + .../src/lib/xential-plugin.specification.ts | 6 + 16 files changed, 392 insertions(+), 47 deletions(-) create mode 100644 backend/app/.env.properties create mode 100644 backend/app/src/main/resources/config/plugin-configurations/app.pluginconfig.json create mode 100644 backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/DocumentCreatedMessage.kt create mode 100644 backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/FileFormat.kt create mode 100644 backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/web/rest/DocumentResource.kt diff --git a/backend/app/.env.properties b/backend/app/.env.properties new file mode 100644 index 0000000..e1c94f0 --- /dev/null +++ b/backend/app/.env.properties @@ -0,0 +1,31 @@ +# This file with secrets has been made public for demonstration purposes. + +VALTIMO_PLUGIN_ENCRYPTION-SECRET=abcdefghijklmnop +VALTIMO_CONNECTOR-ENCRYPTION_SECRET=0123456789101112 + +SPRING_DATASOURCE_PASSWORD=password +SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAKAPI_CLIENT-SECRET=6ef6ca16-6b86-482a-a3d9-0561704c1db9 + +VALTIMO_API_URL=http://host.docker.internal:8080/api/v1/ +ZAKEN_API_URL=http://localhost:8001/zaken/api/v1/ +BESLUITEN_API_URL=http://localhost:8001/besluiten/api/v1/ +CATALOGI_API_URL=http://localhost:8001/catalogi/api/v1/ +DOCUMENTEN_API_URL=http://localhost:8001/documenten/api/v1/ +NOTIFICATIES_API_URL=http://localhost:8002/api/v1/ +OBJECTEN_API_URL=http://localhost:8010/api/v2/ +OBJECTTYPEN_API_URL=http://localhost:8011/api/v1/ + +OPEN_ZAAK_CLIENT_ID=valtimo_client +OPEN_ZAAK_CLIENT_SECRET=e09b8bc5-5831-4618-ab28-41411304309d + +OPEN_NOTIFICATIES_CLIENT_ID=valtimo +OPEN_NOTIFICATIES_CLIENT_SECRET=zZ!xRP&$qTn4A9ETa^ZMKepDm^8egjPz + +OBJECTEN_API_TOKEN=182c13e2209161852c53cef53a879f7a2f923430 +OBJECTTYPEN_API_TOKEN=cd63e158f3aca276ef284e3033d020a22899c728 + +SMART_DOCUMENTS_URL=https://example.com/ +SMART_DOCUMENTS_USERNAME=test-user +SMART_DOCUMENTS_PASSWORD=test-password + +VALTIMO_OPENKLANT_SECRET=e09b8bc5-5831-4618-ab28-41411304309d \ No newline at end of file diff --git a/backend/app/build.gradle b/backend/app/build.gradle index f731534..163fcbd 100644 --- a/backend/app/build.gradle +++ b/backend/app/build.gradle @@ -45,6 +45,8 @@ dependencies { implementation "com.ritense.valtimo:process-document:${valtimoVersion}" implementation "com.ritense.valtimo:plugin:${valtimoVersion}" implementation "com.ritense.valtimo:plugin-valtimo:${valtimoVersion}" + implementation "com.ritense.valtimo:objecten-api-authentication:${valtimoVersion}" + implementation "com.ritense.valtimo:zgw:${valtimoVersion}" implementation "com.ritense.valtimo:web:${valtimoVersion}" implementation "io.github.microutils:kotlin-logging:3.0.5" @@ -55,3 +57,16 @@ dependencies { test { useJUnitPlatform() } + +bootRun { + doFirst { + File f = file(".env.properties") + if (f.isFile()) { + def props = new Properties() + f.withInputStream { props.load(it) } + props.each { key, value -> + environment key.toString(), value.toString() + } + } + } +} diff --git a/backend/app/src/main/resources/config/plugin-configurations/app.pluginconfig.json b/backend/app/src/main/resources/config/plugin-configurations/app.pluginconfig.json new file mode 100644 index 0000000..559780e --- /dev/null +++ b/backend/app/src/main/resources/config/plugin-configurations/app.pluginconfig.json @@ -0,0 +1,65 @@ +[ + { + "id": "b609a0a3-886e-4b3d-ae0d-c01effb311ee", + "title": "OpenZaak Authentication", + "pluginDefinitionKey": "openzaak", + "properties": { + "clientId": "${OPEN_ZAAK_CLIENT_ID}", + "clientSecret": "${OPEN_ZAAK_CLIENT_SECRET}" + } + }, + { + "id": "3079d6fe-42e3-4f8f-a9db-52ce2507b7ee", + "title": "Zaken API", + "pluginDefinitionKey": "zakenapi", + "properties": { + "url": "${ZAKEN_API_URL}", + "authenticationPluginConfiguration": "b609a0a3-886e-4b3d-ae0d-c01effb311ee" + } + }, + { + "id": "5474fe57-532a-4050-8d89-32e62ca3e895", + "title": "Documenten API", + "pluginDefinitionKey": "documentenapi", + "properties": { + "url": "${DOCUMENTEN_API_URL}", + "bronorganisatie": "051845623", + "authenticationPluginConfiguration": "b609a0a3-886e-4b3d-ae0d-c01effb311ee", + "apiVersion": "1.4.3" + } + }, + { + "id": "21a006f9-7833-4cdf-a6b7-1927705dd543", + "title": "Objecten API Authentication", + "pluginDefinitionKey": "objecttokenauthentication", + "properties": { + "token": "${OBJECTEN_API_TOKEN}" + } + }, + { + "id": "b6d83348-97e7-4660-bd35-2e5fcc9629b4", + "title": "Objecten API", + "pluginDefinitionKey": "objectenapi", + "properties": { + "url": "${OBJECTEN_API_URL}", + "authenticationPluginConfiguration": "21a006f9-7833-4cdf-a6b7-1927705dd543" + } + }, + { + "id": "acb0687a-075e-4435-923b-e6cb01d4d5db", + "title": "Objecttypen API Authentication", + "pluginDefinitionKey": "objecttokenauthentication", + "properties": { + "token": "${OBJECTTYPEN_API_TOKEN}" + } + }, + { + "id": "4021bb75-18c8-4ca5-8658-b9f9c728bba0", + "title": "Objecttypen API", + "pluginDefinitionKey": "objecttypenapi", + "properties": { + "url": "${OBJECTTYPEN_API_URL}", + "authenticationPluginConfiguration": "acb0687a-075e-4435-923b-e6cb01d4d5db" + } + } +] diff --git a/backend/plugin/build.gradle b/backend/plugin/build.gradle index 4d43113..c2c5954 100644 --- a/backend/plugin/build.gradle +++ b/backend/plugin/build.gradle @@ -49,6 +49,9 @@ dependencies { implementation "com.ritense.valtimo:plugin-valtimo:${valtimoVersion}" implementation "com.ritense.valtimo:temporary-resource-storage:${valtimoVersion}" implementation "com.ritense.valtimo:value-resolver:${valtimoVersion}" + implementation "com.ritense.valtimo:openzaak-plugin-authentication:${valtimoVersion}" + implementation "com.ritense.valtimo:zaken-api:${valtimoVersion}" + implementation "com.ritense.valtimo:documenten-api:${valtimoVersion}" implementation "org.springframework.boot:spring-boot-starter-webflux:${springVersion}" implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springVersion}" diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/DocumentCreatedMessage.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/DocumentCreatedMessage.kt new file mode 100644 index 0000000..563dcef --- /dev/null +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/DocumentCreatedMessage.kt @@ -0,0 +1,10 @@ +package com.ritense.valtimo.xential.domain + +data class DocumentCreatedMessage( + val taakapplicatie: String, + val gebruiker: String, + val documentCreatieSessieId: String, + val formaat: FileFormat, + val documentkenmerk: String, + val data: String, +) diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/FileFormat.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/FileFormat.kt new file mode 100644 index 0000000..a976592 --- /dev/null +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/FileFormat.kt @@ -0,0 +1,5 @@ +package com.ritense.valtimo.xential.domain + +enum class FileFormat { + WORD, PDF +} diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/GenerateDocumentProperties.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/GenerateDocumentProperties.kt index 606a0e9..d0f55a6 100644 --- a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/GenerateDocumentProperties.kt +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/GenerateDocumentProperties.kt @@ -6,9 +6,6 @@ data class GenerateDocumentProperties( val templateId: UUID, val fileFormat: FileFormat, val documentId: String, + val messageName: String, val templateData: Map ) - -enum class FileFormat { - WORD, PDF -} diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/XentialToken.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/XentialToken.kt index 2ec93ec..dd9eabd 100644 --- a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/XentialToken.kt +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/domain/XentialToken.kt @@ -15,6 +15,8 @@ data class XentialToken ( val token: UUID, @Column(name = "process_id", nullable = false, updatable = false) val processId: UUID, + @Column(name = "message_name", nullable = false, updatable = false) + val messageName: String, @Column(name = "resume_url", nullable = true, updatable = false) val resumeUrl: URI?, ) diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/plugin/XentialPlugin.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/plugin/XentialPlugin.kt index df2e19d..66b3f93 100644 --- a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/plugin/XentialPlugin.kt +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/plugin/XentialPlugin.kt @@ -16,21 +16,25 @@ package com.ritense.valtimo.xential.plugin +import com.ritense.documentenapi.DocumentenApiPlugin +import com.ritense.openzaak.plugin.OpenZaakPlugin import com.ritense.plugin.annotation.Plugin import com.ritense.plugin.annotation.PluginAction import com.ritense.plugin.annotation.PluginProperty import com.ritense.processlink.domain.ActivityTypeWithEventName import com.ritense.valtimo.xential.domain.GenerateDocumentProperties import com.ritense.valtimo.xential.domain.XentialToken +import com.ritense.valtimo.xential.plugin.XentialPlugin.Companion.PLUGIN_KEY import com.ritense.valtimo.xential.repository.XentialTokenRepository import com.ritense.valtimo.xential.service.DocumentGenerationService +import com.ritense.zakenapi.ZakenApiPlugin import com.rotterdam.xential.api.DefaultApi import com.rotterdam.xential.model.Sjabloondata import org.camunda.bpm.engine.delegate.DelegateExecution import java.util.UUID @Plugin( - key = "xential", + key = PLUGIN_KEY, title = "Xential Plugin", description = "" ) @@ -44,6 +48,12 @@ class XentialPlugin( @PluginProperty(key = "clientPassword", secret = true) private lateinit var clientPassword: String + @PluginProperty(key = "documentenApiPluginConfiguration", secret = false) + lateinit var documentenApiPluginConfiguration: DocumentenApiPlugin + + @PluginProperty(key = "zakenApiPluginConfiguration", secret = false) + lateinit var zakenApiPluginConfiguration: ZakenApiPlugin + @PluginAction( key = "generate-document", title = "Generate document", @@ -59,4 +69,8 @@ class XentialPlugin( ) } + companion object { + const val PLUGIN_KEY = "xential" + } + } diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/service/DocumentGenerationService.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/service/DocumentGenerationService.kt index bc987a3..62881d4 100644 --- a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/service/DocumentGenerationService.kt +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/service/DocumentGenerationService.kt @@ -1,16 +1,40 @@ package com.ritense.valtimo.xential.service +import com.ritense.documentenapi.DocumentenApiPlugin +import com.ritense.documentenapi.client.CreateDocumentRequest +import com.ritense.documentenapi.client.DocumentStatusType +import com.ritense.documentenapi.client.DocumentenApiClient +import com.ritense.documentenapi.event.DocumentCreated +import com.ritense.plugin.service.PluginService +import com.ritense.valtimo.xential.domain.DocumentCreatedMessage import com.ritense.valtimo.xential.domain.GenerateDocumentProperties import com.ritense.valtimo.xential.domain.XentialToken +import com.ritense.valtimo.xential.plugin.XentialPlugin import com.ritense.valtimo.xential.repository.XentialTokenRepository +import com.ritense.zakenapi.ZaakUrlProvider +import com.ritense.zakenapi.ZakenApiPlugin +import com.ritense.zakenapi.client.LinkDocumentRequest +import com.ritense.zakenapi.client.ZakenApiClient import com.rotterdam.xential.api.DefaultApi import com.rotterdam.xential.model.Sjabloondata +import org.camunda.bpm.engine.RuntimeService import org.openapitools.client.infrastructure.ApiClient +import org.springframework.context.ApplicationEventPublisher +import org.springframework.security.core.context.SecurityContextHolder +import java.io.ByteArrayInputStream +import java.time.LocalDate +import java.util.Base64 import java.util.UUID class DocumentGenerationService( val defaultApi: DefaultApi, val xentialTokenRepository: XentialTokenRepository, + val pluginService: PluginService, + val documentenApiClient: DocumentenApiClient, + val applicationEventPublisher: ApplicationEventPublisher, + val zaakUrlProvider: ZaakUrlProvider, + val zakenApiClient: ZakenApiClient, + val runtimeService: RuntimeService, ) { fun generateDocument( @@ -37,9 +61,77 @@ class DocumentGenerationService( val xentialToken = XentialToken( token = UUID.fromString(result.documentCreatieSessieId), processId = processId, + messageName = generateDocumentProperties.messageName, resumeUrl = result.resumeUrl ) xentialTokenRepository.save(xentialToken) } + + fun onDocumentGenerated(message: DocumentCreatedMessage) { + val plugin = getXentialPlugin(message) + val documentenApiPlugin = plugin.documentenApiPluginConfiguration + val zakenApiPlugin = plugin.zakenApiPluginConfiguration + + val bytes = Base64.getDecoder().decode(message.data) + + val xentialToken = xentialTokenRepository.findById(UUID.fromString(message.documentCreatieSessieId)) + .orElseThrow { NoSuchElementException("Could not find Xential Token ${message.documentCreatieSessieId}") } + + ByteArrayInputStream(bytes).use { inputStream -> + val createDocumentRequest = CreateDocumentRequest( + bronorganisatie = documentenApiPlugin.bronorganisatie, + creatiedatum = LocalDate.now(), + titel = message.documentkenmerk, + auteur = message.gebruiker, + status = DocumentStatusType.DEFINITIEF, + taal = "nld", + bestandsnaam = message.documentkenmerk, + bestandsomvang = bytes.size.toLong(), + inhoud = inputStream, + beschrijving = "", + ontvangstdatum = LocalDate.now(), + verzenddatum = LocalDate.now(), + informatieobjecttype = null, + formaat = message.formaat.name, + ) + + val documentCreateResult = documentenApiClient.storeDocument( + documentenApiPlugin.authenticationPluginConfiguration, + documentenApiPlugin.url, + createDocumentRequest + ) + val event = DocumentCreated( + documentCreateResult.url, + documentCreateResult.auteur, + documentCreateResult.bestandsnaam, + documentCreateResult.bestandsomvang, + documentCreateResult.beginRegistratie + ) + applicationEventPublisher.publishEvent(event) + + val zaakUrl = zaakUrlProvider.getZaakUrl(xentialToken.processId) + zakenApiClient.linkDocument( + zakenApiPlugin.authenticationPluginConfiguration, + zakenApiPlugin.url, + LinkDocumentRequest( + documentCreateResult.url, + zaakUrl.toString(), + message.documentkenmerk, + "" + ) + ) + + runtimeService.createMessageCorrelation(xentialToken.messageName) + .processInstanceId(xentialToken.processId.toString()) + .correlate() + } + } + + private fun getXentialPlugin(message: DocumentCreatedMessage): XentialPlugin { + //FIXME needs a way of determining the right plugin + val pluginConfig = pluginService.findPluginConfiguration(XentialPlugin.PLUGIN_KEY) { _ -> true} + ?: throw NoSuchElementException("Could not find Xential plugin") + return pluginService.createInstance(pluginConfig) as XentialPlugin + } } diff --git a/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/web/rest/DocumentResource.kt b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/web/rest/DocumentResource.kt new file mode 100644 index 0000000..e2ad871 --- /dev/null +++ b/backend/plugin/src/main/kotlin/com/ritense/valtimo/xential/web/rest/DocumentResource.kt @@ -0,0 +1,31 @@ +package com.ritense.valtimo.xential.web.rest + +import com.fasterxml.jackson.databind.JsonNode +import com.ritense.valtimo.contract.annotation.SkipComponentScan +import com.ritense.valtimo.contract.domain.ValtimoMediaType +import com.ritense.valtimo.xential.domain.DocumentCreatedMessage +import com.ritense.valtimo.xential.service.DocumentGenerationService +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController +import java.util.UUID + +@RestController +@SkipComponentScan +@RequestMapping("/api/xential", produces = [ValtimoMediaType.APPLICATION_JSON_UTF8_VALUE]) +class DocumentResource( + val documentGenerationService: DocumentGenerationService +) { + + @PostMapping("/v1/document") + fun handleSubmission( + @RequestBody message: DocumentCreatedMessage + ) { + documentGenerationService.onDocumentGenerated(message) + } + +} diff --git a/backend/plugin/src/main/resources/config/liquibase/changelog/20241010-add-xential_tokens.xml b/backend/plugin/src/main/resources/config/liquibase/changelog/20241010-add-xential_tokens.xml index 0b9992f..1c6e952 100644 --- a/backend/plugin/src/main/resources/config/liquibase/changelog/20241010-add-xential_tokens.xml +++ b/backend/plugin/src/main/resources/config/liquibase/changelog/20241010-add-xential_tokens.xml @@ -26,6 +26,7 @@ + diff --git a/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.html b/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.html index a0a4fa1..2a4c57c 100644 --- a/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.html +++ b/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.html @@ -44,4 +44,32 @@ [defaultValue]="obs.prefill?.clientPassword" [title]="'clientPassword' | pluginTranslate: pluginId | async"> +
+ + + + diff --git a/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.ts b/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.ts index 9447c80..b2f9e2f 100644 --- a/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.ts +++ b/frontend/projects/valtimo/xential/src/lib/components/xential-configuration/xential-configuration.component.ts @@ -15,60 +15,103 @@ */ import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core'; -import {PluginConfigurationComponent, PluginConfigurationData} from '@valtimo/plugin'; -import {BehaviorSubject, combineLatest, Observable, Subscription, take} from 'rxjs'; +import { + PluginConfigurationComponent, + PluginConfigurationData, + PluginManagementService, + PluginTranslationService +} from '@valtimo/plugin'; +import {BehaviorSubject, combineLatest, map, Observable, Subscription, take} from 'rxjs'; import {XentialConfig} from '../../models'; +import {TranslateService} from "@ngx-translate/core"; @Component({ - selector: 'valtimo-xential-configuration', - templateUrl: './xential-configuration.component.html', + selector: 'valtimo-xential-configuration', + templateUrl: './xential-configuration.component.html', }) export class XentialConfigurationComponent - implements PluginConfigurationComponent, OnInit, OnDestroy -{ - @Input() save$!: Observable; - @Input() disabled$!: Observable; - @Input() pluginId!: string; - @Input() prefillConfiguration$!: Observable; - @Output() valid: EventEmitter = new EventEmitter(); - @Output() configuration: EventEmitter = new EventEmitter(); + implements PluginConfigurationComponent, OnInit, OnDestroy { + @Input() save$!: Observable; + @Input() disabled$!: Observable; + @Input() pluginId!: string; + @Input() prefillConfiguration$!: Observable; + @Output() valid: EventEmitter = new EventEmitter(); + @Output() configuration: EventEmitter = new EventEmitter(); - constructor( - ) {} + private saveSubscription!: Subscription; + private readonly formValue$ = new BehaviorSubject(null); + private readonly valid$ = new BehaviorSubject(false); - private saveSubscription!: Subscription; - private readonly formValue$ = new BehaviorSubject(null); - private readonly valid$ = new BehaviorSubject(false); + readonly zakenApiPluginSelectItems$: Observable> = + combineLatest([ + this.pluginManagementService.getPluginConfigurationsByPluginDefinitionKey('zakenapi'), + this.translateService.stream('key'), + ]).pipe( + map(([configurations]) => + configurations.map(configuration => ({ + id: configuration.id, + text: `${configuration.title} - ${this.pluginTranslationService.instant( + 'title', + configuration.pluginDefinition.key + )}`, + })) + ) + ); - ngOnInit(): void { - this.openSaveSubscription(); - } - ngOnDestroy() { - this.saveSubscription?.unsubscribe(); - } + readonly documentenApiPluginSelectItems$: Observable> = + combineLatest([ + this.pluginManagementService.getPluginConfigurationsByPluginDefinitionKey('documentenapi'), + this.translateService.stream('key'), + ]).pipe( + map(([configurations]) => + configurations.map(configuration => ({ + id: configuration.id, + text: `${configuration.title} - ${this.pluginTranslationService.instant( + 'title', + configuration.pluginDefinition.key + )}`, + })) + ) + ); - formValueChange(formValue: XentialConfig): void { - this.formValue$.next(formValue); - this.handleValid(formValue); - } + constructor( + private readonly pluginManagementService: PluginManagementService, + private readonly translateService: TranslateService, + private readonly pluginTranslationService: PluginTranslationService + ) { + } - private handleValid(formValue: XentialConfig): void { - const valid = !!(formValue); - this.valid$.next(valid); - this.valid.emit(valid); - } + ngOnInit(): void { + this.openSaveSubscription(); + } - private openSaveSubscription(): void { - this.saveSubscription = this.save$?.subscribe(save => { - combineLatest([this.formValue$, this.valid$]) - .pipe(take(1)) - .subscribe(([formValue, valid]) => { - if (valid) { - this.configuration.emit(formValue!); - } + ngOnDestroy() { + this.saveSubscription?.unsubscribe(); + } + + formValueChange(formValue: XentialConfig): void { + this.formValue$.next(formValue); + this.handleValid(formValue); + } + + private handleValid(formValue: XentialConfig): void { + const valid = !!(formValue); + + this.valid$.next(valid); + this.valid.emit(valid); + } + + private openSaveSubscription(): void { + this.saveSubscription = this.save$?.subscribe(save => { + combineLatest([this.formValue$, this.valid$]) + .pipe(take(1)) + .subscribe(([formValue, valid]) => { + if (valid) { + this.configuration.emit(formValue!); + } + }); }); - }); - } + } } diff --git a/frontend/projects/valtimo/xential/src/lib/models/config.ts b/frontend/projects/valtimo/xential/src/lib/models/config.ts index 34a3245..58d8f78 100644 --- a/frontend/projects/valtimo/xential/src/lib/models/config.ts +++ b/frontend/projects/valtimo/xential/src/lib/models/config.ts @@ -19,6 +19,8 @@ import {PluginConfigurationData} from '@valtimo/plugin'; interface XentialConfig extends PluginConfigurationData { clientId: string; clientPassword: string; + zakenApiPluginConfiguration: string; + documentenApiPluginConfiguration: string } export {XentialConfig}; diff --git a/frontend/projects/valtimo/xential/src/lib/xential-plugin.specification.ts b/frontend/projects/valtimo/xential/src/lib/xential-plugin.specification.ts index 539f741..2eda4c2 100644 --- a/frontend/projects/valtimo/xential/src/lib/xential-plugin.specification.ts +++ b/frontend/projects/valtimo/xential/src/lib/xential-plugin.specification.ts @@ -40,6 +40,8 @@ const XentialPluginSpecification: PluginSpecification = { fileFormat: 'Bestandsformaat', documentId: 'Document kenmerk', templateData: 'Sjabloon vuldata', + zakenApiPluginConfiguration: "Zaken API plugin", + documentenApiPluginConfiguration: "documenten API plugin", }, en: { title: 'Xential', @@ -52,6 +54,8 @@ const XentialPluginSpecification: PluginSpecification = { fileFormat: 'File format', documentId: 'Document ID', templateData: 'Template data', + zakenApiPluginConfiguration: "Zaken API plugin", + documentenApiPluginConfiguration: "documenten API plugin", }, de: { title: 'Xential', @@ -64,6 +68,8 @@ const XentialPluginSpecification: PluginSpecification = { fileFormat: 'Dateiformat', documentId: 'Dokument-ID', templateData: 'Vorlagendaten', + zakenApiPluginConfiguration: "Zaken API plugin", + documentenApiPluginConfiguration: "documenten API plugin", }, }, };