Upgraded status pane to API v2

This commit is contained in:
Joel Collins 2019-11-22 13:29:37 +00:00
parent 80ad33fdd8
commit f92d9de3dd

View file

@ -1,34 +1,40 @@
<template> <template>
<div class="host-input"> <div class="host-input">
<div v-if="$store.getters.ready"> <div v-if="status">
<div v-if="$store.state.apiConfig.name"> <div>
<b>Device name:</b> <br /> <div class="uk-margin-small-bottom">
{{ $store.state.apiConfig.name }} <b>Host:</b>
<br />
{{ $store.state.host }}
</div>
</div> </div>
<hr /> <hr />
<div class="uk-margin-small-bottom">
<b>Host:</b> <div v-if="settings">
<br /> <b>Device name:</b> <br />
{{ $store.state.host }} {{ settings.name }}
</div> </div>
<div> <div>
<b>Server version:</b> <br /> <b>Server version:</b> <br />
{{ $store.state.apiState.version }} {{ status.version }}
</div> </div>
<hr /> <hr />
<div class="uk-margin-small-bottom"> <div class="uk-margin-small-bottom">
<b>Camera:</b> <b>Camera:</b>
<br /> <br />
<div v-if="$store.state.apiState.camera.board"> <div v-if="status.camera.board">
{{ $store.state.apiState.camera.board }} {{ status.camera.board }}
</div> </div>
<div v-else class="uk-text-danger"><b>No camera connected</b></div> <div v-else class="uk-text-danger"><b>No camera connected</b></div>
</div> </div>
<div> <div>
<b>Stage:</b> <b>Stage:</b>
<br /> <br />
<div v-if="$store.state.apiState.stage.board"> <div v-if="status.stage.board">
{{ $store.state.apiState.stage.board }} {{ status.stage.board }}
</div> </div>
<div v-else class="uk-text-danger"><b>No stage connected</b></div> <div v-else class="uk-text-danger"><b>No stage connected</b></div>
</div> </div>
@ -44,6 +50,7 @@
</template> </template>
<script> <script>
import axios from "axios";
import progressBar from "../genericComponents/progressBar"; import progressBar from "../genericComponents/progressBar";
export default { export default {
@ -54,16 +61,60 @@ export default {
}, },
data: function() { data: function() {
return {}; return {
status: null,
settings: null
};
}, },
computed: {}, computed: {
settingsUri: function() {
return `http://${this.$store.state.host}:${
this.$store.state.port
}/api/v2/settings`;
},
statusUri: function() {
return `http://${this.$store.state.host}:${
this.$store.state.port
}/api/v2/status`;
}
},
watch: {}, created: function() {
// Watch for host 'ready', then update status
this.$store.watch(
(state, getters) => {
return getters.ready;
},
() => {
this.updateStatus();
this.updateSettings();
}
);
},
mounted() {}, methods: {
updateStatus: function() {
methods: {} axios
.get(this.statusUri)
.then(response => {
this.status = response.data;
})
.catch(error => {
this.modalError(error); // Let mixin handle error
});
},
updateSettings: function() {
axios
.get(this.settingsUri)
.then(response => {
this.settings = response.data;
})
.catch(error => {
this.modalError(error); // Let mixin handle error
});
}
}
}; };
</script> </script>