This commit is contained in:
JonatanRek 2020-02-11 15:09:51 +01:00
commit a0fdd324e2
4 changed files with 27 additions and 22 deletions

View File

@ -2,7 +2,7 @@ Options -Indexes
Options -MultiViews -Indexes
RewriteEngine On
RewriteBase /vasek/home/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@ -10,8 +10,8 @@ RewriteCond %{REQUEST_FILENAME} !.css
RewriteCond %{REQUEST_FILENAME} !.js
RewriteRule (.*) index.php?url=$1 [QSA,L]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !api.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_FILENAME} !api.php
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php .php .phtml

View File

@ -5,9 +5,9 @@
#include <ArduinoJson.h>
//Variables
const char* ssid = "";
const char* pasw = "";
const char* hwId = "";
const char* ssid = "Smart-Home";
const char* pasw = "S1pjg3684dcCPTUQ";
const char* hwId = "45235sadad";
const char* url = "http://dev.steelants.cz/vasek/home/api.php";
int unsuccessfulRounds = 0;

View File

@ -7,6 +7,11 @@ class Home extends Template
{
global $userManager;
global $langMng;
$roomManager = new RoomManager();
$deviceManager = new DeviceManager();
$subDeviceManager = new SubDeviceManager();
$recordManager = new RecordManager();
$utilities = new Utilities();
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
@ -15,7 +20,7 @@ class Home extends Template
$template = new Template('home');
//users instantialize
$users = UserManager::getUsers();
$users = $userManager->getUsers();
$template->prepare('users', $users);
//Users at home Info
@ -34,16 +39,16 @@ class Home extends Template
$roomsItems = [];
$roomsData = RoomManager::getAllRooms();
$roomsData = $roomManager->getAllRooms();
foreach ($roomsData as $roomKey => $roomsData) {
$devices = [];
$devicesData = DeviceManager::getAllDevicesInRoom($roomsData['room_id']);
$devicesData = $deviceManager->getAllDevicesInRoom($roomsData['room_id']);
foreach ($devicesData as $deviceKey => $deviceData) {
$subDevices = [];
$subDevicesData = SubDeviceManager::getAllSubDevices($deviceData['device_id']);
$subDevicesData = $subDeviceManager->getAllSubDevices($deviceData['device_id']);
foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
$events = RecordManager::getLastRecord($subDeviceData['subdevice_id'], 5);
$events = $recordManager->getLastRecord($subDeviceData['subdevice_id'], 5);
$eventsRaw = $events;
$connectionError = true;
@ -100,7 +105,7 @@ class Home extends Template
//parsing last values
$parsedValue = $replacementFalse;
if (Utilities::checkOperator($lastValue, $operator, $breakValue)) {
if ($utilities->checkOperator($lastValue, $operator, $breakValue)) {
$parsedValue = $replacementTrue;
}
@ -108,14 +113,14 @@ class Home extends Template
//parsing last events values
foreach ($events as $key => $value) {
$events[$key]['value'] = $replacementFalse;
if (Utilities::checkOperator($value['value'], $operator, $breakValue)) {
if ($utilities->checkOperator($value['value'], $operator, $breakValue)) {
$events[$key]['value'] = $replacementTrue;
}
}
}
$LastRecordTime = new DateTime($lastRecord['time']);
$niceTime = Utilities::ago($LastRecordTime);
$niceTime = $utilities->ago($LastRecordTime);
$interval = $LastRecordTime->diff(new DateTime());
$hours = $interval->format('%h');
@ -175,7 +180,7 @@ class Home extends Template
];
}
$rooms = RoomManager::getAllRooms();
$rooms = $roomManager->getAllRooms();
$template->prepare('baseDir', BASEDIR);
$template->prepare('debugMod', DEBUGMOD);
$template->prepare('title', 'Home');

View File

@ -3,20 +3,20 @@
"short_name": "Home",
"description": "Smart Home interface in PWA",
"lang": "cs-CZ",
"start_url": "/vasek/home/",
"scope": "/vasek/home/",
"start_url": "/",
"scope": "/",
"display": "fullscreen",
"orientation": "portrait",
"theme_color": "#182239",
"icons": [
{
"src": "/vasek/home/app/templates/images/icon-192x192.png",
"src": "/app/templates/images/icon-192x192.png",
"sizes": "192x192"
},
{
"src": "/vasek/home/app/templates/images/icon-512x512.png",
"src": "/app/templates/images/icon-512x512.png",
"sizes": "512x512"
}
],
"background_color": "#182239"
}
}