Files
gaseous-server/gaseous-server/wwwroot/pages/dialogs/upload.html
2023-11-25 14:50:44 +11:00

130 lines
3.8 KiB
HTML

<!-- The Modal -->
<div id="myModalSub" class="modal">
<!-- Modal content -->
<div class="modal-content-sub">
<span id="modal-close-sub" class="close">&times;</span>
<div id="modal-content-sub">Some text in the Modal..</div>
</div>
</div>
<div>
<div id="upload_target" class="dropzone"></div>
</div>
<table style="width: 100%;">
<tr>
<th style="width: 40%;">
Override automatic platform detection:
</th>
<td style="width: 60%;">
<select id="upload_platformoverride" style="width: 100%;"></select>
</td>
</tr>
</table>
<script type="text/javascript">
document.getElementById('modal-heading').innerHTML = "Upload";
document.getElementById('upload_platformoverride').innerHTML = "<option value='0' selected='selected'>Automatic Platform</option>";
var myDropzone = new Dropzone("div#upload_target", {
url: "/api/v1.1/Roms",
autoProcessQueue: true,
uploadMultiple: true,
paramName: myParamName,
maxFilesize: 60000,
createImageThumbnails: false,
disablePreviews: false
});
function myParamName() {
return "files";
}
function showSubDialog(dialogPage, variables) {
// Get the modal
var submodal = document.getElementById("myModalSub");
// Get the modal content
var subModalContent = document.getElementById("modal-content-sub");
// Get the button that opens the modal
var subbtn = document.getElementById("romDelete");
// Get the <span> element that closes the modal
var subspan = document.getElementById("modal-close-sub");
// When the user clicks on the button, open the modal
submodal.style.display = "block";
// When the user clicks on <span> (x), close the modal
subspan.onclick = function () {
submodal.style.display = "none";
subModalContent.innerHTML = "";
subModalVariables = null;
}
subModalVariables = modalVariables;
$('#modal-content-sub').load('/pages/dialogs/' + dialogPage + '.html?v=' + AppVersion);
}
function closeSubDialog() {
// Get the modal
var submodal = document.getElementById("myModalSub");
// Get the modal content
var subModalContent = document.getElementById("modal-content-sub");
submodal.style.display = "none";
subModalContent.innerHTML = "";
subModalVariables = null;
}
$('#upload_platformoverride').select2({
minimumInputLength: 3,
ajax: {
url: '/api/v1.1/Search/Platform',
data: function (params) {
var query = {
SearchString: params.term
}
// Query parameters will be ?SearchString=[term]
return query;
},
processResults: function (data) {
var arr = [];
// insert automatic detection item
arr.push({
id: 0,
text: "Automatic Platform"
});
for (var i = 0; i < data.length; i++) {
arr.push({
id: data[i].id,
text: data[i].name
});
}
return {
results: arr
};
}
}
});
$('#upload_platformoverride').on('select2:select', function (e) {
var platformOverride = $('#upload_platformoverride').select2('data');
var queryString = '';
if (Number(platformOverride[0].id) != 0) {
queryString = "?OverridePlatformId=" + platformOverride[0].id;
}
console.log(queryString);
myDropzone.options.url = "/api/v1.1/Roms" + queryString;
});
</script>