mirror of
https://github.com/gSpotx2f/luci-app-internet-detector.git
synced 2025-12-06 11:36:49 +03:00
luci-app-internet-detector: Minor fixes
This commit is contained in:
@@ -61,6 +61,8 @@ return baseclass.extend({
|
|||||||
uiCheckIntervalDown : null,
|
uiCheckIntervalDown : null,
|
||||||
currentAppMode : null,
|
currentAppMode : null,
|
||||||
inetStatus : null,
|
inetStatus : null,
|
||||||
|
uiState : null,
|
||||||
|
counter : 0,
|
||||||
|
|
||||||
inetStatusFromJson : function(res) {
|
inetStatusFromJson : function(res) {
|
||||||
let inetStatData = null;
|
let inetStatData = null;
|
||||||
@@ -73,11 +75,7 @@ return baseclass.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
load: async function() {
|
load: async function() {
|
||||||
if(!(
|
if(!(this.uiCheckIntervalUp && this.uiCheckIntervalDown && this.currentAppMode)) {
|
||||||
this.uiCheckIntervalUp &&
|
|
||||||
this.uiCheckIntervalDown &&
|
|
||||||
this.currentAppMode
|
|
||||||
)) {
|
|
||||||
await uci.load(this.appName).then(data => {
|
await uci.load(this.appName).then(data => {
|
||||||
this.uiCheckIntervalUp = Number(uci.get(this.appName, 'ui', 'interval_up'));
|
this.uiCheckIntervalUp = Number(uci.get(this.appName, 'ui', 'interval_up'));
|
||||||
this.uiCheckIntervalDown = Number(uci.get(this.appName, 'ui', 'interval_down'));
|
this.uiCheckIntervalDown = Number(uci.get(this.appName, 'ui', 'interval_down'));
|
||||||
@@ -86,18 +84,15 @@ return baseclass.extend({
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(this.currentAppMode === '2') {
|
if(this.currentAppMode === '2') {
|
||||||
this.internetDetectorCounter = ('internetDetectorCounter' in this) ?
|
this.counter++;
|
||||||
++this.internetDetectorCounter : 0;
|
|
||||||
|
|
||||||
if((this.internetDetectorStateUi === 0 &&
|
if((this.uiState === 0 && this.counter % this.uiCheckIntervalUp) ||
|
||||||
this.internetDetectorCounter % this.uiCheckIntervalUp) ||
|
(this.uiState === 1 && this.counter % this.uiCheckIntervalDown)
|
||||||
(this.internetDetectorStateUi === 1 &&
|
|
||||||
this.internetDetectorCounter % this.uiCheckIntervalDown)
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.internetDetectorCounter = 0;
|
this.counter = 0;
|
||||||
return L.resolveDefault(fs.exec(this.execPath, [ 'poll' ]), null);
|
return L.resolveDefault(fs.exec(this.execPath, [ 'poll' ]), null);
|
||||||
}
|
}
|
||||||
else if(this.currentAppMode === '1') {
|
else if(this.currentAppMode === '1') {
|
||||||
@@ -113,7 +108,7 @@ return baseclass.extend({
|
|||||||
if(data) {
|
if(data) {
|
||||||
this.inetStatus = this.inetStatusFromJson(data);
|
this.inetStatus = this.inetStatusFromJson(data);
|
||||||
if(this.currentAppMode === '2') {
|
if(this.currentAppMode === '2') {
|
||||||
this.internetDetectorStateUi = this.inetStatus.instances[0].inet;
|
this.uiState = this.inetStatus.instances[0].inet;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user