To docker Image
This commit is contained in:
parent
ded8a698f0
commit
619386d391
@ -4,23 +4,36 @@ class RoomsApi extends ApiController{
|
|||||||
|
|
||||||
public function default(){
|
public function default(){
|
||||||
//$this->requireAuth();
|
//$this->requireAuth();
|
||||||
$response = [];
|
$rooms = [];
|
||||||
$roomIds = [];
|
$roomsData = RoomManager::getAllRooms();
|
||||||
$roomsData = RoomManager::getRoomsDefault();
|
|
||||||
|
|
||||||
foreach ($roomsData as $roomKey => $room) {
|
|
||||||
$roomIds[] = $room['room_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
|
||||||
|
|
||||||
foreach ($roomsData as $roomKey => $roomData) {
|
foreach ($roomsData as $roomKey => $roomData) {
|
||||||
$response[] = [
|
|
||||||
|
$widgets = [];
|
||||||
|
$devicesData = DeviceManager::getAllDevicesInRoom($roomData['room_id']);
|
||||||
|
foreach ($devicesData as $deviceKey => $deviceData) {
|
||||||
|
|
||||||
|
$subDevicesData = SubDeviceManager::getAllSubDevices($deviceData['device_id']);
|
||||||
|
foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
|
||||||
|
|
||||||
|
$lastRecord = RecordManager::getLastRecord($subDeviceData['subdevice_id']);
|
||||||
|
$widgets[] = [
|
||||||
|
'subdevice_id' => $subDeviceData['subdevice_id'],
|
||||||
|
'device_id' => $deviceData['device_id'],
|
||||||
|
'name' => $deviceData['name'],
|
||||||
|
'type' => $subDeviceData['type'],
|
||||||
|
'icon' => $deviceData['icon'],
|
||||||
|
'value' => $lastRecord['value'],
|
||||||
|
'unit' => $subDeviceData['unit'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rooms[] = [
|
||||||
'room_id' => $roomData['room_id'],
|
'room_id' => $roomData['room_id'],
|
||||||
'name' => $roomData['name'],
|
'name' => $roomData['name'],
|
||||||
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
'widgets' => $widgets,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$this->response($response);
|
$this->response($rooms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
www/app/api/RoomsApi.php
Normal file
26
www/app/api/RoomsApi.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class RoomsApi extends ApiController{
|
||||||
|
|
||||||
|
public function default(){
|
||||||
|
//$this->requireAuth();
|
||||||
|
$response = [];
|
||||||
|
$roomIds = [];
|
||||||
|
$roomsData = RoomManager::getRoomsDefault();
|
||||||
|
|
||||||
|
foreach ($roomsData as $roomKey => $room) {
|
||||||
|
$roomIds[] = $room['room_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
||||||
|
|
||||||
|
foreach ($roomsData as $roomKey => $roomData) {
|
||||||
|
$response[] = [
|
||||||
|
'room_id' => $roomData['room_id'],
|
||||||
|
'name' => $roomData['name'],
|
||||||
|
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$this->response($response);
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 434 KiB After Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user