Skip to content

Commit

Permalink
Merge pull request #102 from weberbox/dev_dash
Browse files Browse the repository at this point in the history
Bugfix dash.js - Add Get Remote Branches to SocketIO
  • Loading branch information
nebhead authored May 21, 2022
2 parents d4a9473 + f0e8dfe commit e5c4cbd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
26 changes: 17 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,7 @@ def get_app_data(action=None, type=None):
'logs_result' : logs_result,
'error_message' : error_msg }
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid action'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid action'}}

@socketio.on('post_app_data')
def post_app_data(action=None, type=None, json_data=None):
Expand Down Expand Up @@ -1961,7 +1961,7 @@ def post_app_data(action=None, type=None, json_data=None):
else:
return {'response': {'result':'error', 'message':'Error: Key not found in control'}}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid type'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid type'}}

elif action == 'admin_action':
if type == 'clear_history':
Expand Down Expand Up @@ -2005,7 +2005,7 @@ def post_app_data(action=None, type=None, json_data=None):
restart_scripts()
return {'response': {'result':'success'}}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid type'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid type'}}

elif action == 'units_action':
if type == 'f_units' and settings['globals']['units'] == 'C':
Expand Down Expand Up @@ -2150,7 +2150,7 @@ def post_app_data(action=None, type=None, json_data=None):
else:
return {'response': {'result':'error', 'message':'Error: Function not specified'}}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid type'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid type'}}

elif action == 'timer_action':
control = ReadControl()
Expand All @@ -2169,7 +2169,7 @@ def post_app_data(action=None, type=None, json_data=None):
WriteControl(control)
return {'response': {'result':'success'}}
else:
return {'response': {'result':'error', 'message':'Error: Start time not specifed'}}
return {'response': {'result':'error', 'message':'Error: Start time not specified'}}
else:
now = time.time()
control['timer']['end'] = (control['timer']['end'] - control['timer']['paused']) + now
Expand All @@ -2195,9 +2195,9 @@ def post_app_data(action=None, type=None, json_data=None):
WriteControl(control)
return {'response': {'result':'success'}}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid type'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid type'}}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid action'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid action'}}

@socketio.on('post_updater_data')
def updater_action(type='none', branch=None):
Expand Down Expand Up @@ -2237,8 +2237,16 @@ def updater_action(type='none', branch=None):
return {'response': {'result':'error', 'message':'Error: ' + output }}
else:
return {'response': {'result':'error', 'message':'Error: Branch not specified in request'}}

elif type == 'update_remote_branches':
if isRaspberryPi():
os.system('python3 %s %s &' % ('updater.py', '-r')) # Update branches from remote
time.sleep(2)
return {'response': {'result':'success', 'message': 'Branches successfully updated from remote' }}
else:
return {'response': {'result':'error', 'message': 'Could not update branches from remote' }}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid action'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid action'}}

@socketio.on('post_restore_data')
def post_restore_data(type='none', filename='none', json_data=None):
Expand All @@ -2264,7 +2272,7 @@ def post_restore_data(type='none', filename='none', json_data=None):
else:
return {'response': {'result':'error', 'message':'Error: Filename or JSON data not supplied'}}
else:
return {'response': {'result':'error', 'message':'Error: Recieved request without valid type'}}
return {'response': {'result':'error', 'message':'Error: Received request without valid type'}}

'''
Main Program Start
Expand Down
27 changes: 18 additions & 9 deletions static/js/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,19 @@ $(document).ready(function(){
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
console.log('Notification for Grill Requested. ');
console.log('Notification for Grill Requested.');
}
});
});

$("#grill_notify_disable").click(function(){
var postdata = {
var postdata = {
'setpoints' : {
'grill' : 0
},
'notify_req' : {
'grill' : false
},
}
};
req = $.ajax({
url : '/api/control',
Expand All @@ -554,7 +557,7 @@ $(document).ready(function(){
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
console.log('Notification for Probe 1 Cancelled.');
console.log('Notification for Grill Cancelled.');
}
});
});
Expand Down Expand Up @@ -588,13 +591,16 @@ $(document).ready(function(){
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
console.log('Notification for Probe 1 Requested. Shutdown = ' + shutdown);
console.log('Notification for Probe 1 Requested. Shutdown = ' + shutdown + ' Keep Warm = ' + keepWarm);
}
});
});

$("#p1_notify_disable").click(function(){
var postdata = {
var postdata = {
'setpoints' : {
'probe1' : 0
},
'notify_req' : {
'probe1' : false
},
Expand Down Expand Up @@ -644,13 +650,16 @@ $(document).ready(function(){
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
console.log('Notification for Probe 1 Requested. Shutdown = ' + shutdown);
console.log('Notification for Probe 2 Requested. Shutdown = ' + shutdown + ' Keep Warm = ' + keepWarm);
}
});
});

$("#p2_notify_disable").click(function(){
var postdata = {
var postdata = {
'setpoints' : {
'probe2' : 0
},
'notify_req' : {
'probe2' : false
},
Expand All @@ -666,7 +675,7 @@ $(document).ready(function(){
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
console.log('Notification for Probe 1 Cancelled.');
console.log('Notification for Probe 2 Cancelled.');
}
});
});
Expand Down

0 comments on commit e5c4cbd

Please sign in to comment.