FTP -> GIT Diff
This commit is contained in:
@@ -105,10 +105,8 @@ $apiLogManager->write("[API] request body\n" . json_encode($obj, JSON_PRETTY_PRI
|
||||
$apiLogManager->write("[API] POST body\n" . json_encode($_POST, JSON_PRETTY_PRINT), LogRecordTypes::INFO);
|
||||
$apiLogManager->write("[API] GET body\n" . json_encode($_GET, JSON_PRETTY_PRINT), LogRecordTypes::INFO);
|
||||
|
||||
|
||||
|
||||
Debugger::flag('dbconnect');
|
||||
//D B Conector
|
||||
//DB Conector
|
||||
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
|
||||
|
||||
Debugger::flag('routes');
|
||||
|
@@ -112,7 +112,7 @@ class Form {
|
||||
* [render function whitch dysplay generated form]
|
||||
*/
|
||||
function render(){
|
||||
self::addInput(InputTypes::SUBMIT, 'formSubmit', '', 'Submit', 'Submit');
|
||||
self::addInput(InputTypes::SUBMIT, 'formSubmit', '', '', 'Submit');
|
||||
$form = '<form '.$this->formName.$this->formId.$this->method.$this->action.'">';
|
||||
$form .= $this->formContent;
|
||||
$form .= '</form>';
|
||||
|
29
app/models/managers/Pluginmanager.php
Normal file
29
app/models/managers/Pluginmanager.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class PluginManager
|
||||
{
|
||||
public function load(){
|
||||
$dir = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . '/backup/';
|
||||
|
||||
$pluginsFiles = scandir ($dir);
|
||||
foreach ($pluginsFiles as $key => $pluginFile) {
|
||||
$className = str_replace(".zip", "", $pluginsFiles);
|
||||
if(class_exists($className)){
|
||||
(new $className)->make();
|
||||
}
|
||||
}
|
||||
|
||||
$sleepTime = DeviceManager::getDeviceById($deviceId)['sleep_time'];
|
||||
|
||||
$LastRecordTime = new DateTime(RecordManager::getLastRecord($subDeviceId, 1)['time']);
|
||||
$interval = $LastRecordTime->diff(new DateTime());
|
||||
$hours = $interval->format('%h');
|
||||
$minutes = $interval->format('%i');
|
||||
$lastSeen = ($hours * 60 + $minutes);
|
||||
|
||||
if ($lastSeen > $sleepTime || $sleepTime == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -66,10 +66,6 @@ class SubDeviceManager
|
||||
}
|
||||
}
|
||||
|
||||
public static function editSubDevicesByDevice ($deviceId, $subDeviceParameters) {
|
||||
DB::edit('subdevices', $subDeviceParameters, 'WHERE device_id=?', array ($deviceId));
|
||||
}
|
||||
|
||||
public static function remove($subDeviceId)
|
||||
{
|
||||
RecordManager::cleanSubdeviceRecords($subDeviceId);
|
||||
|
11
app/plugins/!ExamplePlugin.php
Normal file
11
app/plugins/!ExamplePlugin.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
class ExamplePlugin extends VirtualDeviceManager
|
||||
{
|
||||
function make(){
|
||||
//Getting Data
|
||||
}
|
||||
|
||||
function translate($value){
|
||||
//Translation of numeric values
|
||||
}
|
||||
}
|
39
app/plugins/!_Covid.php
Normal file
39
app/plugins/!_Covid.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
class Covid extends VirtualDeviceManager
|
||||
{
|
||||
private $country_sluig = "czech-republic";
|
||||
private $api_uri = 'https://api.covid19api.com/live/country/%s/status/confirmed'; // Your redirect uri
|
||||
private $virtual_device_name = "Covid";
|
||||
|
||||
function make()
|
||||
{
|
||||
try {
|
||||
if (DeviceManager::registeret($this->virtual_device_name)) {
|
||||
$deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id'];
|
||||
$dataItems = ['Confirmed', 'Deaths', 'Recovered', 'Active'];
|
||||
foreach ($dataItems as $dataItem) {
|
||||
if (!$subDevice = SubDeviceManager::getSubDeviceByMaster($deviceId, strtolower($dataItem))) {
|
||||
SubDeviceManager::create($deviceId, strtolower($dataItem), $dataItem);
|
||||
sleep(1);
|
||||
$subDevice = SubDeviceManager::getSubDeviceByMaster($deviceId, strtolower($dataItem));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->fetchEnabled($deviceId, $subDevice['subdevice_id'])) die();
|
||||
|
||||
$finalUrl = sprintf($this->api_uri, $this->country_sluig);
|
||||
$json = json_decode(Utilities::CallAPI('GET', $finalUrl, ''), true);
|
||||
|
||||
foreach ($dataItems as $dataItem) {
|
||||
RecordManager::create($deviceId, strtolower($dataItem), end($json)[$dataItem]);
|
||||
}
|
||||
} else {
|
||||
DeviceManager::create($this->virtual_device_name, $this->virtual_device_name, 'senzore-virtual');
|
||||
DeviceManager::approved($this->virtual_device_name);
|
||||
}
|
||||
return 'sucessful';
|
||||
} catch (Exception $e) {
|
||||
return 'exception: ' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,14 +9,6 @@ class AirQuality extends VirtualDeviceManager
|
||||
|
||||
function make()
|
||||
{
|
||||
//Register the settings
|
||||
$settingMng = new SettingsManager();
|
||||
if (!($settingField = $settingMng->getByName("airquality"))) {
|
||||
$settingMng->create("token", "", "airquality");
|
||||
} else {
|
||||
$app_id = $settingField['value'];
|
||||
}
|
||||
|
||||
try {
|
||||
if (DeviceManager::registeret($this->virtual_device_name)) {
|
||||
$deviceId = DeviceManager::getDeviceByToken($this->virtual_device_name)['device_id'];
|
||||
|
@@ -24,7 +24,15 @@ $partial = new Partial('head');
|
||||
<div class="col-md-9 main-body">
|
||||
<a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php $LANGMNG->echo('t_createAutomation'); ?></a>
|
||||
<div class="row no-gutters">
|
||||
<?php foreach ($AUTOMATIONS as $automationId => $automationData) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
foreach ($AUTOMATIONS as $automationId => $automationData) {
|
||||
//BUTTON
|
||||
$partial = new Partial('automationButton');
|
||||
$partial->prepare('langMng',$LANGMNG);
|
||||
@@ -57,6 +65,28 @@ $partial = new Partial('head');
|
||||
|
||||
$partial->prepare('subDevices',$SUBDEVICES);
|
||||
$partial->render();
|
||||
|
||||
$form = new Form('Automation', 'automation-1', 'POST', '');
|
||||
$form->addInput('text','name', 'name', '', true, true);
|
||||
$form->addSelect('run-condition', 'run-condition', 'l_run_condition', [
|
||||
'test' => 'test',
|
||||
'test1' => 'test',
|
||||
'test2' => 'test',
|
||||
'test3' => 'test',
|
||||
'test4' => 'test',
|
||||
'test5' => 'test',
|
||||
|
||||
], true, true, true);
|
||||
$form->addInput('button','add-condition', 'add-condition', 'l_condition', true, true);
|
||||
$form->addSelect('active-time', 'active-time', 'l_run_schedule', [
|
||||
'all' => 'l_all',
|
||||
'day' => 'l_day',
|
||||
'night' => 'l_night',
|
||||
'custome' => 'l_custome',
|
||||
], true, true, true);
|
||||
|
||||
$form->render();
|
||||
|
||||
}?>
|
||||
<script src="./app/templates/js/automation.js"></script>
|
||||
<?php
|
||||
|
@@ -8,60 +8,26 @@
|
||||
<div class="field">
|
||||
<input class="input" type="text" name="name" required/>
|
||||
</div>
|
||||
<div class="label"><?php $LANGMNG->echo('l_runAt')?></div>
|
||||
<div class="field">
|
||||
<select class="input" name="atSelector" id="valueSelector" required>
|
||||
<option value="sunSet"><?php $LANGMNG->echo('l_sunSet')?></option>
|
||||
<option value="sunRise"><?php $LANGMNG->echo('l_sunRice')?></option>
|
||||
<option value="inHome"><?php $LANGMNG->echo('l_inHome')?></option>
|
||||
<option value="outHome"><?php $LANGMNG->echo('l_outHome')?></option>
|
||||
<option value="time"><?php $LANGMNG->echo('l_time')?></option>
|
||||
<option value="atDeviceValue"><?php $LANGMNG->echo('l_deviceValue');?></option>
|
||||
<option value="noOneHome"><?php $LANGMNG->echo('w_noOne') . ' ' . $LANGMNG->get('w_neni') . ' ' . $LANGMNG->get('w_home');?></option>
|
||||
<option value="someOneHome"><?php $LANGMNG->echo('w_someOne') . ' ' . $LANGMNG->get('w_is') . ' ' . $LANGMNG->get('w_home');?></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 $LANGMNG->echo('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 $subDeviceValue['masterDevice']; ?>"><?php echo $subDeviceValue['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<div class="label"><?php $LANGMNG->echo('l_runCondition')?></div>
|
||||
<select class="input" name="condOper" id="valueSelector" required>
|
||||
<option value="or"><?php $LANGMNG->echo('l_oneNeedToBeWaild')?></option>
|
||||
<option value="and"><?php $LANGMNG->echo('l_allNeedToBeWalid')?></option>
|
||||
</select>
|
||||
<input type="button" class="button" name="addCondition" value="<?php $LANGMNG->echo('b_add')?>"/>
|
||||
|
||||
|
||||
<div class="label"><?php $LANGMNG->echo('l_runTask')?></div>
|
||||
<input type="button" class="button" name="addTask" value="<?php $LANGMNG->echo('b_add')?>"/>
|
||||
|
||||
<div class="label"><?php $LANGMNG->echo('l_activeTime')?></div>
|
||||
<select class="input" name="condOper" id="valueSelector" required>
|
||||
<option value="allday"><?php $LANGMNG->echo('l_all')?></option>
|
||||
<option value="daytime"><?php $LANGMNG->echo('l_day')?></option>
|
||||
<option value="night"><?php $LANGMNG->echo('l_night')?></option>
|
||||
<option value="custom"><?php $LANGMNG->echo('l_custome')?></option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="label"><?php $LANGMNG->echo('l_atDays')?></div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="mon"/> <?php $LANGMNG->echo('d_monday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="tue"/> <?php $LANGMNG->echo('d_tuesday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="wed"/> <?php $LANGMNG->echo('d_wednesday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="thu"/> <?php $LANGMNG->echo('d_thursday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="fri"/> <?php $LANGMNG->echo('d_friday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="sat"/> <?php $LANGMNG->echo('d_saturday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="sun"/> <?php $LANGMNG->echo('d_sunday'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="button" name="modalNext" value="<?php $LANGMNG->echo('b_next')?>"/>
|
||||
</form>
|
||||
|
69
app/views/templates/part/newAutomationCreate.phtml
Normal file
69
app/views/templates/part/newAutomationCreate.phtml
Normal file
@@ -0,0 +1,69 @@
|
||||
<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 $LANGMNG->echo('t_createAutomation')?></h4>
|
||||
<form method="post" action="" >
|
||||
<div class="field">
|
||||
<div class="label"><?php $LANGMNG->echo('l_nameAt')?></div>
|
||||
<div class="field">
|
||||
<input class="input" type="text" name="name" required/>
|
||||
</div>
|
||||
<div class="label"><?php $LANGMNG->echo('l_runAt')?></div>
|
||||
<div class="field">
|
||||
<select class="input" name="atSelector" id="valueSelector" required>
|
||||
<option value="sunSet"><?php $LANGMNG->echo('l_sunSet')?></option>
|
||||
<option value="sunRise"><?php $LANGMNG->echo('l_sunRice')?></option>
|
||||
<option value="inHome"><?php $LANGMNG->echo('l_inHome')?></option>
|
||||
<option value="outHome"><?php $LANGMNG->echo('l_outHome')?></option>
|
||||
<option value="time"><?php $LANGMNG->echo('l_time')?></option>
|
||||
<option value="atDeviceValue"><?php $LANGMNG->echo('l_deviceValue');?></option>
|
||||
<option value="noOneHome"><?php $LANGMNG->echo('w_noOne') . ' ' . $LANGMNG->get('w_neni') . ' ' . $LANGMNG->get('w_home');?></option>
|
||||
<option value="someOneHome"><?php $LANGMNG->echo('w_someOne') . ' ' . $LANGMNG->get('w_is') . ' ' . $LANGMNG->get('w_home');?></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 $LANGMNG->echo('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 $subDeviceValue['masterDevice']; ?>"><?php echo $subDeviceValue['name']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="label"><?php $LANGMNG->echo('l_atDays')?></div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="mon"/> <?php $LANGMNG->echo('d_monday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="tue"/> <?php $LANGMNG->echo('d_tuesday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="wed"/> <?php $LANGMNG->echo('d_wednesday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="thu"/> <?php $LANGMNG->echo('d_thursday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="fri"/> <?php $LANGMNG->echo('d_friday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="sat"/> <?php $LANGMNG->echo('d_saturday'); ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="checkbox" name="day[]" value="sun"/> <?php $LANGMNG->echo('d_sunday'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="button" name="modalNext" value="<?php $LANGMNG->echo('b_next')?>"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user