Skip to content

Commit

Permalink
Fix Collector Dashboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Feb 6, 2024
1 parent 9e3c077 commit ecee271
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +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('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
7 changes: 5 additions & 2 deletions app/Controllers/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ public function about()
*/
public function collector()
{
if (empty($this->config->servers)) {
return redirect()->route('home');
}
$tasksModel = new \App\Models\TasksModel();
$tasks = $tasksModel->collection();
$tasks = $tasksModel->listAll();
foreach ($tasks as $task) {
if ($task->attributes->type === 'collector') {
if ($task->type === 'collector') {
$this->resp->data[] = $task;
}
}
Expand Down
7 changes: 6 additions & 1 deletion app/Models/TasksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ public function includedRead(int $id = 0): array
{
$result = $this->builder->getWhere(['id' => intval($id)])->getResult()[0];
$type = ucfirst($result->type);
$namespace = "\\App\\Models\\" . $type . "Model";
if ($type != 'Collector') {
$namespace = "\\App\\Models\\" . $type . "Model";
}
if ($type === 'Collector') {
$namespace = "\\App\\Models\\CollectorsModel";
}
$typeModel = new $namespace;
$included[strtolower($type)] = $typeModel->listUser();

Expand Down
12 changes: 6 additions & 6 deletions app/Views/dashboardsCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# 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]->{'hour'}, '*/') !== false) {
$every = str_replace('*/', '', $data[0]->{'hour'}) . ' hours';
}
if (stripos($data[0]->{'attributes'}->{'minute'}, '*/') !== false) {
$minute = str_replace('*/', '', $data[0]->{'attributes'}->{'minute'});
if (stripos($data[0]->{'minute'}, '*/') !== false) {
$minute = str_replace('*/', '', $data[0]->{'minute'});
if ($every != "") {
$every .= ', ' . $minute . ' minutes';
} else {
Expand All @@ -29,8 +29,8 @@
<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 if ($data[0]->{'last_run'} != "2000-01-01 00:00:00") { ?>
The last time this task was run was <?= $data[0]->{'last_run'}; ?>.<br /><br />
<?php } else { ?>
This task has not yet been run.<br /><br />
<?php } ?>
Expand Down

0 comments on commit ecee271

Please sign in to comment.