Merge pull request #762 from ryanblenis/plugin-admin

Additional hooks, better passing of arguments
This commit is contained in:
Ylian Saint-Hilaire 2019-12-26 11:03:42 -08:00 committed by GitHub
commit 9bebc913d9
4 changed files with 5 additions and 1 deletions

View File

@ -402,6 +402,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// We are all set, start receiving data // We are all set, start receiving data
ws._socket.resume(); ws._socket.resume();
if (parent.parent.pluginHandler != null) parent.parent.pluginHandler.callHook('hook_userLoggedIn', user);
}); });
} catch (e) { console.log(e); } } catch (e) { console.log(e); }

View File

@ -137,7 +137,7 @@ module.exports.pluginHandler = function (parent) {
for (var p in obj.plugins) { for (var p in obj.plugins) {
if (typeof obj.plugins[p][hookName] == 'function') { if (typeof obj.plugins[p][hookName] == 'function') {
try { try {
obj.plugins[p][hookName](args); obj.plugins[p][hookName](...args);
} catch (e) { } catch (e) {
console.log("Error ocurred while running plugin hook" + p + ':' + hookName + ' (' + e + ')'); console.log("Error ocurred while running plugin hook" + p + ':' + hookName + ' (' + e + ')');
} }

View File

@ -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 `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 `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 `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 #### 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. 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) `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_agentCoreIsStable`: called once when an agent initially checks in
`hook_processAgentData`: called each time an agent transmits data back to the server `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 ### 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. 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.

View File

@ -1243,6 +1243,7 @@
d4EditSizeVal = getstore('editorSize', 0); d4EditSizeVal = getstore('editorSize', 0);
d4ToggleWrap(true); d4ToggleWrap(true);
d4ToggleSize(true); d4ToggleSize(true);
if (pluginHandler != null) pluginHandler.callHook('onWebUIStartupEnd');
} }
function adjustPanels() { function adjustPanels() {