Removed node-wot but kept centralised TD store
I had intended to store a ConsumedThing for each Thing, in a module in the store. Until that is possible (will require some more attention to dependency management) I will just store the TDs instead. This commit includes a lot of the code I wrote for node-wot use, but without any dependence on node-wot.
This commit is contained in:
parent
45d2884159
commit
595101248e
6 changed files with 265 additions and 16 deletions
37
webapp/src/wot-client.js
Normal file
37
webapp/src/wot-client.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import axios from "axios";
|
||||
|
||||
export const wotStoreModule = {
|
||||
namespaced: true,
|
||||
state: () => ({
|
||||
thingDescriptions: {},
|
||||
servient: null,
|
||||
helpers: null
|
||||
}),
|
||||
mutations: {
|
||||
addThingDescription(state, { thingUri, thingDescription }) {
|
||||
state.thingDescriptions[thingUri] = thingDescription;
|
||||
},
|
||||
removeThingDescription(state, thingUri) {
|
||||
delete state.thingDescriptions[thingUri];
|
||||
},
|
||||
removeAllThingDescriptions(state) {
|
||||
state.thingDescriptions = {};
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async start() {
|
||||
// Set up thing client - not currently used.
|
||||
},
|
||||
async fetchThingDescription({ commit }, uri) {
|
||||
// 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;
|
||||
commit("addThingDescription", { thingUri: uri, thingDescription: td });
|
||||
}
|
||||
},
|
||||
getters: {}
|
||||
};
|
||||
|
||||
export default wotStoreModule;
|
||||
Loading…
Add table
Add a link
Reference in a new issue