Skip to content

Commit

Permalink
Fix: Device Manager shows 404 if no pin_mapping.json was available
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Apr 24, 2024
1 parent f8cc171 commit 2940301
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions webapp/src/utils/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 };
router.push({ name: "Error", params: error });
if (!ignore_error) {
router.push({ name: "Error", params: error });
}
return Promise.reject(error);
}

Expand Down
5 changes: 4 additions & 1 deletion webapp/src/views/DeviceAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
)
Expand Down

0 comments on commit 2940301

Please sign in to comment.