History Clean Up

This commit is contained in:
JonatanRek
2019-08-23 13:39:42 +02:00
commit 8cf912993d
112 changed files with 11395 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
.button{
background-color: $secondary-color;
border: 0;
border-radius: $control-border-radius;
color: $base-font-color;
padding: $control-padding-y $control-padding-x;
transition: background-color .15s;
height: 2.5rem;
display: inline-block;
line-height: 1.5;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
text-decoration: none;
&:hover{
color: $base-font-color;
background-color: $secondary-color-dark;
}
&:active{
background-color: $secondary-color-dark;
}
&:focus{
box-shadow: 0 0 3px $control-focus-color;
}
}
.button.is-small{
padding: $control-padding-y $control-padding-x/1.5;
height: 2rem;
font-size: .875rem;
}
.button.is-large{
height: 3rem;
font-size: 1.25rem;
}
.buttons .button{
margin-right: .25rem;
margin-bottom: .25rem;
}
.button.is-primary{
background-color: $primary-color;
color: white;
&:hover{
color: white;
background-color: $primary-color-dark;
}
&:active{
background-color: $primary-color-dark;
}
}
.button.is-danger{
background-color: map-get($red-colors , '100');
color: map-get($red-colors , '500');
&:hover{
background-color: map-get($red-colors , '200');
color: map-get($red-colors , '600');
}
&:active{
background-color: map-get($red-colors , '200');
color: map-get($red-colors , '600');
}
}

185
templates/automation.phtml Normal file
View File

@@ -0,0 +1,185 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$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">
<div class="nav">
<div class="nav-item">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item is-active">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div>
<div class="col-md-9 main-body">
<a href="#modal" class="button is-primary m-1">Create Automation</a>
<a id="remove" class="button m-1"><i class="fa fa-trash" aria-hidden="true"></i></a>
<div class="row no-gutters">
<?php foreach ($AUTOMATIONS as $automationId => $automationData) { ?>
<div class="col-12 col-md-6 col-xl-4 square-wrap">
<div class="rectangle-2">
<div class="square-content double <?php echo ($automationData['active'] == 0 ? 'paused' : ''); ?>" onClick="ajaxPost('./ajax.php',{automation_id:'<?php echo $automationId; ?>'}, this, true);">
<div class="delete">delete</div>
<div class="row">
<div class="col-1">
<h5 class="fa">
<?php
switch ($automationData['ifSomething']) {
case 'sunSet':
echo'&#xf186';
break;
case 'sunRise':
echo'&#xf185 ';
break;
default:
echo'&#xf017';
break;
}
?>
</h5>
</div>
<div class="col">
<h5 class="text-right break-all">
<?php
if (!in_array($automationData['ifSomething'], ["sunRise", "sunSet"])) {
echo $automationData['ifSomething'];
}
?>
</h5>
</div>
</div>
<div class="row">
<div class="col">
<?php echo $automationData['onDays'];?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="modal-container modal-container-hiden" id="modal">
<div class="modal">
<a href=""><i class="fa fa-times close"></i></a>
<h4 class="mb-4">Modal bitch</h4>
<?php if (!isset($_POST['modalNext'])) { ?>
<form method="post">
<div class="field">
<div class="label">Run at:</div>
<div class="field">
<select class="input" name="atSelector" id="valueSelector" required>
<option value="sunSet">Západu Slunce</option>
<option value="sunRise">Východu Slunce</option>
<option value="time">Čase</option>
<option value="atDeviceValue">Hodnbotě Zařízení</option>
</select>
<input class="input" type="time" name="atTime" id="atTime" disabled/>
<select class="input" name="atDeviceValue" id="atDeviceValue" disabled>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
<?php } ?>
</select>
=
<input class="input" type="num" name="atDeviceValueInt" id="atDeviceValueInt" required disabled/>
</div>
<div class="label">Select Affected Devices:</div>
<div class="field">
<select class="input" name="devices[]" multiple>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){
if ($subDeviceValue['type'] != 'on/off') continue;?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?></option>
<?php } ?>
</select>
</div>
<div class="label">ve dny:</div>
<div class="field">
<input type="checkbox" name="day[]" value="mon"/> Pondělí
</div>
<div class="field">
<input type="checkbox" name="day[]" value="tue"/> Úterý
</div>
<div class="field">
<input type="checkbox" name="day[]" value="wed"/> Středa
</div>
<div class="field">
<input type="checkbox" name="day[]" value="thu"/> Čtvrtek
</div>
<div class="field">
<input type="checkbox" name="day[]" value="fri"/> Pátek
</div>
<div class="field">
<input type="checkbox" name="day[]" value="sat"/> Sobota
</div>
<div class="field">
<input type="checkbox" name="day[]" value="sun"/> Neděle
</div>
</div>
<input type="submit" class="button" name="modalNext" value="Next"/>
</form>
<?php } else if (isset($_POST['modalNext'])) { ?>
<form method="post" action="controls/automation.php">
<div class="field">
<input type="hidden" name="atSelector" value="<?php if (isset($_POST['atTime'])) {
echo $_POST['atTime'];
} else if (isset($_POST['atDeviceValue'])) {
$subDeviceId = $_POST['atDeviceValue'];
$subDeviceValue = $_POST['atDeviceValueInt'];
$subDevice = SubDeviceManager::getSubDevice($subDeviceId);
$subDeviceMaster = SubDeviceManager::getSubDeviceMaster($subDeviceId,$subDevice['type']);
$json = json_encode([
'deviceID' => $subDeviceMaster['device_id'],
'type'=> htmlspecialchars($subDevice['type']),
'value'=> $subDeviceValue,
]);
echo htmlspecialchars($json);
}
else {
echo $_POST['atSelector'];
} ?>" required/>
<input type="hidden" name="atDays" value="<?php echo htmlspecialchars(($_POST['day'] != '' ? json_encode($_POST['day']) : '')); ?>" required/>
<?php foreach ($_POST['devices'] as $value) { ?>
<?php $deviceData = DeviceManager::getDeviceById($value); ?>
<div class="label"><?php echo $deviceData['name'];?></div>
<select class="input" name="device[<?php echo $deviceData['device_id'];?>]">
<option value="1">ON</option>
<option value="0">OFF</option>
</select>
<?php } ?>
</div>
<input type="submit" class="button" name="modalFinal" value="Next"/>
</form>
<?php } ?>
</div>
</div>
<?php
$partial = new Partial('footer');
$partial->render();
?>
</body>
</html>

