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.

371 lines
9.6 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
6 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
6 years ago
6 years ago
​
​
​
6 years ago
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
6 years ago
​
​
​
​
​
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. var eventsListStore = new Ext.data.JsonStore({
  19. root: 'log',
  20. totalProperty: 'totalCount',
  21. idProperty: 'id',
  22. remoteSort: true,
  23. fields: [{
  24. name: 'id',
  25. type: 'int'
  26. },{
  27. name: 'date',
  28. type: 'string'
  29. },{
  30. name: 'time',
  31. type: 'string'
  32. },{
  33. name: 'device',
  34. type: 'string'
  35. },{
  36. name: 'event',
  37. type: 'string'
  38. },{
  39. name: 'data',
  40. type: 'string',
  41. },{
  42. name: 'has_target',
  43. type: 'boolean'
  44. },{
  45. name: 'has_geo',
  46. type: 'boolean'
  47. }],
  48. proxy : new Ext.data.HttpProxy({
  49. method: 'POST',
  50. prettyUrls: false,
  51. url: '/lib/controller/getEventRecords.php',
  52. headers: {
  53. UID: <?=$UserID;?>,
  54. SID: '<?=$Session;?>',
  55. NID: 1
  56. }
  57. })
  58. });
  59. var SelectedEvent = 0;
  60. var eventsListSelModel = new Ext.grid.RowSelectionModel({
  61. singleSelect: true,
  62. listeners: {
  63. rowselect: function(sm, row, rec) {
  64. loadEventProperties( rec.data.id );
  65. //SelectedEvent = rec.data.id;
  66. //alert( SelectedEvent );
  67. //var CB = Ext.getCmp('con_to_src');
  68. //CB.enable();
  69. }
  70. }
  71. });
  72. function ModeRenderer(val){
  73. var p1, p2, p3;
  74. if( ( val & 1 ) == 1 ){
  75. p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
  76. } else {
  77. p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
  78. };
  79. if( ( val & 2 ) == 2 ){
  80. p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
  81. } else {
  82. p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
  83. };
  84. if( ( val & 4 ) == 4 ){
  85. p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
  86. } else {
  87. p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
  88. };
  89. return p1+p2+p3;
  90. };
  91. function LocRenderer( val ){
  92. if( val ){
  93. return '<img src="/style/icons/icons/accept.png" alt="Location">';
  94. };
  95. return '<img src="/style/icons/icons/bullet_white.png" alt="NO Location">';
  96. };
  97. var eventsListColModel = new Ext.grid.ColumnModel({
  98. columns: [
  99. {header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  100. {header: "date",width: 80, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' },
  101. {header: "time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' },
  102. {header: "device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
  103. {header: "event", width: 80, sortable: false, dataIndex: 'event' },
  104. {header: "targ", width: 200, sortable: false, dataindex: 'data' },
  105. {header: "", width: 20, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer }
  106. ],
  107. defaults: {
  108. sortable: true,
  109. menuDisabled: true,
  110. width: 100
  111. },
  112. listeners: {
  113. hiddenchange: function(cm, colIndex, hidden) {
  114. //saveConfig(colIndex, hidden);
  115. }
  116. }
  117. });
  118. function loadTimeLineGroups( NID ){
  119. Ext.Ajax.request({
  120. url: '/lib/controller/getTimeLineGroups.php',
  121. params: {
  122. NID: NID,
  123. UID: <?=$UserID;?>,
  124. SID: '<?=$Session;?>'
  125. },
  126. success: function( response, opts ){
  127. // If the response is JSON, you have to decode it
  128. var data = Ext.decode(response.responseText);
  129. //for(var i = 0; i < data.length; i++) {
  130. //tlGroups.add(data[i]);
  131. //};
  132. tlGroups.update( data );
  133. loadTimeLineItems( selectedSite );
  134. tlInterval = window.setInterval( loadTimeLineItems, 333, selectedSite );
  135. },
  136. failure: function( response, opts ) {
  137. //Ext.fly('some_div').update('Fail!');
  138. }/*,
  139. callback: function(options,success,response){
  140. // use this if you need to perform your own success/failure checking
  141. }*/
  142. });
  143. };
  144. function loadTimeLineItems( NID ){
  145. if( tlLoadLocker ) return;
  146. tlLoadLocker = true;
  147. Ext.Ajax.request({
  148. url: '/lib/controller/getTimeLineEvents.php',
  149. params: {
  150. NID: NID,
  151. UID: <?=$UserID;?>,
  152. SID: '<?=$Session;?>',
  153. LTS: tlLastTS
  154. },
  155. success: function( response, opts ){
  156. // If the response is JSON, you have to decode it
  157. var data = Ext.decode(response.responseText);
  158. var i = 0;
  159. for(; i < data.length; i++ ){
  160. tlLastTS = data[i].start;
  161. data[i].start = moment.utc( ''+data[i].start, 'X' );
  162. tlItems.add( data[i] );
  163. };
  164. if( timelineObj == null ){
  165. var container = document.getElementById('timeline');
  166. timelineObj = new vis.Timeline( container );
  167. timelineObj.setOptions( tlOptions );
  168. timelineObj.setGroups( tlGroups );
  169. timelineObj.setItems( tlItems );
  170. timelineObj.on('select', function (properties) {
  171. //alert( properties.items[0] );
  172. loadEventProperties( properties.items[0] );
  173. //logEvent('select', properties.items[0]);
  174. });
  175. } else {
  176. timelineObj.redraw();
  177. };
  178. if( tlMonitoring ) timelineObj.moveTo( moment.utc() );
  179. eventsListStore.reload();
  180. tlLoadLocker = false;
  181. },
  182. failure: function( response, opts ) {
  183. //Ext.fly('some_div').update('Fail!');
  184. tlLoadLocker = false;
  185. }/*,
  186. callback: function(options,success,response){
  187. // use this if you need to perform your own success/failure checking
  188. }*/
  189. });
  190. };
  191. function loadEventProperties( EventID ){
  192. //alert( 'Node: ' + NodeID );
  193. Ext.Ajax.request({
  194. url: '/lib/controller/getEventProps.php',
  195. params: {
  196. NID: <?=$SiteID;?>,
  197. UID: <?=$UserID;?>,
  198. SID: '<?=$Session;?>',
  199. EVENT: EventID
  200. },
  201. success: function( response, opts ){
  202. // If the response is JSON, you have to decode it
  203. var data = Ext.decode(response.responseText);
  204. var tPanel = Ext.getCmp('prop_content');
  205. tPanel.remove(0);
  206. tPanel.add( data );
  207. tPanel.doLayout();
  208. },
  209. failure: function( response, opts ) {
  210. //Ext.fly('some_div').update('Fail!');
  211. }/*,
  212. callback: function(options,success,response){
  213. // use this if you need to perform your own success/failure checking
  214. }*/
  215. });
  216. };
  217. function loadTimeLine(){
  218. if( tlInterval!= null ){
  219. window.clearInterval( tlInterval );
  220. tlInterval = null;
  221. timelineObj = null;
  222. };
  223. var tPanel = Ext.getCmp('main_portal');
  224. tPanel.removeAll( true );
  225. Ext.getCmp('main_content').setTitle( 'Full Events Log' );
  226. tPanel.add({
  227. columnWidth: 0.83,
  228. frame: false,
  229. border: false,
  230. items: [{
  231. title: 'Events Monitoring',
  232. frame: false,
  233. border: false,
  234. layout: 'vbox',
  235. layoutConfig: {
  236. align : 'stretch',
  237. pack : 'start',
  238. },
  239. height: 375,
  240. //flex: 1,
  241. //border: true,
  242. items:[{
  243. //title: 'TimeLine',
  244. height: 350,
  245. flex: 1,
  246. frame: true,
  247. border: false,
  248. layout: 'fit',
  249. items:{
  250. style: 'background: ivory;',
  251. html: '<div id="timeline"></div>'
  252. },
  253. tbar:[{
  254. id: 'fev',
  255. text: 'Fit Events',
  256. disabled: tlMonitoring,
  257. handler: function(){
  258. timelineObj.fit();
  259. }
  260. },{
  261. id: 'gtn',
  262. text: 'Go to Now',
  263. disabled: tlMonitoring,
  264. handler: function(){
  265. timelineObj.moveTo( moment.utc() );
  266. }
  267. },{
  268. text: 'Live Monitoring',
  269. enableToggle: true,
  270. pressed: tlMonitoring,
  271. toggleHandler: function(){
  272. tlMonitoring = !tlMonitoring;
  273. if( tlMonitoring ){
  274. Ext.getCmp('gtn').disable();
  275. Ext.getCmp('fev').disable();
  276. } else {
  277. Ext.getCmp('gtn').enable();
  278. Ext.getCmp('fev').enable();
  279. };
  280. }
  281. }]
  282. }]
  283. },{
  284. title: 'Event Log',
  285. frame: false,
  286. height: 400,
  287. xtype: 'grid',
  288. ds: eventsListStore,
  289. cm: eventsListColModel,
  290. sm: eventsListSelModel,
  291. //listeners:{
  292. // beforedestroy: function( t ){
  293. // addDialog = null;
  294. // return true;
  295. // }
  296. //},
  297. viewConfig: {
  298. //forceFit: true
  299. },
  300. bbar: [{
  301. text: 'Clear',
  302. handler: function(){
  303. Ext.Ajax.request({
  304. url: '/lib/controller/clearEventCloud.php',
  305. params: {
  306. UID: <?=$UserID;?>,
  307. SID: '<?=$Session;?>'
  308. },
  309. success: function( response, opts ){
  310. },
  311. failure: function( response, opts ) {
  312. }
  313. });
  314. }
  315. }/*,'->',{
  316. id: 'con_to_src',
  317. text: 'Connect To Selected',
  318. disabled: ( SelectedCam == 0 ),
  319. handler: connectToSeleced
  320. }*/]
  321. }]
  322. });
  323. tPanel.add({
  324. columnWidth: 0.17,
  325. frame: false,
  326. id: 'prop_content',
  327. border: false,
  328. items: [{
  329. title: 'Event Information',
  330. border: true,
  331. frame: true,
  332. html: '<p align="center">Select an Event from TimeLine to See Information</p>'
  333. }]
  334. });
  335. tPanel.doLayout();
  336. loadTimeLineGroups( selectedSite );
  337. eventsListStore.load({params:{start:0, limit:50}});
  338. };
  339. function loadOnlineMonitoring(devID){
  340. var tPanel = Ext.getCmp('main_content');
  341. if( tlInterval!= null ){
  342. window.clearInterval( tlInterval );
  343. tlInterval = null;
  344. timelineObj = null;
  345. };
  346. tPanel.remove(0);
  347. tPanel.add({
  348. html: 'Device Monitoring '+devID
  349. });
  350. tPanel.doLayout();
  351. };