-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- remove "instrument-detail" page - add two buttons on each instrument card: "Upload new images" & "View on wikidata" - initialize image upload modal UI Refs: #150
- Loading branch information
1 parent
081e07b
commit aa13e25
Showing
11 changed files
with
230 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
web-app/django/VIM/apps/instruments/static/instruments/js/ImageUpload.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function displaySelectedImage(event, elementId) { | ||
const selectedImage = document.getElementById(elementId); | ||
const fileInput = event.target; | ||
|
||
if (fileInput.files && fileInput.files[0]) { | ||
const reader = new FileReader(); | ||
|
||
reader.onload = function (e) { | ||
selectedImage.src = e.target.result; | ||
}; | ||
|
||
reader.readAsDataURL(fileInput.files[0]); | ||
} | ||
} | ||
|
||
// Get the modal element | ||
var uploadImagesModal = document.getElementById('uploadImagesModal'); | ||
|
||
uploadImagesModal.addEventListener('show.bs.modal', function (event) { | ||
var button = event.relatedTarget; | ||
var instrumentName = button.getAttribute('data-instrument-name'); | ||
var instrumentWikidataId = button.getAttribute('data-instrument-wikidata-id'); | ||
var instrumentNameInModal = uploadImagesModal.querySelector( | ||
'#instrumentNameInModal' | ||
); | ||
instrumentNameInModal.textContent = instrumentName; | ||
|
||
var instrumentWikidataIdInModal = uploadImagesModal.querySelector( | ||
'#instrumentWikidataId' | ||
); | ||
instrumentWikidataIdInModal.textContent = instrumentWikidataId; | ||
}); | ||
|
||
document | ||
.getElementById('imageFiles') | ||
.addEventListener('change', function (event) { | ||
var previewContainer = document.getElementById('previewImages'); | ||
previewContainer.innerHTML = ''; // Clear existing previews | ||
|
||
var files = event.target.files; | ||
|
||
for (var i = 0; i < files.length; i++) { | ||
var file = files[i]; | ||
|
||
// Ensure that the file is an image | ||
if (file.type.startsWith('image/')) { | ||
var reader = new FileReader(); | ||
|
||
reader.onload = (function (file) { | ||
return function (e) { | ||
var colDiv = document.createElement('div'); | ||
colDiv.className = 'col-3'; | ||
|
||
var img = document.createElement('img'); | ||
img.src = e.target.result; | ||
img.className = 'img-thumbnail'; | ||
img.alt = file.name; | ||
img.style.maxHeight = '150px'; | ||
img.style.objectFit = 'cover'; | ||
|
||
colDiv.appendChild(img); | ||
previewContainer.appendChild(colDiv); | ||
}; | ||
})(file); | ||
|
||
reader.readAsDataURL(file); | ||
} | ||
} | ||
}); |
41 changes: 0 additions & 41 deletions
41
web-app/django/VIM/apps/instruments/static/instruments/js/InstrumentDetail.js
This file was deleted.
Oops, something went wrong.
157 changes: 0 additions & 157 deletions
157
web-app/django/VIM/apps/instruments/templates/instruments/detail.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.