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:
Richard Bowman 2023-11-29 22:43:55 +00:00
parent 45d2884159
commit 595101248e
6 changed files with 265 additions and 16 deletions

37
webapp/src/wot-client.js Normal file
View 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;