🚸 add option to hide PopUps for errors

This commit is contained in:
thelastWallE 2021-11-17 22:27:43 +01:00
parent 55f8d70687
commit 9b51db376f
3 changed files with 52 additions and 9 deletions

View File

@ -140,7 +140,8 @@ class KlipperPlugin(
shortStatus_navbar=True, shortStatus_navbar=True,
shortStatus_sidebar=True, shortStatus_sidebar=True,
parse_check=False, parse_check=False,
fontsize=12 fontsize=12,
hide_error_popups=False
) )
) )

View File

@ -37,19 +37,54 @@ $(function () {
self.shortStatus_sidebar = ko.observable(); self.shortStatus_sidebar = ko.observable();
self.logMessages = ko.observableArray(); self.logMessages = ko.observableArray();
self.popup = undefined;
self._showPopup = function (options) {
self._closePopup();
self.popup = new PNotify(options);
};
self._updatePopup = function (options) {
if (self.popup === undefined) {
self._showPopup(options);
} else {
self.popup.update(options);
}
};
self._closePopup = function () {
if (self.popup !== undefined) {
self.popup.remove();
}
};
self.showPopUp = function (popupType, popupTitle, message) { self.showPopUp = function (popupType, popupTitle, message) {
var title = "OctoKlipper: <br />" + popupTitle + "<br />"; var title = "OctoKlipper: <br />" + popupTitle + "<br />";
var hide = false; var options = undefined;
if (popupType == "success") { var errorOpts = {};
hide = true
} options = {
new PNotify({
title: title, title: title,
text: message, text: message,
type: popupType, type: popupType,
hide: hide, hide: true,
icon: true icon: true
}); };
if (popupType == "error") {
errorOpts = {
mouse_reset: true,
delay: 5000,
animation: "none"
};
FullOptions = Object.assign(options, errorOpts);
self._showPopup(FullOptions);
} else {
if (options !== undefined) {
new PNotify(options);
}
}
}; };
self.showEditorDialog = function () { self.showEditorDialog = function () {
@ -191,7 +226,7 @@ $(function () {
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
} }
if (type == "error") { if (type == "error" && self.settings.settings.plugins.klipper.configuration.hide_error_popups() !== true) {
self.showPopUp(type, "Error:", message); self.showPopUp(type, "Error:", message);
} }

View File

@ -37,6 +37,13 @@
data-bind="checked: settings.settings.plugins.klipper.configuration.debug_logging" /> data-bind="checked: settings.settings.plugins.klipper.configuration.debug_logging" />
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label">{{ _('Hide Error PopUps') }}</label>
<div class="controls">
<input class="controls-checkbox" title="{{ _('Hide Error PopUps') }}" type="checkbox"
data-bind="checked: settings.settings.plugins.klipper.configuration.hide_error_popups" />
</div>
</div>
<div class="control-group border"> <div class="control-group border">
<label class="control-label">{{ _('Config Editor') }}</label> <label class="control-label">{{ _('Config Editor') }}</label>
<div class="controls"> <div class="controls">