This commit is contained in:
JonatanRek 2019-10-08 18:31:23 +02:00
commit fa6a5d6b6a
8 changed files with 33 additions and 13 deletions

View File

@ -8,7 +8,7 @@ if (isset($_POST) && !empty($_POST)){
], JSON_PRETTY_PRINT); ], JSON_PRETTY_PRINT);
$onDays = $_POST['atDays']; $onDays = $_POST['atDays'];
AutomationManager::create('name', $onDays, $doCode, $ifCode); AutomationManager::create($_POST['name'], $onDays, $doCode, $ifCode);
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE); header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
die(); die();
@ -23,7 +23,7 @@ if (isset($_POST) && !empty($_POST)){
$json = json_encode([ $json = json_encode([
'deviceID' => $subDeviceMaster['device_id'], 'deviceID' => $subDeviceMaster['device_id'],
'type'=> htmlspecialchars($subDevice['type']), 'type'=> $subDevice['type'],
'value'=> $subDeviceValue, 'value'=> $subDeviceValue,
]); ]);
} }
@ -36,7 +36,7 @@ if (isset($_POST) && !empty($_POST)){
], JSON_PRETTY_PRINT); ], JSON_PRETTY_PRINT);
$onDays = ($_POST['day'] != '' ? json_encode($_POST['day']) : ''); $onDays = ($_POST['day'] != '' ? json_encode($_POST['day']) : '');
AutomationManager::create('name', $onDays, $doCode, $ifCode, (isset ($_POST['automation_id']) ? $_POST['automation_id'] : "")); AutomationManager::create($_POST['name'], $onDays, $doCode, $ifCode, (isset ($_POST['automation_id']) ? $_POST['automation_id'] : ""));
header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE); header('Location: /vasek/home/' . strtolower(basename(__FILE__, '.php')), TRUE);
die(); die();

View File

