mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Show correct config errors
This commit is contained in:
parent
fcbfdfa844
commit
050b2f558d
@ -674,8 +674,9 @@ def config_save():
|
|||||||
restart_frigate()
|
restart_frigate()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error restarting frigate: {e}")
|
logging.error(f"Error restarting frigate: {e}")
|
||||||
|
return "Config successfully saved, unable to restart frigate", 200
|
||||||
|
|
||||||
return "Config successfully saved", 200
|
return "Config successfully saved, restarting...", 200
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/config/schema")
|
@bp.route("/config/schema")
|
||||||
|
|||||||
@ -9,7 +9,8 @@ import axios from 'axios';
|
|||||||
|
|
||||||
export default function Config() {
|
export default function Config() {
|
||||||
const { data: config } = useSWR('config/raw');
|
const { data: config } = useSWR('config/raw');
|
||||||
const [newCode, setNewCode] = useState(config);
|
const [newCode, setNewCode] = useState();
|
||||||
|
const [success, setSuccess] = useState();
|
||||||
const [error, setError] = useState();
|
const [error, setError] = useState();
|
||||||
|
|
||||||
const onHandleSaveConfig = async (e) => {
|
const onHandleSaveConfig = async (e) => {
|
||||||
@ -17,15 +18,22 @@ export default function Config() {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios.post('config/save', newCode, {
|
axios
|
||||||
headers: { 'Content-Type': 'text/plain' },
|
.post('config/save', newCode, {
|
||||||
});
|
headers: { 'Content-Type': 'text/plain' },
|
||||||
console.log('The resp is ' + response.status + ' and data ' + response.data);
|
})
|
||||||
if (response.status === 200) {
|
.then((response) => {
|
||||||
// TODO set success
|
if (response.status === 200) {
|
||||||
} else {
|
setSuccess(response.data);
|
||||||
setError(response.data);
|
}
|
||||||
}
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error.response) {
|
||||||
|
setError(error.response.data.message);
|
||||||
|
} else {
|
||||||
|
setError(error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCopyConfig = async () => {
|
const handleCopyConfig = async () => {
|
||||||
@ -52,7 +60,8 @@ export default function Config() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="max-h-20 text-red-500">There is an error</div>}
|
{success && <div className="max-h-20 text-red-500">{success}</div>}
|
||||||
|
{error && <div className="p-4 overflow-scroll text-red-500 whitespace-pre-wrap">{error}</div>}
|
||||||
|
|
||||||
<CodeEditor value={config} language="yaml" onChange={(e) => setNewCode(e.target.value)} />
|
<CodeEditor value={config} language="yaml" onChange={(e) => setNewCode(e.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user