Commit 85d3b17e authored by Tang's avatar Tang

Update mysensors device to new result format and handle it in ui too

parent d0f140eb
Pipeline #377 passed with stage
in 2 minutes and 31 seconds
......@@ -51,21 +51,9 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
if( res.result.error==0 )
{
notif.success('#sp');
}
else
{
//error occured
notif.error(res.result.msg);
}
}
else
{
notif.fatal('#nr', 0);
notif.success('#sp');
}
});
};
......@@ -79,14 +67,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
self.port(res.result.port);
}
else
{
notif.fatal('#nr', 0);
}
});
};
......@@ -101,14 +85,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
notif.success('#rc');
}
else
{
notif.fatal('#nr', 0);
}
});
}
};
......@@ -125,14 +105,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
notif.success('#rc');
}
else
{
notif.fatal('#nr', 0);
}
});
}
};
......@@ -146,14 +122,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
self.devices(res.result.devices);
}
else
{
notif.fatal('#nr', 0);
}
});
};
......@@ -169,24 +141,13 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
if( res.result.error==0 )
{
notif.success('#ds');
//refresh devices list
self.getDevices();
self.getCounters();
}
else
{
//error occured
notif.error(res.result.msg);
}
}
else
{
notif.fatal('#nr', 0);
notif.success('#ds');
//refresh devices list
self.getDevices();
self.getCounters();
}
});
}
......@@ -202,17 +163,13 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
var counters = [];
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
for( device in res.result.counters )
{
counters.push(res.result.counters[device]);
}
}
else
{
notif.fatal('#nr', 0);
}
self.counters(counters);
});
};
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment