Skip to content

Commit 2d1c45e

Browse files
committed
replaced most console statements with proper error messages for failed requests
1 parent b2f4628 commit 2d1c45e

File tree

4 files changed

+57
-21
lines changed

4 files changed

+57
-21
lines changed

webapp/src/App.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</v-list>
5353
</v-navigation-drawer>
5454

55-
<v-main class="accent" v-if="$store.state.loading">
55+
<v-main class="accent" v-if="!$store.state.loading">
5656
<v-container fluid fill-height>
5757
<router-view/>
5858
</v-container>
@@ -73,7 +73,6 @@ export default {
7373
this.$ajax
7474
.get('api/v1/ts/')
7575
.then(res => {
76-
console.log(res)
7776
if (res.data) {
7877
this.$store.state.devices = res.data
7978
this.$store.state.active_device = Object.keys(res.data)[0]
@@ -82,9 +81,6 @@ export default {
8281
this.$store.state.loading = false
8382
}
8483
})
85-
.catch(error => {
86-
console.log(error);
87-
});
8884
},
8985
data () {
9086
return {
@@ -99,6 +95,7 @@ export default {
9995
],
10096
right: null,
10197
active_device: "No Devices connected...",
98+
dialog: false
10299
}
103100
},
104101
methods: {

webapp/src/views/Config.vue

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
<v-icon left>mdi-cancel</v-icon> Cancel
2929
</v-btn>
3030
</v-container>
31+
<v-card-text>
32+
<v-alert
33+
v-model="alert"
34+
dense
35+
text
36+
type="warning"
37+
transition="scale-transition"
38+
><v-row align="center">
39+
<v-col class="grow">{{ status }}</v-col>
40+
<v-col class="shrink">
41+
<v-btn color="warning" @click="fetch_data()">Reload</v-btn>
42+
</v-col>
43+
</v-row></v-alert>
44+
</v-card-text>
3145
</v-card>
3246
</v-flex>
3347
</v-layout>
@@ -46,10 +60,7 @@
4660
<v-btn
4761
color="primary"
4862
text
49-
@click="dialog = false"
50-
>
51-
Ok
52-
</v-btn>
63+
@click="dialog = false">Ok</v-btn>
5364
</v-card-actions>
5465
</v-card>
5566
</v-dialog>
@@ -63,25 +74,32 @@ export default {
6374
data_objects: null,
6475
base_data: null,
6576
diff: {},
66-
dialog: false
77+
dialog: false,
78+
status: "",
79+
alert: false
6780
}
6881
},
6982
created() {
70-
let id = this.$store.state.active_device_id
83+
this.fetch_data()
84+
},
85+
methods: {
86+
fetch_data: function() {
87+
let id = this.$store.state.active_device_id
7188
this.$ajax
7289
.get("api/v1/ts/" + id + "/conf")
7390
.then(res => {
91+
this.alert = false
7492
this.data_objects = res.data
7593
// keep a copy so we can make a diff to reduce size,
7694
// writing to eeprom in the MCU takes long...
7795
// this only works with basic datatypes, not with Date() etc.
7896
this.base_data = JSON.parse(JSON.stringify(res.data))
7997
})
8098
.catch(error => {
81-
console.log(error)
99+
this.status = "Configuration Information could not be fetched: " + error.response.status + "-" + error.response.data
100+
this.alert = true
82101
})
83-
},
84-
methods: {
102+
},
85103
reset_values: function() {
86104
this.data_objects = this.base_data
87105
},
@@ -92,15 +110,13 @@ export default {
92110
this.diff[key] = this.data_objects[key]
93111
}
94112
}, this)
95-
console.log(this.diff)
96113
this.$ajax
97114
.patch("api/v1/ts/" + id + "/conf", this.diff)
98115
.then(res => {
99116
this.base_data = this.data_objects
100117
})
101118
.catch(error => {
102119
this.dialog = true
103-
//console.log(error)
104120
})
105121
}
106122
}

webapp/src/views/Home.vue

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
Firmware version: <span class="grey--text">{{fw_version}}</span>
1616
</div>
1717
</v-card-title>
18+
<v-card-text>
19+
<v-alert
20+
v-model="alert"
21+
dense
22+
text
23+
type="warning"
24+
transition="scale-transition"
25+
><v-row align="center">
26+
<v-col class="grow">{{ status }}</v-col>
27+
<v-col class="shrink">
28+
<v-btn color="warning" @click="fetch_data()">Reload</v-btn>
29+
</v-col>
30+
</v-row></v-alert>
31+
</v-card-text>
1832
</v-card>
1933
</v-flex>
2034
</v-layout>
@@ -29,23 +43,32 @@ export default {
2943
device_id: null,
3044
device_type: null,
3145
hw_version: null,
32-
fw_version: null
46+
fw_version: null,
47+
alert: false,
48+
status: null
3349
}
3450
},
3551
mounted() {
36-
let id = this.$store.state.active_device_id
37-
this.$ajax
52+
this.fetch_data()
53+
},
54+
methods: {
55+
fetch_data: function() {
56+
let id = this.$store.state.active_device_id
57+
this.$ajax
3858
.get("api/v1/ts/" + id + "/info")
3959
.then(res => {
60+
this.alert = false
4061
this.manufacturer = res.data.Manufacturer;
4162
this.device_id = res.data.DeviceID;
4263
this.device_type = res.data.DeviceType;
4364
this.hw_version = res.data.HardwareVersion;
4465
this.fw_version = res.data.FirmwareVersion;
4566
})
4667
.catch(error => {
47-
console.log(error);
68+
this.status = "Device Information could not be fetched: " + error.response.status + "-" + error.response.data
69+
this.alert = true
4870
});
71+
}
4972
}
5073
}
5174
</script>

webapp/vue.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
plugins: [new CompressionPlugin({
3333
filename: '[name][ext].gz',
3434
algorithm: "gzip",
35-
deleteOriginalAssets: true,
35+
deleteOriginalAssets: process.env.NODE_ENV === 'production' ? true : false,
3636
})]
3737
}
3838
}

0 commit comments

Comments
 (0)