Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
Frank Jogeleit committed Jan 4, 2024
1 parent 5878d37 commit 1f6866c
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 20 deletions.
8 changes: 8 additions & 0 deletions frontend/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ import { cluster } from "~/modules/core/api";
.no-scrollbar {
overflow: hidden!important;
}
.v-theme--dark .v-data-table-footer {
border-top: 1px solid rgba(255, 255, 255, 0.12)
}
.v-theme--light .v-data-table-footer {
border-top: 1px solid #E1DCDF;
}
</style>
Binary file modified frontend/bun.lockb
Binary file not shown.
24 changes: 11 additions & 13 deletions frontend/components/PageLayout.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<template>
<v-container fluid class="py-4 px-4 main-height">
<v-row>
<v-col>
<v-card>
<v-toolbar color="header" elevation="2">
<v-toolbar-title v-if="title">{{ title }}</v-toolbar-title>
<template #append>
<FormKindAutocomplete style="min-width: 300px; max-width: 100%; margin-right: 15px;" v-model="kinds" :source="source" />
<FormClusterKindAutocomplete v-if="!nsScoped" style="min-width: 300px;" v-model="clusterKinds" :source="source" />
</template>
</v-toolbar>
</v-card>
</v-col>
</v-row>
<app-row>
<v-card>
<v-toolbar color="header" elevation="2">
<v-toolbar-title v-if="title">{{ title }}</v-toolbar-title>
<template #append>
<FormKindAutocomplete style="min-width: 300px; max-width: 100%; margin-right: 15px;" v-model="kinds" :source="source" />
<FormClusterKindAutocomplete v-if="!nsScoped" style="min-width: 300px;" v-model="clusterKinds" :source="source" />
</template>
</v-toolbar>
</v-card>
</app-row>
<slot />
</v-container>
</template>
Expand Down
4 changes: 4 additions & 0 deletions frontend/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<v-list-item :title="item.title" :to="item.path" :exact="item.exact"></v-list-item>
</template>
<v-divider class="mb-1" />
<template v-if="layout.customBoards">
<v-list-subheader>Custom Boards</v-list-subheader>
</template>
<template v-for="item in layout.customBoards" :key="item.title">
<v-list-item :title="item.title" :to="item.path" :exact="item.exact"></v-list-item>
</template>
Expand Down Expand Up @@ -77,5 +80,6 @@ const bg = computed(() => {
const navigation = [
{ title: 'Dashboard', path: '/', exact: true },
{ title: 'Policies', path: '/policies', exact: true },
{ title: 'Notification Targets', path: '/targets', exact: true },
];
</script>
4 changes: 2 additions & 2 deletions frontend/modules/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export class CoreAPI {
}

targets () {
return $fetch<Target[]>('/proxy/'+this.cluster+'/core/v1/targets', { baseURL: this.baseURL })
return $fetch<{ [type: string]: Target[] }>(`/proxy/${this.cluster}/core/v2/targets`, { baseURL: this.baseURL })
}

namespaces (filter?: Filter) {
return $fetch<string[]>('/proxy/'+this.cluster+'/core/v1/namespaces', { baseURL: this.baseURL, params: { ...filter } })
return $fetch<string[]>(`/proxy/${this.cluster}/core/v1/namespaces`, { baseURL: this.baseURL, params: { ...filter } })
}

namespacedKinds (source?: string) {
Expand Down
1 change: 1 addition & 0 deletions frontend/modules/core/components/ResultChip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ const icons = {
[Status.WARN]: 'alert',
[Status.FAIL]: 'alert-circle',
[Status.ERROR]: 'close',
[Status.SKIP]: 'slash-forward',
}
</script>
14 changes: 14 additions & 0 deletions frontend/modules/core/components/chip/Priority.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<v-chip :color="color" v-bind="$attrs">
<template v-if="prefix">{{ prefix }}&nbsp;</template>{{ priority ? priority : Priority.DEBUG }}
</v-chip>
</template>

<script lang="ts" setup>
import { Priority } from "~/modules/core/types";
import { mapPriority } from "~/modules/core/mapper";
const props = defineProps<{ priority?: Priority; prefix?: string; }>()
const color = mapPriority(props.priority)
</script>
3 changes: 2 additions & 1 deletion frontend/modules/core/components/resource/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</v-list-item-title>
<v-list-item-subtitle>{{ item.apiVersion }} {{ item.kind }}</v-list-item-subtitle>
<template v-slot:append>
<ResultChip :status="Status.PASS" :count="item.pass" tooltip="pass results" />
<ResultChip v-if="!!item.skip" :status="Status.SKIP" :count="item.skip" tooltip="skip results" />
<ResultChip class="ml-2" :status="Status.PASS" :count="item.pass" tooltip="pass results" />
<ResultChip class="ml-2" :status="Status.WARN" :count="item.warn" tooltip="warning results" />
<ResultChip class="ml-2" :status="Status.FAIL" :count="item.fail" tooltip="fail results" />
<ResultChip class="ml-2" :status="Status.ERROR" :count="item.error" tooltip="error results" />
Expand Down
4 changes: 2 additions & 2 deletions frontend/modules/core/components/resource/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<td :colspan="columns.length" class="py-3">
<div v-if="item.hasProps">
<v-card v-if="item.message" variant="flat">
<v-alert type="info" variant="flat">
<v-alert type="info" variant="flat" class="text-pre">
{{ item.message }}
</v-alert>
</v-card>
Expand All @@ -46,7 +46,7 @@
</template>
</div>
</div>
<div v-else>
<div class="text-pre" v-else>
{{ item.message }}
</div>
</td>
Expand Down
76 changes: 76 additions & 0 deletions frontend/modules/core/components/target/Group.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

<template>
<v-card>
<v-toolbar color="category">
<v-toolbar-title>{{ capilize(type) }}</v-toolbar-title>
<template #append>
<CollapseBtn v-model="open" />
</template>
</v-toolbar>
<template v-if="open" v-for="target in targets" :key="target.name">
<v-toolbar color="secondary">
<v-toolbar-title>{{ target.name }}</v-toolbar-title>
<template #append>
<chip-priority :priority="target.minimumPriority" variant="flat" />
</template>
</v-toolbar>
<v-divider />
<v-list class="mt-0 pt-0" lines="two">
<v-list-item v-if="target.host" :title="target.host" subtitle="Host" />
<template v-if="target.useTLS">
<v-divider />
<v-list-item title="TLS configured" />
</template>
<template v-if="target.auth">
<v-divider />
<v-list-item title="Uses Authentication" subtitle="Auth method like HTTP Basic, Authorized Header or API Key configured." />
</template>
<template v-if="target.skipTLS">
<v-divider />
<v-list-item title="Skips TLS verification" subtitle="SkipTLS enabled" />
</template>
<template v-for="(v, k) in target.properties">
<v-divider />
<v-list-item :title="v" :subtitle="capilize(k)" />
</template>
<template v-if="target.secretRef">
<v-divider />
<v-list-item :title="`SecretRef: ${target.secretRef}`" subtitle="Secret used to retrieve sensitive target configuration" />
</template>
<template v-if="target.mountedSecret">
<v-divider />
<v-list-item :title="`MountedSecret: ${target.mountedSecret}`" subtitle="Secret mount used to retrieve sensitive target configuration" />
</template>
</v-list>
<template v-if="target.filter && Object.keys(target.filter).length > 0">
<v-divider />
<v-table hover>
<thead>
<tr>
<th>Filter</th>
<th>Included Values</th>
<th>Excluded Values</th>
</tr>
</thead>
<tbody>
<tr v-for="(values, filter) in target.filter">
<td>{{ filter }}</td>
<td>{{ values?.include?.join(', ') }}</td>
<td>{{ values?.exclude?.join(', ') }}</td>
</tr>
</tbody>
</v-table>
</template>
</template>
</v-card>
</template>

<script setup lang="ts">
import { capilize } from "~/modules/core/layouthHelper";
import { type Target } from "~/modules/core/types";
import CollapseBtn from "~/components/CollapseBtn.vue";
defineProps<{ type: string; targets: Target[]; }>()
const open = ref(true)
</script>
17 changes: 15 additions & 2 deletions frontend/modules/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,22 @@ export type ListResult = {

export type Target = {
name: string;
host?: string;
skipTLS?: boolean;
useTLS?: boolean;
auth?: boolean;
mountedSecret?: boolean;
secretRef?: boolean;
minimumPriority: Priority;
sources?: string[];
skipExistingOnStartup: boolean;
filter: {
namespaces?: { include: string[]; exclude: string[]; }
priorities?: { include: string[]; exclude: string[]; }
reportLabels?: { include: string[]; exclude: string[]; }
policies?: { include: string[]; exclude: string[]; }
sources?: { include: string[]; exclude: string[]; }
};
customFields: { [key: string]: string; }
properties: { [key: string]: any; }
}

export type StatusCount = {
Expand Down
18 changes: 18 additions & 0 deletions frontend/pages/targets/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<v-container fluid class="py-4 px-4 main-height" v-if="targets">
<app-row>
<v-card>
<v-toolbar color="header" elevation="2">
<v-toolbar-title>Configured Notification Targets</v-toolbar-title>
</v-toolbar>
</v-card>
</app-row>
<app-row v-for="(list, type) in targets" :key="type">
<target-group :type="type" :targets="list" />
</app-row>
</v-container>
</template>

<script setup lang="ts">
const { data: targets } = useAPI((api) => api.targets())
</script>

0 comments on commit 1f6866c

Please sign in to comment.