Allow the user to control how metadata is searched (#448)
This commit is contained in:
@@ -361,8 +361,10 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
sql = "REPLACE INTO Settings (Setting, ValueType, Value, ValueDate) VALUES (@SettingName, @ValueType, @Value, @ValueDate)";
|
sql = "REPLACE INTO Settings (Setting, ValueType, Value, ValueDate) VALUES (@SettingName, @ValueType, @Value, @ValueDate)";
|
||||||
Type type = typeof(T);
|
Type type = typeof(T);
|
||||||
if (type.ToString() == "System.DateTime")
|
|
||||||
|
switch (type.ToString())
|
||||||
{
|
{
|
||||||
|
case "System.DateTime":
|
||||||
dbDict = new Dictionary<string, object>
|
dbDict = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ "SettingName", SettingName },
|
{ "SettingName", SettingName },
|
||||||
@@ -370,9 +372,19 @@ namespace gaseous_server.Classes
|
|||||||
{ "Value", null },
|
{ "Value", null },
|
||||||
{ "ValueDate", Value }
|
{ "ValueDate", Value }
|
||||||
};
|
};
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
|
case "System.Collections.Generic.List`1[gaseous_server.Classes.Metadata.Games+SearchType]":
|
||||||
|
dbDict = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
|
{ "SettingName", SettingName },
|
||||||
|
{ "ValueType", 2 },
|
||||||
|
{ "Value", JsonConvert.SerializeObject(Value) },
|
||||||
|
{ "ValueDate", null }
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
dbDict = new Dictionary<string, object>
|
dbDict = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ "SettingName", SettingName },
|
{ "SettingName", SettingName },
|
||||||
@@ -380,6 +392,7 @@ namespace gaseous_server.Classes
|
|||||||
{ "Value", Value },
|
{ "Value", Value },
|
||||||
{ "ValueDate", null }
|
{ "ValueDate", null }
|
||||||
};
|
};
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -181,7 +181,13 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
Logging.Log(Logging.LogType.Information, "Import Game", " Searching for title: " + SearchCandidate);
|
Logging.Log(Logging.LogType.Information, "Import Game", " Searching for title: " + SearchCandidate);
|
||||||
|
|
||||||
foreach (Metadata.Games.SearchType searchType in Enum.GetValues(typeof(Metadata.Games.SearchType)))
|
List<Metadata.Games.SearchType> allowedSearchTypes = Config.ReadSetting<List<Metadata.Games.SearchType>>("DefaultSearchMethods", new List<gaseous_server.Classes.Metadata.Games.SearchType>() {
|
||||||
|
Games.SearchType.where,
|
||||||
|
Games.SearchType.wherefuzzy,
|
||||||
|
Games.SearchType.search,
|
||||||
|
Games.SearchType.searchNoPlatform
|
||||||
|
});
|
||||||
|
foreach (Metadata.Games.SearchType searchType in allowedSearchTypes)
|
||||||
{
|
{
|
||||||
Logging.Log(Logging.LogType.Information, "Import Game", " Search type: " + searchType.ToString());
|
Logging.Log(Logging.LogType.Information, "Import Game", " Search type: " + searchType.ToString());
|
||||||
IGDB.Models.Game[] games = Metadata.Games.SearchForGame(SearchCandidate, PlatformId, searchType);
|
IGDB.Models.Game[] games = Metadata.Games.SearchForGame(SearchCandidate, PlatformId, searchType);
|
||||||
@@ -239,7 +245,13 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
foreach (string SearchCandidate in SearchCandidates)
|
foreach (string SearchCandidate in SearchCandidates)
|
||||||
{
|
{
|
||||||
foreach (Metadata.Games.SearchType searchType in Enum.GetValues(typeof(Metadata.Games.SearchType)))
|
List<Metadata.Games.SearchType> allowedSearchTypes = Config.ReadSetting<List<Metadata.Games.SearchType>>("DefaultSearchMethods", new List<gaseous_server.Classes.Metadata.Games.SearchType>() {
|
||||||
|
Games.SearchType.where,
|
||||||
|
Games.SearchType.wherefuzzy,
|
||||||
|
Games.SearchType.search,
|
||||||
|
Games.SearchType.searchNoPlatform
|
||||||
|
});
|
||||||
|
foreach (Metadata.Games.SearchType searchType in allowedSearchTypes)
|
||||||
{
|
{
|
||||||
if ((PlatformId == 0 && searchType == SearchType.searchNoPlatform) || (PlatformId != 0 && searchType != SearchType.searchNoPlatform))
|
if ((PlatformId == 0 && searchType == SearchType.searchNoPlatform) || (PlatformId != 0 && searchType != SearchType.searchNoPlatform))
|
||||||
{
|
{
|
||||||
|
@@ -260,7 +260,13 @@ namespace gaseous_server.Controllers
|
|||||||
{
|
{
|
||||||
AlwaysLogToDisk = Config.LoggingConfiguration.AlwaysLogToDisk,
|
AlwaysLogToDisk = Config.LoggingConfiguration.AlwaysLogToDisk,
|
||||||
MinimumLogRetentionPeriod = Config.LoggingConfiguration.LogRetention,
|
MinimumLogRetentionPeriod = Config.LoggingConfiguration.LogRetention,
|
||||||
EmulatorDebugMode = Boolean.Parse(Config.ReadSetting<string>("emulatorDebugMode", false.ToString()))
|
EmulatorDebugMode = Boolean.Parse(Config.ReadSetting<string>("emulatorDebugMode", false.ToString())),
|
||||||
|
SearchTypes = Config.ReadSetting<List<Classes.Metadata.Games.SearchType>>("DefaultSearchMethods", new List<gaseous_server.Classes.Metadata.Games.SearchType>() {
|
||||||
|
Games.SearchType.where,
|
||||||
|
Games.SearchType.wherefuzzy,
|
||||||
|
Games.SearchType.search,
|
||||||
|
Games.SearchType.searchNoPlatform
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(systemSettingsModel);
|
return Ok(systemSettingsModel);
|
||||||
@@ -279,6 +285,7 @@ namespace gaseous_server.Controllers
|
|||||||
Config.LoggingConfiguration.AlwaysLogToDisk = model.AlwaysLogToDisk;
|
Config.LoggingConfiguration.AlwaysLogToDisk = model.AlwaysLogToDisk;
|
||||||
Config.LoggingConfiguration.LogRetention = model.MinimumLogRetentionPeriod;
|
Config.LoggingConfiguration.LogRetention = model.MinimumLogRetentionPeriod;
|
||||||
Config.SetSetting<string>("emulatorDebugMode", model.EmulatorDebugMode.ToString());
|
Config.SetSetting<string>("emulatorDebugMode", model.EmulatorDebugMode.ToString());
|
||||||
|
Config.SetSetting<List<Classes.Metadata.Games.SearchType>>("DefaultSearchMethods", model.SearchTypes);
|
||||||
Config.UpdateConfig();
|
Config.UpdateConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,5 +726,6 @@ namespace gaseous_server.Controllers
|
|||||||
public bool AlwaysLogToDisk { get; set; }
|
public bool AlwaysLogToDisk { get; set; }
|
||||||
public int MinimumLogRetentionPeriod { get; set; }
|
public int MinimumLogRetentionPeriod { get; set; }
|
||||||
public bool EmulatorDebugMode { get; set; }
|
public bool EmulatorDebugMode { get; set; }
|
||||||
|
public List<Classes.Metadata.Games.SearchType> SearchTypes { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -46,6 +46,14 @@ AgeRatings.PopulateAgeMap();
|
|||||||
// load app settings
|
// load app settings
|
||||||
Config.InitSettings();
|
Config.InitSettings();
|
||||||
|
|
||||||
|
// set default search settings
|
||||||
|
Config.SetSetting<List<gaseous_server.Classes.Metadata.Games.SearchType>>("DefaultSearchMethods", new List<gaseous_server.Classes.Metadata.Games.SearchType>() {
|
||||||
|
Games.SearchType.where,
|
||||||
|
Games.SearchType.wherefuzzy,
|
||||||
|
Games.SearchType.search,
|
||||||
|
Games.SearchType.searchNoPlatform
|
||||||
|
});
|
||||||
|
|
||||||
// disable hasheous
|
// disable hasheous
|
||||||
Config.MetadataConfiguration.SignatureSource = HasheousClient.Models.MetadataModel.SignatureSources.LocalOnly;
|
Config.MetadataConfiguration.SignatureSource = HasheousClient.Models.MetadataModel.SignatureSources.LocalOnly;
|
||||||
|
|
||||||
|
@@ -6,7 +6,8 @@
|
|||||||
<table id="settings_libraries" class="romtable" style="width: 100%;" cellspacing="0">
|
<table id="settings_libraries" class="romtable" style="width: 100%;" cellspacing="0">
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
<div style="text-align: right;"><button id="settings_newlibrary" onclick="showDialog('librarynew');">New Library</button></div>
|
<div style="text-align: right;"><button id="settings_newlibrary" onclick="showDialog('librarynew');">New
|
||||||
|
Library</button></div>
|
||||||
|
|
||||||
<h2>Advanced Settings</h2>
|
<h2>Advanced Settings</h2>
|
||||||
<p><strong>Warning</strong> Do not modify the below settings unless you know what you're doing.</p>
|
<p><strong>Warning</strong> Do not modify the below settings unless you know what you're doing.</p>
|
||||||
@@ -14,7 +15,8 @@
|
|||||||
<table id="settings_tasktimers" class="romtable" style="width: 100%;" cellspacing="0">
|
<table id="settings_tasktimers" class="romtable" style="width: 100%;" cellspacing="0">
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
<div style="text-align: right;"><button id="settings_tasktimers_default" onclick="defaultTaskTimers();">Reset to Default</button><button id="settings_tasktimers_new" onclick="saveTaskTimers();">Save</button></div>
|
<div style="text-align: right;"><button id="settings_tasktimers_default" onclick="defaultTaskTimers();">Reset to
|
||||||
|
Default</button><button id="settings_tasktimers_new" onclick="saveTaskTimers();">Save</button></div>
|
||||||
|
|
||||||
<h3>System Settings</h3>
|
<h3>System Settings</h3>
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
@@ -26,13 +28,15 @@
|
|||||||
Write logs
|
Write logs
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="settings_logs_write" id="settings_logs_write_db" value="false" checked="checked"><label for="settings_logs_write_db"> To database only (default)</label>
|
<input type="radio" name="settings_logs_write" id="settings_logs_write_db" value="false"
|
||||||
|
checked="checked"><label for="settings_logs_write_db"> To database only (default)</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="radio" name="settings_logs_write" id="settings_logs_write_fs" value="true"><label for="settings_logs_write_fs"> To database and disk</label>
|
<input type="radio" name="settings_logs_write" id="settings_logs_write_fs" value="true"><label
|
||||||
|
for="settings_logs_write_fs"> To database and disk</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -46,6 +50,58 @@
|
|||||||
<input type="number" min="1" id="settings_logs_retention" />
|
<input type="number" min="1" id="settings_logs_retention" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Allowed metadata search modes:
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" name="settings_metadata_search" id="settings_metadata_search_where" /><label
|
||||||
|
for="settings_metadata_search_where">
|
||||||
|
Exact:
|
||||||
|
<i>
|
||||||
|
Searches for exact matches only. Example search: name = "Super Mario Bros."
|
||||||
|
</i>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" name="settings_metadata_search" id="settings_metadata_search_wherefuzzy" /><label
|
||||||
|
for="settings_metadata_search_wherefuzzy">
|
||||||
|
Partial:
|
||||||
|
<i>
|
||||||
|
Searches for partial matches. Example search: name = "Mario"
|
||||||
|
</i>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" name="settings_metadata_search" id="settings_metadata_search_search" /><label
|
||||||
|
for="settings_metadata_search_search">
|
||||||
|
Search:
|
||||||
|
<i>
|
||||||
|
Searches for partial matches using full text search. Example search: name = "Mario"
|
||||||
|
</i>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" name="settings_metadata_search"
|
||||||
|
id="settings_metadata_search_searchNoPlatform" /><label for="settings_metadata_search_searchNoPlatform">
|
||||||
|
Search (no platform
|
||||||
|
contraint):
|
||||||
|
<i>
|
||||||
|
Searches for partial matches using full text search, but without a platform constraint. Example
|
||||||
|
search: name = "Mario"
|
||||||
|
</i>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">Emulator</th>
|
<th colspan="2">Emulator</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -403,6 +459,11 @@
|
|||||||
document.getElementById('settings_logs_retention').value = result.minimumLogRetentionPeriod;
|
document.getElementById('settings_logs_retention').value = result.minimumLogRetentionPeriod;
|
||||||
|
|
||||||
document.getElementById('settings_emulator_debug').checked = result.emulatorDebugMode;
|
document.getElementById('settings_emulator_debug').checked = result.emulatorDebugMode;
|
||||||
|
|
||||||
|
for (let i = 0; i < result.searchTypes.length; i++) {
|
||||||
|
const element = result.searchTypes[i];
|
||||||
|
document.getElementById('settings_metadata_search_' + element).checked = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -421,10 +482,20 @@
|
|||||||
retentionValue = 7;
|
retentionValue = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let searchTypes = [];
|
||||||
|
let searchTypeElements = document.getElementsByName('settings_metadata_search');
|
||||||
|
for (let i = 0; i < searchTypeElements.length; i++) {
|
||||||
|
const element = searchTypeElements[i];
|
||||||
|
if (element.checked) {
|
||||||
|
searchTypes.push(element.id.replace('settings_metadata_search_', ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var model = {
|
var model = {
|
||||||
"alwaysLogToDisk": alwaysLogToDisk,
|
"alwaysLogToDisk": alwaysLogToDisk,
|
||||||
"minimumLogRetentionPeriod": retentionValue,
|
"minimumLogRetentionPeriod": retentionValue,
|
||||||
"emulatorDebugMode": document.getElementById('settings_emulator_debug').checked
|
"emulatorDebugMode": document.getElementById('settings_emulator_debug').checked,
|
||||||
|
"searchTypes": searchTypes
|
||||||
};
|
};
|
||||||
|
|
||||||
ajaxCall(
|
ajaxCall(
|
||||||
|
Reference in New Issue
Block a user