Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-app-speedtest: Add packages #6951

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
01d3791
luci-app-speedtest: Add packages
animegasan Mar 2, 2024
5ca3312
luci-mod-network: Add clarifying note to wireless join dialog
hnyman Mar 3, 2024
33c6c9e
luci-mod-status: fix sporadic logical interfaces resolve failures
jow- Mar 4, 2024
905a030
luci-app-ntpc: remove app
dannil Feb 28, 2024
258b0cf
luci-base: docs house-keeping
systemcrash Mar 6, 2024
7fd26e4
rpcd-mod-luci: use standard POSIX header for basename()
guidosarducci Mar 6, 2024
c4fae8b
Translated using Weblate (Lithuanian)
weblate Mar 4, 2024
ac648d8
irqbalance: Add option for new 'debug' setting
schuettecarsten Mar 7, 2024
e8f5ede
luci-base: use correct regex for time validation
dannil Mar 2, 2024
1838356
luci-app-statistics: Add UI to configure Mqtt
McGiverGim Mar 17, 2023
cef7d35
Translated using Weblate (Polish)
weblate Mar 8, 2024
00df19e
luci-app-upnp: remove obsolete translation
stokito Mar 9, 2024
0827230
luci-app-upnp: revise wording to include PCP
stokito Mar 9, 2024
a26f5b2
luci-app-p910nd: convert to JS
systemcrash Feb 12, 2024
f1c13b3
luci-theme-bootstrap: Realtime Graphs dark mode
JimMatthew Mar 12, 2024
4355c4a
Translated using Weblate (Italian)
weblate Mar 12, 2024
adf9b3a
luci-mod-network: drop trailing whitespace
dannil Mar 12, 2024
2a5c802
luci-app-statistics: add users plugin support
mrjoel Jul 31, 2020
0c9bf5f
luci-theme-bootstrap: Allways show scrollbar
thomasschroeder Feb 18, 2024
cf300d1
Merge branch 'openwrt:master' into luci-app-speedtest
animegasan Mar 14, 2024
afa63bd
Merge remote-tracking branch 'upstream/master' into luci-app-speedtest
animegasan Mar 14, 2024
6aac964
Merge branch 'luci-app-speedtest' of https://github.com/animegasan/lu…
animegasan Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions applications/luci-app-speedtest/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is free software, licensed under the Apache License, Version 2.0
#
# Copyright (C) 2024 Hilman Maulana <[email protected]>

include $(TOPDIR)/rules.mk

LUCI_TITLE:=LuCI for speedtestcpp
LUCI_DEPENDS:=+speedtestcpp

PKG_MAINTAINER:=Hilman Maulana <[email protected]>
PKG_VERSION:=1.0
PKG_LICENSE:=Apache-2.0

include ../../luci.mk

# call BuildPackage - OpenWrt buildroot signature
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/* This is free software, licensed under the Apache License, Version 2.0
*
* Copyright (C) 2024 Hilman Maulana <[email protected]>
*/

'use strict';
'require view';
'require fs';

