Fix: Device Manager shows 404 if no pin_mapping.json was available
This commit is contained in:
parent
f8cc171e4a
commit
29403013f5
@ -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 => {
|
return response.text().then(text => {
|
||||||
const data = text && JSON.parse(text);
|
const data = text && JSON.parse(text);
|
||||||
if (!response.ok) {
|
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 };
|
const error = { message: (data && data.message) || response.statusText, status: response.status || 0 };
|
||||||
|
if (!ignore_error) {
|
||||||
router.push({ name: "Error", params: error });
|
router.push({ name: "Error", params: error });
|
||||||
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -219,7 +219,7 @@ export default defineComponent({
|
|||||||
getPinMappingList() {
|
getPinMappingList() {
|
||||||
this.pinMappingLoading = true;
|
this.pinMappingLoading = true;
|
||||||
fetch("/api/config/get?file=pin_mapping.json", { headers: authHeader() })
|
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(
|
.then(
|
||||||
(data) => {
|
(data) => {
|
||||||
this.pinMappingList = data;
|
this.pinMappingList = data;
|
||||||
@ -246,6 +246,9 @@ export default defineComponent({
|
|||||||
.then(
|
.then(
|
||||||
(data) => {
|
(data) => {
|
||||||
this.deviceConfigList = data;
|
this.deviceConfigList = data;
|
||||||
|
if (this.deviceConfigList.curPin.name === "") {
|
||||||
|
this.deviceConfigList.curPin.name = "Default";
|
||||||
|
}
|
||||||
this.dataLoading = false;
|
this.dataLoading = false;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user