This commit is contained in:
Ylian Saint-Hilaire 2020-05-31 16:21:57 -07:00
commit 7a0687e103
3 changed files with 33 additions and 37 deletions

View File

@ -251,6 +251,35 @@ function createMeshCore(agent) {
return (svc); return (svc);
} }
if (require('identifiers').isBatteryPowered && require('identifiers').isBatteryPowered())
{
require('MeshAgent')._battLevelChanged = function _battLevelChanged(val)
{
_battLevelChanged.self.SendCommand({ action: 'battery', state: _battLevelChanged.self._currentPowerState, level: val });
};
require('MeshAgent')._battLevelChanged.self = require('MeshAgent');
require('MeshAgent')._powerChanged = function _powerChanged(val)
{
_powerChanged.self._currentPowerState = (val == 'AC' ? 'ac' : 'dc');
_powerChanged.self.SendCommand({ action: 'battery', state: (val == 'AC' ? 'ac' : 'dc') });
};
require('MeshAgent')._powerChanged.self = require('MeshAgent');
require('MeshAgent').on('Connected', function (status)
{
if (status == 0)
{
require('power-monitor').removeListener('acdc', this._powerChanged);
require('power-monitor').removeListener('batteryLevel', this._battLevelChanged);
}
else
{
require('power-monitor').on('acdc', this._powerChanged);
require('power-monitor').on('batteryLevel', this._battLevelChanged);
}
});
}
/* /*
function borderController() { function borderController() {
this.container = null; this.container = null;

View File

@ -1,34 +0,0 @@
/*
Copyright 2018-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
function powerMonitor()
{
this._ObjectID = 'power-monitor';
require('events').EventEmitter.call(this, true)
.createEvent('changed')
.createEvent('sx')
.createEvent('batteryLevel')
.createEvent('acdc')
.createEvent('display');
this._i = setImmediate(function (self)
{
require('user-sessions'); // This is needed because this is where the Windows Messages are processed for these events
delete self._i;
}, this);
}
module.exports = new powerMonitor();

View File

@ -508,6 +508,7 @@
}, },
{ {
"en": ", for this link to work you must download MeshCentral Router run it and click the install button.", "en": ", for this link to work you must download MeshCentral Router run it and click the install button.",
"nl": ", om deze link te laten werken, moet u MeshCentral Router downloaden, het uitvoeren en op de installatieknop klikken.",
"xloc": [ "xloc": [
"default.handlebars->25->668" "default.handlebars->25->668"
] ]
@ -8348,14 +8349,12 @@
}, },
{ {
"en": "Device is battery powered", "en": "Device is battery powered",
"nl": "Apparaat werkt op batterijen",
"xloc": [ "xloc": [
"default.handlebars->25->177", "default.handlebars->25->177",
"default.handlebars->25->467" "default.handlebars->25->467"
] ]
}, },
{
"en": "Device is battery powered, {0}%"
},
{ {
"cs": "Zařízení je zjištěno, ale nelze zjistit stav jeho napájení.", "cs": "Zařízení je zjištěno, ale nelze zjistit stav jeho napájení.",
"de": "Gerät wurde erkannt, aber der Energiezustand konnte nicht ermittelt werden.", "de": "Gerät wurde erkannt, aber der Energiezustand konnte nicht ermittelt werden.",
@ -8550,6 +8549,7 @@
}, },
{ {
"en": "Device is plugged-in", "en": "Device is plugged-in",
"nl": "Apparaat is aangesloten",
"xloc": [ "xloc": [
"default.handlebars->25->176", "default.handlebars->25->176",
"default.handlebars->25->466" "default.handlebars->25->466"
@ -25011,6 +25011,7 @@
}, },
{ {
"en": "Start MeshCentral Router", "en": "Start MeshCentral Router",
"nl": "Start MeshCentral Router",
"xloc": [ "xloc": [
"default.handlebars->25->667" "default.handlebars->25->667"
] ]