Rewrite devices page backend (and a little frontend) (#9726)

* Implement devices table data output

* initial filter

* Add select2 filters
improve table header layout
improve init_select2

* bump versions to be safe

* add group filtering
fix location sorting

* allow filter value morphing

* add missing state filter

* remove the old devices endpoint
This commit is contained in:
Tony Murray
2019-01-25 15:31:33 -06:00
committed by GitHub
parent ce6fae8dd1
commit 590c488d74
14 changed files with 587 additions and 460 deletions

View File

@@ -151,6 +151,18 @@ class Device extends BaseModel
return $this->hostname;
}
public function name()
{
$displayName = $this->displayName();
if ($this->sysName !== $displayName) {
return $this->sysName;
} elseif ($this->hostname !== $displayName && $this->hostname !== $this->ip) {
return $this->hostname;
}
return '';
}
public function isUnderMaintenance()
{
$query = AlertSchedule::isActive()
@@ -172,6 +184,23 @@ class Device extends BaseModel
return $query->exists();
}
public function loadOs($force = false)
{
global $config;
if (empty($config['os'][$this->os]) || $force) {
$os = \Symfony\Component\Yaml\Yaml::parse(
file_get_contents(base_path('/includes/definitions/' . $this->os . '.yaml'))
);
if (isset($config['os'][$this->os])) {
$config['os'][$this->os] = array_replace_recursive($os, $config['os'][$this->os]);
} else {
$config['os'][$this->os] = $os;
}
}
}
/**
* Get the shortened display name of this device.
* Length is always overridden by shorthost_target_length.
@@ -575,4 +604,9 @@ class Device extends BaseModel
{
return $this->hasMany('App\Models\Vrf', 'device_id');
}
public function wirelessSensors()
{
return $this->hasMany('App\Models\WirelessSensor', 'device_id');
}
}