diff --git a/pluginHandler.js b/pluginHandler.js index 3d1e7e08..47f561b6 100644 --- a/pluginHandler.js +++ b/pluginHandler.js @@ -51,8 +51,8 @@ module.exports.pluginHandler = function (parent) { parent.db.updatePlugin(plugin._id, plugin_config); } catch (e) { console.log("Plugin config file for " + plugin.name + " could not be parsed."); } } - obj.parent.updateMeshCore(); // db calls are delayed, lets inject here once we're ready }); + obj.parent.updateMeshCore(); // db calls are async, lets inject here once we're ready }); } else { obj.loadList.forEach(function (plugin, index) { @@ -88,17 +88,26 @@ module.exports.pluginHandler = function (parent) { } } }; - + // accepts a function returning an object or an object with { tabId: "yourTabIdValue", tabTitle: "Your Tab Title" } obj.registerPluginTab = function(pluginRegInfo) { - var d = pluginRegInfo(); + var d = null; + if (typeof pluginRegInfo == 'function') d = pluginRegInfo(); + else d = pluginRegInfo; + if (d.tabId == null || d.tabTitle == null) { return false; } if (!Q(d.tabId)) { - QA('p19headers', ''+d.tabTitle+''); + var defaultOn = 'class="on"'; + if (Q('p19headers').querySelectorAll("span.on").length) defaultOn = ''; + QA('p19headers', ''+d.tabTitle+''); + QA('p19pages', '
'); } }; - obj.callPluginPage = function(id) { + obj.callPluginPage = function(id, el) { var pages = Q('p19pages').querySelectorAll("#p19pages>div"); for (const i of pages) { i.style.display = 'none'; } QV(id, true); + var tabs = Q('p19headers').querySelectorAll("span"); + for (const i of tabs) { i.classList.remove('on'); } + el.classList.add('on'); }; obj.addPluginEx = function() { meshserver.send({ action: 'addplugin', url: Q('pluginurlinput').value}); diff --git a/plugin_development.md b/plugin_development.md index d5572255..83a66f2c 100644 --- a/plugin_development.md +++ b/plugin_development.md @@ -60,7 +60,7 @@ These are separated into the following categories depending on the type of funct ### Web UI Hooks `onDeviceRefeshEnd`: called when a device is selected in the MeshCentral web interface -`registerPluginTab`: called when a device is selected in the MeshCentral web interface to register a new tab for plugin data, if required +`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 #### Exports diff --git a/public/styles/style.css b/public/styles/style.css index 4f103582..097d6d7e 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -2645,3 +2645,24 @@ a { width: 100%; height: 100%; } + +#p19headers { + padding-right: 7px; + padding-bottom: 10px; + font-weight: bold; + border-bottom: 1px dotted blue; +} + +#p19headers > span:nth-child(n+2) { + border-left: 1px solid black; +} + +#p19headers > span { + padding-left: 4px; + padding-right: 4px; + cursor: pointer; + font-weight: lighter; +} +#p19headers > span.on { + font-weight: bold; +} diff --git a/views/default.handlebars b/views/default.handlebars index 24759e6f..b900f591 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -895,23 +895,6 @@