Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

477 lines
12 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var netwodkData = {
  3. edges: null,
  4. nodes: null
  5. };
  6. var selectedSite = 0;
  7. var cameraListStore = new Ext.data.JsonStore({
  8. root: 'nodes',
  9. totalProperty: 'totalCount',
  10. idProperty: 'id',
  11. remoteSort: true,
  12. fields: [{
  13. name: 'id',
  14. type: 'int'
  15. },{
  16. name: 'name',
  17. type: 'string'
  18. },{
  19. name: 'hardware',
  20. type: 'string'
  21. },{
  22. name: 'caps',
  23. type: 'int'
  24. },{
  25. name: 'ip',
  26. type: 'string'
  27. },{
  28. name: 'mac',
  29. type: 'string'
  30. }],
  31. proxy : new Ext.data.HttpProxy({
  32. method: 'POST',
  33. prettyUrls: false,
  34. url: '/lib/controller/listDiscoveredCameraSources.php',
  35. headers: {
  36. 'UID': '<?=$CUser->Data['id'];?>',
  37. 'SID': '<?=$Session;?>'
  38. }
  39. })
  40. });
  41. var SelectedCam = 0;
  42. var sourceListStore = new Ext.data.JsonStore({
  43. root: 'nodes',
  44. totalProperty: 'totalCount',
  45. idProperty: 'id',
  46. remoteSort: true,
  47. fields: [{
  48. name: 'id',
  49. type: 'int'
  50. },{
  51. name: 'name',
  52. type: 'string'
  53. },{
  54. name: 'encode',
  55. type: 'string'
  56. },{
  57. name: 'bitrate',
  58. type: 'int'
  59. },{
  60. name: 'size',
  61. type: 'string'
  62. }]
  63. });
  64. var cameraListSelModel = new Ext.grid.RowSelectionModel({
  65. singleSelect: true,
  66. listeners: {
  67. rowselect: function(sm, row, rec) {
  68. SelectedCam = rec.data.id;
  69. var CB = Ext.getCmp('con_to_src');
  70. CB.enable();
  71. }
  72. }
  73. });
  74. var SelectedSource = 0;
  75. var sourceListSelModel = new Ext.grid.RowSelectionModel({
  76. singleSelect: true,
  77. listeners: {
  78. rowselect: function(sm, row, rec) {
  79. SelectedSource = rec.data.id;
  80. //document.getElementById('pic_prev').src = '/lib/controller/getVideoFeed.php?UID=<?=$CUser->Data['id'];?>&SID<?=$Session;?>&AUX=200&FID='+SelectedSource;
  81. document.getElementById('pic_prev').src = '/lib/controller/getVideoFeed.php?UID=<?=$CUser->Data['id'];?>&SID<?=$Session;?>&FID='+SelectedSource;
  82. }
  83. }
  84. });
  85. function camCapRenderer(val){
  86. var p1, p2, p3;
  87. if( ( val & 1 ) == 1 ){
  88. p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
  89. } else {
  90. p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
  91. };
  92. if( ( val & 2 ) == 2 ){
  93. p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
  94. } else {
  95. p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
  96. };
  97. if( ( val & 4 ) == 4 ){
  98. p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
  99. } else {
  100. p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
  101. };
  102. return p1+p2+p3;
  103. };
  104. var cameraListColModel = new Ext.grid.ColumnModel({
  105. columns: [
  106. {header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  107. {header: "Type",width: 60, sortable: false, fixed: true, menuDisabled: true, renderer: camCapRenderer, dataIndex: 'caps' },
  108. {header: "IP Address", width: 120, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ip' },
  109. {header: "MAC", width: 120, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'mac' },
  110. {header: "Name", dataIndex: 'name' },
  111. {header: "HW", menuDisabled: true, dataIndex: 'hardware' }
  112. ],
  113. defaults: {
  114. sortable: true,
  115. menuDisabled: true,
  116. width: 100
  117. },
  118. listeners: {
  119. hiddenchange: function(cm, colIndex, hidden) {
  120. //saveConfig(colIndex, hidden);
  121. }
  122. }
  123. });
  124. var sourceListColModel = new Ext.grid.ColumnModel({
  125. columns: [
  126. {header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  127. {header: "Name", dataIndex: 'name' },
  128. {header: "Encoding",width: 120, sortable: false, fixed: true, menuDisabled: true, dataIndex: 'encode' },
  129. {header: "Frame", width: 120, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' },
  130. {header: "Bitrate", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'bitrate' }
  131. ],
  132. defaults: {
  133. sortable: false,
  134. menuDisabled: true,
  135. width: 100
  136. },
  137. listeners: {
  138. hiddenchange: function(cm, colIndex, hidden) {
  139. //saveConfig(colIndex, hidden);
  140. }
  141. }
  142. });
  143. function discoverOnvifSources(){
  144. Ext.Ajax.request({
  145. url: '/lib/controller/listAndDiscoverOnvifSources.php',
  146. params: {
  147. NID: 0,
  148. UID: <?=$UserID;?>,
  149. SID: '<?=$Session;?>'
  150. },
  151. success: function( response, opts ){
  152. cameraListStore.reload();
  153. },
  154. failure: function( response, opts ) {
  155. //Ext.fly('some_div').update('Fail!');
  156. }/*,
  157. callback: function(options,success,response){
  158. // use this if you need to perform your own success/failure checking
  159. }*/
  160. });
  161. };
  162. function preloadOnvifCredentials( SelectedCam ){
  163. Ext.Ajax.request({
  164. url: '/lib/controller/getOnvifCredentials.php',
  165. params: {
  166. CID: SelectedCam,
  167. UID: <?=$UserID;?>,
  168. SID: '<?=$Session;?>'
  169. },
  170. success: function( response, opts ){
  171. var data = Ext.decode( response.responseText );
  172. if( data.success ){
  173. Ext.getCmp('cam_login').setValue( data.login );
  174. Ext.getCmp('cam_password').setValue( data.password );
  175. Ext.getCmp('zigzag').disable();
  176. sourceListStore.loadData( data, false );
  177. document.getElementById('pic_prev').src = '/lib/controller/getVideoFeed.php?UID=<?=$CUser->Data['id'];?>&SID<?=$Session;?>&FID='+data.nodes[0].id;
  178. } else {
  179. Ext.getCmp('cam_login').setValue('');
  180. Ext.getCmp('cam_password').setValue('');
  181. Ext.getCmp('zigzag').enable();
  182. sourceListStore.removeAll();
  183. };
  184. },
  185. failure: function( response, opts ) {
  186. Ext.getCmp('cam_login').setValue('');
  187. Ext.getCmp('cam_password').setValue('');
  188. Ext.getCmp('zigzag').enable();
  189. sourceListStore.removeAll();
  190. }
  191. });
  192. };
  193. function discoverOnvifProfiles( CamID, camUser, camPasswd ){
  194. Ext.Ajax.request({
  195. url: '/lib/controller/listAndDiscoverOnvifProfiles.php',
  196. params: {
  197. NID: 0,
  198. UID: <?=$UserID;?>,
  199. SID: '<?=$Session;?>',
  200. CID: CamID,
  201. GUG: camUser,
  202. GOG: camPasswd
  203. },
  204. success: function( response, opts ){
  205. var data = Ext.decode( response.responseText );
  206. if( data['success'] == true ){
  207. sourceListStore.loadData( data, false );
  208. document.getElementById('pic_prev').src = '/lib/controller/getVideoFeed.php?UID=<?=$CUser->Data['id'];?>&SID<?=$Session;?>&FID='+data.nodes[0].id;
  209. } else {
  210. Ext.Msg.show({
  211. title:'Error Message',
  212. msg: data['error'],
  213. buttons: Ext.Msg.OK,//YESNOCANCEL,
  214. //fn: processResult,
  215. //animEl: 'elId',
  216. icon: Ext.MessageBox.ERROR //QUESTION
  217. });
  218. };
  219. Ext.getCmp('zigzag').getEl().unmask();
  220. },
  221. failure: function( response, opts ) {
  222. //Ext.fly('some_div').update('Fail!');
  223. }/*,
  224. callback: function(options,success,response){
  225. // use this if you need to perform your own success/failure checking
  226. }*/
  227. });
  228. };
  229. var connectOnvifDialog = null;
  230. var addDialog = null;
  231. var SelectedCamPTZ = false;
  232. function connectToSeleced(){
  233. if( SelectedCam > 0 ){
  234. if( connectOnvifDialog == null ){
  235. connectOnvifDialog = new Ext.Window({
  236. modal: true,
  237. title: 'Connect to IP Camera',
  238. width: 600,
  239. height: 500,
  240. layout: 'vbox',
  241. closeAction: 'hide',
  242. border: false,
  243. items:[{
  244. id: 'zigzag',
  245. layout: 'table',
  246. width: '100%',
  247. border: false,
  248. disabled: false,
  249. defaults: {
  250. // applied to each contained panel
  251. border: false,
  252. frame: false,
  253. bodyStyle: 'padding:10px'
  254. },
  255. layoutConfig: {
  256. tableAttrs: {
  257. style: {
  258. width: '100%'
  259. }
  260. },
  261. columns: 3
  262. },
  263. items: [{
  264. colspan: 3,
  265. html: '<p align="center">Please Provide Camera Access Credentials.</p>'
  266. },{
  267. html: '<p align="right">Login:</p>',
  268. width: 170
  269. },{
  270. id: 'cam_login',
  271. xtype: 'textfield',
  272. width: 200
  273. },{
  274. html: '&nbsp;',
  275. width: 170
  276. },{
  277. html: '<p align="right">Password:</p>'
  278. },{
  279. id: 'cam_password',
  280. xtype: 'textfield',
  281. width: 200,
  282. inputType: 'password'
  283. },{
  284. html: '&nbsp;'
  285. },{
  286. html: '&nbsp;'
  287. },{
  288. xtype: 'button',
  289. text: 'Connect to Camera',
  290. width: '100%',
  291. handler: function(){
  292. Ext.getCmp('zigzag').getEl().mask("Please wait...","x-mask-loading");
  293. var User = Ext.getCmp('cam_login').getValue();
  294. var Passwd = Ext.getCmp('cam_password').getValue();
  295. discoverOnvifProfiles( SelectedCam, User, Passwd );
  296. }
  297. },{
  298. html: '&nbsp;'
  299. }]
  300. },{
  301. xtype: 'grid',
  302. title: 'Streams',
  303. height: 124,
  304. disableSelection: true,
  305. ds: sourceListStore,
  306. cm: sourceListColModel,
  307. //sm: sourceListSelModel
  308. },{
  309. layout: 'table',
  310. width: '100%',
  311. border: false,
  312. disabled: false,
  313. defaults: {
  314. // applied to each contained panel
  315. border: false,
  316. frame: false,
  317. bodyStyle: 'text-align:right;padding-left:10px;padding-right:10px;'
  318. },
  319. layoutConfig: {
  320. tableAttrs: {
  321. style: {
  322. width: '100%'
  323. }
  324. },
  325. columns: 6
  326. },
  327. items: [{
  328. html: 'Lon:'
  329. },{
  330. id: 'cam_pos_lon',
  331. xtype: 'textfield',
  332. width: 70
  333. },{
  334. html: 'Lat:'
  335. },{
  336. id: 'cam_pos_lat',
  337. xtype: 'textfield',
  338. width: 70
  339. },{
  340. html: 'Alt:'
  341. },{
  342. id: 'cam_pos_alt',
  343. xtype: 'textfield',
  344. width: 70
  345. },{
  346. html: 'Roll:'
  347. },{
  348. id: 'cam_pos_roll',
  349. xtype: 'textfield',
  350. width: 70
  351. },{
  352. html: 'Pitch:'
  353. },{
  354. id: 'cam_pos_pitch',
  355. xtype: 'textfield',
  356. width: 70
  357. },{
  358. html: 'Yaw:'
  359. },{
  360. id: 'cam_pos_yaw',
  361. xtype: 'textfield',
  362. width: 70
  363. }]
  364. },{
  365. html: '<center><img width="200px" id="pic_prev" src="/style/img/cam_cap0.png"></center>',
  366. width: '100%'
  367. }],bbar:[{
  368. text: 'Cancel',
  369. handler: function(){
  370. //addDialog.close();
  371. //addDialog = null;
  372. connectOnvifDialog.hide();
  373. //connectOnvifDialog = null;
  374. }
  375. },'->',{
  376. text: 'Add Camera to Map',
  377. handler: function(){
  378. p_lon = Ext.getCmp('cam_pos_lon').getValue();
  379. p_lat = Ext.getCmp('cam_pos_lat').getValue();
  380. p_alt = Ext.getCmp('cam_pos_alt').getValue();
  381. p_pitch = Ext.getCmp('cam_pos_pitch').getValue();
  382. p_roll = Ext.getCmp('cam_pos_roll').getValue();
  383. p_yaw = Ext.getCmp('cam_pos_yaw').getValue();
  384. Ext.Ajax.request({
  385. url: '/lib/controller/AddCameraNode.php',
  386. params: {
  387. NID: <?=$SiteID;?>,
  388. UID: <?=$UserID;?>,
  389. SID: '<?=$Session;?>',
  390. CID: SelectedCam,
  391. LAT: p_lat,
  392. LON: p_lon,
  393. ALT: p_alt,
  394. PCH: p_pitch,
  395. ROL: p_roll,
  396. YAW: p_yaw,
  397. PTZ: ((SelectedCamPTZ)?1:0)
  398. },
  399. success: function( response, opts ){
  400. addDialog.close();
  401. addDialog = null;
  402. connectOnvifDialog.close();
  403. connectOnvifDialog = null;
  404. },
  405. failure: function( response, opts ) {
  406. //Ext.fly('some_div').update('Fail!');
  407. }/*,
  408. callback: function(options,success,response){
  409. // use this if you need to perform your own success/failure checking
  410. }*/
  411. });
  412. }
  413. }]
  414. });
  415. };
  416. connectOnvifDialog.show();
  417. preloadOnvifCredentials( SelectedCam );
  418. };
  419. };
  420. function addIpCam(){
  421. if( addDialog == null ){
  422. addDialog = new Ext.Window({
  423. modal: true,
  424. title: 'Add IP Camera',
  425. width: 800,
  426. height: 600,
  427. layout: 'fit',
  428. closeAction: 'hide',
  429. items:{
  430. xtype: 'grid',
  431. ds: cameraListStore,
  432. cm: cameraListColModel,
  433. sm: cameraListSelModel,
  434. //listeners:{
  435. // beforedestroy: function( t ){
  436. // addDialog = null;
  437. // return true;
  438. // }
  439. //},
  440. viewConfig: {
  441. forceFit: true
  442. },
  443. bbar: [{
  444. text: 'Cancel',
  445. handler: function(){//discoverOnvifSources
  446. addDialog.hide();
  447. }
  448. },'->',{
  449. id: 'con_to_src',
  450. text: 'Connect To Selected',
  451. disabled: ( SelectedCam == 0 ),
  452. handler: connectToSeleced
  453. }]
  454. }
  455. });
  456. };
  457. addDialog.show();
  458. cameraListStore.load({params:{start:0, limit:50}});
  459. };