Skip to content

Commit

Permalink
Update UI
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
  • Loading branch information
Frank Jogeleit committed Feb 7, 2024
1 parent d88bb06 commit 46b8dc9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
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.15
appVersion: "2.0.0-alpha.10"
version: 0.0.16
appVersion: "2.0.0-alpha.11"

icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
home: https://kyverno.github.io/policy-reporter-ui
Expand Down
14 changes: 13 additions & 1 deletion frontend/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,33 @@
</v-navigation-drawer>

<v-main :class="bg">
<slot />
<v-container fluid v-if="config.error">
<app-row>
<v-card class="pa-2">
<v-alert variant="outlined" type="error">Failed to access API: {{ config.error }}</v-alert>
</v-card>
</app-row>
</v-container>

<slot v-else />
</v-main>
</v-layout>
</template>

<script setup lang="ts">
import { useTheme } from "vuetify";
import type { LayoutConfig } from "~/modules/core/types";
import {use} from "h3";
import {useConfigStore} from "~/store/config";
const drawer = ref(true)
const { data: layout } = useAPI((api) => api.layout(), { default: (): LayoutConfig => ({ sources: [], customBoards: [], policies: [] }) })
const theme = useTheme()
const config = useConfigStore()
const bg = computed(() => {
if (theme.current.value.dark) {
return 'bg-grey-darken-3'
Expand Down
22 changes: 18 additions & 4 deletions frontend/modules/core/plugins/apis.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import { defineNuxtPlugin } from 'nuxt/app'
import { create } from '~/modules/core/api'
import { useConfigStore } from "~/store/config";
import {defineNuxtPlugin} from 'nuxt/app'
import {create} from '~/modules/core/api'
import {useConfigStore} from "~/store/config";
import {type Config, DisplayMode} from "~/modules/core/types";

export default defineNuxtPlugin(async () => {
const config = useRuntimeConfig()
const api = create({ baseURL: config.public.coreApi as string, prefix: '' })

const apiConfig = await api.config()
const apiConfig = await api.config().catch((error): Config => {
console.error(`failed to load config: ${error}`)

return {
error,
displayMode: DisplayMode.UNSPECIFIED,
default: 'default',
sources: [],
plugins: [],
defaultFilter: { resources: [], clusterResources: [] },
clusters: [{ name: 'Default', slug: 'default', plugins: [] }],
oauth: false,
}
})

api.setPrefix(apiConfig.default)

Expand Down
2 changes: 1 addition & 1 deletion frontend/modules/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ export type PolicyDetails = {
}

export type Config = {
error?: Error;
plugins: string[];
displayMode: DisplayMode;
views: ViewsCofig;
clusters: Cluster[];
sources: SourceConfig[];
oauth: boolean;
Expand Down
2 changes: 2 additions & 0 deletions frontend/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type State = {
plugins: string[];
clusters: Cluster[];
oauth: boolean;
error?: Error;
}

export const useConfigStore = defineStore('config', {
Expand All @@ -32,6 +33,7 @@ export const useConfigStore = defineStore('config', {
},
actions: {
setConfig(config: Config) {
this.error = config.error
this.clusters = config.clusters
this.oauth = config.oauth
},
Expand Down

0 comments on commit 46b8dc9

Please sign in to comment.