Skip to content

Commit 0b401bb

Browse files
Keithmvdkleijn
authored andcommitted
WatchYourLAN enhanced version
1 parent 1b720d7 commit 0b401bb

4 files changed

Lines changed: 59 additions & 2 deletions

File tree

WatchYourLAN/WatchYourLAN.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,47 @@
22

33
namespace App\SupportedApps\WatchYourLAN;
44

5-
class WatchYourLAN extends \App\SupportedApps
5+
class WatchYourLAN extends \App\SupportedApps implements \App\EnhancedApps
66
{
7+
8+
public $config;
9+
10+
//protected $login_first = true; // Uncomment if api requests need to be authed first
11+
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
12+
13+
public function __construct()
14+
{
15+
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
16+
}
17+
18+
public function test()
19+
{
20+
$test = parent::appTest($this->url('api/all/'));
21+
echo $test->status;
22+
}
23+
24+
public function livestats()
25+
{
26+
$status = 'inactive';
27+
$res = parent::execute($this->url('api/all/'));
28+
$hosts = json_decode($res->getBody());
29+
$unknown_count = 0;
30+
31+
if (is_array($hosts)) {
32+
foreach ($hosts as $key => $host) {
33+
if (isset($host->Known) && $host->Known == 0) {
34+
$unknown_count += 1;
35+
}
36+
}
37+
}
38+
39+
$data['unknown_count'] = $unknown_count;
40+
return parent::getLiveStats($status, $data);
41+
}
42+
43+
public function url($endpoint)
44+
{
45+
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
46+
return $api_url;
47+
}
748
}

WatchYourLAN/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"website": "https://github.com/aceberg/WatchYourLAN",
55
"license": "MIT License",
66
"description": "Lightweight network IP scanner with web GUI https://github.com/aceberg/WatchYourLAN",
7-
"enhanced": false,
7+
"enhanced": true,
88
"tile_background": "dark",
99
"icon": "watchyourlan.png"
1010
}

WatchYourLAN/config.blade.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>

WatchYourLAN/livestats.blade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<ul class="livestats">
2+
<li>
3+
<span class="title">Unknown</span>
4+
<strong>{!! $unknown_count !!}</strong>
5+
</li>
6+
</ul>

0 commit comments

Comments
 (0)