ajout heimdall
This commit is contained in:
55
heimdall/config/www/SupportedApps/Octoprint/Octoprint.php
Executable file
55
heimdall/config/www/SupportedApps/Octoprint/Octoprint.php
Executable 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;
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/Octoprint/app.json
Executable file
10
heimdall/config/www/SupportedApps/Octoprint/app.json
Executable 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"
|
||||
}
|
||||
15
heimdall/config/www/SupportedApps/Octoprint/config.blade.php
Executable file
15
heimdall/config/www/SupportedApps/Octoprint/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) ? $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>
|
||||
|
||||
22
heimdall/config/www/SupportedApps/Octoprint/livestats.blade.php
Executable file
22
heimdall/config/www/SupportedApps/Octoprint/livestats.blade.php
Executable 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>
|
||||
BIN
heimdall/config/www/SupportedApps/Octoprint/octoprint.png
Executable file
BIN
heimdall/config/www/SupportedApps/Octoprint/octoprint.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Reference in New Issue
Block a user