🌈 style: extend navbar tooltip

- extend the navbar tooltip for long messages
- add logmessages/PopUp for more messages
This commit is contained in:
thelastWallE 2021-10-07 00:59:23 +02:00
parent 3c940bb786
commit 0b5f86f29f
4 changed files with 34 additions and 17 deletions

View File

@ -355,18 +355,18 @@ class KlipperPlugin(
def on_event(self, event, payload):
if event == "UserLoggedIn":
util.update_status(self, "info", "Klipper: Standby")
logger.log_info(self, "Klipper: Standby")
if event == "Connecting":
util.update_status(self, "info", "Klipper: Connecting ...")
logger.log_info(self, "Klipper: Connecting ...")
elif event == "Connected":
util.update_status(self, "info", "Klipper: Connected to host")
logger.log_info(self, "Klipper: Connected to host")
logger.log_info(
self,
"Connected to host via {} @{}bps".format(payload["port"], payload["baudrate"]))
elif event == "Disconnected":
util.update_status(self, "info", "Klipper: Disconnected from host")
logger.log_info(self, "Klipper: Disconnected from host")
elif event == "Error":
util.update_status(self, "error", "Klipper: Error")
logger.log_error(self, payload["error"])
def processAtCommand(self, comm_instance, phase, command, parameters, tags=None, *args, **kwargs):
@ -398,7 +398,6 @@ class KlipperPlugin(
self._parsing_response = True
elif "!!" in line:
msg = line.strip('!')
util.update_status(self, "error", msg)
logger.log_error(self, msg)
self.write_parsing_response_buffer()
else:

View File

@ -33,6 +33,7 @@ $(function () {
self.access = parameters[5];
self.shortStatus_navbar = ko.observable();
self.shortStatus_navbar_hover = ko.observable();
self.shortStatus_sidebar = ko.observable();
self.logMessages = ko.observableArray();
@ -142,40 +143,57 @@ $(function () {
};
self.onDataUpdaterPluginMessage = function (plugin, data) {
if (plugin == "klipper") {
switch (data.type) {
case "PopUp":
self.showPopUp(data.subtype, data.title, data.payload);
break;
case "start":
break;
case "reload":
break;
case "console":
self.consoleMessage(data.subtype, data.payload);
break;
case "status":
if (data.payload.length > 36) {
var shortText = data.payload.substring(0, 31) + " [..]";
self.shortStatus_navbar(shortText);
} else {
self.shortStatus_navbar(data.payload);
}
self.shortStatus_sidebar(data.payload);
self.shortStatus(data.payload, data.subtype);
break;
default:
self.logMessage(data.time, data.subtype, data.payload);
self.shortStatus(data.payload, data.subtype)
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) {
if (!timestamp) {
var today = new Date();
var timestamp =
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
}
if (type == "error") {
self.showPopUp(type, "Error:", message);
}
self.logMessages.push({
time: timestamp,
type: type,

View File

@ -1,3 +1,3 @@
<!-- 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 -->

View File

@ -7,7 +7,7 @@
</div>
</div>
<!-- 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>
</div>
<!-- /ko -->