From 8f6d0cc33d8b06053f6c9dd631b205e787aea943 Mon Sep 17 00:00:00 2001
From: George Kalampokis
Date: Tue, 19 Dec 2023 18:09:09 +0200
Subject: [PATCH] Made File export menus dynamic and based on the available
file transformers (no POM)
---
.../model/file/TransformerCacheModel.java | 10 +++--
.../repository/TransformerRepository.java | 5 ++-
.../description/DescriptionService.java | 2 +-
.../description/DescriptionServiceImpl.java | 24 ++----------
.../java/eu/eudat/service/dmp/DmpService.java | 6 +--
.../eu/eudat/service/dmp/DmpServiceImpl.java | 26 ++-----------
.../transformer/FileTransformerService.java | 7 ++--
.../controllers/v2/DescriptionController.java | 15 ++++++--
.../eudat/controllers/v2/DmpController.java | 13 ++++++-
.../controllers/v2/EntityDoiController.java | 5 ++-
.../description/description.service.ts | 15 +++++---
.../src/app/core/services/dmp/dmp.service.ts | 11 ++++--
.../core/services/matomo/matomo-service.ts | 2 +-
.../ui/dashboard/drafts/drafts.component.html | 4 +-
.../ui/dashboard/drafts/drafts.component.ts | 7 +++-
.../recent-edited-activity.component.html | 4 +-
.../recent-edited-activity.component.ts | 7 +++-
.../recent-edited-dmp-activity.component.html | 4 +-
.../recent-edited-dmp-activity.component.ts | 5 +++
.../description-listing.component.html | 4 +-
.../listing/description-listing.component.ts | 5 +++
.../description-listing-item.component.html | 21 +++++-----
.../description-listing-item.component.ts | 35 +++++++++--------
.../description-overview.component.html | 13 ++++++-
.../description-overview.component.ts | 38 ++++++++++---------
.../ui/dmp/listing/dmp-listing.component.html | 2 +-
.../ui/dmp/listing/dmp-listing.component.ts | 6 ++-
.../dmp-listing-item.component.html | 14 ++++++-
.../dmp-listing-item.component.ts | 30 ++++++++-------
.../dmp/overview/dmp-overview.component.html | 15 ++++++--
.../ui/dmp/overview/dmp-overview.component.ts | 11 ++++--
31 files changed, 215 insertions(+), 151 deletions(-)
diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/file/TransformerCacheModel.java b/dmp-backend/core/src/main/java/eu/eudat/model/file/TransformerCacheModel.java
index 2be248f43..a61eaaf5b 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/model/file/TransformerCacheModel.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/model/file/TransformerCacheModel.java
@@ -1,22 +1,24 @@
package eu.eudat.model.file;
+import eu.eudat.file.transformer.model.file.FileFormat;
+
import java.util.List;
public class TransformerCacheModel {
- private List formats;
+ private List formats;
public TransformerCacheModel() {
}
- public TransformerCacheModel(List formats) {
+ public TransformerCacheModel(List formats) {
this.formats = formats;
}
- public List getFormats() {
+ public List getFormats() {
return formats;
}
- public void setFormats(List formats) {
+ public void setFormats(List formats) {
this.formats = formats;
}
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/repository/TransformerRepository.java b/dmp-backend/core/src/main/java/eu/eudat/repository/TransformerRepository.java
index d33508d60..4d4cf9acd 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/repository/TransformerRepository.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/repository/TransformerRepository.java
@@ -5,6 +5,7 @@ import eu.eudat.file.transformer.model.DescriptionFileTransformerModel;
import eu.eudat.file.transformer.model.DmpFileTransformerModel;
import eu.eudat.file.transformer.model.ExtraPropertiesModel;
import eu.eudat.file.transformer.model.file.FileEnvelope;
+import eu.eudat.file.transformer.model.file.FileFormat;
import eu.eudat.utilities.webclient.WebClientUtils;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.reactive.function.client.WebClient;
@@ -43,8 +44,8 @@ public class TransformerRepository implements FileTransformerExecutor {
}
@Override
- public List getSupportedFileFormats() {
- return transformerClient.get().uri("/formats").exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference>() {})).block();
+ public List getSupportedFileFormats() {
+ return transformerClient.get().uri("/formats").exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference>() {})).block();
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java
index 42ad3f7af..352bb90b1 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionService.java
@@ -24,7 +24,7 @@ public interface DescriptionService {
void clone(UUID dmpId, UUID descriptionId) throws InvalidApplicationException;
- ResponseEntity export(UUID id, DescriptionServiceImpl.DescriptionExportType exportType) throws InvalidApplicationException, IOException;
+ ResponseEntity export(UUID id, String exportType) throws InvalidApplicationException, IOException;
}
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java
index bb2901e7a..281b9412b 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java
@@ -582,32 +582,16 @@ public class DescriptionServiceImpl implements DescriptionService {
//region file export
- public enum DescriptionExportType {
- Word, Pdf, Xml;
- }
@Override
- public ResponseEntity export(UUID id, DescriptionExportType exportType) throws InvalidApplicationException, IOException {
+ public ResponseEntity export(UUID id, String exportType) throws InvalidApplicationException, IOException {
HttpHeaders headers = new HttpHeaders();
- String type = switch(exportType) {
- case Word -> "docx";
- case Pdf -> "pdf";
- case Xml -> "xml";
- };
+ String type = exportType;
FileEnvelope fileEnvelope = this.fileTransformerService.exportDescription(id, type);
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
byte[] data = Files.readAllBytes(fileEnvelope.getFile().toPath());
- switch (exportType){
- case Xml -> {
- headers.setContentType(MediaType.APPLICATION_XML);
- return new ResponseEntity<>(data, headers, HttpStatus.OK);
- }
- case Word, Pdf -> {
- headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
- return new ResponseEntity<>(data, headers, HttpStatus.OK);
- }
- }
- return ResponseEntity.badRequest().body(new byte[]{});
+ headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+ return new ResponseEntity<>(data, headers, HttpStatus.OK);
}
//endregion
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java
index 040657145..4888c3202 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpService.java
@@ -23,10 +23,6 @@ import java.util.UUID;
public interface DmpService {
- enum DmpExportType {
- Word, Pdf, Json, Xml;
- }
-
Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JsonProcessingException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException, IOException;
@@ -38,7 +34,7 @@ public interface DmpService {
List assignUsers(UUID dmp, List model, FieldSet fields) throws InvalidApplicationException;
Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException;
- ResponseEntity export(UUID id, DmpExportType exportType) throws InvalidApplicationException, IOException;
+ ResponseEntity export(UUID id, String exportType) throws InvalidApplicationException, IOException;
void inviteUsers(UUID id, DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException;
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java
index 388374026..f48ccb161 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmp/DmpServiceImpl.java
@@ -456,33 +456,15 @@ public class DmpServiceImpl implements DmpService {
}
@Override
- public ResponseEntity export(UUID id, DmpExportType exportType) throws InvalidApplicationException, IOException {
+ public ResponseEntity export(UUID id, String exportType) throws InvalidApplicationException, IOException {
HttpHeaders headers = new HttpHeaders();
- String type = switch(exportType) {
- case Word -> "docx";
- case Pdf -> "pdf";
- case Json -> "json";
- case Xml -> "xml";
- };
+ String type = exportType;
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(id, type);
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
byte[] data = Files.readAllBytes(fileEnvelope.getFile().toPath());
- switch (exportType){
- case Xml -> {
- headers.setContentType(MediaType.APPLICATION_XML);
- return new ResponseEntity<>(data, headers, HttpStatus.OK);
- }
- case Json -> {
- headers.setContentType(MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(data, headers, HttpStatus.OK);
- }
- case Word, Pdf -> {
- headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
- return new ResponseEntity<>(data, headers, HttpStatus.OK);
- }
- }
- return ResponseEntity.badRequest().body(new byte[]{});
+ headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+ return new ResponseEntity<>(data, headers, HttpStatus.OK);
}
private DmpEntity patchAndSave(DmpPersist model) throws JsonProcessingException, InvalidApplicationException {
diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java b/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java
index 38b47cf38..16b4ed968 100644
--- a/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java
+++ b/dmp-backend/core/src/main/java/eu/eudat/service/transformer/FileTransformerService.java
@@ -12,6 +12,7 @@ import eu.eudat.file.transformer.model.DmpFileTransformerModel;
import eu.eudat.file.transformer.model.ExtraPropertiesModel;
import eu.eudat.file.transformer.model.descriptiontemplatedefinition.Field;
import eu.eudat.file.transformer.model.descriptiontemplatedefinition.Rule;
+import eu.eudat.file.transformer.model.file.FileFormat;
import eu.eudat.model.*;
import eu.eudat.model.builder.DescriptionBuilder;
import eu.eudat.model.builder.DmpBuilder;
@@ -116,15 +117,15 @@ public class FileTransformerService {
}
- public List getAvailableConfigurations() {
+ public List getAvailableConfigurations() {
TransformerCacheModel configs = fileTransformerConfigurationCache.lookup("base");
if (configs == null) {
- List configurations = new ArrayList<>();
+ List configurations = new ArrayList<>();
//GK: So much for lazy loading
List repositories = transformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getCodes().get(0))).toList();
repositories.forEach((client) -> {
- List repositoryConfigs = client.getSupportedFileFormats();
+ List repositoryConfigs = client.getSupportedFileFormats();
if (repositoryConfigs != null && !repositoryConfigs.isEmpty()) {
configurations.addAll(repositoryConfigs);
}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java
index ac315984b..37b3705c4 100644
--- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java
+++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionController.java
@@ -6,6 +6,7 @@ import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.commons.enums.DmpAccessType;
import eu.eudat.commons.enums.DmpStatus;
import eu.eudat.commons.enums.IsActive;
+import eu.eudat.file.transformer.model.file.FileFormat;
import eu.eudat.model.Description;
import eu.eudat.model.Dmp;
import eu.eudat.model.PublicDescription;
@@ -22,6 +23,7 @@ import eu.eudat.service.description.DescriptionService;
import eu.eudat.service.description.DescriptionServiceImpl;
import eu.eudat.service.dmp.DmpService;
import eu.eudat.service.elastic.ElasticQueryHelperService;
+import eu.eudat.service.transformer.FileTransformerService;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.censor.CensorFactory;
@@ -64,14 +66,15 @@ public class DescriptionController {
private final MessageSource messageSource;
private final ElasticQueryHelperService elasticQueryHelperService;
+ private final FileTransformerService fileTransformerService;
public DescriptionController(
BuilderFactory builderFactory,
AuditService auditService,
DescriptionService descriptionService,
CensorFactory censorFactory,
QueryFactory queryFactory,
- MessageSource messageSource,
- ElasticQueryHelperService elasticQueryHelperService) {
+ MessageSource messageSource,
+ ElasticQueryHelperService elasticQueryHelperService, FileTransformerService fileTransformerService) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.descriptionService = descriptionService;
@@ -79,6 +82,7 @@ public class DescriptionController {
this.queryFactory = queryFactory;
this.messageSource = messageSource;
this.elasticQueryHelperService = elasticQueryHelperService;
+ this.fileTransformerService = fileTransformerService;
}
@PostMapping("public/query")
@@ -189,7 +193,12 @@ public class DescriptionController {
public ResponseEntity export(@PathVariable("id") UUID id, @PathVariable("type") String exportType) throws InvalidApplicationException, IOException {
logger.debug(new MapLogEntry("exporting description"));
- return this.descriptionService.export(id, DescriptionServiceImpl.DescriptionExportType.valueOf(exportType));
+ return this.descriptionService.export(id, exportType);
+ }
+
+ @GetMapping("/export/formats")
+ public List getAvailableExportFormats() {
+ return this.fileTransformerService.getAvailableConfigurations();
}
}
diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java
index 33355d0d1..019ae50ba 100644
--- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java
+++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpController.java
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import eu.eudat.audit.AuditableAction;
import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.data.DmpEntity;
+import eu.eudat.file.transformer.model.file.FileFormat;
import eu.eudat.model.Dmp;
import eu.eudat.model.DmpUser;
import eu.eudat.model.builder.DmpBuilder;
@@ -62,19 +63,22 @@ public class DmpController {
private final MessageSource messageSource;
+ private final FileTransformerService fileTransformerService;
+
public DmpController(
BuilderFactory builderFactory,
AuditService auditService,
DmpService dmpService,
CensorFactory censorFactory,
QueryFactory queryFactory,
- MessageSource messageSource) {
+ MessageSource messageSource, FileTransformerService fileTransformerService) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.dmpService = dmpService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
+ this.fileTransformerService = fileTransformerService;
}
@PostMapping("query")
@@ -203,7 +207,12 @@ public class DmpController {
public ResponseEntity export(@PathVariable("id") UUID id, @PathVariable("type") String exportType) throws InvalidApplicationException, IOException {
logger.debug(new MapLogEntry("exporting dmp"));
- return this.dmpService.export(id, DmpService.DmpExportType.valueOf(exportType));
+ return this.dmpService.export(id, exportType);
+ }
+
+ @GetMapping("/export/formats")
+ public List getAvailableExportFormats() {
+ return this.fileTransformerService.getAvailableConfigurations();
}
@PostMapping("{id}/invite-users")
diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/EntityDoiController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/EntityDoiController.java
index cd4c6b985..ac8e8b1ea 100644
--- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/EntityDoiController.java
+++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/EntityDoiController.java
@@ -11,6 +11,7 @@ import eu.eudat.model.persist.EntityDoiPersist;
import eu.eudat.model.result.QueryResult;
import eu.eudat.query.EntityDoiQuery;
import eu.eudat.query.lookup.EntityDoiLookup;
+import eu.eudat.service.deposit.DepositService;
import eu.eudat.service.entitydoi.EntityDoiService;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.data.builder.BuilderFactory;
@@ -43,6 +44,7 @@ public class EntityDoiController {
private final AuditService auditService;
private final EntityDoiService entityDoiService;
+ private final DepositService repositoryDepositService;
private final CensorFactory censorFactory;
@@ -54,12 +56,13 @@ public class EntityDoiController {
BuilderFactory builderFactory,
AuditService auditService,
EntityDoiService entityDoiService,
- CensorFactory censorFactory,
+ DepositService repositoryDepositService, CensorFactory censorFactory,
QueryFactory queryFactory,
MessageSource messageSource) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.entityDoiService = entityDoiService;
+ this.repositoryDepositService = repositoryDepositService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
diff --git a/dmp-frontend/src/app/core/services/description/description.service.ts b/dmp-frontend/src/app/core/services/description/description.service.ts
index cbd8c79f5..8e7309812 100644
--- a/dmp-frontend/src/app/core/services/description/description.service.ts
+++ b/dmp-frontend/src/app/core/services/description/description.service.ts
@@ -13,6 +13,7 @@ import { catchError, map } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Injectable()
export class DescriptionService {
@@ -76,13 +77,17 @@ export class DescriptionService {
catchError((error: any) => throwError(error)));
}
- public downloadPDF(id: string): Observable> {
- return this.httpClient.get(`${this.apiBase}/${id}/export/Pdf`, { responseType: 'blob', observe: 'response', headers: this.headers });
+ // public downloadPDF(id: string): Observable> {
+ // return this.httpClient.get(`${this.apiBase}/${id}/export/Pdf`, { responseType: 'blob', observe: 'response', headers: this.headers });
+ // }
+
+ public download(id: string, format: string): Observable> {
+ //let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
+ return this.httpClient.get(`${this.apiBase}/${id}/export/${format}`, { responseType: 'blob', observe: 'response', headers: this.headers });
}
- public downloadDOCX(id: string): Observable> {
- let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
- return this.httpClient.get(`${this.apiBase}/${id}/export/Word`, { responseType: 'blob', observe: 'response', headers: headerDocx });
+ public getExportFormats(): Observable {
+ return this.httpClient.get(`${this.apiBase}/export/formats`);
}
//
diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts
index e03f825d0..0dfcad89a 100644
--- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts
+++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts
@@ -34,6 +34,7 @@ import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { BaseHttpService } from '../http/base-http.service';
import { DmpStatus } from '@app/core/common/enum/dmp-status';
import { DmpDescriptionTemplateLookup } from '@app/core/query/dmp-description-template.lookup';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Injectable()
export class DmpServiceNew {
@@ -125,9 +126,9 @@ export class DmpServiceNew {
catchError((error: any) => throwError(error)));
}
- public downloadDocx(id: string): Observable> {
- let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
- return this.httpClient.get(`${this.apiBase}/${id}/export/Word`, { responseType: 'blob', observe: 'response', headers: headerDoc });
+ public download(id: string, format: string): Observable> {
+ //let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
+ return this.httpClient.get(`${this.apiBase}/${id}/export/${format}`, { responseType: 'blob', observe: 'response', headers: this.headers });
}
public downloadPDF(id: string): Observable> {
@@ -135,6 +136,10 @@ export class DmpServiceNew {
return this.httpClient.get(`${this.apiBase}/${id}/export/Pdf`, { responseType: 'blob', observe: 'response', headers: headerPdf });
}
+ public getExportFormats(): Observable {
+ return this.httpClient.get(`${this.apiBase}/export/formats`);
+ }
+
// public downloadJson(id: string): Observable> {
// return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' });
// }
diff --git a/dmp-frontend/src/app/core/services/matomo/matomo-service.ts b/dmp-frontend/src/app/core/services/matomo/matomo-service.ts
index 94b5654a7..16c07734a 100644
--- a/dmp-frontend/src/app/core/services/matomo/matomo-service.ts
+++ b/dmp-frontend/src/app/core/services/matomo/matomo-service.ts
@@ -37,7 +37,7 @@ export class MatomoService {
}
}
- trackDownload(category: "dmps" | "datasets" | "descriptions", type: "docx" | "pdf" | "xml" | "json", id: string): void {
+ trackDownload(category: "dmps" | "datasets" | "descriptions", type: string, id: string): void {
if (this.configurationService.matomoEnabled) {
var principalid = this.authService.userId();
if (principalid != null) { this.matomoTracker.setUserId(principalid.toString()); }
diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html
index 647f8a1c7..964c18692 100644
--- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html
+++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html
@@ -24,8 +24,8 @@
0">
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
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 38de03551..d71b40a1c 100644
--- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts
+++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts
@@ -16,6 +16,8 @@ import { BaseComponent } from '@common/base/base.component';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { AuthService } from '../../../core/services/auth/auth.service';
+import { FileFormat } from '@app/core/model/file/file-format.model';
+import { DmpServiceNew } from '@app/core/services/dmp/dmp.service';
@Component({
selector: 'app-drafts',
@@ -27,6 +29,7 @@ export class DraftsComponent extends BaseComponent implements OnInit {
lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
pageSize: number = 5;
listingItems: RecentActivityItem[];
+ fileFormats: FileFormat[] = [];
public formGroup = new UntypedFormBuilder().group({
like: new UntypedFormControl(),
@@ -49,7 +52,8 @@ export class DraftsComponent extends BaseComponent implements OnInit {
private authentication: AuthService,
private dashboardService: DashboardService,
private location: Location,
- private matomoService: MatomoService
+ private matomoService: MatomoService,
+ private dmpServiceNew: DmpServiceNew
) {
super();
}
@@ -84,6 +88,7 @@ export class DraftsComponent extends BaseComponent implements OnInit {
this.updateUrl();
}
});
+ this.dmpServiceNew.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result);
if (this.isAuthenticated()) {
this.refresh();
}
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 54e05f9cd..957d1e861 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
@@ -26,7 +26,7 @@
0">
@@ -35,4 +35,4 @@
0 && (allRecentActivities.length >= startIndex + pageSize) && hasMoreActivity" class="d-flex justify-content-center">
-
\ No newline at end of file
+
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 da4eca1ea..a94a3e005 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
@@ -7,10 +7,12 @@ import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-it
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
import { Description } from '@app/core/model/description/description';
import { Dmp, DmpUser } from '@app/core/model/dmp/dmp';
+import { FileFormat } from '@app/core/model/file/file-format.model';
import { DmpReference, Reference } from '@app/core/model/reference/reference';
import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup';
import { AuthService } from '@app/core/services/auth/auth.service';
import { DashboardService } from '@app/core/services/dashboard/dashboard.service';
+import { DmpServiceNew } from '@app/core/services/dmp/dmp.service';
import { MatomoService } from '@app/core/services/matomo/matomo-service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
@@ -27,6 +29,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
lookup: RecentActivityItemLookup = new RecentActivityItemLookup();
pageSize: number = 5;
listingItems: RecentActivityItem[];
+ fileFormats: FileFormat[] = [];
public formGroup = new UntypedFormBuilder().group({
@@ -50,7 +53,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
private authentication: AuthService,
private dashboardService: DashboardService,
private location: Location,
- private matomoService: MatomoService
+ private matomoService: MatomoService,
+ private dmpServiceNew: DmpServiceNew
) {
super();
}
@@ -85,6 +89,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
this.updateUrl();
}
});
+ this.dmpServiceNew.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result);
if (this.isAuthenticated()) {
this.refresh();
}
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html
index ff1282fcb..9f44d103b 100644
--- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html
+++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html
@@ -24,7 +24,7 @@
+ {{format.formatName}}
+
+
+
-
\ No newline at end of file
+
diff --git a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts
index b4769f897..ffd5a95ee 100644
--- a/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts
+++ b/dmp-frontend/src/app/ui/description/listing/listing-item/description-listing-item.component.ts
@@ -28,6 +28,7 @@ import { DmpService, DmpServiceNew } from '@app/core/services/dmp/dmp.service';
import { ReferenceService } from '@app/core/services/reference/reference.service';
import { ReferenceType } from '@app/core/common/enum/reference-type';
import { DescriptionCopyDialogComponent } from '../../description-copy-dialog/description-copy-dialog.component';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Component({
selector: 'app-description-listing-item-component',
@@ -39,6 +40,7 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
@Input() description: Description;
@Input() showDivider: boolean = true;
@Input() isPublic: boolean = false;
+ @Input() fileFormats: FileFormat[] = [];
@Output() onClick: EventEmitter = new EventEmitter();
isDraft: boolean;
@@ -48,6 +50,7 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
dmpAccessTypeEnum = DmpAccessType;
referenceTypeEnum = ReferenceType;
+
constructor(
private router: Router,
public enumUtils: EnumUtils,
@@ -103,27 +106,27 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
return this.isPublic ? [`/explore-plans/publicOverview/${this.description.dmp.id}`] : [`/plans/edit/${this.description.dmp.id}`];
}
- downloadPDF(description: Description): void {
- this.descriptionService.downloadPDF(description.id.toString())
+ // downloadPDF(description: Description): void {
+ // this.descriptionService.downloadPDF(description.id.toString())
+ // .pipe(takeUntil(this._destroyed))
+ // .subscribe(response => {
+ // const blob = new Blob([response.body], { type: 'application/pdf' });
+ // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
+
+ // FileSaver.saveAs(blob, filename);
+ // this.matomoService.trackDownload('descriptions', "pdf", description.id.toString());
+ // });
+ // }
+
+ download(description: Description, format: string): void {
+ this.descriptionService.download(description.id.toString(), format)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/pdf' });
+ const blob = new Blob([response.body], { type: 'application/octet-stream' });
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('descriptions', "pdf", description.id.toString());
- });
- }
-
- downloadDOCX(description: Description): void {
- this.descriptionService.downloadDOCX(description.id.toString())
- .pipe(takeUntil(this._destroyed))
- .subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/msword' });
- const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
-
- FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('descriptions', "docx", description.id.toString());
+ this.matomoService.trackDownload('descriptions', format, description.id.toString());
});
}
diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html
index fafc186de..967bf04a8 100644
--- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.html
+++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.html
@@ -117,6 +117,15 @@
{{ 'DESCRIPTION-OVERVIEW.ACTIONS.EXPORT' | translate }}
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts
index e2a401b2a..16eb10feb 100644
--- a/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts
+++ b/dmp-frontend/src/app/ui/description/overview/description-overview.component.ts
@@ -29,11 +29,12 @@ import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-d
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { Guid } from '@common/types/guid';
import { TranslateService } from '@ngx-translate/core';
-import { filter, takeUntil } from 'rxjs/operators';
+import { filter, take, takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { DescriptionCopyDialogComponent } from '../description-copy-dialog/description-copy-dialog.component';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import * as FileSaver from 'file-saver';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Component({
@@ -58,6 +59,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
referenceTypeEnum = ReferenceType;
dmpStatusEnum = DmpStatus;
dmpUserRoleEnum = DmpUserRole;
+ fileFormats: FileFormat[] = [];
constructor(
private route: ActivatedRoute,
@@ -138,6 +140,8 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
});
}
});
+
+ this.descriptionService.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result);
}
checkLockStatus(id: Guid) {
@@ -291,27 +295,27 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
return path + reference;
}
- downloadPDF(id: string) {
- this.descriptionService.downloadPDF(id)
+ // downloadPDF(id: string) {
+ // this.descriptionService.downloadPDF(id)
+ // .pipe(takeUntil(this._destroyed))
+ // .subscribe(response => {
+ // const blob = new Blob([response.body], { type: 'application/pdf' });
+ // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
+
+ // FileSaver.saveAs(blob, filename);
+ // this.matomoService.trackDownload('descriptions', "pdf", id);
+ // });
+ // }
+
+ download(id: string, format: string) {
+ this.descriptionService.download(id, format)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/pdf' });
+ const blob = new Blob([response.body], { type: 'application/octet-stream' });
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('descriptions', "pdf", id);
- });
- }
-
- downloadDocx(id: string) {
- this.descriptionService.downloadDOCX(id)
- .pipe(takeUntil(this._destroyed))
- .subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/msword' });
- const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
-
- FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('descriptions', "docx", id);
+ this.matomoService.trackDownload('descriptions', format, id);
});
}
diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html
index 71cd988bb..f06be2118 100644
--- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html
+++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html
@@ -47,7 +47,7 @@
0 && this.lookup?.page?.offset < this.totalCount - 1 && this.pageSize < this.totalCount - 1" class="d-flex justify-content-center">
diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts
index a79cbc0c8..baaca9e64 100644
--- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts
+++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts
@@ -27,6 +27,7 @@ import { TranslateService } from '@ngx-translate/core';
import { NgDialogAnimationService } from "ng-dialog-animation";
import { debounceTime, takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Component({
selector: 'app-dmp-listing-component',
@@ -44,6 +45,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr
isPublic: boolean = false;
hasListingItems = null;
pageSize: number = 5;
+ fileFormats: FileFormat[] = [];
public formGroup = new UntypedFormBuilder().group({
like: new UntypedFormControl(),
order: new UntypedFormControl()
@@ -106,6 +108,8 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh(this.lookup));
+
+ this.dmpServiceNew.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result);
}
public dashboardTour: GuidedTour = {
@@ -316,4 +320,4 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr
public hasLikeCriteria(): boolean {
return this.lookup.like !== undefined && this.lookup.like !== null;
}
-}
\ No newline at end of file
+}
diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html
index 3d8a5bd20..3a9e05762 100644
--- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html
+++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html
@@ -38,7 +38,17 @@
more_horiz
+
+
+
+
+
+
-
\ No newline at end of file
+
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 b838c6847..5ccccc0bd 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
@@ -23,6 +23,7 @@ import { takeUntil } from 'rxjs/operators';
import { DmpStatus } from '../../../../core/common/enum/dmp-status';
import { AuthService } from '../../../../core/services/auth/auth.service';
import * as FileSaver from 'file-saver';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Component({
selector: 'app-dmp-listing-item-component',
@@ -34,6 +35,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
@Input() dmp: Dmp;
@Input() showDivider: boolean = true;
@Input() isPublic: boolean;
+ @Input() fileFormats: FileFormat[] = [];
@Output() onClick: EventEmitter = new EventEmitter();
isDraft: boolean;
@@ -191,30 +193,30 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
// });
}
- downloadDocx(id: Guid) {
+ download(id: Guid, format: string) {
// TODO: Add this
- this.dmpService.downloadDocx(id.toString())
+ this.dmpService.download(id.toString(), format)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/msword' });
+ const blob = new Blob([response.body], { type: 'application/octet-stream' });
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('dmps', "docx", id.toString());
+ this.matomoService.trackDownload('dmps', format, id.toString());
});
}
- downloadPDF(id: Guid) {
- this.dmpService.downloadPDF(id.toString())
- .pipe(takeUntil(this._destroyed))
- .subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/pdf' });
- const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
+ // downloadPDF(id: Guid) {
+ // this.dmpService.downloadPDF(id.toString())
+ // .pipe(takeUntil(this._destroyed))
+ // .subscribe(response => {
+ // const blob = new Blob([response.body], { type: 'application/pdf' });
+ // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
- FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('dmps', "pdf", id.toString());
- });
- }
+ // FileSaver.saveAs(blob, filename);
+ // this.matomoService.trackDownload('dmps', "pdf", id.toString());
+ // });
+ // }
downloadJson(id: Guid) {
// TODO: Add this
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 e7580d2a2..aa2d902b2 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
@@ -143,7 +143,7 @@
-
+ 0" [inputRepos]="inputRepos" [dmp]="dmp" (outputReposEmitter)="afterDeposit($event)">
+
+
+
+
+
-
\ No newline at end of file
+
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 4de426621..25a510b65 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
@@ -36,6 +36,7 @@ import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import * as FileSaver from 'file-saver';
+import { FileFormat } from '@app/core/model/file/file-format.model';
@Component({
selector: 'app-dmp-overview',
@@ -56,6 +57,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
textMessage: any;
pastVersions: Dmp[]; //TODO: get these from the backend
selectedModel: EntityDoi;
+ fileFormats: FileFormat[] = [];
@ViewChild('doi')
doi: ElementRef;
@@ -153,6 +155,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
});
}
});
+ this.dmpService.getExportFormats().pipe(takeUntil(this._destroyed)).subscribe(result => this.fileFormats = result);
this.depositRepositoriesService.getAvailableRepos()
.pipe(takeUntil(this._destroyed))
.subscribe(
@@ -355,15 +358,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
// });
}
- downloadDocx(id: string) {
- this.dmpService.downloadDocx(id)
+ download(id: string, format: string) {
+ this.dmpService.download(id, format)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
- const blob = new Blob([response.body], { type: 'application/msword' });
+ const blob = new Blob([response.body], { type: 'application/octet-stream' });
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
FileSaver.saveAs(blob, filename);
- this.matomoService.trackDownload('dmps', "docx", id);
+ this.matomoService.trackDownload('dmps', format, id);
});
}