add name to automatization

This commit is contained in:
unknown 2019-10-08 18:23:57 +02:00
parent 9ae039a4b5
commit 68da935592
8 changed files with 38 additions and 18 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,9 +37,10 @@
<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>
@ -49,6 +50,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>

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'])) {

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,