Fix: Device Manager shows 404 if no pin_mapping.json was available

This commit is contained in:
Thomas Basler 2024-04-24 22:28:59 +02:00
parent f8cc171e4a
commit 29403013f5
2 changed files with 8 additions and 3 deletions

View File

@ -65,7 +65,7 @@ export function login(username: string, password: string) {
});
}
export function handleResponse(response: Response, emitter: Emitter<Record<EventType, unknown>>, router: Router) {
export function handleResponse(response: Response, emitter: Emitter<Record<EventType, unknown>>, router: Router, ignore_error: boolean = false) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
@ -78,7 +78,9 @@ export function handleResponse(response: Response, emitter: Emitter<Record<Event
}
const error = { message: (data && data.message) || response.statusText, status: response.status || 0 };
if (!ignore_error) {
router.push({ name: "Error", params: error });
}
return Promise.reject(error);
}

View File

@ -219,7 +219,7 @@ export default defineComponent({
getPinMappingList() {
this.pinMappingLoading = true;
fetch("/api/config/get?file=pin_mapping.json", { headers: authHeader() })
.then((response) => handleResponse(response, this.$emitter, this.$router))
.then((response) => handleResponse(response, this.$emitter, this.$router, true))
.then(
(data) => {
this.pinMappingList = data;
@ -246,6 +246,9 @@ export default defineComponent({
.then(
(data) => {
this.deviceConfigList = data;
if (this.deviceConfigList.curPin.name === "") {
this.deviceConfigList.curPin.name = "Default";
}
this.dataLoading = false;
}
)