Skip to content

Commit 22596e4

Browse files
committed
Fixed for new Speedtest Tracker app by alexjustesen
1 parent 1df029c commit 22596e4

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

SpeedtestTracker/SpeedtestTracker.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,37 @@ class SpeedtestTracker extends \App\SupportedApps implements \App\EnhancedApps
1111
//protected $login_first = true; // Uncomment if api requests need to be authed first
1212
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
1313

14+
public function getRequestAttrs()
15+
{
16+
$api_token = $this->config->apikey;
17+
18+
$attrs = [
19+
"headers" => [
20+
"Accept" => "application/json",
21+
"Authorization" => "Bearer " . $api_token,
22+
],
23+
];
24+
25+
return $attrs;
26+
}
27+
1428
public function __construct()
1529
{
1630
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
1731
}
1832

1933
public function test()
2034
{
21-
$test = parent::appTest($this->url("api/speedtest/latest/"));
35+
$attrs = $this->getRequestAttrs();
36+
$test = parent::appTest($this->url("api/v1/results/latest/"), $attrs);
2237
echo $test->status;
2338
}
2439

2540
public function livestats()
2641
{
2742
$status = "inactive";
28-
$res = parent::execute($this->url("api/speedtest/latest/"));
43+
$attrs = $this->getRequestAttrs();
44+
$res = parent::execute($this->url("api/v1/results/latest/"), $attrs);
2945
$details = json_decode($res->getBody());
3046

3147
$data = [];
@@ -78,7 +94,7 @@ private static function formatUsingStat($stat, $number)
7894
switch ($stat) {
7995
case "download":
8096
case "upload":
81-
return number_format($number) . "<span>Mbit/s</span>";
97+
return number_format($number * 8 / 1000000) . "<span>Mbit/s</span>";
8298
case "ping":
8399
return number_format($number) . "<span>ms</span>";
84100
case "created_at":

SpeedtestTracker/app.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"appid": "c106a4464d1b08d0e35edb92ddfabae6f9dc765f",
33
"name": "Speedtest Tracker",
4-
"website": "https://github.com/henrywhitaker3/Speedtest-Tracker",
5-
"license": "GNU General Public License v3.0 only",
4+
"website": "https://github.com/alexjustesen/speedtest-tracker",
5+
"license": "MIT License",
66
"description": "This program runs a speedtest check every hour and graphs the results. The back-end is written in Laravel and the front-end uses React. It uses the Ookla's speedtest cli package to get the data and uses Chart.js to plot the results.",
77
"enhanced": true,
88
"tile_background": "dark",

SpeedtestTracker/config.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
22
<div class="items">
33
<div class="input">
4-
<label>{{ strtoupper(__('app.url')) }}</label>
5-
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
4+
<label>{{ __('app.apps.apikey') }}</label>
5+
{!! Form::text('config[apikey]', isset($item) ? $item->getconfig()->apikey : null, ['placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item']) !!}
66
</div>
77
<div class="input">
88
<label>Stats to show</label>

0 commit comments

Comments
 (0)