diff --git a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts index d21df6676..e7306d139 100644 --- a/dmp-frontend/src/app/core/services/dataset/dataset.service.ts +++ b/dmp-frontend/src/app/core/services/dataset/dataset.service.ts @@ -11,7 +11,7 @@ import { BaseHttpService } from '../http/base-http.service'; import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria'; import { ConfigurationService } from '../configuration/configuration.service'; import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview'; -import { HttpHeaders } from '@angular/common/http'; +import { HttpHeaders, HttpResponse, HttpClient } from '@angular/common/http'; import { DatasetModel } from '@app/core/model/dataset/dataset'; @Injectable() @@ -22,7 +22,8 @@ export class DatasetService { constructor( private http: BaseHttpService, - private configurationSevice: ConfigurationService) { + private configurationSevice: ConfigurationService, + private httpClient: HttpClient) { this.actionUrl = configurationSevice.server + 'datasets/'; } @@ -69,4 +70,27 @@ export class DatasetService { delete(id: String): Observable { return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); // + 'delete/' } + + publish(id: String): Observable { + return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }); + } + + public downloadXML(id: string): Observable> { + let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') + return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); //+ "/getXml/" + } + + public downloadDocx(id: string): Observable> { + let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword') + return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDoc }); + } + + public downloadPDF(id: string): Observable> { + let headerPdf: HttpHeaders = this.headers.set('Content-Type', 'application/pdf') + return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf }); + } + + public downloadJson(id: string): Observable> { + return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' }); + } } diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html index ea6fa3f22..dcd35cc47 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html @@ -9,7 +9,7 @@
-

{{ dataset.label }}

+

{{ dataset.label }}

@@ -41,34 +41,38 @@ (click)="viewVersions(dmp.groupId, dmp.label)"> {{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}} --> -
{{'GENERAL.STATUSES.EDIT' | translate}} : +
{{'GENERAL.STATUSES.EDIT' | translate}} : {{dataset.modified | date:"longDate"}}
- +
+ create + {{'TYPES.DATASET-STATUS.DRAFT' | translate}} +
+
-
{{ 'DATASET-LISTING.TOOLTIP.DMP-FOR' | translate }}: {{ dataset.datasetTemplate.label }}
@@ -85,7 +90,7 @@
{{'DMP-OVERVIEW.GRANT' | translate}}
-
Grant label
+
Grant label
{{'DMP-OVERVIEW.RESEARCHERS' | translate}}
@@ -127,8 +132,8 @@
-->
- - +
- - +
diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss index cc76c8022..979463146 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.scss @@ -20,7 +20,7 @@ font-size: 1.2em; } -.mat-mini-fab:hover { +.actions-btn:hover { background-color: #129D99; color: #FFFFFF; } @@ -150,13 +150,12 @@ color: #008887; padding-right: 0.5em; align-self: center; - } .header { opacity: 0.6; margin-top: 1em; - margin-bottom: 0.25em; + margin-bottom: 0.5em; } .dataset-label, .header { @@ -262,7 +261,7 @@ // ********CENTER ELEMENTS******** -.mat-mini-fab, .mat-mini-fab-icon, +.mat-mini-fab, .mat-mini-fab-icon, .actions-btn, .status-icon, .dataset-logo, .frame-btn, .finalize-btn { display: flex; justify-content: center; diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts index e7cbd4742..6df5ec3b3 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts @@ -19,6 +19,12 @@ import { Location } from '@angular/common'; import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; import { DatasetStatus } from '@app/core/common/enum/dataset-status'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; +import * as FileSaver from 'file-saver'; +import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation.component'; +import { DatasetWizardEditorModel } from '../dataset-wizard/dataset-wizard-editor.model'; +import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; +import { FormControl } from '@angular/forms'; +import { DatasetCopyDialogueComponent } from '../dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; @Component({ @@ -29,6 +35,7 @@ import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog export class DatasetOverviewComponent extends BaseComponent implements OnInit { dataset: DatasetOverviewModel; + datasetWizardModel: DatasetWizardEditorModel; isNew = true; isFinalized = false; isPublicView = true; @@ -50,7 +57,8 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { private configurationService: ConfigurationService, private oauth2DialogService: Oauth2DialogService, private userService: UserService, - private location: Location + private location: Location, + private datasetWizardService: DatasetWizardService ) { super(); } @@ -69,6 +77,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dataset = data; + this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed)) + .subscribe(data => { + this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); + }); // this.checkLockStatus(this.dataset.id); this.setIsUserOwner(); const breadCrumbs = []; @@ -92,6 +104,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dataset = data; + this.datasetWizardService.getSingle(this.dataset.id).pipe(takeUntil(this._destroyed)) + .subscribe(data => { + this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data); + }); // this.checkLockStatus(this.dataset.id); this.setIsUserOwner(); const breadCrumbs = []; @@ -130,7 +146,12 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { if (principal) this.isUserOwner = principal.id === this.dataset.users.find(x => x.role === Role.Owner).id; } } - + + isUserAuthor(userId: string): boolean { + const principal: Principal = this.authentication.current(); + return userId === principal.id; + } + isUserDatasetRelated() { const principal: Principal = this.authentication.current(); let isRelated: boolean = false; @@ -143,6 +164,17 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { } return isRelated; } + + roleDisplay(value: UserInfoListingModel) { + if (value.role === Role.Owner) { + return this.translate.instant('DMP-LISTING.OWNER'); + } else if (value.role === Role.Member) { + return this.translate.instant('DMP-LISTING.MEMBER'); + } else { + return this.translate.instant('DMP-LISTING.OWNER'); + } + } + roleDisplayFromList(value: UserInfoListingModel[]) { const principal: Principal = this.authentication.current(); @@ -162,21 +194,37 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { return this.translate.instant('DMP-LISTING.OWNER'); } } + + openShareDialog(rowId: any, rowName: any) { + const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { + // height: '250px', + // width: '700px', + restoreFocus: false, + data: { + dmpId: rowId, + dmpName: rowName + } + }); + } public isAuthenticated(): boolean { return !(!this.authentication.current()); } - cloneClicked(dataset: DatasetOverviewModel) { - this.router.navigate(['/datasets/clone/' + dataset.id]); - } - isDraftDataset(dataset: DatasetOverviewModel) { return dataset.status == DatasetStatus.Draft; } + + isFinalizedDataset(dataset: DatasetOverviewModel) { + return dataset.status == DatasetStatus.Finalized; + } editClicked(dataset: DatasetOverviewModel) { - this.router.navigate(['/datasets/edit/' + dataset.id]); + if (dataset.public) { + this.router.navigate(['/datasets/publicEdit/' + dataset.id]); + } else { + this.router.navigate(['/datasets/edit/' + dataset.id]); + } } deleteClicked() { @@ -200,6 +248,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { } }); } + + dmpClicked(dmpId: String) { + this.router.navigate(['/plans/overview/' + dmpId]); + } onCallbackSuccess(): void { this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); @@ -213,9 +265,116 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { public getOrcidPath(): string { return this.configurationService.orcidPath; } + + downloadPDF(id: string) { + this.datasetService.downloadPDF(id) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { + const blob = new Blob([response.body], { type: 'application/pdf' }); + const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + + FileSaver.saveAs(blob, filename); + }); + } + + downloadDocx(id: string) { + this.datasetService.downloadDocx(id) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { + const blob = new Blob([response.body], { type: 'application/msword' }); + const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + + FileSaver.saveAs(blob, filename); + }); + } + + downloadXml(id: string) { + this.datasetService.downloadXML(id) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { + const blob = new Blob([response.body], { type: 'application/xml' }); + const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + + FileSaver.saveAs(blob, filename); + }); + } + + downloadJson(id: string) { + this.datasetService.downloadJson(id) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { + const blob = new Blob([response.body], { type: 'application/json' }); + const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + FileSaver.saveAs(blob, filename); + }) + } + + getFilenameFromContentDispositionHeader(header: string): string { + const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g); + + const matches = header.match(regex); + let filename: string; + for (let i = 0; i < matches.length; i++) { + const match = matches[i]; + if (match.includes('filename="')) { + filename = match.substring(10, match.length - 1); + break; + } else if (match.includes('filename=')) { + filename = match.substring(9); + break; + } + } + return filename; + } + + showPublishButton(dataset: DatasetOverviewModel) { + return this.isFinalizedDataset(dataset) && !dataset.public && this.hasPublishButton; + } + + publish(datasetId: String) { + const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + maxWidth: '500px', + restoreFocus: false, + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'), + privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'), + confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), + cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), + isDeleteConfirmation: false + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result) { + this.datasetService.publish(datasetId) + .pipe(takeUntil(this._destroyed)) + .subscribe(() => { this.hasPublishButton = false }); + } + }); + } + + openDmpSearchDialogue() { + const formControl = new FormControl(); + const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { + width: '500px', + restoreFocus: false, + data: { + formControl: formControl, + datasetId: this.dataset.id, + datasetProfileId: this.datasetWizardModel.profile, + datasetProfileExist: false, + confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), + cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') + } + }); + + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) + .subscribe(result => { + if (result && result.datasetProfileExist) { + const newDmpId = result.formControl.value.id + this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); + } + }); + } - // showPublishButton(dataset: DatasetOverviewModel) { - // return this.isFinalizedDmp(dmp) && !dmp.isPublic && this.hasPublishButton; - // } } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index cd5c4e1f2..5ee16de2b 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -46,7 +46,11 @@
check - {{'DATASET-LISTING.COLUMNS.FINALIZED' | translate}} + {{'TYPES.DMP.FINALISED' | translate}} +
+
+ create + {{'TYPES.DMP.DRAFT' | translate}}
diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss index 9ceae05d1..97e0fc96d 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.scss @@ -161,7 +161,7 @@ .header { opacity: 0.6; margin-top: 1em; - margin-bottom: 0.25em; + margin-bottom: 0.5em; } .dmp-label, .header { 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 1d233f5fc..14f877006 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 @@ -183,12 +183,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } datasetClicked(datasetId: String) { - if (this.isPublicView) { - this.router.navigate(['/datasets/publicEdit/' + datasetId]); - } else { - this.router.navigate(['/datasets/edit/' + datasetId]); - console.log('inhere') - } + // if (this.isPublicView) { + // this.router.navigate(['/datasets/publicEdit/' + datasetId]); + // } else { + // this.router.navigate(['/datasets/edit/' + datasetId]); + // } + this.router.navigate(['/datasets/overview/' + datasetId]); } datasetsClicked(dmpId: String) { diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 11ed9caaf..452088bf1 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -106,6 +106,7 @@ "LOGIN": "Login", "DMP-OVERVIEW": "DMP Overview", "DMP-EDIT": "Edit DMP", + "DATASET-OVERVIEW": "Dataset Overview", "DATASET-EDIT": "Dataset View/Edit", "DMP-NEW-VERSION": "DMP New Version", "DMP-CLONE": "Clone DMP", @@ -567,7 +568,7 @@ } }, "DATASET-OVERVIEW": { - "DATASET-AUTHORS": "Dataset description Authors", + "DATASET-AUTHORS": "Dataset description authors", "ERROR": { "DELETED-DATASET": "The requested dataset is deleted", "FORBIDEN-DATASET": "You are not allowed to access this dataset" diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index dc4e1e6e4..02fa89ccd 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -105,6 +105,7 @@ "LOGIN": "Iniciar sesión", "DMP-OVERVIEW": "Resumen del PGD", "DMP-EDIT": "Editar el PGD", + "DATASET-OVERVIEW": "Resumen del Dataset", "DATASET-EDIT": "Ver/Editar el Dataset", "DMP-NEW-VERSION": "Nueva versiónd del PGD", "DMP-CLONE": "Clonar el PGD", @@ -565,7 +566,7 @@ } }, "DATASET-OVERVIEW": { - "DATASET-AUTHORS": "Descripciones del Dataset Autores", + "DATASET-AUTHORS": "Descripciones del dataset autores", "ERROR": { "DELETED-DATASET": "El Dataset solicitado está borrado", "FORBIDEN-DATASET": "No tiene permiso para acceder a esto Dataset" diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 75dc1c0e2..4f696bf13 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -105,6 +105,7 @@ "LOGIN": "Σύνδεση", "DMP-OVERVIEW": "Επισκόπηση Σχεδίου Διαχείρισης Δεδομένων", "DMP-EDIT": "Επεξεργασία Σχεδίου Διαχείρισης Δεδομένων", + "DATASET-OVERVIEW": "Επισκόπηση Συνόλου Δεδομένων", "DATASET-EDIT": "Προβολή / Επεξεργασία Συνόλου Δεδομένων", "DMP-NEW-VERSION": "Νέα έκδοση Σχεδίου Διαχείρισης Δεδομένων", "DMP-CLONE": "Κλωνοποίηση Σχεδίου Διαχείρισης Δεδομένων", @@ -566,7 +567,7 @@ } }, "DATASET-OVERVIEW": { - "DATASET-AUTHORS": "Συγγραφείς Περιγραφής Δεδομένων", + "DATASET-AUTHORS": "Συγγραφείς περιγραφής δεδομένων", "ERROR": { "DELETED-DATASET": "H επιλεγμένη Περιγραφή Δεδομένων θα διαγραφεί", "FORBIDEN-DATASET": "Δεν επιτρέπεται η πρόσβαση σε αυτή την Περιγραφή Δεδομένων"