Files
gaseous-server/gaseous-server/wwwroot/pages/dialogs/librarynew.html
Michael Green 1934558595 Create libraries based on external unmanaged directories (#147)
* Library management is now complete

* Library functions complete

* Added default platform support
2023-10-09 12:19:59 +11:00

91 lines
3.0 KiB
HTML

<div style="padding-top: 5px;">
<strong>New Library</strong>
</div>
<div style="width: 300px;">
<table style="width: 98%; margin-top: 15px; margin-bottom: 15px;">
<tr>
<th>Name</th>
<td><input type="text" id="newlibrary_name" style="width: 95%;" /></td>
</tr>
<tr>
<th>Default Platform</th>
<td><select id="newlibrary_defaultplatform" style="width: 100%;"></select></td>
</tr>
<tr>
<th>Path</th>
<td><input type="text" id="newlibrary_path" style="width: 95%;" /></td>
</tr>
</table>
<div style="width: 100%; text-align: right;">
<div style="display: inline-block; margin-right: 20px;">
<button value="OK" onclick="newLibrary();">OK</button>
</div>
<div style="display: inline-block;">
<button value="Cancel" onclick="closeSubDialog();">Cancel</button>
</div>
</div>
</div>
<script type="text/javascript">
$('#newlibrary_defaultplatform').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 = [];
arr.push({
id: 0,
text: 'Any'
});
for (var i = 0; i < data.length; i++) {
arr.push({
id: data[i].id,
text: data[i].name
});
}
return {
results: arr
};
}
}
});
document.getElementById('newlibrary_defaultplatform').innerHTML = "<option value='" + 0 + "' selected='selected'>Any</option>";
function newLibrary() {
var libName = document.getElementById('newlibrary_name').value;
var libPlatform = $('#newlibrary_defaultplatform').select2('data');
var libPath = document.getElementById('newlibrary_path').value;
if (libName.length == 0) {
alert("A library name must be provided.")
} else if (libPath.length == 0) {
alert("A path must be provided.");
} else {
ajaxCall(
'/api/v1/Library?Name=' + encodeURIComponent(libName) + '&DefaultPlatformId=' + libPlatform[0].id + '&Path=' + encodeURIComponent(libPath),
'POST',
function(result) {
drawLibrary();
closeSubDialog();
},
function(error) {
alert('An error occurred while creating the library:\n\n' + JSON.stringify(error.responseText));
}
);
}
}
</script>