Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h5 class="modal-title" id="title-of-dialog">Upload New Slide</h5>
<h3>Steps for uploading.</h3>
<ul>
<li>Select the file you wish to upload. The <b>Token</b> field should be automatically populated .</li>
<li>Enter the desired filename, including its extension, for the destination file.</li>
<li> Provide the destination filename with extension. For example "sample.svs"</li>
<li>Click on the <b><i class="fas fa-arrow-right"></i></b> button to preview the slide.</li>
<li>Click on <b>Finish Upload</b> to complete the process and post the slide to caMicroscope.</li>
</ul>
Expand Down
20 changes: 18 additions & 2 deletions apps/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,22 @@ function fileNameChange() {
const fileName = fileNameInput.val();
let newFileName = fileName.split(' ').join('_');
fileNameInput.val(newFileName);
let fileExtension = newFileName.toLowerCase().split('.').reverse()[0];
if (!allowedExtensions.includes(fileExtension)) {
let fileParts = newFileName.split('.');
let fileExtension = fileParts.length > 1 ? fileParts.reverse()[0].toLowerCase() : null;
if (!fileExtension) {
fileNameInput.addClass('is-invalid');
let fDiv = document.getElementById('filename-feedback0');

if (!fDiv) {
fileNameInput.addClass('is-invalid');
let fDiv = document.createElement('div');
fDiv.classList.add('invalid-feedback');
fDiv.id = 'filename-feedback0';
fDiv.textContent = 'The file name you provided is incompatible. File names should follow this format "filename.ext"';
fileNameInput.parent().append(fDiv);
}

} else if (!allowedExtensions.includes(fileExtension)) {
fileNameInput.addClass('is-invalid');
let fDiv = document.createElement('div');
fDiv.classList.add('invalid-feedback');
Expand All @@ -734,6 +748,8 @@ function fileNameChange() {
}
}
}


function switchToFile() {
$('.urlUploadClass').css('display', 'none');
$('.fileInputClass').css('display', 'block');
Expand Down