add edit on owen server

This commit is contained in:
unknown 2020-02-06 17:57:11 +01:00
parent 21bcff9660
commit fc7689b5a6
4 changed files with 27 additions and 22 deletions

View File

@ -2,7 +2,7 @@ Options -Indexes
Options -MultiViews -Indexes Options -MultiViews -Indexes
RewriteEngine On RewriteEngine On
RewriteBase /vasek/home/ RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
@ -10,8 +10,8 @@ RewriteCond %{REQUEST_FILENAME} !.css
RewriteCond %{REQUEST_FILENAME} !.js RewriteCond %{REQUEST_FILENAME} !.js
RewriteRule (.*) index.php?url=$1 [QSA,L] RewriteRule (.*) index.php?url=$1 [QSA,L]
RewriteCond %{HTTPS} off #RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !api.php #RewriteCond %{REQUEST_FILENAME} !api.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] #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> #include <ArduinoJson.h>
//Variables //Variables
const char* ssid = ""; const char* ssid = "Smart-Home";
const char* pasw = ""; const char* pasw = "S1pjg3684dcCPTUQ";
const char* hwId = ""; const char* hwId = "45235sadad";
const char* url = "http://dev.steelants.cz/vasek/home/api.php"; const char* url = "http://dev.steelants.cz/vasek/home/api.php";
int unsuccessfulRounds = 0; int unsuccessfulRounds = 0;

View File

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

View File

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