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>
|
||||||
@@ -115,7 +171,7 @@
|
|||||||
ajaxCall(
|
ajaxCall(
|
||||||
'/api/v1/System/Settings/BackgroundTasks/Configuration',
|
'/api/v1/System/Settings/BackgroundTasks/Configuration',
|
||||||
'GET',
|
'GET',
|
||||||
function(result) {
|
function (result) {
|
||||||
var targetTable = document.getElementById('settings_tasktimers');
|
var targetTable = document.getElementById('settings_tasktimers');
|
||||||
targetTable.innerHTML = '';
|
targetTable.innerHTML = '';
|
||||||
|
|
||||||
@@ -171,7 +227,7 @@
|
|||||||
daySelector.multiple = 'multiple';
|
daySelector.multiple = 'multiple';
|
||||||
daySelector.setAttribute('data-default', value.defaultAllowedDays.join(","));
|
daySelector.setAttribute('data-default', value.defaultAllowedDays.join(","));
|
||||||
daySelector.style.width = '95%';
|
daySelector.style.width = '95%';
|
||||||
var days = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ];
|
var days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
||||||
for (var d = 0; d < days.length; d++) {
|
for (var d = 0; d < days.length; d++) {
|
||||||
var dayOpt = document.createElement('option');
|
var dayOpt = document.createElement('option');
|
||||||
dayOpt.value = days[d];
|
dayOpt.value = days[d];
|
||||||
@@ -312,7 +368,7 @@
|
|||||||
var taskName = timerValues[i].getAttribute('data-name');
|
var taskName = timerValues[i].getAttribute('data-name');
|
||||||
var taskEnabled = document.getElementById('settings_enabled_' + taskName).checked;
|
var taskEnabled = document.getElementById('settings_enabled_' + taskName).checked;
|
||||||
var taskIntervalObj = document.getElementById('settings_tasktimers_' + taskName);
|
var taskIntervalObj = document.getElementById('settings_tasktimers_' + taskName);
|
||||||
var taskInterval = function() { if (taskIntervalObj.value) { return taskIntervalObj.value; } else { return taskIntervalObj.getAttribute('placeholder'); } };
|
var taskInterval = function () { if (taskIntervalObj.value) { return taskIntervalObj.value; } else { return taskIntervalObj.getAttribute('placeholder'); } };
|
||||||
var taskDaysRaw = $('#settings_alloweddays_' + taskName).select2('data');
|
var taskDaysRaw = $('#settings_alloweddays_' + taskName).select2('data');
|
||||||
var taskDays = [];
|
var taskDays = [];
|
||||||
if (taskDaysRaw.length > 0) {
|
if (taskDaysRaw.length > 0) {
|
||||||
@@ -327,10 +383,10 @@
|
|||||||
var taskEndHourObj = document.getElementById('settings_tasktimers_' + taskName + '_End_Hour');
|
var taskEndHourObj = document.getElementById('settings_tasktimers_' + taskName + '_End_Hour');
|
||||||
var taskEndMinuteObj = document.getElementById('settings_tasktimers_' + taskName + '_End_Minute');
|
var taskEndMinuteObj = document.getElementById('settings_tasktimers_' + taskName + '_End_Minute');
|
||||||
|
|
||||||
var taskStartHour = function() { if (taskStartHourObj.value) { return taskStartHourObj.value; } else { return taskStartHourObj.getAttribute('placeholder'); } };
|
var taskStartHour = function () { if (taskStartHourObj.value) { return taskStartHourObj.value; } else { return taskStartHourObj.getAttribute('placeholder'); } };
|
||||||
var taskStartMinute = function() { if (taskStartMinuteObj.value) { return taskStartMinuteObj.value; } else { return taskStartMinuteObj.getAttribute('placeholder'); } };
|
var taskStartMinute = function () { if (taskStartMinuteObj.value) { return taskStartMinuteObj.value; } else { return taskStartMinuteObj.getAttribute('placeholder'); } };
|
||||||
var taskEndHour = function() { if (taskEndHourObj.value) { return taskEndHourObj.value; } else { return taskEndHourObj.getAttribute('placeholder'); } };
|
var taskEndHour = function () { if (taskEndHourObj.value) { return taskEndHourObj.value; } else { return taskEndHourObj.getAttribute('placeholder'); } };
|
||||||
var taskEndMinute = function() { if (taskEndMinuteObj.value) { return taskEndMinuteObj.value; } else { return taskEndMinuteObj.getAttribute('placeholder'); } };
|
var taskEndMinute = function () { if (taskEndMinuteObj.value) { return taskEndMinuteObj.value; } else { return taskEndMinuteObj.getAttribute('placeholder'); } };
|
||||||
|
|
||||||
model.push(
|
model.push(
|
||||||
{
|
{
|
||||||
@@ -349,10 +405,10 @@
|
|||||||
ajaxCall(
|
ajaxCall(
|
||||||
'/api/v1/System/Settings/BackgroundTasks/Configuration',
|
'/api/v1/System/Settings/BackgroundTasks/Configuration',
|
||||||
'POST',
|
'POST',
|
||||||
function(result) {
|
function (result) {
|
||||||
getBackgroundTaskTimers();
|
getBackgroundTaskTimers();
|
||||||
},
|
},
|
||||||
function(error) {
|
function (error) {
|
||||||
getBackgroundTaskTimers();
|
getBackgroundTaskTimers();
|
||||||
},
|
},
|
||||||
JSON.stringify(model)
|
JSON.stringify(model)
|
||||||
@@ -393,7 +449,7 @@
|
|||||||
ajaxCall(
|
ajaxCall(
|
||||||
'/api/v1/System/Settings/System',
|
'/api/v1/System/Settings/System',
|
||||||
'GET',
|
'GET',
|
||||||
function(result) {
|
function (result) {
|
||||||
var optionToSelect = 'settings_logs_write_db';
|
var optionToSelect = 'settings_logs_write_db';
|
||||||
if (result.alwaysLogToDisk == true) {
|
if (result.alwaysLogToDisk == true) {
|
||||||
optionToSelect = 'settings_logs_write_fs';
|
optionToSelect = 'settings_logs_write_fs';
|
||||||
@@ -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,19 +482,29 @@
|
|||||||
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(
|
||||||
'/api/v1/System/Settings/System',
|
'/api/v1/System/Settings/System',
|
||||||
'POST',
|
'POST',
|
||||||
function(result) {
|
function (result) {
|
||||||
getSystemSettings();
|
getSystemSettings();
|
||||||
},
|
},
|
||||||
function(error) {
|
function (error) {
|
||||||
getSystemSettings();
|
getSystemSettings();
|
||||||
},
|
},
|
||||||
JSON.stringify(model)
|
JSON.stringify(model)
|
||||||
|
Reference in New Issue
Block a user