Fixed Issues With Progress Bar inflicted by changes in visibility service
This commit is contained in:
parent
2c2133bb28
commit
7cc9854f11
|
@ -159,5 +159,26 @@ public class DMPs extends BaseController {
|
|||
responseHeaders,
|
||||
HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
||||
File file = new DataManagementPlanManager().getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File pdffile = new DatasetManager().convertToPDF(file, environment, file.getName());
|
||||
InputStream resource = new FileInputStream(pdffile);
|
||||
System.out.println("Mime Type of " + file.getName() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(file));
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentLength(pdffile.length());
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + pdffile.getName());
|
||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||
|
||||
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
||||
return new ResponseEntity<>(content,
|
||||
responseHeaders,
|
||||
HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
<button mat-menu-item (click)="downloadDocx(this.dataManagementPlan.id)">
|
||||
<mat-icon>save_alt</mat-icon>{{'DMP-LISTING.ACTIONS.DOWNLOAD-DOCX' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="downloadPDF(this.dataManagementPlan.id)">
|
||||
<mat-icon>save_alt</mat-icon>{{'DMP-LISTING.ACTIONS.DOWNLOAD-PDF' | translate}}
|
||||
</button>
|
||||
</mat-menu>
|
||||
<div>
|
||||
<button mat-icon-button type="button" [matMenuTriggerFor]="actionsMenu">
|
||||
|
|
|
@ -352,6 +352,15 @@ export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadC
|
|||
});
|
||||
}
|
||||
|
||||
downloadPDF(id: string) {
|
||||
this.dataManagementPlanService.downloadPDF(id).subscribe(response => {
|
||||
const blob = new Blob([response.body], { type: 'application/octet-stream' });
|
||||
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);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div>
|
||||
<div class="alignment-center">
|
||||
<!-- <ngb-pagination *ngIf="pages" [collectionSize]="pages.length*10" [page]="currentPageIndex" (pageChange)="changePageIndex($event)" aria-label="Default pagination"></ngb-pagination> -->
|
||||
<!-- <app-progress-bar *ngIf="form" [formGroup]="form"></app-progress-bar> -->
|
||||
<app-progress-bar *ngIf="form" [formGroup]="form"></app-progress-bar>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -54,12 +54,13 @@ export class ProgressBarComponent implements OnInit {
|
|||
if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); } else if (control instanceof FormArray) {
|
||||
const formArray = (<FormArray>control);
|
||||
for (let i = 0; i < formArray.length; i++) {
|
||||
//if (<FormGroup>formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
|
||||
//value += this.getFormControlDepthLength(<FormGroup>formArray.get("" + i))
|
||||
if (<FormGroup>formArray.get('' + i).value && this.visibilityRulesService.checkElementVisibility(formArray.get('' + i).value.id)) {
|
||||
value += this.getFormControlDepthLength(<FormGroup>formArray.get('' + i));
|
||||
}
|
||||
}
|
||||
} else if (key === 'value' && this.visibilityRulesService.checkElementVisibility(form.controls['id'].value)) {
|
||||
value++;
|
||||
}
|
||||
//else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
|
||||
//value++;
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ export class Field extends BaseModel implements Serializable<Field>, FormGenerat
|
|||
this.defaultValue = JsonSerializer.fromJSONObject(item.defaultValue, DefaultValue);
|
||||
this.value = this.defaultValue.value && !item.value ? this.defaultValue.value : item.value;
|
||||
//this.multiplicity = new Multiplicity();
|
||||
if (this.viewStyle.renderStyle === 'checkBox') {
|
||||
this.value = this.value === 'true';
|
||||
}
|
||||
// if (this.viewStyle.renderStyle === 'checkBox') {
|
||||
// this.value = this.value === 'true';
|
||||
// }
|
||||
//this.multiplicity.max = 2;
|
||||
if (item.multiplicityItems) { this.multiplicityItems = JsonSerializer.fromJSONArray(item.multiplicityItems, Field); }
|
||||
this.data = item.data;
|
||||
|
|
|
@ -79,4 +79,8 @@ export class DataManagementPlanService {
|
|||
public downloadDocx(id: string): Observable<HttpResponse<Blob>> {
|
||||
return this.httpClient.get(this.actionUrl + 'getWord/' + id, { responseType: 'blob', observe: 'response' });
|
||||
}
|
||||
|
||||
public downloadPDF(id: string): Observable<HttpResponse<Blob>> {
|
||||
return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response' });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,9 @@
|
|||
"NEW-VERSION": "New Version",
|
||||
"VIEW-VERSION": "All DMP Versions",
|
||||
"CLONE": "Clone",
|
||||
"DOWNLOAD-XML": "Download XML"
|
||||
"DOWNLOAD-XML": "Download XML",
|
||||
"DOWNLOAD-DOCX": "Download Document",
|
||||
"DOWNLOAD-PDF": "Download PDF"
|
||||
}
|
||||
},
|
||||
"DATASET-WIZARD": {
|
||||
|
|
Loading…
Reference in New Issue