This commit is contained in:
Michael Green
2025-01-01 21:33:35 +11:00
parent 1727a62150
commit 42370a9699
10 changed files with 428 additions and 175 deletions

View File

@@ -136,9 +136,8 @@ namespace gaseous_server.Classes
_config.DatabaseConfiguration.DatabaseName = (string)Common.GetEnvVar("dbname", _config.DatabaseConfiguration.DatabaseName);
_config.DatabaseConfiguration.Port = int.Parse((string)Common.GetEnvVar("dbport", _config.DatabaseConfiguration.Port.ToString()));
_config.MetadataConfiguration.DefaultMetadataSource = (HasheousClient.Models.MetadataSources)Enum.Parse(typeof(HasheousClient.Models.MetadataSources), (string)Common.GetEnvVar("metadatasource", _config.MetadataConfiguration.DefaultMetadataSource.ToString()));
_config.MetadataConfiguration.MetadataUseHasheousProxy = bool.Parse((string)Common.GetEnvVar("metadatausehasheousproxy", _config.MetadataConfiguration.MetadataUseHasheousProxy.ToString()));
_config.IGDBConfiguration.UseHasheousProxy = bool.Parse((string)Common.GetEnvVar("metadatausehasheousproxy", _config.IGDBConfiguration.UseHasheousProxy.ToString()));
_config.MetadataConfiguration.SignatureSource = (HasheousClient.Models.MetadataModel.SignatureSources)Enum.Parse(typeof(HasheousClient.Models.MetadataModel.SignatureSources), (string)Common.GetEnvVar("signaturesource", _config.MetadataConfiguration.SignatureSource.ToString())); ;
_config.MetadataConfiguration.MaxLibraryScanWorkers = int.Parse((string)Common.GetEnvVar("maxlibraryscanworkers", _config.MetadataConfiguration.MaxLibraryScanWorkers.ToString()));
_config.MetadataConfiguration.HasheousHost = (string)Common.GetEnvVar("hasheoushost", _config.MetadataConfiguration.HasheousHost);
_config.IGDBConfiguration.ClientId = (string)Common.GetEnvVar("igdbclientid", _config.IGDBConfiguration.ClientId);
_config.IGDBConfiguration.Secret = (string)Common.GetEnvVar("igdbclientsecret", _config.IGDBConfiguration.Secret);
@@ -739,21 +738,6 @@ namespace gaseous_server.Classes
private static string _HasheousAPIKey { get; set; } = "";
private static int _MaxLibraryScanWorkers
{
get
{
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("maxlibraryscanworkers")))
{
return int.Parse(Environment.GetEnvironmentVariable("maxlibraryscanworkers"));
}
else
{
return 4;
}
}
}
private static string _HasheousHost
{
get
@@ -771,8 +755,6 @@ namespace gaseous_server.Classes
public HasheousClient.Models.MetadataSources DefaultMetadataSource = _MetadataSource;
public bool MetadataUseHasheousProxy = _MetadataUseHasheousProxy;
public HasheousClient.Models.MetadataModel.SignatureSources SignatureSource = _SignatureSource;
public bool HasheousSubmitFixes = _HasheousSubmitFixes;
@@ -782,8 +764,6 @@ namespace gaseous_server.Classes
[JsonIgnore]
public string HasheousClientAPIKey = _HasheousClientAPIKey;
public int MaxLibraryScanWorkers = _MaxLibraryScanWorkers;
public string HasheousHost = _HasheousHost;
}
@@ -819,8 +799,24 @@ namespace gaseous_server.Classes
}
}
private static bool _MetadataUseHasheousProxy
{
get
{
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("igdbusehasheousproxy")))
{
return bool.Parse(Environment.GetEnvironmentVariable("igdbusehasheousproxy"));
}
else
{
return false;
}
}
}
public string ClientId = _DefaultIGDBClientId;
public string Secret = _DefaultIGDBSecret;
public bool UseHasheousProxy = _MetadataUseHasheousProxy;
}
public class Logging

