ajout heimdall
This commit is contained in:
61
heimdall/config/www/SupportedApps/Syncthing/Syncthing.php
Executable file
61
heimdall/config/www/SupportedApps/Syncthing/Syncthing.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php namespace App\SupportedApps\Syncthing;
|
||||
|
||||
class Syncthing 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
|
||||
|
||||
function __construct() {
|
||||
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
|
||||
}
|
||||
|
||||
function get_request_attrs() {
|
||||
$attrs['headers'] = ["X-API-Key" => $this->config->apikey];
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$attrs = $this->get_request_attrs();
|
||||
$test = parent::appTest($this->url('/rest/system/version'), $attrs);
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$data = [];
|
||||
$needed_files = 0;
|
||||
$needed_bytes = 0;
|
||||
$status = 'inactive';
|
||||
$attrs = $this->get_request_attrs();
|
||||
|
||||
# first get a list of folders
|
||||
$res = parent::execute($this->url('/rest/stats/folder'), $attrs);
|
||||
$details = json_decode($res->getBody());
|
||||
|
||||
foreach ($details as $folder => $folder_status) {
|
||||
$folder_db_res = parent::execute($this->url('/rest/db/status?folder=${folder}'), $attrs);
|
||||
$folder_db = json_decode($folder_db_res->getBody());
|
||||
|
||||
if ($folder_db) {
|
||||
$needed_files += $folder_db["needFiles"];
|
||||
$needed_bytes += $folder_db["needBytes"];
|
||||
}
|
||||
}
|
||||
|
||||
if ($needed_files || $needed_bytes) {
|
||||
$status = 'active';
|
||||
}
|
||||
|
||||
$data['needed_files'] = $needed_files;
|
||||
$data['needed_bytes'] = $needed_bytes;
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url).$endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/Syncthing/app.json
Executable file
10
heimdall/config/www/SupportedApps/Syncthing/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "7775c3bbf580fbaf57818e68ce7b1b48b8f93b95",
|
||||
"name": "Syncthing",
|
||||
"website": "https://syncthing.net/",
|
||||
"license": "Mozilla Public License 2.0",
|
||||
"description": "Syncthing is a free, open-source peer-to-peer file synchronization application. It can sync files between devices on a local network, or between remote devices over the Internet.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "syncthing.png"
|
||||
}
|
||||
15
heimdall/config/www/SupportedApps/Syncthing/config.blade.php
Executable file
15
heimdall/config/www/SupportedApps/Syncthing/config.blade.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ strtoupper(__('app.url')) }}</label>
|
||||
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.apikey') }}</label>
|
||||
{!! Form::text('config[apikey]', (isset($item) && property_exists($item->getconfig(), "apikey") ? $item->getconfig()->apikey : null), array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
10
heimdall/config/www/SupportedApps/Syncthing/livestats.blade.php
Executable file
10
heimdall/config/www/SupportedApps/Syncthing/livestats.blade.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<ul class="livestats">
|
||||
<li>
|
||||
<span class="title">Needed Files</span>
|
||||
<strong>{!! $needed_files !!}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Needed Bytes</span>
|
||||
<strong>{!! $needed_bytes !!}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
BIN
heimdall/config/www/SupportedApps/Syncthing/syncthing.png
Executable file
BIN
heimdall/config/www/SupportedApps/Syncthing/syncthing.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
Reference in New Issue
Block a user