Initial commit

This commit is contained in:
gSpot
2020-06-19 21:37:31 +03:00
parent 106989fa7a
commit 89662951e6
7 changed files with 112 additions and 0 deletions

17
Makefile Normal file
View File

@@ -0,0 +1,17 @@
#
# Copyright (C) 2020 gSpot (https://github.com/gSpotx2f/luci-app-internet-detector)
#
# This is free software, licensed under the MIT License.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-internet-detector
LUCI_TITLE:=Internet detector for the LuCI status page
LUCI_DEPENDS:=+luci-mod-admin-full
LUCI_PKGARCH:=all
PKG_LICENSE:=MIT
include ../../luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@@ -0,0 +1,53 @@
'use strict';
'require fs';
return L.Class.extend({
title: _('Internet'),
hosts: [
'8.8.8.8',
'1.1.1.1',
'8.8.4.4',
],
checkInterval: 11, // 5 x 11 = 55 sec.
load: async function() {
window.internetDetectorCounter = ('internetDetectorCounter' in window) ?
++window.internetDetectorCounter : 0;
if(!('internetDetectorState' in window)) {
window.internetDetectorState = 1;
};
if(window.internetDetectorState === 0 &&
window.internetDetectorCounter % this.checkInterval) {
return;
};
for(let host of this.hosts) {
await fs.exec('/bin/ping', [ '-c', '1', '-W', '1', host ]).then(res => {
window.internetDetectorState = res.code;
}).catch(e => {});
if(window.internetDetectorState === 0) {
break;
};
};
},
render: function() {
let internetStatus = E('span', { 'class': 'label' });
if(window.internetDetectorState === 0) {
internetStatus.style.background = '#46a546';
internetStatus.textContent = _('Internet connected');
} else {
internetStatus.textContent = _('Internet disconnected');
};
return E('div', {
'class': 'cbi-section',
'style': 'margin-bottom:1em',
}, internetStatus);
},
});

View File

@@ -0,0 +1,21 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ru\n"
"X-Generator: Poedit 2.0.6\n"
msgid "Internet"
msgstr "Интернет"
msgid "Internet connected"
msgstr "Интернет подключен"
msgid "Internet disconnected"
msgstr "Интернет отключен"

View File

@@ -0,0 +1,11 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Internet"
msgstr ""
msgid "Internet connected"
msgstr ""
msgid "Internet disconnected"
msgstr ""

View File

@@ -0,0 +1,10 @@
{
"luci-app-internet-detector": {
"description": "Grant access to internet-detector procedures",
"read": {
"file": {
"/bin/ping -c 1 -W 1 [0-9.]*": [ "exec" ]
}
}
}
}

BIN
screenshots/01.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.