View File

@@ -678,7 +678,7 @@ namespace gaseous_server.Classes
public static List<GameLibrary.LibraryItem> LibrariesToScan = new List<GameLibrary.LibraryItem>();
public void LibraryScan()
{
int maxWorkers = Config.MetadataConfiguration.MaxLibraryScanWorkers;
int maxWorkers = 4;
if (LibrariesToScan.Count == 0)
{

View File

@@ -58,7 +58,7 @@ namespace gaseous_server.Classes.Metadata
switch (value)
{
case HasheousClient.Models.MetadataSources.IGDB:
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
// set rate limiter avoidance values
RateLimitAvoidanceWait = 1500;
@@ -254,7 +254,7 @@ namespace gaseous_server.Classes.Metadata
case HasheousClient.Models.MetadataSources.None:
return null;
case HasheousClient.Models.MetadataSources.IGDB:
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
string fieldList = "";
string query = "where slug = \"" + Slug + "\"";
@@ -336,7 +336,7 @@ namespace gaseous_server.Classes.Metadata
case HasheousClient.Models.MetadataSources.None:
return null;
case HasheousClient.Models.MetadataSources.IGDB:
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
string fieldList = "";
string query = "where id = " + Id;
@@ -527,7 +527,7 @@ namespace gaseous_server.Classes.Metadata
case HasheousClient.Models.MetadataSources.None:
return null;
case HasheousClient.Models.MetadataSources.IGDB:
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
return await IGDBAPI<T>(Endpoint, Fields, Query);
}
@@ -1157,7 +1157,7 @@ namespace gaseous_server.Classes.Metadata
case HasheousClient.Models.MetadataSources.IGDB:
originalFilePath = originalFilePath + ".jpg";
requestedFilePath = requestedFilePath + ".jpg";
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
await comms.IGDBAPI_GetImage(ImageId, originalPath);
}

View File

@@ -167,7 +167,7 @@ namespace gaseous_server.Classes.Metadata
case HasheousClient.Models.MetadataSources.None:
return new Game[0];
case HasheousClient.Models.MetadataSources.IGDB:
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
string searchBody = "";
string searchFields = "fields id,name,slug,platforms,summary; ";

View File

@@ -111,6 +111,15 @@ namespace gaseous_server.Classes.Metadata
}
}
// if the source is "none", cache status should be "current" or "not present"
if (SourceType == HasheousClient.Models.MetadataSources.None)
{
if (cacheStatus == Storage.CacheStatus.Expired)
{
cacheStatus = Storage.CacheStatus.Current;
}
}
T? metadata = (T)Activator.CreateInstance(typeof(T));
switch (cacheStatus)

View File

