-
Notifications
You must be signed in to change notification settings - Fork 18
Feat/color schemes rework #3878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: importer-rework
Are you sure you want to change the base?
Changes from 2 commits
a453a51
9a31171
fa0dafe
4b71211
378b4d1
f7864d6
d72220b
d7824cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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'); |
| 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; | ||
|
|
||
ErikPre marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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> | ||||
|
|
@@ -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; } = []; | ||||
|
|
@@ -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 = []; | ||||
|
|
@@ -261,6 +273,8 @@ else | |||
| if(configData != null) | ||||
| { | ||||
| configData.DefaultLanguage = selectedLanguage.Name; | ||||
| configData.ColorScheme = selectedColorScheme.Name; | ||||
| StateHasChanged(); | ||||
|
||||
| StateHasChanged(); |
| 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]); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| 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]); |
Uh oh!
There was an error while loading. Please reload this page.