mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-02 20:52:41 +02:00
Add toggle for control
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /system/sdcard/www/cgi-bin/func.cgi
|
||||
. /system/sdcard/scripts/common_functions.sh
|
||||
|
||||
export LD_LIBRARY_PATH=/system/lib
|
||||
export LD_LIBRARY_PATH=/thirdlib:$LD_LIBRARY_PATH
|
||||
@@ -14,18 +13,10 @@ echo ""
|
||||
if [ -n "$F_cmd" ]; then
|
||||
case "$F_cmd" in
|
||||
get_services)
|
||||
echo "auto_night_mode#:#$(auto_night_mode status)#:#$(test -f /system/sdcard/config/autostart/auto-night-detection && echo 'true' || echo 'false')#:#false"
|
||||
echo "debug-on-osd#:#$(debug_on_osd status)#:#$(test -f /system/sdcard/config/autostart/debug-on-osd && echo 'true' || echo 'false')#:#false"
|
||||
echo "ftp_server#:#$(ftp_server status)#:#$(test -f /system/sdcard/config/autostart/ftp_server && echo 'true' || echo 'false')#:#false"
|
||||
echo "mqtt-control#:#$(mqtt_control status)#:#$(test -f /system/sdcard/config/autostart/mqtt-control && echo 'true' || echo 'false')#:#false"
|
||||
echo "mqtt-status#:#$(mqtt_status status)#:#$(test -f /system/sdcard/config/autostart/mqtt-status && echo 'true' || echo 'false')#:#false"
|
||||
echo "onvif-srvd#:#$(onvif_srvd status)#:#$(test -f /system/sdcard/config/autostart/onvif-srvd && echo 'true' || echo 'false')#:#false"
|
||||
echo "recording#:#$(recording status)#:#$(test -f /system/sdcard/config/autostart/recording && echo 'true' || echo 'false')#:#false"
|
||||
echo "rtsp-h264#:#$(rtsp_h264_server status)#:#$(test -f /system/sdcard/config/autostart/rtsp-h264 && echo 'true' || echo 'false')#:#false"
|
||||
echo "rtsp-mjpeg#:#$(rtsp_mjpeg_server status)#:#$(test -f /system/sdcard/config/autostart/rtsp-mjpeg && echo 'true' || echo 'false')#:#false"
|
||||
echo "sound-on-startup#:#$(sound_on_startup status)#:#$(test -f /system/sdcard/config/autostart/sound-on-startup && echo 'true' || echo 'false')#:#false"
|
||||
echo "telegram-bot#:#$(telegram_bot status)#:#$(test -f /system/sdcard/config/autostart/telegram-bot && echo 'true' || echo 'false')#:#false"
|
||||
echo "timelapse#:#$(timelapse status)#:#$(test -f /system/sdcard/config/autostart/timelapse && echo 'true' || echo 'false')#:#false"
|
||||
services="auto-night-detection debug-on-osd ftp_server mqtt-control mqtt-status onvif-srvd recording rtsp-h264 rtsp-mjpeg sound-on-startup telegram-bot timelapse"
|
||||
for service in $services ; do
|
||||
echo "${service}#:#$(test -f /run/${service}.pid && echo 'started' || echo 'stopped')#:#$(test -f /system/sdcard/config/autostart/${service} && echo 'true' || echo 'false')#:#false"
|
||||
done
|
||||
return
|
||||
;;
|
||||
autoStartService)
|
||||
@@ -41,7 +32,7 @@ if [ -n "$F_cmd" ]; then
|
||||
return
|
||||
;;
|
||||
services)
|
||||
$F_service $F_action
|
||||
$(/system/sdcard/controlscripts/${F_service} $F_action) > /dev/null
|
||||
return
|
||||
;;
|
||||
getFiles)
|
||||
|
@@ -207,23 +207,13 @@ function start(branch,mode) {
|
||||
//Function control service (stop/start)
|
||||
function controlService(action,serviceName) {
|
||||
$.get("cgi-bin/ui_control.cgi", {cmd: "services",service: serviceName, action: action}, function(result){
|
||||
if (action == 'on') {
|
||||
$('#start_'+serviceName).removeAttr('onclick');
|
||||
$('#stop_'+serviceName).attr('onclick','controlService("off","'+serviceName+'")');
|
||||
$('#start_'+serviceName).removeClass('w3-text-green');
|
||||
$('#start_'+serviceName).addClass('w3-text-grey');
|
||||
$('#stop_'+serviceName).removeClass('w3-text-grey');
|
||||
$('#stop_'+serviceName).addClass('w3-text-red');
|
||||
$('#control_'+serviceName).removeAttr('onclick');
|
||||
if (action == 'start') {
|
||||
$('#control_'+serviceName).attr('onclick','controlService("stop","'+serviceName+'")')
|
||||
}
|
||||
else {
|
||||
$('#stop_'+serviceName).removeAttr('onclick');
|
||||
$('#start_'+serviceName).attr('onclick','controlService("on","'+serviceName+'")');
|
||||
$('#start_'+serviceName).removeClass('w3-text-grey');
|
||||
$('#start_'+serviceName).addClass('w3-text-green');
|
||||
$('#stop_'+serviceName).removeClass('w3-text-red');
|
||||
$('#stop_'+serviceName).addClass('w3-text-grey');
|
||||
$('#control_'+serviceName).attr('onclick','controlService("start","'+serviceName+'")')
|
||||
}
|
||||
$('#start').append("<tr><td>"+config_info[0]+"</td><td><i class='fa fa-play-circle w3-xxlarge "+color_start+"</i> <i class='fa fa-stop-circle w3-xxlarge "+color_stop+"</i></td><td><input class='w3-check' type='checkbox' "+checked+"></td></tr>");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -247,19 +237,15 @@ function getServices() {
|
||||
for (var i = 0; i < config_all.length-1; i++) {
|
||||
var config_info = config_all[i].split("#:#");
|
||||
// Select button color accrding status
|
||||
if (config_info[1] == "ON") {
|
||||
var color_start = "w3-text-grey' style='cursor:not-allowed' id='start_"+config_info[0]+"'>";
|
||||
var color_stop = "w3-text-red'onclick='controlService(\"off\",\""+config_info[0]+"\")' id='stop_"+config_info[0]+"'>";
|
||||
}
|
||||
else {
|
||||
var color_start = "w3-text-green' onclick='controlService(\"on\",\""+config_info[0]+"\")' id='start_"+config_info[0]+"'>";
|
||||
var color_stop = "w3-text-grey' style='cursor:not-allowed' id='stop_"+config_info[0]+"'>";
|
||||
}
|
||||
var checked = "onclick='autoStartService(\"true\",\""+config_info[0]+"\")')";
|
||||
var control_checked = "onclick='controlService(\"start\",\""+config_info[0]+"\")')";
|
||||
if (config_info[1] == "started")
|
||||
control_checked = "checked onclick='controlService(\"stop\",\""+config_info[0]+"\")')";
|
||||
var autostart_checked = "onclick='autoStartService(\"true\",\""+config_info[0]+"\")')";
|
||||
if(config_info[2] == "true")
|
||||
checked = "checked onclick='autoStartService(\"false\",\""+config_info[0]+"\")')";
|
||||
|
||||
$('#tabServices').append("<tr><td>"+config_info[0]+"</td><td><i class='fa fa-play-circle w3-xxlarge "+color_start+"</i> <i class='fa fa-stop-circle w3-xxlarge "+color_stop+"</i></td><td>Off <label class='switch'><input id='autoStart_"+config_info[0]+"' class='w3-check' type='checkbox' "+checked+"> <span class='slider round'></span></label> On</td></tr>");
|
||||
autostart_checked = "checked onclick='autoStartService(\"false\",\""+config_info[0]+"\")')";
|
||||
$('#tabServices').append("<tr><td>"+config_info[0]+"</td>\
|
||||
<td>Stop <label class='switch'><input id='control_"+config_info[0]+"' class='w3-check' type='checkbox' "+control_checked+"> <span class='slider round'></span></label> Start</td>\
|
||||
<td>Off <label class='switch'><input id='autoStart_"+config_info[0]+"' class='w3-check' type='checkbox' "+autostart_checked+"> <span class='slider round'></span></label> On</td></tr>");
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user