Skip to content

Commit

Permalink
Fix issue where ups may be set to null under certain conditions. #12
Browse files Browse the repository at this point in the history
  • Loading branch information
kantlivelong committed Mar 30, 2022
1 parent af03d83 commit 5d4cec9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion octoprint_ups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ def on_api_command(self, command, data):
res = ups.list_ups()
return jsonify(result=list(res.keys()))
except:
# TODO: Can be done diff? idk?
return make_response("Error getting UPS list", 500)


Expand Down
9 changes: 6 additions & 3 deletions octoprint_ups/static/js/ups.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,18 @@ $(function() {
}).done(function(data) {
console.log(data);
self.available_upses(data.result);
}).fail(function(data) {
console.warn("Failed fetching UPS list. Falling back to config value.");
alert("Unable to fetch UPS list.");

self.available_upses([self.settings.plugins.ups.ups()]);
});
};

self.onBeforeBinding = function() {
self.settings = self.settingsViewModel.settings;
};

self.onSettingsShown = function () {
self.updateUPSList();
self.available_upses([self.settings.plugins.ups.ups()]);
};

self.onDataUpdaterPluginMessage = function(plugin, data) {
Expand Down
2 changes: 1 addition & 1 deletion octoprint_ups/templates/ups_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="control-group">
<label class="control-label">UPS</label>
<div class="controls">
<select data-bind="options: available_upses, value: settings.plugins.ups.ups">
<select data-bind="options: available_upses, value: settings.plugins.ups.ups, click: function() { $root.updateUPSList(); }">
</select>
<a title="Refresh" href="#" data-bind="click: function() { $root.updateUPSList(); }">
<i class="icon-refresh"></i>
Expand Down

0 comments on commit 5d4cec9

Please sign in to comment.