Minor Bug Fixes
This commit is contained in:
parent
f80b9a6b43
commit
9c565d90fa
@ -17,7 +17,7 @@ RewriteCond %{REQUEST_FILENAME} \.
|
|||||||
RewriteRule (.*) ./public/$1 [L]
|
RewriteRule (.*) ./public/$1 [L]
|
||||||
|
|
||||||
# serve all other request as query parameters
|
# serve all other request as query parameters
|
||||||
# RewriteRule (.*) ./public/index.php?url=$1 [L,QSA]
|
RewriteRule (.*) ./public/index.php?url=$1 [L,QSA]
|
||||||
RewriteRule ^(.*?\.php)/([^/]*)/([^/]*)(/.+)? ./public/index.php?url=$1&$2&$3 [NC,N,QSA]
|
#RewriteRule ^(.*?\.php)/([^/]*)/([^/]*)(/.+)? ./public/index.php?url=$1&$2&$3 [NC,N,QSA]
|
||||||
|
|
||||||
AddType application/x-httpd-php .php .phtml
|
AddType application/x-httpd-php .php .phtml
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
class RoomsApi extends ApiController
|
class RoomsApi extends ApiController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function default()
|
public function default()
|
||||||
{
|
{
|
||||||
//$this->requireAuth();
|
//$this->requireAuth();
|
||||||
$response = [];
|
$response = [];
|
||||||
$roomIds = [];
|
$roomIds = [];
|
||||||
$roomsData = RoomManager::getRoomsDefault();
|
$roomsData = RoomManager::getRoomsDefault();
|
||||||
|
|
||||||
foreach ($roomsData as $roomKey => $room) {
|
foreach ($roomsData as $roomKey => $room) {
|
||||||
$roomIds[] = $room['room_id'];
|
$roomIds[] = $room['room_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Translation Of Numeric Walues
|
//Translation Of Numeric Walues
|
||||||
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
||||||
foreach ($subDevicesData as $subDeviceKey => $subDevice) {
|
foreach ($subDevicesData as $subDeviceKey => $subDevice) {
|
||||||
@ -25,14 +25,21 @@ class RoomsApi extends ApiController
|
|||||||
} else if (strpos(SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'], '-') !== false) {
|
} else if (strpos(SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'], '-') !== false) {
|
||||||
$type = SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'];
|
$type = SubDeviceManager::getSubDeviceMaster($subDevicesData[$subDeviceKey][$key]['subdevice_id'])['type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Connection Error Creation
|
//Connection Error Creation
|
||||||
$connectionError = true;
|
$connectionError = true;
|
||||||
$LastRecordTime = new DateTime($subDevicesData[$subDeviceKey][$key]['time']);
|
$LastRecordTime = new DateTime($subDevicesData[$subDeviceKey][$key]['heartbeat']);
|
||||||
$interval = $LastRecordTime->diff(new DateTime());
|
$interval = $LastRecordTime->diff(new DateTime());
|
||||||
$lastSeen = ($interval->format('%h') * 60 + $interval->format('%i'));
|
|
||||||
|
|
||||||
if ($subDevicesData[$subDeviceKey][$key]['sleep_time'] == NULL || $subDevicesData[$subDeviceKey][$key]['sleep_time'] == 0 || $lastSeen < $subDevicesData[$subDeviceKey][$key]['sleep_time']) {
|
$lastSeen = $interval->days * 24 * 60;
|
||||||
|
$lastSeen += $interval->h * 60;
|
||||||
|
$lastSeen += $interval->i;
|
||||||
|
|
||||||
|
|
||||||
|
//$lastSeen = ($interval->format('%h') * 60 + $interval->format('%i'));
|
||||||
|
|
||||||
|
if ($lastSeen < ($subDevicesData[$subDeviceKey][$key]['sleep_time'] == 0 ? 15 : $subDevicesData[$subDeviceKey][$key]['sleep_time'])) {
|
||||||
$connectionError = false;
|
$connectionError = false;
|
||||||
}
|
}
|
||||||
$subDevicesData[$subDeviceKey][$key]['connection_error'] = $connectionError;
|
$subDevicesData[$subDeviceKey][$key]['connection_error'] = $connectionError;
|
||||||
@ -50,7 +57,7 @@ class RoomsApi extends ApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($roomsData as $roomKey => $roomData) {
|
foreach ($roomsData as $roomKey => $roomData) {
|
||||||
if ($roomData['device_count'] == 0) continue;
|
if ($roomData['device_count'] == 0) continue;
|
||||||
$subDevicesSorted = isset($subDevicesData[$roomData['room_id']]) ? Utilities::sortArrayByKey($subDevicesData[$roomData['room_id']], 'connection_error', 'asc') : [];
|
$subDevicesSorted = isset($subDevicesData[$roomData['room_id']]) ? Utilities::sortArrayByKey($subDevicesData[$roomData['room_id']], 'connection_error', 'asc') : [];
|
||||||
@ -64,11 +71,11 @@ class RoomsApi extends ApiController
|
|||||||
|
|
||||||
$this->response($response);
|
$this->response($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($roomId)
|
public function update($roomId)
|
||||||
{
|
{
|
||||||
//$this->requireAuth();
|
//$this->requireAuth();
|
||||||
|
|
||||||
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]);
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]);
|
||||||
$this->response($subDevicesData);
|
$this->response($subDevicesData);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,8 @@ class WidgetApi extends ApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$subDeviceData = SubDeviceManager::edit($subDeviceId, $obj);
|
echo $subDeviceId;
|
||||||
|
echo SubDeviceManager::edit($subDeviceId, $obj);
|
||||||
|
|
||||||
$response = [
|
$response = [
|
||||||
"value" => "OK"
|
"value" => "OK"
|
||||||
|
@ -92,7 +92,7 @@ class SubDeviceManager
|
|||||||
|
|
||||||
//TODO: @Patrik Check line 89
|
//TODO: @Patrik Check line 89
|
||||||
$rows = Db::loadAll("
|
$rows = Db::loadAll("
|
||||||
SELECT d.room_id, d.sleep_time, sd.subdevice_id, sd.device_id, COALESCE(sd.icon, d.icon) AS icon, COALESCE(sd.name, d.name) AS name, sd.type, sd.unit, r.value, r.time FROM subdevices sd
|
SELECT d.room_id, d.sleep_time, d.heartbeat, sd.subdevice_id, sd.device_id, COALESCE(sd.icon, d.icon) AS icon, COALESCE(sd.name, d.name) AS name, sd.type, sd.unit, r.value, r.time FROM subdevices sd
|
||||||
JOIN devices d ON sd.device_id = d.device_id
|
JOIN devices d ON sd.device_id = d.device_id
|
||||||
JOIN records r ON r.subdevice_id = sd.subdevice_id
|
JOIN records r ON r.subdevice_id = sd.subdevice_id
|
||||||
WHERE d.room_id IN (" . str_repeat("?,", count($roomIds) - 1) . "?)
|
WHERE d.room_id IN (" . str_repeat("?,", count($roomIds) - 1) . "?)
|
||||||
|
Loading…
Reference in New Issue
Block a user