ajout heimdall

This commit is contained in:
2025-01-01 11:24:01 +01:00
parent f8be42e486
commit c52f60fca9
1477 changed files with 15692 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
<?php namespace App\SupportedApps\AriaNg;
class AriaNg 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
}
public function test()
{
$attrs = $this->newRequestAttrs('aria2.getVersion');
$test = parent::appTest($this->url('jsonrpc'), $attrs);
if ($test->code === 200) {
$data = json_decode($test->response);
if (isset($data->result) && isset($data->result->version)) {
$version = $data->result->version;
$test->status = "Connected to Aria2 v$version";
}
else {
$test->status ="Unknown Aria2 version";
}
}
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$attrs = $this->newRequestAttrs('aria2.getGlobalStat');
$res = parent::execute($this->url('jsonrpc'), $attrs);
if ($res == null) {
//Log::debug('Aria2 connection failed');
return '';
}
$details = json_decode($res->getBody());
if (!isset($details->result)) {
//Log::debug('Failed to fetch data from Aria2');
return '';
}
$downloadSpeed = $details->result->downloadSpeed;
$uploadSpeed = $details->result->uploadSpeed;
$active = $details->result->numActive;
$stopped = $details->result->numStopped;
$waiting = $details->result->numWaiting;
if ($active > 0) {
$status = 'active';
}
$data = [];
$data['download_rate'] = format_bytes($downloadSpeed, false, ' <span>', '/s</span>');
$data['upload_rate'] = format_bytes($uploadSpeed, false, ' <span>', '/s</span>');
$data['running_count'] = ($active + $waiting) ?? 0;
$data['stopped_count'] = $stopped ?? 0;
return parent::getLiveStats($status, $data);
}
private function newRequestAttrs($rpcMethod)
{
$body = [
'jsonrpc' => '2.0',
'id' => 'qwer',
'method' => $rpcMethod
];
if (isset($this->config->password)) {
$body['params'] = ['token:'.$this->config->password];
}
$attrs = [
'body' => json_encode($body),
'cookies' => $this->jar,
'headers' => ['Content-Type' => 'application/json', 'Accept' => 'application/json']
];
return $attrs;
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).$endpoint;
return $api_url;
}
}

View File

@@ -0,0 +1,10 @@
{
"appid": "a0f88a6334b03ff11dc56d1b627f122ccacb75ce",
"name": "AriaNg",
"website": "https://github.com/mayswind/AriaNg",
"license": "MIT License",
"description": "AriaNg is a modern web frontend making aria2 easier to use. AriaNg is written in pure html & javascript, thus it does not need any compilers or runtime environment. You can just put AriaNg in your web server and open it in your browser. AriaNg uses responsive layout, and supports any desktop or mobile devices.",
"enhanced": true,
"tile_background": "dark",
"icon": "ariang.png"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,14 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }} (http://HOST:PORT)</label>
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }} (secret token)</label>
{!! Form::password('config[password]', (isset($item) ? $item->getconfig()->password: null), array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

View File

@@ -0,0 +1,4 @@
<ul class="livestats">
<li><span class="title">RUN: {{ $running_count}}</span><strong>{!! $download_rate !!}</strong></li>
<li><span class="title">DONE: {{ $stopped_count }}</span><strong>{!! $upload_rate !!}</strong></li>
</ul>