diff --git a/WatchYourLAN/WatchYourLAN.php b/WatchYourLAN/WatchYourLAN.php index 60d204d3ab..0ce04d1d1a 100644 --- a/WatchYourLAN/WatchYourLAN.php +++ b/WatchYourLAN/WatchYourLAN.php @@ -2,6 +2,47 @@ namespace App\SupportedApps\WatchYourLAN; -class WatchYourLAN extends \App\SupportedApps +class WatchYourLAN extends \App\SupportedApps implements \App\EnhancedApps { + + public $config; + + //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 __construct() + { + //$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set + } + + public function test() + { + $test = parent::appTest($this->url('api/all/')); + echo $test->status; + } + + public function livestats() + { + $status = 'inactive'; + $res = parent::execute($this->url('api/all/')); + $hosts = json_decode($res->getBody()); + $unknown_count = 0; + + if (is_array($hosts)) { + foreach ($hosts as $key => $host) { + if (isset($host->Known) && $host->Known == 0) { + $unknown_count += 1; + } + } + } + + $data['unknown_count'] = $unknown_count; + return parent::getLiveStats($status, $data); + } + + public function url($endpoint) + { + $api_url = parent::normaliseurl($this->config->url) . $endpoint; + return $api_url; + } } diff --git a/WatchYourLAN/app.json b/WatchYourLAN/app.json index 4084314390..40bf539bb2 100644 --- a/WatchYourLAN/app.json +++ b/WatchYourLAN/app.json @@ -4,7 +4,7 @@ "website": "https://github.com/aceberg/WatchYourLAN", "license": "MIT License", "description": "Lightweight network IP scanner with web GUI https://github.com/aceberg/WatchYourLAN", - "enhanced": false, + "enhanced": true, "tile_background": "dark", "icon": "watchyourlan.png" } \ No newline at end of file diff --git a/WatchYourLAN/config.blade.php b/WatchYourLAN/config.blade.php new file mode 100644 index 0000000000..53f26e13cb --- /dev/null +++ b/WatchYourLAN/config.blade.php @@ -0,0 +1,10 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')

+
+
+ + {!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!} +
+
+ +
+
diff --git a/WatchYourLAN/livestats.blade.php b/WatchYourLAN/livestats.blade.php new file mode 100644 index 0000000000..4cc25ebbd1 --- /dev/null +++ b/WatchYourLAN/livestats.blade.php @@ -0,0 +1,6 @@ +