Merge branch 'fix_montage_server_refs' into storageareas

This commit is contained in:
Isaac Connor 2016-05-13 11:11:27 -04:00
commit a61dade6df
3 changed files with 29 additions and 19 deletions

View File

@ -187,7 +187,7 @@ public function beforeFilter() {
// arm/disarm alarms
// expected format: http(s):/portal-api-url/monitors/alarm/id:M/command:C.json
// where M=monitorId
// where C=on|off
// where C=on|off|status
public function alarm()
{
$id = $this->request->params['named']['id'];
@ -195,19 +195,27 @@ public function beforeFilter() {
if (!$this->Monitor->exists($id)) {
throw new NotFoundException(__('Invalid monitor'));
}
if ( $cmd != 'on' && $cmd != 'off')
if ( $cmd != 'on' && $cmd != 'off' && $cmd != 'status')
{
throw new BadRequestException(__('Invalid command'));
}
if ($this->Session->Read('systemPermission') != 'Edit')
{
throw new UnauthorizedException(__('Insufficient privileges'));
return;
}
$zm_path_bin = Configure::read('ZM_PATH_BIN');
$q = ($cmd == 'on') ? '-a':'-c';
switch ($cmd)
{
case "on":
$q = '-a';
$verbose = "-v";
break;
case "off":
$q = "-c";
$verbose = "-v";
break;
case "status":
$verbose = ""; // zmu has a bug - gives incorrect verbose output in this case
$q = "-s";
break;
}
// form auth key based on auth credentials
$this->loadModel('Config');
@ -245,7 +253,7 @@ public function beforeFilter() {
}
}
$shellcmd = escapeshellcmd("$zm_path_bin/zmu -v -m$id $q $auth");
$shellcmd = escapeshellcmd("$zm_path_bin/zmu $verbose -m$id $q $auth");
$status = exec ($shellcmd);
$this->set(array(

View File

@ -1,10 +1,11 @@
var requestQueue = new Request.Queue( { concurrent: 2 } );
function Monitor( index, id, connKey )
function Monitor( index, monitorData )
{
this.index = index;
this.id = id;
this.connKey = connKey;
this.id = monitorData.id;
this.connKey = monitorData.connKey;
this.server_url = monitorData.server_url;
this.status = null;
this.alarmState = STATE_IDLE;
this.lastAlarmState = STATE_IDLE;
@ -110,7 +111,7 @@ function Monitor( index, id, connKey )
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
}
this.streamCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
}
@ -146,7 +147,7 @@ function initPage()
{
for ( var i = 0; i < monitorData.length; i++ )
{
monitors[i] = new Monitor( i, monitorData[i].id, monitorData[i].connKey );
monitors[i] = new Monitor( i, monitorData[i] );
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
monitors[i].start( delay );
}

View File

@ -35,7 +35,8 @@ monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>,
'connKey': <?php echo $monitor->connKey() ?>,
'width': <?php echo $monitor->Width() ?>,
'height':<?php echo $monitor->Height() ?>
'height':<?php echo $monitor->Height() ?>,
'server_url': '<?php echo $monitor->Server()->Url().$_SERVER['PHP_SELF'] ?>'
};
<?php
}