Skip to content

Commit

Permalink
Fixed some issues on the sidebar.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasiek committed Jun 17, 2016
1 parent 7e72c5b commit 79966e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions octoprint_cost/static/js/cost.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ $(function() {
filesState.getAdditionalData = function(data) {
var output = originalGetAdditionalData(data);

var currency = settingsState.settings.plugins.cost.currency();
var cost_per_meter = settingsState.settings.plugins.cost.cost_per_meter();
var cost_per_hour = settingsState.settings.plugins.cost.cost_per_hour();
if (data.hasOwnProperty('gcodeAnalysis')) {
var gcode = data.gcodeAnalysis;
if (gcode.hasOwnProperty('filament') && gcode.filament.hasOwnProperty('tool0') && gcode.hasOwnProperty('estimatedPrintTime')) {
var currency = settingsState.settings.plugins.cost.currency();
var cost_per_meter = settingsState.settings.plugins.cost.cost_per_meter();
var cost_per_hour = settingsState.settings.plugins.cost.cost_per_hour();

var filament_used_meters = data["gcodeAnalysis"]["filament"]["tool0"].length / 1000;
var expected_time_hours = data["gcodeAnalysis"]["estimatedPrintTime"] / 3600;
var filament_used_meters = gcode.filament.tool0.length / 1000;
var expected_time_hours = gcode.estimatedPrintTime / 3600;

var totalCost = cost_per_meter * filament_used_meters + expected_time_hours * cost_per_hour;
var totalCost = cost_per_meter * filament_used_meters + expected_time_hours * cost_per_hour;

output += gettext("Cost") + ": " + currency + totalCost.toFixed(2);;
output += gettext("Cost") + ": " + currency + totalCost.toFixed(2);
}
}

return output;
};

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-Cost"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.1.1"
plugin_version = "0.1.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 79966e3

Please sign in to comment.