diff --git a/app/Item.php b/app/Item.php index ace78bb6..da141c34 100644 --- a/app/Item.php +++ b/app/Item.php @@ -64,6 +64,7 @@ class Item extends Model $view = $sap->configDetails(); $output->view = $view; } + if(!isset($output->dataonly)) $output->dataonly = 0; } return (object)$output; @@ -74,6 +75,7 @@ class Item extends Model $config = null; } else { $store = false; + //die(print_r($config)); foreach($config as $key => $check) { if($key == 'type') continue; if(!empty($check)) { diff --git a/app/SupportedApps/Pihole.php b/app/SupportedApps/Pihole.php index 60d153ec..c9b0c9c0 100644 --- a/app/SupportedApps/Pihole.php +++ b/app/SupportedApps/Pihole.php @@ -1,6 +1,9 @@ buildRequest(); + switch($res->getStatusCode()) { + case 200: + echo 'Successfully connected to the API'; + break; + case 401: + echo 'Failed: Invalid credentials'; + break; + case 404: + echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; + break; + default: + echo 'Something went wrong... Code: '.$res->getStatusCode(); + break; + } + } + + public function executeConfig() + { + $output = ''; + $res = $this->buildRequest(); + $data = json_decode($res->getBody()); + + $output = ' + + '; + return $output; + } + + public function buildRequest() + { + $config = $this->config; + $url = $config->url; + + $api_url = $url.'admin/api.php'; + //die( $api_url.' --- '); + + $client = new Client(['http_errors' => false]); + $res = $client->request('GET', $api_url); + return $res; + + } + + } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index baf029dc..f5536c0c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -20,6 +20,8 @@ $.when( $.ready ).then(function() { if($('.livestats-container').length) { $('.livestats-container').each(function(index){ var id = $(this).data('id'); + var dataonly = $(this).data('dataonly'); + var increaseby = (dataonly == 1) ? 20000 : 1000; var container = $(this); var max_timer = 30000; var timer = 5000; @@ -28,7 +30,7 @@ $.when( $.ready ).then(function() { url: '/get_stats/'+id, success: function(data) { container.html(data); - if(data != '') timer = 1000; + if(data != '') timer = increaseby; else { if(timer < max_timer) timer += 2000; } diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 4d4a0cfa..3263a88f 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -11,6 +11,8 @@ $.when( $.ready ).then(function() { if($('.livestats-container').length) { $('.livestats-container').each(function(index){ var id = $(this).data('id'); + var dataonly = $(this).data('dataonly'); + var increaseby = (dataonly == 1) ? 20000 : 1000; var container = $(this); var max_timer = 30000; var timer = 5000; @@ -19,7 +21,7 @@ $.when( $.ready ).then(function() { url: '/get_stats/'+id, success: function(data) { container.html(data); - if(data != '') timer = 1000; + if(data != '') timer = increaseby; else { if(timer < max_timer) timer += 2000; } diff --git a/resources/lang/en/app.php b/resources/lang/en/app.php index d4276445..6abc3655 100644 --- a/resources/lang/en/app.php +++ b/resources/lang/en/app.php @@ -60,6 +60,7 @@ return [ 'apps.password' => 'Password', 'apps.config' => 'Config', 'apps.apikey' => 'Api Key', + 'apps.enable' => 'Enable', 'url' => 'Url', 'title' => 'Title', diff --git a/resources/views/item.blade.php b/resources/views/item.blade.php index 3e6bf5ca..e5783e1a 100644 --- a/resources/views/item.blade.php +++ b/resources/views/item.blade.php @@ -8,7 +8,7 @@
{{ $app->title }}
@if(isset($app->config->enabled) && ((bool)$app->config->enabled === true)) -
+
@endif
diff --git a/resources/views/supportedapps/pihole.blade.php b/resources/views/supportedapps/pihole.blade.php new file mode 100644 index 00000000..bcbbee53 --- /dev/null +++ b/resources/views/supportedapps/pihole.blade.php @@ -0,0 +1,19 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }})

+
+ + +
+ + +
+ +
\ No newline at end of file