// var SelectedCam = 0; var SelectedSource = 0; var SelectedCamPTZ = false; var connectCamDialog = null; var addIpCamDialog = null; var addE2UDialog = null; var cameraListStore = new Ext.data.JsonStore({ root: 'nodes', totalProperty: 'totalCount', idProperty: 'id', remoteSort: true, fields: [{ name: 'id', type: 'int' },{ name: 'name', type: 'string' },{ name: 'hardware', type: 'string' },{ name: 'caps', type: 'int' },{ name: 'ip', type: 'string' },{ name: 'mac', type: 'string' }], proxy : new Ext.data.HttpProxy({ method: 'POST', prettyUrls: false, url: '/lib/controller/listDiscoveredCameraSources.php', headers: { 'UID': '=$CUser->Data['id'];?>', 'SID': '=$Session;?>' } }) }); var sourceListStore = new Ext.data.JsonStore({ root: 'nodes', totalProperty: 'totalCount', idProperty: 'id', remoteSort: true, fields: [{ name: 'id', type: 'int' },{ name: 'name', type: 'string' },{ name: 'encode', type: 'string' },{ name: 'bitrate', type: 'int' },{ name: 'size', type: 'string' }] }); var cameraListSelModel = new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { SelectedCam = rec.data.id; var CB = Ext.getCmp('con_to_src'); CB.enable(); } } }); var sourceListSelModel = new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { SelectedSource = rec.data.id; Ext.getCmp('pic_prev').update( '
';
} else {
p1 = '
';
};
if( ( val & 2 ) == 2 ){
p2 = '
';
} else {
p2 = '
';
};
if( ( val & 4 ) == 4 ){
p3 = '
';
} else {
p3 = '
';
};
return p1+p2+p3;
};
var cameraListColModel = new Ext.grid.ColumnModel({
columns: [
{header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
{header: "Type",width: 60, sortable: false, fixed: true, menuDisabled: true, renderer: camCapRenderer, dataIndex: 'caps' },
{header: "IP Address", width: 120, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ip' },
{header: "MAC", width: 120, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'mac' },
{header: "Name", dataIndex: 'name' },
{header: "HW", menuDisabled: true, dataIndex: 'hardware' }
],
defaults: {
sortable: true,
menuDisabled: true,
width: 100
},
listeners: {
hiddenchange: function(cm, colIndex, hidden) {
//saveConfig(colIndex, hidden);
}
}
});
var sourceListColModel = new Ext.grid.ColumnModel({
columns: [
{header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
{header: "Name", dataIndex: 'name' },
{header: "Encoding",width: 120, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'encode' },
{header: "Frame", width: 120, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' },
{header: "Bitrate", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'bitrate' }
],
defaults: {
sortable: false,
menuDisabled: true,
width: 100
},
listeners: {
hiddenchange: function(cm, colIndex, hidden) {
//saveConfig(colIndex, hidden);
}
}
});
function discoverOnvifSources(){
Ext.Ajax.request({
url: '/lib/controller/listAndDiscoverOnvifSources.php',
params: {
NID: 0,
UID: =$UserID;?>,
SID: '=$Session;?>'
},
success: function( response, opts ){
cameraListStore.reload();
},
failure: failureAJAXFunction
});
};
function loadCameraSettings( SC ){
Ext.Ajax.request({
url: '/lib/controller/getCameraSettings.php',
params: {
CID: SC,
UID: =$UserID;?>,
SID: '=$Session;?>'
},
success: function( response, opts ){
var data = Ext.decode( response.responseText );
if( data.success ){
} else {
};
},
failure: function( response, opts ) {
Ext.getCmp('cam_login').setValue('');
Ext.getCmp('cam_password').setValue('');
Ext.getCmp('cac_tab').enable();
Ext.getCmp('str_tab').disable();
Ext.getCmp('ptz_tab').disable();
Ext.getCmp('loc_tab').disable();
Ext.getCmp('coc_tabs').setActiveTab( 0 );
sourceListStore.removeAll();
}
});
};
function preloadOnvifCredentials( SC ){
Ext.Ajax.request({
url: '/lib/controller/getOnvifCredentials.php',
params: {
CID: SC,
UID: =$UserID;?>,
SID: '=$Session;?>'
},
success: function( response, opts ){
var data = Ext.decode( response.responseText );
if( data.success ){
Ext.getCmp('cam_login').setValue( data.login );
Ext.getCmp('cam_password').setValue( data.password );
Ext.getCmp('acm_btn').enable();
Ext.getCmp('cac_tab').disable();
Ext.getCmp('lens_tab').enable();
Ext.getCmp('str_tab').enable();
Ext.getCmp('ptz_tab').enable();
Ext.getCmp('loc_tab').enable();
Ext.getCmp('coc_tabs').setActiveTab( 1 );
sourceListStore.loadData( data, false );
//document.getElementById('pic_prev').src = '/lib/controller/getVideoFeed.php?UID==$CUser->Data['id'];?>&SID=$Session;?>&FID='+data.nodes[0].id;
} else {
Ext.getCmp('cam_login').setValue('');
Ext.getCmp('cam_password').setValue('');
Ext.getCmp('acm_btn').disable();
Ext.getCmp('cac_tab').enable();
Ext.getCmp('lens_tab').disable();
Ext.getCmp('str_tab').disable();
Ext.getCmp('ptz_tab').disable();
Ext.getCmp('loc_tab').disable();
Ext.getCmp('coc_tabs').setActiveTab( 0 );
sourceListStore.removeAll();
if( data.error != null ){
Ext.Msg.show({
title:'=$Labels->GetLabel('Error_Message');?>',
msg: data['error'],
buttons: Ext.Msg.OK,//YESNOCANCEL,
//fn: processResult,
//animEl: 'elId',
icon: Ext.MessageBox.ERROR //QUESTION
});
};
};
},
failure: function( response, opts ) {
Ext.getCmp('cam_login').setValue('');
Ext.getCmp('cam_password').setValue('');
Ext.getCmp('cac_tab').enable();
Ext.getCmp('lens_tab').disable();
Ext.getCmp('str_tab').disable();
Ext.getCmp('ptz_tab').disable();
Ext.getCmp('loc_tab').disable();
Ext.getCmp('coc_tabs').setActiveTab( 0 );
sourceListStore.removeAll();
}
});
};
function discoverOnvifProfiles( CamID, camUser, camPasswd ){
Ext.Ajax.request({
url: '/lib/controller/listAndDiscoverOnvifProfiles.php',
params: {
NID: 0,
UID: =$UserID;?>,
SID: '=$Session;?>',
CID: CamID,
GUG: camUser,
GOG: camPasswd
},
success: function( response, opts ){
var data = Ext.decode( response.responseText );
if( data['success'] == true ){
sourceListStore.loadData( data, false );
document.getElementById('pic_prev').src = '/lib/controller/getVideoFeed.php?UID==$CUser->Data['id'];?>&SID=$Session;?>&FID='+data.nodes[0].id;
} else {
Ext.Msg.show({
title:'=$Labels->GetLabel('Error_Message');?>',
msg: data['error'],
width: 640,
buttons: Ext.Msg.OK,//YESNOCANCEL,
//fn: processResult,602811123
//animEl: 'elId',
icon: Ext.MessageBox.ERROR //QUESTION
});
};
Ext.getCmp('cac_tab').getEl().unmask();
},
failure: failureAJAXFunction
});
};
var CamPropType = 0;
function showCamPropDialog(){
if( connectCamDialog == null ){
connectCamDialog = new Ext.Window({
modal: true,
title: (CamPropType)?'=$Labels->GetLabel('_CON_2_IP_CAM_');?>':'IP Camera Settings',
width: 600,
height: 500,
layout: 'vbox',
closeAction: 'hide',
border: false,
items:[{
id: 'coc_tabs',
xtype: 'tabpanel',
activeTab: 0,
items: [{
title: '=$Labels->GetLabel('_CAC_TAB_');?>',
id: 'cac_tab',
layout: 'table',
width: '100%',
border: false,
disabled: false,
defaults: {
border: false,
frame: false,
bodyStyle: 'padding:10px'
},
layoutConfig: {
columns: 3
},
items: [{
colspan: 3,
html: '=$Labels->GetLabel('_PROV_CAC_');?>
' },{ html: '=$Labels->GetLabel('_LOGIN_0_');?>
', width: 170 },{ id: 'cam_login', xtype: 'textfield', width: 200 },{ html: ' ' },{ html: '=$Labels->GetLabel('_PASSWORD_0_');?>
' },{ id: 'cam_password', xtype: 'textfield', inputType: 'password', width: 200 },{ html: ' ' },{ html: ' ' },{ xtype: 'button', text: 'Connect to Camera', width: '100%', handler: function(){ Ext.getCmp('cac_tab').getEl().mask("Please wait...","x-mask-loading"); var User = Ext.getCmp('cam_login').getValue(); var Passwd = Ext.getCmp('cam_password').getValue(); discoverOnvifProfiles( SelectedCam, User, Passwd ); } },{ html: ' ' }] },{ title: '=$Labels->GetLabel('_STREAMS_');?>', id: 'str_tab', disabled: true, items:[{ xtype: 'grid', title: '=$Labels->GetLabel('_STREAMS_');?>', height: 124, disableSelection: true, ds: sourceListStore, cm: sourceListColModel, sm: sourceListSelModel },{ height: 300, id: 'pic_prev', width: 600, html: '
X '+ c + '
'); }; } } },{ id: 'zoom_disp', html: ' ' }] }] },{ title: '=$Labels->GetLabel('_PTZ_TAB_');?>', id: 'ptz_tab', disabled: true, items:[{ layout: 'table', layoutConfig: { columns: 3 }, defaults: { frame: false, bodyStyle: 'padding:10px', border: false }, items:[{ width: 200, html: 'PTZ Control' },{ xtype: 'combo', fieldLabel: 'Ptz Control', lazyRender: true, id: 'ptz_proto', mode: 'local', store: new Ext.data.ArrayStore({ fields: ['type','type_txt'], data: [ [0,'No PTZ'], [1,'Sony VISCA'], [2,'Pelco-D'], [3,'OnVif'], [4,'PSIA'], [5,'GB/T28181'] ] }), valueField: 'type', displayField: 'type_txt', listeners:{ change: function( a, c, b ){ if( c > 0 ){ if( c != 3 ){ Ext.getCmp('uart_id').enable(); Ext.getCmp('prot_id').enable(); } else { Ext.getCmp('uart_id').disable(); Ext.getCmp('prot_id').disable(); }; Ext.getCmp('pan_mode').enable(); Ext.getCmp('tilt_mode').enable(); Ext.getCmp('pan_ang').enable(); Ext.getCmp('tilt_ang').enable(); } else { Ext.getCmp('uart_id').disable(); Ext.getCmp('prot_id').disable(); Ext.getCmp('pan_mode').disable(); Ext.getCmp('tilt_mode').disable(); Ext.getCmp('pan_ang').disable(); Ext.getCmp('tilt_ang').disable(); }; } } },{ html: ' ' },{ html: 'UART Port' },{ xtype: 'combo', fieldLabel: 'UART Port', lazyRender: true, id: 'uart_id', mode: 'local', disabled: true, store: new Ext.data.ArrayStore({ fields: ['uart','uart_txt'], data: [ Query( $QS ); $P = array(); foreach( $R as $RR ){ $P[] = "[{$RR['aux_id']}, '{$RR['name']}']"; }; echo implode( ",", $P ); ?> ] }), valueField: 'uart', displayField: 'uart_txt' },{ html: ' ' },{ html: 'Camera ID' },{ xtype: 'numberfield', id: 'prot_id', width: '95%', disabled: true, minValue: 0, maxValue: 255 },{ html: ' ' },{ html: 'Pan Model' },{ xtype: 'combo', fieldLabel: 'Pan Model', lazyRender: true, id: 'pan_mode', disabled: true, mode: 'local', store: new Ext.data.ArrayStore({ fields: ['pm','pm_txt'], data: [ [0,'Regular'], [1,'Reversed'] ] }), valueField: 'pm', displayField: 'pm_txt' },{ html: ' ' },{ html: 'Tottal Pan Angles' },{ xtype: 'numberfield', id: 'pan_ang', width: '95%', disabled: true, minValue: 0, maxValue: 360 },{ html: ' ' },{ html: 'Tilt Model' },{ xtype: 'combo', fieldLabel: 'Tilt Model', lazyRender: true, id: 'tilt_mode', disabled: true, mode: 'local', store: new Ext.data.ArrayStore({ fields: ['tm','tm_txt'], data: [ [0,'Regular'], [1,'Reversed'], [2,'Shifted 90°'], [3,'Rev-Shifted 90°'] ] }), valueField: 'tm', displayField: 'tm_txt' },{ html: ' ' },{ html: 'Tottal Tilt Angles' },{ xtype: 'numberfield', id: 'tilt_ang', width: '95%', disabled: true, minValue: 0, maxValue: 180 },{ html: ' ' }] }] },{ title: '=$Labels->GetLabel('_ADV_TAB_');?>', disabled: true, layout: 'table', id: 'loc_tab', border: false, defaults: { // applied to each contained panel border: false, frame: false, bodyStyle: 'text-align:right;padding-left:10px;padding-right:10px;' }, layoutConfig: { columns: 3 }, items: [{ html: '=$Labels->GetLabel('_CAM_MAP_NAME_');?>:' },{ id: 'cam_label', xtype: 'textfield', width: 200 },{ html: ' ' }] }] }], bbar:[{ text: '=$Labels->GetLabel('_CANCEL_');?>', handler: function(){ //addDialog.close(); //addDialog = null; connectCamDialog.hide(); //connectOnvifDialog = null; } },'->',{ text: 'Add Camera to Map', id: 'acm_btn', disabled: true, handler: function(){ var CLAB = Ext.getCmp('cam_label').getValue(); var CPTZP = Ext.getCmp('ptz_proto').getValue(); var CPTZU = Ext.getCmp('uart_id').getValue(); var CPTZID = Ext.getCmp('prot_id').getValue(); var CPANM = Ext.getCmp('pan_mode').getValue(); var CTILTM = Ext.getCmp('tilt_mode').getValue(); var CPANANG = Ext.getCmp('pan_ang').getValue(); var CTILTANG = Ext.getCmp('tilt_ang').getValue(); var CIMAGER = Ext.getCmp('sens_size').getValue(); var CMINF = Ext.getCmp('min_foc').getValue(); var CMAXF = Ext.getCmp('max_foc').getValue(); if( CLAB != '' ){ Ext.Ajax.request({ url: '/lib/controller/AddCameraNode.php', params: { NID: =$SiteID;?>, UID: =$UserID;?>, SID: '=$Session;?>', CID: SelectedCam, LAB: CLAB, UART: CPTZU, PROTOID: CPTZID, PANMODE: CPANM, TILTMODE: CTILTM, PANANG: CPANANG, TILTANG: CTILTANG, IMSIZE: CIMAGER, FMIN: CMINF, FMAX: CMAXF, PTZ: CPTZP }, success: function( response, opts ){ addIpCamDialog.close(); addIpCamDialog = null; connectCamDialog.close(); connectCamDialog = null; }, failure: failureAJAXFunction }); } else { Ext.Msg.show({ title:'Data Error!', msg: 'Please Provide Camera Name!', buttons: Ext.Msg.OK, icon: Ext.MessageBox.INFO }); }; } }] }); } else { }; connectCamDialog.show(); }; function connectToSeleced(){ CamPropType = 1; if( SelectedCam > 0 ){ showCamPropDialog(); preloadOnvifCredentials( SelectedCam ); //loadCameraSettings( SelectedCam ); }; }; function addIpCam(){ if( addIpCamDialog == null ){ addIpCamDialog = new Ext.Window({ modal: true, title: '=$Labels->GetLabel('_DET_IP_CAMERA_LST_');?>', width: 800, height: 600, layout: 'fit', closeAction: 'hide', items:{ xtype: 'grid', ds: cameraListStore, cm: cameraListColModel, sm: cameraListSelModel, viewConfig: { forceFit: true }, bbar: [{ text: '=$Labels->GetLabel('_CANCEL_');?>', handler: function(){ addIpCamDialog.hide(); } },'->',{ id: 'con_to_src', text: '=$Labels->GetLabel('_CONNECT_2_SEL_');?>', disabled: ( SelectedCam == 0 ), handler: connectToSeleced }] } }); }; addIpCamDialog.show(); cameraListStore.load({params:{start:0, limit:50}}); }; function addEthernet2Uart(){ if( addE2UDialog == null ){ addE2UDialog = new Ext.Window({ modal: true, title: 'Add Ethernet To Serial Adapter', width: 400, height: 300, layout: 'fit', closeAction: 'hide', items:[{ xtype: 'form', labelWidth: 120, // label settings here cascade unless overridden frame: false, bodyStyle:'padding:5px 5px 0', defaultType: 'textfield', items:[{ xtype: 'combo', fieldLabel: 'Speed', id: 'ued_speed', lazyRender:true, mode: 'local', store: new Ext.data.ArrayStore({ fields: ['speed'], data: [[19200], [115200]] }), valueField: 'speed', displayField: 'speed' },{ xtype: 'combo', fieldLabel: 'Bits', id: 'ued_bit', lazyRender:true, mode: 'local', store: new Ext.data.ArrayStore({ fields: ['bits'], data: [[5],[6],[7],[8],[9]] }), valueField: 'bits', displayField: 'bits' },{ xtype: 'combo', fieldLabel: 'Stop Bit', lazyRender:true, id: 'ued_stops', mode: 'local', store: new Ext.data.ArrayStore({ fields: ['stops'], data: [[1],[1.5],[2]] }), valueField: 'stops', displayField: 'stops' },{ xtype: 'combo', fieldLabel: 'Parity', lazyRender:true, id: 'ued_parity', mode: 'local', store: new Ext.data.ArrayStore({ fields: ['parity'], data: [['Odd'], ['Even'],['None']] }), valueField: 'parity', displayField: 'parity' },{ xtype: 'combo', fieldLabel: 'Working Mode', lazyRender: true, id: 'ued_mode', mode: 'local', store: new Ext.data.ArrayStore({ fields: ['mode','mode_txt'], data: [[0,'UDP Client'], [1,'TCP Client'], [2,'UDP Server'], [3,'TCP Server']] }), valueField: 'mode', displayField: 'mode_txt' },{ fieldLabel: 'IP Address', id: 'ued_ip' },{ fieldLabel: 'IP Port', id: 'ued_port' }], bbar: [{ text: 'Cancel', handler: function(){//discoverOnvifSources addE2UDialog.hide(); } },'->',{ id: 'con_to_src', text: 'Add Adapter to Site', disabled: false, handler: function(){ var SPD = Ext.getCmp('ued_speed').getValue(); var BIT = Ext.getCmp('ued_bit').getValue(); var STP = Ext.getCmp('ued_stops').getValue(); var PAR = Ext.getCmp('ued_parity').getValue(); var MOD = Ext.getCmp('ued_mode').getValue(); var IP = Ext.getCmp('ued_ip').getValue(); var PORT= Ext.getCmp('ued_port').getValue(); Ext.Ajax.request({ url: '/lib/controller/addNetworkNode.php', params: { NID: =$SiteID;?>, TYPE: 20, UART_SPEED: SPD, UART_BITS: BIT, UART_STOP: STP, UART_PAR: PAR, UART_MODE: MOD, UART_IP: IP, UART_PORT: PORT, UID: =$UserID;?>, SID: '=$Session;?>' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.sucess == false ){ Ext.Msg.show({ title:'Request Failure!', msg: data.error, buttons: Ext.Msg.OK, icon: Ext.MessageBox.INFO }); } else { loadSystemEditor(); }; addE2UDialog.hide(); }, failure: function( response, opts ) { failureAJAXFunction( response, opts ); addE2UDialog.hide(); } }); } }] }] }); }; addE2UDialog.show(); };