Skip to content

Commit

Permalink
feat: add iframe visibility settings via brevia_app.public_iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanorosanelli committed Nov 22, 2024
1 parent f0a6ce4 commit bcb8c5d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions components/Form/ChatbotAdvanced.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@
</div>
</Transition>

<!--UI-->
<div class="flex border-b-4 border-primary hover:cursor-pointer" @click="openCloseSection('UI')">
<p class="mx-auto font-bold uppercase text-xl">UI</p>
<Icon :name="uiVisible ? 'material-symbols:keyboard-arrow-up' : 'material-symbols:keyboard-arrow-down'" size="32" />
</div>
<Transition name="section-fade">
<div v-if="uiVisible" class="space-y-4">
<div>
Brevia App
<JsonEditorVue v-model="breviaAppOptions" :mode="Mode.text" />
</div>
</div>
</Transition>

<div v-if="error" class="p-3 bg-neutral-100 text-center font-semibold text-brand_primary">
{{ $t('AN_ERROR_OCCURRED_PLEASE_RETRY') }}
</div>
Expand Down Expand Up @@ -150,6 +164,9 @@ const docMetadata = ref(collection.cmetadata.documents_metadata);
const docDefaults = ref(collection.cmetadata.metadata_defaults);
const upldOptions = ref(collection.cmetadata.file_upload_options);
const lnkLdOptions = ref(collection.cmetadata.link_load_options);
// Brevia App
const uiVisible = ref(true);
const breviaAppOptions = ref(collection.cmetadata.brevia_app);
const integration = useIntegration();
Expand Down Expand Up @@ -196,6 +213,8 @@ const updateMetadataItems = () => {
handleJsonMeta('metadata_defaults', docDefaults.value);
handleJsonMeta('file_upload_options', upldOptions.value);
handleJsonMeta('link_load_options', lnkLdOptions.value);
// UI
handleJsonMeta('brevia_app', breviaAppOptions.value);
};
const handleIntMeta = (name: string, value: any) => {
Expand Down
9 changes: 8 additions & 1 deletion pages/chatbot-iframe/[uuid].vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ onBeforeMount(async () => {
const data = await $fetch(`/api/brevia/collections?uuid=${uuid}`);
collection.value = data;
if (!collection.value?.uuid) {
if (!checkChatbotAvailable()) {
throw createError({
statusCode: 404,
message: 'not found',
Expand All @@ -44,4 +44,11 @@ watch(isBusy, (val) => {
}, 100);
}
});
const checkChatbotAvailable = (): boolean => {
if (!collection.value?.uuid) {
return false;
}
return collection.value.cmetadata?.brevia_app?.public_iframe || false;
};
</script>

0 comments on commit bcb8c5d

Please sign in to comment.