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
+93
View File
@@ -0,0 +1,93 @@
<?php namespace App\SupportedApps\Freenas;
class Freenas 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()
{
$test = parent::appTest($this->url('core/ping'), $this->attrs);
if($test->code === 200) {
$data = $test->response;
if($test->response != '"pong"') {
$test->status = 'Failed: '.$data;
}
}
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$data = [];
$res = parent::execute($this->url('system/info'), $this->attrs);
$details = json_decode($res->getBody());
$seconds = $details->uptime_seconds ?? 0;
$data['uptime'] = $this->uptime($seconds);
$res = parent::execute($this->url('alert/list'), $this->attrs);
$details = json_decode($res->getBody(), true);
$data['alert_tot'] = $this->alerts($details);
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$this->attrs = ['auth'=> [$this->config->username, $this->config->password, 'Basic']];
$api_url = parent::normaliseurl($this->config->url).'api/v2.0/'.$endpoint;
return $api_url;
}
public function uptime($inputSeconds)
{
// Adapted from https://stackoverflow.com/questions/8273804/convert-seconds-into-days-hours-minutes-and-seconds
$res = '';
$secondsInAMinute = 60;
$secondsInAnHour = 60 * $secondsInAMinute;
$secondsInADay = 24 * $secondsInAnHour;
// extract days
$days = floor($inputSeconds / $secondsInADay);
// extract hours
$hourSeconds = $inputSeconds % $secondsInADay;
$hours = floor($hourSeconds / $secondsInAnHour);
// extract minutes
$minuteSeconds = $hourSeconds % $secondsInAnHour;
$minutes = floor($minuteSeconds / $secondsInAMinute);
// extract the remaining seconds
$remainingSeconds = $minuteSeconds % $secondsInAMinute;
$seconds = ceil($remainingSeconds);
//$res = strval($days).'d '.strval($hours).':'.sprintf('%02d', $minutes).':'.sprintf('%02d', $seconds);
if($days > 0) {
$res = strval($days).'d '.strval($hours).':'.sprintf('%02d', $minutes);
} else {
$res = strval($hours).':'.sprintf('%02d', $minutes).':'.sprintf('%02d', $seconds);
}
return $res;
}
public function alerts($alert)
{
$count = 0;
foreach($alert as $key => $value)
{
if ($value["dismissed"] == false) $count += 1;
}
return strval($count);
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"appid": "3d258071fa9cd41a85627f6bf7fc6998c3a8f5cf",
"name": "Freenas",
"website": "https://www.freenas.org/",
"license": "BSD-2-Clause",
"description": "FreeNAS is an embedded open source network-attached storage (NAS) operating system based on FreeBSD.",
"enhanced": true,
"tile_background": "light",
"icon": "freenas.png"
}
+19
View File
@@ -0,0 +1,19 @@
<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]', (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.username') }}</label>
{!! Form::text('config[username]', (isset($item) ? $item->getconfig()->username : null), array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
{!! Form::password('config[password]', array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item', 'type' => '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: 4.4 KiB

@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Uptime</span>
<strong>{!! $uptime !!}</strong>
</li>
<li>
<span class="title">Alerts</span>
<strong>{!! $alert_tot !!}</strong>
</li>
</ul>