Skip to content

Commit

Permalink
dependency updates
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
Frank Jogeleit committed Feb 18, 2024
1 parent baee5e6 commit a0a57c9
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 31 deletions.
19 changes: 17 additions & 2 deletions backend/pkg/server/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,25 @@ func (h *Handler) GetCustomBoard(ctx *gin.Context) {
namespaces = config.Namespaces.List
}

if len(namespaces) > 0 {
query["namespaces"] = namespaces
if len(namespaces) == 0 {
ctx.JSON(http.StatusOK, service.Dashboard{
Title: config.Name,
ClusterScope: config.ClusterScope,
Sources: sources,
SingleSource: len(sources) == 1,
MultipleSource: len(sources) > 1,
Namespaces: make([]string, 0),
Charts: service.Charts{
ClusterScope: make(map[string]map[string]int),
NamespaceScope: make(map[string]*service.Chart),
Findings: &service.Chart{},
},
})
return
}

query["namespaces"] = namespaces

dashboard, err := h.service.Dashboard(ctx, ctx.Param("cluster"), sources, namespaces, config.ClusterScope, query)
if err != nil {
zap.L().Error("failed to generate dashboard", zap.Error(err))
Expand Down
4 changes: 4 additions & 0 deletions backend/pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ func (s *Service) Dashboard(ctx context.Context, cluster string, sources []strin
findingChart = MapFindingsToSourceStatusChart(sources[0], findings)
}

if namespaces == nil {
namespaces = make([]string, 0)
}

return &Dashboard{
FilterSources: make([]string, 0),
ClusterScope: clusterScope,
Expand Down
4 changes: 2 additions & 2 deletions charts/ui/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: ui
description: Policy Reporter UI
type: application
version: 0.0.20
appVersion: "2.0.0-alpha.14"
version: 0.0.21
appVersion: "2.0.0-alpha.15"

icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
home: https://kyverno.github.io/policy-reporter-ui
Expand Down
Binary file modified frontend/bun.lockb
Binary file not shown.
7 changes: 3 additions & 4 deletions frontend/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<template #append>
<form-cluster-select />
<form-display-mode-select style="width: 150px;" />
<user-menu class="ml-4" />
<user-menu />
</template>
</v-app-bar>

Expand Down Expand Up @@ -80,12 +80,11 @@
<script setup lang="ts">
import { useTheme } from "vuetify";
import type { LayoutConfig } from "~/modules/core/types";
import {use} from "h3";
import {useConfigStore} from "~/store/config";
import { useConfigStore } from "~/store/config";
const drawer = ref(true)
const { data: layout } = useAPI((api) => api.layout(), { default: (): LayoutConfig => ({ sources: [], customBoards: [], policies: [] }) })
const { data: layout } = useAPI((api) => api.layout(), { default: (): LayoutConfig => ({ sources: [], customBoards: [], policies: [], targets: false }) })
const theme = useTheme()
Expand Down
4 changes: 2 additions & 2 deletions frontend/modules/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export class CoreAPI {
return exec<LayoutConfig>(`/api/config/${this.cluster}/layout`, { baseURL: this.baseURL })
}

dashboard <T extends Boolean>(filter?: Filter) {
dashboard <T extends boolean>(filter?: Filter) {
return exec<Dashboard<T>>(`/api/config/${this.cluster}/dashboard`, { baseURL: this.baseURL, params: applyExcludes(filter, [...this.nsExcludes, ...this.clusterExcludes]) })
}

customBoard <T extends Boolean>(id: string, filter?: Filter) {
customBoard <T extends boolean>(id: string, filter?: Filter) {
return exec<Dashboard<T>>(`/api/config/${this.cluster}/custom-board/${id}`, { baseURL: this.baseURL, params: applyExcludes(filter, [...this.nsExcludes, ...this.clusterExcludes]) })
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/modules/core/components/UserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
<script setup lang="ts">
const logout = () => {
document.cookie.split(";").forEach((c) => { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
// @ts-ignore
window.location = '/logout'
}
const { data: profile } = useAPI(api => api.profile(), { default: () => ({ name: 'Frank Jogeleit' } )})
const { data: profile } = useAPI(api => api.profile(), { default: () => ({ name: 'Frank Jogeleit', id: undefined } )})
</script>
2 changes: 1 addition & 1 deletion frontend/modules/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export type NamespaceScope = {

export type Findings = Chart

export type Dashboard<T extends Boolean> = {
export type Dashboard<T extends boolean> = {
title?: string;
clusterScope: boolean;
filterSources: string[];
Expand Down
9 changes: 8 additions & 1 deletion frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import vuetify from "vite-plugin-vuetify";
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
import { join } from 'node:path'

export default defineNuxtConfig({
Expand Down Expand Up @@ -31,6 +31,13 @@ export default defineNuxtConfig({
publicDir: join(__dirname, 'dist')
}
},
vite: {
vue: {
template: {
transformAssetUrls,
},
},
},
app: {
head: {
title: 'Policy Reporter UI',
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"@nuxt/devtools": "latest",
"@types/chroma-js": "^2.4.3",
"@types/lodash.debounce": "^4.0.9",
"nuxt": "^3.10.1",
"nuxt": "^3.10.2",
"sass": "^1.69.5",
"vite-plugin-vuetify": "^1.0.2",
"vite-plugin-vuetify": "^2.0.1",
"vue": "^3.3.8",
"vue-router": "^4.2.5"
},
Expand Down
41 changes: 25 additions & 16 deletions frontend/pages/custom-boards/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@
:title="data.title"
v-if="data"
>
<GraphSourceStatus v-if="data.singleSource" :data="data" :source="data.sources[0]" />
<GraphSourcesStatus v-else :data="data" :hide-cluster="!data.clusterScope" />
<v-row v-if="data.clusterScope">
<v-col>
<resource-cluster-list :details="data.multiSource" />
</v-col>
</v-row>
<resource-namespace-section v-if="data.namespaces.length" :namespaces="data.namespaces">
<template #default="{ namespaces }">
<resource-scroller :list="namespaces" :default-loadings="3">
<template #default="{ item }">
<resource-list :namespace="item" :details="data.multiSource" />
</template>
</resource-scroller>
</template>
</resource-namespace-section>
<template v-if="data.namespaces.length">
<GraphSourceStatus v-if="data.singleSource" :data="data" :source="data.sources[0]" />
<GraphSourcesStatus v-else :data="data" :hide-cluster="!data.clusterScope" />
<v-row v-if="data.clusterScope">
<v-col>
<resource-cluster-list :details="data.multiSource" />
</v-col>
</v-row>
<resource-namespace-section v-if="data.namespaces.length" :namespaces="data.namespaces">
<template #default="{ namespaces }">
<resource-scroller :list="namespaces" :default-loadings="3">
<template #default="{ item }">
<resource-list :namespace="item" :details="data.multiSource" />
</template>
</resource-scroller>
</template>
</resource-namespace-section>
</template>
<v-card class="mt-4" v-else>
<v-card-text>
<v-alert variant="outlined" type="error">
No configured namespaces are found
</v-alert>
</v-card-text>
</v-card>
</page-layout>
</template>

Expand Down
1 change: 1 addition & 0 deletions frontend/plugins/02.vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import { md3 } from 'vuetify/blueprints'
import { useConfigStore } from "~/store/config";
import 'vuetify/styles'

export default defineNuxtPlugin((nuxtApp) => {
const config = useConfigStore()
Expand Down

0 comments on commit a0a57c9

Please sign in to comment.