6
templates/css/font-awesome.min.css vendored Normal file

File diff suppressed because one or more lines are too long

19
templates/css/loading.css Normal file
View File

@@ -0,0 +1,19 @@
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid rgb(101, 30, 122);;
width: 100%;
height: 100%;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

2956
templates/css/main.css Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

28
templates/css/modal.css Normal file
View File

@@ -0,0 +1,28 @@
.modal-container-hiden {
display: none !important;
}
#modal:target {
display: flex;
}
#modal2:target {
display: flex;
}
#modal3:target {
display: flex;
}
#modal4:target {
display: flex;
}
@media (max-width: 767px){
.modal>.overflow {
height: calc(100% - 44px);
overflow-y: scroll;
overflow-x: hidden;
}
}

17
templates/css/pre.css Normal file
View File

@@ -0,0 +1,17 @@
pre{
border-radius: 3px;
border: 0px solid transparent;
color: #d4def7;
padding: 0.5em 0.8em;
line-height: 1.5;
background: #121a2b;
width: 100%;
display: block;
}
.rectangle-content{
width: 100%;
background: linear-gradient(135deg, rgba(116, 34, 189, 0.5), rgba(185, 19, 121, 0.5));
border-radius: 8px;
padding: .25rem !important;
}

75
templates/dashboard.phtml Normal file
View File

@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$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">
<div class="nav">
<div class="nav-item">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item is-active">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div>
<div class="col-md-9 main-body">
<a href="#modal" class="button is-primary m-1">Add Device</a>
<a id="remove" class="button m-1"><i class="fa fa-trash" aria-hidden="true"></i></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">
<a href=""><i class="fa fa-times close"></i></a>
<h4 class="mb-4">Modal bitch</h4>
<form method="post" action="controls/dashboard.php">
<div class="field px-2">
<div class="label">Zvolte zařízení:</div>
<select class="input" name="devices[]" multiple>
<?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="Next"/>
</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>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

100
templates/home.phtml Normal file
View File

@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$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">
<div class="nav">
<div class="nav-item is-active">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</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">
doma jsou:
<?php
foreach ($USERS as $user) {
if (trim($user['at_home']) === "entered") {
echo $user['username'];
}
if (trim($user['at_home']) === "connected to") {
echo $user['username'];
}
} ?>
</div>
<select class="select m-1" 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 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('lang',$LANG);
$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('lang',$LANG);
$partialEdit->render();
}
}
} ?>
</div>
</div>
</div>
<?php
$partial = new Partial('footer');
$partial->render();
?>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

2
templates/js/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,182 @@
/*
jQuery Redirect v1.1.3
Copyright (c) 2013-2018 Miguel Galante
Copyright (c) 2011-2013 Nemanja Avramovic, www.avramovic.info
Licensed under CC BY-SA 4.0 License: http://creativecommons.org/licenses/by-sa/4.0/
This means everyone is allowed to:
Share - copy and redistribute the material in any medium or format
Adapt - remix, transform, and build upon the material for any purpose, even commercially.
Under following conditions:
Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
ShareAlike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
*/
;(function ($) {
'use strict';
//Defaults configuration
var defaults = {
url: null,
values: null,
method: "POST",
target: null,
traditional: false,
redirectTop: false
};
/**
* jQuery Redirect
* @param {string} url - Url of the redirection
* @param {Object} values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url.
* @param {string} method - (optional) The HTTP verb can be GET or POST (defaults to POST)
* @param {string} target - (optional) The target of the form. "_blank" will open the url in a new window.
* @param {boolean} traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array. This allows arrays to work with MVC.net among others.
* @param {boolean} redirectTop - (optional) If its called from a iframe, force to navigate the top window.
*//**
* jQuery Redirect
* @param {string} opts - Options object
* @param {string} opts.url - Url of the redirection
* @param {Object} opts.values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url.
* @param {string} opts.method - (optional) The HTTP verb can be GET or POST (defaults to POST)
* @param {string} opts.target - (optional) The target of the form. "_blank" will open the url in a new window.
* @param {boolean} opts.traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array. This allows arrays to work with MVC.net among others.
* @param {boolean} opts.redirectTop - (optional) If its called from a iframe, force to navigate the top window.
*/
$.redirect = function (url, values, method, target, traditional, redirectTop) {
var opts = url;
if (typeof url !== "object") {
var opts = {
url: url,
values: values,
method: method,
target: target,
traditional: traditional,
redirectTop: redirectTop
};
}
var config = $.extend({}, defaults, opts);
var generatedForm = $.redirect.getForm(config.url, config.values, config.method, config.target, config.traditional);
$('body', config.redirectTop ? window.top.document : undefined).append(generatedForm.form);
generatedForm.submit();
generatedForm.form.remove();
};
$.redirect.getForm = function (url, values, method, target, traditional) {
method = (method && ["GET", "POST", "PUT", "DELETE"].indexOf(method.toUpperCase()) !== -1) ? method.toUpperCase() : 'POST';
url = url.split("#");
var hash = url[1] ? ("#" + url[1]) : "";
url = url[0];
if (!values) {
var obj = $.parseUrl(url);
url = obj.url;
values = obj.params;
}
values = removeNulls(values);
var form = $('<form>')
.attr("method", method)
.attr("action", url + hash);
if (target) {
form.attr("target", target);
}
var submit = form[0].submit;
iterateValues(values, [], form, null, traditional);
return { form: form, submit: function () { submit.call(form[0]); } };
}
//Utility Functions
/**
* Url and QueryString Parser.
* @param {string} url - a Url to parse.
* @returns {object} an object with the parsed url with the following structure {url: URL, params:{ KEY: VALUE }}
*/
$.parseUrl = function (url) {
if (url.indexOf('?') === -1) {
return {
url: url,
params: {}
};
}
var parts = url.split('?'),
query_string = parts[1],
elems = query_string.split('&');
url = parts[0];
var i, pair, obj = {};
for (i = 0; i < elems.length; i += 1) {
pair = elems[i].split('=');
obj[pair[0]] = pair[1];
}
return {
url: url,
params: obj
};
};
//Private Functions
var getInput = function (name, value, parent, array, traditional) {
var parentString;
if (parent.length > 0) {
parentString = parent[0];
var i;
for (i = 1; i < parent.length; i += 1) {
parentString += "[" + parent[i] + "]";
}
if (array) {
if (traditional)
name = parentString;
else
name = parentString + "[" + name + "]";
} else {
name = parentString + "[" + name + "]";
}
}
return $("<input>").attr("type", "hidden")
.attr("name", name)
.attr("value", value);
};
var iterateValues = function (values, parent, form, isArray, traditional) {
var i, iterateParent = [];
Object.keys(values).forEach(function (i) {
if (typeof values[i] === "object") {
iterateParent = parent.slice();
iterateParent.push(i);
iterateValues(values[i], iterateParent, form, Array.isArray(values[i]), traditional);
} else {
form.append(getInput(i, values[i], parent, isArray, traditional));
}
});
};
var removeNulls = function (values) {
var propNames = Object.getOwnPropertyNames(values);
for (var i = 0; i < propNames.length; i++) {
var propName = propNames[i];
if (values[propName] === null || values[propName] === undefined) {
delete values[propName];
} else if (typeof values[propName] === 'object') {
values[propName] = removeNulls(values[propName]);
} else if (values[propName].length < 1) {
delete values[propName];
}
}
return values;
};
}(window.jQuery || window.Zepto || window.jqlite));

