Skip to content

Commit

Permalink
Merge pull request #155 from OctoPrint/navbar-icon
Browse files Browse the repository at this point in the history
Add a navbar icon for accessing the firmware updater
  • Loading branch information
benlye authored Nov 27, 2020
2 parents 53adb61 + c8902c9 commit 4cd8b5a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def _flash_worker(self, method, firmware, printer_port):
def get_settings_defaults(self):
return {
"flash_method": None,
"enable_navbar": False,
"avrdude_path": None,
"avrdude_conf": None,
"avrdude_avrmcu": None,
Expand Down
20 changes: 18 additions & 2 deletions octoprint_firmwareupdater/static/js/firmwareupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ $(function() {
self.loginState = parameters[1];
self.connection = parameters[2];
self.printerState = parameters[3];
self.access = parameters[4];

// General settings
self.configFlashMethod = ko.observable();
self.configShowNavbarIcon = ko.observable();
self.showFirmwareUpdaterNavbarIcon = ko.observable(false);
self.showAdvancedConfig = ko.observable(false);
self.showAvrdudeConfig = ko.observable(false);
self.showBossacConfig = ko.observable(false);
Expand Down Expand Up @@ -123,6 +126,17 @@ $(function() {

self.inSettingsDialog = false;

self.onAllBound = function(allViewModels) {
self.configShowNavbarIcon(self.settingsViewModel.settings.plugins.firmwareupdater.enable_navbar());
if (self.loginState.isAdmin() && self.configShowNavbarIcon()) {
self.showFirmwareUpdaterNavbarIcon(true);
}
}

self.showFirmwareUpdater = function(){
self.settingsViewModel.show("#settings_plugin_firmwareupdater");
}

self.connection.selectedPort.subscribe(function(value) {
if (value === undefined) return;
self.flashPort(value);
Expand Down Expand Up @@ -437,6 +451,7 @@ $(function() {
self.showPluginConfig = function() {
// Load the general settings
self.configFlashMethod(self.settingsViewModel.settings.plugins.firmwareupdater.flash_method());
self.configShowNavbarIcon(self.settingsViewModel.settings.plugins.firmwareupdater.enable_navbar());
self.configPreflashCommandline(self.settingsViewModel.settings.plugins.firmwareupdater.preflash_commandline());
self.configPostflashCommandline(self.settingsViewModel.settings.plugins.firmwareupdater.postflash_commandline());
self.configPostflashDelay(self.settingsViewModel.settings.plugins.firmwareupdater.postflash_delay());
Expand Down Expand Up @@ -526,6 +541,7 @@ $(function() {
plugins: {
firmwareupdater: {
flash_method: self.configFlashMethod(),
enable_navbar: self.configShowNavbarIcon(),
avrdude_path: self.configAvrdudePath(),
avrdude_conf: self.configAvrdudeConfigFile(),
avrdude_avrmcu: self.configAvrdudeMcu(),
Expand Down Expand Up @@ -841,7 +857,7 @@ $(function() {

OCTOPRINT_VIEWMODELS.push([
FirmwareUpdaterViewModel,
["settingsViewModel", "loginStateViewModel", "connectionViewModel", "printerStateViewModel"],
[document.getElementById("settings_plugin_firmwareupdater")]
["settingsViewModel", "loginStateViewModel", "connectionViewModel", "printerStateViewModel", "accessViewModel"],
["#settings_plugin_firmwareupdater", "#navbar_plugin_firmwareupdater"]
]);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="javascript:void(0)" data-bind="visible: showFirmwareUpdaterNavbarIcon, click: showFirmwareUpdater"><i class="fas fa-microchip" title="Firmware Updater"></i></a>
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@
</div>
<!-- end stm32flash options -->

<div class="control-group">
<label class="control-label">{{ _('Enable navbar icon') }}</label>
<div class="controls">
<div class="input">
<input type="checkbox" class="input-block-level" data-bind="checked: configShowNavbarIcon">
</div>
<span class="help-block">{{ _('Enables a link to the Firmware Updater in the OctoPrint navbar. (Reload after enabling/disabling.)') }}</span>
</div>
</div>
<hr>

<!-- advanced options -->

<div data-bind="visible: !showAdvancedConfig() && (showAvrdudeConfig() || showBossacConfig() || showLpc1768Config() || showDfuConfig() || showStm32flashConfig())">
Expand Down Expand Up @@ -547,4 +558,3 @@
</div>
</div>
</div>

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-FirmwareUpdater"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.7.1"
plugin_version = "1.7.2"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 4cd8b5a

Please sign in to comment.