Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Shoko/shoko.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions Steerhouse/Steerhouse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\SupportedApps\Steerhouse;

class Steerhouse extends \App\SupportedApps implements \App\EnhancedApps
{
public $config;

public function __construct()
{
}

public function test()
{
$test = parent::appTest($this->url('api/stats'), $this->getAttrs());
echo $test->status;
}

public function livestats()
{
$status = 'inactive';
$data = [
'running' => 0,
'queued' => 0,
'failed' => 0,
];

// GET /api/stats returns counts only, e.g. {"queued": 0, "running": 2, "succeeded_24h": 14,
// "failed_24h": 1, "workers_online": 3}. execute() returns null when the connection fails;
// a bad key gets a 401 whose body has no counts, so the tile stays at zero and inactive.
$res = parent::execute($this->url('api/stats'), $this->getAttrs());
if ($res !== null && $res->getStatusCode() === 200) {
$body = json_decode($res->getBody());
if (isset($body->running, $body->queued, $body->failed_24h)) {
$data['running'] = (int) $body->running;
$data['queued'] = (int) $body->queued;
$data['failed'] = (int) $body->failed_24h;
// Refresh every 5 seconds while runs are waiting or in progress, else every 30.
if ($data['running'] > 0 || $data['queued'] > 0) {
$status = 'active';
}
}
}

return parent::getLiveStats($status, $data);
}

private function getAttrs()
{
// A "stats" API key from Projects -> API keys in Steerhouse: it can read these counts only.
$attrs = [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . ($this->config->apikey ?? ''),
],
];
if (!empty($this->config->ignore_tls)) {
$attrs['verify'] = false;
}
return $attrs;
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}
}
10 changes: 10 additions & 0 deletions Steerhouse/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"appid": "422c6bf3a19cca6e7c2e59a393b1838cca9bb6e9",
"name": "Steerhouse",
"website": "https://github.com/HoneyBearTech/Steerhouse",
"license": "MIT License",
"description": "Self-hosted web UI and API for running Ansible playbooks, with per-project access control, isolated workers and a full audit trail.",
"enhanced": true,
"tile_background": "dark",
"icon": "steerhouse.svg"
}
31 changes: 31 additions & 0 deletions Steerhouse/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::input('password', 'config[apikey]', isset($item) ? ($item->getconfig()->apikey ?? null) : null, ['placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<label>Skip TLS verification</label>
<div class="toggleinput" style="margin-top: 26px; padding-left: 15px;">
{!! Form::hidden('config[ignore_tls]', 0, ['class' => 'config-item', 'data-config' => 'ignore_tls']) !!}
<label class="switch">
<?php
$checked = false;
if (isset($item) && !empty($item) && isset($item->getconfig()->ignore_tls)) {
$checked = $item->getconfig()->ignore_tls;
}
$set_checked = $checked ? ' checked="checked"' : '';
?>
<input type="checkbox" class="config-item" data-config="ignore_tls" name="config[ignore_tls]" value="1" <?php echo $set_checked; ?> />
<span class="slider round"></span>
</label>
</div>
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>
14 changes: 14 additions & 0 deletions Steerhouse/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<ul class="livestats">
<li>
<span class="title">Run</span>
<strong>{!! $running ?? 0 !!}</strong>
</li>
<li>
<span class="title">Queue</span>
<strong>{!! $queued ?? 0 !!}</strong>
</li>
<li>
<span class="title">Failed</span>
<strong>{!! $failed ?? 0 !!}</strong>
</li>
</ul>
1 change: 1 addition & 0 deletions Steerhouse/steerhouse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Verdaccio/verdaccio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading