Merge branch 'devbyspi' into 'master'
Devices-Übersicht/DeviceApicontroller/SmsNotification See merge request fronk/thetool!56
This commit is contained in:
@@ -4,7 +4,8 @@ $pagination_baseurl_params = ["filter" => $filter];
|
||||
$pagination_entity_name = "Device";
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
<link href="<?=self::getResourcePath()?>assets/css/datatables-std.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
|
||||
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
|
||||
type="text/css"/>
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@@ -52,6 +53,7 @@ $pagination_entity_name = "Device";
|
||||
<th class="text-center">Seriennummer</th>
|
||||
<th class="text-center">Preis</th>
|
||||
<th class="text-center">max. Leistung</th>
|
||||
<th class="text-center">Backup</th>
|
||||
<th class="edit-width"></th>
|
||||
</tr>
|
||||
<tr id="filterrow">
|
||||
@@ -65,6 +67,7 @@ $pagination_entity_name = "Device";
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -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 = '<i class="fa-regular fa-circle-check"><span style="display: none">OK</span></i>';
|
||||
} else {
|
||||
$backup = '<i class="fa-regular fa-circle-xmark" title="Letztes Configbackup älter als 48 Stunden"><span style="display: none">AGED</span></i>';
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$backup = '<i class="fa-regular fa-ban" title="Kein Configbackup"><span style="display: none">N/A</span></i>';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
@@ -97,6 +114,7 @@ $pagination_entity_name = "Device";
|
||||
<td class="text-center"><?= $device->serial ?></td>
|
||||
<td class="text-right"><?= $price ?> €</td>
|
||||
<td class="text-right"><?= $power ?> Watt</td>
|
||||
<td class="text-center"><?= $backup ?></td>
|
||||
|
||||
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em; width: 80px">
|
||||
@@ -126,13 +144,17 @@ $pagination_entity_name = "Device";
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var hidesearch=[9];
|
||||
var columndefs={ type: 'ip-address', targets: 4 };
|
||||
var hidesearch = [10];
|
||||
var columndefs = {type: 'ip-address', targets: 4};
|
||||
|
||||
var columnfilter = [9];
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/datatables-std.js?<?=date('U')?>"></script>
|
||||
<script type="text/javascript"
|
||||
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.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"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
56
application/SmsNotification/SmsNotification.php
Normal file
56
application/SmsNotification/SmsNotification.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class SmsNotification
|
||||
{
|
||||
private $ApiKey;
|
||||
private $ApiUrl;
|
||||
private $body;
|
||||
private $recipient;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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('<select style="padding: 0;height: 28px;;text-align: center;" id="selectsearch" class="form-control form-control-select form-control-special" data-index="' + i + '"><option value=""></option><option value="OK">OK</option><option value="AGED">AGED</option><option value="N/A">N/A</option></select>');
|
||||
|
||||
} else {
|
||||
$(this).html('<input type="text" placeholder="' + title + '" class="form-control" data-index="' + i + '" value="" />');
|
||||
}
|
||||
@@ -46,8 +53,8 @@ table = $('#datatable').DataTable({
|
||||
"initComplete": function () {
|
||||
$('#datatable_filter').append('<i id="clear_cookie" class="fas fa-times clear-fa" title="Filter löschen" aria-hidden="true" ></i>');
|
||||
$('#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) {
|
||||
|
||||
Reference in New Issue
Block a user