Skip to content

Commit

Permalink
Feature: Show error in webapp if pin_mapping.json contains syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Jul 22, 2023
1 parent 972dea2 commit eaacce7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@
},
"deviceadmin": {
"DeviceManager": "Hardware-Einstellungen",
"ParseError": "Syntaxfehler in 'pin_mapping.json': {error}",
"PinAssignment": "Anschlusseinstellungen",
"SelectedProfile": "Ausgewähltes Profil:",
"DefaultProfile": "(Standardeinstellungen)",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@
},
"deviceadmin": {
"DeviceManager": "Device-Manager",
"ParseError": "Parse error in 'pin_mapping.json': {error}",
"PinAssignment": "Connection settings",
"SelectedProfile": "Selected profile:",
"DefaultProfile": "(Default settings)",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@
},
"deviceadmin": {
"DeviceManager": "Gestionnaire de périphériques",
"ParseError": "Erreur d'analyse dans 'pin_mapping.json': {error}",
"PinAssignment": "Paramètres de connexion",
"SelectedProfile": "Profil sélectionné",
"DefaultProfile": "(Réglages par défaut)",
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/utils/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export function handleResponse(response: Response, emitter: Emitter<Record<Event
// auto logout if 401 response returned from api
logout();
emitter.emit("logged-out");
router.push({path: "/login", query: { returnUrl: router.currentRoute.value.fullPath }});
router.push({ path: "/login", query: { returnUrl: router.currentRoute.value.fullPath } });
}

const error = (data && data.message) || response.statusText;
const error = { message: (data && data.message) || response.statusText, status: response.status || 0 };
return Promise.reject(error);
}

Expand Down
13 changes: 9 additions & 4 deletions webapp/src/views/DeviceAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
<div class="row mb-3">
<label for="inputDisplayContrast" class="col-sm-2 col-form-label">{{
$t('deviceadmin.Contrast', { contrast: $n(deviceConfigList.display.contrast / 100,
'percent')
}) }}</label>
'percent')
}) }}</label>
<div class="col-sm-10">
<input type="range" class="form-range" min="0" max="100" id="inputDisplayContrast"
v-model="deviceConfigList.display.contrast" />
Expand Down Expand Up @@ -120,7 +120,7 @@ export default defineComponent({
BootstrapAlert,
InputElement,
PinInfo,
},
},
data() {
return {
dataLoading: true,
Expand Down Expand Up @@ -157,7 +157,12 @@ export default defineComponent({
this.pinMappingList = data;
}
)
.catch(() => {
.catch((error) => {
if (error.status != 404) {
this.alertMessage = this.$t('deviceadmin.ParseError', { error: error.message });
this.alertType = 'danger';
this.showAlert = true;
}
this.pinMappingList = Array<Device>();
})
.finally(() => {
Expand Down

0 comments on commit eaacce7

Please sign in to comment.