Skip to content

Commit 0c39521

Browse files
lucaslraLucas Araujo
andauthored
feat: add MySpeed app integration with live stats and config (#869)
* feat: add MySpeed app integration with live stats and config - Implement MySpeed app with live statistics display for download/upload speeds - Add configuration page with URL override option - Include app icon and metadata in app.json * style: format constructor with consistent spacing * refactor: remove empty line in MySpeed constructor --------- Co-authored-by: Lucas Araujo <[email protected]>
1 parent 51d2ae1 commit 0c39521

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed

MySpeed/MySpeed.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace App\SupportedApps\MySpeed;
4+
5+
class MySpeed extends \App\SupportedApps implements \App\EnhancedApps
6+
{
7+
public $config;
8+
9+
public function __construct() {
10+
}
11+
12+
public function test()
13+
{
14+
$test = parent::appTest($this->url('api/info/version'));
15+
echo $test->status;
16+
}
17+
18+
public function livestats()
19+
{
20+
$status = 'inactive';
21+
$res = parent::execute($this->url('api/speedtests/statistics'));
22+
$details = json_decode($res->getBody());
23+
24+
$data = [];
25+
26+
if ($details) {
27+
$status = 'active';
28+
$data = [
29+
'avg_down' => floor($details->download->avg),
30+
'avg_up' => floor($details->upload->avg)
31+
32+
];
33+
}
34+
35+
return parent::getLiveStats($status, $data);
36+
}
37+
38+
public function url($endpoint)
39+
{
40+
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
41+
return $api_url;
42+
}
43+
}

MySpeed/app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"appid": "ac2f9c8aee6a960204b0fb387d33185679217db2",
3+
"name": "MySpeed",
4+
"website": "https://myspeed.dev",
5+
"license": "MIT License",
6+
"description": "MySpeed is a speed test analysis software that records your internet speed for up to 30 days.",
7+
"enhanced": true,
8+
"tile_background": "dark",
9+
"icon": "myspeed.png"
10+
}

MySpeed/config.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
2+
<div class="items">
3+
<div class="input">
4+
<label>{{ strtoupper(__('app.url')) }}</label>
5+
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
6+
</div>
7+
<div class="input">
8+
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
9+
</div>
10+
</div>
11+

MySpeed/livestats.blade.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<ul class="livestats">
2+
<li>
3+
<span class="title">Down</span>
4+
<strong>{!! $avg_down . 'Mbps' !!}</strong>
5+
</li>
6+
<li>
7+
<span class="title">Up</span>
8+
<strong>{!! $avg_up . 'Mbps' !!}</strong>
9+
</li>
10+
</ul>

MySpeed/myspeed.png

3.77 KB
Loading

0 commit comments

Comments
 (0)