Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the possibility to add margin to button #23

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion octoprint_simpleemergencystop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def get_settings_defaults(self):
return dict(
emergencyGCODE="M112",
confirmationDialog=False,
big_button=False
big_button=False,
enableMargin=False,
marginValue=0,
)

def on_settings_save(self, data):
Expand Down
24 changes: 21 additions & 3 deletions octoprint_simpleemergencystop/static/js/simpleemergencystop.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,33 @@ $(function () {
return user.permissions.includes("control") || user.needs.role.includes("control");
}
else return true;

}

this.ses_margin_css = function () {
if (this.settings.enableMargin()) {
$('#ses_wrapper').css({
'margin-left':`${this.settings.marginValue()}px`,
'margin-right':`${this.settings.marginValue()}px`
});
} else {
$('#ses_wrapper').css({
'margin-left':'0px',
'margin-right':'0px'
});
}
};

this.ses_visible = function () {
return this.loginState.isUser() && this.hasControlPermition();
};

this.big_button_visible = function () {
return this.loginState.isUser() && this.settings.big_button() && this.hasControlPermition();
return this.settings.big_button();
};

this.little_button_visible = function () {
return this.loginState.isUser() && !this.settings.big_button() && this.hasControlPermition();
return !this.settings.big_button();
};

this.can_send_command = function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<div>
<a data-bind="click: click, css: little_button_css(), attr: { title: get_title() }, visible: little_button_visible()"
href="#">
<span class="fa-stack">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-hand-paper fa-stack-1x fa-inverse"></i>
</span>
</a>
</div>

<div>
<a data-bind="click: click, css: big_button_css(), attr: { title: get_title() }, visible: big_button_visible()"
href="#">
<div class="ses_big_middle">
<span class="fa-stack">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-hand-paper fa-stack-1x fa-inverse"></i>
</span>
<h5>{{ _("Emergency Stop") }}</h5>
<div id="ses_wrapper" data-bind="css: ses_margin_css(), visible: ses_visible()">
<div>
<a data-bind="click: click, css: little_button_css(), attr: { title: get_title() }, visible: little_button_visible()"
href="#">
<span class="fa-stack">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-hand-paper fa-stack-1x fa-inverse"></i>
</span>
</div>
</a>
</a>
</div>

<div>
<a data-bind="click: click, css: big_button_css(), attr: { title: get_title() }, visible: big_button_visible()"
href="#">
<div class="ses_big_middle">
<span class="fa-stack">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-hand-paper fa-stack-1x fa-inverse"></i>
</span>
<h5>{{ _("Emergency Stop") }}</h5>
<span class="fa-stack">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-hand-paper fa-stack-1x fa-inverse"></i>
</span>
</div>
</a>
</div>
</div>

<div id="confirmation" class="modal hide fade">
Expand All @@ -43,4 +45,4 @@
_("Proceed")
}}</a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="control-group">
<label class="control-label">{{ _('Emergency GCODE:') }}</label>
<div class="controls">
<input type="text" class="input-block-level"
<input type="text" class=""
data-bind="value: settings.plugins.simpleemergencystop.emergencyGCODE">
</div>
</div>
Expand All @@ -19,6 +19,21 @@
<input type="checkbox" data-bind="checked: settings.plugins.simpleemergencystop.big_button">
</div>
</div>


<div class="control-group">
<label class="control-label">{{ _('Enable margin') }}</label>
<div class="controls">
<input type="checkbox" data-bind="checked: settings.plugins.simpleemergencystop.enableMargin">
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Margin value:') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" class="" step="5" min="0" data-bind="
value: settings.plugins.simpleemergencystop.marginValue,
enable: settings.plugins.simpleemergencystop.enableMargin()">
<span class="add-on">px</span>
</div>
</div>
</div>
</form>