Skip to content

Commit

Permalink
Admin, Add restart dmg device detection in node table
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico0084 committed Apr 1, 2016
1 parent 55618bc commit b217010
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
22 changes: 17 additions & 5 deletions admin/static/js/ozwlib.js
Expand Up @@ -713,7 +713,9 @@ function renderNodeStatusCol(data, type, full, meta) {
};
devContent += "</div>";
dmgDev = "<span id='nodedmgdevices"+ nodeData.NodeID + "' class='fa fa-check-circle icon-success extbtn'" +
" data-toggle='popover' title='Domogik device associated'" +
" data-toggle='popover' title='"+'<div><span class="badge pull-right">Click '+
'<i class="fa fa-check-circle icon-success"></i><br>lock/unlock<br>display popup</span>'+
"<h4>Domogik device associated</h4></div>'" +
" data-container='body' data-content='" + devContent + "'></span>";
};
if (Object.keys(nodeData.KnownDeviceTypes).length != 0) {
Expand Down Expand Up @@ -746,7 +748,9 @@ function renderNodeStatusCol(data, type, full, meta) {
devContent += "</div>";
if (find) {
knDev = "<span id='knowndevicetypes"+ nodeData.NodeID + "' class='fa fa-asterisk icon-warning extbtn'" +
" data-toggle='popover' title='<h4>No domogik device associate.<br>Create it with device-type :</h4>'" +
" data-toggle='popover' title='"+'<div><span class="badge pull-right">Click '+
'<i class="fa fa-asterisk icon-warning"></i><br>lock / unlock<br>display popup</span>'+
"<h4>No domogik device associate.<br>Create it with device-type :</h4></div>'" +
" data-container='body' data-content='" + devContent + "'></span>";
};
};
Expand All @@ -757,15 +761,23 @@ function renderNodeStatusCol(data, type, full, meta) {
};
devContent += "</div>";
newDev = "<span id='newdevicetypes"+ nodeData.NodeID + "' class='fa fa-plus-square icon-warning extbtn'" +
" data-toggle='popover' title='<h4>No domogik device type associate.<br>Send a developper request to create it with :</h4>'" +
" data-toggle='popover' title='"+'<div><span class="badge pull-right">Click '+
'<i class="fa fa-plus-square icon-warning"></i><br>lock / unlock<br>display popup</span>'+
"<h4>No domogik device type associate.<br>Send a developper request to create it with :</h4></div>'" +
" data-container='body' data-content='" + devContent + "'></span>";
};
if (devContent == "") {
devContent = "";
if (initState !='completed') {devContent = "Wait for complet initialisation...";
} else {devContent = "Try to launch detection again...";};
} else {devContent =
'<button class="btn btn-primary center-block" id="refrechDetectDev">'+ GetNodeRefId(nodeData.NetworkID, nodeData.NodeID)+'">' +
'<i class="fa fa-refresh" id="refrechDetectDev-ic'+ GetNodeRefId(nodeData.NetworkID, nodeData.NodeID)+'"></i>' +
'<span> Restart detection ...</span>' +
'</button>';};
dmgDev = "<span id='nodedmgdevices"+ nodeData.NodeID + "' class='fa fa-exclamation-circle icon-danger extbtn'" +
" data-toggle='popover' title='Neither domogik device type find !'" +
" data-toggle='popover' title='"+'<div><span class="badge pull-right">Click '+
'<i class="fa fa-exclamation-circle icon-danger"></i><br>lock / unlock<br>display popup</span>'+
"<h4>Neither domogik device type find !</h4></div>'" +
" data-content='" + devContent + "'></span>";
}
return str + "<span id='nodestate" + nodeData.NodeID + "' class='fa extbtn " + status +
Expand Down
28 changes: 28 additions & 0 deletions admin/templates/nodes.html
Expand Up @@ -173,6 +173,34 @@ <h3></h3>
console.log(err);
};
});
$("[id^='refrechDetectDev_']").not("[isHandled]" ).each(function(rowN, nData) {
EnableButtonAction(this, function(obj) {
var refId = obj.id.split("_");
var NetworkID = refId[1];
var NodeID = refId[2];
$("#refrechdevList-ic_"+refId[1]+"_"+refId[2]).removeClass().addClass("fa fa-refresh fa-spin");
sendRequest("ozwave.node.action", {"action": "RefrechDetectDev", "networkId": refId[1], "nodeId": refId[2]}, function(data, result) {
var nodeRefId = GetNodeRefId(data.content.NetworkID, data.content.NodeID);
$("#refrechdevList-ic"+data.content.NetworkID+"_"+data.content.NodeID).removeClass().addClass("fa fa-refresh");
$("#refrechdevList"+data.content.NetworkID+"_"+data.content.NodeID).popover('hide');
if (result == "error" || data.result == "error") {
new PNotify({
type: 'error',
title: 'Action fail',
text: 'Refreshing linked domogik device.',
delay: 6000
});
} else {
new PNotify({
type: 'success',
title: 'Action sended',
text: 'Wait for result of refreshing linked domogik device ...',
delay: 4000
});
};
});
});
});
$( "input[type='checkbox'][id^='batcheck']").not("[isHandled]" ).each(function(rowN, nData) {
$(this).attr("isHandled", true);
$(this).on('change', function (e) {
Expand Down
6 changes: 6 additions & 0 deletions lib/ozwave.py
Expand Up @@ -1761,6 +1761,12 @@ def _handleNodeRequest(self, request, data):
report['state'] = node.setBatteryCheck(True if data['state'] in [True, 'True', 'true'] else False)
report['error'] = ''
else : report = {'error': "Node {0}.{1} doesn't exist.".format(data['homeId'], data['nodeId'])}
elif data['action'] == 'RefrechDetectDev' :
node = self._getNode(data['homeId'], data['nodeId'])
if node :
threading.Thread(None, node._checkDmgDeviceLink, "th_refreshDevices", (), {"force": True}).start()
report['error'] = ''
else : report = {'error': "Node {0}.{1} doesn't exist.".format(data['homeId'], data['nodeId'])}
else :
report['error'] ='Request {0} unknown action, data : {1}'.format(request, data)
report['action'] = data['action']
Expand Down
6 changes: 3 additions & 3 deletions lib/ozwnode.py
Expand Up @@ -169,10 +169,10 @@ def setReady(self):
"""Node retrieve NodeQueriesComplete notification, intialisation process completed."""
self._ready = True
self.reportToUI({'type': 'init-process', 'usermsg' : 'Node is now ready', 'data': self.GetNodeStateNW()})
self._checkDmgDeviceLink()
self._checkDmgDeviceLink(True)

def _checkDmgDeviceLink(self):
if not self._knownDeviceTypes and not self._newDeviceTypes and self.isInitialized() :
def _checkDmgDeviceLink(self, force = False):
if (not self._knownDeviceTypes and not self._newDeviceTypes and self.isInitialized()) or force :
try :
self.liklyDmgDevices()
if self._dmgDevices == [] : self.refreshAllDmgDevice()
Expand Down

0 comments on commit b217010

Please sign in to comment.