Dictionary not found #4045
Replies: 9 comments 3 replies
-
For now as a workaround I hardcoded the json but that cant be the solution |
Beta Was this translation helpful? Give feedback.
-
@Voreck could you post your code so we can try to reproduce |
Beta Was this translation helpful? Give feedback.
-
This all lies in opencmt/src/plugins/my-plugin/src/plugin.js (Idk if thats the right place to put it, I just did what seemed right to me function getDictionary() {
return fetch("dictionary.json").then(function(response){
return response.json()
});
}
const objectProvider = {
get: function (identifier) {
if (identifier.key === "dir.root") {
return Promise.resolve({
identifier: identifier,
name: dictionary.name,
type: "folder",
location: "ROOT"
});
}
}
};
export default function () {
return function install(openmct) {
openmct.objects.addRoot({
namespace: "vck.zll",
key: "dir.root"
});
openmct.objects.addProvider("vck.zll", objectProvider);
}
}; I've tried both simply dictionary.json as well as src/plugins/my-plugin/src/dictionary.json which is where the file lies |
Beta Was this translation helpful? Give feedback.
-
I found another, similar behaviour: I previously "installed" my plugin by mimicing what i saw in the plugins.js. But if I try to install it the way its installed in the tutorial, through the script tag and the install function I get a 404 at the script tag |
Beta Was this translation helpful? Give feedback.
-
Alright, I found a solution: I used the define([
"./dictionary.json"
], function (
dictionary
) {
// Something
}); form I found in other js files. Not a fix to the problem with the script tag though, obviouslt |
Beta Was this translation helpful? Give feedback.
-
Yeah, not a bad solution. The reason we usually don't run into this type of thing is we use the strategy of Open MCT as a dependency this way when you're installing plugins that are outside of the Open MCT framework you're still inside of a JS environment (src/index.js in this case), so you can get past those issues of needing to use a source tag. We use webpack for our builds as well, which, could move your static dictionary file over to a built "dist" directory that holds all the code and just references it relatively. |
Beta Was this translation helpful? Give feedback.
-
Ok, so that makes sense to me if an user only wants to install one plugin. But what if the user wants to install more plugins? Can the user just put both plugins in the same directory, type Probably not the place to ask these questions, sorry |
Beta Was this translation helpful? Give feedback.
-
With that kinda setup, you can install as many plugins as you like. You just need to import them in the index.js, like here: https://github.com/deeptailor/openmct-as-a-dependency/blob/8546acb2b632e8154f81d0dcb729d4bcbd2ef871/src/index.js#L2 No worries, I'll actually move this over to our Discussions page for informational purposes. |
Beta Was this translation helpful? Give feedback.
-
I think there should be some mention of openmct as a dependency in the tutorial |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'll preface this with: Im pretty new to Javascript, node and pretty much everything. I've followed the tutorial and now am trying to do something myself. Form here i've gathered that i cant use the http thing from the tutorial.
so im doing this
but i get
plugin.js?2852:3 GET http://localhost:8080/dictionary.json 404 (Not Found)
Im sure im making a stupid newbie mistake but still id be really grateful for help
Beta Was this translation helpful? Give feedback.
All reactions