54
templates/js/post.js Normal file
View File

@@ -0,0 +1,54 @@
function ajaxPost(path, params, self, reload = false) {
navigator.vibrate([200]);
$.ajax({
url: path,
type: 'POST',
data: params,
success: function(msg){
if (msg != '' && msg != 1){
$(self).find('.content').addClass( "loader" );
$(self).find('.row').hide();
waitForExecution(params, self, msg);
} else {
}
console.log(msg);
if (reload){
location.reload();
}
},
error: function (request, status, error) {
console.log('0');
}
});
return false;
}
function waitForExecution(params, elements, msg_state){
console.log('Waiting FOR Executed');
var interval = setInterval(
function(){
$.ajax({
url: 'ajax',
type: 'POST',
data: {
lastRecord:'',
subDevice_id : params['subDevice_id']
},
success: function(msg){
if (msg == 1){
$(elements).find('.text-right').text(msg_state);
$(elements).find('.content').removeClass( "loader" );
$(elements).find('.row').show();
console.log('Executed');
clearInterval(interval);
}
console.log('Waiting FOR Executed');
console.log(msg);
},
error: function (request, status, error) {
console.log('0');
}
});
}, 1000);
}

226
templates/js/script.js Normal file
View File

@@ -0,0 +1,226 @@
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('serviceWorker.js')
.then(registration => {
console.log('Service Worker is registered', registration);
})
.catch(err => {
console.error('Registration failed:', err);
});
});
}
$('#valueSelector').change(function() {
console.log($(this).val());
if( $(this).val() == 'time') {
$('#atTime').prop( "disabled", false );
} else if( $(this).val() == 'atDeviceValue') {
$('#atDeviceValue').prop( "disabled", false );
$('#atDeviceValueInt').prop( "disabled", false );
} else {
$('#atDeviceValue').prop( "disabled", true );
}
});
var pressTimer;
var touch = 0;
var touchSubId = "";
$("div.square-content").on('touchend', function (e){
clearTimeout(pressTimer);
});
$("div.square-content").on('touchstart', function (eTarget) {
var id = $(this).attr('id').replace('device-', '');
var subId = $(this).attr('data-sub-device-id');
touch++;
if(touch == 2 && touchSubId == subId){
console.log("Detail");
$("#modal-detail-"+subId).removeClass('modal-container-hiden').show();
ajaxChart(subId);
touch = 0;
touchSubId = "";
return;
}
touchSubId = subId;
pressTimer = window.setTimeout(function (e) {
console.log("Setting");
$("#modal-setting-"+id).removeClass('modal-container-hiden').show();
}, 500);
});
$("div.square-content").mousedown(function(e) {
if (event.which == 3) {
var windowLoc = $(location).attr('pathname');
windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
console.log(windowLoc);
var id = null;
if (windowLoc == "/") {
id = $(this).attr('id').replace('device-', '');
} else if (windowLoc == "/scene") {
id = $(this).attr('id').replace('scene-', '');
}
$("#modal-setting-"+id).removeClass('modal-container-hiden').show();
console.log("Setting");
console.log("modal" + id);
}
});
$(".close").on('click', function (e) {
var a = $(this).parent().parent();
a.hide();
});
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
$("div.square-content").on('dblclick', function (eTarget) {
windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
if (windowLoc == "/") {
console.log("Detail");
var subId = $(this).attr('data-sub-device-id');
ajaxChart(subId);
$("#modal-detail-"+subId).removeClass('modal-container-hiden').show();
}
});
$("input#sleepTime").change(function() {
console.log("Input text changed!");
});
var element = $('div.delete');
element.hide();
$("a#remove").on('click', function (e) {
console.log("Show/Hide Button");
var element = $('div.delete');
element.toggle();
});
function ajaxChart(id, period = 'day', group = 'hour'){
$.ajax({
url: 'ajax',
type: 'POST',
dataType: 'json',
data: {
"subDevice": id,
"action": 'chart',
"period": period,
"group": group
},
success: function(data){
console.log('ID: ',id, 'DATA: ', data);
var ctx = document.getElementById('canvas-'+id).getContext('2d');
var myChart = new Chart(ctx, data);
},
error: function (request, status, error) {
console.log("ERROR ajaxChart():", request, error);
}
});
}
//select room on load
var windowLoc = $(location).attr('pathname');
windowLoc = windowLoc.substring(windowLoc.lastIndexOf("/"));
console.log();
if (windowLoc == "/") {
var selectRoomId = localStorage.getItem("selectedRoomId");
console.log('Saved Selected Room ID '+ selectRoomId);
$('[name="room"]').val(selectRoomId);
$('.device-button').each(function(){
if (selectRoomId != 'all'){
if($(this).data('room-id') != selectRoomId){
$(this).hide();
} else {
$(this).show();
}
}
});
}
//Room selector
$( '[name="room"]' ).change(function (e) {
console.log('Selected Room ID ' + this.value)
var roomId = this.value;
localStorage.setItem("selectedRoomId", roomId);
$('.device-button').show();
if (roomId != 'all'){
$('.device-button').each(function(){
if($(this).data('room-id') != roomId){
$(this).hide();
}
});
}
});
var autoUpdate = setInterval(function(){
$.ajax({
url: 'ajax',
type: 'POST',
dataType: 'json',
data: {
"action": 'getState'
},
success: function(data){
// console.log('DATA: ', data);
for (const key in data) {
if (data.hasOwnProperty(key)) {
const device = data[key];
$('[data-sub-device-id="'+key+'"]')
.find('.device-button-value')
.text(device['value'])
.attr('title',device['time'])
}
}
},
error: function (request, status, error) {
console.log("ERROR ajaxChart():", request, error);
}
});
},2000);
//Graphs
$('.graph-period').on('click', function (e) {
var subId = $(this).attr('data-sub-device-id');
var period = $(this).attr('data-period');
var groupBy = $(this).attr('data-group');
ajaxChart(subId, period, groupBy);
});

