From bd06df58c52f0fac6e273952a8c8be69780ed1f2 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 14 May 2024 14:36:45 +0300 Subject: [PATCH 1/5] fix notification --- .gitignore | 2 ++ .../main/resources/logging/logback-dev.xml | 4 --- .../resources/config/notification-devel.yml | 2 +- .../main/resources/logging/logback-dev.xml | 4 --- .../MessageBuilderServiceImpl.java | 27 +++++++++++-------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 163f4068e..291bc8d8d 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ backend/target/classes/ backend/core/target/maven-archiver/ backend/node_modules/.yarn-integrity dmp-frontend/.nx/ +notification-service/notification-web/src/main/resources/config/app.env +backend/web/src/main/resources/config/app.env diff --git a/annotation-service/annotation-web/src/main/resources/logging/logback-dev.xml b/annotation-service/annotation-web/src/main/resources/logging/logback-dev.xml index 0aaad5f31..e304c45df 100644 --- a/annotation-service/annotation-web/src/main/resources/logging/logback-dev.xml +++ b/annotation-service/annotation-web/src/main/resources/logging/logback-dev.xml @@ -46,10 +46,6 @@ - - - - diff --git a/notification-service/notification-web/src/main/resources/config/notification-devel.yml b/notification-service/notification-web/src/main/resources/config/notification-devel.yml index 788f40ec3..d63b07d14 100644 --- a/notification-service/notification-web/src/main/resources/config/notification-devel.yml +++ b/notification-service/notification-web/src/main/resources/config/notification-devel.yml @@ -486,5 +486,5 @@ notification: priority-key: null cipher-fields: [ ] template-cache: - prefix: ${CACHE_DISAMBIGUATION:} + prefix: ${CACHE_DISAMBIGUATION} key-pattern: "{prefix}:Notification_Message_InApp_Template:{key}:v0" \ No newline at end of file diff --git a/notification-service/notification-web/src/main/resources/logging/logback-dev.xml b/notification-service/notification-web/src/main/resources/logging/logback-dev.xml index 0aaad5f31..e304c45df 100644 --- a/notification-service/notification-web/src/main/resources/logging/logback-dev.xml +++ b/notification-service/notification-web/src/main/resources/logging/logback-dev.xml @@ -46,10 +46,6 @@ - - - - diff --git a/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java b/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java index 22f2b5062..af4138ba5 100644 --- a/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java +++ b/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java @@ -108,20 +108,25 @@ public class MessageBuilderServiceImpl implements MessageInfoBuilderService { if (messageInfo.getTimeZone() == null || messageInfo.getTimeZone().isBlank()) messageInfo.setTimeZone(this.localeService.timezoneName()); if (this.scope.isMultitenant()) { - TenantEntity tenantInfo = this.queryFactory.query(TenantQuery.class) - .isActive(IsActive.Active).firstAs(new BaseFieldSet(TenantEntity._id, TenantEntity._code)); + if (this.scope.isDefaultTenant()) { + TenantEntity tenantInfo = this.queryFactory.query(TenantQuery.class) + .isActive(IsActive.Active).firstAs(new BaseFieldSet(TenantEntity._id, TenantEntity._code)); - if (tenantInfo == null) { - try { - logger.error("Could not retrieve tenant info for notification {} in tenant {}", notification.getId(), scope.getTenant()); - } catch (InvalidApplicationException e) { - throw new RuntimeException(e); + if (tenantInfo == null) { + try { + logger.error("Could not retrieve tenant info for notification {} in tenant {}", notification.getId(), scope.getTenant()); + } catch (InvalidApplicationException e) { + throw new RuntimeException(e); + } + throw new MyForbiddenException(this.errors.getMissingTenant().getCode(), this.errors.getMissingTenant().getMessage()); } - throw new MyForbiddenException(this.errors.getMissingTenant().getCode(), this.errors.getMissingTenant().getMessage()); - } - messageInfo.setTenantId(tenantInfo.getId()); - messageInfo.setTenantCode(tenantInfo.getCode()); + messageInfo.setTenantId(tenantInfo.getId()); + messageInfo.setTenantCode(tenantInfo.getCode()); + } else { + messageInfo.setTenantId(null); + messageInfo.setTenantCode(this.scope.getDefaultTenantCode()); + } } return messageInfo; From a243427b4bb15f0aeed3fbca3e7e824fd622c24a Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 14 May 2024 14:57:20 +0300 Subject: [PATCH 2/5] config changes --- .../main/resources/config/dashboard-devel.yml | 4 +++ .../src/main/resources/config/dashboard.yml | 4 +-- backend/web/src/main/resources/config/db.yml | 12 ++----- .../main/resources/config/elasticsearch.yml | 16 ++++----- .../src/main/resources/config/external.yml | 4 --- .../main/resources/config/logging-devel.yml | 36 +------------------ .../resources/config/notification-devel.yml | 14 ++++++++ .../main/resources/config/notification.yml | 13 ------- .../resources/config/public-api-devel.yml | 10 ++++++ .../src/main/resources/config/public-api.yml | 10 +----- .../src/main/resources/config/security.yml | 4 +-- 11 files changed, 44 insertions(+), 83 deletions(-) create mode 100644 backend/web/src/main/resources/config/dashboard-devel.yml create mode 100644 backend/web/src/main/resources/config/notification-devel.yml create mode 100644 backend/web/src/main/resources/config/public-api-devel.yml diff --git a/backend/web/src/main/resources/config/dashboard-devel.yml b/backend/web/src/main/resources/config/dashboard-devel.yml new file mode 100644 index 000000000..ed280bb46 --- /dev/null +++ b/backend/web/src/main/resources/config/dashboard-devel.yml @@ -0,0 +1,4 @@ +dashboard: + reference-type-counters: + - "7eeffb98-58fb-4921-82ec-e27f32f8e738" + - "5b9c284f-f041-4995-96cc-fad7ad13289c" \ No newline at end of file diff --git a/backend/web/src/main/resources/config/dashboard.yml b/backend/web/src/main/resources/config/dashboard.yml index ed280bb46..8119375cb 100644 --- a/backend/web/src/main/resources/config/dashboard.yml +++ b/backend/web/src/main/resources/config/dashboard.yml @@ -1,4 +1,2 @@ dashboard: - reference-type-counters: - - "7eeffb98-58fb-4921-82ec-e27f32f8e738" - - "5b9c284f-f041-4995-96cc-fad7ad13289c" \ No newline at end of file + reference-type-counters: [] \ No newline at end of file diff --git a/backend/web/src/main/resources/config/db.yml b/backend/web/src/main/resources/config/db.yml index 917ce54bf..d77085af8 100644 --- a/backend/web/src/main/resources/config/db.yml +++ b/backend/web/src/main/resources/config/db.yml @@ -1,9 +1,3 @@ -#database: -# driver-class-name: org.postgresql.Driver -# lock-fail-interval: 120000 -# url: ${DB_URL:} -# username: ${DB_USER:} -# password: ${DB_PASS:} spring: jpa: properties: @@ -19,9 +13,9 @@ spring: physical-strategy: org.opencdmp.data.namingstrategy.PrefixPhysicalNamingStrategy implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy datasource: - url: ${DB_URL:} - username: ${DB_USER:} - password: ${DB_PASS:} + url: ${DB_URL} + username: ${DB_USER} + password: ${DB_PASS} driver-class-name: org.postgresql.Driver hikari: connection-timeout: 30000 diff --git a/backend/web/src/main/resources/config/elasticsearch.yml b/backend/web/src/main/resources/config/elasticsearch.yml index 47c9499a6..6a3f171b6 100644 --- a/backend/web/src/main/resources/config/elasticsearch.yml +++ b/backend/web/src/main/resources/config/elasticsearch.yml @@ -1,10 +1,10 @@ elastic: - enabled: ${ELASTIC_ENABLED:} + enabled: ${ELASTIC_ENABLED} hosts: - - ${ELASTIC_HOST:} - username: ${ELASTIC_USER:} - password: ${ELASTIC_PASS:} - useSSL: ${ELASTIC_USE_SSL:} + - ${ELASTIC_HOST} + username: ${ELASTIC_USER} + password: ${ELASTIC_PASS} + useSSL: ${ELASTIC_USE_SSL} socketTimeoutMillis: 30000 connectTimeoutMillis: 30000 defaultResultSize: 100 @@ -14,8 +14,8 @@ elastic: defaultCompositeAggregationResultSize: 200000 disableHostnameVerifier: false app-elastic: - enabled: ${ELASTIC_ENABLED:} - dmpIndexName: ${ELASTIC_DMP_INDEX:} - descriptionIndexName: ${ELASTIC_DESCRIPTION_INDEX:} + enabled: ${ELASTIC_ENABLED} + dmpIndexName: ${ELASTIC_DMP_INDEX} + descriptionIndexName: ${ELASTIC_DESCRIPTION_INDEX} enableIcuAnalysisPlugin: false resetBatchSize: 1000 diff --git a/backend/web/src/main/resources/config/external.yml b/backend/web/src/main/resources/config/external.yml index 8c40185a5..68718a4bb 100644 --- a/backend/web/src/main/resources/config/external.yml +++ b/backend/web/src/main/resources/config/external.yml @@ -1,7 +1,3 @@ -pdf: - converter: - url: ${PDF_CONVERTER_URL:} - publicapi: host: devel.opendmp.eu basePath: /srv diff --git a/backend/web/src/main/resources/config/logging-devel.yml b/backend/web/src/main/resources/config/logging-devel.yml index 59f65e470..1910ce38d 100644 --- a/backend/web/src/main/resources/config/logging-devel.yml +++ b/backend/web/src/main/resources/config/logging-devel.yml @@ -1,36 +1,2 @@ logging: - config: classpath:logging/logback-${spring.profiles.active}.xml - context: - request: - requestIdKey: req.id - requestRemoteHostKey: req.remoteHost - requestUriKey: req.requestURI - requestQueryStringKey: req.queryString - requestUrlKey : req.requestURL - requestMethodKey: req.method - requestUserAgentKey: req.userAgent - requestForwardedForKey: req.xForwardedFor - requestSchemeKey: req.scheme - requestRemoteAddressKey: req.remoteAddr - requestRemotePortKey: req.remotePort - requestRemoteUserKey: req.remoteUser - principal: - subjectKey: usr.subject - nameKey: usr.name - clientKey: usr.client -audit: - enable: true - requestRemoteHostKey: req.remoteHost - requestUriKey: req.requestURI - requestQueryStringKey: req.queryString - requestUrlKey : req.requestURL - requestMethodKey: req.method - requestUserAgentKey: req.userAgent - requestForwardedForKey: req.xForwardedFor - requestSchemeKey: req.scheme - requestRemoteAddressKey: req.remoteAddr - requestRemotePortKey: req.remotePort - requestRemoteUserKey: req.remoteUser - principalSubjectKey: usr.subject - principalNameKey: usr.name - principalClientKey: usr.client + config: classpath:logging/logback-${spring.profiles.active}.xml \ No newline at end of file diff --git a/backend/web/src/main/resources/config/notification-devel.yml b/backend/web/src/main/resources/config/notification-devel.yml new file mode 100644 index 000000000..9fcb3db83 --- /dev/null +++ b/backend/web/src/main/resources/config/notification-devel.yml @@ -0,0 +1,14 @@ +notification: + dmpInvitationExternalUserType: 065DEECD-21BB-44AF-9983-E660FDF24BC4 + dmpInvitationExistingUserType: 4904dea2-5079-46d3-83be-3a19c9ab45dc + dmpModifiedType: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB + dmpFinalisedType: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E + descriptionModifiedType: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 + descriptionFinalisedType: 33790bad-94d4-488a-8ee2-7f6295ca18ea + mergeAccountConfirmationType: BFE68845-CB05-4C5A-A03D-29161A7C9660 + removeCredentialConfirmationType: C9BC3F16-057E-4BBA-8A5F-36BD835E5604 + dmpDepositType: 55736F7A-83AB-4190-AF43-9D031A6F9612 + descriptionTemplateInvitationType: 223BB607-EFA1-4CE7-99EC-4BEABFEF9A8B + contactSupportType: 5B1D6C52-88F9-418B-9B8A-6F1F963D9EAD + publicContactSupportType: B542B606-ACC6-4629-ADEF-4D8EE2F01222 + contactSupportEmail: support@dmp.com \ No newline at end of file diff --git a/backend/web/src/main/resources/config/notification.yml b/backend/web/src/main/resources/config/notification.yml index 2927a1a93..0a3261e83 100644 --- a/backend/web/src/main/resources/config/notification.yml +++ b/backend/web/src/main/resources/config/notification.yml @@ -1,15 +1,2 @@ notification: - dmpInvitationExternalUserType: 065DEECD-21BB-44AF-9983-E660FDF24BC4 - dmpInvitationExistingUserType: 4904dea2-5079-46d3-83be-3a19c9ab45dc - dmpModifiedType: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB - dmpFinalisedType: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E - descriptionModifiedType: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 - descriptionFinalisedType: 33790bad-94d4-488a-8ee2-7f6295ca18ea - mergeAccountConfirmationType: BFE68845-CB05-4C5A-A03D-29161A7C9660 - removeCredentialConfirmationType: C9BC3F16-057E-4BBA-8A5F-36BD835E5604 - dmpDepositType: 55736F7A-83AB-4190-AF43-9D031A6F9612 - descriptionTemplateInvitationType: 223BB607-EFA1-4CE7-99EC-4BEABFEF9A8B - contactSupportType: 5B1D6C52-88F9-418B-9B8A-6F1F963D9EAD - publicContactSupportType: B542B606-ACC6-4629-ADEF-4D8EE2F01222 - contactSupportEmail: support@dmp.com emailExpirationTimeSeconds: 14400 \ No newline at end of file diff --git a/backend/web/src/main/resources/config/public-api-devel.yml b/backend/web/src/main/resources/config/public-api-devel.yml new file mode 100644 index 000000000..de7b59e8f --- /dev/null +++ b/backend/web/src/main/resources/config/public-api-devel.yml @@ -0,0 +1,10 @@ +public-api: + reference-type-map: + funderTypeId: "538928bb-c7c6-452e-b66d-08e539f5f082" + grantTypeId: "5b9c284f-f041-4995-96cc-fad7ad13289c" + registryTypeId: "2beacaad-3223-43ad-ad99-1e5f21328e7b" + serviceTypeId: "9ec2000d-95c7-452e-b356-755fc8e2574c" + dataRepositoryTypeId: "d26b64ba-fda0-4b14-b3ef-9856a492d55a" + datasetTypeId: "a3ce0fb2-d72c-48bb-b322-7401940cb802" + researcherTypeId: "5a2112e7-ea99-4cfe-98a1-68665e26726e" + organizationTypeId: "7eeffb98-58fb-4921-82ec-e27f32f8e738" \ No newline at end of file diff --git a/backend/web/src/main/resources/config/public-api.yml b/backend/web/src/main/resources/config/public-api.yml index de7b59e8f..f569ce7e3 100644 --- a/backend/web/src/main/resources/config/public-api.yml +++ b/backend/web/src/main/resources/config/public-api.yml @@ -1,10 +1,2 @@ public-api: - reference-type-map: - funderTypeId: "538928bb-c7c6-452e-b66d-08e539f5f082" - grantTypeId: "5b9c284f-f041-4995-96cc-fad7ad13289c" - registryTypeId: "2beacaad-3223-43ad-ad99-1e5f21328e7b" - serviceTypeId: "9ec2000d-95c7-452e-b356-755fc8e2574c" - dataRepositoryTypeId: "d26b64ba-fda0-4b14-b3ef-9856a492d55a" - datasetTypeId: "a3ce0fb2-d72c-48bb-b322-7401940cb802" - researcherTypeId: "5a2112e7-ea99-4cfe-98a1-68665e26726e" - organizationTypeId: "7eeffb98-58fb-4921-82ec-e27f32f8e738" \ No newline at end of file + reference-type-map: [] \ No newline at end of file diff --git a/backend/web/src/main/resources/config/security.yml b/backend/web/src/main/resources/config/security.yml index 5776031be..edbfa69b5 100644 --- a/backend/web/src/main/resources/config/security.yml +++ b/backend/web/src/main/resources/config/security.yml @@ -10,6 +10,6 @@ web: token-type: JWT #| opaque jwt: claims: [ role, x-role ] - issuer-uri: ${IDP_ISSUER_URI:} + issuer-uri: ${IDP_ISSUER_URI} audiences: [ "dmp_web" ] - validIssuer: ${IDP_ISSUER_URI:} \ No newline at end of file + validIssuer: ${IDP_ISSUER_URI} \ No newline at end of file From 36e15fe2e510408b08b6773c50554684c119e773 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Tue, 14 May 2024 15:02:51 +0300 Subject: [PATCH 3/5] bug fix --- .../service/message/infobuilder/MessageBuilderServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java b/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java index af4138ba5..0e65fbb71 100644 --- a/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java +++ b/notification-service/notification/src/main/java/gr/cite/notification/service/message/infobuilder/MessageBuilderServiceImpl.java @@ -108,7 +108,7 @@ public class MessageBuilderServiceImpl implements MessageInfoBuilderService { if (messageInfo.getTimeZone() == null || messageInfo.getTimeZone().isBlank()) messageInfo.setTimeZone(this.localeService.timezoneName()); if (this.scope.isMultitenant()) { - if (this.scope.isDefaultTenant()) { + if (!this.scope.isDefaultTenant()) { TenantEntity tenantInfo = this.queryFactory.query(TenantQuery.class) .isActive(IsActive.Active).firstAs(new BaseFieldSet(TenantEntity._id, TenantEntity._code)); From 9cdbf46ba7379ff7de5cad5ec6d870a9a8bdebed Mon Sep 17 00:00:00 2001 From: amandilaras Date: Tue, 14 May 2024 15:03:55 +0300 Subject: [PATCH 4/5] fix user for keycloak --- deployment/opencdmp/backend/config/app.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/opencdmp/backend/config/app.env b/deployment/opencdmp/backend/config/app.env index d064cce8d..36b16d6ae 100644 --- a/deployment/opencdmp/backend/config/app.env +++ b/deployment/opencdmp/backend/config/app.env @@ -30,8 +30,8 @@ RABBIT_PASS=guest #KEYCLOAK KEYCLOAK_API_SERVER_URL=http://host.docker.internal:8081/keycloak KEYCLOAK_API_REALM=OpenCDMP -KEYCLOAK_API_USERNAME=keycloak-admin -KEYCLOAK_API_PASSWORD=admin +KEYCLOAK_API_USERNAME=dmp-keycloak-api +KEYCLOAK_API_PASSWORD=dmp-api KEYCLOAK_API_CLIENT_ID=dmp_web KEYCLOAK_API_CLIENT_SECRET=web_secret From cbbf70d3f6c8e8ecdf1e8bcfe3013dae1e0fefe9 Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 14 May 2024 15:13:00 +0300 Subject: [PATCH 5/5] add dmp delete dialog where dmp has descriptions --- .../dmp-delete-dialog.component.html | 22 ++++++++ .../dmp-delete-dialog.component.scss | 55 +++++++++++++++++++ .../dmp-delete-dialog.component.ts | 31 +++++++++++ .../dmp-delete-dialog.module.ts | 13 +++++ .../dmp-editor-blueprint/dmp-editor.module.ts | 2 + .../dmp-listing-item.component.ts | 33 +++++++---- .../ui/dmp/overview/dmp-overview.component.ts | 30 +++++++--- .../ui/dmp/overview/dmp-overview.module.ts | 2 + dmp-frontend/src/assets/i18n/en.json | 8 +++ 9 files changed, 177 insertions(+), 19 deletions(-) create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.html create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.scss create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.ts create mode 100644 dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.module.ts diff --git a/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.html b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.html new file mode 100644 index 000000000..efcb85594 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.html @@ -0,0 +1,22 @@ +
+
+
+ {{'DMP-DELETE-DIALOG.WARNING' | translate}} + close +
+
+
+
{{'DMP-DELETE-DIALOG.DELETE-ITEM' | translate}}
+
+
+ +
    +
  • {{description.label}}
  • +
+
+
+
+
+
+
+
diff --git a/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.scss b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.scss new file mode 100644 index 000000000..4c8d6441d --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.scss @@ -0,0 +1,55 @@ +// ::ng-deep .mat-dialog-container { +// overflow: hidden; +// padding: 20px; +// border-radius: 125px; +// } + +.dmp-delete-dialog { + + padding: 24px; + overflow: hidden; + + .confirmation { + padding-bottom: 20px; + } + + .close-btn { + margin-left: auto; + cursor: pointer; + } + + .warn-text { + // color: #f44336; + + } + + .cancel { + background-color: #aaaaaa; + color: #ffffff; + } + + .cancel-btn { + min-width: 101px; + height: 43px; + background: #ffffff; + border: 1px solid #b5b5b5; + border-radius: 30px; + opacity: 1; + } + + + .delete { + background-color: #ba2c2c; + color: #ffffff; + } + + .delete-btn { + min-width: 101px; + height: 43px; + background: #ffffff; + color: #ba2c2c; + border: 1px solid #ba2c2c; + border-radius: 30px; + opacity: 1; + } +} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.ts new file mode 100644 index 000000000..462545121 --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.component.ts @@ -0,0 +1,31 @@ +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Description } from '@app/core/model/description/description'; + +@Component({ + selector: 'app-dmp-delete-dialog', + templateUrl: './dmp-delete-dialog.component.html', + styleUrls: ['./dmp-delete-dialog.component.scss'] +}) +export class DmpDeleteDialogComponent { + + descriptions: Description[]; + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { + this.descriptions = data.descriptions; + } + + close() { + this.dialogRef.close(false); + } + + cancel() { + this.dialogRef.close(false); + } + + confirm() { + this.dialogRef.close(true); + } +} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.module.ts b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.module.ts new file mode 100644 index 000000000..83366e14b --- /dev/null +++ b/dmp-frontend/src/app/ui/dmp/dmp-delete-dialog/dmp-delete-dialog.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DmpDeleteDialogComponent } from './dmp-delete-dialog.component'; + +@NgModule({ + imports: [CommonUiModule, FormsModule], + declarations: [DmpDeleteDialogComponent], + exports: [DmpDeleteDialogComponent] +}) +export class DmpDeleteDialogModule { + constructor() { } +} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.module.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.module.ts index 80b7e8fe4..382196446 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.module.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.module.ts @@ -11,6 +11,7 @@ import { DmpUserFieldModule } from '../dmp-user-field/dmp-user-field.module'; import { DmpEditorComponent } from './dmp-editor.component'; import { DmpEditorRoutingModule } from './dmp-editor.routing'; import { DmpFormProgressIndicationModule } from './form-progress-indication/dmp-form-progress-indication.module'; +import { DmpDeleteDialogModule } from '../dmp-delete-dialog/dmp-delete-dialog.module'; @NgModule({ imports: [ @@ -18,6 +19,7 @@ import { DmpFormProgressIndicationModule } from './form-progress-indication/dmp- CommonFormsModule, FormattingModule, ConfirmationDialogModule, + DmpDeleteDialogModule, DmpEditorRoutingModule, RichTextEditorModule, AutoCompleteModule, diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index d5a19d0e0..e4a13e752 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -29,6 +29,7 @@ import { NewVersionDmpDialogComponent } from '../../new-version-dialog/dmp-new-v import { AppPermission } from '@app/core/common/enum/permission.enum'; import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type'; import { DmpVersionStatus } from '@app/core/common/enum/dmp-version-status'; +import { DmpDeleteDialogComponent } from '../../dmp-delete-dialog/dmp-delete-dialog.component'; @Component({ selector: 'app-dmp-listing-item-component', @@ -168,16 +169,28 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { } openDeleteDialog(id: Guid) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); + let dialogRef: any; + + if (this.dmp.descriptions && this.dmp.descriptions.length > 0){ + dialogRef = this.dialog.open(DmpDeleteDialogComponent, { + maxWidth: '300px', + data: { + descriptions: this.dmp.descriptions, + } + }); + } else { + dialogRef = this.dialog.open(ConfirmationDialogComponent, { + maxWidth: '300px', + restoreFocus: false, + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), + confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), + cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), + isDeleteConfirmation: true + } + }); + } + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { this.dmpService.delete(id) diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 5fca4b832..acd56a99a 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -48,6 +48,7 @@ import { DmpFinalizeDialogComponent, DmpFinalizeDialogOutput } from '../dmp-fina import { DmpEditorResolver } from '../dmp-editor-blueprint/dmp-editor.resolver'; import { FileTransformerEntityType } from '@app/core/common/enum/file-transformer-entity-type'; import { DmpVersionStatus } from '@app/core/common/enum/dmp-version-status'; +import { DmpDeleteDialogComponent } from '../dmp-delete-dialog/dmp-delete-dialog.component'; @Component({ selector: 'app-dmp-overview', @@ -373,15 +374,26 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { // } deleteClicked() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); + let dialogRef: any; + if (this.dmp.descriptions && this.dmp.descriptions.length > 0){ + dialogRef = this.dialog.open(DmpDeleteDialogComponent, { + maxWidth: '300px', + data: { + descriptions: this.dmp.descriptions, + } + }); + } else { + dialogRef = this.dialog.open(ConfirmationDialogComponent, { + maxWidth: '300px', + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), + confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), + cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), + isDeleteConfirmation: true + } + }); + } + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { this.dmpService.delete(this.dmp.id) diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts index dd5856888..26553c95c 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.module.ts @@ -10,12 +10,14 @@ import { NgDialogAnimationService } from 'ng-dialog-animation'; import { DmpFinalizeDialogModule } from '../dmp-finalize-dialog/dmp-finalize-dialog.module'; import { DmpOverviewRoutingModule } from './dmp-overview.routing'; import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.module'; +import { DmpDeleteDialogModule } from '../dmp-delete-dialog/dmp-delete-dialog.module'; @NgModule({ imports: [ CommonUiModule, CommonFormsModule, ConfirmationDialogModule, + DmpDeleteDialogModule, MultipleChoiceDialogModule, FormattingModule, AutoCompleteModule, diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 8f50accb6..b8e9bc3ff 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -643,6 +643,14 @@ }, "PLACEHOLDER": "Plan title" }, + "DMP-DELETE-DIALOG": { + "WARNING": "Warning!", + "DELETE-ITEM": "Are you sure to delete this plan? The following descriptions will also be removed:", + "ACTIONS": { + "DELETE": "Delete", + "CANCEL": "Cancel" + } + }, "DMP-OVERVIEW": { "TITLE": "Plan", "PUBLIC": "Public",