mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-09 15:35:39 +02:00
fix(obico): POST image bytes directly to ML API instead of callback URL (#1003)
The ML API previously called back into Bambuddy to fetch snapshots, which failed behind reverse proxies with external auth (Authelia, etc.). Now the detection loop captures the JPEG locally and POSTs it directly as multipart form data — no callback URL, no nonce cache, no external_url dependency.
This commit is contained in:
@@ -40,7 +40,6 @@ const baseStatus = {
|
||||
sensitivity: 'medium',
|
||||
action: 'notify',
|
||||
poll_interval: 10,
|
||||
external_url_configured: true,
|
||||
};
|
||||
|
||||
describe('FailureDetectionSettings', () => {
|
||||
@@ -62,19 +61,6 @@ describe('FailureDetectionSettings', () => {
|
||||
expect(screen.getByText(/Sensitivity/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('warns when external URL is missing and detection is enabled', async () => {
|
||||
server.use(
|
||||
http.get('/api/v1/settings/', () => HttpResponse.json({ ...baseSettings, obico_enabled: true })),
|
||||
http.get('/api/v1/obico/status', () =>
|
||||
HttpResponse.json({ ...baseStatus, enabled: true, external_url_configured: false }),
|
||||
),
|
||||
);
|
||||
render(<FailureDetectionSettings />);
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/External URL is not set/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('test button calls the test-connection endpoint and shows success', async () => {
|
||||
let called = false;
|
||||
server.use(
|
||||
|
||||
@@ -1868,7 +1868,6 @@ export interface ObicoStatus {
|
||||
sensitivity: 'low' | 'medium' | 'high';
|
||||
action: 'notify' | 'pause' | 'pause_and_off';
|
||||
poll_interval: number;
|
||||
external_url_configured: boolean;
|
||||
}
|
||||
|
||||
export interface ObicoTestConnection {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { Loader2, ScanEye, Check, X, AlertTriangle, Info } from 'lucide-react';
|
||||
import { Loader2, ScanEye, Check, X, Info } from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import { Card, CardContent, CardHeader } from './Card';
|
||||
import { Button } from './Button';
|
||||
@@ -221,15 +221,6 @@ export function FailureDetectionSettings() {
|
||||
<p className="text-xs text-bambu-gray mt-1">{t('failureDetection.pollIntervalHint')}</p>
|
||||
</div>
|
||||
|
||||
{status && !status.external_url_configured && enabled && (
|
||||
<div className="flex items-start gap-2 p-3 bg-amber-900/30 border border-amber-700 rounded text-sm text-amber-200">
|
||||
<AlertTriangle className="w-4 h-4 mt-0.5 flex-shrink-0" />
|
||||
<div>
|
||||
<div className="font-medium">{t('failureDetection.externalUrlMissing')}</div>
|
||||
<div className="text-xs mt-1">{t('failureDetection.externalUrlHint')}</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -5054,8 +5054,6 @@ export default {
|
||||
actionPauseOff: 'Pausieren und Strom abschalten',
|
||||
pollInterval: 'Prüfintervall (Sekunden)',
|
||||
pollIntervalHint: 'Wie oft jeder Drucker während eines laufenden Drucks geprüft wird. Minimum 5 s, Maximum 120 s.',
|
||||
externalUrlMissing: 'Externe URL ist nicht gesetzt.',
|
||||
externalUrlHint: 'Die ML-API lädt das Kamerabild per URL. Setze die Externe URL in den allgemeinen Einstellungen, damit der ML-API-Container Bambuddy erreichen kann.',
|
||||
perPrinterTitle: 'Überwachte Drucker',
|
||||
perPrinterHint: 'Wähle, welche Drucker vom Erkennungsdienst überwacht werden.',
|
||||
monitorAll: 'Alle verbundenen Drucker überwachen',
|
||||
|
||||
@@ -5062,8 +5062,6 @@ export default {
|
||||
actionPauseOff: 'Pause and cut power',
|
||||
pollInterval: 'Poll interval (seconds)',
|
||||
pollIntervalHint: 'How often to check each printer while it is printing. Minimum 5s, maximum 120s.',
|
||||
externalUrlMissing: 'External URL is not set.',
|
||||
externalUrlHint: 'The ML API fetches the camera snapshot by URL. Set the External URL in General settings so the ML API container can reach Bambuddy.',
|
||||
perPrinterTitle: 'Monitored Printers',
|
||||
perPrinterHint: 'Choose which printers the detection service watches.',
|
||||
monitorAll: 'Monitor all connected printers',
|
||||
|
||||
@@ -4968,8 +4968,6 @@ export default {
|
||||
actionPauseOff: 'Pause et couper l\'alimentation',
|
||||
pollInterval: 'Intervalle de vérification (secondes)',
|
||||
pollIntervalHint: 'Fréquence de vérification de chaque imprimante pendant l\'impression. Minimum 5s, maximum 120s.',
|
||||
externalUrlMissing: 'L\'URL externe n\'est pas définie.',
|
||||
externalUrlHint: 'L\'API ML récupère l\'image de la caméra via URL. Définissez l\'URL externe dans les paramètres généraux pour que le conteneur ML API puisse atteindre Bambuddy.',
|
||||
perPrinterTitle: 'Imprimantes surveillées',
|
||||
perPrinterHint: 'Choisissez quelles imprimantes le service de détection surveille.',
|
||||
monitorAll: 'Surveiller toutes les imprimantes connectées',
|
||||
|
||||
@@ -4967,8 +4967,6 @@ export default {
|
||||
actionPauseOff: 'Pausa e stacca corrente',
|
||||
pollInterval: 'Intervallo di controllo (secondi)',
|
||||
pollIntervalHint: 'Frequenza di controllo di ogni stampante durante la stampa. Minimo 5s, massimo 120s.',
|
||||
externalUrlMissing: 'URL esterno non impostato.',
|
||||
externalUrlHint: 'L\'API ML recupera l\'immagine della fotocamera tramite URL. Imposta l\'URL esterno nelle impostazioni generali affinché il container ML API possa raggiungere Bambuddy.',
|
||||
perPrinterTitle: 'Stampanti monitorate',
|
||||
perPrinterHint: 'Scegli quali stampanti il servizio di rilevamento deve monitorare.',
|
||||
monitorAll: 'Monitora tutte le stampanti connesse',
|
||||
|
||||
@@ -5006,8 +5006,6 @@ export default {
|
||||
actionPauseOff: '一時停止して電源を切る',
|
||||
pollInterval: 'ポーリング間隔(秒)',
|
||||
pollIntervalHint: '印刷中に各プリンターをチェックする頻度。最小 5 秒、最大 120 秒。',
|
||||
externalUrlMissing: '外部 URL が設定されていません。',
|
||||
externalUrlHint: 'ML API は URL 経由でカメラ画像を取得します。ML API コンテナが Bambuddy に到達できるよう、一般設定で外部 URL を設定してください。',
|
||||
perPrinterTitle: '監視対象プリンター',
|
||||
perPrinterHint: '検出サービスが監視するプリンターを選択します。',
|
||||
monitorAll: '接続されているすべてのプリンターを監視',
|
||||
|
||||
@@ -4981,8 +4981,6 @@ export default {
|
||||
actionPauseOff: 'Pausar e cortar energia',
|
||||
pollInterval: 'Intervalo de verificação (segundos)',
|
||||
pollIntervalHint: 'Frequência de verificação de cada impressora durante a impressão. Mínimo 5s, máximo 120s.',
|
||||
externalUrlMissing: 'URL externa não configurada.',
|
||||
externalUrlHint: 'A API ML busca a imagem da câmera por URL. Defina a URL externa nas configurações gerais para que o contêiner da API ML possa alcançar o Bambuddy.',
|
||||
perPrinterTitle: 'Impressoras monitoradas',
|
||||
perPrinterHint: 'Escolha quais impressoras o serviço de detecção monitora.',
|
||||
monitorAll: 'Monitorar todas as impressoras conectadas',
|
||||
|
||||
@@ -4966,8 +4966,6 @@ export default {
|
||||
actionPauseOff: '暂停并切断电源',
|
||||
pollInterval: '检查间隔(秒)',
|
||||
pollIntervalHint: '打印过程中每台打印机的检查频率。最小 5 秒,最大 120 秒。',
|
||||
externalUrlMissing: '未设置外部 URL。',
|
||||
externalUrlHint: 'ML API 通过 URL 获取相机截图。请在常规设置中设置外部 URL,以便 ML API 容器可以访问 Bambuddy。',
|
||||
perPrinterTitle: '监控的打印机',
|
||||
perPrinterHint: '选择检测服务要监视哪些打印机。',
|
||||
monitorAll: '监控所有已连接的打印机',
|
||||
|
||||
Reference in New Issue
Block a user