Skip to content

Commit

Permalink
Fix graph style missing on themed installations
Browse files Browse the repository at this point in the history
Can't get Background graph line color to change #75
  • Loading branch information
LazeMSS committed Dec 11, 2022
1 parent 08ef15b commit 90790e3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions octoprint_toptemp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self):
'graphSettings': {
'height': 50,
'show': True,
'forceStyle': False,
'opa': 0.2,
'width': 1,
'color' : '#000000',
Expand Down
17 changes: 16 additions & 1 deletion octoprint_toptemp/static/js/TopTemp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,10 +1544,25 @@ $(function() {

// Add CSS for the graphs
self.setGraphStyle = function(name,settings){
var important = "";
if (settings.forceStyle()){
important = " !important";
}
// Remove old
$('#TopTempGraph_'+name+'_style').remove();

var styleSet = `
#TopTempGraph_${name}_graph{
height:${settings.height()}%${important};
}
#TopTempGraph_${name}_graph.TopTempGraph > svg >g .ct-line{
stroke-width: ${settings.width()}px${important};
stroke-opacity: ${settings.opa()}${important};
stroke: ${settings.color()}${important};
}`;

// Build new
$('head').append('<style id="TopTempGraph_'+name+'_style">\n#TopTempGraph_'+name+'_graph{\nheight:'+settings.height()+'%\n}\n#TopTempGraph_'+name+'_graph.TopTempGraph > svg >g .ct-line{\nstroke-width: '+settings.width()+'px;\nstroke-opacity: '+settings.opa()+';\nstroke: '+settings.color()+';\n}\n</style>' );
$('head').append('<style id="TopTempGraph_'+name+'_style">\n'+styleSet+'</style>');
// Show the graph?
if (settings.show){
$('#TopTempGraph_'+name+'_graph').show();
Expand Down
28 changes: 28 additions & 0 deletions octoprint_toptemp/templates/toptemp_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@
</div>
</div>
<div class="TopTempGraphSetting" data-bind="visible: settings.plugins.toptemp.bed.graphSettings.show">
<div class="control-group" title="Overrule any themeing styles with these settings">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.toptemp.bed.graphSettings.forceStyle"> {{ _('Overrule themeing') }}
</label>
</div>
</div>
<div class="control-group" title="Graph transparency">
<label class="control-label">Graph transparency</label>
<div class="controls">
Expand Down Expand Up @@ -353,6 +360,13 @@
</div>
</div>
<div class="TopTempGraphSetting" data-bind="visible: settings.plugins.toptemp.chamber.graphSettings.show">
<div class="control-group" title="Overrule any themeing styles with these settings">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.toptemp.chamber.graphSettings.forceStyle"> {{ _('Overrule themeing') }}
</label>
</div>
</div>
<div class="control-group" title="Graph transparency">
<label class="control-label">Graph transparency</label>
<div class="controls">
Expand Down Expand Up @@ -514,6 +528,13 @@
</div>
</div>
<div class="TopTempGraphSetting" data-bind="visible: $parent.settings.plugins.toptemp['tool'+$index()].graphSettings.show">
<div class="control-group" title="Overrule any themeing styles with these settings">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: $parent.settings.plugins.toptemp['tool'+$index()].graphSettings.forceStyle"> {{ _('Overrule themeing') }}
</label>
</div>
</div>
<div class="control-group" title="Graph transparency">
<label class="control-label">Graph transparency</label>
<div class="controls">
Expand Down Expand Up @@ -729,6 +750,13 @@
</div>
</div>
<div class="TopTempGraphSetting" data-visible="graphSettings.show">
<div class="control-group" title="Overrule any themeing styles with these settings">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-settings="graphSettings.forceStyle"> {{ _('Overrule themeing') }}
</label>
</div>
</div>
<div class="control-group" title="Graph transparency">
<label class="control-label">Graph transparency</label>
<div class="controls">
Expand Down

0 comments on commit 90790e3

Please sign in to comment.