20
templates/loading.css Normal file
View File

@@ -0,0 +1,20 @@
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

37
templates/login.phtml Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$partial->render();
?>
<title><?php echo $TITLE ?></title>
</head>
<body class="no-transitions">
<div class="modal-container">
<div class="modal">
<h4 class="mb-4">Login</h4>
<form method="post">
<div class="field">
<div class="label">Name:</div>
<input class="input" type="text" name="username" placeholder="Jméno.."/>
</div>
<div class="field">
<div class="label">Password:</div>
<input class="input" type="password" name="password" placeholder="Heslo.."/>
</div>
<div class="field">
<div class="label">Remember me:</div>
<input class="" type="checkbox" name="remember" value="true"/>
</div>
<input type="submit" class="button" name="login" value="Login"/>
</form>
</div>
</div>
<?php
$partial = new Partial('footer');
$partial->render();
?>
</body>
</html>

View File

@@ -0,0 +1,85 @@
<div class="modal-container modal-container-hiden" id="modal">
<div class="modal">
<a href=""><i class="fa fa-times close"></i></a>
<h4 class="mb-4"><?php echo $LANG['t_createAutomation']?></h4>
<form method="post">
<div class="field">
<div class="label"><?php echo $LANG['l_runAt']?></div>
<div class="field">
<select class="input" name="atSelector" id="valueSelector" required>
<option value="sunSet"><?php echo $LANG['l_sunSet']?></option>
<option value="sunRise"><?php echo $LANG['l_sunRice']?></option>
<option value="inHome"><?php echo $LANG['l_inHome']?></option>
<option value="outHome"><?php echo $LANG['l_outHome']?></option>
<option value="time"><?php echo $LANG['l_time']?></option>
<option value="atDeviceValue"><?php echo $LANG['l_deviceValue']?></option>
</select>
<input class="input" type="time" name="atTime" id="atTime" disabled/>
<select class="input" name="atDeviceValue" id="atDeviceValue" disabled>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
<?php } ?>
</select>
=
<input class="input" type="num" name="atDeviceValueInt" id="atDeviceValueInt" required disabled/>
</div>
<div class="label"><?php echo $LANG['l_resetAt']?></div>
<div class="field">
<select class="input" name="restartAtSelector" id="valueSelector" required>
<option value="sunSet"><?php echo $LANG['l_sunSet']?></option>
<option value="sunRise"><?php echo $LANG['l_sunRice']?></option>
<option value="inHome"><?php echo $LANG['l_inHome']?></option>
<option value="outHome"><?php echo $LANG['l_outHome']?></option>
<option value="time"><?php echo $LANG['l_time']?></option>
<option value="atDeviceValue"><?php echo $LANG['l_deviceValue']?></option>
</select>
<input class="input" type="time" name="restartAtTime" id="atTime" disabled/>
<select class="input" name="restartAtDeviceValue" id="atDeviceValue" disabled>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
<?php } ?>
</select>
=
<input class="input" type="num" name="restartAtDeviceValueInt" id="atDeviceValueInt" required disabled/>
</div>
<div class="label"><?php echo $LANG['l_affectedDevices']?></div>
<div class="field">
<select class="input" name="devices[]" multiple>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){
if ($subDeviceValue['type'] != 'on/off') continue;?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?></option>
<?php } ?>
</select>
</div>
<div class="label"><?php echo $LANG['l_atDays']?></div>
<div class="field">
<input type="checkbox" name="day[]" value="mon"/> Pondělí
</div>
<div class="field">
<input type="checkbox" name="day[]" value="tue"/> Úterý
</div>
<div class="field">
<input type="checkbox" name="day[]" value="wed"/> Středa
</div>
<div class="field">
<input type="checkbox" name="day[]" value="thu"/> Čtvrtek
</div>
<div class="field">
<input type="checkbox" name="day[]" value="fri"/> Pátek
</div>
<div class="field">
<input type="checkbox" name="day[]" value="sat"/> Sobota
</div>
<div class="field">
<input type="checkbox" name="day[]" value="sun"/> Neděle
</div>
</div>
<input type="submit" class="button" name="modalNext" value="<?php echo $LANG['b_next']?>"/>
</form>
</div>
</div>

View File