@ -44,6 +44,7 @@ $lang = [
'l_inMinutes' => 'v minutách', 'l_inMinutes' => 'v minutách',
'l_sleepTime' => 'Doba spánku zařízení', 'l_sleepTime' => 'Doba spánku zařízení',
'l_atHome' => 'Doma Jsou', 'l_atHome' => 'Doma Jsou',
'l_nameAt' => 'Název',
//Title //Title
't_createScene' => 'Vytvořit scénu', 't_createScene' => 'Vytvořit scénu',

View File

@ -44,6 +44,7 @@ $lang = [
'l_inMinutes' => 'in minutes', 'l_inMinutes' => 'in minutes',
'l_sleepTime' => 'Device sleep Time', 'l_sleepTime' => 'Device sleep Time',
'l_atHome' => 'At home', 'l_atHome' => 'At home',
'l_nameAt' => 'Name',
//Title //Title
't_createScene' => 'Create Scene', 't_createScene' => 'Create Scene',

View File

@ -37,10 +37,11 @@
</div> </div>
<div class="col"> <div class="col">
<h5 class="text-right break-all"> <h5 class="text-right break-all">
<?php <?php
if (!in_array($AUTOMATIONDATA['ifSomething'], ["sunRise", "sunSet"])) { /*if (!in_array($AUTOMATIONDATA['ifSomething'], ["sunRise", "sunSet"])) {
echo $AUTOMATIONDATA['ifSomething']; echo $AUTOMATIONDATA['ifSomething'];
} }*/
echo $AUTOMATIONDATA['name'];
?> ?>
</h5> </h5>
</div> </div>
@ -50,6 +51,14 @@
<?php echo implode(', ',$AUTOMATIONDATA['onDays']);?> <?php echo implode(', ',$AUTOMATIONDATA['onDays']);?>
</div> </div>
</div> </div>
<div class="row">
<div class="col">
<a class="button is-primary m-1" onclick="$('#modal').removeClass('modal-container-hiden').show();">restart</a>
</div>
<div class="col">
<a class="button is-primary m-1" onclick="$('#modal').removeClass('modal-container-hiden').show();">deaktivovat</a>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,6 +4,10 @@
<h4 class="mb-4"><?php echo $LANG['t_createAutomation']?></h4> <h4 class="mb-4"><?php echo $LANG['t_createAutomation']?></h4>
<form method="post"> <form method="post">
<div class="field"> <div class="field">
<div class="label"><?php echo $LANG['l_nameAt']?></div>
<div class="field">
<input class="input" type="text" name="name" required/>
</div>
<div class="label"><?php echo $LANG['l_runAt']?></div> <div class="label"><?php echo $LANG['l_runAt']?></div>
<div class="field"> <div class="field">
<select class="input" name="atSelector" id="valueSelector" required> <select class="input" name="atSelector" id="valueSelector" required>
@ -29,12 +33,12 @@
<div class="label"><?php echo $LANG['l_affectedDevices']?></div> <div class="label"><?php echo $LANG['l_affectedDevices']?></div>
<div class="field"> <div class="field">
<select class="input" name="devices[]" multiple> <select class="input" name="devices[]" multiple>
<?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){ <?php foreach ($SUBDEVICES as $subDeviceKey => $subDeviceValue){
if ($subDeviceValue['type'] != 'on/off') continue;?> if ($subDeviceValue['type'] != 'on/off') continue;?>
<option value="<?php echo $subDeviceValue['masterDevice']; ?>"><?php echo $subDeviceValue['name']; ?></option> <option value="<?php echo $subDeviceValue['masterDevice']; ?>"><?php echo $subDeviceValue['name']; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
<div class="label"><?php echo $LANG['l_atDays']?></div> <div class="label"><?php echo $LANG['l_atDays']?></div>
<div class="field"> <div class="field">
@ -62,4 +66,4 @@
<input type="submit" class="button" name="modalNext" value="<?php echo $LANG['b_next']?>"/> <input type="submit" class="button" name="modalNext" value="<?php echo $LANG['b_next']?>"/>
</form> </form>
</div> </div>
</div> </div>

View File

@ -5,6 +5,7 @@
<form method="post"> <form method="post">
<div class="field"> <div class="field">
<input type="hidden" name="atSelector" value="<?php echo $_POST['atSelector']; ?>" required/> <input type="hidden" name="atSelector" value="<?php echo $_POST['atSelector']; ?>" required/>
<input type="hidden" name="name" value="<?php echo $_POST['name']; ?>" required/>
<input type="hidden" name="atSelectorValue" value="<?php if (isset($_POST['atTime'])) { <input type="hidden" name="atSelectorValue" value="<?php if (isset($_POST['atTime'])) {
echo $_POST['atTime']; echo $_POST['atTime'];
} else if (isset($_POST['atDeviceValue'])) { } else if (isset($_POST['atDeviceValue'])) {
@ -12,7 +13,7 @@
$subDeviceValue = $_POST['atDeviceValueInt']; $subDeviceValue = $_POST['atDeviceValueInt'];
$subDevice = SubDeviceManager::getSubDevice($subDeviceId); $subDevice = SubDeviceManager::getSubDevice($subDeviceId);
$subDeviceMaster = SubDeviceManager::getSubDeviceMaster($subDeviceId,$subDevice['type']); $subDeviceMaster = SubDeviceManager::getSubDeviceMaster($subDeviceId,$subDevice['type']);
$json = json_encode([ $json = json_encode([
'deviceID' => $subDeviceMaster['device_id'], 'deviceID' => $subDeviceMaster['device_id'],
'type'=> htmlspecialchars($subDevice['type']), 'type'=> htmlspecialchars($subDevice['type']),
@ -36,4 +37,4 @@
<input type="submit" class="button" name="modalFinal" value="Next"/> <input type="submit" class="button" name="modalFinal" value="Next"/>
</form> </form>
</div> </div>
</div> </div>

View File

@ -7,6 +7,10 @@
<form method="post"> <form method="post">
<input name="automation_id" type="hidden" value="<?php echo $AUTOMATIONID; ?>"> <input name="automation_id" type="hidden" value="<?php echo $AUTOMATIONID; ?>">
<div class="field"> <div class="field">
<div class="label"><?php echo $LANG['l_nameAt']?></div>
<div class="field">
<input class="input" type="text" name="name" value="<?php echo (isset ($AUTOMATION['name']) ? $AUTOMATION['name'] : ""); ?>" required/>
</div>
<div class="label"><?php echo $LANG['l_runAt']?></div> <div class="label"><?php echo $LANG['l_runAt']?></div>
<div class="field"> <div class="field">
<?php //TODO Dodělat identifikaci pro Selctor události a selector času zařízení hodnoty ?> <?php //TODO Dodělat identifikaci pro Selctor události a selector času zařízení hodnoty ?>

View File

@ -28,7 +28,7 @@ class Automation extends Template
]; ];
} }
$automations[$automationData['automation_id']] = [ $automations[$automationData['automation_id']] = [
'name' => '', 'name' => $automationData['name'],
'onDays' => json_decode($automationData['on_days']), 'onDays' => json_decode($automationData['on_days']),
'ifSomething' => $automationData['if_something'], 'ifSomething' => $automationData['if_something'],
'doSomething' => $doSomething, 'doSomething' => $doSomething,