netdb.io plugins.
Plugins are tools that will run agains the dataset of specific workspace. PLugins run sandboxed, so no plugin can comunicate with the netdb software, but netdb suftware can. Plugin trying to access to the netdb platform itself, will be deleted.
We are ussing the API method 'postMessage', the Window.postMessage() method safely enables cross-origin communication.
QUite simple.
- netdb will dispatch to your html, postMesage event with an array.
- Array will contain two key:values which are: data and configuration.
- Then.. You will recivie the event message, and do something with the data and config.
- host screenshot
- Create and folder with the name of your plugin
- Add an index.html file to the root of your folder.
- Create an app.js file to the root of your folder.
- Add the following code to your html to recieve the data from the netdb app. The Window.postMessage() method safely enables cross-origin communication. see here API
// we are reciving the data with this "magic" method
window.addEventListener('message', function(event){
if (~event.origin.indexOf('http://netdb.io'))
initPlugin(event.data);
});
// we prefer to use this naming convention
function initPlugin(response){
var config = response['config']['key'];
var data = response['data'];
console.log(config, data);
// ...do whatever with your plugin
}
- Create a config.json file, containing separted by comma, all the fields required to be sent by netdb app to the plugin(eh:ip, latitude, longitude).
The data sent to the plugin will be an array of two keys.
- Key config: contains array with configuration key/values configured from the netdbapp of this specific plugin.
- Key data: contains an array of the full/selected workspace hosts, will only contains the existing keys in the config file
- @jamesjara
- @fmonge