@@ -0,0 +1,38 @@
<div class="modal-container" id="modal">
<div class="modal">
<a href=""><i class="fa fa-times close"></i></a>
<h4 class="mb-4"><?php echo $LANG['t_createAutomation']?></h4>
<form method="post">
<div class="field">
<input type="hidden" name="atSelector" value="<?php if (isset($_POST['atTime'])) {
echo $_POST['atTime'];
} else if (isset($_POST['atDeviceValue'])) {
$subDeviceId = $_POST['atDeviceValue'];
$subDeviceValue = $_POST['atDeviceValueInt'];
$subDevice = SubDeviceManager::getSubDevice($subDeviceId);
$subDeviceMaster = SubDeviceManager::getSubDeviceMaster($subDeviceId,$subDevice['type']);
$json = json_encode([
'deviceID' => $subDeviceMaster['device_id'],
'type'=> htmlspecialchars($subDevice['type']),
'value'=> $subDeviceValue,
]);
echo htmlspecialchars($json);
}
else {
echo $_POST['atSelector'];
} ?>" required/>
<input type="hidden" name="atDays" value="<?php echo htmlspecialchars(($_POST['day'] != '' ? json_encode($_POST['day']) : '')); ?>" required/>
<?php foreach ($_POST['devices'] as $value) { ?>
<?php $deviceData = DeviceManager::getDeviceById($value); ?>
<div class="label"><?php echo $deviceData['name'];?></div>
<select class="input" name="device[<?php echo $deviceData['device_id'];?>]">
<option value="1">ON</option>
<option value="0">OFF</option>
</select>
<?php } ?>
</div>
<input type="submit" class="button" name="modalFinal" value="Next"/>
</form>
</div>
</div>

View File

