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 >
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 }
0 commit comments