Skip to content

Commit

Permalink
Add a Collector Dashboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Feb 6, 2024
1 parent de02f8e commit 9e3c077
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
$routes->get('features', 'Help::features', ['filter' => \App\Filters\Session::class, 'as' => 'features']);
$routes->get('prereq', 'Help::prereq', ['filter' => \App\Filters\Session::class, 'as' => 'prereq']);
$routes->get('welcome', 'Help::welcome', ['filter' => \App\Filters\Session::class, 'as' => 'welcome']);
$routes->get('dashboards/collector', 'Help::collector', ['filter' => \App\Filters\Session::class, 'as' => 'dashboardCollector']);
$routes->get('appLicenses', 'Help::licenses', ['filter' => \App\Filters\Session::class, 'as' => 'appLicenses']);
$routes->get('getting_started', 'Help::gettingStarted', ['filter' => \App\Filters\Session::class, 'as' => 'getting_started']);
$routes->get('discovery_issues/(:num)', 'Help::discoveryIssues/$1', ['filter' => \App\Filters\Session::class, 'as' => 'discoveryIssues']);
Expand Down
29 changes: 29 additions & 0 deletions app/Controllers/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,35 @@ public function about()
. view('shared/footer', ['license_string' => $this->resp->meta->license_string]);
}

/**
* The Welcome page
*
* @access public
* @return NULL
*/
public function collector()
{
$tasksModel = new \App\Models\TasksModel();
$tasks = $tasksModel->collection();
foreach ($tasks as $task) {
if ($task->attributes->type === 'collector') {
$this->resp->data[] = $task;
}
}

return view('shared/header', [
'config' => $this->config,
'dashboards' => filter_response($this->dashboards),
'data' => filter_response($this->resp->data),
'meta' => filter_response($this->resp->meta),
'orgs' => filter_response($this->orgsUser),
'queries' => filter_response($this->queriesUser),
'roles' => filter_response($this->roles),
'user' => filter_response($this->user)]) .
view('dashboardsCollector', [])
. view('shared/footer', ['license_string' => $this->resp->meta->license_string]);
}

/**
* The Features page
*
Expand Down
45 changes: 45 additions & 0 deletions app/Views/dashboardsCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
# Copyright © 2023 FirstWave. All Rights Reserved.
# SPDX-License-Identifier: AGPL-3.0-or-later
include 'shared/collection_functions.php';
$every = '';
if (stripos($data[0]->{'attributes'}->{'hour'}, '*/') !== false) {
$every = str_replace('*/', '', $data[0]->{'attributes'}->{'hour'}) . ' hours';
}
if (stripos($data[0]->{'attributes'}->{'minute'}, '*/') !== false) {
$minute = str_replace('*/', '', $data[0]->{'attributes'}->{'minute'});
if ($every != "") {
$every .= ', ' . $minute . ' minutes';
} else {
$every = $minute . ' minutes';
}
}
?>
<main class="container-fluid">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-4 clearfix">
<h6 style="padding-top:10px;"><span class="fa fa-chart-bar oa-icon"></span><?= __('Collector') ?></h6>
</div>
</div>
</div>
<div class="card-body">
<div class="row">
<p class="text-center"><br />
<?php if ($every != '') { ?>
This collector requests tasks every <?= $every ?>.<br /><br />
<?php if ($data[0]->{'attributes'}->{'last_run'} != "2000-01-01 00:00:00") { ?>
The last time this task was run was <?= $data[0]->{'attributes'}->{'last_run'}; ?>.<br /><br />
<?php } else { ?>
This task has not yet been run.<br /><br />
<?php } ?>
<?php } else { ?>
<b>This collector is not requesting tasks.</b><br /><br />
<?php } ?>
The number of devices discovered by this collector is <?= $config->device_count ?>.
</div>
</div>
</div>
<br />
</main>

0 comments on commit 9e3c077

Please sign in to comment.