From 868678e03fb1066c713ba7eb43b46459e0208780 Mon Sep 17 00:00:00 2001 From: gpapavgeri Date: Wed, 22 Jul 2020 14:26:49 +0300 Subject: [PATCH] reloadPage & delete buttons updated --- .../ui/dashboard/drafts/drafts.component.ts | 24 ++++++++++++++++--- .../recent-edited-activity.component.html | 2 +- .../recent-edited-activity.component.ts | 22 +++++++++++++---- ...ent-edited-dataset-activity.component.html | 2 +- ...ecent-edited-dataset-activity.component.ts | 24 ++++++++++++++++--- .../recent-edited-dmp-activity.component.ts | 18 ++++++++++++-- .../dataset-listing-item.component.html | 2 +- .../dataset-listing-item.component.ts | 17 +++++++------ .../overview/dataset-overview.component.ts | 11 +++++---- .../dmp-listing-item.component.ts | 14 ++++++++--- .../ui/dmp/overview/dmp-overview.component.ts | 5 ++-- dmp-frontend/src/assets/i18n/de.json | 1 + dmp-frontend/src/assets/i18n/en.json | 1 + dmp-frontend/src/assets/i18n/es.json | 1 + dmp-frontend/src/assets/i18n/gr.json | 1 + dmp-frontend/src/assets/i18n/tr.json | 1 + 16 files changed, 114 insertions(+), 32 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 70fce0ebe..7bc040ece 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts @@ -22,6 +22,7 @@ import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; +import { Location } from '@angular/common'; @Component({ selector: 'app-drafts', @@ -55,7 +56,8 @@ export class DraftsComponent extends BaseComponent implements OnInit { public dialog: MatDialog, private datasetWizardService: DatasetWizardService, public enumUtils: EnumUtils, - private uiNotificationService: UiNotificationService + private uiNotificationService: UiNotificationService, + private location: Location ) { super(); } @@ -170,8 +172,8 @@ export class DraftsComponent extends BaseComponent implements OnInit { this.datasetWizardService.delete(id) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => this.onCallbackSuccess(), - error => this.onCallbackError(error) + complete => this.onDeleteCallbackSuccess(), + error => this.onDeleteCallbackError(error) ); } }); @@ -198,6 +200,22 @@ export class DraftsComponent extends BaseComponent implements OnInit { // this.setErrorModel(error.error); } + reloadPage(): void { + const path = this.location.path(); + this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { + this.router.navigate([path]); + }); + } + + onDeleteCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); + this.reloadPage(); + } + + onDeleteCallbackError(error) { + this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); + } + downloadPDF(dataset: DatasetListingModel): void { this.datasetWizardService.downloadPDF(dataset.id as string) .pipe(takeUntil(this._destroyed)) diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html index 0d6b6c1a0..59e1b2f75 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html @@ -82,7 +82,7 @@ - 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 394a33842..cf6c5a4bd 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 @@ -30,6 +30,7 @@ import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset- import { FormControl, FormBuilder } from '@angular/forms'; import { DatasetCopyDialogueComponent } from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; +import { Location } from '@angular/common'; @Component({ selector: 'app-recent-edited-activity', @@ -64,7 +65,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn private language: TranslateService, private dialog: MatDialog, private uiNotificationService: UiNotificationService, - private datasetWizardService: DatasetWizardService + private datasetWizardService: DatasetWizardService, + private location: Location ) { super(); } @@ -158,7 +160,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn this.dmpService.delete(dmp.id) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { this.onCallbackSuccess() }, + complete => this.onDeleteCallbackSuccess(), error => this.onDeleteCallbackError(error) ); } @@ -186,6 +188,18 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn this.router.navigate(['/plans']); } + reloadPage(): void { + const path = this.location.path(); + this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { + this.router.navigate([path]); + }); + } + + onDeleteCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); + this.reloadPage(); + } + onDeleteCallbackError(error) { this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); } @@ -394,8 +408,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn this.datasetWizardService.delete(id) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => this.onCallbackSuccess(), - // error => this.onCallbackError(error) + complete => this.onDeleteCallbackSuccess(), + error => this.onDeleteCallbackError(error) ); } }); diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html index 820227c41..2d7e6e01b 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html @@ -54,7 +54,7 @@ -