To docker Image

This commit is contained in:
JonatanRek 2020-05-15 22:45:31 +02:00
parent ded8a698f0
commit 619386d391
104 changed files with 52 additions and 13 deletions

View File

@ -4,23 +4,36 @@ 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);
$rooms = [];
$roomsData = RoomManager::getAllRooms();
foreach ($roomsData as $roomKey => $roomData) {
$response[] = [
'room_id' => $roomData['room_id'],
'name' => $roomData['name'],
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
$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'],
];
}
$this->response($response);
}
$rooms[] = [
'room_id' => $roomData['room_id'],
'name' => $roomData['name'],
'widgets' => $widgets,
];
}
$this->response($rooms);
}
}

26
www/app/api/RoomsApi.php Normal file
View 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);
}
}

View File

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 434 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

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