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,55 @@
<?php namespace App\SupportedApps\Octoprint;
use Carbon\Carbon;
class Octoprint 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() {
}
public function test()
{
$attrs['headers'] = ['X-Api-Key' => $this->config->apikey];
$test = parent::appTest($this->url('api/version'), $attrs);
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$attrs['headers'] = ['X-Api-Key' => $this->config->apikey];
$res = parent::execute($this->url('api/job'), $attrs);
if(!$res) return parent::getLiveStats($status, ['error' => "Connection"]);
$details = json_decode($res->getBody());
$data = [];
$progress = $details->progress->completion;
$data['progress'] = @round($progress) ?? 0;
$seconds = $details->progress->printTimeLeft;
if($seconds === null) {
$data['estimated'] = 'N/A';
} elseif($seconds > 0) {
$data['estimated'] = Carbon::now()->addSeconds($seconds)->diffForHumans();
} else {
$data['estimated'] = 'N/A';
}
$status = ($data['progress'] < 100 && $progress !== null) ? 'active' : 'inactive';
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).$endpoint;
return $api_url;
}
}

View File

@@ -0,0 +1,10 @@
{
"appid": "99be0df8034cbcd7b5dfb3290839f7db21c1acbb",
"name": "Octoprint",
"website": "https://octoprint.org/",
"license": "GNU Affero General Public License v3.0",
"description": "OctoPrint is the snappy web interface for your 3D printer that allows you to control and monitor all aspects of your printer and print jobs, right from your browser.",
"enhanced": true,
"tile_background": "dark",
"icon": "octoprint.png"
}

View 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) ? $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>

View File

@@ -0,0 +1,22 @@
<ul class="livestats">
@if(isset($error))
<li>
<span class="title">ERROR</span>
<strong>{!! $error !!}</strong>
</li>
@else
@if(isset($progress))
<li>
<span class="title">Progress</span>
<strong>{!! $progress !!}<span>%</span></strong>
</li>
@endif
@if(isset($estimated))
<li class="right">
<span class="title">Finish</span>
<strong>{!! $estimated !!}</strong>
</li>
@endif
@endif
</ul>

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB