Skip to content

Commit

Permalink
Remove templates re #10798
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed May 2, 2024
1 parent 4bbcd2f commit 247f92c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 67 deletions.
37 changes: 0 additions & 37 deletions arches/app/media/js/viewmodels/jsonld-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ define([
this.data2 = ko.observable(false);
this.moduleId = params.etlmoduleid;
ImporterViewModel.apply(this, arguments);
this.selectedTemplate = ko.observable();
this.loadStatus = ko.observable('ready');
this.downloadMode = ko.observable(false);
this.selectedLoadEvent = params.selectedLoadEvent || ko.observable();
Expand All @@ -26,9 +25,6 @@ define([
this.validated = params.validated || ko.observable();
this.getErrorReport = params.getErrorReport;
this.getNodeError = params.getNodeError;
this.templates = ko.observableArray(
arches.resources.map(resource => ({text: resource.name, id: resource.graphid}))
);

this.toggleDownloadMode = () => {
this.downloadMode(!this.downloadMode());
Expand All @@ -48,39 +44,6 @@ define([
return decodeURIComponent(xsrfCookies[0].split('=')[1]);
}

this.downloadTemplate = async() => {
const url = arches.urls.etl_manager;
const formData = new window.FormData();
formData.append("id", ko.unwrap(this.selectedTemplate));
formData.append("format", "xls");
formData.append("module", ko.unwrap(self.moduleId));
formData.append("action", "download");

const response = await window.fetch(url, {
method: 'POST',
body: formData,
credentials: 'same-origin',
headers: {
"Accept": "application/json",
"X-CSRFToken": getCookie("csrftoken")
}
});

const blob = await response.blob();
const urlObject = window.URL.createObjectURL(blob);
const a = window.document.createElement('a');
window.document.body.appendChild(a);
a.href = urlObject;
a.download = `${this.templates().filter(x => x.id == this.selectedTemplate())[0].text}.xlsx`;
a.click();

setTimeout(() => {
window.URL.revokeObjectURL(urlObject);
window.document.body.removeChild(a);
}, 0);
this.loading(false);
};

this.showAlert = (data) => {
self.alert(new AlertViewModel(
'ep-alert-red',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,10 @@
<h3>
<span data-bind="text: $root.translations.jsonldCap"></span>
</h3>
<h2>
<span data-bind="text: $root.translations.downloadTemplates"></span>
</h2>
<h4>
<span data-bind="text: $root.translations.selectAResourceModel"></span>
</h4>
<div style="display: flex; padding: 15px 25px; flex-direction: column; justify-content: center; align-items: center;">
<div style="width: 250px; display:flex; flex-direction: column;">
<div>
<!-- ko if: templates().length -->
<select style="display:inline-block;" data-bind="select2Query: {
select2Config: {
clickBubble: true,
disabled: false,
data: templates(),
value: selectedTemplate,
allowClear: true,
multiple: false,
placeholder: $root.translations.selectTemplate
}}">
</select>
<!--/ko-->
</div>
</div>
<!-- ko if: selectedTemplate() -->
<button style="border-top: 1px solid #c4c4c4; margin: 15px;" class="btn btn-primary btn-labeled btn-lg fa fa-download" data-bind="click: downloadTemplate" >
<span data-bind="text: $root.translations.download"></span>
</button>
<!-- /ko -->
<div style="margin-top: 15px;">
<button class="btn btn-primary btn-labeled btn-lg fa fa-cloud-upload" data-bind="click: toggleDownloadMode">
<span data-bind="text: $root.translations.uploadZipFile"></span>
Expand Down Expand Up @@ -85,11 +60,6 @@ <h4>
<h5>
<span data-bind="text: $root.translations.etlFileUploadMessage"></span>
</h5>
<div style="margin-top: 15px;">
<button class="btn btn-primary btn-labeled btn-lg fa fa-download" data-bind="click: toggleDownloadMode">
<span data-bind="text: $root.translations.downloadTemplates"></span>
</button>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 247f92c

Please sign in to comment.