This commit is contained in:
2021-09-20 18:22:15 +00:00
parent 6de72a6dd3
commit 7576c9c3e2
2 changed files with 11 additions and 5 deletions

2
.vscode/launch.json vendored
View File

@@ -52,7 +52,7 @@
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", "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_SEEDLEVEL": "small",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"

View File

@@ -21,6 +21,9 @@ namespace AyaNova.Api.Controllers
[Authorize] [Authorize]
public class ScheduleController : ControllerBase 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 AyContext ct;
private readonly ILogger<ScheduleController> log; private readonly ILogger<ScheduleController> log;
private readonly ApiServerState serverState; private readonly ApiServerState serverState;
@@ -183,8 +186,8 @@ namespace AyaNova.Api.Controllers
{ {
var s = new PersonalScheduleListItem(); var s = new PersonalScheduleListItem();
s.Id = v.Id; s.Id = v.Id;
s.Color = p.Dark ? "white" : "black"; s.Color = p.Dark ? WHITE_HEXA : BLACK_HEXA;
s.TextColor = TextColor(s.Color); s.TextColor = p.Dark ? BLACK_HEXA : WHITE_HEXA;
s.Start = (DateTime)v.ReviewDate; 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.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; s.Type = AyaType.Review;
@@ -211,13 +214,16 @@ namespace AyaNova.Api.Controllers
private static string TextColor(string hexcolor) 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("#", ""); hexcolor = hexcolor.Replace("#", "");
var r = StringUtil.HexToInt(hexcolor.Substring(0, 2)); var r = StringUtil.HexToInt(hexcolor.Substring(0, 2));
var g = StringUtil.HexToInt(hexcolor.Substring(2, 2)); var g = StringUtil.HexToInt(hexcolor.Substring(2, 2));
var b = StringUtil.HexToInt(hexcolor.Substring(4, 2)); var b = StringUtil.HexToInt(hexcolor.Substring(4, 2));
var yiq = (r * 299 + g * 587 + b * 114) / 1000; 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) private static string NameFromWOItem(ViewSchedulePersonalWorkOrder v, PersonalScheduleParams p)