Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions roles/database/files/sql/idempotent/fworch-texts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,22 @@ INSERT INTO txt VALUES ('edit_notification', 'German', 'Benachrichtigung bea
INSERT INTO txt VALUES ('edit_notification', 'English', 'Edit Notification');
INSERT INTO txt VALUES ('delete_notification', 'German', 'Benachrichtigung löschen');
INSERT INTO txt VALUES ('delete_notification', 'English', 'Delete Notification');
INSERT INTO txt VALUES ('notification', 'German', 'Benachrichtigung');
INSERT INTO txt VALUES ('notification', 'English', 'Notification');
INSERT INTO txt VALUES ('edit_notification', 'German', 'Benachrichtigung bearbeiten');
INSERT INTO txt VALUES ('edit_notification', 'English', 'Edit Notification');
INSERT INTO txt VALUES ('delete_notification', 'German', 'Benachrichtigung löschen');
INSERT INTO txt VALUES ('delete_notification', 'English', 'Delete Notification');
INSERT INTO txt VALUES ('color_scheme', 'German', 'Farbschema');
INSERT INTO txt VALUES ('color_scheme', 'English', 'Color Scheme');
INSERT INTO txt VALUES ('color_scheme_blue', 'German', 'Blaues Farbschema');
INSERT INTO txt VALUES ('color_scheme_blue', 'English', 'Blue Color Scheme');
INSERT INTO txt VALUES ('color_scheme_green', 'German', 'Grünes Farbschema');
INSERT INTO txt VALUES ('color_scheme_green', 'English', 'Green Color Scheme');
INSERT INTO txt VALUES ('color_scheme_red', 'German', 'Rotes Farbschema');
INSERT INTO txt VALUES ('color_scheme_red', 'English', 'Red Color Scheme');
INSERT INTO txt VALUES ('color_scheme_purple', 'German', 'Violettes Farbschema');
INSERT INTO txt VALUES ('color_scheme_purple', 'English', 'Purple Color Scheme');

-- monitoring
INSERT INTO txt VALUES ('open_alerts', 'German', 'Offene Alarme');
Expand Down
10 changes: 10 additions & 0 deletions roles/database/files/upgrade/8.8.11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
INSERT INTO txt VALUES ('color_scheme', 'German', 'Farbschema');
INSERT INTO txt VALUES ('color_scheme', 'English', 'Color Scheme');
INSERT INTO txt VALUES ('color_scheme_standard', 'German', 'Standard Farbschema');
INSERT INTO txt VALUES ('color_scheme_standard', 'English', 'Standard Color Scheme');
INSERT INTO txt VALUES ('color_scheme_green', 'German', 'Grünes Farbschema');
INSERT INTO txt VALUES ('color_scheme_green', 'English', 'Green Color Scheme');
INSERT INTO txt VALUES ('color_scheme_red', 'German', 'Rotes Farbschema');
INSERT INTO txt VALUES ('color_scheme_red', 'English', 'Red Color Scheme');
INSERT INTO txt VALUES ('color_scheme_purple', 'German', 'Violettes Farbschema');
INSERT INTO txt VALUES ('color_scheme_purple', 'English', 'Purple Color Scheme');
45 changes: 45 additions & 0 deletions roles/lib/files/FWO.Config.Api/Data/ColorScheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Text.Json.Serialization;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto.Engines;

namespace FWO.Config.Api.Data
{
/// <summary>
/// a list of all available ColorSchemes
/// </summary>
public class ColorScheme
{
[JsonProperty("name"), JsonPropertyName("name")]
public string Name { get; set; } = "";

[JsonProperty("isDefault"), JsonPropertyName("isDefault")]
public bool IsDefault { get; set; } = false;

[JsonProperty("hex"), JsonPropertyName("hex")]
public string Hex { get; set; } = "";

[JsonProperty("hex2"), JsonPropertyName("hex2")]
public string Hex2 { get; set; } = "";

[JsonProperty("textHex"), JsonPropertyName("textHex")]
public string TextHex { get; set; } = "";


public static List<ColorScheme> AvailableSchemes { get; } = new List<ColorScheme>
{
new ColorScheme { Name = "color_scheme_blue", IsDefault = true, Hex = "#054B8C", Hex2 = "#03335E", TextHex = "#2FA5ED" },
new ColorScheme { Name = "color_scheme_green", Hex = "#1c8c05ff" , Hex2 = "#155e03ff", TextHex = "#b4ed2fff" },
new ColorScheme { Name = "color_scheme_red", Hex = "#8c0505ff", Hex2 = "#5e0303ff", TextHex = "#ed2f2fff" },
new ColorScheme { Name = "color_scheme_purple", Hex = "#5b058cff", Hex2 = "#3a035eff", TextHex = "#a12fedff" }
// Add more schemes as needed
};

public static ColorScheme GetSchemeByName(string name)
{
return AvailableSchemes.FirstOrDefault(s => s.Name == name) ?? AvailableSchemes.First(s => s.IsDefault);
}
}

}


3 changes: 3 additions & 0 deletions roles/lib/files/FWO.Config.Api/Data/ConfigData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ public class ConfigData : ICloneable
[JsonProperty("debugConfig"), JsonPropertyName("debugConfig")]
public string DebugConfig { get; set; } = "";

[JsonProperty("colorScheme"), JsonPropertyName("colorScheme"), UserConfigData]
public string ColorScheme { get; set; } = "color_scheme_blue";

[JsonProperty("autoCalculateInternetZone"), JsonPropertyName("autoCalculateInternetZone")]
public bool AutoCalculateInternetZone { get; set; } = true;

Expand Down
14 changes: 14 additions & 0 deletions roles/ui/files/FWO.UI/Pages/Settings/SettingsDefaults.razor
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
<CustomLogoUpload AuthorizedRoles="@Roles.Admin" SupportedFileFormats=".png,.jpg,.jpeg"></CustomLogoUpload>
</div>
</div>
<div class="form-group row" data-toggle="tooltip" title="@(userConfig.PureLine("H5411"))">
<label class="col-form-label col-sm-4">@(userConfig.GetText("color_scheme")):</label>
<div class="col-sm-2">
<Dropdown ElementType="ColorScheme" ElementToString="@(c => userConfig.GetText(c.Name ))" @bind-SelectedElement="selectedColorScheme" Elements="ColorScheme.AvailableSchemes">
<ElementTemplate Context="colorScheme">
@(userConfig.GetText(colorScheme.Name))
</ElementTemplate>
</Dropdown>
</div>
</div>
<hr />
<div class="form-group row" data-toggle="tooltip" title="@(userConfig.PureLine("H5412"))">
<label class="col-form-label col-sm-4">@(userConfig.GetText("elementsPerFetch"))*:</label>
Expand Down Expand Up @@ -223,6 +233,7 @@ else

private ConfigData? configData;
private Language selectedLanguage = new Language();
private ColorScheme selectedColorScheme = new ColorScheme();
private DateTime autoDiscStartDate = DateTime.Today;
private DateTime autoDiscStartTime = DateTime.Now.AddSeconds(-DateTime.Now.Second);
private List<Module> availableModules { get; set; } = [];
Expand All @@ -239,6 +250,7 @@ else

configData = await globalConfig.GetEditableConfig();
selectedLanguage = globalConfig.UiLanguages.FirstOrDefault(l => l.Name == configData.DefaultLanguage) ?? new Language();
selectedColorScheme = ColorScheme.GetSchemeByName(configData.ColorScheme);
autoDiscStartDate = autoDiscStartTime = configData.AutoDiscoverStartAt;
availableModules = JsonSerializer.Deserialize<List<Module>>(string.IsNullOrEmpty(configData.AvailableModules) ? ModuleGroups.AllModulesNumList() : configData.AvailableModules) ?? throw new JsonException("Config data could not be parsed.");
modulesVisibleDict = [];
Expand All @@ -261,6 +273,8 @@ else
if(configData != null)
{
configData.DefaultLanguage = selectedLanguage.Name;
configData.ColorScheme = selectedColorScheme.Name;
StateHasChanged();
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling StateHasChanged() in the middle of the Save() method is unnecessary and could cause premature re-rendering before the save operation completes. If a state refresh is needed, it should be called after all data modifications are complete, or removed entirely if the framework handles it automatically after the async operation completes.

Suggested change
StateHasChanged();

Copilot uses AI. Check for mistakes.
configData.AutoDiscoverStartAt = autoDiscStartDate.Date.Add(autoDiscStartTime.TimeOfDay);
availableModules = [];
foreach(Module module in modulesVisibleDict.Keys)
Expand Down
46 changes: 46 additions & 0 deletions roles/ui/files/FWO.UI/Services/ColorThemeService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

using System.Collections.Concurrent;


namespace FWO.Ui.Services
{
public interface IColorModeServices
{
string GetColourMode(string key);
bool SetColourMode(string key, string mode);
}
public class ColorModeServices : IColorModeServices
{
private readonly ConcurrentDictionary<string, string> _UserColorModes = new ConcurrentDictionary<string, string>();

public string GetColourMode(string key)
{
string mode = string.Empty;
if (_UserColorModes.TryGetValue(key, out mode))
{
return mode;
}
else
{
//Did not find
mode = "light"; //Default mode
}
return mode;
}

public bool SetColourMode(string key, string mode)
{
bool allGood = false;
if (_UserColorModes.TryAdd(key, mode))
{
allGood = true;

}
else
{
allGood = _UserColorModes.TryUpdate(key, mode, _UserColorModes[key]);
}
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Suggested change
bool allGood = false;
if (_UserColorModes.TryAdd(key, mode))
{
allGood = true;
}
else
{
allGood = _UserColorModes.TryUpdate(key, mode, _UserColorModes[key]);
}
bool allGood = _UserColorModes.TryAdd(key, mode)
? true
: _UserColorModes.TryUpdate(key, mode, _UserColorModes[key]);

Copilot uses AI. Check for mistakes.
return allGood;
}
}
}
4 changes: 3 additions & 1 deletion roles/ui/files/FWO.UI/Shared/NavigationMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
@if (InitComplete)
{
<div class="position-sticky" style="z-index:15; top:0px;">
<nav id="navbar" class="navbar navbar-expand-xl navbar-dark bg-blue shadow w-100">
<nav id="navbar" class="navbar navbar-expand-xl navbar-dark bg-blue shadow w-100"
style="--bg-color:@(ColorScheme.GetSchemeByName(userConfig.ColorScheme).Hex);
--bg-color-2:@(ColorScheme.GetSchemeByName(userConfig.ColorScheme).Hex2);">
<a class="navbar-brand pad-10" href="#">
@if (globalConfig.UseCustomLogo)
{
Expand Down
5 changes: 2 additions & 3 deletions roles/ui/files/FWO.UI/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ header {

.bg-blue {
z-index: 10;
background-image: linear-gradient(#054B8C, #03335E);
background-image: linear-gradient(var(--bg-color, #054B8C), var(--bg-color-2, #03335E));
}

.bg-gray {
Expand Down Expand Up @@ -173,10 +173,9 @@ h2,
h3,
h4,
h5 {
color: #2FA5ED;
color: var(--heading-color, #2FA5ED); /* fallback if not set */
font-weight: bold;
}

.popup-body {
height: fit-content;
/* Increase/decrease this value for cross-browser compatibility */
Expand Down
Loading