2020-05-15 22:45:31 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class RoomsApi extends ApiController{
|
2020-07-20 13:08:17 +02:00
|
|
|
|
2020-05-15 22:45:31 +02:00
|
|
|
public function default(){
|
2020-07-28 11:29:36 +02:00
|
|
|
$this->requireAuth();
|
2020-05-16 22:11:20 +02:00
|
|
|
$response = [];
|
|
|
|
$roomIds = [];
|
|
|
|
$roomsData = RoomManager::getRoomsDefault();
|
2020-07-20 13:08:17 +02:00
|
|
|
|
2020-05-16 22:11:20 +02:00
|
|
|
foreach ($roomsData as $roomKey => $room) {
|
|
|
|
$roomIds[] = $room['room_id'];
|
|
|
|
}
|
2020-07-20 13:08:17 +02:00
|
|
|
|
2020-05-16 22:11:20 +02:00
|
|
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
2020-07-20 13:08:17 +02:00
|
|
|
|
2020-05-16 22:11:20 +02:00
|
|
|
foreach ($roomsData as $roomKey => $roomData) {
|
2020-07-20 13:08:17 +02:00
|
|
|
if ($roomData['device_count'] == 0) continue;
|
|
|
|
$response[] = [
|
|
|
|
'room_id' => $roomData['room_id'],
|
|
|
|
'name' => $roomData['name'],
|
|
|
|
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
|
|
|
];
|
2020-05-15 22:45:31 +02:00
|
|
|
}
|
2020-05-16 22:11:20 +02:00
|
|
|
$this->response($response);
|
2020-05-15 22:45:31 +02:00
|
|
|
}
|
2020-07-20 13:08:17 +02:00
|
|
|
|
2020-05-24 19:35:19 +02:00
|
|
|
public function update($roomId){
|
|
|
|
//$this->requireAuth();
|
2020-07-20 13:08:17 +02:00
|
|
|
|
2020-05-24 19:44:58 +02:00
|
|
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]);
|
|
|
|
$this->response($subDevicesData);
|
2020-05-24 19:35:19 +02:00
|
|
|
}
|
2020-05-15 22:45:31 +02:00
|
|
|
}
|