You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
Tried to use this in a production environment and after some debugging i found out that the code is outdated regarding how to use Kuzzle-SDK in vanilla js.
Here is the new code so you can update it:
(function(){freeboard.loadDatasourcePlugin({type_name: "kuzzle_subscribe_data",display_name: "Kuzzle Datasource",description: "Monitor Kuzzle Documents",external_scripts: ["node_modules/kuzzle-sdk/dist/kuzzle.js"],settings: [{name: "kuzzle_host",display_name: "Kuzzle host",type: "text",default_value: "localhost",description: "URL to you Kuzzle instance"},{name: "kuzzle_port",display_name: "Kuzzle port",type: "text",default_value: 7512,description: "Kuzzle port"},{name: "kuzzle_token",display_name: "Token",type: "text",description:
"API token retreived using: https://docs.kuzzle.io/api-documentation/controller-auth/login/"},{name: "kuzzle_index",display_name: "Index",type: "text",description: "The index that holds the collection"},{name: "kuzzle_collection",display_name: "Collection",type: "text",description: "The collection"},{name: "kuzzle_subscribe_query",display_name: "Subscribe query",type: "text",description:
"The subscribe query: https://docs.kuzzle.io/sdk-reference/collection/subscribe/"}],newInstance: function(settings,newInstanceCallback,updateCallback){newInstanceCallback(newmyDatasourcePlugin(settings,updateCallback));}});varmyDatasourcePlugin=function(settings,updateCallback){varself=this;varcurrentSettings=settings;varcallback=(notification)=>{console.log(notification);updateCallback(notification.result);};varkuzzle=newKuzzleSDK.Kuzzle(newKuzzleSDK.WebSocket(currentSettings.kuzzle_host),{port: currentSettings.kuzzle_port,autoReconnect: true});kuzzle.on('networkError',error=>{console.error('Network Error: ',error);});kuzzle.on('connected',()=>{console.log('Successfully connected to Kuzzle');});kuzzle.connect().then(()=>{kuzzle.realtime.subscribe(currentSettings.kuzzle_index,currentSettings.kuzzle_collection,JSON.parse(currentSettings.kuzzle_subscribe_query),callback);}).then(()=>{console.log('Successfully subscribed to document notifications!');}).catch(error=>{console.error('Ooops! An error occurred: ',error);kuzzle.disconnect();});self.onSettingsChanged=function(newSettings){currentSettings=newSettings;};self.updateNow=function(){console.log("Pub/Sub model does not allow to update on demand.");};self.onDispose=function(){kuzzle.disconnect();};};})();
The text was updated successfully, but these errors were encountered:
@Aschen
Yeah, of course!
Give me a couple of days and I'll enhance it a little bit to make it as useful for any general scenario as possible and then submit that PR.
Thanks!
Tried to use this in a production environment and after some debugging i found out that the code is outdated regarding how to use Kuzzle-SDK in vanilla js.
Here is the new code so you can update it:
The text was updated successfully, but these errors were encountered: