Skip to content

Commit

Permalink
Merge pull request #197 from benlye/disable-accept
Browse files Browse the repository at this point in the history
Make the 'accept' attribute optional on the file selector for mobile browser compatibility
  • Loading branch information
benlye authored Feb 8, 2021
2 parents 0e90022 + b4908ec commit 09c8798
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def get_settings_defaults(self):
"enable_postflash_gcode": None,
"enable_preflash_gcode": None,
"disable_bootloadercheck": None,
"disable_filefilter": False,
"save_url": False,
"last_url": None,
"plugin_version": self._plugin_version
Expand Down
15 changes: 15 additions & 0 deletions octoprint_firmwareupdater/static/js/firmwareupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ $(function() {
self.configPreflashGcode = ko.observable();
self.configSaveUrl = ko.observable();
self.configLastUrl = ko.observable();
self.configDisableFileFilter = ko.observable();
self.pluginVersion = ko.observable();

self.filterFileTypes = ko.computed(function() {
if (self.configDisableFileFilter()) {
return null;
} else {
return '.hex,.bin';
}
});

// Config settings for avrdude
self.configAvrdudeMcu = ko.observable();
self.configAvrdudePath = ko.observable();
Expand Down Expand Up @@ -151,6 +160,7 @@ $(function() {
}

self.marlinbftHasCapability(self.settingsViewModel.settings.plugins.firmwareupdater.marlinbft_hascapability());
self.configDisableFileFilter(self.settingsViewModel.settings.plugins.firmwareupdater.disable_filefilter());
self.pluginVersion(self.settingsViewModel.settings.plugins.firmwareupdater.plugin_version());
}

Expand Down Expand Up @@ -589,6 +599,10 @@ $(function() {
self.configDisableBootloaderCheck(self.settingsViewModel.settings.plugins.firmwareupdater.disable_bootloadercheck());
}

if (self.settingsViewModel.settings.plugins.firmwareupdater.disable_filefilter() != 'false') {
self.configDisableFileFilter(self.settingsViewModel.settings.plugins.firmwareupdater.disable_filefilter());
}

// Load the avrdude settings
self.configAvrdudePath(self.settingsViewModel.settings.plugins.firmwareupdater.avrdude_path());
self.configAvrdudeConfigFile(self.settingsViewModel.settings.plugins.firmwareupdater.avrdude_conf());
Expand Down Expand Up @@ -699,6 +713,7 @@ $(function() {
enable_preflash_gcode: self.configEnablePreflashGcode(),
disable_bootloadercheck: self.configDisableBootloaderCheck(),
save_url: self.configSaveUrl(),
disable_filefilter: self.configDisableFileFilter(),
last_url: lastUrl,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<span class="span3">
<span class="btn input-group-btn fileinput-button">
<span>{{ _('Browse...') }}</span>
<input id="settings_firmwareupdater_selectFilePath" type="file" name="file" data-bind='attr: { accept: ".hex,.bin" }' data-url="{{ url_for("plugin.firmwareupdater.flash_firmware") }}">
<input id="settings_firmwareupdater_selectFilePath" type="file" name="file" data-bind='attr: { accept: filterFileTypes }' data-url="{{ url_for("plugin.firmwareupdater.flash_firmware") }}">
</span>
</span>
<span class="span9">
Expand Down Expand Up @@ -599,6 +599,15 @@
<span class="help-block">{{ _('Last URL will be remembered when using \'Flash from URL\'.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Disable file filter') }}</label>
<div class="controls">
<div class="input">
<input type="checkbox" class="input-block-level" data-bind="checked: configDisableFileFilter">
</div>
<span class="help-block">{{ _('Disable the file extension filters when selecting a file for \'Flash from file\'. (For compatibility browsers which do not support the \'accept\' attribute.)') }}</span>
</div>
</div>
</div>
</form>
<div class="pull-right" style="font-size:12px; opacity:0.6">Plugin Version: <span data-bind="text: pluginVersion"></span></div>
Expand Down
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.8.1b0"
plugin_version = "1.8.1b1"

# 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 09c8798

Please sign in to comment.