Skip to content

Commit 84c025b

Browse files
author
Lucas Araujo
committed
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
1 parent ff057fe commit 84c025b

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

MySpeed/MySpeed.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
public function test()
12+
{
13+
$test = parent::appTest($this->url('api/info/version'));
14+
echo $test->status;
15+
}
16+
17+
public function livestats()
18+
{
19+
$status = 'inactive';
20+
$res = parent::execute($this->url('api/speedtests/statistics'));
21+
$details = json_decode($res->getBody());
22+
23+
$data = [];
24+
25+
if ($details) {
26+
$status = 'active';
27+
$data = [
28+
'avg_down' => floor($details->download->avg),
29+
'avg_up' => floor($details->upload->avg)
30+
31+
];
32+
}
33+
34+
return parent::getLiveStats($status, $data);
35+
}
36+
37+
public function url($endpoint)
38+
{
39+
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
40+
return $api_url;
41+
}
42+
}

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)