diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc461fc8..eea7df2f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,41 @@
# Release Notes
-## v1.1.2 (2018-02-05)
+## v1.3.0 (2018-02-05)
+
+### Added
+- guzzlehttp/guzzle as a dependency
+- Variable polling, so interval is increased when an app is idle and decreased when it's active
+- Turkish language translation
+- Added Sabnzbd enhanced application
+
+### Changed
+- Updated composer dependencies
+- Added live stats to Nzbget supported application
+- Changed Pihole to an enhanced application
+- Changed NZBGet to an enhanced application
+
+### Fixed
+- Fixed autocomplete being hard to see
+
+
+## v1.2.0 (2018-02-07)
### Added
- Translation support
- Initial "Supported" application support
+- Finnish translation
+- Swedish translation
+- German translation
+- French translation
+- Spanish translation
+- Duplicati supported application
+- Emby supported application
+- Nzbget supported application
+- Pfsense supported application
+- Pihole supported application
+- Plex supported application
+- Portainer supported application
+- Unifi supported application
### Changed
- button layout and behaviour
diff --git a/app/Helper.php b/app/Helper.php
new file mode 100644
index 00000000..513c4287
--- /dev/null
+++ b/app/Helper.php
@@ -0,0 +1,12 @@
+= $btype && $x < (count($labels) - 1); $bytes /= $btype, $x++); // use 1000 rather than 1024 to simulate HD size not real size
+ if($labels[$x] == "TB") return(round($bytes, 3).$beforeunit.$labels[$x].$afterunit);
+ elseif($labels[$x] == "GB") return(round($bytes, 2).$beforeunit.$labels[$x].$afterunit);
+ elseif($labels[$x] == "MB") return(round($bytes, 2).$beforeunit.$labels[$x].$afterunit);
+ else return(round($bytes, 0).$beforeunit.$labels[$x].$afterunit);
+}
diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php
index 5cd2d5d1..6c575b43 100644
--- a/app/Http/Controllers/ItemController.php
+++ b/app/Http/Controllers/ItemController.php
@@ -139,19 +139,17 @@ class ItemController extends Controller
]);
}
- $config = json_encode($request->input('config'));
- if($config) {
- $request->merge([
- 'description' => $config
- ]);
- }
+ $config = Item::checkConfig($request->input('config'));
+ $request->merge([
+ 'description' => $config
+ ]);
//die(print_r($request->input('config')));
Item::create($request->all());
return redirect()->route('dash')
- ->with('success', __('alert.success.item_created'));
+ ->with('success', __('app.alert.success.item_created'));
}
/**
@@ -202,11 +200,15 @@ class ItemController extends Controller
]);
}
+ $config = Item::checkConfig($request->input('config'));
+ $request->merge([
+ 'description' => $config
+ ]);
Item::find($id)->update($request->all());
return redirect()->route('dash')
- ->with('success',__('alert.success.item_updated'));
+ ->with('success',__('app.alert.success.item_updated'));
}
/**
@@ -228,7 +230,7 @@ class ItemController extends Controller
}
return redirect()->route('items.index')
- ->with('success',__('alert.success.item_deleted'));
+ ->with('success',__('app.alert.success.item_deleted'));
}
/**
@@ -244,7 +246,17 @@ class ItemController extends Controller
->where('id', $id)
->restore();
return redirect()->route('items.index')
- ->with('success',__('alert.success.item_restored'));
+ ->with('success',__('app.alert.success.item_restored'));
+ }
+
+ public function isSupportedAppByKey($app)
+ {
+ $output = false;
+ $all_supported = Item::supportedList();
+ if(array_key_exists($app, $all_supported)) {
+ $output = new $all_supported[$app];
+ }
+ return $output;
}
/**
@@ -254,16 +266,53 @@ class ItemController extends Controller
*/
public function appload(Request $request)
{
+ $output = [];
$app = $request->input('app');
- if($app) {
- $all_supported = Item::supportedList();
- $app_details = new $all_supported[$app];
+
+ if(($app_details = $this->isSupportedAppByKey($app)) !== false) {
+ // basic details
+ $output['icon'] = $app_details->icon();
+ $output['colour'] = $app_details->defaultColour();
+
+ // live details
+ if($app_details instanceof \App\SupportedApps\Contracts\Livestats) {
+ $output['config'] = $app_details->configDetails();
+ } else {
+ $output['config'] = null;
+ }
}
- $output['icon'] = $app_details->icon();
- $output['colour'] = $app_details->defaultColour();
- $output['config'] = $app_details->configDetails();
+
return json_encode($output);
}
+ public function testConfig(Request $request)
+ {
+ $data = $request->input('data');
+ //$url = $data[array_search('url', array_column($data, 'name'))]['value'];
+
+ $app = $data['type'];
+
+ $app_details = new $app();
+ $app_details->config = (object)$data;
+ $app_details->testConfig();
+ }
+
+ public function getStats($id)
+ {
+ $item = Item::find($id);
+
+ $config = json_decode($item->description);
+ if(isset($config->type)) {
+ $config->url = $item->url;
+ if(isset($config->override_url) && !empty($config->override_url)) {
+ $config->url = $config->override_url;
+ }
+ $app_details = new $config->type;
+ $app_details->config = $config;
+ echo $app_details->executeConfig();
+ }
+
+ }
+
}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index de4a4c37..ae1893a9 100644
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -14,6 +14,8 @@ class VerifyCsrfToken extends Middleware
protected $except = [
//
'order',
- 'appload'
+ 'appload',
+ 'test_config',
+ //'get_stats'
];
}
diff --git a/app/Item.php b/app/Item.php
index bdde1539..1f4fd1b2 100644
--- a/app/Item.php
+++ b/app/Item.php
@@ -32,8 +32,9 @@ class Item extends Model
'pFsense' => \App\SupportedApps\Pfsense::class,
'Pihole' => \App\SupportedApps\Pihole::class,
'Plex' => \App\SupportedApps\Plex::class,
- 'UniFi' => \App\SupportedApps\Unifi::class,
'Portainer' => \App\SupportedApps\Portainer::class,
+ 'UniFi' => \App\SupportedApps\Unifi::class,
+ 'Sabnzbd' => \App\SupportedApps\Sabnzbd::class,
];
}
public static function supportedOptions()
@@ -58,13 +59,39 @@ class Item extends Model
$view = null;
if(isset($this->description) && !empty($this->description)){
$output = json_decode($this->description);
+ $output = is_object($output) ? $output : new \stdClass();
if(isset($output->type) && !empty($output->type)) {
$class = $output->type;
$sap = new $class();
$view = $sap->configDetails();
+ $output->view = $view;
}
- $output->view = $view;
+ if(!isset($output->dataonly)) $output->dataonly = '0';
+
}
return (object)$output;
}
+ public static function checkConfig($config)
+ {
+ if(empty($config)) {
+ $config = null;
+ } else {
+ $store = false;
+ //die(var_dump($config));
+ foreach($config as $key => $check) {
+ if($key == 'type') continue;
+ if($key == 'dataonly') continue;
+ if(!empty($check) && $check != '0') {
+ $store = true;
+ break;
+ }
+ }
+ //die(var_dump($store))
+
+ $config['enabled'] = ($store) ? true : false;
+ $config = json_encode($config);
+ }
+ return $config;
+
+ }
}
diff --git a/app/Setting.php b/app/Setting.php
index 8eae80dd..cf8cc22e 100644
--- a/app/Setting.php
+++ b/app/Setting.php
@@ -97,8 +97,8 @@ class Setting extends Model
if(isset($this->value) && (bool)$this->value === true) $checked = true;
$set_checked = ($checked) ? ' checked="checked"' : '';
$value = '
+
';
diff --git a/app/SupportedApps/Contracts/Applications.php b/app/SupportedApps/Contracts/Applications.php
index 99ddb1b7..535c7958 100644
--- a/app/SupportedApps/Contracts/Applications.php
+++ b/app/SupportedApps/Contracts/Applications.php
@@ -5,7 +5,5 @@ interface Applications {
public function defaultColour();
public function icon();
-
- public function configDetails();
}
\ No newline at end of file
diff --git a/app/SupportedApps/Contracts/Livestats.php b/app/SupportedApps/Contracts/Livestats.php
new file mode 100644
index 00000000..89e45b9c
--- /dev/null
+++ b/app/SupportedApps/Contracts/Livestats.php
@@ -0,0 +1,11 @@
+buildRequest('status');
+ 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('status');
+ $data = json_decode($res->getBody());
+ //$data->result->RemainingSizeMB = '10000000';
+ //$data->result->DownloadRate = '100000000';
+ $size = $data->result->RemainingSizeMB;
+ $rate = $data->result->DownloadRate;
+ $queue_size = format_bytes($size*1000*1000, false, ' ', '');
+ $current_speed = format_bytes($rate, false, ' ');
+
+ if($size > 0 || $rate > 0) {
+ $output = '
+
+
+
+ ';
+ }
+ return $output;
+ }
+ public function buildRequest($endpoint)
+ {
+ $config = $this->config;
+ $url = $config->url;
+ $username = $config->username;
+ $password = $config->password;
+
+ $rebuild_url = str_replace('http://', 'http://'.$username.':'.$password.'@', $url);
+ $rebuild_url = str_replace('https://', 'https://'.$username.':'.$password.'@', $rebuild_url);
+
+ $api_url = $rebuild_url.'jsonrpc/'.$endpoint;
+
+ $client = new Client(['http_errors' => false]);
+ $res = $client->request('GET', $api_url);
+ return $res;
+
}
}
\ No newline at end of file
diff --git a/app/SupportedApps/Pfsense.php b/app/SupportedApps/Pfsense.php
index daf465a3..eadbb096 100644
--- a/app/SupportedApps/Pfsense.php
+++ b/app/SupportedApps/Pfsense.php
@@ -3,14 +3,10 @@
class Pfsense implements Contracts\Applications {
public function defaultColour()
{
- return '#222';
+ return '#4e4742';
}
public function icon()
{
return 'supportedapps/pfsense.png';
}
- public function configDetails()
- {
- return null;
- }
}
\ No newline at end of file
diff --git a/app/SupportedApps/Pihole.php b/app/SupportedApps/Pihole.php
index b558e4a5..83b132a0 100644
--- a/app/SupportedApps/Pihole.php
+++ b/app/SupportedApps/Pihole.php
@@ -1,16 +1,70 @@
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 = '
+