closes #75 and adds initial support for proxmox

This commit is contained in:
KodeStar 2018-02-13 22:46:36 +00:00
parent 88c36d2b2d
commit 592f8f0831
6 changed files with 99 additions and 3 deletions

View file

@ -129,7 +129,7 @@ class ItemController extends Controller
//
$validatedData = $request->validate([
'title' => 'required|max:255',
'url' => 'required',
'url' => 'required|url',
]);
if($request->hasFile('file')) {
@ -190,7 +190,7 @@ class ItemController extends Controller
{
$validatedData = $request->validate([
'title' => 'required|max:255',
'url' => 'required',
'url' => 'required|url',
]);
//die(print_r($request->all()));
if($request->hasFile('file')) {

View file

@ -41,6 +41,7 @@ class Item extends Model
'Plexpy' => \App\SupportedApps\Plexpy::class,
'Plexrequests' => \App\SupportedApps\Plexrequests::class,
'Portainer' => \App\SupportedApps\Portainer::class,
'Proxmox' => \App\SupportedApps\Proxmox::class,
'Radarr' => \App\SupportedApps\Radarr::class,
'Sabnzbd' => \App\SupportedApps\Sabnzbd::class,
'Sonarr' => \App\SupportedApps\Sonarr::class,

View file

@ -0,0 +1,80 @@
<?php namespace App\SupportedApps;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
class Proxmox implements Contracts\Applications, Contracts\Livestats {
public function defaultColour()
{
return '#542e0a';
}
public function icon()
{
return 'supportedapps/proxmox.png';
}
public function configDetails()
{
//return 'proxmox';
return null;
}
public function testConfig()
{
/*$res = $this->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;
}*/
return null;
}
public function executeConfig()
{
/*
$output = '';
$res = $this->buildRequest();
$data = json_decode($res->getBody());
$output = '
<ul class="livestats">
<li><span class="title">Domains<br />Blocked</span><strong>'.$data->domains_being_blocked.'</strong></li>
<li><span class="title">Blocked<br />Today</span><strong>'.$data->ads_blocked_today.'</span></strong></li>
</ul>
';
return $output;
*/
return null;
}
public function buildRequest($endpoint='')
{
$config = $this->config;
$username = $config->username;
$password = $config->password;
$url = $config->url;
$url = rtrim($url, '/');
$api_url = $url.'/api2/json/'.$endpoint.'?username='.$username.'&password='.$password;
//die( $api_url.' --- ');
$client = new Client(['http_errors' => false, 'verify' => false ]);
$res = $client->request('GET', $api_url);
return $res;
}
}

View file

@ -7,7 +7,7 @@
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
{!! Form::text('config[password]', null, array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!}
<input type="password" name="config[password]" value="{{ $item->config->password }}" placeholder="{{ __('app.apps.password') }}" class="form-control config-item" data-config="password" />
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>

View file

@ -0,0 +1,15 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
<div class="items">
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\Proxmox" />
<div class="input">
<label>{{ __('app.apps.username') }}</label>
{!! Form::text('config[username]', null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
<input type="password" name="config[password]" value="{{ $item->config->password or '' }}" placeholder="{{ __('app.apps.password') }}" class="form-control config-item" data-config="password" />
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB