Added a setting to toggle the emulator debug mode

* Added a setting to toggle the emulator debug mode
This commit is contained in:
Michael Green
2024-01-28 21:46:47 +11:00
committed by GitHub
parent 10be6c53ba
commit 69863f8b61
3 changed files with 28 additions and 11 deletions

View File

@@ -106,7 +106,8 @@ namespace gaseous_server.Controllers
}) + ";" + Environment.NewLine + }) + ";" + Environment.NewLine +
"var AgeRatingGroups = " + JsonSerializer.Serialize(AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{ "var AgeRatingGroups = " + JsonSerializer.Serialize(AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{
WriteIndented = true WriteIndented = true
}) + ";"; }) + ";" + Environment.NewLine +
"var emulatorDebugMode = " + Config.ReadSetting<string>("emulatorDebugMode", false.ToString()).ToLower() + ";";
byte[] bytes = Encoding.UTF8.GetBytes(ver); byte[] bytes = Encoding.UTF8.GetBytes(ver);
return File(bytes, "text/javascript"); return File(bytes, "text/javascript");
} }
@@ -251,7 +252,8 @@ namespace gaseous_server.Controllers
{ {
SystemSettingsModel systemSettingsModel = new SystemSettingsModel{ SystemSettingsModel systemSettingsModel = new SystemSettingsModel{
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()))
}; };
return Ok(systemSettingsModel); return Ok(systemSettingsModel);
@@ -269,6 +271,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.UpdateConfig(); Config.UpdateConfig();
} }
@@ -705,5 +708,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; }
} }
} }

View File

@@ -28,7 +28,7 @@
// Path to the data directory // Path to the data directory
EJS_pathtodata = '/emulators/EmulatorJS/data/'; EJS_pathtodata = '/emulators/EmulatorJS/data/';
EJS_DEBUG_XX = false; EJS_DEBUG_XX = emulatorDebugMode;
console.log("Debug enabled: " + EJS_DEBUG_XX); console.log("Debug enabled: " + EJS_DEBUG_XX);
EJS_backgroundImage = emuBackground; EJS_backgroundImage = emuBackground;

View File

@@ -16,8 +16,11 @@
</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>Logging</h3> <h3>System Settings</h3>
<table cellspacing="0" style="width: 100%;"> <table cellspacing="0" style="width: 100%;">
<tr>
<th colspan="2">Logging</th>
</tr>
<tr> <tr>
<th> <th>
Write logs Write logs
@@ -43,9 +46,16 @@
<input type="number" min="1" id="settings_logs_retention" /> <input type="number" min="1" id="settings_logs_retention" />
</td> </td>
</tr> </tr>
<tr>
<th colspan="2">Emulator</th>
</tr>
<tr>
<th>Enable debug mode</th>
<td><input type="checkbox" name="settings_emulator" id="settings_emulator_debug" checked="checked" /></td>
</tr>
<tr> <tr>
<td colspan="2" style="text-align: right;"> <td colspan="2" style="text-align: right;">
<button id="settings_tasktimers_new" onclick="setLoggingSettings();">Save</button> <button id="settings_tasktimers_new" onclick="setSystemSettings();">Save</button>
</td> </td>
</tr> </tr>
</table> </table>
@@ -379,7 +389,7 @@
saveTaskTimers(); saveTaskTimers();
} }
function getLoggingSettings() { function getSystemSettings() {
ajaxCall( ajaxCall(
'/api/v1/System/Settings/System', '/api/v1/System/Settings/System',
'GET', 'GET',
@@ -391,11 +401,13 @@
document.getElementById(optionToSelect).checked = true; document.getElementById(optionToSelect).checked = true;
document.getElementById('settings_logs_retention').value = result.minimumLogRetentionPeriod; document.getElementById('settings_logs_retention').value = result.minimumLogRetentionPeriod;
document.getElementById('settings_emulator_debug').checked = result.emulatorDebugMode;
} }
); );
} }
function setLoggingSettings() { function setSystemSettings() {
var alwaysLogToDisk = false; var alwaysLogToDisk = false;
if ($("input[type='radio'][name='settings_logs_write']:checked").val() == "true") { if ($("input[type='radio'][name='settings_logs_write']:checked").val() == "true") {
alwaysLogToDisk = true; alwaysLogToDisk = true;
@@ -411,17 +423,18 @@
var model = { var model = {
"alwaysLogToDisk": alwaysLogToDisk, "alwaysLogToDisk": alwaysLogToDisk,
"minimumLogRetentionPeriod": retentionValue "minimumLogRetentionPeriod": retentionValue,
"emulatorDebugMode": document.getElementById('settings_emulator_debug').checked
}; };
ajaxCall( ajaxCall(
'/api/v1/System/Settings/System', '/api/v1/System/Settings/System',
'POST', 'POST',
function(result) { function(result) {
getLoggingSettings(); getSystemSettings();
}, },
function(error) { function(error) {
getLoggingSettings(); getSystemSettings();
}, },
JSON.stringify(model) JSON.stringify(model)
); );
@@ -429,5 +442,5 @@
drawLibrary(); drawLibrary();
getBackgroundTaskTimers(); getBackgroundTaskTimers();
getLoggingSettings(); getSystemSettings();
</script> </script>