Only Admins can see different Tabs in Device

This commit is contained in:
Luca Haid
2025-01-29 16:42:33 +01:00
parent 0a71458672
commit 9e1802795d
2 changed files with 6 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ class DeviceController extends mfBaseController
"DEVICE_MANUFACTURERS" => $deviceManufacturers,
"DEVICE_TYPES" => $deviceTypes,
"DEVICES" => $this->getDevices(),
"IS_ADMIN" => $this->me->is(["Admin"]),
"ZABBIX_URL" => (defined("ZABBIX_URL")) ? ZABBIX_URL : "",
"GRAFANA_URL" => (defined("GRAFANA_URL")) ? GRAFANA_URL : "",
];

View File

@@ -14,8 +14,8 @@ Vue.component('device-view-switch', {
<div class="device-view-switch" style="margin-bottom: 10px">
<div v-if="!isOverflowing" class="button-group" style="display:grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-content: center; align-items: center; text-align: center; width: 100%;">
<button @click="$emit('input', 'DeviceTable')" :class="{ 'active': value === 'DeviceTable' }" class="btn btn-primary">Devices</button>
<button @click="$emit('input', 'DeviceManufacturer')" :class="{ 'active': value === 'DeviceManufacturer' }" class="btn btn-primary">Hersteller</button>
<button @click="$emit('input', 'DeviceType')" :class="{ 'active': value === 'DeviceType' }" class="btn btn-primary">Geräte Typen</button>
<button v-show="window.TT_CONFIG['IS_ADMIN'] === '1'" @click="$emit('input', 'DeviceManufacturer')" :class="{ 'active': value === 'DeviceManufacturer' }" class="btn btn-primary">Hersteller</button>
<button v-show="window.TT_CONFIG['IS_ADMIN'] === '1'" @click="$emit('input', 'DeviceType')" :class="{ 'active': value === 'DeviceType' }" class="btn btn-primary">Geräte Typen</button>
</div>
<div v-else>
<div class="dropdown">
@@ -23,8 +23,8 @@ Vue.component('device-view-switch', {
class="btn btn-primary dropdown-toggle">Ansicht</button>
<div v-show="showDropdown" class="dropdown-menu show">
<a href="#" @click="$emit('input', 'DeviceTable'); showDropdown = false" class="dropdown-item">Devices</a>
<a href="#" @click="$emit('input', 'DeviceManufacturer'); showDropdown = false" class="dropdown-item">Hersteller</a>
<a href="#" @click="$emit('input', 'DeviceType'); showDropdown = false" class="dropdown-item">Geräte Typen</a>
<a v-show="window.TT_CONFIG['IS_ADMIN'] === '1'" href="#" @click="$emit('input', 'DeviceManufacturer'); showDropdown = false" class="dropdown-item">Hersteller</a>
<a v-show="window.TT_CONFIG['IS_ADMIN'] === '1'" href="#" @click="$emit('input', 'DeviceType'); showDropdown = false" class="dropdown-item">Geräte Typen</a>
</div>
</div>
</div>
@@ -33,6 +33,7 @@ Vue.component('device-view-switch', {
props: ['value'],
data() {
return {
window: window,
isOverflowing: false,
showDropdown: false,
};