ServerCleanUp
This commit is contained in:
parent
4113296f86
commit
8f13c7ee5d
@ -7,16 +7,12 @@ $router->setDefault(function(){
|
||||
});
|
||||
|
||||
//Pages
|
||||
$router->any('/', 'Home');
|
||||
$router->any('/', 'Log');
|
||||
$router->any('/login', 'Login');
|
||||
$router->any('/logout', 'Logout');
|
||||
$router->any('/automation', 'Automation');
|
||||
$router->any('/dashboard', 'Dashboard');
|
||||
$router->any('/setting', 'Setting');
|
||||
$router->any('/scene', 'Scene');
|
||||
$router->any('/ajax', 'Ajax');
|
||||
$router->any('/log', 'Log');
|
||||
$router->any('/rooms', 'Rooms');
|
||||
|
||||
$router->post('/api/devices', 'DevicesApi@getAllDevices');
|
||||
$router->post('/api/login', 'AuthApi@login');
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
if (isset($_POST) && !empty($_POST)){
|
||||
|
||||
if (isset($_POST['modalFinal']) && $_POST['modalFinal'] != "") {
|
||||
$subDeviceIds = $_POST['devices'];
|
||||
foreach ($subDeviceIds as $subDeviceId) {
|
||||
DashboardManager::Add($subDeviceId);
|
||||
}
|
||||
}
|
||||
header('Location: ' . BASEURL . strtolower(basename(__FILE__, '.php')));
|
||||
die();
|
||||
}
|
||||
?>
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
if (isset($_POST) && !empty($_POST)){
|
||||
if (isset($_POST['saveDevice']) && $_POST['saveDevice'] != "") {
|
||||
$deviceId = $_POST['deviceId'];
|
||||
$deviceName = $_POST['deviceName'];
|
||||
$deviceIcon = $_POST['deviceIcon'];
|
||||
$sleepTime = 0;
|
||||
if (isset($_FILES['deviceFirmware']) && isset($_FILES['deviceFirmware']['tmp_name']) && $_FILES['deviceFirmware']['tmp_name'] != "") {
|
||||
$file = $_FILES['deviceFirmware'];
|
||||
$deviceMac = DeviceManager::getDeviceById($deviceId)['mac'];
|
||||
$fileName = (isset ($deviceMac) && $deviceMac != "" ? str_replace(":", "", $deviceMac) . ".bin" : "");
|
||||
if ($fileName != "" && file_exists("./app/updater/" . $fileName)) {
|
||||
unlink("./app/updater/" . $fileName);
|
||||
}
|
||||
if ($fileName != "") {
|
||||
copy($file['tmp_name'], "./app/updater/" . $fileName);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['sleepTime'])) {
|
||||
$sleepTime = $_POST['sleepTime'];
|
||||
}
|
||||
//TODO: if device isnt on off
|
||||
$permissionsInJson = json_encode([
|
||||
(int) $_POST['permissionOwner'],
|
||||
(int) $_POST['permissionOther'],
|
||||
]);
|
||||
|
||||
|
||||
$deviceOwnerUserId = $_POST['deviceOwnerUserId'];
|
||||
$deviceOwnerRoomId = $_POST['deviceOwnerId'];
|
||||
|
||||
try {
|
||||
$args = array(
|
||||
'owner' => $deviceOwnerUserId,
|
||||
'name' => $deviceName,
|
||||
'icon' => $deviceIcon,
|
||||
'permission' => $permissionsInJson,
|
||||
'sleep_time' => $sleepTime,
|
||||
'room_id' => $deviceOwnerRoomId,
|
||||
);
|
||||
DeviceManager::edit($deviceId, $args);
|
||||
} catch (\Exception $e) {
|
||||
echo $e->message();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Debug
|
||||
if (DEBUGMOD == 1) {
|
||||
echo '<pre>';
|
||||
echo $permissionsInJson;
|
||||
echo $deviceId;
|
||||
var_dump(json_decode ($permissionsInJson));
|
||||
echo '</pre>';
|
||||
echo '<a href="' . BASEDIR .'">CONTINUE</a>';
|
||||
die();
|
||||
}
|
||||
} else if (isset($_POST['approveDevice'])) {
|
||||
$deviceId = $_POST['deviceId'];
|
||||
$args = array(
|
||||
'approved' => 1,
|
||||
);
|
||||
DeviceManager::edit($deviceId, $args);
|
||||
} else if (isset($_POST['disableDevice'])) {
|
||||
$deviceId = $_POST['deviceId'];
|
||||
$args = array(
|
||||
'approved' => 2,
|
||||
);
|
||||
DeviceManager::edit($deviceId, $args);
|
||||
}
|
||||
|
||||
//Debug
|
||||
if (DEBUGMOD == 1) {
|
||||
echo '<pre>';
|
||||
var_dump($POST);
|
||||
echo '</pre>';
|
||||
echo '<a href="' . BASEURL . '">CONTINUE</a>';
|
||||
die();
|
||||
}
|
||||
header('Location: ' . BASEURL );
|
||||
die();
|
||||
}
|
||||
?>
|
@ -40,7 +40,7 @@ if (
|
||||
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
|
||||
if ($checkResult) {
|
||||
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
|
||||
header('Location: ' . BASEURL . $landingPage);
|
||||
header('Location: ' . BASEURL . '/');
|
||||
echo 'OK';
|
||||
} else {
|
||||
echo 'FAILED';
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (isset($_POST) && !empty($_POST)){
|
||||
if (isset($_POST['submitFinal']) && $_POST['submitFinal'] != "") {
|
||||
SceneManager::create($_POST['sceneIcon'], $_POST['sceneName'], json_encode($_POST['devices']));
|
||||
header('Location: ' . BASEURL . strtolower(basename(__FILE__, '.php')));
|
||||
die();
|
||||
}
|
||||
|
||||
//Debug
|
||||
if (DEBUGMOD == 1) {
|
||||
echo '<pre>';
|
||||
var_dump($_POST);
|
||||
echo '</pre>';
|
||||
echo '<a href="/' . BASEURL . strtolower(basename(__FILE__, '.php')).'">CONTINUE</a>';
|
||||
die();
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
class Dashboard extends Template
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
global $userManager;
|
||||
global $langMng;
|
||||
|
||||
if (!$userManager->isLogin()){
|
||||
header('Location: ' . BASEURL . 'login');
|
||||
}
|
||||
|
||||
$template = new Template('dashboard');
|
||||
|
||||
$dashboard = [];
|
||||
$dashboardData = DashboardManager::getAllDashboards($userManager->getUserData('user_id'));
|
||||
foreach ($dashboardData as $dashboardItemKey => $dashboardItemValue) {
|
||||
$subDeviceData = SubDeviceManager::getSubDevice($dashboardItemValue['subdevice_id']);
|
||||
$deviceData = SubDeviceManager::getSubDeviceMaster($dashboardItemValue['subdevice_id']);
|
||||
|
||||
$lastRecord = RecordManager::getLastRecord($dashboardItemValue['subdevice_id']);
|
||||
$parsedValue = $lastRecord['value'];
|
||||
|
||||
//TODO: Opravit aby to bylo stejné parsování jako na HOME
|
||||
if ($subDeviceData['type'] == "on/off") {
|
||||
$parsedValue = ($parsedValue == 1 ? 'ON' : 'OFF');
|
||||
}
|
||||
if ($subDeviceData['type'] == "light") {
|
||||
$parsedValue = ($parsedValue == 1 ? 'Light' : 'Dark');
|
||||
}
|
||||
|
||||
$dashboard[$dashboardItemValue['dashboard_id']] = [
|
||||
'icon' => $deviceData['icon'],
|
||||
'id' => $subDeviceData['subdevice_id'],
|
||||
'masterId' => $deviceData['device_id'],
|
||||
'name' => $deviceData['name'],
|
||||
'type' => $subDeviceData['type'],
|
||||
'unit' => $subDeviceData['unit'],
|
||||
'lastRecord' => [
|
||||
'value' => $parsedValue,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$approvedSubDevices = [];
|
||||
$allDevicesData = DeviceManager::getAllDevices();
|
||||
foreach ($allDevicesData as $deviceKey => $deviceValue) {
|
||||
if (!$deviceValue['approved']) continue;
|
||||
$allSubDevicesData = SubDeviceManager::getAllSubDevices($deviceValue['device_id']);
|
||||
foreach ($allSubDevicesData as $subDeviceKey => $subDeviceValue) {
|
||||
$approvedSubDevices[$subDeviceValue['subdevice_id']] = [
|
||||
'name' => $allDevicesData[$deviceKey]['name'],
|
||||
'type' => $subDeviceValue['type'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['deviceId'])){
|
||||
|
||||
$deviceData = DeviceManager::getDeviceById($_POST['deviceId']);
|
||||
|
||||
$subDevices = [];
|
||||
$subDevicesData = SubDeviceManager::getAllSubDevices($_POST['deviceId']);
|
||||
|
||||
foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
|
||||
$subDevices[$subDeviceData['subdevice_id']] = [
|
||||
'type' => $subDeviceData['type'],
|
||||
'unit' => $subDeviceData['unit'],
|
||||
];
|
||||
}
|
||||
|
||||
$device = [
|
||||
'id' => $deviceData['device_id'],
|
||||
'name' => $deviceData['name'],
|
||||
'token' => $deviceData['token'],
|
||||
'icon' => $deviceData['icon'],
|
||||
'subDevices' => $subDevices,
|
||||
];
|
||||
$template->prepare('deviceData', $device);
|
||||
}
|
||||
|
||||
$template->prepare('baseDir', BASEDIR);
|
||||
$template->prepare('debugMod', DEBUGMOD);
|
||||
$template->prepare('title', 'Nástěnka');
|
||||
$template->prepare('langMng', $langMng);
|
||||
$template->prepare('dashboard', $dashboard);
|
||||
$template->prepare('subDevices', $approvedSubDevices);
|
||||
|
||||
$template->render();
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Home extends Template
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
global $userManager;
|
||||
global $langMng;
|
||||
|
||||
if (!$userManager->isLogin()){
|
||||
header('Location: ' . BASEURL . 'login');
|
||||
}
|
||||
|
||||
$template = new Template('home');
|
||||
|
||||
//users instantialize
|
||||
$users = UserManager::getUsers();
|
||||
$template->prepare('users', $users);
|
||||
|
||||
//Users at home Info
|
||||
$usersAtHome = '';
|
||||
$i = 0;
|
||||
foreach ($users as $user) {
|
||||
if ($user['at_home'] == 'true') {
|
||||
$i++;
|
||||
$usersAtHome .= $user['username'];
|
||||
if ($usersAtHome != "" && isset($users[$i + 1]) && $users[$i + 1]['at_home'] == 'true'){
|
||||
$usersAtHome .= ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
$template->prepare('usersAtHome', $usersAtHome);
|
||||
|
||||
|
||||
$roomsItems = [];
|
||||
$roomsData = RoomManager::getAllRooms();
|
||||
foreach ($roomsData as $roomKey => $roomsData) {
|
||||
$devices = [];
|
||||
$devicesData = DeviceManager::getAllDevicesInRoom($roomsData['room_id']);
|
||||
foreach ($devicesData as $deviceKey => $deviceData) {
|
||||
$subDevices = [];
|
||||
$subDevicesData = SubDeviceManager::getAllSubDevices($deviceData['device_id']);
|
||||
foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
|
||||
|
||||
$events = RecordManager::getLastRecord($subDeviceData['subdevice_id'], 5);
|
||||
$eventsRaw = $events;
|
||||
|
||||
$connectionError = true;
|
||||
$parsedValue = "";
|
||||
$niceTime = "";
|
||||
|
||||
if (sizeof($events) > 1) {
|
||||
$lastRecord = $events[0];
|
||||
$lastValue = round($lastRecord['value']);
|
||||
$parsedValue = $lastValue;
|
||||
|
||||
/*Value Parsing*/
|
||||
//Last Value Parsing
|
||||
switch ($subDeviceData['type']) {
|
||||
case 'on/off':
|
||||
$replacementTrue = 'On';
|
||||
$replacementFalse = 'Off';
|
||||
$operator = '==';
|
||||
$breakValue = 1;
|
||||
break;
|
||||
|
||||
case 'door':
|
||||
$replacementTrue = 'Closed';
|
||||
$replacementFalse = 'Open';
|
||||
$operator = '==';
|
||||
$breakValue = 1;
|
||||
break;
|
||||
|
||||
case 'light':
|
||||
$replacementTrue = 'Light';
|
||||
$replacementFalse = 'Dark';
|
||||
$operator = '==';
|
||||
$breakValue = 1;
|
||||
if ($lastValue != 1 && $lastValue != 0) { //Digital Light Senzor
|
||||
$operator = '<';
|
||||
$breakValue = 810;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'water':
|
||||
$replacementTrue = 'Wet';
|
||||
$replacementFalse = 'Dry';
|
||||
$operator = '==';
|
||||
$breakValue = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
$replacementTrue = '';
|
||||
$replacementFalse = '';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($replacementTrue != '' && $replacementFalse != '') {
|
||||
//parsing last values
|
||||
$parsedValue = $replacementFalse;
|
||||
|
||||
if (Utilities::checkOperator($lastValue, $operator, $breakValue)) {
|
||||
$parsedValue = $replacementTrue;
|
||||
}
|
||||
|
||||
|
||||
//parsing last events values
|
||||
foreach ($events as $key => $value) {
|
||||
$events[$key]['value'] = $replacementFalse;
|
||||
if (Utilities::checkOperator($value['value'], $operator, $breakValue)) {
|
||||
$events[$key]['value'] = $replacementTrue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$LastRecordTime = new DateTime($lastRecord['time']);
|
||||
$niceTime = Utilities::ago($LastRecordTime);
|
||||
|
||||
$interval = $LastRecordTime->diff(new DateTime());
|
||||
$hours = $interval->format('%h');
|
||||
$minutes = $interval->format('%i');
|
||||
$lastSeen = ($hours * 60 + $minutes);
|
||||
|
||||
if (
|
||||
$lastSeen < $deviceData['sleep_time'] ||
|
||||
$subDeviceData['type'] == "on/off" ||
|
||||
$subDeviceData['type'] == "door"
|
||||
) {
|
||||
$connectionError = false;
|
||||
}
|
||||
}
|
||||
|
||||
$subDevices[$subDeviceData['subdevice_id']] = [
|
||||
'events'=> $events,
|
||||
'eventsRaw'=> $eventsRaw,
|
||||
'type' => $subDeviceData['type'],
|
||||
'unit' => $subDeviceData['unit'],
|
||||
'comError' => $connectionError,
|
||||
'lastRecort' => [
|
||||
'value' => (empty($parsedValue) ? 0 : $parsedValue),
|
||||
'time' => (empty($lastRecord['time']) ? "00:00" : $lastRecord['time']),
|
||||
'niceTime' => (empty($niceTime) ? "00:00" : $niceTime),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$permissionArray = json_decode($deviceData['permission']);
|
||||
$userIsDeviceAdmin = false;
|
||||
if($permissionArray[1] == 3) {
|
||||
$userIsDeviceAdmin = true;
|
||||
} else if ($permissionArray[0] == 3) {
|
||||
if ( $deviceData['owner'] == $_SESSION['user']['id']) {
|
||||
$userIsDeviceAdmin = true;
|
||||
}
|
||||
}
|
||||
|
||||
$devices[$deviceData['device_id']] = [
|
||||
'name' => $deviceData['name'],
|
||||
'icon' => $deviceData['icon'],
|
||||
'room' => $deviceData['room_id'],
|
||||
'token' => $deviceData['token'],
|
||||
'type' => $deviceData['type'],
|
||||
'mac' => $deviceData['mac'],
|
||||
'ip' => $deviceData['ip_address'],
|
||||
'subnet' => $deviceData['subnet'],
|
||||
'gateway' => $deviceData['gateway'],
|
||||
'sleepTime' => $deviceData['sleep_time'],
|
||||
'approved' => $deviceData['approved'],
|
||||
'permission' => $permissionArray,
|
||||
'owner' => $deviceData['owner'],
|
||||
'userIsAdmin' => $userIsDeviceAdmin,
|
||||
'subDevices' => $subDevices,
|
||||
];
|
||||
}
|
||||
$roomsItems[$roomsData['room_id']] = [
|
||||
'name' => $roomsData['name'],
|
||||
'deviceCount' => $roomsData['device_count'],
|
||||
'devices' => $devices,
|
||||
];
|
||||
}
|
||||
|
||||
$rooms = RoomManager::getAllRooms();
|
||||
$template->prepare('baseDir', BASEDIR);
|
||||
$template->prepare('debugMod', DEBUGMOD);
|
||||
$template->prepare('title', 'Home');
|
||||
$template->prepare('rooms', $rooms);
|
||||
$template->prepare('langMng', $langMng);
|
||||
$template->prepare('data', $roomsItems);
|
||||
|
||||
$template->render();
|
||||
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rooms extends Template
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
global $userManager;
|
||||
global $langMng;
|
||||
|
||||
if (!$userManager->isLogin()){
|
||||
header('Location: ' . BASEURL . 'login');
|
||||
}
|
||||
|
||||
$template = new Template('rooms');
|
||||
|
||||
$template->prepare('baseDir', BASEDIR);
|
||||
$template->prepare('debugMod', DEBUGMOD);
|
||||
$template->prepare('title', 'Rooms');
|
||||
$template->prepare('langMng', $langMng);
|
||||
|
||||
$roomsItems = [];
|
||||
$roomsData = RoomManager::getAllRooms();
|
||||
foreach ($roomsData as $roomKey => $roomsData) {
|
||||
$devicesData = DeviceManager::getAllDevicesInRoom($roomsData['room_id']);
|
||||
$roomReading = [];
|
||||
if ($roomsData['device_count'] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$roomReadingCache = [];
|
||||
$roomControlsCache = [];
|
||||
foreach ($devicesData as $deviceKey => $deviceData) {
|
||||
$subDevicesData = SubDeviceManager::getAllSubDevices($deviceData['device_id']);
|
||||
foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
|
||||
$subDeviceType = $subDeviceData['type'];
|
||||
$subDeviceUnit = $subDeviceData['unit'];
|
||||
$lastRecord = RecordManager::getLastRecord($subDeviceData['subdevice_id']);
|
||||
|
||||
if (in_array($subDeviceType, ['on/off','battery','door'])) {
|
||||
if ($subDeviceType == 'on/off') {
|
||||
$roomControlsCache[$subDeviceKey] = [
|
||||
'type' => $subDeviceType,
|
||||
'name' => $deviceData['name'],
|
||||
'icon' => $deviceData['icon'],
|
||||
'value' => $lastRecord['value'],
|
||||
];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists($subDeviceType, $roomReadingCache)) {
|
||||
$roomReadingCache[$subDeviceType] = [
|
||||
"value" => $roomReadingCache[$subDeviceType]['value'] + $lastRecord['value'],
|
||||
"count" => $roomReadingCache[$subDeviceType]['count'] + 1,
|
||||
"unit" => $subDeviceUnit,
|
||||
];
|
||||
} else {
|
||||
$roomReadingCache[$subDeviceType] = [
|
||||
"value" => $lastRecord['value'],
|
||||
"count" => 1,
|
||||
"unit" => $subDeviceUnit,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// parsing
|
||||
foreach ($roomReadingCache as $type => $value) {
|
||||
$roomReading[$type] = $value["value"] / $value["count"];
|
||||
$roomReading[$type] .= @($value['unit']);
|
||||
}
|
||||
|
||||
$roomsItems[$roomsData['room_id']] = [
|
||||
'name' => $roomsData['name'],
|
||||
'reading' => $roomReading,
|
||||
'controls' => $roomControlsCache,
|
||||
'deviceCount' => $roomsData['device_count'],
|
||||
];
|
||||
}
|
||||
|
||||
$template->prepare('rooms', $roomsItems);
|
||||
|
||||
$template->render();
|
||||
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
class Scene extends Template
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
global $userManager;
|
||||
global $langMng;
|
||||
|
||||
if (!$userManager->isLogin()){
|
||||
header('Location: ' . BASEURL . 'login');
|
||||
}
|
||||
|
||||
$template = new Template('scene');
|
||||
$template->prepare('baseDir', BASEDIR);
|
||||
$template->prepare('debugMod', DEBUGMOD);
|
||||
$template->prepare('title', 'Scény');
|
||||
$template->prepare('langMng', $langMng);
|
||||
|
||||
$scenes = [];
|
||||
foreach (SceneManager::getAllScenes() as $sceneId => $sceneData) {
|
||||
$doSomething = [];
|
||||
foreach (json_decode($sceneData['do_something']) as $subdeviceId => $subDeviceState) {
|
||||
$subDeviceMasterDeviceData = SubDeviceManager::getSubDeviceMaster($subdeviceId);
|
||||
$doSomething[$subdeviceId] = [
|
||||
'name' => $subDeviceMasterDeviceData['name'],
|
||||
'state' => $subDeviceState,
|
||||
];
|
||||
}
|
||||
$scenes[$sceneData['scene_id']] = [
|
||||
"name" => $sceneData['name'],
|
||||
"icon" => $sceneData['icon'],
|
||||
"doSomething" => $doSomething,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
$template->prepare('scenes', $scenes);
|
||||
|
||||
$approvedSubDevices = [];
|
||||
$allDevicesData = DeviceManager::getAllDevices();
|
||||
foreach ($allDevicesData as $deviceKey => $deviceValue) {
|
||||
if (!$deviceValue['approved']) continue;
|
||||
$allSubDevicesData = SubDeviceManager::getAllSubDevices($deviceValue['device_id']);
|
||||
foreach ($allSubDevicesData as $subDeviceKey => $subDeviceValue) {
|
||||
if ($subDeviceValue['type'] != 'on/off') continue;
|
||||
$approvedSubDevices[$subDeviceValue['subdevice_id']] = [
|
||||
'name' => $allDevicesData[$deviceKey]['name'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$template->prepare('subDevices', $approvedSubDevices);
|
||||
|
||||
$approvedSubDevices = [];
|
||||
$allDevicesData = DeviceManager::getAllDevices();
|
||||
foreach ($allDevicesData as $deviceKey => $deviceValue) {
|
||||
if (!$deviceValue['approved']) continue;
|
||||
$allSubDevicesData = SubDeviceManager::getAllSubDevices($deviceValue['device_id']);
|
||||
foreach ($allSubDevicesData as $subDeviceKey => $subDeviceValue) {
|
||||
if ($subDeviceValue['type'] != 'on/off') continue;
|
||||
$approvedSubDevices[$subDeviceValue['subdevice_id']] = [
|
||||
'name' => $allDevicesData[$deviceKey]['name'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$template->prepare('subDevices', $approvedSubDevices);
|
||||
|
||||
if (isset($_POST['devices'])){
|
||||
$devices = $_POST['devices'];
|
||||
$devicesOBJ = [];
|
||||
foreach ($devices as $deviceId) {
|
||||
$deviceData = DeviceManager::getDeviceById($deviceId);
|
||||
$subdeviceData = SubDeviceManager::getSubDeviceByMaster($deviceId, 'on/off');
|
||||
$devicesOBJ[$deviceId] = [
|
||||
'name' => $deviceData['name'],
|
||||
'setableSubDevices' => $subdeviceData['subdevice_id'],
|
||||
];
|
||||
}
|
||||
$template->prepare('setStateFormDevices', $devicesOBJ);
|
||||
$template->prepare('sceneName', $_POST['sceneName']);
|
||||
$template->prepare('sceneIcon', $_POST['sceneIcon']);
|
||||
}
|
||||
$template->render();
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php
|
||||
$partial = new Partial('head');
|
||||
$partial->prepare('baseDir', $BASEDIR);
|
||||
$partial->render();
|
||||
?>
|
||||
<title><?php echo $TITLE; ?></title>
|
||||
</head>
|
||||
<body class="no-transitions">
|
||||
<div class="row no-gutters main">
|
||||
<div class="col-md-3 d-sm-none"></div>
|
||||
<div class="col-md-3 nav-container">
|
||||
<?php
|
||||
$partial = new Partial('menu');
|
||||
$partial->prepare('item', 'dashboard');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('debugMod',$DEBUGMOD);
|
||||
$partial->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-md-9 main-body">
|
||||
<a onClick="$('#modal').removeClass('modal-container-hiden').show();" class="button is-primary m-1"><?php $LANGMNG->echo('t_addDevice'); ?></a>
|
||||
<div class="row no-gutters">
|
||||
<?php foreach ($DASHBOARD as $dashboardItemId => $dashboardItemData) {
|
||||
$partialDeviceButton = new Partial('dashboardButton');
|
||||
$partialDeviceButton->prepare('dashboardItemData', $dashboardItemData);
|
||||
|
||||
$partialDeviceButton->render();
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-container modal-container-hiden" id="modal">
|
||||
<div class="modal">
|
||||
<div class="close">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_addDevice'); ?></h4>
|
||||
<form method="post">
|
||||
<div class="field px-2">
|
||||
<div class="label"><?php $LANGMNG->echo('l_choseDevice'); ?>:</div>
|
||||
<select class="input" name="devices[]" multiple required>
|
||||
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
|
||||
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name'] . '[' . $subDeviceValue['type'] . ']'; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<input type="submit" class="button" name="modalFinal" value="<?php $LANGMNG->echo('b_create'); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['deviceId'])) {
|
||||
$partial = new Partial('deviceEdit');
|
||||
$partial->prepare('DEVICEDATA', $DEVICEDATA);
|
||||
|
||||
$partial->render();
|
||||
}
|
||||
$partial = new Partial('footer');
|
||||
$partial->render();
|
||||
?>
|
||||
</body>
|
||||
</html>
|
@ -1,107 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php
|
||||
$partial = new Partial('head');
|
||||
$partial->prepare('baseDir', $BASEDIR);
|
||||
$partial->render();
|
||||
?>
|
||||
<title><?php echo $TITLE ?></title>
|
||||
</head>
|
||||
<body class="no-transitions">
|
||||
<div class="row no-gutters main">
|
||||
<div class="col-md-3 d-sm-none"></div>
|
||||
<div class="col-md-3 nav-container">
|
||||
<?php
|
||||
$partial = new Partial('menu');
|
||||
$partial->prepare('item', 'home');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('debugMod',$DEBUGMOD);
|
||||
$partial->render();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script>
|
||||
|
||||
<div class="col-md-9 main-body">
|
||||
<div class="label m-1">
|
||||
<?php
|
||||
if ($USERSATHOME != "") {
|
||||
$LANGMNG->echo('l_atHome');
|
||||
echo ': ' . $USERSATHOME;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="m-1">
|
||||
<select class="select" name="room">
|
||||
<option value="all">All</option>
|
||||
<?php foreach ($ROOMS as $key => $room) {
|
||||
if ($room['device_count'] > 0) { ?>
|
||||
<option value="<?php echo $room['room_id']?>"><?php echo $room['name'] ?></option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row no-gutters">
|
||||
<?php foreach ($DATA as $roomId => $room) { ?>
|
||||
<?php foreach ($room['devices'] as $deviceId => $device) { ?>
|
||||
<?php foreach ($device['subDevices'] as $subDeviceKey => $subDevice) {
|
||||
//BUTTON
|
||||
$partialDeviceButton = new Partial('deviceButton');
|
||||
$partialDeviceButton->prepare('roomid',$roomId);
|
||||
$partialDeviceButton->prepare('subdeviceid',$subDeviceKey);
|
||||
$partialDeviceButton->prepare('subdevice',$subDevice);
|
||||
$partialDeviceButton->prepare('deviceid',$deviceId);
|
||||
$partialDeviceButton->prepare('device',$device);
|
||||
|
||||
$partialDeviceButton->render();
|
||||
|
||||
//DETAIL
|
||||
$partialDetail = new Partial('deviceDetail');
|
||||
$partialDetail->prepare('subdeviceid',$subDeviceKey);
|
||||
$partialDetail->prepare('subdevice',$subDevice);
|
||||
$partialDetail->prepare('device',$device);
|
||||
$partialDetail->prepare('langMng',$LANGMNG);
|
||||
|
||||
$partialDetail->render();
|
||||
|
||||
//SETTING
|
||||
$partialEdit = new Partial('deviceEdit');
|
||||
$partialEdit->prepare('deviceid',$deviceId);
|
||||
$partialEdit->prepare('subdevice',$subDevice);
|
||||
$partialEdit->prepare('device',$device);
|
||||
$partialEdit->prepare('users',$USERS);
|
||||
$partialEdit->prepare('rooms',$ROOMS);
|
||||
$partialEdit->prepare('langMng',$LANGMNG);
|
||||
|
||||
$partialEdit->render();
|
||||
}
|
||||
}
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$partial = new Partial('footer');
|
||||
$partial->render();
|
||||
?>
|
||||
<script>
|
||||
$(document).on('keyup mouseup', '#value_control', function(event) {
|
||||
$.ajax({
|
||||
url: 'ajax',
|
||||
type: 'POST',
|
||||
//TODO: GET Attribute from ID
|
||||
data: { subDevice_id : '46', action : 'set', value: this.value},
|
||||
success: function(msg){
|
||||
console.log("message");
|
||||
console.log(msg);
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
console.log('0');
|
||||
}
|
||||
});
|
||||
console.log(this.value);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,21 +0,0 @@
|
||||
<div class="col-4 col-sm-3 col-xl-2 square-wrap">
|
||||
<div class="square">
|
||||
<div class="square-content" id="device-<?php echo $DASHBOARDITEMDATA['masterId'] ?>" onClick="ajaxPost('ajax',{subDevice_id:'<?php echo $DASHBOARDITEMDATA['id']; ?>'}, this);">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 class="fa">&#x<?php echo $DASHBOARDITEMDATA['icon'] ?></h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 class="text-right"><?php echo $DASHBOARDITEMDATA['lastRecord']['value'].''.$DASHBOARDITEMDATA['unit'] ?></h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php echo $DASHBOARDITEMDATA['name'] ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
$action = "";
|
||||
if ($SUBDEVICE['type'] == 'on/off') {
|
||||
$action = 'onClick="ajaxPost(\'ajax\',{subDevice_id:\'' . $SUBDEVICEID . '\', action:\'change\'}, this);"';
|
||||
}
|
||||
//neaktivní zařízení is-inactive
|
||||
?>
|
||||
|
||||
<div class="device-button col-4 col-sm-3 col-xl-2 square-wrap" <?php echo $action; ?> data-room-id="<?php echo $ROOMID; ?>">
|
||||
<div class="square">
|
||||
<div class="square-content <?php echo (($SUBDEVICE['comError'] == 1 || $DEVICE['approved'] == 0) ? "is-inactive" : "") ;?>" id="device-<?php echo $DEVICEID ?>" data-sub-device-id="<?php echo $SUBDEVICEID;?>">
|
||||
<div class="content">
|
||||
<div class="row no-gutters">
|
||||
<div class="col">
|
||||
<h5 unselectable="on" class="fa">&#x<?php echo $DEVICE['icon'] ?></h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<?php if ($SUBDEVICE['type'] == 'temp_cont') { ?>
|
||||
<input type="number" step="5" class="device-button-value text-right" id="value_control" value="<?php echo $SUBDEVICE['lastRecort']['value'] ?>"><?php echo $SUBDEVICE['unit']?>
|
||||
<style>
|
||||
input.device-button-value.text-right {
|
||||
width: inherit;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php } else { ?>
|
||||
<h5 unselectable="on" class="device-button-value text-right" title="<?php echo $SUBDEVICE['lastRecort']['time']; ?>"><?php echo $SUBDEVICE['lastRecort']['value'] . $SUBDEVICE['unit']?></h5>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col button-text" unselectable="on" >
|
||||
<?php echo $DEVICE['name']; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,85 +0,0 @@
|
||||
<!-- Detail -->
|
||||
<div class="modal-container modal-container-hiden" id="modal-detail-<?php echo $SUBDEVICEID;?>">
|
||||
<div class="modal">
|
||||
<div class="close">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php echo $DEVICE['name']; ?></h4>
|
||||
<h5 class="mb-4"><?php echo $SUBDEVICE['lastRecort']['value'] . $SUBDEVICE['unit']?></h5>
|
||||
<p><?php $LANGMNG->echo('l_lastSeen'); echo ' ' . $SUBDEVICE['lastRecort']['niceTime']; ?></p>
|
||||
<div class="">
|
||||
<canvas id="canvas-<?php echo $SUBDEVICEID;?>"></canvas>
|
||||
</div>
|
||||
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
class="button col-2 graph-period"
|
||||
data-period="year"
|
||||
data-group="month"
|
||||
data-sub-device-id="<?php echo $SUBDEVICEID;?>"
|
||||
value="<?php $LANGMNG->echo('b_year');?>"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
class="button col-2 graph-period"
|
||||
data-period="month"
|
||||
data-group="day"
|
||||
data-sub-device-id="<?php echo $SUBDEVICEID;?>"
|
||||
value="<?php $LANGMNG->echo('b_month');?>"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
class="button col-2 graph-period"
|
||||
data-period="week"
|
||||
data-group="day"
|
||||
data-sub-device-id="<?php echo $SUBDEVICEID;?>"
|
||||
value="<?php $LANGMNG->echo('b_week');?>"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
class="button col-2 graph-period"
|
||||
data-period="day"
|
||||
data-group="hour"
|
||||
data-sub-device-id="<?php echo $SUBDEVICEID;?>"
|
||||
value="<?php $LANGMNG->echo('b_day');?>"
|
||||
/>
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
class="button col-2 graph-period"
|
||||
data-period="hour"
|
||||
data-group="minute"
|
||||
data-sub-device-id="<?php echo $SUBDEVICEID;?>"
|
||||
value="<?php $LANGMNG->echo('b_hour');?>"
|
||||
/>
|
||||
|
||||
<div>
|
||||
<table class="table is-fluid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php $LANGMNG->echo('t_time');?></th>
|
||||
<th><?php $LANGMNG->echo('t_state');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($SUBDEVICE['events'] as $key => $value) { ?>
|
||||
<tr>
|
||||
<td><?php echo (new DateTime($value['time']))->format(DATEFORMAT); ?></td>
|
||||
<td title="test"><?php
|
||||
echo $value['value'] . $SUBDEVICE['unit'];
|
||||
if (DEBUGMOD) {
|
||||
echo ' (' . $SUBDEVICE['eventsRaw'][$key]['value'] . ')';
|
||||
}
|
||||
?></td>
|
||||
<?php //TODO: P5IDAT TOOLTIP PRO RAW VALUE?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,179 +0,0 @@
|
||||
<div class="modal-container modal-container-hiden" id="modal-setting-<?php echo $DEVICEID ?>">
|
||||
<div class="modal">
|
||||
<div class="close">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_editDevice'); ?></h4>
|
||||
<form method="post" action="" enctype="multipart/form-data">
|
||||
<input class="input" type="hidden" name="deviceId" value="<?php echo $DEVICEID; ?>">
|
||||
<?php if ($DEVICE['approved'] != 0) { ?>
|
||||
<?php if ($DEVICE['userIsAdmin']) { ?>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_owner'); ?></div>
|
||||
<select class="input" name="deviceOwnerUserId">
|
||||
<option value=""><?php $LANGMNG->echo('w_noOne'); ?></option>
|
||||
<?php foreach ($USERS as $user) {
|
||||
$userId = $user['user_id'];
|
||||
$userName = $user['username'];
|
||||
?>
|
||||
<option value="<?php echo $userId; ?>" <?php ECHO ((int) $userId === (int) $DEVICE['owner'] ? 'selected="selected"' : ''); ?>><?php echo $userName; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="label"><?php $LANGMNG->echo('l_permission'); ?></div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-6">
|
||||
<div class="label"> - <?php $LANGMNG->echo('l_owner'); ?></div>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<?php
|
||||
$permissions = $DEVICE['permission'];
|
||||
//Debug
|
||||
if (DEBUGMOD == 1) {
|
||||
echo '<pre>';
|
||||
VAR_DUMP($permissions);
|
||||
echo '</pre>';
|
||||
}
|
||||
?>
|
||||
<input type="radio" name="permissionOwner" value=1 <?php ECHO ($permissions[0] == 1 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_read'); ?>
|
||||
<input type="radio" name="permissionOwner" value=2 <?php ECHO ($permissions[0] == 2 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_use'); ?>
|
||||
<input type="radio" name="permissionOwner" value=3 <?php ECHO ($permissions[0] == 3 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_edit'); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="label"> - <?php $LANGMNG->echo('l_member'); ?></div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<input type="radio" name="permissionOther" value=1 <?php ECHO ($permissions[1] == 1 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_read'); ?>
|
||||
<input type="radio" name="permissionOther" value=2 <?php ECHO ($permissions[1] == 2 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_use'); ?>
|
||||
<input type="radio" name="permissionOther" value=3 <?php ECHO ($permissions[1] == 3 ? 'checked' : ''); ?>/><?php $LANGMNG->echo('l_edit'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_title'); ?></div>
|
||||
<input class="input" type="text" name="deviceName" value="<?php echo $DEVICE['name']; ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="field">
|
||||
<div class="label">Token:</div>
|
||||
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['token']; ?>" disabled>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_networkSetting'); ?></h4>
|
||||
<div class="field">
|
||||
<div class="label">Type:</div>
|
||||
<input class="input" type="text" name="deviceToken" value="<?php echo $DEVICE['type']; ?>" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Mac Address:</div>
|
||||
<input class="input" type="text" name="deviceMac" value="<?php echo $DEVICE['mac']; ?>" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">IP:</div>
|
||||
<input class="input" type="text" name="deviceIp" value="<?php echo $DEVICE['ip']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Subnet:</div>
|
||||
<input class="input" type="text" name="deviceSubnet" value="<?php echo $DEVICE['subnet']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label">Gateway:</div>
|
||||
<input class="input" type="text" name="deviceGateway" value="<?php echo $DEVICE['gateway']; ?>" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" disabled>
|
||||
</div>
|
||||
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_deviceVersion'); ?></h4>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_uploadFirmware'); ?></div>
|
||||
<input class="input" type="file" name="deviceFirmware" value="">
|
||||
</div>
|
||||
|
||||
<?php if ($DEVICE['userIsAdmin']) { ?>
|
||||
<?php if (!in_array($SUBDEVICE['type'], ['on/off', 'door', 'water'])) { ?>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_sleepTime'); ?></div>
|
||||
<input class="input" type="int" name="sleepTime" value="<?php echo $DEVICE['sleepTime']; ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
|
||||
<p>* - <?php $LANGMNG->echo('l_inMinutes'); ?></p>
|
||||
</div>
|
||||
<?php }?>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_room'); ?></div>
|
||||
<select class="input" name="deviceOwnerId">
|
||||
<?php foreach ($ROOMS as $room) {
|
||||
$roomId = $room['room_id'];
|
||||
$roomName = $room['name'];
|
||||
?>
|
||||
<option value="<?php echo $roomId; ?>" <?php ECHO ((int) $roomId === (int) $DEVICE['room'] ? 'selected="selected"' : ''); ?>><?php echo $roomName; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_icon'); ?></div>
|
||||
<select class="input fa" name="deviceIcon" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
|
||||
<option value=""><?php $LANGMNG->echo('w_no'); ?><?php echo ' '; ?><?php $LANGMNG->echo('w_icon'); ?></option>
|
||||
<option value="f0eb" <?php ECHO ($DEVICE['icon'] == "f0eb" ? 'selected="selected"' : ''); ?>> - fa-lightbulb-o</option>
|
||||
<option value="f2dc" <?php ECHO ($DEVICE['icon'] == "f2dc" ? 'selected="selected"' : ''); ?>> - fa-snowflake-o</option>
|
||||
<option value="f0e7" <?php ECHO ($DEVICE['icon'] == "f0e7" ? 'selected="selected"' : ''); ?>> - fa-bolt</option>
|
||||
<option value="f2c7" <?php ECHO ($DEVICE['icon'] == "f2c7" ? 'selected="selected"' : ''); ?>> - fa-thermometer-full</option>
|
||||
<option value="f236" <?php ECHO ($DEVICE['icon'] == "f236" ? 'selected="selected"' : ''); ?>> - fa-bed</option>
|
||||
<option value="f185" <?php ECHO ($DEVICE['icon'] == "f185" ? 'selected="selected"' : ''); ?>> - fa-sun-o</option>
|
||||
<option value="f2db" <?php ECHO ($DEVICE['icon'] == "f2db" ? 'selected="selected"' : ''); ?>> - fa-microchip</option>
|
||||
<option value="f011" <?php ECHO ($DEVICE['icon'] == "f011" ? 'selected="selected"' : ''); ?>> - fa-power-off</option>
|
||||
<option value="f011" <?php ECHO ($DEVICE['icon'] == "f011" ? 'selected="selected"' : ''); ?>> - fa-desktop</option>
|
||||
</select>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_moduls'); ?></div>
|
||||
<div class="row no-gutters">
|
||||
<?php foreach ($DEVICE['subDevices'] as $subDeviceKey => $subDevice) { ?>
|
||||
<div class="device-button col-4 col-sm-3 col-xl-2 square-wrap">
|
||||
<div class="square">
|
||||
<div class="square-content">
|
||||
<div class="row no-gutters">
|
||||
<div class="col">
|
||||
<h5 unselectable="on" class="fa">&#x<?php echo $DEVICE['icon'] ?></h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 unselectable="on" class="device-button-value text-right" title="<?php echo $subDevice['lastRecort']['time']; ?>"><?php echo $subDevice['lastRecort']['value'] . $subDevice['unit']?></h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col button-text" unselectable="on" >
|
||||
<?php echo $DEVICE['name']; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="button" name="saveDevice" value="<?php $LANGMNG->echo('b_save'); ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>/>
|
||||
<input type="submit" class="button is-danger" name="disableDevice" value="<?php $LANGMNG->echo('b_disable'); ?>"/>
|
||||
<?php } else { ?>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_moduls'); ?></div>
|
||||
<div class="row no-gutters">
|
||||
<?php foreach ($DEVICE['subDevices'] as $subDeviceKey => $subDevice) { ?>
|
||||
<div class="device-button col-4 col-sm-3 col-xl-2 square-wrap">
|
||||
<div class="square">
|
||||
<div class="square-content">
|
||||
|
||||
<?php echo $DEVICE['name']; ?>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="button is-primary" name="approveDevice" value="<?php $LANGMNG->echo('b_approve'); ?>"/>
|
||||
<input type="submit" class="button is-danger" name="disableDevice" value="<?php $LANGMNG->echo('b_disable'); ?>"/>
|
||||
<?php } ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -1,16 +1,6 @@
|
||||
<div class="nav">
|
||||
<?php
|
||||
$menuItems = [
|
||||
'fa-home' => [
|
||||
'slug' => 'home',
|
||||
'lngKey' => 'home',
|
||||
'path' => './',
|
||||
],
|
||||
'fa-tachometer' => [
|
||||
'slug' => 'dashboard',
|
||||
'lngKey' => 'dashboard',
|
||||
'path' => 'dashboard',
|
||||
],
|
||||
'fa-wrench' => [
|
||||
'slug' => 'setting',
|
||||
'lngKey' => 'settings',
|
||||
@ -21,15 +11,10 @@
|
||||
'lngKey' => 'automatization',
|
||||
'path' => 'automation',
|
||||
],
|
||||
'fa-terminal' => [
|
||||
'slug' => 'scene',
|
||||
'lngKey' => 'scenes',
|
||||
'path' => 'scene',
|
||||
],
|
||||
'fa-bug' =>[
|
||||
'slug' => 'log',
|
||||
'slug' => '',
|
||||
'lngKey' => 'log',
|
||||
'path' => 'log',
|
||||
'path' => '',
|
||||
],
|
||||
];
|
||||
foreach ( $menuItems as $key => $value) {
|
||||
|
@ -1,22 +0,0 @@
|
||||
<div class="col-12 col-md-6 col-xl-4 square-wrap noselect">
|
||||
<div class="rectangle-2">
|
||||
<div class="square-content double" id="scene-<?php echo $SCENEID ?>" onClick="ajaxPost('ajax',{scene_id:'<?php echo $SCENEID; ?>',action:'execute'}, this);" >
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<h5 class="fa noselect">
|
||||
&#x<?php echo $SCENEDATA['icon']; ?>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 class="text-right break-all noselect">
|
||||
<?php echo $SCENEDATA['name']; ?>
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,40 +0,0 @@
|
||||
<div class="modal-container modal-container-hiden" id="modal">
|
||||
<div class="modal">
|
||||
<div class="close">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_createScene');?></h4>
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_title');?>:</div>
|
||||
<input type="text" class="input" name="sceneName" value=""/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_icon');?>:</div>
|
||||
<select class="input fa" name="sceneIcon" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
|
||||
<option value="">No icon</option>
|
||||
<option value="f0eb"> - fa-lightbulb-o</option>
|
||||
<option value="f2dc"> - fa-snowflake-o</option>
|
||||
<option value="f0e7"> - fa-bolt</option>
|
||||
<option value="f2c7"> - fa-thermometer-full</option>
|
||||
<option value="f236"> - fa-bed</option>
|
||||
<option value="f185"> - fa-sun-o</option>
|
||||
<option value="f2db"> - fa-microchip</option>
|
||||
<option value="f011"> - fa-power-off</option>
|
||||
<option value="f011"> - fa-desktop</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_choseDevice');?></div>
|
||||
<select class="input" name="devices[]" multiple required>
|
||||
<?php
|
||||
foreach ($SUBDEVICES as $subdeviceId => $subdeviceData) {
|
||||
echo '<option value="'.$subdeviceId.'">'.$subdeviceData['name'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<input type="submit" class="button" name="submit" value="<?php $LANGMNG->echo('b_next');?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -1,26 +0,0 @@
|
||||
<div class="modal-container" id="modal">
|
||||
<div class="modal">
|
||||
<div class="close">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_createScene');?></h4>
|
||||
<form method="post">
|
||||
<input type="hidden" name="sceneName" value="<?php echo $SCENENAME; ?>">
|
||||
<input type="hidden" name="sceneIcon" value="<?php echo $SCENEICON; ?>">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($SETSTATEFORMDEVICES as $device){ ?>
|
||||
<div class="field px-2">
|
||||
<div class="label"><?php echo $device['name']; ?></div>
|
||||
<select class="input" name="devices[<?php echo $device['setableSubDevices']; ?>]">
|
||||
<option value="0">off</option>
|
||||
<option value="1">on</option>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
$i++;
|
||||
} ?>
|
||||
<input type="submit" class="button" name="submitFinal" value="<?php echo $LANGMNG->echo('b_create');?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -1,47 +0,0 @@
|
||||
<div class="modal-container modal-container-hiden" id="modal-setting-<?php echo $SCENEID ?>">
|
||||
<div class="modal">
|
||||
<div class="close">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
<h4 class="mb-4"><?php $LANGMNG->echo('t_editScene')?></h4>
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_title');?>:</div>
|
||||
<input type="text" class="input" name="sceneName" value="<?php echo $SCENE['name']; ?>"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('w_icon');?>:</div>
|
||||
<select class="input fa" name="sceneIcon">
|
||||
<option value=""><?php $LANGMNG->echo('w_no').$LANGMNG->get('w_icon');?></option>
|
||||
<option value="f0eb" <?php ECHO ($SCENE['icon'] == "f0eb" ? 'selected="selected"' : ''); ?>> - fa-lightbulb-o</option>
|
||||
<option value="f2dc" <?php ECHO ($SCENE['icon'] == "f2dc" ? 'selected="selected"' : ''); ?>> - fa-snowflake-o</option>
|
||||
<option value="f0e7" <?php ECHO ($SCENE['icon'] == "f0e7" ? 'selected="selected"' : ''); ?>> - fa-bolt</option>
|
||||
<option value="f2c7" <?php ECHO ($SCENE['icon'] == "f2c7" ? 'selected="selected"' : ''); ?>> - fa-thermometer-full</option>
|
||||
<option value="f236" <?php ECHO ($SCENE['icon'] == "f236" ? 'selected="selected"' : ''); ?>> - fa-bed</option>
|
||||
<option value="f185" <?php ECHO ($SCENE['icon'] == "f185" ? 'selected="selected"' : ''); ?>> - fa-sun-o</option>
|
||||
<option value="f2db" <?php ECHO ($SCENE['icon'] == "f2db" ? 'selected="selected"' : ''); ?>> - fa-microchip</option>
|
||||
<option value="f011" <?php ECHO ($SCENE['icon'] == "f011" ? 'selected="selected"' : ''); ?>> - fa-power-off</option>
|
||||
<option value="f011" <?php ECHO ($SCENE['icon'] == "f011" ? 'selected="selected"' : ''); ?>> - fa-desktop</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field px-2">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($SCENE['doSomething'] as $subDeviceId => $subDeviceData){ ?>
|
||||
<div id="scene-<?php echo $SCENEID; ?>-content">
|
||||
<div class="label"><?php echo $subDeviceData['name']; ?></div>
|
||||
<select class="input" name="devices[<?php echo $subDeviceId; ?>]">
|
||||
<option value="0" <?php ECHO ($subDeviceData['state'] == "0" ? 'selected="selected"' : ''); ?>>off</option>
|
||||
<option value="1" <?php ECHO ($subDeviceData['state'] == "1" ? 'selected="selected"' : ''); ?>>on</option>
|
||||
</select>
|
||||
<button name="remove" type="button" class="button is-danger fa" data-scene-id="<?php echo $SCENEID; ?>"></button>
|
||||
</div>
|
||||
<?php
|
||||
$i++;
|
||||
} ?>
|
||||
</div>
|
||||
<input type="submit" class="button" name="saveDevice" value="<?php $LANGMNG->echo('b_edit');?>"/>
|
||||
<input type="button" class="button is-danger" onClick="ajaxPost('ajax',{scene_id:'<?php echo $SCENEID ?>', 'action':'delete'}, this, true);" name="saveDevice" value="<?php $LANGMNG->echo('b_remove');?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -1,154 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php
|
||||
$partial = new Partial('head');
|
||||
$partial->prepare('baseDir', $BASEDIR);
|
||||
$partial->render();
|
||||
?>
|
||||
<title><?php echo $TITLE ?></title>
|
||||
</head>
|
||||
<body class="no-transitions">
|
||||
<div class="row no-gutters main">
|
||||
<div class="col-md-3 d-sm-none"></div>
|
||||
<div class="col-md-3 nav-container">
|
||||
<?php
|
||||
$partial = new Partial('menu');
|
||||
$partial->prepare('item', 'rooms');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('debugMod',$DEBUGMOD);
|
||||
$partial->render();
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-9 main-body">
|
||||
<div class="frame">
|
||||
<?php foreach ($ROOMS as $roomId => $room) { ?>
|
||||
<div class="single-frame" id="room-<?php echo $roomId; ?>">
|
||||
<div class="">
|
||||
<h1><?php echo $room['name']; ?></h1>
|
||||
<?php foreach ($room['reading'] as $key => $value) { ?>
|
||||
<?php echo $LANGMNG->get($key) .": ". $value; ?></br>
|
||||
<?php } ?>
|
||||
<?php if (DEBUGMOD == 1) { ?>
|
||||
<pre>
|
||||
<?php var_dump($room);?>
|
||||
</pre>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php foreach ($room['controls'] as $key => $value) { ?>
|
||||
<div class="row no-gutters">
|
||||
<div class="device-button col-4 col-sm-3 col-xl-2 square-wrap" data-room-id="">
|
||||
<div class="square">
|
||||
<div class="square-content" id="device-" data-sub-device-id="">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5 unselectable="on" class="fa">&#x<?php echo $value['icon'];?></h5>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h5 unselectable="on" class="device-button-value text-right" title=""><?php echo $value['value'];?></h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" unselectable="on" >
|
||||
<?php echo $value['name'];?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<style>
|
||||
.single-frame {
|
||||
background-color: red;
|
||||
width: 100%;
|
||||
flex: 0 0 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.frame {
|
||||
overflow-x: auto;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body,html{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.frame .single-frame:nth-child(even) {
|
||||
background: red;
|
||||
}
|
||||
|
||||
.frame .single-frame:nth-child(odd) {
|
||||
background: green;
|
||||
}
|
||||
|
||||
</style>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$partial = new Partial('footer');
|
||||
$partial->render();
|
||||
?>
|
||||
<script>
|
||||
var prev_id;
|
||||
var id;
|
||||
var current_element
|
||||
var elementWidth = $('.frame').width();
|
||||
|
||||
$('.frame').scroll(function(){
|
||||
//console.log('SCROLLING!');
|
||||
//console.log('scrool'+$('.single-frame').scrollLeft());
|
||||
var element_width = $('.single-frame').width();
|
||||
|
||||
var offset = $('.single-frame').offset();
|
||||
var positive = Math.abs(offset.left)
|
||||
var divided = positive / element_width;
|
||||
var round = Math.round(divided);
|
||||
|
||||
current_element = $('.frame').children().eq(round);
|
||||
id = current_element.attr('id');
|
||||
|
||||
if (prev_id != id){
|
||||
prev_id = id;
|
||||
console.log(prev_id);
|
||||
}
|
||||
var scrollTo = $('#'+id).offset().left;
|
||||
console.log('s-f: '+ scrollTo)
|
||||
|
||||
});
|
||||
$('.frame').on('touchend', function(){ // listen to mouse up
|
||||
console.log('STOPPED SCROLLING!');
|
||||
var scrollLeft = $('.frame').scrollLeft();
|
||||
console.log('frameLeft' + scrollLeft);
|
||||
var a = $('.frame').children();
|
||||
for (index = 0; index < a.length; ++index) {
|
||||
if(a[index].id == id){
|
||||
$('.frame').animate({
|
||||
scrollLeft: (index * elementWidth)
|
||||
});
|
||||
$('.frame').animate({
|
||||
scrollLeft: (index * elementWidth)
|
||||
});
|
||||
}
|
||||
console.log(a[index]);
|
||||
}
|
||||
|
||||
if (scrollTo > 160) {
|
||||
console.log($('#'+id).left)
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php
|
||||
$partial = new Partial('head');
|
||||
$partial->prepare('baseDir', $BASEDIR);
|
||||
$partial->render();
|
||||
?>
|
||||
<title><?php echo $TITLE ?></title>
|
||||
</head>
|
||||
<body class="no-transitions">
|
||||
<div class="row no-gutters main">
|
||||
<div class="col-md-3 d-sm-none"></div>
|
||||
<div class="col-md-3 nav-container">
|
||||
<?php
|
||||
$partial = new Partial('menu');
|
||||
$partial->prepare('item', 'scene');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('debugMod',$DEBUGMOD);
|
||||
$partial->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-md-9 main-body">
|
||||
<a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php $LANGMNG->echo('t_createScene');?></a>
|
||||
<div class="row no-gutters">
|
||||
<?php foreach ($SCENES as $sceneId => $sceneData) {
|
||||
//BUTTON
|
||||
$partialScenButton = new Partial('sceneButton');
|
||||
$partialScenButton->prepare('langMng', $LANGMNG);
|
||||
$partialScenButton->prepare('sceneId', $sceneId);
|
||||
$partialScenButton->prepare('sceneData', $sceneData);
|
||||
|
||||
$partialScenButton->render();
|
||||
|
||||
// Edit
|
||||
$partialSceneEdit = new Partial('sceneEdit');
|
||||
$partialSceneEdit->prepare('langMng',$LANGMNG);
|
||||
$partialSceneEdit->prepare('sceneId',$sceneId);
|
||||
$partialSceneEdit->prepare('scene',$sceneData);
|
||||
|
||||
$partialSceneEdit->render();
|
||||
?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_POST['submit'])) {
|
||||
$partial = new Partial('sceneCreateFinal');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('setStateFormDevices',$SETSTATEFORMDEVICES );
|
||||
$partial->prepare('sceneIcon',$SCENEICON );
|
||||
$partial->prepare('SceneName',$SCENENAME );
|
||||
|
||||
$partial->render();
|
||||
} else {
|
||||
$partial = new Partial('sceneCreate');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
$partial->prepare('subDevices',$SUBDEVICES);
|
||||
|
||||
$partial->render();
|
||||
}
|
||||
$partial = new Partial('footer');
|
||||
$partial->render();
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user