From e7e95322559ba2a77ea77ffd89bd1c402f44d16d Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Thu, 26 Dec 2019 10:45:14 -0500 Subject: [PATCH 1/6] fix internal arg passing --- pluginHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pluginHandler.js b/pluginHandler.js index a1659051..c0d595b4 100644 --- a/pluginHandler.js +++ b/pluginHandler.js @@ -137,7 +137,7 @@ module.exports.pluginHandler = function (parent) { for (var p in obj.plugins) { if (typeof obj.plugins[p][hookName] == 'function') { try { - obj.plugins[p][hookName](args); + obj.plugins[p][hookName](...args); } catch (e) { console.log("Error ocurred while running plugin hook" + p + ':' + hookName + ' (' + e + ')'); } From 07c8fd29902c44e5a0251c4681fcc788169ac0fe Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Thu, 26 Dec 2019 10:45:51 -0500 Subject: [PATCH 2/6] Add plugin hook for user login --- meshuser.js | 1 + 1 file changed, 1 insertion(+) diff --git a/meshuser.js b/meshuser.js index d9e8dfee..8d0769a7 100644 --- a/meshuser.js +++ b/meshuser.js @@ -402,6 +402,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // We are all set, start receiving data ws._socket.resume(); + if (parent.parent.pluginHandler != null) parent.parent.pluginHandler.callHook('userLoggedIn_end', user); }); } catch (e) { console.log(e); } From 8ffdaec668a82708f5fe4d775f197115fe10252e Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Thu, 26 Dec 2019 10:46:56 -0500 Subject: [PATCH 3/6] Add webUI startup hook --- views/default.handlebars | 1 + 1 file changed, 1 insertion(+) diff --git a/views/default.handlebars b/views/default.handlebars index 66be1c47..53168dd6 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1243,6 +1243,7 @@ d4EditSizeVal = getstore('editorSize', 0); d4ToggleWrap(true); d4ToggleSize(true); + if (pluginHandler != null) pluginHandler.callHook('onWebUIStartup_end'); } function adjustPanels() { From 29d294eac59a6cd10db026e392616cb39462401d Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Thu, 26 Dec 2019 10:52:48 -0500 Subject: [PATCH 4/6] Consistency in call names --- views/default.handlebars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/default.handlebars b/views/default.handlebars index 53168dd6..af6a81e8 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1243,7 +1243,7 @@ d4EditSizeVal = getstore('editorSize', 0); d4ToggleWrap(true); d4ToggleSize(true); - if (pluginHandler != null) pluginHandler.callHook('onWebUIStartup_end'); + if (pluginHandler != null) pluginHandler.callHook('onWebUIStartupEnd'); } function adjustPanels() { From 26de76579c1789ad04138f7f6bf8acc32d641fe2 Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Thu, 26 Dec 2019 10:55:03 -0500 Subject: [PATCH 5/6] Consistency in call names hook_userLoggedInEnd --- meshuser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshuser.js b/meshuser.js index 8d0769a7..9282bb6b 100644 --- a/meshuser.js +++ b/meshuser.js @@ -402,7 +402,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // We are all set, start receiving data ws._socket.resume(); - if (parent.parent.pluginHandler != null) parent.parent.pluginHandler.callHook('userLoggedIn_end', user); + if (parent.parent.pluginHandler != null) parent.parent.pluginHandler.callHook('hook_userLoggedIn', user); }); } catch (e) { console.log(e); } From d5fb308caa082959cc1d97c9e5286e7c1c1318bc Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Thu, 26 Dec 2019 10:56:10 -0500 Subject: [PATCH 6/6] Documentation updates for new hooks --- plugin_development.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin_development.md b/plugin_development.md index 83a66f2c..a3015873 100644 --- a/plugin_development.md +++ b/plugin_development.md @@ -62,6 +62,7 @@ These are separated into the following categories depending on the type of funct `onDeviceRefeshEnd`: called when a device is selected in the MeshCentral web interface `registerPluginTab`: callable when a device is selected in the MeshCentral web interface to register a new tab for plugin data, if required. Accepts an object, or function that returns an object, with the following properties: { tabId: "yourShortNameHere", tabTitle: "Your Display Name"}. A tab and div with the associated ID and title will be created for your use `onDesktopDisconnect`: called when a remote desktop session is disconnected +`onWebUIStartupEnd`: called when the page has loaded for the first time after a login / refresh #### Exports Any function can be exported to the Web UI layer by adding the name of the function to an `exports` array in the plugin object. @@ -70,6 +71,7 @@ Any function can be exported to the Web UI layer by adding the name of the funct `server_startup`: called once when the server starts (or when the plugin is first installed) `hook_agentCoreIsStable`: called once when an agent initially checks in `hook_processAgentData`: called each time an agent transmits data back to the server +`hook_userLoggedIn`: called when a user has logged into the web interface ### Mesh Agent Use of the optional file `plugin_name.js` in the optional folder `modules_meshcore` will include the file in the default meshcore file sent to each endpoint. This is useful to add functionality on each of the endpoints.