From 7576c9c3e24d0b8580a7d254adcf421e842a3925 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 20 Sep 2021 18:22:15 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- server/AyaNova/Controllers/ScheduleController.cs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 976f60e9..f92c39ec 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,7 +52,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "true", + "AYANOVA_SERVER_TEST_MODE": "false", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" diff --git a/server/AyaNova/Controllers/ScheduleController.cs b/server/AyaNova/Controllers/ScheduleController.cs index de35c19c..20e98194 100644 --- a/server/AyaNova/Controllers/ScheduleController.cs +++ b/server/AyaNova/Controllers/ScheduleController.cs @@ -21,6 +21,9 @@ namespace AyaNova.Api.Controllers [Authorize] public class ScheduleController : ControllerBase { + private const string WHITE_HEXA = "#FFFFFFFF"; + private const string BLACK_HEXA = "#000000FF"; + private const string GRAY_NEUTRAL_HEXA = "#CACACAFF"; private readonly AyContext ct; private readonly ILogger log; private readonly ApiServerState serverState; @@ -183,8 +186,8 @@ namespace AyaNova.Api.Controllers { var s = new PersonalScheduleListItem(); s.Id = v.Id; - s.Color = p.Dark ? "white" : "black"; - s.TextColor = TextColor(s.Color); + s.Color = p.Dark ? WHITE_HEXA : BLACK_HEXA; + s.TextColor = p.Dark ? BLACK_HEXA : WHITE_HEXA; s.Start = (DateTime)v.ReviewDate; s.End = (DateTime)v.ReviewDate.AddMinutes(30);//just something to show in schedule as not supporting all day or unscheduled type stuff s.Type = AyaType.Review; @@ -211,13 +214,16 @@ namespace AyaNova.Api.Controllers private static string TextColor(string hexcolor) { - if (string.IsNullOrWhiteSpace(hexcolor)) return "black"; + //Note: we use HEXA format which is 8 hex digits + //this here works even though it's considering as 6 digits because in hexA the last two + //digits are the opacity which this can ignore + if (string.IsNullOrWhiteSpace(hexcolor) || hexcolor.Length < 6) return GRAY_NEUTRAL_HEXA;//gray neutral hexcolor = hexcolor.Replace("#", ""); var r = StringUtil.HexToInt(hexcolor.Substring(0, 2)); var g = StringUtil.HexToInt(hexcolor.Substring(2, 2)); var b = StringUtil.HexToInt(hexcolor.Substring(4, 2)); var yiq = (r * 299 + g * 587 + b * 114) / 1000; - return yiq >= 128 ? "black" : "white"; + return yiq >= 128 ? WHITE_HEXA : BLACK_HEXA; } private static string NameFromWOItem(ViewSchedulePersonalWorkOrder v, PersonalScheduleParams p)