mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Display Name in availability map (#13841)
* Display Name option in availability map widget * fix availability map page and shortDisplayName
This commit is contained in:
@@ -242,7 +242,7 @@ class Device extends BaseModel
|
|||||||
|
|
||||||
$length = \LibreNMS\Config::get('shorthost_target_length', $length);
|
$length = \LibreNMS\Config::get('shorthost_target_length', $length);
|
||||||
if ($length < strlen($name)) {
|
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));
|
return implode('.', array_slice(explode('.', $name), 0, $take));
|
||||||
}
|
}
|
||||||
|
@@ -170,7 +170,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||||||
$in_devices = dbFetchColumn($device_group, [Session::get('group_view')]);
|
$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()) {
|
if (! Auth::user()->hasGlobalRead()) {
|
||||||
$sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND ';
|
$sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND ';
|
||||||
|
@@ -30,17 +30,15 @@
|
|||||||
@if($type == 0)
|
@if($type == 0)
|
||||||
@if($color_only_select == 1)
|
@if($color_only_select == 1)
|
||||||
<span class="label {{ $row['labelClass'] }} widget-availability-fixed widget-availability label-font-border"> </span>
|
<span class="label {{ $row['labelClass'] }} widget-availability-fixed widget-availability label-font-border"> </span>
|
||||||
@else
|
@elseif($color_only_select == 2)
|
||||||
@if($color_only_select == 2)
|
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['device']->hostname }}</span>
|
||||||
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['device']->hostname) }}</span>
|
@elseif($color_only_select == 3)
|
||||||
@else
|
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['device']->sysName }}</span>
|
||||||
@if($color_only_select == 3)
|
@elseif($color_only_select == 4)
|
||||||
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['device']->sysName) }}</span>
|
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ $row['device']->shortDisplayName() }}</span>
|
||||||
@else
|
@else
|
||||||
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['stateName']) }}</span>
|
<span class="label {{ $row['labelClass'] }} widget-availability label-font-border">{{ __($row['stateName']) }}</span>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
|
||||||
@endif
|
|
||||||
@else
|
@else
|
||||||
<div class="availability-map-oldview-box-{{ $row['stateName'] }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
|
<div class="availability-map-oldview-box-{{ $row['stateName'] }}" style="width:{{ $tile_size }}px;height:{{ $tile_size }}px;"></div>
|
||||||
@endif
|
@endif
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
<label for="color_only_select-{{ $id }}" class="control-label">{{ __('Display Text') }}</label>
|
<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 }}">
|
<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="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="2" @if($color_only_select == 2) selected @endunless>{{ __('Hostname') }}</option>
|
||||||
<option value="3" @if($color_only_select == 3) selected @endunless>{{ __('Sysname') }}</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>
|
<option value="0" @unless($color_only_select) selected @endunless>{{ __('Device Status') }}</option>
|
||||||
|
Reference in New Issue
Block a user