Code clean up and API versioning (#178)

* Merged tools project into main project

* Applied API versioning
This commit is contained in:
Michael Green
2023-10-31 10:42:15 +11:00
committed by GitHub
parent 1cc7eb22dc
commit 2ade60c551
85 changed files with 338 additions and 297 deletions

View File

@@ -24,7 +24,7 @@
$('#collection_addgame').select2({
ajax: {
url: '/api/v1/Collections',
url: '/api/v1.0/Collections',
placeholder: 'Select collection',
processResults: function (data) {
var arr = [];
@@ -59,7 +59,7 @@
if (CollectionId != 0) {
ajaxCall(
'/api/v1/Collections/' + CollectionId + '/AlwaysInclude' + RebuildCollection,
'/api/v1.0/Collections/' + CollectionId + '/AlwaysInclude' + RebuildCollection,
'PATCH',
function (result) {
closeSubDialog();

View File

@@ -12,7 +12,7 @@
<script type="text/javascript">
function deleteCollection() {
ajaxCall(
'/api/v1/Collections/' + subModalVariables,
'/api/v1.0/Collections/' + subModalVariables,
'DELETE',
function (result) {
GetCollections();

View File

@@ -136,7 +136,7 @@
// setup dropdowns
$('#collection_platform').select2({
ajax: {
url: '/api/v1/Filter',
url: '/api/v1.0/Filter',
processResults: function (data) {
var filter = data['platforms'];
@@ -159,7 +159,7 @@
$('#collection_genres').select2({
ajax: {
url: '/api/v1/Filter',
url: '/api/v1.0/Filter',
processResults: function (data) {
var filter = data['genres'];
@@ -182,7 +182,7 @@
$('#collection_players').select2({
ajax: {
url: '/api/v1/Filter',
url: '/api/v1.0/Filter',
processResults: function (data) {
var filter = data['gamemodes'];
@@ -205,7 +205,7 @@
$('#collection_playerperspectives').select2({
ajax: {
url: '/api/v1/Filter',
url: '/api/v1.0/Filter',
processResults: function (data) {
var filter = data['playerperspectives'];
@@ -228,7 +228,7 @@
$('#collection_themes').select2({
ajax: {
url: '/api/v1/Filter',
url: '/api/v1.0/Filter',
processResults: function (data) {
var filter = data['themes'];
@@ -258,7 +258,7 @@
// edit mode
ajaxCall(
'/api/v1/Collections/' + modalVariables,
'/api/v1.0/Collections/' + modalVariables,
'GET',
function(result) {
if (result.name) { document.getElementById('collection_name').value = result.name; }
@@ -278,7 +278,7 @@
// fill select2 controls
$.ajax(
{
url: '/api/v1/Filter',
url: '/api/v1.0/Filter',
type: 'GET',
indexValue: result,
dataType: 'json',
@@ -344,7 +344,7 @@
// existing object - save over the top
item.id = modalVariables;
ajaxCall(
'/api/v1/Collections/' + modalVariables,
'/api/v1.0/Collections/' + modalVariables,
'PATCH',
function(result) {
location.reload();
@@ -357,7 +357,7 @@
} else {
// new object
ajaxCall(
'/api/v1/Collections',
'/api/v1.0/Collections',
'POST',
function(result) {
location.reload();
@@ -426,7 +426,7 @@
var item = GenerateCollectionItem();
ajaxCall(
'/api/v1/Collections/Preview',
'/api/v1.0/Collections/Preview',
'POST',
function(result) {
DisplayPreview(result, 'collectionedit_previewbox_content');
@@ -579,7 +579,7 @@
var gameImage = document.createElement('img');
gameImage.className = 'game_tile_image game_tile_image_small';
if (gameItem.cover) {
gameImage.src = '/api/v1/Games/' + gameItem.id + '/cover/image';
gameImage.src = '/api/v1.0/Games/' + gameItem.id + '/cover/image';
} else {
gameImage.src = '/images/unknowngame.png';
gameImage.className = 'game_tile_image game_tile_image_small unknown';

View File

@@ -12,7 +12,7 @@
<script type="text/javascript">
function deleteLibrary() {
ajaxCall(
'/api/v1/Library/' + subModalVariables,
'/api/v1.0/Library/' + subModalVariables,
'DELETE',
function (result) {
drawLibrary();

View File

@@ -32,7 +32,7 @@
$('#newlibrary_defaultplatform').select2({
minimumInputLength: 3,
ajax: {
url: '/api/v1/Search/Platform',
url: '/api/v1.0/Search/Platform',
data: function (params) {
var query = {
SearchString: params.term
@@ -76,7 +76,7 @@
alert("A path must be provided.");
} else {
ajaxCall(
'/api/v1/Library?Name=' + encodeURIComponent(libName) + '&DefaultPlatformId=' + libPlatform[0].id + '&Path=' + encodeURIComponent(libPath),
'/api/v1.0/Library?Name=' + encodeURIComponent(libName) + '&DefaultPlatformId=' + libPlatform[0].id + '&Path=' + encodeURIComponent(libPath),
'POST',
function(result) {
drawLibrary();

View File

@@ -12,7 +12,7 @@
<script type="text/javascript">
function deleteCollection() {
ajaxCall(
'/api/v1/Games/' + gameData.id + '/romgroup/' + subModalVariables,
'/api/v1.0/Games/' + gameData.id + '/romgroup/' + subModalVariables,
'DELETE',
function (result) {
loadRoms();

View File

@@ -105,7 +105,7 @@
DisplayWebEmulatorContent(false);
ajaxCall(
'/api/v1/PlatformMaps/' + modalVariables,
'/api/v1.0/PlatformMaps/' + modalVariables,
'GET',
function (result) {
// set heading
@@ -338,7 +338,7 @@
console.log(JSON.stringify(item));
ajaxCall(
'/api/v1/PlatformMaps/' + modalVariables,
'/api/v1.0/PlatformMaps/' + modalVariables,
'PATCH',
function (result) {
loadPlatformMapping();

View File

@@ -11,7 +11,7 @@
<script type="text/javascript">
function deleteRom() {
ajaxCall('/api/v1/Games/' + gameId + '/roms/' + modalVariables, 'DELETE', function (result) {
ajaxCall('/api/v1.0/Games/' + gameId + '/roms/' + modalVariables, 'DELETE', function (result) {
window.location.reload();
});
}

View File

@@ -118,7 +118,7 @@
}
}
ajaxCall('/api/v1/Games/' + gameId + '/roms/' + modalVariables, 'GET', function (result) {
ajaxCall('/api/v1.0/Games/' + gameId + '/roms/' + modalVariables, 'GET', function (result) {
romData = result;
document.getElementById('modal-heading').innerHTML = result.name;
document.getElementById('rominfo_library').innerHTML = result.library.name;
@@ -169,7 +169,7 @@
$('#properties_fixplatform').select2({
minimumInputLength: 3,
ajax: {
url: '/api/v1/Search/Platform',
url: '/api/v1.0/Search/Platform',
data: function (params) {
var query = {
SearchString: params.term
@@ -200,7 +200,7 @@
minimumInputLength: 3,
templateResult: DropDownRenderGameOption,
ajax: {
url: '/api/v1/Search/Game',
url: '/api/v1.0/Search/Game',
data: function (params) {
fixplatform = $('#properties_fixplatform').select2('data');
@@ -236,7 +236,7 @@
document.getElementById('properties_fixsave').setAttribute("disabled", "disabled");
ajaxCall('/api/v1/Games/' + gameId + '/roms/' + modalVariables + '?NewPlatformId=' + fixplatform[0].id + '&NewGameId=' + fixgame[0].id, 'PATCH', function (result) {
ajaxCall('/api/v1.0/Games/' + gameId + '/roms/' + modalVariables + '?NewPlatformId=' + fixplatform[0].id + '&NewGameId=' + fixgame[0].id, 'PATCH', function (result) {
window.location.reload();
});
}

View File

@@ -28,7 +28,7 @@
document.getElementById('upload_platformoverride').innerHTML = "<option value='0' selected='selected'>Automatic Platform</option>";
var myDropzone = new Dropzone("div#upload_target", {
url: "/api/v1/Roms",
url: "/api/v1.0/Roms",
autoProcessQueue: true,
uploadMultiple: true,
paramName: myParamName,
@@ -84,7 +84,7 @@
$('#upload_platformoverride').select2({
minimumInputLength: 3,
ajax: {
url: '/api/v1/Search/Platform',
url: '/api/v1.0/Search/Platform',
data: function (params) {
var query = {
SearchString: params.term
@@ -125,6 +125,6 @@
}
console.log(queryString);
myDropzone.options.url = "/api/v1/Roms" + queryString;
myDropzone.options.url = "/api/v1.0/Roms" + queryString;
});
</script>