Skip to content

Commit 9d87d43

Browse files
committed
Added permission to enable/disable image capture
1 parent 918f507 commit 9d87d43

File tree

6 files changed

+46
-27
lines changed

6 files changed

+46
-27
lines changed

backend/open_webui/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,10 @@ def oidc_oauth_register(client: OAuth):
11961196
os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true"
11971197
)
11981198

1199+
USER_PERMISSIONS_CHAT_IMAGE_CAPTURE = (
1200+
os.environ.get("USER_PERMISSIONS_CHAT_IMAGE_CAPTURE", "True").lower() == "true"
1201+
)
1202+
11991203
USER_PERMISSIONS_CHAT_PARAMS = (
12001204
os.environ.get("USER_PERMISSIONS_CHAT_PARAMS", "True").lower() == "true"
12011205
)
@@ -1304,6 +1308,7 @@ def oidc_oauth_register(client: OAuth):
13041308
"controls": USER_PERMISSIONS_CHAT_CONTROLS,
13051309
"valves": USER_PERMISSIONS_CHAT_VALVES,
13061310
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
1311+
"image_capture": USER_PERMISSIONS_CHAT_IMAGE_CAPTURE,
13071312
"params": USER_PERMISSIONS_CHAT_PARAMS,
13081313
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
13091314
"delete": USER_PERMISSIONS_CHAT_DELETE,

backend/open_webui/routers/users.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class ChatPermissions(BaseModel):
145145
controls: bool = True
146146
valves: bool = True
147147
system_prompt: bool = True
148+
image_capture: bool = True
148149
params: bool = True
149150
file_upload: bool = True
150151
delete: bool = True

src/lib/components/admin/Users/Groups.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
controls: true,
6969
valves: true,
7070
system_prompt: true,
71+
image_capture: true,
7172
params: true,
7273
file_upload: true,
7374
delete: true,

src/lib/components/admin/Users/Groups/EditGroupModal.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
controls: true,
5151
valves: true,
5252
system_prompt: true,
53+
image_capture: true,
5354
params: true,
5455
file_upload: true,
5556
delete: true,

src/lib/components/admin/Users/Groups/Permissions.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
valves: true,
2525
system_prompt: true,
2626
params: true,
27+
image_capture: true,
2728
file_upload: true,
2829
delete: true,
2930
delete_message: true,
@@ -304,6 +305,14 @@
304305
<Switch bind:state={permissions.chat.edit} />
305306
</div>
306307

308+
<div class=" flex w-full justify-between my-2 pr-2">
309+
<div class=" self-center text-xs font-medium">
310+
{$i18n.t('Allow Image capture')}
311+
</div>
312+
313+
<Switch bind:state={permissions.chat.image_capture} />
314+
</div>
315+
307316
<div class=" flex w-full justify-between my-2 pr-2">
308317
<div class=" self-center text-xs font-medium">
309318
{$i18n.t('Allow Chat Delete')}

src/lib/components/chat/MessageInput/InputMenu.svelte

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -182,36 +182,38 @@
182182
<hr class="border-black/5 dark:border-white/5 my-1" />
183183
{/if}
184184

185-
<Tooltip
186-
content={fileUploadCapableModels.length !== selectedModels.length
187-
? $i18n.t('Model(s) do not support file upload')
188-
: !fileUploadEnabled
189-
? $i18n.t('You do not have permission to upload files.')
190-
: ''}
191-
className="w-full"
192-
>
193-
<DropdownMenu.Item
194-
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl {!fileUploadEnabled
195-
? 'opacity-50'
196-
: ''}"
197-
on:click={() => {
198-
if (fileUploadEnabled) {
199-
if (!detectMobile()) {
200-
screenCaptureHandler();
201-
} else {
202-
const cameraInputElement = document.getElementById('camera-input');
185+
{#if $user?.role === 'admin' || $user?.permissions.chat?.image_capture}
186+
<Tooltip
187+
content={fileUploadCapableModels.length !== selectedModels.length
188+
? $i18n.t('Model(s) do not support file upload')
189+
: !fileUploadEnabled
190+
? $i18n.t('You do not have permission to upload files.')
191+
: ''}
192+
className="w-full"
193+
>
194+
<DropdownMenu.Item
195+
class="flex gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl {!fileUploadEnabled
196+
? 'opacity-50'
197+
: ''}"
198+
on:click={() => {
199+
if (fileUploadEnabled) {
200+
if (!detectMobile()) {
201+
screenCaptureHandler();
202+
} else {
203+
const cameraInputElement = document.getElementById('camera-input');
203204

204-
if (cameraInputElement) {
205-
cameraInputElement.click();
205+
if (cameraInputElement) {
206+
cameraInputElement.click();
207+
}
206208
}
207209
}
208-
}
209-
}}
210-
>
211-
<CameraSolid />
212-
<div class=" line-clamp-1">{$i18n.t('Capture')}</div>
213-
</DropdownMenu.Item>
214-
</Tooltip>
210+
}}
211+
>
212+
<CameraSolid />
213+
<div class=" line-clamp-1">{$i18n.t('Capture')}</div>
214+
</DropdownMenu.Item>
215+
</Tooltip>
216+
{/if}
215217

216218
<Tooltip
217219
content={fileUploadCapableModels.length !== selectedModels.length

0 commit comments

Comments
 (0)