@@ -14,12 +14,14 @@ namespace gaseous_server.Classes.Metadata
}
public static Platform? GetPlatform(long Id)
public static Platform? GetPlatform(long Id, HasheousClient.Models.MetadataSources? SourceType = null)
{
HasheousClient.Models.MetadataSources Source = SourceType ?? Communications.MetadataSource;
if ((Id == 0) || (Id == null))
{
Platform returnValue = new Platform();
if (Storage.GetCacheStatus(Communications.MetadataSource, "Platform", 0) == Storage.CacheStatus.NotPresent)
if (Storage.GetCacheStatus(Source, "Platform", 0) == Storage.CacheStatus.NotPresent)
{
returnValue = new Platform
{
@@ -27,26 +29,26 @@ namespace gaseous_server.Classes.Metadata
Name = "Unknown Platform",
Slug = "Unknown"
};
Storage.NewCacheValue(Communications.MetadataSource, returnValue);
Storage.NewCacheValue(Source, returnValue);
return returnValue;
}
else
{
return Storage.GetCacheValue<Platform>(Communications.MetadataSource, returnValue, "id", 0);
return Storage.GetCacheValue<Platform>(Source, returnValue, "id", 0);
}
}
else
{
Platform? RetVal = new Platform();
if (Config.MetadataConfiguration.DefaultMetadataSource == HasheousClient.Models.MetadataSources.None)
if (Source == HasheousClient.Models.MetadataSources.None)
{
RetVal = (Platform?)Storage.GetCacheValue<Platform>(HasheousClient.Models.MetadataSources.None, RetVal, "Id", (long)Id);
}
else
{
RetVal = Metadata.GetMetadata<Platform>(HasheousClient.Models.MetadataSources.IGDB, (long)Id, false);
RetVal = Metadata.GetMetadata<Platform>(Source, (long)Id, false);
}
return RetVal;
}

View File

@@ -67,7 +67,7 @@ namespace gaseous_server.Controllers
switch (Config.MetadataConfiguration.DefaultMetadataSource)
{
case HasheousClient.Models.MetadataSources.IGDB:
if (Config.MetadataConfiguration.MetadataUseHasheousProxy == false)
if (Config.IGDB.UseHasheousProxy == false)
{
string searchBody = "";
string searchFields = "fields *; ";

View File

@@ -312,12 +312,10 @@ namespace gaseous_server.Controllers
HasheousSubmitFixes = (bool)Config.MetadataConfiguration.HasheousSubmitFixes,
HasheousAPIKey = Config.MetadataConfiguration.HasheousAPIKey
},
MetadataSource = new SystemSettingsModel.MetadataSourceItem()
MetadataSources = new List<SystemSettingsModel.MetadataSourceItem>
{
Source = Config.MetadataConfiguration.DefaultMetadataSource,
UseHasheousProxy = Config.MetadataConfiguration.MetadataUseHasheousProxy,
IGDBClientId = Config.IGDB.ClientId,
IGDBClientSecret = Config.IGDB.Secret
new SystemSettingsModel.MetadataSourceItem(HasheousClient.Models.MetadataSources.None, false, "", "", Config.MetadataConfiguration.DefaultMetadataSource),
new SystemSettingsModel.MetadataSourceItem(HasheousClient.Models.MetadataSources.IGDB, Config.IGDB.UseHasheousProxy, Config.IGDB.ClientId, Config.IGDB.Secret, Config.MetadataConfiguration.DefaultMetadataSource)
}
};
@@ -341,10 +339,34 @@ namespace gaseous_server.Controllers
Config.MetadataConfiguration.HasheousHost = model.SignatureSource.HasheousHost;
Config.MetadataConfiguration.HasheousAPIKey = model.SignatureSource.HasheousAPIKey;
Config.MetadataConfiguration.HasheousSubmitFixes = model.SignatureSource.HasheousSubmitFixes;
Config.MetadataConfiguration.DefaultMetadataSource = model.MetadataSource.Source;
Config.MetadataConfiguration.MetadataUseHasheousProxy = model.MetadataSource.UseHasheousProxy;
Config.IGDB.ClientId = model.MetadataSource.IGDBClientId;
Config.IGDB.Secret = model.MetadataSource.IGDBClientSecret;
foreach (SystemSettingsModel.MetadataSourceItem metadataSourceItem in model.MetadataSources)
{
// configure the default metadata source
if (metadataSourceItem.Default == true)
{
Config.MetadataConfiguration.DefaultMetadataSource = metadataSourceItem.Source;
}
else
{
Config.MetadataConfiguration.DefaultMetadataSource = HasheousClient.Models.MetadataSources.None;
}
// configure the metadata source
switch (metadataSourceItem.Source)
{
case HasheousClient.Models.MetadataSources.None:
break;
case HasheousClient.Models.MetadataSources.IGDB:
Config.IGDB.UseHasheousProxy = metadataSourceItem.UseHasheousProxy;
Config.IGDB.ClientId = metadataSourceItem.ClientId;
Config.IGDB.Secret = metadataSourceItem.Secret;
break;
case HasheousClient.Models.MetadataSources.TheGamesDb:
break;
default:
break;
}
}
Config.UpdateConfig();
}
@@ -787,7 +809,7 @@ namespace gaseous_server.Controllers
public int MinimumLogRetentionPeriod { get; set; }
public bool EmulatorDebugMode { get; set; }
public SignatureSourceItem SignatureSource { get; set; }
public MetadataSourceItem MetadataSource { get; set; }
public List<MetadataSourceItem> MetadataSources { get; set; }
public class SignatureSourceItem
{
@@ -799,10 +821,97 @@ namespace gaseous_server.Controllers
public class MetadataSourceItem
{
public MetadataSourceItem()
{
}
public MetadataSourceItem(HasheousClient.Models.MetadataSources source, bool useHasheousProxy, string clientId, string secret, HasheousClient.Models.MetadataSources defaultSource)
{
Source = source;
UseHasheousProxy = useHasheousProxy;
ClientId = clientId;
Secret = secret;
if (Source == defaultSource)
{
Default = true;
}
else
{
Default = false;
}
}
public HasheousClient.Models.MetadataSources Source { get; set; }
public bool UseHasheousProxy { get; set; }
public string IGDBClientId { get; set; }
public string IGDBClientSecret { get; set; }
public string ClientId { get; set; }
public string Secret { get; set; }
public bool Default { get; set; }
public bool? Configured
{
get
{
switch (Source)
{
case HasheousClient.Models.MetadataSources.None:
return true;
case HasheousClient.Models.MetadataSources.IGDB:
if ((!String.IsNullOrEmpty(ClientId) && !String.IsNullOrEmpty(Secret)) || UseHasheousProxy == true)
{
return true;
}
else
{
return false;
}
case HasheousClient.Models.MetadataSources.TheGamesDb:
if ((!String.IsNullOrEmpty(ClientId) && !String.IsNullOrEmpty(Secret)) || UseHasheousProxy == true)
{
return true;
}
else
{
return false;
}
default:
return false;
}
}
}
public bool? UsesProxy
{
get
{
switch (Source)
{
case HasheousClient.Models.MetadataSources.None:
return false;
case HasheousClient.Models.MetadataSources.IGDB:
return true;
case HasheousClient.Models.MetadataSources.TheGamesDb:
return true;
default:
return false;
}
}
}
public bool? UsesClientIdAndSecret
{
get
{
switch (Source)
{
case HasheousClient.Models.MetadataSources.None:
return false;
case HasheousClient.Models.MetadataSources.IGDB:
return true;
case HasheousClient.Models.MetadataSources.TheGamesDb:
return true;
default:
return false;
}
}
}
}
}
}

