benlye
November 27, 2020, 12:02pm
1
Is it possible to have a direct link to my plugin's settings from an icon in the nav bar?
I know how to add the icon, but can't work out how to open the settings modal and go directly to my plugin's settings page. Is such a link / action possible?
Here's how the ngrok plugin does it:
<li data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.PLUGIN_NGROK_CONTROL)">
<a href="javascript:void(0)" data-bind="
text: (tunnelName() != '') ? _('Close tunnel') : _('Create tunnel'),
click: function() { if (tunnelName() != '') { closeTunnel(); } else { connectTunnel(); } }
"></a>
</li>
<li data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.SETTINGS)" class="divider"></li>
<li data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.SETTINGS)">
<a href="https://dashboard.ngrok.com/" target="_blank">{{ _('ngrok dashboard...') }}</a></li>
<li data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.SETTINGS)">
<a href="javascript:void(0)" data-bind="click: showTunnelSettings;">{{ _('Tunnel settings...') }}</a>
</li>
</ul>
and
self.closeTunnel = function() {
OctoPrint.simpleApiCommand("ngrok", "close", {});
}
self.connectTunnel = function() {
self.settings.saveData();
OctoPrint.simpleApiCommand("ngrok", "connect", {});
}
self.showTunnelSettings = function() {
if (!self.loginState.hasPermission(self.access.permissions.SETTINGS)) {
return;
}
self.settings.show("#settings_plugin_ngrok");
}
self.requestData = function() {
OctoPrint.plugins.ngrok.get()
.done(function(response) {
self.tunnelName(response.tunnel);
2 Likes
benlye
November 27, 2020, 12:22pm
3
Thank you! Will look at that and figure it out