From cce9df8eb7eaf9e5bf666948bfc5f5acfe34daa9 Mon Sep 17 00:00:00 2001 From: Kristan Ntavidi Date: Fri, 9 Jul 2021 13:03:09 +0300 Subject: [PATCH] Fixes * Feedback message on error saving dataset. * Unsubscribe backend calls on dashboard component destroy. --- .../src/app/ui/dashboard/drafts/drafts.component.ts | 8 ++++++-- .../recent-edited-activity.component.ts | 3 +++ .../recent-edited-dataset-activity.component.ts | 2 ++ .../recent-edited-dmp-activity.component.ts | 1 + .../recent-visited-activity.component.ts | 2 ++ .../ui/dataset/dataset-wizard/dataset-wizard.component.ts | 6 ++++++ dmp-frontend/src/assets/i18n/de.json | 4 ++++ dmp-frontend/src/assets/i18n/en.json | 4 ++++ dmp-frontend/src/assets/i18n/es.json | 4 ++++ dmp-frontend/src/assets/i18n/gr.json | 4 ++++ dmp-frontend/src/assets/i18n/pt.json | 4 ++++ dmp-frontend/src/assets/i18n/sk.json | 4 ++++ dmp-frontend/src/assets/i18n/sr.json | 4 ++++ dmp-frontend/src/assets/i18n/tr.json | 4 ++++ 14 files changed, 52 insertions(+), 2 deletions(-) diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts index ecbf545bd..95d88f121 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts @@ -78,7 +78,9 @@ export class DraftsComponent extends BaseComponent implements OnInit { const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, 5, { fields: fields }); dmpDataTableRequest.criteria = new DatasetCriteria(); dmpDataTableRequest.criteria.status = DmpStatus.Draft; - this.datasetService.getPaged(dmpDataTableRequest).subscribe(response => { + this.datasetService.getPaged(dmpDataTableRequest) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { this.datasetDrafts = response.data; this.totalCount = response.totalCount; this.totalCountDraftDatasets.emit(this.datasetDrafts.length); @@ -314,7 +316,9 @@ export class DraftsComponent extends BaseComponent implements OnInit { dmpDataTableRequest.criteria = new DatasetCriteria(); dmpDataTableRequest.criteria.status = DmpStatus.Draft; dmpDataTableRequest.criteria.like = this.formGroup.get("like").value; - this.datasetService.getPaged(dmpDataTableRequest).subscribe(response => { + this.datasetService.getPaged(dmpDataTableRequest) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { this.datasetDrafts = response.data; this.totalCount = response.totalCount; this.totalCountDraftDatasets.emit(this.datasetDrafts.length); diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index 84eac2e7c..c951e6735 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -100,6 +100,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn allDataTableRequest.criteria.order = this.formGroup.get('order').value; this.dashboardService .getRecentActivity(allDataTableRequest) + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.allRecentActivities = response; this.allRecentActivities.forEach(recentActivity => { @@ -123,6 +124,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn const allDataTableRequest = this.setPublicDataTableRequest(); this.dashboardService .getRecentActivity(allDataTableRequest) + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.allRecentActivities = response; this.allRecentActivities.forEach(recentActivity => { @@ -619,6 +621,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn allDataTableRequest.criteria.order = this.formGroup.get("order").value; this.dashboardService .getRecentActivity(allDataTableRequest) + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.allRecentActivities = response; this.allRecentActivities.forEach(recentActivity => { diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts index 0955ec5c3..a9edf18ca 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts @@ -77,6 +77,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen datasetDataTableRequest.criteria.like = ""; this.datasetService .getPaged(datasetDataTableRequest) + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.datasetActivities = response.data; this.totalCount = response.totalCount; @@ -130,6 +131,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen } this.datasetService .getPaged(datasetDataTableRequest) + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.datasetActivities = response.data; this.totalCount = response.totalCount; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts index e0492ccd8..013a03fdd 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts @@ -90,6 +90,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O dmpDataTableRequest.criteria.like = ""; this.dmpService .getPaged(dmpDataTableRequest, "listing") + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.dmpActivities = response.data; this.totalCount = response.totalCount; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts index 6cb7c8111..3edf9340e 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts @@ -8,6 +8,7 @@ import { AuthService } from '@app/core/services/auth/auth.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { BaseComponent } from '@common/base/base.component'; +import { takeUntil } from "rxjs/operators"; @Component({ selector: "app-recent-visited-activity", @@ -38,6 +39,7 @@ export class RecentVisitedActivityComponent extends BaseComponent dmpDataTableRequest.criteria.like = ""; this.dmpService .getPaged(dmpDataTableRequest, "listing") + .pipe(takeUntil(this._destroyed)) .subscribe(response => { this.dmpActivities = response.data; }); diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index fbce489b4..0853efffb 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -854,6 +854,12 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme } onCallbackError(error: any) { + const errmes = error && error.message? error.message as string : null; + let feedbackMessage = this.language.instant('DATASET-EDITOR.ERRORS.ERROR-OCCURED'); + if(errmes){ + feedbackMessage += errmes; + } + this.uiNotificationService.snackBarNotification(feedbackMessage, SnackBarNotificationLevel.Warning); this.setErrorModel(error.error); } diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index cb8b5da50..aaf859785 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Die Versionierung ist automatisiert.", "QUESTION": "Es scheint, dass Ihre Vorlage der Datensatzbeschreibung veraltet ist. Möchten Sie sie auf die neueste Version aktualisieren?" + }, + "ERRORS":{ + "ERROR-OCCURED": "An error occured.", + "MESSAGE": "Message: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 60e3e4bd3..58b94a5e7 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Versioning is automated.", "QUESTION": "It seems your Dataset Template is outdated. Do you want to update it to the latest version?" + }, + "ERRORS":{ + "ERROR-OCCURED": "An error occured.", + "MESSAGE": "Message: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index ac861ed3a..ae36b9a06 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Versionado es automático.", "QUESTION": "Parece que su plantilla de descripción del dataset está desactualizada. ¿Queire actualizarla a la última versión?" + }, + "ERRORS":{ + "ERROR-OCCURED": "An error occured.", + "MESSAGE": "Message: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index ee4741459..e83fcaf30 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Η δημιουργία νέας έκδοσης συμβαίνει αυτόματα", "QUESTION": "Το Template το Συνόλου Δεδομένων που επιλέξατε χρειάζεται επικαιροποίηση. Θα θέλατε να το ενημερώσετε στην πιο πρόσφατη έκδοσή του;" + }, + "ERRORS":{ + "ERROR-OCCURED": "Προέκυψε κάποιο σφάλμα.", + "MESSAGE": "Μήνυμα: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index 830471d29..e7e7a04cc 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "O versionamento é automático.", "QUESTION": "O seu modelo de dados está desatualizado. Pretende atualizá-lo de acordo com a última versão?" + }, + "ERRORS":{ + "ERROR-OCCURED": "Um erro ocorreu.", + "MESSAGE": "Mensangem: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index 3ee09b999..b46eb4250 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Verziovanie je automatizované.", "QUESTION": "Zdá sa, že Vaša šablóna súboru dát je zastaraná. Chcete ju aktualizovať na najnovšiu verziu?" + }, + "ERRORS":{ + "ERROR-OCCURED": "An error occured.", + "MESSAGE": "Message: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index 490455dec..c612c8c34 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Verzionisanje je automatsko.", "QUESTION": "Izgleda da je obrazac za skup podataka zastareo. Da li želite da koristite najnoviju verziju?" + }, + "ERRORS":{ + "ERROR-OCCURED": "An error occured.", + "MESSAGE": "Message: " } }, "DATASET-CREATE-WIZARD": { diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 6083b7189..78ed3739b 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -1228,6 +1228,10 @@ "VERSION-DIALOG": { "ABOUT": "Sürüm Otomatiktir.", "QUESTION": "Veri Seti Şablonunuz güncel değil. Son sürüme güncellenmesini ister misiniz?" + }, + "ERRORS":{ + "ERROR-OCCURED": "An error occured.", + "MESSAGE": "Message: " } }, "DATASET-CREATE-WIZARD": {