From 9ba1a0f76a123235a6f483b4eac33f09b777a521 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Wed, 29 Mar 2023 08:58:12 -0700 Subject: [PATCH] Adds health status by parsing the label from status (#2099) * Adds healthcheck to status in menu * Fixes bug with crated * Moves colors to vars * Updates icons --- assets/components.d.ts | 4 ++ assets/components/LogViewer/LogLevel.vue | 8 ++-- assets/components/SideMenu.vue | 52 ++++++++++++++++-------- assets/models/Container.ts | 7 ++-- assets/pages/index.vue | 6 ++- assets/stores/container.ts | 13 +++++- assets/styles.scss | 7 ++++ assets/types/Container.d.ts | 2 + docker/client.go | 11 +++++ docker/types.go | 1 + web/events.go | 18 ++++++++ 11 files changed, 101 insertions(+), 28 deletions(-) diff --git a/assets/components.d.ts b/assets/components.d.ts index 82c7362d..1ed115b9 100644 --- a/assets/components.d.ts +++ b/assets/components.d.ts @@ -10,6 +10,10 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { CarbonCaretDown: typeof import('~icons/carbon/caret-down')['default'] + 'Cil:checkAlt': typeof import('~icons/cil/check-alt')['default'] + 'Cil:checkCircle': typeof import('~icons/cil/check-circle')['default'] + 'Cil:columns': typeof import('~icons/cil/columns')['default'] + CilCheckAlt: typeof import('~icons/cil/check-alt')['default'] CilColumns: typeof import('~icons/cil/columns')['default'] CilFindInPage: typeof import('~icons/cil/find-in-page')['default'] ComplexLogItem: typeof import('./components/LogViewer/ComplexLogItem.vue')['default'] diff --git a/assets/components/LogViewer/LogLevel.vue b/assets/components/LogViewer/LogLevel.vue index f15d9f81..f96ebc3b 100644 --- a/assets/components/LogViewer/LogLevel.vue +++ b/assets/components/LogViewer/LogLevel.vue @@ -43,20 +43,20 @@ div { &.debug, &.trace { - background-color: #9c27b0; + background-color: var(--purple-color); } &.info { - background-color: #00b5ad; + background-color: var(--green-color); } &.error, &.fatal { - background-color: #f44336; + background-color: var(--red-color); } &.warn { - background-color: #ff9800; + background-color: var(--orange-color); } } diff --git a/assets/components/SideMenu.vue b/assets/components/SideMenu.vue index b923f5a2..f068ff6f 100644 --- a/assets/components/SideMenu.vue +++ b/assets/components/SideMenu.vue @@ -66,14 +66,18 @@
{{ item.name }}
-
+
- + + + + +
@@ -115,6 +119,12 @@ aside { } } +.logo { + width: 122px; + height: 54px; + fill: var(--logo-color); +} + .loading { opacity: 0.5; } @@ -123,27 +133,33 @@ li.exited a { color: #777; } -.logo { - width: 122px; - height: 54px; - fill: var(--logo-color); -} - -.menu-list li { - .column-icon { - visibility: hidden; - - & > span { - vertical-align: middle; - } +.health { + &[health="unhealthy"] { + color: var(--red-color); } - &:hover .column-icon { - visibility: visible; + &[health="healthy"] { + color: var(--green-color); + } +} + +a { + .pin { + display: none; &:hover { color: var(--secondary-color); } } + + &:hover { + .pin { + display: block; + } + + .health { + display: none; + } + } } diff --git a/assets/models/Container.ts b/assets/models/Container.ts index 0007b65a..865400f3 100644 --- a/assets/models/Container.ts +++ b/assets/models/Container.ts @@ -1,4 +1,4 @@ -import type { ContainerStat, ContainerState } from "@/types/Container"; +import type { ContainerHealth, ContainerStat, ContainerState } from "@/types/Container"; import type { UseThrottledRefHistoryReturn } from "@vueuse/core"; import { Ref } from "vue"; @@ -10,12 +10,13 @@ export class Container { constructor( public readonly id: string, - public readonly created: number, + public readonly created: Date, public readonly image: string, public readonly name: string, public readonly command: string, public status: string, - public state: ContainerState + public state: ContainerState, + public health?: ContainerHealth ) { this.stat = ref({ cpu: 0, memory: 0, memoryUsage: 0 }); this.throttledStatHistory = useThrottledRefHistory(this.stat, { capacity: 300, deep: true, throttle: 1000 }); diff --git a/assets/pages/index.vue b/assets/pages/index.vue index a22f7798..f0480a41 100644 --- a/assets/pages/index.vue +++ b/assets/pages/index.vue @@ -65,7 +65,7 @@ {{ item.name }}
- +
@@ -147,17 +147,21 @@ function onEnter() {