🌈 style: extend navbar tooltip
- extend the navbar tooltip for long messages - add logmessages/PopUp for more messages
This commit is contained in:
parent
3c940bb786
commit
0b5f86f29f
|
@ -355,18 +355,18 @@ class KlipperPlugin(
|
||||||
|
|
||||||
def on_event(self, event, payload):
|
def on_event(self, event, payload):
|
||||||
if event == "UserLoggedIn":
|
if event == "UserLoggedIn":
|
||||||
util.update_status(self, "info", "Klipper: Standby")
|
logger.log_info(self, "Klipper: Standby")
|
||||||
if event == "Connecting":
|
if event == "Connecting":
|
||||||
util.update_status(self, "info", "Klipper: Connecting ...")
|
logger.log_info(self, "Klipper: Connecting ...")
|
||||||
elif event == "Connected":
|
elif event == "Connected":
|
||||||
util.update_status(self, "info", "Klipper: Connected to host")
|
logger.log_info(self, "Klipper: Connected to host")
|
||||||
logger.log_info(
|
logger.log_info(
|
||||||
self,
|
self,
|
||||||
"Connected to host via {} @{}bps".format(payload["port"], payload["baudrate"]))
|
"Connected to host via {} @{}bps".format(payload["port"], payload["baudrate"]))
|
||||||
elif event == "Disconnected":
|
elif event == "Disconnected":
|
||||||
util.update_status(self, "info", "Klipper: Disconnected from host")
|
logger.log_info(self, "Klipper: Disconnected from host")
|
||||||
|
|
||||||
elif event == "Error":
|
elif event == "Error":
|
||||||
util.update_status(self, "error", "Klipper: Error")
|
|
||||||
logger.log_error(self, payload["error"])
|
logger.log_error(self, payload["error"])
|
||||||
|
|
||||||
def processAtCommand(self, comm_instance, phase, command, parameters, tags=None, *args, **kwargs):
|
def processAtCommand(self, comm_instance, phase, command, parameters, tags=None, *args, **kwargs):
|
||||||
|
@ -398,7 +398,6 @@ class KlipperPlugin(
|
||||||
self._parsing_response = True
|
self._parsing_response = True
|
||||||
elif "!!" in line:
|
elif "!!" in line:
|
||||||
msg = line.strip('!')
|
msg = line.strip('!')
|
||||||
util.update_status(self, "error", msg)
|
|
||||||
logger.log_error(self, msg)
|
logger.log_error(self, msg)
|
||||||
self.write_parsing_response_buffer()
|
self.write_parsing_response_buffer()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -33,6 +33,7 @@ $(function () {
|
||||||
self.access = parameters[5];
|
self.access = parameters[5];
|
||||||
|
|
||||||
self.shortStatus_navbar = ko.observable();
|
self.shortStatus_navbar = ko.observable();
|
||||||
|
self.shortStatus_navbar_hover = ko.observable();
|
||||||
self.shortStatus_sidebar = ko.observable();
|
self.shortStatus_sidebar = ko.observable();
|
||||||
self.logMessages = ko.observableArray();
|
self.logMessages = ko.observableArray();
|
||||||
|
|
||||||
|
@ -142,40 +143,57 @@ $(function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.onDataUpdaterPluginMessage = function (plugin, data) {
|
self.onDataUpdaterPluginMessage = function (plugin, data) {
|
||||||
|
|
||||||
if (plugin == "klipper") {
|
if (plugin == "klipper") {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "PopUp":
|
case "PopUp":
|
||||||
self.showPopUp(data.subtype, data.title, data.payload);
|
self.showPopUp(data.subtype, data.title, data.payload);
|
||||||
break;
|
break;
|
||||||
case "start":
|
|
||||||
break;
|
|
||||||
case "reload":
|
case "reload":
|
||||||
break;
|
break;
|
||||||
case "console":
|
case "console":
|
||||||
self.consoleMessage(data.subtype, data.payload);
|
self.consoleMessage(data.subtype, data.payload);
|
||||||
break;
|
break;
|
||||||
case "status":
|
case "status":
|
||||||
if (data.payload.length > 36) {
|
self.shortStatus(data.payload, data.subtype);
|
||||||
var shortText = data.payload.substring(0, 31) + " [..]";
|
|
||||||
self.shortStatus_navbar(shortText);
|
|
||||||
} else {
|
|
||||||
self.shortStatus_navbar(data.payload);
|
|
||||||
}
|
|
||||||
self.shortStatus_sidebar(data.payload);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
self.logMessage(data.time, data.subtype, data.payload);
|
self.logMessage(data.time, data.subtype, data.payload);
|
||||||
|
self.shortStatus(data.payload, data.subtype)
|
||||||
self.consoleMessage(data.subtype, data.payload);
|
self.consoleMessage(data.subtype, data.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
self.shortStatus = function(msg, type) {
|
||||||
|
|
||||||
|
var baseText = gettext("Go to OctoKlipper Tab");
|
||||||
|
if (msg.length > 36) {
|
||||||
|
var shortText = msg.substring(0, 31) + " [..]";
|
||||||
|
self.shortStatus_navbar(shortText);
|
||||||
|
self.shortStatus_navbar_hover(msg);
|
||||||
|
} else {
|
||||||
|
self.shortStatus_navbar(msg);
|
||||||
|
self.shortStatus_navbar_hover(baseText);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.shortStatus_sidebar(msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
self.logMessage = function (timestamp, type = "info", message) {
|
self.logMessage = function (timestamp, type = "info", message) {
|
||||||
|
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
var timestamp =
|
var timestamp =
|
||||||
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == "error") {
|
||||||
|
self.showPopUp(type, "Error:", message);
|
||||||
|
}
|
||||||
|
|
||||||
self.logMessages.push({
|
self.logMessages.push({
|
||||||
time: timestamp,
|
time: timestamp,
|
||||||
type: type,
|
type: type,
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<!-- ko if: settings.settings.plugins.klipper.configuration.shortStatus_navbar -->
|
<!-- ko if: settings.settings.plugins.klipper.configuration.shortStatus_navbar -->
|
||||||
<a title="{{ _('Go to OctoKlipper Tab') }}" data-bind="text: shortStatus_navbar, click: navbarClicked"></a>
|
<a data-bind="attr: { title: shortStatus_navbar_hover }, text: shortStatus_navbar, click: navbarClicked"></a>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ko if: settings.settings.plugins.klipper.configuration.shortStatus_sidebar -->
|
<!-- ko if: settings.settings.plugins.klipper.configuration.shortStatus_sidebar -->
|
||||||
<div class="plugin-klipper-sidebar">
|
<div id="shortStatus_SideBar" class="plugin-klipper-sidebar">
|
||||||
<a title="{{ _('Go to OctoKlipper Tab') }}" data-bind="text: shortStatus_sidebar, click: navbarClicked"></a>
|
<a title="{{ _('Go to OctoKlipper Tab') }}" data-bind="text: shortStatus_sidebar, click: navbarClicked"></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
|
|
Loading…
Reference in New Issue