return view.extend({
handleSaveApply: null,
handleSave: null,
handleReset: null,
render: function() {
var header = [
E('h2', {'class': 'section-title'}, _('Speedtest')),
E('div', {'class': 'cbi-map-descr'}, _('Here you can perform a speed test to measure the basic aspects of your network connection.'))
];
var select = [
E('label', { 'class': 'cbi-input-label', 'for': 'speedtest-type', 'style': 'margin-right: 8px;'}, _('Test')),
E('select', { 'id': 'speedtest-type', 'style': 'width:80%;'}, [
E('option', { 'value': 'all', 'selected': 'selected'}, _('All')),
E('option', { 'value': 'latency' }, _('Latency')),
E('option', { 'value': 'download' }, _('Download')),
E('option', { 'value': 'upload' }, _('Upload'))
])
];
var status = [
E('label', { 'class': 'cbi-input-label', 'style': 'margin-right: 8px;'}, _('Status')),
E('em', { 'id': 'speedtest-status'}, _('Available'))
];
var table = [
E('h3', {'class': 'section-title'}, _('Results')),
E('table', {'class': 'table cbi-section-table'}, [
E('tr', {'class': 'tr table-title'}, [
E('th', {'class': 'th ', 'style': 'display: none;'})
]),
E('tr', {'class': 'tr cbi-rowstyle-1'},[
E('td', {'class': 'td left', 'width': '50%'}, _('IP Address')),
E('td', {'class': 'td', 'id': 'client-ip'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-2'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Provider')),
E('td', {'class': 'td', 'id': 'client-isp'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-1'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Server')),
E('td', {'class': 'td', 'id': 'server-name'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-2'},[
E('td', {'class': 'td left', 'width': '50%'}, _('ID')),
E('td', {'class': 'td', 'id': 'server-id'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-1'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Location')),
E('td', {'class': 'td', 'id': 'server-location'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-2'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Server Host')),
E('td', {'class': 'td', 'id': 'server-host'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-1'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Ping')),
E('td', {'class': 'td', 'id': 'ping'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-2'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Jitter')),
E('td', {'class': 'td', 'id': 'jitter'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-1'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Download Speed')),
E('td', {'class': 'td', 'id': 'download'}, '-')
]),
E('tr', {'class': 'tr cbi-rowstyle-2'},[
E('td', {'class': 'td left', 'width': '50%'}, _('Upload Speed')),
E('td', {'class': 'td', 'id': 'upload'}, '-')
])
])
];
var running = false;
var button = [
E('button', {
'class': 'btn cbi-button cbi-button-action',
'click': function() {
if (!running) {
running = true;
var dropdown = document.getElementById('speedtest-type');
var value = dropdown.options[dropdown.selectedIndex].value;
var command = ['--output', 'json'];
if (value !== 'all') {
command.push('--' + value);
}

var status = document.getElementById('speedtest-status');
status.textContent = _('Running');

fs.exec_direct('speedtest', command)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the app assumes that the speedtest binary is available. Let's say that the binary was deleted, or some sysupgrade went bad (even tho this app depends on it), what happens when the binary is absent? Is the error message misleading or must we perform a separate check at init?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action has been handled here.

.catch(function(err) {
	if (!err.response) {
		status.textContent = _('No response received, please check your internet connection or try again later.');
	} else if (err.response.data && err.response.data.error === 'unable to retrieve your ip info') {
		status.textContent = _('Unable to retrieve IP information, please check your internet connection.');
	} else {
		status.textContent = err;
	}
	running = false;
});

.then(function(response) {
var result = JSON.parse(response);
document.getElementById('client-ip').textContent = result.client.ip;
document.getElementById('client-isp').textContent = result.client.isp + ' [' + result.client.lat + ', ' + result.client.lon + ']';
document.getElementById('server-name').textContent = result.server.sponsor;
document.getElementById('server-id').textContent = result.server.id;
document.getElementById('server-location').textContent = result.server.name + ' (' + result.server.distance + ' km)';
document.getElementById('server-host').textContent = result.server.host;
document.getElementById('ping').textContent = result.ping + ' ms';
document.getElementById('jitter').textContent = result.jitter + ' ms';
document.getElementById('download').textContent = result.download_mbit ? result.download_mbit + ' Mbit/s' : '-';
document.getElementById('upload').textContent = result.upload_mbit ? result.upload_mbit + ' Mbit/s' : '-';
status.textContent = _('Finished');
running = false;
})
.catch(function(err) {
if (!err.response) {
status.textContent = _('No response received, please check your internet connection or try again later.');
} else if (err.response.data && err.response.data.error === 'unable to retrieve your ip info') {
status.textContent = _('Unable to retrieve IP information, please check your internet connection.');
} else {
status.textContent = err;
}
running = false;
});
}
}
}, _('Start'))
];
return E('div', {'class': 'cbi-map'}, [
E(header),
E('table', {'class': 'table'}, [
E('tr', {'class': 'tr'}, [
E('td', {'class': 'td', 'style': 'overflow:initial;'}, select),
E('td', {'class': 'td', 'style': 'overflow:initial;'}, button),
E('td', {'class': 'td'}, status)
])
]),
E('div', {'class': 'cbi-section'}, [
E('div', {'class': 'speedtest-info'}, table)
])
])
}
})
107 changes: 107 additions & 0 deletions applications/luci-app-speedtest/po/templates/speedtest.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"

#: applications/luci-app-speedtest/root/usr/share/rpcd/acl.d/luci-app-speedtest.json:3
msgid "Grant access to speedtest"
msgstr ""

#: applications/luci-app-speedtest/root/usr/share/luci/menu.d/luci-app-speedtest.json:3
#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:16
msgid "Speedtest"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:17
msgid "Here you can perform a speed test to measure the basic aspects of your network connection."
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:20
msgid "Test"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:22
msgid "All"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:23
msgid "Latency"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:24
msgid "Download"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:25
msgid "Upload"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:29
msgid "Status"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:30
msgid "Available"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:33
msgid "Results"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:39
msgid "IP Address"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:43
msgid "Provider"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:47
msgid "Server"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:51
msgid "ID"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:55
msgid "Location"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:59
msgid "Server Host"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:63
msgid "Ping"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:67
msgid "Jitter"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:71
msgid "Download Speed"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:75
msgid "Upload Speed"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:95
msgid "Running"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:110
msgid "Finished"
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:115
msgid "No response received, please check your internet connection or try again later."
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:117
msgid "Unable to retrieve IP information, please check your internet connection."
msgstr ""

#: applications/luci-app-speedtest/htdocs/luci-static/resources/view/speedtest.js:125
msgid "Start"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"admin/network/speedtest": {
"title": "Speedtest",
"order": 50,
"action": {
"type": "view",
"path": "speedtest"
},
"depends": {
"acl": [ "luci-app-speedtest" ]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"luci-app-speedtest": {
"description": "Grant access to speedtest",
"write": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a problem to use "read": { instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried it yet, but I'll give it a shot. Perhaps it'll work out.

"file": {
"/usr/bin/speedtest": [ "exec" ]
}
}
}
}
Loading