Skip to content

Commit

Permalink
feat: enhance scrutiny foundation app (#696)
Browse files Browse the repository at this point in the history
* feat: enhance scrutiny foundation app

* chore: update scrutiny to use spaces rather than tabsuse spaces rather than tabs
  • Loading branch information
imnotjames committed Feb 27, 2024
1 parent b9eb06f commit f912eac
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
58 changes: 57 additions & 1 deletion Scrutiny/Scrutiny.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

namespace App\SupportedApps\Scrutiny;

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

public function __construct()
{
}

public function test()
{
$attrs = [
"headers" => ["Accept" => "application/json"],
];
$test = parent::appTest($this->url("health"), $attrs);
echo $test->status;
}

public function livestats()
{
$status = "inactive";
$data = [
"passed" => 0,
"failed" => 0,
];

$attrs = [
"headers" => ["Accept" => "application/json"],
];

$response = json_decode(
parent::execute($this->url("summary"), $attrs)->getBody()
);

$summary = $response->data->summary;

foreach ($summary as $entry) {
$device_status = $entry->device->device_status;

if ($device_status == 0) {
$data["passed"]++;
} else {
$status = "active";
$data["failed"]++;
}
}

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

public function url($endpoint)
{
$api_url =
parent::normaliseurl($this->config->url) .
"api/" .
$endpoint;

return $api_url;
}
}
2 changes: 1 addition & 1 deletion Scrutiny/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"website": "https://github.com/AnalogJ/scrutiny",
"license": "MIT License",
"description": "Scrutiny is a Hard Drive Health Dashboard & Monitoring solution, merging manufacturer provided S.M.A.R.T metrics with real-world failure rates.",
"enhanced": false,
"enhanced": true,
"tile_background": "light",
"icon": "scrutiny.png"
}
23 changes: 23 additions & 0 deletions Scrutiny/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<input type="hidden" data-config="dataonly" class="config-item" name="config[dataonly]" value="1" />
<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>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">
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>
11 changes: 11 additions & 0 deletions Scrutiny/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<ul class="livestats">
<li>
<span class="title">Passed</span>
<strong>{!! $passed ?? 0 !!}</strong>
</li>

<li>
<span class="title">Failed</span>
<strong>{!! $failed ?? 0 !!}</strong>
</li>
</ul>

0 comments on commit f912eac

Please sign in to comment.