From 4603f7a79a9c095e99e29fa0ccdccefa4f778cf7 Mon Sep 17 00:00:00 2001 From: Tine Date: Wed, 15 May 2024 17:25:39 +0200 Subject: [PATCH] feat: trying to setup building blocks --- internal/handlers/settings.go | 60 ++++++++++++++++++------ internal/handlers/settingsmonitors.go | 14 +++--- web/static/css/tailwind.css | 10 ++++ web/templates/components/settings.tmpl | 64 ++++++++++++++++---------- web/templates/pages/index.tmpl | 15 +++++- 5 files changed, 116 insertions(+), 47 deletions(-) diff --git a/internal/handlers/settings.go b/internal/handlers/settings.go index 1d3185b..eda2d5d 100644 --- a/internal/handlers/settings.go +++ b/internal/handlers/settings.go @@ -8,10 +8,15 @@ import ( "github.com/labstack/echo/v4" ) +type SettingsSidebarGroup struct { + Group string + Pages []*components.Page +} + type Settings struct { *components.Base SettingsSidebarActive *components.Page - SettingsSidebar []*components.Page + SettingsSidebar []SettingsSidebarGroup User *AuthenticatedUser SettingsBreadcrumbs []*components.Page } @@ -23,7 +28,7 @@ func NewSettings(user *AuthenticatedUser, page *components.Page, breadCrumbs []* Navbar: Pages, }, SettingsSidebarActive: page, - SettingsSidebar: SettingsNavbar, + SettingsSidebar: SettingsSidebar, SettingsBreadcrumbs: breadCrumbs, User: user, } @@ -31,10 +36,11 @@ func NewSettings(user *AuthenticatedUser, page *components.Page, breadCrumbs []* var SettingsPages = []*components.Page{ {Path: "/settings", Title: "Overview", Breadcrumb: "Overview"}, - {Path: "/settings/targets", Title: "Targets", Breadcrumb: "Monitors"}, + {Path: "/settings/targets", Title: "Incidents", Breadcrumb: "Incidents"}, + {Path: "/settings/targets", Title: "Targets", Breadcrumb: "Targets"}, {Path: "/settings/targets/create", Title: "Targets Create", Breadcrumb: "Create"}, - {Path: "/settings/monitors", Title: "Monitors", Breadcrumb: "Monitors"}, - {Path: "/settings/monitors/create", Title: "Monitors Create", Breadcrumb: "Create"}, + {Path: "/settings/monitors", Title: "Checks", Breadcrumb: "Checks"}, + {Path: "/settings/monitors/create", Title: "Checks Create", Breadcrumb: "Create"}, {Path: "/settings/worker-groups", Title: "Worker Groups", Breadcrumb: "Worker Groups"}, {Path: "/settings/worker-groups/create", Title: "Worker Groups Create", Breadcrumb: "Create"}, {Path: "/settings/notifications", Title: "Notifications", Breadcrumb: "Notifications"}, @@ -45,15 +51,41 @@ var SettingsPages = []*components.Page{ {Path: "/oauth2/logout", Title: "Logout", Breadcrumb: "Logout"}, } -var SettingsNavbar = []*components.Page{ - GetPageByTitle(SettingsPages, "Overview"), - GetPageByTitle(SettingsPages, "Targets"), - GetPageByTitle(SettingsPages, "Monitors"), - GetPageByTitle(SettingsPages, "Triggers"), - GetPageByTitle(SettingsPages, "Notifications"), - GetPageByTitle(SettingsPages, "Worker Groups"), - GetPageByTitle(SettingsPages, "Temporal"), - GetPageByTitle(SettingsPages, "Logout"), +var SettingsSidebar = []SettingsSidebarGroup{ + { + Group: "Overview", + Pages: []*components.Page{ + GetPageByTitle(SettingsPages, "Overview"), + }, + }, + { + Group: "Monitor", + Pages: []*components.Page{ + GetPageByTitle(SettingsPages, "Targets"), + GetPageByTitle(SettingsPages, "Checks"), + }, + }, + { + Group: "Decide", + Pages: []*components.Page{ + GetPageByTitle(SettingsPages, "Triggers"), + }, + }, + { + Group: "Notify", + Pages: []*components.Page{ + GetPageByTitle(SettingsPages, "Incidents"), + GetPageByTitle(SettingsPages, "Notifications"), + }, + }, + { + Group: "Manage", + Pages: []*components.Page{ + GetPageByTitle(SettingsPages, "Worker Groups"), + GetPageByTitle(SettingsPages, "Temporal"), + GetPageByTitle(SettingsPages, "Logout"), + }, + }, } type SettingsOverview struct { diff --git a/internal/handlers/settingsmonitors.go b/internal/handlers/settingsmonitors.go index 0c7b9ea..99a426a 100644 --- a/internal/handlers/settingsmonitors.go +++ b/internal/handlers/settingsmonitors.go @@ -86,8 +86,8 @@ func (h *BaseHandler) SettingsMonitorsGET(c echo.Context) error { return c.Render(http.StatusOK, "settings_monitors.tmpl", &SettingsMonitors{ Settings: NewSettings( cc.Principal.User, - GetPageByTitle(SettingsPages, "Monitors"), - []*components.Page{GetPageByTitle(SettingsPages, "Monitors")}, + GetPageByTitle(SettingsPages, "Checks"), + []*components.Page{GetPageByTitle(SettingsPages, "Checks")}, ), Monitors: monitorsByGroup, MonitorGroups: monitorGroups, @@ -127,9 +127,9 @@ func (h *BaseHandler) SettingsMonitorsDescribeGET(c echo.Context) error { return c.Render(http.StatusOK, "settings_monitors_describe.tmpl", &SettingsMonitor{ Settings: NewSettings( cc.Principal.User, - GetPageByTitle(SettingsPages, "Monitors"), + GetPageByTitle(SettingsPages, "Checks"), []*components.Page{ - GetPageByTitle(SettingsPages, "Monitors"), + GetPageByTitle(SettingsPages, "Checks"), { Path: fmt.Sprintf("/settings/monitors/%s", slug), Title: "Describe", @@ -260,10 +260,10 @@ func (h *BaseHandler) SettingsMonitorsCreateGET(c echo.Context) error { return c.Render(http.StatusOK, "settings_monitors_create.tmpl", &SettingsMonitorCreate{ Settings: NewSettings( cc.Principal.User, - GetPageByTitle(SettingsPages, "Monitors"), + GetPageByTitle(SettingsPages, "Checks"), []*components.Page{ - GetPageByTitle(SettingsPages, "Monitors"), - GetPageByTitle(SettingsPages, "Monitors Create"), + GetPageByTitle(SettingsPages, "Checks"), + GetPageByTitle(SettingsPages, "Checks Create"), }, ), Example: h.examples.Monitor, diff --git a/web/static/css/tailwind.css b/web/static/css/tailwind.css index d9fcd81..83f35cb 100644 --- a/web/static/css/tailwind.css +++ b/web/static/css/tailwind.css @@ -974,6 +974,11 @@ video { background-color: rgb(74 222 128 / var(--tw-bg-opacity)); } +.bg-orange-300 { + --tw-bg-opacity: 1; + background-color: rgb(253 186 116 / var(--tw-bg-opacity)); +} + .bg-red-100 { --tw-bg-opacity: 1; background-color: rgb(254 226 226 / var(--tw-bg-opacity)); @@ -1183,6 +1188,11 @@ video { color: rgb(107 114 128 / var(--tw-text-opacity)); } +.text-gray-600 { + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity)); +} + .text-gray-700 { --tw-text-opacity: 1; color: rgb(55 65 81 / var(--tw-text-opacity)); diff --git a/web/templates/components/settings.tmpl b/web/templates/components/settings.tmpl index 121d49d..ce72719 100644 --- a/web/templates/components/settings.tmpl +++ b/web/templates/components/settings.tmpl @@ -10,35 +10,49 @@
-
- {{ else }} + {{ else if eq .Status "INCIDENT" }}
+

Incident in progress

+

+ Last updated on + {{ Now.UTC.Format "Jan 02 at 15:04 MST" }} +

+
+ {{ else }} +
+ + +

Degraded performance

Last updated on