Display Name in availability map (#13841)

* Display Name option in availability map widget

* fix availability map page and shortDisplayName
This commit is contained in:
Tony Murray 2022-03-12 16:14:09 -06:00 committed by GitHub
parent 964cdfbbc3
commit 6d3bf03074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 10 deletions

View File

@ -242,7 +242,7 @@ class Device extends BaseModel
$length = \LibreNMS\Config::get('shorthost_target_length', $length);
if ($length < strlen($name)) {
$take = substr_count($name, '.', 0, $length) + 1;
$take = max(substr_count($name, '.', 0, $length), 1);
return implode('.', array_slice(explode('.', $name), 0, $take));
}

View File

@ -170,7 +170,7 @@ if (defined('SHOW_SETTINGS')) {
$in_devices = dbFetchColumn($device_group, [Session::get('group_view')]);
}
$sql = 'SELECT `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`status`, `D`.`uptime`, `D`.`last_polled`, `D`.`os`, `D`.`icon`, `D`.`disable_notify`, `D`.`disabled` FROM `devices` AS `D`';
$sql = 'SELECT `D`.`hostname`, `D`.`sysName`, `D`.`display`, `D`.`device_id`, `D`.`status`, `D`.`uptime`, `D`.`last_polled`, `D`.`os`, `D`.`icon`, `D`.`disable_notify`, `D`.`disabled` FROM `devices` AS `D`';
if (! Auth::user()->hasGlobalRead()) {
$sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND ';

View File

@ -30,17 +30,15 @@
@if($type == 0)
@if($color_only_select == 1)
<span class="label {{ $row['labelClass'] }} widget-availability-fixed widget-availability label-font-border"> </span>
@else
@if($color_only_select == 2)
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['device']->hostname) }}</span>
@else
@if($color_only_select == 3)
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['device']->sysName) }}</span>
@elseif($color_only_select == 2)
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['device']->hostname }}</span>
@elseif($color_only_select == 3)
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['device']->sysName }}</span>
@elseif($color_only_select == 4)
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['device']->shortDisplayName() }}</span>
@else
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['stateName']) }}</span>
@endif
@endif
@endif
@else
<div class="availability-map-oldview-box-{{ $row['stateName'] }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
@endif

View File

@ -18,6 +18,7 @@
<label for="color_only_select-{{ $id }}" class="control-label">{{ __('Display Text') }}</label>
<select class="form-control" name="color_only_select" id="color_only_select-{{ $id }}">
<option value="1" @if($color_only_select == 1) selected @endif>{{ __('empty') }}</option>
<option value="4" @if($color_only_select == 4) selected @endunless>{{ __('Display Name') }}</option>
<option value="2" @if($color_only_select == 2) selected @endunless>{{ __('Hostname') }}</option>
<option value="3" @if($color_only_select == 3) selected @endunless>{{ __('Sysname') }}</option>
<option value="0" @unless($color_only_select) selected @endunless>{{ __('Device Status') }}</option>