Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): 411 overview dashboard core services #471

Merged
merged 33 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e1019b8
feat(ui): adding UI widget with mock data
BillyFigueroa Oct 11, 2024
7a926db
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 17, 2024
b20a43c
feat: adding api call and data for services
BillyFigueroa Oct 18, 2024
d9b75a9
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 18, 2024
882357a
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 18, 2024
e089c98
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 18, 2024
62d5e54
refactor: updating core services widget empty logic
BillyFigueroa Oct 18, 2024
fb44fcc
fix: fixing test
BillyFigueroa Oct 18, 2024
a111887
fix: updating green color
BillyFigueroa Oct 18, 2024
1c802c6
fix: updating reactivity for component
BillyFigueroa Oct 18, 2024
d40e939
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 18, 2024
ca5849d
refactor: changing widget to be full width
BillyFigueroa Oct 21, 2024
8e97cb8
refactor: using diff sort function
BillyFigueroa Oct 21, 2024
8daa8f4
feat: adding sorting
BillyFigueroa Oct 21, 2024
a7d16d5
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 21, 2024
806957d
feat: adding pod to check for pepr service
BillyFigueroa Oct 22, 2024
cca56f2
fix: typo
BillyFigueroa Oct 22, 2024
b1b31bf
fix: updating services var to core services
BillyFigueroa Oct 22, 2024
c878705
fix: removing unused css
BillyFigueroa Oct 22, 2024
a2365d0
fix: adding description to resource information icon
BillyFigueroa Oct 22, 2024
590f211
fix: updating logic and adding comment to explain logic
BillyFigueroa Oct 22, 2024
e136873
refactor: adding server status color
BillyFigueroa Oct 22, 2024
22e4e67
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 22, 2024
09ea0ea
fix: re-adding comment
BillyFigueroa Oct 22, 2024
5b231b5
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 22, 2024
ecc271e
Merge branch 'main' into 411-overview-dashboard-core-services
BillyFigueroa Oct 24, 2024
f381245
adding check for istio (Service Mesh)
BillyFigueroa Oct 24, 2024
fcf7db2
Updating logic for checking for service mesh
BillyFigueroa Oct 24, 2024
6b4766f
Merging main
BillyFigueroa Oct 24, 2024
7ff5e0f
Fixing error for no crd found
BillyFigueroa Oct 25, 2024
5856318
Fixing formatting error
BillyFigueroa Oct 25, 2024
a138a56
fixes
TristanHoladay Oct 25, 2024
2bd460b
Merge branch 'main' into 411-overview-dashboard-core-services
decleaver Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions ui/src/lib/components/CoreServicesWidget/component.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<script lang="ts">
import { type CoreServiceType } from '$lib/types'
import { Cube, Information } from 'carbon-icons-svelte'

export let services: CoreServiceType[] = []
export let sortedCoreServices: CoreServiceType[] = []

const coreServicesMapping: Record<string, string> = {
authservice: 'Authservice',
grafana: 'Grafana',
keycloak: 'KeyCloak',
loki: 'Loki',
'metrics-server': 'Metrics Server',
neuvector: 'Neuvector',
'prometheus-stack': 'Prometheus Stack',
vector: 'Vector',
velero: 'Velero',
'uds-runtime': 'UDS Runtime',
}

const coreServiceKeys = Object.keys(coreServicesMapping)

let hasNoCoreServices: boolean = false
$: hasNoCoreServices = services.every((service) => !coreServiceKeys.includes(service.metadata.name))

const sortServices = (a: CoreServiceType, b: CoreServiceType) => {
if (a.metadata.name < b.metadata.name) {
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
return -1
}

if (a.metadata.name > b.metadata.name) {
return 1
}

return 0
}

$: {
sortedCoreServices = services
.filter((service) => coreServiceKeys.includes(service.metadata.name))
.sort(sortServices)
}
</script>

<div class="core-services">
<div class="core-services__header">
<h2 class="core-services__header-title">Core Services</h2>

<Information class="ml-2 w-4 h-4 dark:text-gray-400 text-blue-500" />
BillyFigueroa marked this conversation as resolved.
Show resolved Hide resolved
</div>

