From 85eff4cecffa0499a8458b89669467b8ff259d8f Mon Sep 17 00:00:00 2001 From: Kuchuk Andrey Date: Tue, 22 Aug 2023 22:42:48 +0400 Subject: [PATCH 1/4] [#19] add version request to sidebar --- .env.sample | 4 ++-- components/LayoutSidebar/LayoutSidebar.vue | 26 +++++++++++++++++++++- plugins/api.client.ts | 22 ++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 plugins/api.client.ts diff --git a/.env.sample b/.env.sample index 234f37fa..892278b1 100644 --- a/.env.sample +++ b/.env.sample @@ -1,2 +1,2 @@ -VITE_EVENTS_REST_API=https://test.buggregator.dev/ -VITE_EVENTS_WS_API=wss://test.buggregator.dev/connection/websocket \ No newline at end of file +VITE_EVENTS_REST_API=https://test.buggregator.dev +VITE_EVENTS_WS_API=wss://test.buggregator.dev/connection/websocket diff --git a/components/LayoutSidebar/LayoutSidebar.vue b/components/LayoutSidebar/LayoutSidebar.vue index 787e03cf..7a0a0067 100644 --- a/components/LayoutSidebar/LayoutSidebar.vue +++ b/components/LayoutSidebar/LayoutSidebar.vue @@ -17,7 +17,11 @@ - + @@ -33,12 +37,17 @@ + +
+ {{ appVersion }} +
diff --git a/plugins/api.client.ts b/plugins/api.client.ts new file mode 100644 index 00000000..8be69ae1 --- /dev/null +++ b/plugins/api.client.ts @@ -0,0 +1,22 @@ +import { REST_API_URL } from "~/utils/events-transport"; + +export default defineNuxtPlugin(() => { + const getAppVersion = () => fetch(`${REST_API_URL}/api/version`) + .then((response) => response.json()) + .then((response) => { + if (response?.data) { + return response.data + } + + return 'unknown' + }) + .catch(() => 'unknown'); + + return { + provide: { + api: { + getVersion: getAppVersion, + } + } + } +}) From bd492e9d0f192e5d8c321c8b421bfb8ad28b6af9 Mon Sep 17 00:00:00 2001 From: Kuchuk Andrey Date: Tue, 22 Aug 2023 22:53:37 +0400 Subject: [PATCH 2/4] [#19] update version styles --- components/LayoutSidebar/LayoutSidebar.vue | 28 +++++++++++++--------- nuxt.config.ts | 7 ++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/components/LayoutSidebar/LayoutSidebar.vue b/components/LayoutSidebar/LayoutSidebar.vue index 7a0a0067..962cf218 100644 --- a/components/LayoutSidebar/LayoutSidebar.vue +++ b/components/LayoutSidebar/LayoutSidebar.vue @@ -36,11 +36,11 @@ - -
- {{ appVersion }} -
+
+ {{ appVersion }} +
+ @@ -48,6 +48,7 @@ import IconSvg from "~/components/IconSvg/IconSvg.vue"; import { defineComponent } from "vue"; import { useNuxtApp } from "#app"; +import { EVENT_TYPES } from "~/config/constants"; export default defineComponent({ components: { IconSvg }, @@ -57,19 +58,20 @@ export default defineComponent({ required: true, }, }, - async setup() { + setup() { if (process.client) { - const { $api } = useNuxtApp(); - - const appVersion = await $api.getVersion(); + const { $config } = useNuxtApp(); return { - appVersion, + appVersion: + !$config?.version || $config.version === "0.0.1" + ? "@dev" + : `v${$config.version}`, }; } return { - appVersion: null, + appVersion: "@dev", }; }, }); @@ -81,7 +83,7 @@ export default defineComponent({ } .layout-sidebar__nav { - @apply divide-y divide-gray-300 dark:divide-gray-600 sticky top-0; + @apply divide-y divide-gray-300 dark:divide-gray-600 sticky top-0 h-screen max-h-screen; } .layout-sidebar__link { @@ -92,6 +94,10 @@ export default defineComponent({ } } +.layout-sidebar__nav-version { + @apply flex justify-center text-xs dark:text-gray-400 p-2 absolute bottom-0 left-0 right-0; +} + .layout-sidebar__link-icon { @apply fill-current; } diff --git a/nuxt.config.ts b/nuxt.config.ts index 2e0457e0..8e7272c2 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,4 +1,6 @@ import {defineNuxtConfig} from "nuxt/config"; +import pkg from './package.json'; + // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ target: 'static', @@ -55,4 +57,9 @@ export default defineNuxtConfig({ host: '127.0.0.1', url: 'http://127.0.0.1:3000', }, + runtimeConfig: { + public: { + version: pkg.version, + } + } }); From c2358a2d02dbff49697aebddc4568e3f33d56879 Mon Sep 17 00:00:00 2001 From: Kuchuk Andrey Date: Sat, 16 Sep 2023 12:18:44 +0400 Subject: [PATCH 3/4] [#19] remove unnecessary plugin --- plugins/api.client.ts | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 plugins/api.client.ts diff --git a/plugins/api.client.ts b/plugins/api.client.ts deleted file mode 100644 index 8be69ae1..00000000 --- a/plugins/api.client.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { REST_API_URL } from "~/utils/events-transport"; - -export default defineNuxtPlugin(() => { - const getAppVersion = () => fetch(`${REST_API_URL}/api/version`) - .then((response) => response.json()) - .then((response) => { - if (response?.data) { - return response.data - } - - return 'unknown' - }) - .catch(() => 'unknown'); - - return { - provide: { - api: { - getVersion: getAppVersion, - } - } - } -}) From 68717b2c9024a5a12b391bc7ceb324a775e57a8e Mon Sep 17 00:00:00 2001 From: Kuchuk Andrey Date: Sat, 16 Sep 2023 12:26:18 +0400 Subject: [PATCH 4/4] [#19] remove unnused import --- components/LayoutSidebar/LayoutSidebar.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/components/LayoutSidebar/LayoutSidebar.vue b/components/LayoutSidebar/LayoutSidebar.vue index 962cf218..c474519e 100644 --- a/components/LayoutSidebar/LayoutSidebar.vue +++ b/components/LayoutSidebar/LayoutSidebar.vue @@ -48,7 +48,6 @@ import IconSvg from "~/components/IconSvg/IconSvg.vue"; import { defineComponent } from "vue"; import { useNuxtApp } from "#app"; -import { EVENT_TYPES } from "~/config/constants"; export default defineComponent({ components: { IconSvg },