Provide a platform override option during web based import (#94)
This commit is contained in:
@@ -12,9 +12,20 @@
|
||||
<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/Roms",
|
||||
@@ -69,4 +80,51 @@
|
||||
subModalContent.innerHTML = "";
|
||||
subModalVariables = null;
|
||||
}
|
||||
|
||||
$('#upload_platformoverride').select2({
|
||||
minimumInputLength: 3,
|
||||
ajax: {
|
||||
url: '/api/v1/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/Roms" + queryString;
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user