{#if hasNoCoreServices}
<span class="flex self-center">No Core Services running</span>
{:else}
<div class="core-services__rows">
{#each sortedCoreServices as { metadata: { name } }}
<div class="core-services__rows-item">
<div class="w-10/12 flex items-center space-x-2">
<div class="core-services__name-icon">
<Cube size={16} class="text-gray-400" />
</div>

<div class="truncate">{coreServicesMapping[name]}</div>
</div>

<div class="w-2/12 text-green-400">Running</div>
BillyFigueroa marked this conversation as resolved.
Show resolved Hide resolved
</div>
{/each}
</div>
{/if}
</div>

<style lang="postcss">
UncleGedd marked this conversation as resolved.
Show resolved Hide resolved
.core-services {
@apply px-6 pb-6 w-full rounded-md dark:bg-gray-800 flex flex-col;
}

.core-services__header {
@apply flex items-center h-14;
}

.core-services__header-title {
@apply text-lg dark:text-white font-semibold;
}

.core-services__rows {
@apply flex flex-col text-sm;
}

.core-services__rows-item {
@apply flex dark:border-gray-700 items-center;
border-bottom-width: 1px;
}

.core-services__name-icon {
@apply h-7 w-7 rounded-lg bg-gray-700 flex items-center justify-center my-2;
}

.core-services__button-link {
@apply text-sm text-blue-500 dark:text-blue-400 flex items-center space-x-1;
}
</style>
1 change: 1 addition & 0 deletions ui/src/lib/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial

export { default as AnsiDisplay } from './AnsiDisplay/component.svelte'
export { default as CoreServicesWidget } from './CoreServicesWidget/component.svelte'
export { default as Card } from './k8s/Card/component.svelte'
export { default as DataTable } from './k8s/DataTable/component.svelte'
export { default as Drawer } from './k8s/Drawer/component.svelte'
Expand Down
32 changes: 27 additions & 5 deletions ui/src/lib/features/k8s/cluster-overview/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<script lang="ts">
import { onMount } from 'svelte'

import { ProgressBarWidget, WithRightIconWidget } from '$components'
import { CoreServicesWidget, ProgressBarWidget, WithRightIconWidget } from '$components'
import EventsOverviewWidget from '$components/k8s/Event/EventsOverviewWidget.svelte'
import { createStore } from '$lib/features/k8s/events/store'
import { type CoreServiceType } from '$lib/types'
import { resourceDescriptions } from '$lib/utils/descriptions'
import { Analytics, DataVis_1 } from 'carbon-icons-svelte'
import Chart from 'chart.js/auto'
Expand Down Expand Up @@ -39,11 +40,18 @@
let onMessageCount = 0
let myChart: Chart
const description = resourceDescriptions['Events']
let services: CoreServiceType[] = []
BillyFigueroa marked this conversation as resolved.
Show resolved Hide resolved

onMount(() => {
let ctx = document.getElementById('chartjs-el') as HTMLCanvasElement
const path: string = `/api/v1/monitor/cluster-overview`
const overview = new EventSource(path)
const overviewPath: string = '/api/v1/monitor/cluster-overview'
const servicesPath: string = '/api/v1/resources/configs/uds-packages?fields=.metadata.name'
const overview = new EventSource(overviewPath)
const servicesEvent = new EventSource(servicesPath)

servicesEvent.onmessage = (event) => {
services = JSON.parse(event.data) as CoreServiceType[]
}

overview.onmessage = (event) => {
clusterData = JSON.parse(event.data) as ClusterData
Expand Down Expand Up @@ -71,7 +79,7 @@
myChart = new Chart(ctx, { type: 'line', data: chartData, options: chartOptions })
}

// on each message manually update the grap
// on each message manually update the graph
myChart.data.labels = historicalUsage.map((point) => [formatTime(point.Timestamp)])
myChart.data.datasets[0].data = historicalUsage.map((point) => point.Memory / (1024 * 1024 * 1024))
myChart.data.datasets[1].data = historicalUsage.map((point) => point.CPU / 1000)
Expand All @@ -94,7 +102,7 @@
</script>

<div class="p-4 dark:text-white pt-0">
<h1 class="text-2xl font-bold mb-4">Cluster Overview</h1>
<h1 class="text-xl font-bold mb-4">Cluster Overview</h1>
<div class="grid grid-cols-1 min-[1024px]:grid-cols-2 min-[1510px]:grid-cols-4 gap-4">
<WithRightIconWidget
statText={clusterData.totalPods.toString()}
Expand Down Expand Up @@ -127,6 +135,20 @@
/>
</div>

<div class="mt-8 flex flex-col xl:flex-row xl:space-x-4">
<div class="w-full xl:w-1/2">
<div class="flex p-5 bg-gray-800 rounded-lg overflow-hidden shadow h-full items-center justify-center">
Packages Widget Coming Soon...
BillyFigueroa marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>

<div class="w-full xl:w-1/2 max-xl:mt-4">
<div class="p-5 bg-gray-800 rounded-lg overflow-hidden shadow">
<CoreServicesWidget {services} />
</div>
</div>
</div>

<div class="mt-8">
<h2 class="text-xl font-bold mb-4">Resource Usage Over Time</h2>

Expand Down
6 changes: 6 additions & 0 deletions ui/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ export type PeprEvent = {
res?: Record<string, unknown>
details?: PeprDetails | undefined
}

export type CoreServiceType = {
metadata: {
name: string
}
}
3 changes: 3 additions & 0 deletions ui/tests/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ test.describe('Navigation', async () => {
// Check for Events Widget
await expect(page.getByText('Event Logs')).toBeVisible()
await expect(page.getByText('VIEW EVENTS')).toBeVisible()

// Check for the Core Services
await expect(page.getByRole('heading', { name: 'Core Services' })).toBeVisible()
})

test('Ensure Overview page and pod page show same number of pods', async ({ page }) => {
Expand Down
Loading