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.

673 lines
16 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var now = moment.utc().minutes(0).seconds(0).milliseconds(0);
  3. //alert( now );
  4. var netwodkData = {
  5. edges: null,
  6. nodes: null
  7. };
  8. var networkObj = null;
  9. var selectedSite = 0;
  10. var selectedConnection = null;
  11. var selectedNode = null;
  12. var timelineObj = null;
  13. var tlGroups = new vis.DataSet();
  14. var tlItems = new vis.DataSet();
  15. var tlOptions = {
  16. groupOrder: 'content', // groupOrder can be a property name or a sorting function
  17. stack: true,
  18. showCurrentTime: true,
  19. verticalScroll: true,
  20. zoomKey: 'ctrlKey',
  21. minHeight: 300,
  22. maxHeight: 300
  23. };
  24. var tlLoadLocker = false;
  25. var tlLastTS = 0;
  26. var tlInterval = null;
  27. function loadTimeLineGroups( NID ){
  28. Ext.Ajax.request({
  29. url: '/lib/controller/getTimeLineGroups.php',
  30. params: {
  31. NID: NID,
  32. UID: <?=$UserID;?>,
  33. SID: '<?=$Session;?>'
  34. },
  35. success: function( response, opts ){
  36. // If the response is JSON, you have to decode it
  37. var data = Ext.decode(response.responseText);
  38. //for(var i = 0; i < data.length; i++) {
  39. //tlGroups.add(data[i]);
  40. //};
  41. tlGroups.update( data );
  42. loadTimeLineItems( selectedSite );
  43. tlInterval = window.setInterval( loadTimeLineItems, 100, selectedSite );
  44. },
  45. failure: function( response, opts ) {
  46. //Ext.fly('some_div').update('Fail!');
  47. }/*,
  48. callback: function(options,success,response){
  49. // use this if you need to perform your own success/failure checking
  50. }*/
  51. });
  52. };
  53. function loadTimeLineItems( NID ){
  54. if( tlLoadLocker ) return;
  55. tlLoadLocker = true;
  56. Ext.Ajax.request({
  57. url: '/lib/controller/getTimeLineEvents.php',
  58. params: {
  59. NID: NID,
  60. UID: <?=$UserID;?>,
  61. SID: '<?=$Session;?>',
  62. LTS: tlLastTS
  63. },
  64. success: function( response, opts ){
  65. // If the response is JSON, you have to decode it
  66. var data = Ext.decode(response.responseText);
  67. var i = 0;
  68. for(; i < data.length; i++ ){
  69. tlLastTS = data[i].start;
  70. data[i].start = moment.utc( ''+data[i].start, 'X' );
  71. tlItems.add( data[i] );
  72. };
  73. if( timelineObj == null ){
  74. //alert('Now');
  75. var container = document.getElementById('timeline');
  76. timelineObj = new vis.Timeline( container );
  77. timelineObj.setOptions( tlOptions );
  78. timelineObj.setGroups( tlGroups );
  79. timelineObj.setItems( tlItems );
  80. } else {
  81. timelineObj.redraw();
  82. };
  83. tlLoadLocker = false;
  84. },
  85. failure: function( response, opts ) {
  86. //Ext.fly('some_div').update('Fail!');
  87. tlLoadLocker = false;
  88. }/*,
  89. callback: function(options,success,response){
  90. // use this if you need to perform your own success/failure checking
  91. }*/
  92. });
  93. };
  94. function reloadNetworkData( NID ){
  95. Ext.Ajax.request({
  96. url: '/lib/controller/getNetwork.php',
  97. params: {
  98. NID: NID,
  99. UID: <?=$UserID;?>,
  100. SID: '<?=$Session;?>',
  101. },
  102. success: function( response, opts ){
  103. // If the response is JSON, you have to decode it
  104. var data = Ext.decode(response.responseText);
  105. netwodkData.nodes = new vis.DataSet( data.nodes );
  106. netwodkData.edges = new vis.DataSet( data.edges );
  107. networkObj.setData( netwodkData );
  108. networkObj.redraw();
  109. },
  110. failure: function( response, opts ) {
  111. //Ext.fly('some_div').update('Fail!');
  112. }/*,
  113. callback: function(options,success,response){
  114. // use this if you need to perform your own success/failure checking
  115. }*/
  116. });
  117. };
  118. function createNode( NID, STYPE ){
  119. Ext.Ajax.request({
  120. url: '/lib/controller/addNetworkNode.php',
  121. params: {
  122. NID: NID,
  123. UID: <?=$UserID;?>,
  124. SID: '<?=$Session;?>',
  125. TYPE: STYPE
  126. },
  127. success: function( response, opts ){
  128. // If the response is JSON, you have to decode it
  129. reloadNetworkData( NID );
  130. },
  131. failure: function( response, opts ) {
  132. //Ext.fly('some_div').update('Fail!');
  133. }/*,
  134. callback: function(options,success,response){
  135. // use this if you need to perform your own success/failure checking
  136. }*/
  137. });
  138. };
  139. var currentConnectonMode = 0;
  140. function createConnection( NID, SID, EID, CTY ){
  141. Ext.Ajax.request({
  142. url: '/lib/controller/addConnection.php',
  143. params: {
  144. NID: NID,
  145. SNID: SID,
  146. ENID: EID,
  147. UID: <?=$UserID;?>,
  148. SID: '<?=$Session;?>',
  149. TYPE: CTY
  150. },
  151. success: function( response, opts ){
  152. var data = Ext.decode(response.responseText);
  153. if( data.status ){
  154. //reloadNetworkData( NID );
  155. netwodkData.edges.add( data.edge );
  156. } else {
  157. alert( data.message );
  158. };
  159. },
  160. failure: function( response, opts ) {
  161. //Ext.fly('some_div').update('Fail!');
  162. }/*,
  163. callback: function(options,success,response){
  164. // use this if you need to perform your own success/failure checking
  165. }*/
  166. });
  167. };
  168. var networkOpts = {
  169. interaction:{
  170. hover: true
  171. },
  172. manipulation: {
  173. enabled: false,
  174. addNode: function (data, callback) {
  175. // filling in the popup DOM elements
  176. console.log('add', data);
  177. },
  178. editNode: function (data, callback) {
  179. // filling in the popup DOM elements
  180. console.log('edit', data);
  181. },
  182. addEdge: function (data, callback) {
  183. console.log('add edge', data);
  184. if (data.from == data.to) {
  185. var r = confirm("Do you want to connect the node to itself?");
  186. if (r === true) {
  187. //callback(data);
  188. createConnection( selectedSite, data.from, data.to, currentConnectonMode );
  189. };
  190. } else {
  191. //callback(data);
  192. createConnection( selectedSite, data.from, data.to, currentConnectonMode );
  193. };
  194. networkObj.disableEditMode();
  195. }
  196. }
  197. };
  198. function startCreateConnection( CType ){
  199. if( networkObj!= null ){
  200. currentConnectonMode = CType;
  201. networkObj.addEdgeMode();
  202. };
  203. };
  204. function finishCreateConnection(){
  205. if( networkObj!= null ){
  206. };
  207. //connectionAddMode = false;
  208. };
  209. function loadDashBoard(){
  210. var tPanel = Ext.getCmp('main_content');
  211. if( tlInterval!= null ){
  212. window.clearInterval( tlInterval );
  213. tlInterval = null;
  214. timelineObj = null;
  215. };
  216. tPanel.remove(0);
  217. tPanel.add({
  218. html: 'DashBoard Content'
  219. });
  220. tPanel.doLayout();
  221. };
  222. function loadTimeLine(){
  223. var tPanel = Ext.getCmp('main_content');
  224. tPanel.remove(0);
  225. tPanel.add({
  226. title: 'Events Monitoring',
  227. frame: false,
  228. border: false,
  229. //layout: 'fit',
  230. //height: 700,
  231. //flex: 1,
  232. //border: true,
  233. items:[{
  234. title: 'TimeLine',
  235. height: 350,
  236. flex: 1,
  237. frame: true,
  238. border: false,
  239. layout: 'fit',
  240. items:{
  241. style: 'background: ivory;',
  242. html: '<div id="timeline"></div>'
  243. }
  244. },{
  245. title: 'Event Information',
  246. frame: true,
  247. html: '<p align="center">Select an Event from TimeLine to See Information'
  248. }]
  249. });
  250. tPanel.doLayout();
  251. loadTimeLineGroups( selectedSite );
  252. };
  253. function loadOnlineMonitoring(devID){
  254. var tPanel = Ext.getCmp('main_content');
  255. if( tlInterval!= null ){
  256. window.clearInterval( tlInterval );
  257. tlInterval = null;
  258. timelineObj = null;
  259. };
  260. tPanel.remove(0);
  261. tPanel.add({
  262. html: 'Device Monitoring '+devID
  263. });
  264. tPanel.doLayout();
  265. };
  266. function loadNodeProperties( NodeID ){
  267. //alert( 'Node: ' + NodeID );
  268. Ext.Ajax.request({
  269. url: '/lib/controller/getNetworkNodeProps.php',
  270. params: {
  271. NID: selectedSite,
  272. UID: <?=$UserID;?>,
  273. SID: '<?=$Session;?>',
  274. NODE: NodeID
  275. },
  276. success: function( response, opts ){
  277. // If the response is JSON, you have to decode it
  278. var data = Ext.decode(response.responseText);
  279. var tPanel = Ext.getCmp('prop_content');
  280. tPanel.remove(0);
  281. tPanel.add( data );
  282. tPanel.doLayout();
  283. },
  284. failure: function( response, opts ) {
  285. //Ext.fly('some_div').update('Fail!');
  286. }/*,
  287. callback: function(options,success,response){
  288. // use this if you need to perform your own success/failure checking
  289. }*/
  290. });
  291. };
  292. function loadLinkProperties( EdgeID, From, To ){
  293. alert( 'Edge: ' + EdgeID );
  294. };
  295. function loadSystemEditor(){
  296. var tPanel = Ext.getCmp('main_content');
  297. if( tlInterval!= null ){
  298. window.clearInterval( tlInterval );
  299. tlInterval = null;
  300. timelineObj = null;
  301. };
  302. tPanel.remove(0);
  303. tPanel.add({
  304. title: 'System Map',
  305. // id: 'sys_map',
  306. frame: false,
  307. border: false,
  308. //layout: 'column', // Specifies that the items will now be arranged in columns
  309. layout:'hbox',
  310. layoutConfig: {
  311. align : 'stretch',
  312. pack : 'start',
  313. //padding:'5',
  314. //align:'middle'
  315. },
  316. items: [{
  317. //columnWidth: 0.60,
  318. layout: 'fit',
  319. //height: 700,
  320. flex: 1,
  321. border: true,
  322. items:{
  323. id: 'sys_map'
  324. }
  325. },{
  326. title: 'Properties',
  327. flex: 1,
  328. width: 210,
  329. layout: 'fit',
  330. frame: true,
  331. id: 'prop_content',
  332. // border: true
  333. items:{
  334. html: 'Select Item From Map'
  335. }
  336. }],
  337. tbar: [{
  338. xtype: 'splitbutton',
  339. text: 'Add Laser Sensor',
  340. split: true,
  341. enableToggle : undefined,
  342. menu : {
  343. items: [{
  344. text:'ALS',
  345. handler: function(){
  346. createNode( 0, 1 );
  347. }
  348. },{
  349. text:'LFS',
  350. handler: function(){
  351. createNode( 0, 2 );
  352. }
  353. },{
  354. text:'PLS-200',
  355. handler: function(){
  356. createNode( 0, 3 );
  357. }
  358. },{
  359. text:'PLS-360',
  360. handler: function(){
  361. createNode( 0, 4 );
  362. }
  363. },{
  364. text:'3DLIDAR',
  365. handler: function(){
  366. createNode( 0, 5 );
  367. }
  368. }]
  369. }
  370. },{
  371. xtype: 'splitbutton',
  372. text: 'Add Additional Equipment',
  373. split: true,
  374. enableToggle : undefined,
  375. menu : {
  376. items: [{
  377. text:'Static Analog Camera'
  378. },{
  379. text:'PTZ Analog Camera'
  380. },{
  381. text:'Static IP Camera'
  382. },{
  383. text:'PTZ IP Camera'
  384. },{
  385. text:'DVR/Video Server/Streamer'
  386. },{
  387. text:'Network Video Recorder'
  388. },{
  389. text:'Ethernet to UART transeiver'
  390. },{
  391. text:'DC to Ethernet (ADAM)'
  392. }]
  393. }
  394. },{
  395. xtype: 'splitbutton',
  396. text: 'Add Connection',
  397. split: true,
  398. enableToggle : undefined,
  399. menu : {
  400. items: [{
  401. text:'COM_TYPE_RS485_CTRL',
  402. handler: function(){
  403. startCreateConnection(1);
  404. }
  405. },{
  406. text:'COM_TYPE_RS422_CTRL',
  407. handler: function(){
  408. startCreateConnection(2);
  409. }
  410. },{
  411. text:'COM_TYPE_RS232_CTRL',
  412. handler: function(){
  413. startCreateConnection(3);
  414. }
  415. },{
  416. text:'COM_TYPE_TCP_CTRL',
  417. handler: function(){
  418. startCreateConnection(4);
  419. }
  420. },{
  421. text:'COM_TYPE_RS485_PTZ',
  422. handler: function(){
  423. startCreateConnection(5);
  424. }
  425. },{
  426. text:'COM_TYPE_RS422_PTZ',
  427. handler: function(){
  428. startCreateConnection(6);
  429. }
  430. },{
  431. text:'COM_TYPE_RS232_PTZ',
  432. handler: function(){
  433. startCreateConnection(7);
  434. }
  435. },{
  436. text:'COM_TYPE_TCP_PTZ',
  437. handler: function(){
  438. startCreateConnection(8);
  439. }
  440. },{
  441. text:'COM_TYPE_ANALOG_VIDEO',
  442. handler: function(){
  443. startCreateConnection(9);
  444. }
  445. },{
  446. text:'COM_TYPE_ANALOG_AUDIO',
  447. handler: function(){
  448. startCreateConnection(10);
  449. }
  450. },{
  451. text:'COM_TYPE_DC_ALARM_NC',
  452. handler: function(){
  453. startCreateConnection(11);
  454. }
  455. },{
  456. text:'COM_TYPE_DC_ALARM_NO',
  457. handler: function(){
  458. startCreateConnection(12);
  459. }
  460. }]
  461. }
  462. }]
  463. });
  464. tPanel.doLayout();
  465. Ext.Ajax.request({
  466. url: '/lib/controller/getNetwork.php',
  467. params: {
  468. NID: selectedSite,
  469. UID: <?=$UserID;?>,
  470. SID: '<?=$Session;?>'
  471. },
  472. success: function( response, opts ){
  473. // If the response is JSON, you have to decode it
  474. var data = Ext.decode(response.responseText);
  475. netwodkData.nodes = new vis.DataSet( data.nodes );
  476. netwodkData.edges = new vis.DataSet( data.edges );
  477. var container = document.getElementById(Ext.getCmp('sys_map').body.id);
  478. networkObj = new vis.Network(container, netwodkData, networkOpts );
  479. networkObj.on("click", function (params) {
  480. //if(!connectionAddMode){
  481. if( params.nodes.length > 0 ){
  482. loadNodeProperties( params.nodes[0] );
  483. } else if( params.edges.length > 0 ){
  484. selectedConnection = netwodkData.edges.get(params.edges[0]);
  485. loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to );
  486. };
  487. //};
  488. });
  489. networkObj.on("doubleClick", function (params) {
  490. //if(!connectionAddMode){
  491. if( params.nodes.length > 0 ){
  492. loadNodeProperties( params.nodes[0] );
  493. } else if( params.edges.length > 0 ){
  494. selectedConnection = netwodkData.edges.get(params.edges[0]);
  495. loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to );
  496. };
  497. //};
  498. });
  499. /*
  500. networkObj.on("dragStart", function (params) {
  501. if( connectionAddMode ){
  502. var tID = this.getNodeAt(params.pointer.DOM);
  503. if( tID != undefined ){
  504. newConnectionStart = tID;
  505. };
  506. };
  507. });
  508. networkObj.on("dragEnd", function (params) {
  509. if( connectionAddMode ){
  510. var tID = this.getNodeAt(params.pointer.DOM);
  511. if( tID != undefined ){
  512. newConnectionEnd = tID;
  513. //selectedConnection = netwodkData.edges[netwodkData.edges.length];
  514. //selectedConnection.color = {
  515. // color: '#ff0000',
  516. // opacity: 0.3,
  517. // highlight: 'blue'
  518. //};
  519. //networkObj.addEdgeMode(0);
  520. createConnection( newConnectionStart, newConnectionEnd );
  521. connectionAddMode = false;
  522. };
  523. };
  524. });
  525. */
  526. },
  527. failure: function( response, opts ) {
  528. //Ext.fly('some_div').update('Fail!');
  529. }/*,
  530. callback: function(options,success,response){
  531. // use this if you need to perform your own success/failure checking
  532. }*/
  533. });
  534. };
  535. //http://visjs.org/index.html
  536. Ext.onReady(function(){
  537. var viewport = new Ext.Viewport({
  538. layout:'border',
  539. items: [{
  540. xtype: 'panel',
  541. region: 'north',
  542. baseCls: 'x-plain',
  543. height: 50,
  544. items:[{
  545. xtype: 'panel',
  546. id:'top',
  547. baseCls: 'x-plain',
  548. html: '<p style="padding:10px;color:#556677;font-size:11px;"><img src="/style/img/logo32.png"> R-Goose Security System</p>'
  549. }]
  550. },{
  551. xtype: 'panel',
  552. id:'btns',
  553. region:'west',
  554. baseCls:'x-plain',
  555. split:true,
  556. width:150,
  557. minWidth: 100,
  558. maxWidth: 250,
  559. layout:'fit',
  560. margins: '5 0 5 5',
  561. items: [{
  562. xtype: 'panel',
  563. //baseCls: 'x-plain',
  564. height: 400,
  565. title: 'R-Goose System',
  566. layout:'accordion',
  567. defaults: {
  568. // applied to each contained panel
  569. bodyStyle: 'padding:5px'
  570. },
  571. layoutConfig: {
  572. // layout-specific configs go here
  573. titleCollapse: false,
  574. animate: true//,
  575. //activeOnTop: true
  576. },
  577. items: [{
  578. title: 'Dashboard',
  579. layout: 'vbox',
  580. height: 120,
  581. pack: 'center',
  582. align : 'strech',
  583. items:[{
  584. xtype: 'button',
  585. width: '100%',
  586. id:'go_home',
  587. text: 'Go Home',
  588. handler: function( b, e ){
  589. loadDashBoard();
  590. }
  591. },{
  592. xtype: 'button',
  593. width: '100%',
  594. id:'go_monitor',
  595. text: 'Monitor Events',
  596. handler: function( b, e ){
  597. loadTimeLine();
  598. }
  599. },{
  600. xtype: 'button',
  601. width: '100%',
  602. id:'go_out',
  603. text: 'Logout',
  604. handler: function( b, e ){
  605. window.location = '/login.php?UID=1';
  606. }
  607. }]
  608. },{
  609. title: 'System Settings',
  610. layout: 'vbox',
  611. height: 120,
  612. pack: 'center',
  613. align : 'strech',
  614. items:[{
  615. xtype: 'button',
  616. width: '100%',
  617. id:'sys_edit',
  618. text: 'Edit System',
  619. handler: function( b, e ){
  620. loadSystemEditor();
  621. }
  622. },{
  623. xtype: 'button',
  624. width: '100%',
  625. id:'logout',
  626. text: 'Logout',
  627. handler: function( b, e ){
  628. window.location = '/login.php?UID=1';
  629. }
  630. }]
  631. },{
  632. title: 'Profile Settings',
  633. html: '<p>Panel content!</p>'
  634. }]
  635. }]
  636. },{
  637. region:'center',
  638. margins: '5 5 5 0',
  639. id: 'main_content',
  640. layout: 'fit',
  641. items:[{
  642. xtype: 'panel',
  643. html: '<p style="padding:10px;color:#556677;font-size:11px;"><center><img src="/style/img/logo.png"></center></p>'
  644. }]
  645. }]
  646. });
  647. loadDashBoard();
  648. });