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.

174 lines
4.3 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var timelineObj = null;
  3. var tlGroups = new vis.DataSet();
  4. var tlItems = new vis.DataSet();
  5. var tlOptions = {
  6. groupOrder: 'content', // groupOrder can be a property name or a sorting function
  7. stack: true,
  8. showCurrentTime: true,
  9. //verticalScroll: true,
  10. //zoomKey: 'ctrlKey',
  11. minHeight: 308,
  12. maxHeight: 308
  13. };
  14. var tlLoadLocker = false;
  15. var tlLastTS = 0;
  16. var tlInterval = null;
  17. var tlMonitoring = false;
  18. function loadTimeLineGroups( NID ){
  19. Ext.Ajax.request({
  20. url: '/lib/controller/getTimeLineGroups.php',
  21. params: {
  22. NID: NID,
  23. UID: <?=$UserID;?>,
  24. SID: '<?=$Session;?>'
  25. },
  26. success: function( response, opts ){
  27. // If the response is JSON, you have to decode it
  28. var data = Ext.decode(response.responseText);
  29. //for(var i = 0; i < data.length; i++) {
  30. //tlGroups.add(data[i]);
  31. //};
  32. tlGroups.update( data );
  33. loadTimeLineItems( selectedSite );
  34. tlInterval = window.setInterval( loadTimeLineItems, 333, selectedSite );
  35. },
  36. failure: function( response, opts ) {
  37. //Ext.fly('some_div').update('Fail!');
  38. }/*,
  39. callback: function(options,success,response){
  40. // use this if you need to perform your own success/failure checking
  41. }*/
  42. });
  43. };
  44. function loadTimeLineItems( NID ){
  45. if( tlLoadLocker ) return;
  46. tlLoadLocker = true;
  47. Ext.Ajax.request({
  48. url: '/lib/controller/getTimeLineEvents.php',
  49. params: {
  50. NID: NID,
  51. UID: <?=$UserID;?>,
  52. SID: '<?=$Session;?>',
  53. LTS: tlLastTS
  54. },
  55. success: function( response, opts ){
  56. // If the response is JSON, you have to decode it
  57. var data = Ext.decode(response.responseText);
  58. var i = 0;
  59. for(; i < data.length; i++ ){
  60. tlLastTS = data[i].start;
  61. data[i].start = moment.utc( ''+data[i].start, 'X' );
  62. tlItems.add( data[i] );
  63. };
  64. if( timelineObj == null ){
  65. //alert('Now');
  66. var container = document.getElementById('timeline');
  67. timelineObj = new vis.Timeline( container );
  68. timelineObj.setOptions( tlOptions );
  69. timelineObj.setGroups( tlGroups );
  70. timelineObj.setItems( tlItems );
  71. timelineObj.on('select', function (properties) {
  72. logEvent('select', properties);
  73. });
  74. } else {
  75. timelineObj.redraw();
  76. };
  77. if( tlMonitoring ) timelineObj.moveTo( moment.utc() );
  78. tlLoadLocker = false;
  79. },
  80. failure: function( response, opts ) {
  81. //Ext.fly('some_div').update('Fail!');
  82. tlLoadLocker = false;
  83. }/*,
  84. callback: function(options,success,response){
  85. // use this if you need to perform your own success/failure checking
  86. }*/
  87. });
  88. };
  89. function loadTimeLine(){
  90. var tPanel = Ext.getCmp('main_content');
  91. tPanel.remove(0);
  92. tPanel.add({
  93. title: 'Events Monitoring',
  94. frame: false,
  95. border: false,
  96. layout: 'vbox',
  97. layoutConfig: {
  98. align : 'stretch',
  99. pack : 'start',
  100. },
  101. //height: 700,
  102. //flex: 1,
  103. //border: true,
  104. items:[{
  105. //title: 'TimeLine',
  106. height: 350,
  107. flex: 1,
  108. frame: true,
  109. border: false,
  110. layout: 'fit',
  111. items:{
  112. style: 'background: ivory;',
  113. html: '<div id="timeline"></div>'
  114. },
  115. tbar:[{
  116. id: 'fev',
  117. text: 'Fit Events',
  118. disabled: tlMonitoring,
  119. handler: function(){
  120. timelineObj.fit();
  121. }
  122. },{
  123. id: 'gtn',
  124. text: 'Go to Now',
  125. disabled: tlMonitoring,
  126. handler: function(){
  127. timelineObj.moveTo( moment.utc() );
  128. }
  129. },{
  130. text: 'Live Monitoring',
  131. enableToggle: true,
  132. pressed: tlMonitoring,
  133. toggleHandler: function(){
  134. tlMonitoring = !tlMonitoring;
  135. if( tlMonitoring ){
  136. Ext.getCmp('gtn').disable();
  137. Ext.getCmp('fev').disable();
  138. } else {
  139. Ext.getCmp('gtn').enable();
  140. Ext.getCmp('fev').enable();
  141. };
  142. }
  143. }]
  144. },{
  145. title: 'Event Information',
  146. frame: true,
  147. html: '<p align="center">Select an Event from TimeLine to See Information</p>'
  148. }]
  149. });
  150. tPanel.doLayout();
  151. loadTimeLineGroups( selectedSite );
  152. };
  153. function loadOnlineMonitoring(devID){
  154. var tPanel = Ext.getCmp('main_content');
  155. if( tlInterval!= null ){
  156. window.clearInterval( tlInterval );
  157. tlInterval = null;
  158. timelineObj = null;
  159. };
  160. tPanel.remove(0);
  161. tPanel.add({
  162. html: 'Device Monitoring '+devID
  163. });
  164. tPanel.doLayout();
  165. };