Automation Restart & Deactive Button add
This commit is contained in:
		@@ -13,6 +13,10 @@ class AutomationManager{
 | 
				
			|||||||
		return Db::command ('UPDATE automation SET active = ? WHERE automation_id=?', array ($flipedValue,$automationId));
 | 
							return Db::command ('UPDATE automation SET active = ? WHERE automation_id=?', array ($flipedValue,$automationId));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public function restart($automationId) {
 | 
				
			||||||
 | 
							return Db::command ('UPDATE automation SET executed = 0 WHERE automation_id=?', array ($automationId));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public function create ($name, $onDays, $doCode, $ifCode, $automationId = "") {
 | 
						public function create ($name, $onDays, $doCode, $ifCode, $automationId = "") {
 | 
				
			||||||
		$scene = array (
 | 
							$scene = array (
 | 
				
			||||||
			'name' => $name,
 | 
								'name' => $name,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,9 @@
 | 
				
			|||||||
		$partial->prepare('langMng',$LANGMNG);
 | 
							$partial->prepare('langMng',$LANGMNG);
 | 
				
			||||||
		$partial->prepare('subDevices',$SUBDEVICES);
 | 
							$partial->prepare('subDevices',$SUBDEVICES);
 | 
				
			||||||
		$partial->render();
 | 
							$partial->render();
 | 
				
			||||||
	}
 | 
						}?>
 | 
				
			||||||
 | 
						<script src="./app/templates/js/automation.js"></script>
 | 
				
			||||||
 | 
						<?php
 | 
				
			||||||
	$partial = new Partial('footer');
 | 
						$partial = new Partial('footer');
 | 
				
			||||||
	$partial->render();
 | 
						$partial->render();
 | 
				
			||||||
	?>
 | 
						?>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										35
									
								
								app/templates/js/automation.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								app/templates/js/automation.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					function restartAutomation(automationId){
 | 
				
			||||||
 | 
					    console.log("restartingAutomation" + automationId);
 | 
				
			||||||
 | 
					    $.ajax({
 | 
				
			||||||
 | 
					        url: 'ajax',
 | 
				
			||||||
 | 
					        type: 'POST',
 | 
				
			||||||
 | 
					        data: {
 | 
				
			||||||
 | 
					            "automation_id" : automationId,
 | 
				
			||||||
 | 
					            "action": 'restart'
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        success: function(data){
 | 
				
			||||||
 | 
					            console.log(data);
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        error: function (request, status, error) {
 | 
				
			||||||
 | 
					            console.log("ERROR ", request, error);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function toggleAutomation(automationId){
 | 
				
			||||||
 | 
					    console.log("togglingAutomation" + automationId);
 | 
				
			||||||
 | 
					    $.ajax({
 | 
				
			||||||
 | 
					        url: 'ajax',
 | 
				
			||||||
 | 
					        type: 'POST',
 | 
				
			||||||
 | 
					        data: {
 | 
				
			||||||
 | 
					            "automation_id" : automationId,
 | 
				
			||||||
 | 
					            "action": 'deactive'
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        success: function(data){
 | 
				
			||||||
 | 
					            console.log(data);
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        error: function (request, status, error) {
 | 
				
			||||||
 | 
					            console.log("ERROR ", request, error);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -40,6 +40,11 @@ class Ajax extends Template
 | 
				
			|||||||
				die();
 | 
									die();
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									case 'restart':
 | 
				
			||||||
 | 
									AutomationManager::restart($automationId);
 | 
				
			||||||
 | 
									die();
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				default:
 | 
									default:
 | 
				
			||||||
				echo 'no action detected';
 | 
									echo 'no action detected';
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user