mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-22 21:31:35 +03:00
Improved battery state indication.
This commit is contained in:
parent
8c321a5a0d
commit
6a70f1371a
BIN
public/images/batteries24.png
Normal file
BIN
public/images/batteries24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 9.9 KiB |
@ -800,6 +800,33 @@ NoMeshesPanel img {
|
||||
.deviceBatteryLarge4 { background: url(../images/batteries48.png) -84px 0px; }
|
||||
.deviceBatteryLarge5 { background: url(../images/batteries48.png) -112px 0px; }
|
||||
.deviceBatteryLarge6 { background: url(../images/batteries48.png) -140px 0px; }
|
||||
.deviceBatteryLarge7 { background: url(../images/batteries48.png) -168px 0px; }
|
||||
.deviceBatteryLarge8 { background: url(../images/batteries48.png) -196px 0px; }
|
||||
.deviceBatteryLarge9 { background: url(../images/batteries48.png) -224px 0px; }
|
||||
.deviceBatteryLarge10 { background: url(../images/batteries48.png) -252px 0px; }
|
||||
.deviceBatteryLarge11 { background: url(../images/batteries48.png) -280px 0px; }
|
||||
|
||||
.deviceBatterySmall {
|
||||
position:absolute;
|
||||
left:20px;
|
||||
top:28px;
|
||||
width:14px;
|
||||
height:24px;
|
||||
border:none;
|
||||
box-shadow:none;
|
||||
}
|
||||
|
||||
.deviceBatterySmall1 { background: url(../images/batteries24.png) 0px 0px; }
|
||||
.deviceBatterySmall2 { background: url(../images/batteries24.png) -14px 0px; }
|
||||
.deviceBatterySmall3 { background: url(../images/batteries24.png) -28px 0px; }
|
||||
.deviceBatterySmall4 { background: url(../images/batteries24.png) -42px 0px; }
|
||||
.deviceBatterySmall5 { background: url(../images/batteries24.png) -56px 0px; }
|
||||
.deviceBatterySmall6 { background: url(../images/batteries24.png) -70px 0px; }
|
||||
.deviceBatterySmall7 { background: url(../images/batteries24.png) -84px 0px; }
|
||||
.deviceBatterySmall8 { background: url(../images/batteries24.png) -98px 0px; }
|
||||
.deviceBatterySmall9 { background: url(../images/batteries24.png) -112px 0px; }
|
||||
.deviceBatterySmall10 { background: url(../images/batteries24.png) -126px 0px; }
|
||||
.deviceBatterySmall11 { background: url(../images/batteries24.png) -140px 0px; }
|
||||
|
||||
.deviceNotifyLargeDot {
|
||||
text-align:center;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2648,7 +2648,7 @@
|
||||
node.lastconnect = Date.now();
|
||||
|
||||
// Clear sesssion and battery information if needed
|
||||
if ((node.conn & 1) == 0) { delete node.sessions; delete node.battery; }
|
||||
if ((node.conn & 1) == 0) { delete node.sessions; }
|
||||
|
||||
// Web page update
|
||||
masterUpdate(1 | 4 | 16);
|
||||
@ -3183,10 +3183,33 @@
|
||||
// Setup device notification
|
||||
var devNotify = '';
|
||||
if (node.sessions != null) {
|
||||
if (view == 2) {
|
||||
devNotify = '<img onclick=showDeviceSessions(\'' + node._id + '\',null,event) class=deviceNotifySmallDot src=images/icon-relay-notify10.png width=10 height=10>';
|
||||
} else {
|
||||
devNotify = '<img onclick=showDeviceSessions(\'' + node._id + '\',null,event) class=deviceNotifyDot src=images/icon-relay-notify.png width=16 height=16>';
|
||||
// Sessions are active
|
||||
if ((node.sessions.kvm != null) || (node.sessions.terminal != null) || (node.sessions.files != null)) {
|
||||
if (view == 2) {
|
||||
devNotify = '<img onclick=showDeviceSessions(\'' + node._id + '\',null,event) class=deviceNotifySmallDot src=images/icon-relay-notify10.png width=10 height=10>';
|
||||
} else {
|
||||
devNotify = '<img onclick=showDeviceSessions(\'' + node._id + '\',null,event) class=deviceNotifyDot src=images/icon-relay-notify.png width=16 height=16>';
|
||||
}
|
||||
}
|
||||
|
||||
// Battery state
|
||||
if ((node.sessions.battery != null) && (view == 1)) {
|
||||
var bat = node.sessions.battery;
|
||||
var statestr = '';
|
||||
if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
|
||||
if (bat.state == 'dc') { statestr = "Device is battery powered"; }
|
||||
|
||||
var levelstr = '', levelnum = -1;
|
||||
if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
|
||||
levelstr = bat.level + '%';
|
||||
levelnum = (Math.floor((bat.level + 10) / 25) + 1);
|
||||
if (levelnum > 5) { lvl = 5; }
|
||||
if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
|
||||
}
|
||||
|
||||
if (levelnum > 0) {
|
||||
devNotify += '<div class="deviceBatterySmall deviceBatterySmall' + levelnum + '" title="' + ((statestr != null)?(statestr + ', ' + levelstr):levelstr) + '"></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5014,21 +5037,23 @@
|
||||
QV('p10deviceBattery', false);
|
||||
if ((currentNode.sessions != null) && (currentNode.sessions.battery != null)) {
|
||||
var bat = currentNode.sessions.battery;
|
||||
if (bat.state == 'ac') {
|
||||
|
||||
var statestr = '';
|
||||
if (bat.state == 'ac') { statestr = "Device is plugged-in"; }
|
||||
if (bat.state == 'dc') { statestr = "Device is battery powered"; }
|
||||
|
||||
var levelstr = '', levelnum = -1;
|
||||
if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
|
||||
levelstr = bat.level + '%';
|
||||
levelnum = (Math.floor((bat.level + 10) / 25) + 1);
|
||||
if (levelnum > 5) { lvl = 5; }
|
||||
if (bat.state == 'ac') { if (bat.level == 100) { levelnum = 11; } else { levelnum += 5; } }
|
||||
}
|
||||
|
||||
if (levelnum > 0) {
|
||||
Q('p10deviceBattery').title = (statestr != null)?(statestr + ', ' + levelstr):levelstr;
|
||||
QV('p10deviceBattery', true);
|
||||
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge6';
|
||||
Q('p10deviceBattery').title = "Device is plugged-in";
|
||||
} else {
|
||||
Q('p10deviceBattery').title = format("Device is battery powered, {0}%", bat.level);
|
||||
if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
|
||||
QV('p10deviceBattery', true);
|
||||
var lvl = (Math.floor((bat.level + 10) / 25) + 1);
|
||||
if (lvl > 5) { lvl = 5; }
|
||||
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge' + lvl;
|
||||
} else {
|
||||
QV('p10deviceBattery', true);
|
||||
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge5';
|
||||
}
|
||||
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge' + levelnum;
|
||||
}
|
||||
} else {
|
||||
QV('p10deviceBattery', false);
|
||||
|
Loading…
Reference in New Issue
Block a user