diff --git a/Layout/default/Device/Index.php b/Layout/default/Device/Index.php deleted file mode 100644 index 15c4fc105..000000000 --- a/Layout/default/Device/Index.php +++ /dev/null @@ -1,167 +0,0 @@ -getUrl($Mod, "Index"); -$pagination_baseurl_params = ["filter" => $filter]; -$pagination_entity_name = "Device"; -?> - - - - -
-
-
-
- -
-

Devices

-
-
-
- - - -
-
-
-
-
-

Liste aller Devices

-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - price != "0.00") { - $price = $device->price; - } else { - $price = $device->devicetype->price; - } - if ($device->power != "0.0") { - $power = $device->power; - } else { - $power = $device->devicetype->power; - } - - if ($device->last_config_backup) { - if (time() - $device->last_config_backup <= 172800) { - $backup = 'OK'; - } else { - $backup = 'AGED'; - } - - - } else { - $backup = 'N/A'; - } - if ($device->autobackup==1) { - $backup = 'Auto'.$backup; - } - if ($device->pop->id) { - $destination = ' $device->pop->id]) . '">' . $device->pop->name . ''; - } else if ($device->addr_street) { - $address = $device->addr_street . " " . $device->addr_number . ", " . $device->addr_zip . " " . $device->addr_city; - $destination = '' . $address . ''; - } else if ($device->gps_lat) { - $address = $device->gps_lat . " , " . $device->gps_long; - $destination = '' . $address . ''; - } else { - $destination = ''; - } - ?> - - - - - - - - - - - - - - - - - - - - - -
Device NameGeräte TypHerstellerPop/AdresseIP-AdresseMac-AdresseSeriennummerPreismax. LeistungBackup
- $device->id]) ?>">name ?> - devicetype->name ?>devicetype->devicemanufactor->name ?>ip ?>mac ?>serial ?> Watt - $device->id]) ?>"> - $device->id]) ?>" - onclick="if(!confirm('Device wirklich löschen?')) return false;" class="text-danger" - title="Löschen"> -
-
-
- - - - - - - - - - \ No newline at end of file diff --git a/application/Device/DeviceController.php b/application/Device/DeviceController.php index 3285a0660..09a4829a1 100644 --- a/application/Device/DeviceController.php +++ b/application/Device/DeviceController.php @@ -17,11 +17,36 @@ class DeviceController extends mfBaseController protected function indexAction() { + $deviceManufacturers = array_map(function($manufacturer) { + return [ + "text" => $manufacturer->name, + "value" => $manufacturer->name, + ]; + }, DevicemanufactorModel::getAll()); - $this->layout()->setTemplate("Device/Index"); - $devices = DeviceModel::getAll(); - $this->layout()->set("devices", $devices); + $deviceTypes = array_map(function($deviceType) { + return [ + "text" => $deviceType->name, + "value" => $deviceType->name, + ]; + }, DevicetypeModel::getAll()); + $JSGlobals = ["BASE_URL" => self::getUrl("Device"), + "DASHBOARD_URL" => self::getUrl("Dashboard"), + "MFAPPNAME" => MFAPPNAME_SLUG, + "PAGE_TITLE" => "Devices", + "PATH" => [ + ["text" => MFAPPNAME_SLUG, "href" => self::getUrl("Dashboard")], + ["text" => "Devices", "href" => self::getUrl("Device")] + ], + "DEVICE_MANUFACTURERS" => $deviceManufacturers, + "DEVICE_TYPES" => $deviceTypes, + "DEVICE_API_URL" => self::getUrl("Device/api"), + ]; + + $this->layout()->set("vueViewName", "Device"); + $this->layout()->set("JSGlobals", $JSGlobals); + $this->layout()->setTemplate("VueViews/Vue"); } @@ -83,7 +108,7 @@ class DeviceController extends mfBaseController } $this->layout()->set("device", $device); - return $this->addAction(); + $this->addAction(); } protected function saveAction() @@ -253,57 +278,25 @@ class DeviceController extends mfBaseController switch ($do) { case "getDevices": - $devices = DeviceModel::getAll(); - - foreach ($devices as $device) { - $locationText = ""; - $locationUrl = ""; - - if (trim($device->pop->name)) { - $locationText = $device->pop->name; - $locationUrl = self::getUrl("Pop", "Detail", ["id" => $device->pop->id]); - } else if (trim($device->addr_street)) { - $locationText = $device->addr_street . " " . $device->addr_number . ", " . $device->addr_zip . " " . $device->addr_city; - $locationUrl = "http://maps.google.com/?q=" . $locationText; - } else if (trim($device->gps_lat)) { - $locationText = $device->gps_lat . " , " . $device->gps_long; - $locationUrl = "http://maps.google.com/?q=" . $locationText; - } - - $data[] = [ - "name" => $device->name, - "devicetype" => $device->devicetype->name, - "devicemanufactor" => $device->devicetype->devicemanufactor->name, - "locationText" => $locationText, - "locationUrl" => $locationUrl, - "ip" => $device->ip, - "mac" => $device->mac, - "serial" => $device->serial, - "price" => $device->price != "0.0" ? $device->price : $device->devicetype->price, - "power" => $device->power != "0.0" ? $device->power : $device->devicetype->power, - "backup" => $device->last_config_backup ? (time() - $device->last_config_backup <= 172800 ? 'ok' : 'aged') : 'na', - ]; - } - - die(json_encode($data)); - break; + header('Content-Type: application/json'); + die(json_encode($this->getDevices())); case "getconfig": - $return = $this->getConfig($id, $format, $filename); + $this->getConfig($id, $format, $filename); break; case "createconfig": - $return = $this->createConfig($ip); + $this->createConfig($ip); break; case "getoltinfo": - $return = $this->getoltInfo($ip, $portid, $adv); + $this->getoltInfo($ip, $portid, $adv); break; case "getontinfo": - $return = $this->getontInfo($ip, $portid, $ont); + $this->getontInfo($ip, $portid, $ont); break; case "getontinfomac": - $return = $this->getontInfoMac($ip, $portid, $ont); + $this->getontInfoMac($ip, $portid, $ont); break; case "changeoltsplitter": - $return = $this->changeoltSplitter($id, $portid, $ports); + $this->changeoltSplitter($id, $portid, $ports); break; default: $return = false; @@ -352,7 +345,7 @@ class DeviceController extends mfBaseController $returnUrl = "Device"; $returnAction = "Detail"; $returnVariables['id'] = $id; - return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker); + $this->redirect($returnUrl, $returnAction, $returnVariables); } private function changeoltSplitter($id, $portid, $ports) @@ -390,4 +383,54 @@ class DeviceController extends mfBaseController exit; } + private function getDevices() + { + $devices = DeviceModel::getAll(); + + foreach ($devices as $device) { + $locationText = ""; + $locationUrl = ""; + + if (trim($device->pop->name)) { + $locationText = $device->pop->name; + $locationUrl = self::getUrl("Pop", "Detail", ["id" => $device->pop->id]); + } else if (trim($device->addr_street)) { + $locationText = $device->addr_street . " " . $device->addr_number . ", " . $device->addr_zip . " " . $device->addr_city; + $locationUrl = "http://maps.google.com/?q=" . $locationText; + } else if (trim($device->gps_lat)) { + $locationText = $device->gps_lat . " , " . $device->gps_long; + $locationUrl = "http://maps.google.com/?q=" . $locationText; + } + + $backup = 'na'; + if ($device->last_config_backup) { + if (time() - $device->last_config_backup <= 172800) { + $backup = 'ok'; + if ($device->autobackup==1) { + $backup = 'auto'; + } + } else { + $backup = 'aged'; + } + } + + $data[] = [ + "id" => $device->id, + "name" => $device->name, + "devicetype" => $device->devicetype->name, + "devicemanufactor" => $device->devicetype->devicemanufactor->name, + "locationText" => $locationText, + "locationUrl" => $locationUrl, + "ip" => $device->ip, + "mac" => $device->mac, + "serial" => $device->serial, + "price" => $device->price != "0.00" ? $device->price : $device->devicetype->price, + "power" => $device->power != "0.00" ? intval($device->power) : intval($device->devicetype->power), + "backup" => $backup, + ]; + } + + return $data ?? []; + } + } \ No newline at end of file diff --git a/public/js/pages/Device/Device.js b/public/js/pages/Device/Device.js new file mode 100644 index 000000000..435685be6 --- /dev/null +++ b/public/js/pages/Device/Device.js @@ -0,0 +1,72 @@ +Vue.component('Device', { + //language=Vue + template: ` +
+ + + + + + + + + + + + + +
+ `, + + data() { + return { + window: window, + DeviceTableConfig: { + key: 'DeviceTable', + tableHeader: 'Device-Liste', + defaultPageSize: 25, + headers: [ + { text: 'Device Name', key: 'name', sortable: true, class: 'text-nowrap', priority: 10 }, + { text: 'Hersteller', key: 'devicemanufactor', filter: 'select',class: 'text-nowrap text-center', filterOptions: window.TT_CONFIG["DEVICE_MANUFACTURERS"] }, + { text: 'Geräte Typ', key: 'devicetype', filter: 'autocomplete', class: 'text-nowrap text-center', filterOptions: window.TT_CONFIG["DEVICE_TYPES"] , priority: 7}, + { text: 'Pop/Adresse', key: 'locationText', filter: 'search' , class: 'text-nowrap text-center'}, + { text: 'IP-Adresse', key: 'ip', filter: 'search',class: 'text-center', priority: 8}, + { text: 'Mac-Adresse', key: 'mac', filter: 'search',class: 'text-center' }, + { text: 'Seriennummer', key: 'serial', filter: 'search',class: 'text-center' }, + { text: 'Preis', key: 'price', filter: 'numberRange',class: 'text-center', suffix: ' €' }, + { text: 'max. Leistung', key: 'power', filter: 'numberRange',class: 'text-center', suffix: ' W' }, + { + text: 'Backup', + key: 'backup', + filter: 'iconSelect', + filterOptions: [ + { value: 'ok', text: 'Configbackup aktuell', icon: 'fa-regular fa-circle-check text-success' }, + { value: 'auto', text: 'Configbackup aktuell', icon: 'fa-regular fa-circle-a text-success' }, + { value: 'aged', text: 'Letztes Configbackup älter als 48 Stunden', icon: 'fa-regular fa-circle-xmark' }, + { value: 'na', text: 'N/A', icon: 'fa-regular fa-ban text-warning' } + ], + priority: 6, + sortable: false, + }, + {text: 'Aktionen', key: 'actions', class: 'text-center', sortable: false, filter: false, priority: 9}, + ], + }, + }; + }, +}); diff --git a/public/js/pages/Domain/Domain.js b/public/js/pages/Domain/Domain.js index 73650f418..8e3377f38 100644 --- a/public/js/pages/Domain/Domain.js +++ b/public/js/pages/Domain/Domain.js @@ -20,7 +20,7 @@ Vue.component('Domain', {
- +