aboutsummaryrefslogtreecommitdiff
path: root/src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-12-29 00:41:52 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-12-29 00:41:52 +0100
commita304c24b32c0327436bbd8c2853e60668e161b42 (patch)
tree08f65c05daca134cf4d2e4f779bd15d98fd66370 /src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs
parent120a3c6bddd0fb8d9fa05df4763596956554c025 (diff)
Rename a lot of stuff, add Santiago real time
Diffstat (limited to 'src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs')
-rw-r--r--src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs b/src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs
new file mode 100644
index 0000000..7c0a9c2
--- /dev/null
+++ b/src/Enmarcha.Experimental.ServiceViewer/Controllers/StylesheetController.cs
@@ -0,0 +1,39 @@
+using System.Text;
+using Enmarcha.Experimental.ServiceViewer.Data;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+namespace Enmarcha.Experimental.ServiceViewer.Controllers;
+
+[Controller]
+[Route("")]
+public class StylesheetController : Controller
+{
+ private readonly AppDbContext _db;
+ public StylesheetController(AppDbContext db)
+ {
+ _db = db;
+ }
+
+ [HttpGet("stylesheets/routecolours.css")]
+ public IActionResult GetRouteColoursSheet()
+ {
+ var routeColours = _db.Routes
+ .Select(r => new { Id = r.SafeId, r.Color, r.TextColor })
+ .ToListAsync();
+
+ StringBuilder sb = new();
+ foreach (var route in routeColours.Result)
+ {
+ sb.Append($".route-{route.Id} {{");
+ sb.Append($"--route-color: #{route.Color};");
+ sb.Append($"--route-text: #{route.TextColor};");
+ sb.Append($"--route-color-semi: #{route.Color}4d;");
+ sb.Append($"--route-text-semi: #{route.TextColor}4d;");
+ sb.Append('}');
+ }
+ sb.Append('}');
+
+ return Content(sb.ToString(), "text/css", Encoding.UTF8);
+ }
+}