Files
librenms-librenms/app/Http/Controllers/Widgets/DeviceSummaryController.php
Tony Murray 9ede688d13 Replace legacy menu with new Blade generated one (#10173)
* Remove legacy index php file

* fix routing page missing data

* WIP

* fix $navbar global usage

* remove global use of $locations

* ObjectCache again...

* move vars.inc.php to init.php for legacy ajax

* navbar is more local than I thought before.  Fix it.

* Fix some sensors tables escaping

* restore custom menu functionality, but with blade
and docs

* cleanup

* tidy menu @if checks

* Fix up the rest of the global variables and remove print-menubar.php

* consolidate some counting in the menu

* filter out empty custom port descr types

* Fix up custom port groups

* Fix up apps menu

* Fix services menu when all are ok

* Limit cached data to the user it is for

* Fix style

* A few clean ups

* fix pseudowire bug
2019-05-10 11:02:39 -05:00

72 lines
2.2 KiB
PHP

<?php
/**
* DeviceSummaryController.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Http\Controllers\Widgets;
use App\Models\Device;
use App\Models\Port;
use App\Models\Service;
use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\Util\ObjectCache;
abstract class DeviceSummaryController extends WidgetController
{
protected $title = 'Device Summary';
public function __construct()
{
// init defaults we need to check config, so do it in construct
$this->defaults = [
'show_services' => (int)Config::get('show_services', 1),
'summary_errors' => (int)Config::get('summary_errors', 0)
];
}
public function getSettingsView(Request $request)
{
$settings = $this->getSettings();
return view('widgets.settings.device-summary', $settings);
}
protected function getData(Request $request)
{
$data = $this->getSettings();
$data['devices'] = ObjectCache::deviceCounts(['total', 'up', 'down', 'ignored', 'disabled']);
$data['ports'] = $data['summary_errors'] ?
ObjectCache::portCounts(['total', 'up', 'down', 'ignored', 'shutdown', 'errored']) :
ObjectCache::portCounts(['total', 'up', 'down', 'ignored', 'shutdown']);
if ($data['show_services']) {
$data['services'] = ObjectCache::serviceCounts(['total', 'ok', 'critical', 'ignored', 'disabled']);
}
return $data;
}
}