Skip to content

Commit

Permalink
Misc UI bug fixes (museumsvictoria#335)
Browse files Browse the repository at this point in the history
* Bugfix button within status block

* Possible fix for museumsvictoria#259

Proactively disconnect and reconnect websockets when visibility and/or connectivity changes

* Fix incorrect display of values in the log

* Fix dropdown not closing on navigation

* Allow icons in status blocks
  • Loading branch information
mcartmel authored Aug 5, 2024
1 parent 3b4f6d7 commit 71054c1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
8 changes: 4 additions & 4 deletions nodel-webui-js/src/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<ul class="dropdown-menu">
<xsl:for-each select="page">
<li>
<a role="button" data-nav="{translate(@title,translate(@title,$allowedSymbols,''),'')}" data-toggle="collapse" data-target="#nodel-navbar.in">
<a role="button" data-nav="{translate(@title,translate(@title,$allowedSymbols,''),'')}" data-toggle="dropdown" data-target="#nodel-navbar .dropdown.open">
<xsl:if test="@action">
<xsl:attribute name="data-action">
<xsl:value-of select="@action"/>
Expand All @@ -120,7 +120,7 @@
</xsl:if>
<xsl:if test="self::page">
<li>
<a role="button" data-nav="{translate(@title,translate(@title,$allowedSymbols,''),'')}" data-toggle="collapse" data-target="#nodel-navbar.in">
<a role="button" data-nav="{translate(@title,translate(@title,$allowedSymbols,''),'')}">
<xsl:if test="@action">
<xsl:attribute name="data-action">
<xsl:value-of select="@action"/>
Expand Down Expand Up @@ -764,8 +764,8 @@
<span class="logtitle">{^{>rawalias}}</span><span class="logtimestamp"> - {^{>~nicetime(timestamp)}}</span>
{^{if ~isset(arg)}}
<span class="logarg">
{^{if ~root.hold or ~root.flt}}
{^{:~jsonhighlight(~sanitize(arg, 250))}}
{^{if ~root.hold || ~root.flt}}
{^{:~jsonhighlight(~sanitize(arg, 250, true))}}
{{else}}
{^{:~sanitize(arg, 250)}}
{{/if}}
Expand Down
33 changes: 24 additions & 9 deletions nodel-webui-js/src/nodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,22 @@ $.views.helpers({
idxid: function (idx,id) {
return !_.isUndefined(idx)? String(idx)+'_'+id : id;
},
sanitize: function(value, maxLength) {
sanitize: function(value, maxLength, nostrip) {
var value = JSON.stringify(value, null, 2);
if (maxLength && value.length > maxLength) {
value = value.substring(0, maxLength ) + "...";
}
return value.replace(/[<>&]/g, function (c) {
switch (c) {
case '<': return '&lt;';
case '>': return '&gt;';
case '&': return '&amp;';
}
});
if(nostrip){
return value;
} else {
return value.replaceAll(/[<>&]/g, function (c) {
switch (c) {
case '<': return '&lt;';
case '>': return '&gt;';
case '&': return '&amp;';
}
});
}
},
nicetime: function (value, precise, format) {
if (precise) return moment(value).format('MM-DD HH:mm:ss.SS');
Expand Down Expand Up @@ -1270,7 +1274,6 @@ var setEvents = function(){
$("[data-section="+id+"]").show();
history.replaceState(undefined, undefined, '#'+id);
$("[data-section="+id+"]").find('.nodel-console').scrollTop(999999);
return false;
});
$('body').on('click', '#confirmkeypad *[data-keypad]', function () {
var number = $(this).data('keypad');
Expand Down Expand Up @@ -2543,6 +2546,18 @@ var updateLogs = function(){
offline();
$('body').data('update', setTimeout(function() { updateLogs(); }, 1000));
}
// proactively disconnect websocket when the page is not being viewed
$(document).off("visibilitychange.socket").on("visibilitychange.socket", function() {
if(document.hidden) socket.close();
else updateLogs();
});
// proactively disconnect when network is disconnected
$(window).off("offline.socket").on("offline.socket", function() {
socket.close();
});
$(window).off("online.socket").on("online.socket", function() {
if(!document.hidden) updateLogs();
});
} catch(exception){
console.log('Error: '+exception);
offline();
Expand Down
2 changes: 1 addition & 1 deletion nodel-webui-js/src/templates.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@
</xsl:attribute>
</xsl:if>
<div class="panel-body">
<xsl:apply-templates select="image"/><xsl:apply-templates select="link"/><xsl:apply-templates select="button|switch|partialswitch"/><xsl:apply-templates select="badge|partialbadge|signal"/><strong><xsl:value-of select="text()"/></strong>
<xsl:apply-templates select="image"/><xsl:apply-templates select="icon"/><xsl:apply-templates select="link"/><xsl:apply-templates select="button|switch|partialswitch"/><xsl:apply-templates select="badge|partialbadge|signal"/><strong><xsl:value-of select="text()"/></strong>
<xsl:if test="@event">
<br/><span class="status">Unknown</span>
</xsl:if>
Expand Down
2 changes: 1 addition & 1 deletion nodel-webui-js/src/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ label {
& > .btn.btn-outline {
color: @label-color;
}
& > .btn, & > .btn-group {
& > .btn, & > .btn-group, span[class^="fa"], span[class^="glyph"] {
float: right;
margin-left: 15px;
margin-bottom: 5px;
Expand Down

0 comments on commit 71054c1

Please sign in to comment.