View File

@@ -3,119 +3,71 @@
</div>
<div class="section">
<div class="section-header">Metadata Settings</div>
<div class="section-header">Signature Sources</div>
<div class="section-body">
<div class="section">
<div class="section-header">Source</div>
<div class="section-body">
<table style="width: 100%;">
<tr>
<td style="width: 30%;">
Signature Source
</td>
<td>
<input type="radio" name="settings_signaturesource" id="settings_signaturesource_local"
value="LocalOnly">
<label for="settings_signaturesource_local">Local Only</label>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" name="settings_signaturesource" id="settings_signaturesource_hasheous"
value="Hasheous">
<label for="settings_signaturesource_hasheous">Hasheous</label>
</td>
</tr>
<tr>
<td style="width: 30%;">
Metadata Source
</td>
<td>
<input type="radio" name="settings_metadatasource" id="settings_metadatasource_none"
value="None">
<label for="settings_metadatasource_none">None</label>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" name="settings_metadatasource" id="settings_metadatasource_hasheous"
value="Hasheous">
<label for="settings_metadatasource_hasheous">IGDB via Hasheous Proxy</label>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" name="settings_metadatasource" id="settings_metadatasource_igdb"
value="IGDB">
<label for="settings_metadatasource_igdb">IGDB</label>
</td>
</tr>
</table>
</div>
</div>
<div class="section">
<div class="section-header">IGDB Configuration</div>
<div class="section-body">
<table style="width: 100%;">
<tr id="settings_igdbclientid_row">
<td style="width: 30%;">
IGDB Client ID
</td>
<td>
<input type="text" id="settings_igdbclientid" style="width: 90%;">
</td>
</tr>
<tr id="settings_igdbclientkey_row">
<td style="width: 30%;">
IGDB Client Key
</td>
<td>
<input type="text" id="settings_igdbclientkey" style="width: 90%;">
</td>
</tr>
</table>
</div>
</div>
<div class="section">
<div class="section-header">Hasheous Configuration</div>
<div class="section-body">
<table style="width: 100%;">
<tr id="settings_hasheoushost_row">
<td style="width: 30%;">
Hasheous Host
</td>
<td>
<input type="url" id="settings_signaturesource_hasheoushost" style="width: 90%;">
</td>
</tr>
<tr>
<td>
<label for="settings_hasheoussubmit">Submit updates to Hasheous when fixing ROM
matches</label>
</td>
<td>
<input type="checkbox" id="settings_hasheoussubmit" onchange="toggleHasheousAPIKey(this);">
</td>
</tr>
<tr id="settings_hasheousapikey_row">
<td style="width: 30%;">
Hasheous API key
</td>
<td>
<input type="text" id="settings_hasheousapikey" style="width: 90%;">
</td>
</tr>
</table>
</div>
</div>
<table style="width: 100%;">
<tr>
<td style="width: 30%;">
Signature Source
</td>
<td>
<input type="radio" name="settings_signaturesource" id="settings_signaturesource_local"
value="LocalOnly">
<label for="settings_signaturesource_local">Local Only</label>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" name="settings_signaturesource" id="settings_signaturesource_hasheous"
value="Hasheous">
<label for="settings_signaturesource_hasheous">Hasheous</label>
</td>
</tr>
</table>
</div>
</div>
<div class="section">
<div class="section-header">Default Metadata Source</div>
<div class="section-body" id="settings_metadata">
</div>
</div>
<div class="section">
<div class="section-header">Hasheous Configuration</div>
<div class="section-body">
<table style="width: 100%;">
<tr id="settings_hasheoushost_row">
<td style="width: 30%;">
Hasheous Host
</td>
<td>
<input type="url" id="settings_signaturesource_hasheoushost" style="width: 90%;">
</td>
</tr>
<tr>
<td>
<label for="settings_hasheoussubmit">Submit updates to Hasheous when fixing ROM
matches</label>
</td>
<td>
<input type="checkbox" id="settings_hasheoussubmit" onchange="toggleHasheousAPIKey(this);">
</td>
</tr>
<tr id="settings_hasheousapikey_row">
<td style="width: 30%;">
Hasheous API key
</td>
<td>
<input type="text" id="settings_hasheousapikey" style="width: 90%;">
</td>
</tr>
</table>
</div>
</div>
<div class="section">
<div class="section-header">Logging</div>
<div class="section-body">