@@ -0,0 +1,97 @@
<div class="modal-container modal-container-hiden" id="modal-setting-<?php echo $AUTOMATIONID; ?>">
<div class="modal">
<div class="close">
<i class="fa fa-times"></i>
</div>
<h4 class="mb-4"><?php echo $LANG['t_createAutomation']?></h4>
<form method="post">
<div class="field">
<div class="label"><?php echo $LANG['l_runAt']?></div>
<div class="field">
<?php //TODO Dodělat identifikaci pro Selctor události a selector času zařízení hodnoty ?>
<select class="input" name="atSelector" id="valueSelector" required>
<option value="sunSet" <?php ECHO ($AUTOMATION['ifSomething'] == "sunSet" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_sunSet']?></option>
<option value="sunRise" <?php ECHO ($AUTOMATION['ifSomething'] == "sunRise" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_sunRice']?></option>
<option value="inHome" <?php ECHO ($AUTOMATION['ifSomething'] == "inHome" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_inHome']?></option>
<option value="outHome" <?php ECHO ($AUTOMATION['ifSomething'] == "outHome" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_outHome']?></option>
<option value="time" <?php ECHO ($AUTOMATION['ifSomething'] == "time" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_time']?></option>
<option value="atDeviceValue" <?php ECHO ($AUTOMATION['ifSomething'] == "atDeviceValue" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_deviceValue']?></option>
</select>
<input class="input" type="time" name="atTime" id="atTime" <?php ECHO ($AUTOMATION['ifSomething'] == "time" ? '' : 'disabled'); ?>/>
<select class="input" name="atDeviceValue" id="atDeviceValue" <?php ECHO ($AUTOMATION['ifSomething'] == "atDeviceValue" ? '' : 'disabled'); ?>>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
<?php } ?>
</select>
=
<input class="input" type="num" name="atDeviceValueInt" id="atDeviceValueInt" required <?php ECHO ($AUTOMATION['ifSomething'] == "atDeviceValue" ? '' : 'disabled'); ?>/>
</div>
<div class="label"><?php echo $LANG['l_resetAt']?></div>
<div class="field">
<?php //TODO Dodělat identifikaci pro Selctor události a selector času zařízení hodnoty ?>
<select class="input" name="restartAtSelector" id="valueSelector" required>
<option value="sunSet" <?php ECHO ($AUTOMATION['ifSomething'] == "sunSet" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_sunSet']?></option>
<option value="sunRise" <?php ECHO ($AUTOMATION['ifSomething'] == "sunRise" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_sunRice']?></option>
<option value="inHome" <?php ECHO ($AUTOMATION['ifSomething'] == "inHome" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_inHome']?></option>
<option value="outHome" <?php ECHO ($AUTOMATION['ifSomething'] == "outHome" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_outHome']?></option>
<option value="time" <?php ECHO ($AUTOMATION['ifSomething'] == "time" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_time']?></option>
<option value="atDeviceValue" <?php ECHO ($AUTOMATION['ifSomething'] == "atDeviceValue" ? 'selected="selected"' : ''); ?>><?php echo $LANG['l_deviceValue']?></option>
</select>
<input class="input" type="time" name="restartAtTime" id="atTime" <?php ECHO ($AUTOMATION['ifSomething'] == "time" ? '' : 'disabled'); ?>/>
<select class="input" name="restartAtDeviceValue" id="atDeviceValue" <?php ECHO ($AUTOMATION['ifSomething'] == "atDeviceValue" ? '' : 'disabled'); ?>>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ ?>
<option value="<?php echo $subDeviceKey; ?>"><?php echo $subDeviceValue['name']; ?>[<?php echo $subDeviceValue['type']; ?>]</option>
<?php } ?>
</select>
=
<input class="input" type="num" name="restartAtDeviceValueInt" id="atDeviceValueInt" required <?php ECHO ($AUTOMATION['ifSomething'] == "atDeviceValue" ? '' : 'disabled'); ?>/>
</div>
<div class="label"><?php echo $LANG['l_affectedDevices'];?></div>
<div class="field">
<div class="field px-2">
<?php
$i = 0;
foreach($AUTOMATION['doSomething'] as $subDeviceId => $subDeviceData){ ?>
<div id="automation-<?php echo $AUTOMATIONID; ?>-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-automation-id="<?php echo $AUTOMATIONID; ?>">&#xf1f8;</button>
</div>
<?php
$i++;
} ?>
</div>
</div>
<div class="label"><?php echo $LANG['l_atDays'];?></div>
<div class="field">
<input type="checkbox" name="day[]" value="mon" <?php ECHO (in_array("mon", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Pondělí
</div>
<div class="field">
<input type="checkbox" name="day[]" value="tue" <?php ECHO (in_array("tue", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Úterý
</div>
<div class="field">
<input type="checkbox" name="day[]" value="wed" <?php ECHO (in_array("wed", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Středa
</div>
<div class="field">
<input type="checkbox" name="day[]" value="thu" <?php ECHO (in_array("thu", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Čtvrtek
</div>
<div class="field">
<input type="checkbox" name="day[]" value="fri" <?php ECHO (in_array("fri", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Pátek
</div>
<div class="field">
<input type="checkbox" name="day[]" value="sat" <?php ECHO (in_array("sat", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Sobota
</div>
<div class="field">
<input type="checkbox" name="day[]" value="sun" <?php ECHO (in_array("sun", $AUTOMATION['onDays']) ? 'checked' : ''); ?>/> Neděle
</div>
</div>
<input type="submit" class="button" name="modalFinal" value="<?php echo $LANG['b_edit'];?>"/>
<input type="submit" class="button is-danger" onClick="ajaxPost('ajax',{automation_id:'<?php echo $AUTOMATIONID ?>', 'action':'delete'}, this, true);" name="remove" value="<?php echo $LANG['b_remove'];?>"/>
</form>
</div>
</div>

View File

@@ -0,0 +1,22 @@
<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.php',{subDevice_id:'<?php echo $DASHBOARDITEMDATA['id']; ?>'}, this);">
<div class="content">
<div class="delete">delete</div>
<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>

View File

@@ -0,0 +1,29 @@
<?php
$action = "";
if ($SUBDEVICE['type'] == 'on/off') {
$action = 'onClick="ajaxPost(\'ajax\',{subDevice_id:\'' . $SUBDEVICEID . '\'}, 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'] ? "is-inactive" : "") ;?>" id="device-<?php echo $DEVICEID ?>" data-sub-device-id="<?php echo $SUBDEVICEID;?>">
<div class="content">
<div class="row">
<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" unselectable="on" >
<?php echo $DEVICE['name']; ?>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,80 @@
<!-- 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>Last Seen <?php 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 echo $LANG['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 echo $LANG['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 echo $LANG['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 echo $LANG['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 echo $LANG['b_hour']?>"
/>
<div>
<table class="table is-fluid">
<thead>
<tr>
<th>Time</th>
<th>State</th>
</tr>
</thead>
<tbody>
<?php foreach ($SUBDEVICE['events'] as $key => $value) { ?>
<tr>
<th><?php echo (new DateTime($value['time']))->format(DATEFORMAT); ?></th>
<th title="test"><?php echo $value['value'] . $SUBDEVICE['unit'];?></th>
<?php //TODO: P5IDAT TOOLTIP PRO RAW VALUE?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -0,0 +1,160 @@
<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 echo $LANG['t_editDevice']; ?></h4>
<form method="post" action="">
<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 echo $LANG['l_owner']; ?></div>
<select class="input" name="deviceOwnerUserId">
<option value=""><?php echo $LANG['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 echo $LANG['l_permission']; ?></div>
<div class="row">
<div class="col-6">
<div class="label"> - <?php echo $LANG['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 echo $LANG['l_read']; ?>
<input type="radio" name="permissionOwner" value=2 <?php ECHO ($permissions[0] == 2 ? 'checked' : ''); ?>/> <?php echo $LANG['l_use']; ?>
<input type="radio" name="permissionOwner" value=3 <?php ECHO ($permissions[0] == 3 ? 'checked' : ''); ?>/> <?php echo $LANG['l_edit']; ?>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="label"> - <?php echo $LANG['l_member']; ?></div>
</div>
<div class="col-6">
<input type="radio" name="permissionOther" value=1 <?php ECHO ($permissions[1] == 1 ? 'checked' : ''); ?>/> <?php echo $LANG['l_read']; ?>
<input type="radio" name="permissionOther" value=2 <?php ECHO ($permissions[1] == 2 ? 'checked' : ''); ?>/> <?php echo $LANG['l_use']; ?>
<input type="radio" name="permissionOther" value=3 <?php ECHO ($permissions[1] == 3 ? 'checked' : ''); ?>/> <?php echo $LANG['l_edit']; ?>
</div>
</div>
<div class="field">
<div class="label"><?php echo $LANG['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>
<?php if ($DEVICE['userIsAdmin']) { ?>
<?php if (!in_array($SUBDEVICE['type'], ['on/off', 'door'])) { ?>
<div class="field">
<div class="label"><?php echo $LANG['l_sleepTime']; ?></div>
<input class="input" type="int" name="sleepTime" value="<?php echo $DEVICE['sleepTime']; ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
<p>* - <?php echo $LANG['l_inMinutes']; ?></p>
</div>
<?php }?>
<div class="field">
<div class="label"><?php echo $LANG['w_room']; ?></div>
<select class="input" name="deviceOwnerId">
<?php foreach ($ROOMS as $room) {
$roomId = $room['room_id'];
$roomName = $room['name'];
?>
<option value="<?php echo $roomName; ?>" <?php ECHO ((int) $roomId === (int) $DEVICE['room'] ? 'selected="selected"' : ''); ?>><?php echo $roomName; ?></option>
<?php } ?>
</select>
</div>
<div class="field">
<div class="label"><?php echo $LANG['w_icon']; ?></div>
<select class="input fa" name="deviceIcon" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
<option value=""><?php echo $LANG['w_no'] . ' ' . $LANG['w_icon']; ?></option>
<option value="f0eb" <?php ECHO ($DEVICE['icon'] == "f0eb" ? 'selected="selected"' : ''); ?>>&#xf0eb; - fa-lightbulb-o</option>
<option value="f2dc" <?php ECHO ($DEVICE['icon'] == "f2dc" ? 'selected="selected"' : ''); ?>>&#xf2dc; - fa-snowflake-o</option>
<option value="f0e7" <?php ECHO ($DEVICE['icon'] == "f0e7" ? 'selected="selected"' : ''); ?>>&#xf0e7; - fa-bolt</option>
<option value="f2c7" <?php ECHO ($DEVICE['icon'] == "f2c7" ? 'selected="selected"' : ''); ?>>&#xf2c7; - fa-thermometer-full</option>
<option value="f236" <?php ECHO ($DEVICE['icon'] == "f236" ? 'selected="selected"' : ''); ?>>&#xf236; - fa-bed</option>
<option value="f185" <?php ECHO ($DEVICE['icon'] == "f185" ? 'selected="selected"' : ''); ?>>&#xf185; - fa-sun-o</option>
<option value="f2db" <?php ECHO ($DEVICE['icon'] == "f2db" ? 'selected="selected"' : ''); ?>>&#xf2db; - fa-microchip</option>
<option value="f011" <?php ECHO ($DEVICE['icon'] == "f011" ? 'selected="selected"' : ''); ?>>&#xf011; - fa-power-off</option>
<option value="f011" <?php ECHO ($DEVICE['icon'] == "f011" ? 'selected="selected"' : ''); ?>>&#xf108; - fa-desktop</option>
</select>
</div>
<?php } ?>
<div class="field">
<div class="label"><?php echo $LANG['w_moduls']; ?></div>
<div class="row no-gutters">
<?php foreach ($DEVICE['subDevices'] as $subDeviceKey => $subDevice) { ?>
<div class="col-4 col-sm-3 col-xl-2 square-wrap">
<div class="square">
<div class="square-content">
<div class="row">
<div class="col">
<h3 class="fa">&#x<?php echo $DEVICE['icon']; ?></h3>
</div>
<div class="col">
<h3><?php echo $subDevice['unit']; ?></h3>
</div>
</div>
<div class="row">
<div class="col">
<?php echo $DEVICE['name']; ?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<input type="submit" class="button" name="saveDevice" value="<?php echo $LANG['b_save']; ?>" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>/>
<input type="submit" class="button is-danger" name="disableDevice" value="<?php echo $LANG['b_disable']; ?>"/>
<?php } else { ?>
<div class="field">
<div class="label"><?php echo $LANG['w_moduls']; ?></div>
<div class="row no-gutters">
<?php foreach ($DEVICE['subDevices'] as $subDeviceKey => $subDevice) { ?>
<div class="col-4 col-sm-3 col-xl-2 square-wrap">
<div class="square">
<div class="square-content">
<div class="row">
<div class="col">
<h3 class="fa">&#x<?php echo $DEVICE['icon']; ?></h3>
</div>
<div class="col">
<h3><?php echo $subDevice['unit']; ?></h3>
</div>
</div>
<div class="row">
<div class="col">
<?php echo $DEVICE['name']; ?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<input type="submit" class="button is-primary" name="approveDevice" value="<?php echo $LANG['b_approve']; ?>"/>
<input type="submit" class="button is-danger" name="disableDevice" value="<?php echo $LANG['b_disable']; ?>"/>
<?php } ?>
</form>
</div>
</div>

View File

@@ -0,0 +1,3 @@
<script src="./templates/js/jquery.js"></script>
<script src="./templates/js/post.js"></script>
<script src="./templates/js/script.js"></script>

25
templates/part/head.phtml Normal file
View File

@@ -0,0 +1,25 @@
<link rel="manifest" href="manifest.json">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="application-name" content="Home">
<meta name="apple-mobile-web-app-title" content="Home">
<meta name="theme-color" content="#182239">
<meta name="msapplication-navbutton-color" content="#182239">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="msapplication-starturl" content="/vasek/home/">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" sizes="192x192" href="/vasek/home/templates/images/icon-192x192.png">
<link rel="apple-touch-icon" sizes="192x192" href="/vasek/home/templates/images/icon-192x192.png">
<link rel="icon" sizes="512x512" href="/vasek/home/templates/images/icon-512x512.png">
<link rel="apple-touch-icon" sizes="512x512" href="/vasek/home/templates/images/icon-512x512.png">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./templates/css/main.css">
<link rel="stylesheet" href="./templates/css/font-awesome.min.css">
<link rel="stylesheet" href="./templates/css/modal.css">
<link rel="stylesheet" href="./templates/css/pre.css">
<link rel="stylesheet" href="./templates/css/loading.css">

View File

@@ -0,0 +1,40 @@
<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 echo $LANG['t_createScene'];?></h4>
<form method="post" action="" >
<div class="field">
<div class="label"><?php echo $LANG['w_title'];?>:</div>
<input type="text" class="input" name="sceneName" value=""/>
</div>
<div class="field">
<div class="label"><?php echo $LANG['w_icon'];?>:</div>
<select class="input fa" name="sceneIcon" <?php echo (!$DEVICE['userIsAdmin'] ? 'disabled' : ''); ?>>
<option value="">No icon</option>
<option value="f0eb">&#xf0eb; - fa-lightbulb-o</option>
<option value="f2dc">&#xf2dc; - fa-snowflake-o</option>
<option value="f0e7">&#xf0e7; - fa-bolt</option>
<option value="f2c7">&#xf2c7; - fa-thermometer-full</option>
<option value="f236">&#xf236; - fa-bed</option>
<option value="f185">&#xf185; - fa-sun-o</option>
<option value="f2db">&#xf2db; - fa-microchip</option>
<option value="f011">&#xf011; - fa-power-off</option>
<option value="f011">&#xf108; - fa-desktop</option>
</select>
</div>
<div class="field">
<div class="label"><?php echo $LANG['l_choseDevice'];?></div>
<select class="input" name="devices[]" multiple>
<?php
foreach ($SUBDEVICES as $subdeviceId => $subdeviceData) {
echo '<option value="'.$subdeviceId.'">'.$subdeviceData['name'].'</option>';
}
?>
</select>
</div>
<input type="submit" class="button" name="submit" value="<?php echo $LANG['b_next'];?>"/>
</form>
</div>
</div>

View File

@@ -0,0 +1,26 @@
<div class="modal-container" id="modal">
<div class="modal">
<div class="close">
<i class="fa fa-times"></i>
</div>
<h4 class="mb-4"><?php echo $LANG['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="submit" value="<?php echo $LANG['b_create'];?>"/>
</form>
</div>
</div>

View File

@@ -0,0 +1,48 @@
<?php //TODO DOD2LAT UKL8D8N9?>
<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 echo $LANG['t_editScene']?></h4>
<form method="post">
<div class="field">
<div class="label"><?php echo $LANG['w_title'];?>:</div>
<input type="text" class="input" name="sceneName" value="<?php echo $SCENE['name']; ?>"/>
</div>
<div class="field">
<div class="label"><?php echo $LANG['w_icon'];?>:</div>
<select class="input fa" name="sceneIcon">
<option value=""><?php echo $LANG['w_no'].$LANG['w_icon'];?></option>
<option value="f0eb" <?php ECHO ($SCENE['icon'] == "f0eb" ? 'selected="selected"' : ''); ?>>&#xf0eb; - fa-lightbulb-o</option>
<option value="f2dc" <?php ECHO ($SCENE['icon'] == "f2dc" ? 'selected="selected"' : ''); ?>>&#xf2dc; - fa-snowflake-o</option>
<option value="f0e7" <?php ECHO ($SCENE['icon'] == "f0e7" ? 'selected="selected"' : ''); ?>>&#xf0e7; - fa-bolt</option>
<option value="f2c7" <?php ECHO ($SCENE['icon'] == "f2c7" ? 'selected="selected"' : ''); ?>>&#xf2c7; - fa-thermometer-full</option>
<option value="f236" <?php ECHO ($SCENE['icon'] == "f236" ? 'selected="selected"' : ''); ?>>&#xf236; - fa-bed</option>
<option value="f185" <?php ECHO ($SCENE['icon'] == "f185" ? 'selected="selected"' : ''); ?>>&#xf185; - fa-sun-o</option>
<option value="f2db" <?php ECHO ($SCENE['icon'] == "f2db" ? 'selected="selected"' : ''); ?>>&#xf2db; - fa-microchip</option>
<option value="f011" <?php ECHO ($SCENE['icon'] == "f011" ? 'selected="selected"' : ''); ?>>&#xf011; - fa-power-off</option>
<option value="f011" <?php ECHO ($SCENE['icon'] == "f011" ? 'selected="selected"' : ''); ?>>&#xf108; - 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; ?>">&#xf1f8;</button>
</div>
<?php
$i++;
} ?>
</div>
<input type="submit" class="button" name="saveDevice" value="<?php echo $LANG['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 echo $LANG['b_remove'];?>"/>
</form>
</div>
</div>

View File

@@ -0,0 +1,3 @@
<H1>
TEST - TEST
</H1>

163
templates/rooms.phtml Normal file
View File

@@ -0,0 +1,163 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$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">
<div class="nav">
<div class="nav-item is-active">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</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 $LANG[$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>

91
templates/scene.phtml Normal file
View File

@@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$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">
<div class="nav">
<div class="nav-item">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item is-active">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div>
<div class="col-md-9 main-body">
<a class="button is-primary m-2" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php echo $LANG['t_createScene'];?></a>
<div class="row no-gutters">
<?php foreach ($SCENES as $sceneId => $sceneData) { ?>
<div class="col-12 col-md-6 col-xl-4 square-wrap">
<div class="rectangle-2">
<div class="square-content double" id="scene-<?php echo $sceneId ?>" onClick="ajaxPost('ajax',{scene_id:'<?php echo $sceneId; ?>'}, this);" >
<div class="row">
<div class="col-1">
<h5 class="fa">
&#x<?php echo $sceneData['icon']; ?>
</h5>
</div>
<div class="col">
<h5 class="text-right break-all">
<?php echo $sceneData['name']; ?>
</h5>
</div>
</div>
<div class="row">
<div class="col">
</div>
</div>
</div>
</div>
</div>
<?php
// Edit
$partialSceneEdit = new Partial('sceneEdit');
$partialSceneEdit->prepare('lang',$LANG);
$partialSceneEdit->prepare('sceneId',$sceneId);
$partialSceneEdit->prepare('scene',$sceneData);
$partialSceneEdit->render();
?>
<?php } ?>
</div>
</div>
</div>
<?php if (isset($_POST['devices'])) {
$partial = new Partial('sceneCreateOptions');
$partial->prepare('lang',$LANG);
$partial->prepare('setStateFormDevices',$SETSTATEFORMDEVICES );
$partial->prepare('sceneIcon',$SCENEICON );
$partial->prepare('SceneName',$SCENENAME );
$partial->render();
} else {
$partial = new Partial('sceneCreate');
$partial->prepare('lang',$LANG);
$partial->prepare('subDevices',$SUBDEVICES);
$partial->render();
}
$partial = new Partial('footer');
$partial->render();
?>
</body>
</html>

81
templates/setting.phtml Normal file
View File

@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$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">
<div class="nav">
<div class="nav-item">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item is-active">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
<div class="nav-item">
<a href="rooms"><i class="fa fa-terminal" aria-hidden="true"></i><span>ROOMS</span></a>
</div>
</div>
</div>
<div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4">
<form method="post" enctype="multipart/form-data">
<div class="">
<div class="field">
<div class="label">Stránka po načtení</div>
<select class="input" name="loadPage">
<option value="0" <?php echo (UserManager::getUserData("startPage") == 0 ? "selected" : ""); ?>>Default</option>
<option value="1" <?php echo (UserManager::getUserData("startPage") == 1 ? "selected" : ""); ?>>Dashboard</option>
</select>
</div>
<input type="submit" name="submit" class="button" value="Uložit"/>
</div>
</div>
</form>
<div class="col-12 col-sm-9 mx-auto mt-4">
<div class="field">
<a href="logout" class="button is-primary">Odhlásit se</a>
</div>
</div>
<div class="col-12 col-sm-9 mx-auto mt-4">
<div class="field">
<button id="enable-features" class="button">Enable Alpha Feature</button>
</div>
</div>
</div>
</div>
<?php
$partial = new Partial('footer');
$partial->render();
//TODO js do main.js
?>
<script>
$( "#enable-features" ).click(function(e) {
var selectRoomId = localStorage.getItem("enableFeature");
if (selectRoomId){
localStorage.setItem("enableFeature", true);
}else {
localStorage.setItem("enableFeature", false);
}
});
</script>
</body>
</html>