Skip to content

Commit

Permalink
Merge pull request #51 from moeiscool/dev
Browse files Browse the repository at this point in the history
get started monitors json list
  • Loading branch information
moeiscool authored Jan 22, 2017
2 parents 190086b + de13027 commit fa0a778
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@ app.get(['/:auth/embed/:ke/:id','/:auth/embed/:ke/:id/:addon'], function (req,re
});
// Get monitors json
app.get(['/:auth/monitor/:ke','/:auth/monitor/:ke/:id'], function (req,res){
req.ret={ok:false};
res.setHeader('Content-Type', 'application/json');
req.fn=function(){
req.sql='SELECT * FROM Monitors WHERE ke=?';req.ar=[req.params.ke];
if(req.params.id){req.sql+=' and mid=?';req.ar.push(req.params.id)}
Expand All @@ -1097,6 +1099,29 @@ app.get(['/:auth/monitor/:ke','/:auth/monitor/:ke/:id'], function (req,res){
}
s.auth(req.params,req.fn,res,req);
});
// Get monitors online json
app.get(['/:auth/smonitor/:ke','/:auth/smonitor/:ke/:id'], function (req,res){
req.ret={ok:false};
res.setHeader('Content-Type', 'application/json');
req.fn=function(){
req.sql='SELECT * FROM Monitors WHERE ke=?';req.ar=[req.params.ke];
if(req.params.id){req.sql+=' and mid=?';req.ar.push(req.params.id)}
sql.query(req.sql,req.ar,function(err,r){
if(r&&r[0]){
req.ar=[];
r.forEach(function(v){
if(s.group[req.params.ke]&&s.group[req.params.ke].mon[v.mid]&&s.group[req.params.ke].mon[v.mid].started===1){
req.ar.push(v)
}
})
}else{
req.ar=[];
}
res.send(JSON.stringify(req.ar, null, 3));
})
}
s.auth(req.params,req.fn,res,req);
});
// Control monitor mode via HTTP
app.get(['/:auth/monitor/:ke/:mid/:f','/:auth/monitor/:ke/:mid/:f/:ff','/:auth/monitor/:ke/:mid/:f/:ff/:fff'], function (req,res){
req.ret={ok:false};
Expand Down

0 comments on commit fa0a778

Please sign in to comment.