diff --git a/Layout/default/Device/Index.php b/Layout/default/Device/Index.php index 162a79b27..1c499b593 100644 --- a/Layout/default/Device/Index.php +++ b/Layout/default/Device/Index.php @@ -4,7 +4,8 @@ $pagination_baseurl_params = ["filter" => $filter]; $pagination_entity_name = "Device"; ?> - +
@@ -52,6 +53,7 @@ $pagination_entity_name = "Device"; Seriennummer Preis max. Leistung + Backup @@ -65,6 +67,7 @@ $pagination_entity_name = "Device"; + @@ -81,6 +84,20 @@ $pagination_entity_name = "Device"; } 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'; + } + + ?> @@ -97,6 +114,7 @@ $pagination_entity_name = "Device"; serial ?> Watt + @@ -126,13 +144,17 @@ $pagination_entity_name = "Device"; - + \ No newline at end of file diff --git a/application/Api/v1/DeviceApicontroller.php b/application/Api/v1/DeviceApicontroller.php index fb1bae3f5..f2ceaad0d 100644 --- a/application/Api/v1/DeviceApicontroller.php +++ b/application/Api/v1/DeviceApicontroller.php @@ -6,6 +6,7 @@ class DeviceApicontroller extends mfBaseApicontroller { $db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $this->addRoute("/device/getDevices", "getDevices", "GET"); + $this->addRoute("/device/updateDevices", "updateDevices", "POST"); } @@ -18,6 +19,7 @@ class DeviceApicontroller extends mfBaseApicontroller $deviceReturn[$key]['ip'] = $device->ip; $deviceReturn[$key]['snmp_version'] = $device->snmp_version; $deviceReturn[$key]['serial'] = $device->serial; + $deviceReturn[$key]['last_config_backup'] = $device->last_config_backup; $deviceReturn[$key]['manufactor'] = $device->devicetype->devicemanufactor->name; } @@ -25,4 +27,40 @@ class DeviceApicontroller extends mfBaseApicontroller return mfResponse::Ok($deviceReturn); } + + protected function updateDevices() + { + $id = $this->post['id']; + $changeArray[] = 'last_config_backup'; + if ($id) { + $device = new Device($id); + if (!$device->id) { + return mfResponse::BadRequest(['message' => "Device not found"]); + } + $data = []; + foreach ($this->post as $keychanges => $changes) { + if (in_array($keychanges, $changeArray)) { + if ($changes == "null" || empty($changes)) { + $data[$keychanges] = NULL; + } else { + $data[$keychanges] = $changes; + } + } + } + if (!empty($data)) { + $device->update($data); + $device->save(); + $result['message'] = 'Device update success'; + $result['updates'] = implode(",", array_keys($data)); + return mfResponse::Ok($result); + } else { + return mfResponse::BadRequest(['message' => "Keine Update Felder angegeben"]); + } + + } else { + return mfResponse::BadRequest(['message' => "Device id nicht angegeben"]); + } + + } + } \ No newline at end of file diff --git a/application/SmsNotification/SmsNotification.php b/application/SmsNotification/SmsNotification.php new file mode 100644 index 000000000..3da3d54e5 --- /dev/null +++ b/application/SmsNotification/SmsNotification.php @@ -0,0 +1,56 @@ +ApiKey = TT_OUTGOING_SMS_API_KEY; + $this->ApiUrl = TT_OUTGOING_SMS_API_URL; + } + + + public function setBody($body) + { + $this->body = $body; + } + + public function setRecipient($recipient) + { + if (is_array($recipient)) { + $this->recipient = implode(",", $recipient); + } else { + $this->recipient = $recipient; + } + } + + + public function send() + { + $curl = curl_init(); + curl_setopt_array($curl, array( + CURLOPT_URL => $this->ApiUrl . '/smsmessaging/simple', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => '', + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 0, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS => array('messageContent' => $this->body, 'recipientAddressList' => $this->recipient), + CURLOPT_HTTPHEADER => array( + 'Authorization: Bearer ' . $this->ApiKey + ), + )); + $response = curl_exec($curl); + curl_close($curl); + echo $response; + } + +} + diff --git a/public/assets/css/datatables-std.css b/public/assets/css/datatables-std.css index a8f84221e..a76801f22 100644 --- a/public/assets/css/datatables-std.css +++ b/public/assets/css/datatables-std.css @@ -87,3 +87,18 @@ .w-30 { width: 33% !important; } +.fa-ban +{ + color: #0151e7; + font-size: 15px; +} +.fa-circle-check +{ + color: #23b900; + font-size: 15px; +} +.fa-circle-xmark +{ + color: #f1556c; + font-size: 15px; +} diff --git a/public/assets/js/datatables-std.js b/public/assets/js/datatables-std.js index 30be8536d..e29cca7de 100644 --- a/public/assets/js/datatables-std.js +++ b/public/assets/js/datatables-std.js @@ -16,12 +16,19 @@ if (typeof columndefs === "undefined") { } +if (typeof columnfilter === "undefined") { + var columnfilter; + columnfilter = ""; +} $('#filterrow th').each(function (i) { let title = $('#datatable thead th').eq($(this).index()).text(); if (hidesearch.includes($(this).index())) { + } else if (columnfilter.includes($(this).index())) { + $(this).html(''); + } else { $(this).html(''); } @@ -46,8 +53,8 @@ table = $('#datatable').DataTable({ "initComplete": function () { $('#datatable_filter').append(''); $('#clear_cookie').click(function () { - $('input').val(''); - + $('#filterrow input').val(''); + $('#filterrow select').val(''); table.search('').columns().search('').draw(); }); }, @@ -63,6 +70,15 @@ $('#filterrow').on('keyup', 'input', function () { .draw(); +}); + +$('#selectsearch').change(function () { + table + .column($(this).data('index')) + .search(this.value) + .draw(); + + }); let state = table.state.loaded(); if (state) {