Compare commits

...

7 Commits

13 changed files with 1541 additions and 332 deletions

View File

@@ -1,6 +1,10 @@
FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm
RUN apt-get update && apt-get install -y p7zip-full # update apt-get
RUN mkdir -p /workspace/gaseous-server/wwwroot/emulators/EmulatorJS RUN apt-get update
RUN wget https://cdn.emulatorjs.org/releases/4.0.11.7z
RUN 7z x -y -o/workspace/gaseous-server/wwwroot/emulators/EmulatorJS 4.0.11.7z # download and unzip EmulatorJS from CDN
RUN apt-get install -y p7zip-full
RUN mkdir -p out/wwwroot/emulators/EmulatorJS
RUN wget https://cdn.emulatorjs.org/releases/4.1.1.7z
RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.1.1.7z

View File

@@ -1,85 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "main", "branch-v*.*.*" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '21 11 * * 2'
jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'csharp', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Sign in to Nuget
run: dotnet nuget add source --username michael-j-green --password ${{ secrets.NUGETKEY }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/gaseous-project/index.json"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

View File

@@ -14,19 +14,14 @@ RUN dotnet restore "gaseous-server/gaseous-server.csproj" -a $TARGETARCH
# Build and publish a release # Build and publish a release
RUN dotnet publish "gaseous-server/gaseous-server.csproj" --use-current-runtime --self-contained true -c Release -o out -a $TARGETARCH RUN dotnet publish "gaseous-server/gaseous-server.csproj" --use-current-runtime --self-contained true -c Release -o out -a $TARGETARCH
# disabled for 1.7.4 as the next version EmulatorJS is not yet available # update apt-get
# # update apt-get RUN apt-get update
# RUN apt-get update
# # download and unzip EmulatorJS from CDN # download and unzip EmulatorJS from CDN
# RUN apt-get install -y p7zip-full RUN apt-get install -y p7zip-full
# RUN mkdir -p out/wwwroot/emulators/EmulatorJS
# RUN wget https://cdn.emulatorjs.org/releases/4.0.12.7z
# RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.0.12.7z
RUN wget --recursive --no-parent https://cdn.emulatorjs.org/latest/
RUN mkdir -p out/wwwroot/emulators/EmulatorJS RUN mkdir -p out/wwwroot/emulators/EmulatorJS
RUN cp -fr cdn.emulatorjs.org/latest/* out/wwwroot/emulators/EmulatorJS RUN wget https://cdn.emulatorjs.org/releases/4.1.1.7z
RUN rm -Rf cdn.emulatorjs.org RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.1.1.7z
# clean up apt-get # clean up apt-get
RUN apt-get clean && rm -rf /var/lib/apt/lists RUN apt-get clean && rm -rf /var/lib/apt/lists

View File

@@ -14,15 +14,14 @@ RUN dotnet restore "gaseous-server/gaseous-server.csproj" -a $TARGETARCH
# Build and publish a release # Build and publish a release
RUN dotnet publish "gaseous-server/gaseous-server.csproj" --use-current-runtime --self-contained true -c Release -o out -a $TARGETARCH RUN dotnet publish "gaseous-server/gaseous-server.csproj" --use-current-runtime --self-contained true -c Release -o out -a $TARGETARCH
# disabled for 1.7.4 as the next version EmulatorJS is not yet available # update apt-get
# # update apt-get RUN apt-get update
# RUN apt-get update
# # download and unzip EmulatorJS from CDN # download and unzip EmulatorJS from CDN
# RUN apt-get install -y p7zip-full RUN apt-get install -y p7zip-full
# RUN mkdir -p out/wwwroot/emulators/EmulatorJS RUN mkdir -p out/wwwroot/emulators/EmulatorJS
# RUN wget https://cdn.emulatorjs.org/releases/4.0.12.7z RUN wget https://cdn.emulatorjs.org/releases/4.1.1.7z
# RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.0.12.7z RUN 7z x -y -oout/wwwroot/emulators/EmulatorJS 4.1.1.7z
RUN wget --recursive --no-parent https://cdn.emulatorjs.org/latest/ RUN wget --recursive --no-parent https://cdn.emulatorjs.org/latest/
RUN mkdir -p out/wwwroot/emulators/EmulatorJS RUN mkdir -p out/wwwroot/emulators/EmulatorJS

View File

@@ -361,25 +361,38 @@ 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())
{ {
dbDict = new Dictionary<string, object> case "System.DateTime":
{ dbDict = new Dictionary<string, object>
{ "SettingName", SettingName }, {
{ "ValueType", 1 }, { "SettingName", SettingName },
{ "Value", null }, { "ValueType", 1 },
{ "ValueDate", Value } { "Value", null },
}; { "ValueDate", Value }
} };
else break;
{
dbDict = new Dictionary<string, object> case "System.Collections.Generic.List`1[gaseous_server.Classes.Metadata.Games+SearchType]":
{ dbDict = new Dictionary<string, object>
{ "SettingName", SettingName }, {
{ "ValueType", 0 }, { "SettingName", SettingName },
{ "Value", Value }, { "ValueType", 2 },
{ "ValueDate", null } { "Value", JsonConvert.SerializeObject(Value) },
}; { "ValueDate", null }
};
break;
default:
dbDict = new Dictionary<string, object>
{
{ "SettingName", SettingName },
{ "ValueType", 0 },
{ "Value", Value },
{ "ValueDate", null }
};
break;
} }
} }
else else

View File

@@ -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))
{ {

View File

@@ -7,7 +7,7 @@ namespace gaseous_server.Classes.Metadata
{ {
public class Games public class Games
{ {
const string fieldList = "fields age_ratings,aggregated_rating,aggregated_rating_count,alternative_names,artworks,bundles,category,checksum,collection,collections,cover,created_at,dlcs,expanded_games,expansions,external_games,first_release_date,follows,forks,franchise,franchises,game_engines,game_localizations,game_modes,genres,hypes,involved_companies,keywords,language_supports,multiplayer_modes,name,parent_game,platforms,player_perspectives,ports,rating,rating_count,release_dates,remakes,remasters,screenshots,similar_games,slug,standalone_expansions,status,storyline,summary,tags,themes,total_rating,total_rating_count,updated_at,url,version_parent,version_title,videos,websites;"; const string fieldList = "fields age_ratings,aggregated_rating,aggregated_rating_count,alternative_names,artworks,bundles,category,checksum,collections,cover,created_at,dlcs,expanded_games,expansions,external_games,first_release_date,follows,forks,franchise,franchises,game_engines,game_localizations,game_modes,genres,hypes,involved_companies,keywords,language_supports,multiplayer_modes,name,parent_game,platforms,player_perspectives,ports,rating,rating_count,release_dates,remakes,remasters,screenshots,similar_games,slug,standalone_expansions,status,storyline,summary,tags,themes,total_rating,total_rating_count,updated_at,url,version_parent,version_title,videos,websites;";
public Games() public Games()
{ {

View File

@@ -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; }
} }
} }

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View File

@@ -16,20 +16,20 @@
<DocumentationFile>bin\Release\net8.0\gaseous-server.xml</DocumentationFile> <DocumentationFile>bin\Release\net8.0\gaseous-server.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.0.0" /> <PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.0.0" /> <PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="gaseous-signature-parser" Version="2.1.0" /> <PackageReference Include="gaseous-signature-parser" Version="2.1.0" />
<PackageReference Include="gaseous.IGDB" Version="1.0.2" /> <PackageReference Include="gaseous.IGDB" Version="1.0.2" />
<PackageReference Include="hasheous-client" Version="0.1.0" /> <PackageReference Include="hasheous-client" Version="0.1.0" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.5.0" /> <PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.5.0" />
<PackageReference Include="sharpcompress" Version="0.36.0" /> <PackageReference Include="sharpcompress" Version="0.38.0" />
<PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.1.23" /> <PackageReference Include="Squid-Box.SevenZipSharp" Version="1.6.2.24" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageReference Include="MySqlConnector" Version="2.3.5" /> <PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.1" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -41,11 +41,10 @@
EJS_threads = false; EJS_threads = false;
EJS_Buttons = { EJS_Buttons = {
saveSavFiles: false, exitEmulation: false
loadSavFiles: false
} }
EJS_onSaveState = function(e) { EJS_onSaveState = function (e) {
var returnValue = { var returnValue = {
"ScreenshotByteArrayBase64": btoa(Uint8ToString(e.screenshot)), "ScreenshotByteArrayBase64": btoa(Uint8ToString(e.screenshot)),
"StateByteArrayBase64": btoa(Uint8ToString(e.state)) "StateByteArrayBase64": btoa(Uint8ToString(e.state))
@@ -72,7 +71,7 @@
returnValue = undefined; returnValue = undefined;
} }
EJS_onLoadState = function(e) { EJS_onLoadState = function (e) {
showDialog('emulatorloadstate', { "romId": romId, "IsMediaGroup": IsMediaGroup }); showDialog('emulatorloadstate', { "romId": romId, "IsMediaGroup": IsMediaGroup });
} }
</script> </script>

View File

@@ -6,15 +6,17 @@
<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>
<h3>Background Task Timers</h3> <h3>Background Task Timers</h3>
<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>&nbsp;</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>&nbsp;</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>&nbsp;</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>
@@ -95,9 +151,9 @@
} }
newTable.appendChild(createTableRow( newTable.appendChild(createTableRow(
false, false,
[ [
result[i].name, result[i].name,
result[i].path, result[i].path,
platformName, platformName,
defaultLibrary, defaultLibrary,
@@ -115,14 +171,14 @@
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 = '';
for (const [key, value] of Object.entries(result)) { for (const [key, value] of Object.entries(result)) {
var newTableRowBody = document.createElement('tbody'); var newTableRowBody = document.createElement('tbody');
newTableRowBody.className = 'romrow'; newTableRowBody.className = 'romrow';
var enabledString = ""; var enabledString = "";
if (value.enabled == true) { if (value.enabled == true) {
enabledString = 'checked="checked"'; enabledString = 'checked="checked"';
@@ -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)