diff --git a/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue b/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue index 3f718352..e6021f41 100644 --- a/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue +++ b/webapp/src/components/tabContentComponents/navigateComponents/paneNavigate.vue @@ -239,7 +239,7 @@ export default { }, positionStatusUri: function() { return `${this.baseUri}/stage/position`; - }, + } }, watch: { diff --git a/webapp/src/components/tabContentComponents/settingsComponents/cameraSettings.vue b/webapp/src/components/tabContentComponents/settingsComponents/cameraSettings.vue index f9e70ebb..ea08f866 100644 --- a/webapp/src/components/tabContentComponents/settingsComponents/cameraSettings.vue +++ b/webapp/src/components/tabContentComponents/settingsComponents/cameraSettings.vue @@ -136,19 +136,17 @@ export default { { text: "Normal (30fps)", value: 30 }, { text: "Low (15fps)", value: 15 }, { text: "Very low (10fps)", value: 10 } - ], - thingDescription: undefined + ] }; }, computed: { cameraUri: function() { return `${this.$store.getters.baseUri}/camera/`; + }, + thingDescription: function() { + return this.$store.getters["wot/thingDescription"]("camera"); } - }, - - mounted: async function() { - this.thingDescription = await this.getThingDescription("camera"); } }; diff --git a/webapp/src/main.js b/webapp/src/main.js index c1aaaf5a..9cbc414a 100644 --- a/webapp/src/main.js +++ b/webapp/src/main.js @@ -1,6 +1,7 @@ import Vue from "vue"; import App from "./App.vue"; import store from "./store"; +import axios from "axios"; import UIkit from "uikit"; import VueTour from "vue-tour"; import VueFriendlyIframe from "vue-friendly-iframe"; @@ -41,7 +42,11 @@ Vue.mixin({ return this.$store.getters["wot/thingAvailable"](thing); }, async readThingProperty(thing, property) { - let url = this.$store.getters["wot/thingPropertyUrl"](thing, property, "readproperty"); + let url = this.$store.getters["wot/thingPropertyUrl"]( + thing, + property, + "readproperty" + ); try { let response = await axios.get(url); return response.data; @@ -50,9 +55,13 @@ Vue.mixin({ } }, async writeThingProperty(thing, property, value) { - let url = this.$store.getters["wot/thingPropertyUrl"](thing, property, "writeproperty"); + let url = this.$store.getters["wot/thingPropertyUrl"]( + thing, + property, + "writeproperty" + ); try { - let response = await axios.put(url, value); + await axios.put(url, value); } catch (error) { this.modalError(error); } diff --git a/webapp/src/wot-client.js b/webapp/src/wot-client.js index 2a2a69a1..d5aa375d 100644 --- a/webapp/src/wot-client.js +++ b/webapp/src/wot-client.js @@ -22,30 +22,42 @@ export const wotStoreModule = { async start() { // Set up thing client - not currently used. }, - async fetchThingDescription({ commit }, {uri, name=null}) { + async fetchThingDescription({ commit }, { uri, name = null }) { // Fetch the thing description from the given URI and consume it // NB this should only be called once, or we'll duplicate effort. // Deduplication should be done elsewhere. let response = await axios.get(uri); let td = response.data; - let thing_name = name | uri.replace(/\/$/, "").split("/").pop(); - commit("addThingDescription", { thingName: thing_name, thingDescription: td }); + let thing_name = + name | + uri + .replace(/\/$/, "") + .split("/") + .pop(); + commit("addThingDescription", { + thingName: thing_name, + thingDescription: td + }); }, async fetchThingDescriptions({ commit }, uri) { // Fetch thing descriptions from the given URI let response = await axios.get(uri); if (response.status != 200) throw "Could not retrieve thing descriptions"; - for (const k in response.data){ + for (const k in response.data) { let thing_name = k.replace(/\/$/, "").replace(/^\//, ""); - commit("addThingDescription", {thing_name: thing_name, thing_description: response.data[k]}); + commit("addThingDescription", { + thingName: thing_name, + thingDescription: response.data[k] + }); } - }, + } }, getters: { thingDescription: state => thingName => { return state.thingDescriptions[thingName]; }, thingAvailable: state => thingName => { + console.log("thingAvailable", thingName, state.thingDescriptions) return thingName in state.thingDescriptions; }, thingFormUrl: state => (thing, affordanceType, affordance, op) => { @@ -62,11 +74,11 @@ export const wotStoreModule = { thingActionUrl: (_state, getters) => (thing, action, op) => { // Find the URL for a particular action return getters.thingFormUrl(thing, "actions", action, op); - }, + } } }; -export function findForm(affordance, op){ +export function findForm(affordance, op) { // Find the form in the affordance that matches the given operation type let forms = affordance.forms; let matchingForm = forms.find(f => f.op == op || f.op.includes(op));