Skip to content

Commit 4a1314a

Browse files
committed
feat: add prompt preview renderer
1 parent e9bc8ca commit 4a1314a

File tree

9 files changed

+141
-6
lines changed

9 files changed

+141
-6
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ dashboard_setup:
2828
dashboard_protoc: dashboard_setup
2929
pnpm run -C dashboard protoc
3030

31-
dashboard_build: dashboard_protoc
31+
dashboard_build: lib_build dashboard_protoc
3232
pnpm run -C dashboard build
3333

34-
dashboard: cleanup docker_network oidc-server-mock postgres_database postgres_backend dashboard_protoc
34+
dashboard: cleanup docker_network oidc-server-mock postgres_database postgres_backend lib_build dashboard_protoc
3535
NUXT_PUBLIC_FEEDBACK_FUSION_ENDPOINT="http://localhost:8000" \
3636
FEEDBACK_FUSION_OIDC_PROVIDER_AUTHORIZATION_URL="http://localhost:5151/connect/authorize" \
3737
FEEDBACK_FUSION_OIDC_PROVIDER_TOKEN_URL="http://localhost:5151/connect/token" \

dashboard/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ RUN apt-get update && apt-get install -y protobuf-compiler libprotobuf-dev make
44

55
COPY ./dashboard/ ./dashboard
66
COPY ./proto ./proto
7+
COPY ./lib ./lib
78
COPY ./Makefile .
89

910
RUN make dashboard_build
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<v-expansion-panels>
3+
<v-expansion-panel :title="$t('prompt.preview')">
4+
<v-expansion-panel-text>
5+
<v-tabs bg-color="primary" v-model="tab">
6+
<v-tab value="preview">
7+
{{ $t("prompt.preview") }}
8+
</v-tab>
9+
10+
<v-tab value="code">
11+
{{ $t("prompt.code") }}
12+
</v-tab>
13+
</v-tabs>
14+
15+
<v-tabs-window v-model="tab">
16+
<v-tabs-window-item value="preview">
17+
<div class="d-flex justify-center align-center">
18+
<feedback-fusion-prompt
19+
:baseUrl="config.public.feedbackFusionEndpoint"
20+
:promptId="prompt"
21+
class="mt-4 mb-4"
22+
style="width: 500px; max-width: 95vw"
23+
/>
24+
</div>
25+
</v-tabs-window-item>
26+
27+
<v-tabs-window-item value="code">
28+
<pre>
29+
<code>
30+
&lt;feedback-fusion-prompt
31+
baseUrl="{{ config.public.feedbackFusionEndpoint }}"
32+
promptId="{{ prompt }}"
33+
class="mt-4 mb-4"
34+
style="width: 500px; max-width: 95vw"
35+
/&gt;
36+
</code>
37+
</pre>
38+
</v-tabs-window-item>
39+
</v-tabs-window>
40+
</v-expansion-panel-text>
41+
</v-expansion-panel>
42+
</v-expansion-panels>
43+
</template>
44+
45+
<script setup lang="ts">
46+
import { defineProps, useRuntimeConfig, ref } from "#imports";
47+
import "@onelitefeathernet/feedback-fusion";
48+
49+
const config = useRuntimeConfig();
50+
const tab = ref("preview");
51+
52+
const props = defineProps({
53+
prompt: String,
54+
});
55+
</script>

dashboard/i18n/locales/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
"title": "Title",
2020
"delete": "Are you sure you want to delete the prompt? This will also delete all fields and gathered data.",
2121
"description": "description",
22-
"create": "Create new prompt"
22+
"create": "Create new prompt",
23+
"active": "active",
24+
"disabled": "disabled",
25+
"preview": "Preview",
26+
"code": "Code"
2327
},
2428
"target": {
2529
"delete": "Are you sure you want to delete the target? This will also delete all prompts and gathered data.",

dashboard/nuxt.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export default defineNuxtConfig({
3030
alwaysRedirect: true,
3131
},
3232
},
33+
build: {
34+
transpile: ["@onelitefeathernet/feedback-fusion"],
35+
},
3336
oidc: {
3437
middleware: {
3538
globalMiddlewareEnabled: true,
@@ -67,6 +70,9 @@ export default defineNuxtConfig({
6770
},
6871
vuetify: {
6972
vuetifyOptions: {
73+
theme: {
74+
defaultTheme: "dark",
75+
},
7076
labComponents: true,
7177
},
7278
},

dashboard/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@nuxtjs/i18n": "^9.1.1",
16+
"@onelitefeathernet/feedback-fusion": "link:../lib",
1617
"@pinia/nuxt": "0.9.0",
1718
"@protobuf-ts/grpcweb-transport": "^2.9.4",
1819
"@protobuf-ts/plugin": "^2.9.4",
@@ -28,11 +29,13 @@
2829
},
2930
"devDependencies": {
3031
"@eslint/js": "^9.17.0",
32+
"@lit/localize": "^0.12.2",
3133
"eslint": "^9.17.0",
3234
"eslint-config-prettier": "^9.1.0",
3335
"eslint-plugin-prettier": "^5.2.1",
3436
"eslint-plugin-vue": "^9.32.0",
3537
"globals": "^15.14.0",
38+
"lit": "^3.2.1",
3639
"prettier": "^3.4.2",
3740
"protoc": "^1.1.3",
3841
"sass": "^1.83.0",

dashboard/pages/target/[target]/prompt/[prompt]/index.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
:deleteMessage="$t('prompt.delete')"
1010
>
1111
<template #title="{ instance }">
12-
{{ instance?.title }}
12+
{{ instance?.title }} -
13+
<v-chip
14+
v-if="instance?.active"
15+
color="success"
16+
:text="$t('prompt.active')"
17+
/>
18+
<v-chip v-else color="error" :text="$t('prompt.disabled')" />
1319
</template>
1420

1521
<template #subtitle="{ instance }">
@@ -22,6 +28,8 @@
2228
:target="route.params.target"
2329
:prompt="instance.id"
2430
/>
31+
32+
<PromptPreview class="mt-8" :prompt="route.params.prompt" />
2533
</template>
2634
</InstanceCard>
2735
</template>

dashboard/pnpm-lock.yaml

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"module": "dist/src/index.js",
1010
"exports": {
1111
".": {
12+
"browser": "./dist/src/index.min.js",
1213
"import": "./dist/src/index.js",
13-
"require": "./dist/src/index.js",
14-
"browser": "./dist/src/index.min.js"
14+
"require": "./dist/src/index.js"
1515
}
1616
},
1717
"scripts": {

0 commit comments

Comments
 (0)