From 9cb981a2e9f3f49a2cf1e938a0e78036fc4bb1b9 Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:33:14 +1000 Subject: [PATCH] feat: added ROM game match fixing --- .../Controllers/SearchController.cs | 2 +- gaseous-server/wwwroot/index.html | 2 + .../wwwroot/pages/dialogs/rominfo.html | 249 ++++++++++++++---- gaseous-server/wwwroot/pages/game.html | 4 +- gaseous-server/wwwroot/styles/style.css | 91 ++++++- gaseous-tools/Common.cs | 2 + 6 files changed, 299 insertions(+), 51 deletions(-) diff --git a/gaseous-server/Controllers/SearchController.cs b/gaseous-server/Controllers/SearchController.cs index aff9151..14c46a8 100644 --- a/gaseous-server/Controllers/SearchController.cs +++ b/gaseous-server/Controllers/SearchController.cs @@ -54,7 +54,7 @@ namespace gaseous_server.Controllers private static async Task> _SearchForGame(long PlatformId, string SearchString) { string searchBody = ""; - searchBody += "fields cover,first_release_date,name,platforms,slug; "; + searchBody += "fields cover.*,first_release_date,name,platforms,slug; "; searchBody += "search \"" + SearchString + "\";"; searchBody += "where platforms = (" + PlatformId + ");"; diff --git a/gaseous-server/wwwroot/index.html b/gaseous-server/wwwroot/index.html index 3599d04..e99a798 100644 --- a/gaseous-server/wwwroot/index.html +++ b/gaseous-server/wwwroot/index.html @@ -5,6 +5,8 @@ + + diff --git a/gaseous-server/wwwroot/pages/dialogs/rominfo.html b/gaseous-server/wwwroot/pages/dialogs/rominfo.html index df3194a..108c54d 100644 --- a/gaseous-server/wwwroot/pages/dialogs/rominfo.html +++ b/gaseous-server/wwwroot/pages/dialogs/rominfo.html @@ -1,54 +1,86 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Platform
File name
Size
ROM Type
Media Type
Media Label
MD5
SHA1
Signature Matched From
Signature Source Flags
+
+
General
+
Title Match
+
Manage
+
+
+ + + + + +
\ No newline at end of file + + function SelectTab(TabName) { + var tabs = document.getElementsByName('properties_tab'); + for (var i = 0; i < tabs.length; i++) { + if ((tabs[i].id) == ("properties_bodypanel_" + TabName)) { + tabs[i].style.display = ''; + } else { + tabs[i].style.display = 'none'; + } + } + + var tocs = document.getElementsByName('properties_toc_item'); + for (var i = 0; i < tocs.length; i++) { + if ((tocs[i].id) == ("properties_toc_" + TabName)) { + tocs[i].className = "properties_toc_item_selected"; + } else { + tocs[i].className = ''; + } + } + } + + $('#properties_fixplatform').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 = []; + + for (var i = 0; i < data.length; i++) { + arr.push({ + id: data[i].id, + text: data[i].name + }); + } + + return { + results: arr + }; + + } + } + }); + + $('#properties_fixgame').select2({ + minimumInputLength: 3, + templateResult: DropDownRenderGameOption, + ajax: { + url: '/api/v1/Search/Game', + data: function (params) { + fixplatform = $('#properties_fixplatform').select2('data'); + + var query = { + PlatformId: fixplatform[0].id, + SearchString: params.term + } + + // Query parameters will be ?SearchString=[term] + return query; + }, + processResults: function (data) { + var arr = []; + + for (var i = 0; i < data.length; i++) { + arr.push({ + id: data[i].id, + text: data[i].name, + cover: data[i].cover + }); + } + + return { + results: arr + }; + } + } + }); + + function DropDownRenderGameOption(state) { + console.log(JSON.stringify(state)); + + if (state.loading) { + return state; + } + + var response; + + if (state.cover) { + response = $( + '' + ); + } else { + response = $( + '' + ); + } + return response; + } + + function SaveFixedGame() { + var fixplatform = $('#properties_fixplatform').select2('data'); + var fixgame = $('#properties_fixgame').select2('data'); + + 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) { + window.location.reload(); + }); + } + + SelectTab('general'); + diff --git a/gaseous-server/wwwroot/pages/game.html b/gaseous-server/wwwroot/pages/game.html index 5203aad..80a1851 100644 --- a/gaseous-server/wwwroot/pages/game.html +++ b/gaseous-server/wwwroot/pages/game.html @@ -55,6 +55,7 @@