Skip to content

Commit cdeb24c

Browse files
committed
feat: adding global setting to control file upload ability
1 parent 1727f4e commit cdeb24c

File tree

7 files changed

+31
-13
lines changed

7 files changed

+31
-13
lines changed

app/components/Chat/ChatInput.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const { width } = useWindowSize();
4848
4949
// Handle file uploads
5050
const uploadedFiles = ref<MessageFile[]>([]);
51+
const globalSettingsStore = useGlobalSettingsStore();
5152
</script>
5253

5354
<template>
@@ -113,6 +114,7 @@ const uploadedFiles = ref<MessageFile[]>([]);
113114
<ChatInputModel />
114115
<ChatInputSystemPrompt />
115116
<ChatInputFileUpload
117+
v-if="globalSettingsStore.settings.allowFileUpload"
116118
@file-uploaded="
117119
(file) => {
118120
if (uploadedFiles.map((f) => f.name).includes(file.name)) {

app/components/Settings/SettingsAdmin.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const tabs: Record<string, Tab> = {
2525
icon: "lucide:bot",
2626
path: "/settings/admin/models",
2727
},
28-
rag: {
29-
name: "rag",
30-
component: resolveComponent("SettingsAdminRAG"),
28+
files: {
29+
name: "files",
30+
component: resolveComponent("SettingsAdminFiles"),
3131
icon: "lucide:library",
32-
path: "/settings/admin/rag",
32+
path: "/settings/admin/files",
3333
},
3434
users: {
3535
name: "users",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup lang="ts">
2+
const globalSettingsStore = useGlobalSettingsStore();
3+
</script>
4+
5+
<template>
6+
<SettingsGroup title="upload" icon="lucide:file-up">
7+
<SettingsToggleItem
8+
title="allow file upload to chat"
9+
description="the whole text from uploaded files will be appeneded to their respective messages"
10+
:value="globalSettingsStore.settings.allowFileUpload"
11+
@toggle="
12+
() => {
13+
globalSettingsStore.updateSettings({
14+
allowFileUpload: !globalSettingsStore.settings.allowFileUpload,
15+
});
16+
}
17+
"
18+
/>
19+
</SettingsGroup>
20+
</template>

app/components/Settings/SettingsAdminRAG.vue

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/components/Settings/SettingsAdminUsers.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,8 @@ const globalSettingsStore = useGlobalSettingsStore();
254254
</SettingsGroup>
255255
<SettingsGroup title="allow registration" icon="lucide:lock">
256256
<SettingsToggleItem
257+
description="allow users to register themselves at /register"
257258
:value="globalSettingsStore.settings.allowRegistration"
258-
true-label="registration allowed"
259-
false-label="registration not allowed"
260259
@toggle="
261260
globalSettingsStore.updateSettings({
262261
allowRegistration: !globalSettingsStore.settings.allowRegistration,

app/components/Settings/SettingsToggleItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const emit = defineEmits(["toggle"]);
1212

1313
<template>
1414
<div
15-
class="grid grid-cols-[auto_min-content_auto] grid-rows-2 items-center gap-2"
15+
class="w-full grid grid-cols-[1fr_min-content] grid-rows-2 items-center gap-2"
1616
>
1717
<div v-if="title" class="row-start-1 col-start-1">{{ title }}</div>
1818
<div v-if="description" class="row-start-2 col-start-1 italic">
@@ -34,7 +34,7 @@ const emit = defineEmits(["toggle"]);
3434
]"
3535
/>
3636
</button>
37-
<div class="row-span-2 italic">
37+
<div class="row-span-2 italic justify-self-end">
3838
<div v-if="value" class="text-sm">
3939
{{ trueLabel }}
4040
</div>

app/stores/globalSettings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { triggerDebouncedSync } from "~/utils/sync/debounce";
55
export interface GlobalSettings {
66
availableModels: Model[];
77
allowRegistration: boolean;
8+
allowFileUpload: boolean;
89
ollamaUrls: string[];
910
}
1011

1112
function getDefaultSettings(): GlobalSettings {
1213
return {
1314
availableModels: [],
1415
allowRegistration: false,
16+
allowFileUpload: false,
1517
ollamaUrls: [],
1618
};
1719
}

0 commit comments

Comments
 (0)