View File

@@ -25,23 +25,179 @@ function getSystemSettings() {
}
switch (result.metadataSource.source) {
case "None":
document.getElementById('settings_metadatasource_none').checked = true;
break;
let metadataSettingsContainer = document.getElementById('settings_metadata');
metadataSettingsContainer.innerHTML = '';
result.metadataSources.forEach(element => {
// section
let sourceSection = document.createElement('div');
sourceSection.classList.add('section');
sourceSection.setAttribute('id', 'settings_metadatasource_' + element.source);
case "Hasheous":
document.getElementById('settings_metadatasource_hasheous').checked = true;
break;
// section header
let sourceHeader = document.createElement('div');
sourceHeader.classList.add('section-header');
case "IGDB":
document.getElementById('settings_metadatasource_igdb').checked = true;
break;
let sourceRadio = document.createElement('input');
sourceRadio.setAttribute('type', 'radio');
sourceRadio.setAttribute('name', 'settings_metadatasource');
sourceRadio.setAttribute('value', element.source);
sourceRadio.setAttribute('id', 'settings_metadatasource_' + element.source + '_radio');
sourceRadio.style.margin = '0px';
sourceRadio.style.height = 'unset';
if (element.default) {
sourceRadio.checked = true;
}
}
let sourceLabel = document.createElement('label');
sourceLabel.setAttribute('for', 'settings_metadatasource_' + element.source + '_radio');
document.getElementById('settings_igdbclientid').value = result.metadataSource.igdbClientId;
document.getElementById('settings_igdbclientkey').value = result.metadataSource.igdbClientSecret;
let sourceName = document.createElement('span');
switch (element.source) {
case "IGDB":
sourceName.innerText = 'Internet Game Database (IGDB)';
break;
default:
sourceName.innerText = element.source;
break;
}
sourceName.style.marginLeft = '10px';
sourceLabel.appendChild(sourceName);
let sourceConfigured = document.createElement('span');
sourceConfigured.style.float = 'right';
sourceConfigured.classList.add(element.configured ? 'greentext' : 'redtext');
sourceConfigured.innerText = element.configured ? 'Configured' : 'Not Configured';
sourceHeader.appendChild(sourceRadio);
sourceHeader.appendChild(sourceLabel);
sourceHeader.appendChild(sourceConfigured);
sourceSection.appendChild(sourceHeader);
// section body
let sourceContent = document.createElement('div');
sourceContent.classList.add('section-body');
if (element.usesProxy === false && element.usesClientIdAndSecret === false) {
sourceContent.innerText = 'No options to configure';
} else {
// render controls
let controlsTable = document.createElement('table');
controlsTable.style.width = '100%';
// hasheous proxy row
if (element.usesProxy === true) {
let proxyRow = document.createElement('tr');
let proxyLabel = document.createElement('td');
if (element.usesClientIdAndSecret === true) {
let proxyRadio = document.createElement('input');
proxyRadio.id = 'settings_metadatasource_proxy_' + element.source;
proxyRadio.setAttribute('type', 'radio');
proxyRadio.setAttribute('name', 'settings_metadatasource_proxy_' + element.source);
proxyRadio.style.marginRight = '10px';
if (element.useHasheousProxy === true) {
proxyRadio.checked = true;
}
proxyLabel.appendChild(proxyRadio);
let proxyLabelLabel = document.createElement('label');
proxyLabelLabel.setAttribute('for', 'settings_metadatasource_proxy_' + element.source);
let proxyLabelSpan = document.createElement('span');
proxyLabelSpan.innerText = 'Use Hasheous Proxy';
proxyLabelLabel.appendChild(proxyLabelSpan);
proxyLabel.appendChild(proxyLabelLabel);
proxyRow.appendChild(proxyLabel);
} else {
proxyLabel.innerHTML = 'Uses Hasheous Proxy';
proxyRow.appendChild(proxyLabel);
}
controlsTable.appendChild(proxyRow);
}
// client id and secret row
if (element.usesClientIdAndSecret === true) {
if (element.usesProxy === true) {
let clientRadioRow = document.createElement('tr');
let clientRadioLabel = document.createElement('td');
let clientRadio = document.createElement('input');
clientRadio.id = 'settings_metadatasource_client_' + element.source;
clientRadio.setAttribute('type', 'radio');
clientRadio.setAttribute('name', 'settings_metadatasource_proxy_' + element.source);
clientRadio.style.marginRight = '10px';
if (element.useHasheousProxy === false) {
clientRadio.checked = true;
}
clientRadioLabel.appendChild(clientRadio);
let clientRadioLabelLabel = document.createElement('label');
clientRadioLabelLabel.setAttribute('for', 'settings_metadatasource_client_' + element.source);
let clientRadioLabelSpan = document.createElement('span');
clientRadioLabelSpan.innerText = 'Direct connection';
clientRadioLabelLabel.appendChild(clientRadioLabelSpan);
clientRadioLabel.appendChild(clientRadioLabelLabel);
clientRadioRow.appendChild(clientRadioLabel);
controlsTable.appendChild(clientRadioRow);
}
let clientIdTable = document.createElement('table');
clientIdTable.style.width = '100%';
if (element.usesProxy === true) {
clientIdTable.style.marginLeft = '30px';
}
let clientIdRow = document.createElement('tr');
let clientIdLabel = document.createElement('td');
clientIdLabel.style.width = '15%';
clientIdLabel.innerText = 'Client ID';
clientIdRow.appendChild(clientIdLabel);
let clientIdInput = document.createElement('td');
let clientIdInputField = document.createElement('input');
clientIdInputField.style.width = '90%';
clientIdInputField.setAttribute('type', 'text');
clientIdInputField.setAttribute('id', 'settings_metadatasource_' + element.source + '_clientid');
clientIdInputField.value = element.clientId;
clientIdInput.appendChild(clientIdInputField);
clientIdRow.appendChild(clientIdInput);
clientIdTable.appendChild(clientIdRow);
let clientSecretRow = document.createElement('tr');
let clientSecretLabel = document.createElement('td');
clientSecretLabel.style.width = '15%';
clientSecretLabel.innerText = 'Client Secret';
clientSecretRow.appendChild(clientSecretLabel);
let clientSecretInput = document.createElement('td');
let clientSecretInputField = document.createElement('input');
clientSecretInputField.style.width = '90%';
clientSecretInputField.setAttribute('type', 'text');
clientSecretInputField.setAttribute('id', 'settings_metadatasource_' + element.source + '_clientsecret');
clientSecretInputField.value = element.secret;
clientSecretInput.appendChild(clientSecretInputField);
clientSecretRow.appendChild(clientSecretInput);
clientIdTable.appendChild(clientSecretRow);
controlsTable.appendChild(clientIdTable);
}
sourceContent.appendChild(controlsTable);
}
sourceSection.appendChild(sourceContent);
metadataSettingsContainer.appendChild(sourceSection);
});
document.getElementById('settings_signaturesource_hasheoushost').value = result.signatureSource.hasheousHost;
@@ -69,15 +225,44 @@ function setSystemSettings() {
retentionValue = 7;
}
let metadataSources = [];
let metadataSourceRadios = $("input[type='radio'][name='settings_metadatasource']");
metadataSourceRadios.each(function (index, element) {
let source = $(element).val();
let useHasheousProxy = false;
let clientId = '';
let secret = '';
if (source == "IGDB") {
let igdbClientId = document.getElementById('settings_metadatasource_' + source + '_clientid').value;
let igdbClientSecret = document.getElementById('settings_metadatasource_' + source + '_clientsecret').value;
if (igdbClientId && igdbClientSecret) {
clientId = igdbClientId;
secret = igdbClientSecret;
}
}
let useHasheousProxyRadio = $("input[type='radio'][id='settings_metadatasource_proxy_" + source + "']:checked");
if (useHasheousProxyRadio.length > 0) {
useHasheousProxy = true;
} else {
useHasheousProxy = false;
}
let metadataSource = {
"Source": source,
"UseHasheousProxy": useHasheousProxy,
"ClientId": clientId,
"Secret": secret,
"Default": $(element).is(':checked')
};
metadataSources.push(metadataSource);
});
let model = {
"alwaysLogToDisk": alwaysLogToDisk,
"minimumLogRetentionPeriod": Number(retentionValue),
"emulatorDebugMode": document.getElementById('settings_emulator_debug').checked,
"metadataSource": {
"Source": $("input[type='radio'][name='settings_metadatasource']:checked").val(),
"IgdbClientId": document.getElementById('settings_igdbclientid').value,
"IgdbClientSecret": document.getElementById('settings_igdbclientkey').value
},
"metadataSources": metadataSources,
"signatureSource": {
"Source": $("input[type='radio'][name='settings_signaturesource']:checked").val(),
"HasheousHost": document.getElementById('settings_signaturesource_hasheoushost').value,