FTP -> GIT (SYNC)
This commit is contained in:
17
app/controls/automation.php
Normal file
17
app/controls/automation.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
if (isset($_POST) && !empty($_POST)){
|
||||
if (isset($_POST['modalFinal']) && $_POST['modalFinal'] == "Next") {
|
||||
$doCode = json_encode($_POST['device'], JSON_PRETTY_PRINT);
|
||||
$ifCode = json_encode([
|
||||
"type" => $_POST['atSelector'],
|
||||
"value" => $_POST['atSelectorValue'],
|
||||
], JSON_PRETTY_PRINT);
|
||||
$onDays = $_POST['atDays'];
|
||||
|
||||
AutomationManager::create('name', $onDays, $doCode, $ifCode);
|
||||
|
||||
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
||||
die();
|
||||
}
|
||||
}
|
||||
?>
|
14
app/controls/dashboard.php
Normal file
14
app/controls/dashboard.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
if (isset($_POST) && !empty($_POST)){
|
||||
|
||||
if (isset($_POST['modalFinal']) && $_POST['modalFinal'] == "Next") {
|
||||
$subDeviceIds = $_POST['devices'];
|
||||
foreach ($subDeviceIds as $subDeviceId) {
|
||||
DashboardManager::Add($subDeviceId);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
||||
die();
|
||||
}
|
||||
?>
|
73
app/controls/home.php
Normal file
73
app/controls/home.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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($_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="/vasek/home/">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="/vasek/home/">CONTINUE</a>';
|
||||
die();
|
||||
}
|
||||
header('Location: /vasek/home/', TRUE);
|
||||
die();
|
||||
}
|
||||
?>
|
18
app/controls/scene.php
Normal file
18
app/controls/scene.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
if (isset($_POST) && !empty($_POST)){
|
||||
|
||||
SceneManager::create($_POST['sceneIcon'], $_POST['sceneName'], json_encode($_POST['devices']));
|
||||
|
||||
//Debug
|
||||
if (DEBUGMOD == 1) {
|
||||
echo '<pre>';
|
||||
var_dump($_POST);
|
||||
echo '</pre>';
|
||||
echo '<a href="/vasek/home/' . strtolower(basename(__FILE__, '.php')).'">CONTINUE</a>';
|
||||
die();
|
||||
}
|
||||
|
||||
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
|
||||
die();
|
||||
}
|
Reference in New Issue
Block a user