Skip to content

Commit

Permalink
feat: add button to convert to pdf
Browse files Browse the repository at this point in the history
Integrates backend endpoint to convert docx, odt to pdf
  • Loading branch information
Yelinz committed Feb 20, 2024
1 parent 4dad0e1 commit cb7da6f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
11 changes: 10 additions & 1 deletion addon/components/single-document-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,16 @@
</ul>
</div>

<div class="uk-grid-small uk-child-width-1-2" uk-grid>
<div class="uk-grid-small uk-child-width-1-3" uk-grid>
<div>
<UkButton
@size="small"
class="uk-width-1"
>
{{t "alexandria.document-details.convert"}}
</UkButton>
</div>

<div uk-form-custom>
<input
data-test-replace
Expand Down
14 changes: 14 additions & 0 deletions addon/components/single-document-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,18 @@ export default class SingleDocumentDetailsComponent extends DocumentCard {
);
}
}

@dropTask
*convertToPDF(event) {
event?.preventDefault();
try {
let url = this.config?.zipDownloadHost || "";
url += this.config?.zipDownloadNamespace || "";
url += `/api/v1/document/${this.args.document.id}/convert`;
yield this.fetch.fetch(url);
this.notification.success(this.intl.t("alexandria.success.covert-pdf"));
} catch (error) {
new ErrorHandler(this, error).notify("alexandria.errors.convert-pdf");
}
}
}
3 changes: 3 additions & 0 deletions translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ alexandria:
update: "Your changes chould'nt be saved. Please try again."
no-permission: "You don't have permission to perform this action."
move-document: "While moving {count, plural, one {the document} other {# documents}}, an error occured. Please try again."
covert-pdf: "While converting, an error occured. Please try again."

success:
delete-document: "Document deleted successfully"
Expand All @@ -30,6 +31,7 @@ alexandria:
} uploaded successfully.
update: "Changes saved."
move-document: "{count, plural, one {Document} other {# documents}} moved successfully"
covert-pdf: "Document converted successfully."

category-nav:
all-files: "All documents"
Expand Down Expand Up @@ -70,6 +72,7 @@ alexandria:
created-by-user: "Created by user"
created-by-group: "Created by group"
replace: "Replace"
convert: "To PDF"
tags:
title: "Tags"
add: "Add"
Expand Down

0 comments on commit cb7da6f

Please sign in to comment.