Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 19 additions & 3 deletions SpeedtestTracker/SpeedtestTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,37 @@ class SpeedtestTracker extends \App\SupportedApps implements \App\EnhancedApps
//protected $login_first = true; // Uncomment if api requests need to be authed first
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST

public function getRequestAttrs()
{
$api_token = $this->config->apikey;

$attrs = [
"headers" => [
"Accept" => "application/json",
"Authorization" => "Bearer " . $api_token,
],
];

return $attrs;
}

public function __construct()
{
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}

public function test()
{
$test = parent::appTest($this->url("api/speedtest/latest/"));
$attrs = $this->getRequestAttrs();
$test = parent::appTest($this->url("api/v1/results/latest/"), $attrs);
echo $test->status;
}

public function livestats()
{
$status = "inactive";
$res = parent::execute($this->url("api/speedtest/latest/"));
$attrs = $this->getRequestAttrs();
$res = parent::execute($this->url("api/v1/results/latest/"), $attrs);
$details = json_decode($res->getBody());

$data = [];
Expand Down Expand Up @@ -78,7 +94,7 @@ private static function formatUsingStat($stat, $number)
switch ($stat) {
case "download":
case "upload":
return number_format($number) . "<span>Mbit/s</span>";
return number_format($number * 8 / 1000000) . "<span>Mbit/s</span>";
case "ping":
return number_format($number) . "<span>ms</span>";
case "created_at":
Expand Down
4 changes: 2 additions & 2 deletions SpeedtestTracker/app.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"appid": "c106a4464d1b08d0e35edb92ddfabae6f9dc765f",
"name": "Speedtest Tracker",
"website": "https://github.com/henrywhitaker3/Speedtest-Tracker",
"license": "GNU General Public License v3.0 only",
"website": "https://github.com/alexjustesen/speedtest-tracker",
"license": "MIT License",
"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.",
"enhanced": true,
"tile_background": "dark",
Expand Down
4 changes: 2 additions & 2 deletions SpeedtestTracker/config.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::text('config[apikey]', isset($item) ? $item->getconfig()->apikey : null, ['placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<label>Stats to show</label>
Expand Down