KodeStar
7 years ago
6 changed files with 99 additions and 3 deletions
@ -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; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -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> |
After Width: | Height: | Size: 3.3 KiB |
Loading…
Reference in new issue