Web Interface For Lite Argus Control modules
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.

293 lines
10 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
4 years ago
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. $UID = intval( $CUser->Data['id'] );
  4. $Data = '';
  5. if( $UID > 1 ){
  6. $QS = "SELECT * FROM `system_props` LIMIT 1";
  7. $SPD = $DATABASE->Query( $QS );
  8. if( count( $SPD ) ){
  9. $SP = $SPD[0];
  10. $DUMMY = array();
  11. if( $CUser->Data['access'] > 5 ){
  12. $TABA =<<<_DATA_BOUNDARY
  13. {
  14. xtype: 'panel',
  15. html: '<table id="tbl_ph_ccc_%%ID%%" style="color: black; background-image: url(\'/style/assets/16-9-nocam.png\');" width="100%" border=0><tr><td colspan=3>&nbsp;</td></tr><tr><td>&nbsp;</td><td align="center"><div id="btn_ph_ccc_%%ID%%"></div></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>',
  16. listeners:{
  17. afterrender : function( ){
  18. var tb = document.getElementById('tbl_ph_ccc_%%ID%%');
  19. var W = tb.offsetWidth;
  20. var H = (W/16)*9;
  21. tb.setAttribute("height", H );
  22. tb.style.backgroundSize=W+"px "+H+"px";
  23. var p = Ext.getCmp('pan_ph_ccc_%%ID%%');
  24. p.setHeight( H+40 );
  25. var jaja = Ext.create({
  26. xtype: 'panel',
  27. title: 'Camera is Not Assigned to the System',
  28. frame: true,
  29. renderTo: 'btn_ph_ccc_%%ID%%',
  30. layout: 'vbox',
  31. width: 500,
  32. height: 120,
  33. items:[{
  34. xtype: 'spacer',
  35. height: 10
  36. },{
  37. width: '100%',
  38. html: '<center>Proceed to Cameras Settings to Assign One</center>'
  39. },{
  40. xtype: 'spacer',
  41. height: 20
  42. },{
  43. xtype: 'button',
  44. width: '100%',
  45. text: 'Open Camera Settings',
  46. handler: function(){
  47. showContent( 2020 );
  48. }
  49. }]
  50. });
  51. jaja.doLayout();
  52. }
  53. }
  54. }
  55. _DATA_BOUNDARY;
  56. $LOGIO=<<<_DATA_BOUNDARY
  57. {
  58. xtype: 'grid',
  59. id: 'rep_grid',
  60. border: false,
  61. frame: false,
  62. autoScroll: true,
  63. //width: '100%',
  64. lazyRender: true,
  65. height: 210,
  66. ds: rep_store,
  67. cm: new Ext.grid.ColumnModel( rep_ColModel_ops ),
  68. sm: new Ext.grid.RowSelectionModel( rep_SelModel_ops ),
  69. viewConfig: {
  70. forceFit: true,
  71. getRowClass: function( record, rowIndex, rowParams, store){
  72. switch( record.get('node_id')%5 ){
  73. case 0: return 'row-level01';
  74. case 1: return 'row-level02';
  75. case 2: return 'row-level03';
  76. case 3: return 'row-level04';
  77. case 4: return 'row-level05';
  78. };
  79. return '';
  80. }
  81. },
  82. listeners:{
  83. afterrender : function( t ){
  84. var papa = Ext.getCmp('segment_portal');
  85. var jj = papa.getComponent( 1 ).getHeight();
  86. var mama = Ext.getCmp('lg_panel');
  87. var R = PanelH - jj - 30;
  88. mama.setHeight( R+40 );
  89. t.setHeight( R );
  90. }
  91. }
  92. }
  93. _DATA_BOUNDARY;
  94. $MAPIO=<<<_DATA_BOUNDARY
  95. {
  96. id: 'report_map',
  97. height: 200,
  98. title: 'Map',
  99. frame: true,
  100. draggable: false,
  101. collapsible: false,
  102. html: '&nbsp;',
  103. listeners:{
  104. afterrender : function( t ){
  105. var papa = Ext.getCmp('segment_portal');
  106. var jj = 9 * papa.getWidth() / 32;//getComponent( 0 ).getHeight();
  107. //alert( jj );
  108. t.setHeight( jj + 30 );
  109. geoMapIsPresent = true;
  110. initMapReporting();
  111. }
  112. }
  113. }
  114. _DATA_BOUNDARY;
  115. $DUMMY['camera']="{xtype:'panel', id:'pan_ph_ccc_%%ID%%', title: 'Camera Placeholder', frame: true, border: true, draggable: false, layouit: 'fit', items:{$TABA}}";
  116. $DUMMY['sensor']="{xtype:'panel', title: 'Sensor Placeholder', frame: true, border: true, draggable: false, html:'NO SENSOR', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 66+W );}}}";
  117. $DUMMY['map']="{xtype:'panel', title: 'Map Placeholder', frame: true, height: 200, border: true, draggable: false, html:'NO MAP'}";
  118. $DUMMY['log']="{xtype:'panel', id: 'lg_panel', title: 'Report Log', frame: true, border: true, draggable: false, items:[{$LOGIO}] }";
  119. } else {
  120. $DUMMY['camera']="{xtype:'panel', title: false, frame: true, draggable: false, html: '&nbsp;', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}";
  121. $DUMMY['sensor']="{xtype:'panel', title: false, frame: true, draggable: false, html: '&nbsp;', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}";
  122. $DUMMY['map']="{xtype:'panel', title: false, frame: true, draggable: false, height: 200, html: '&nbsp;'}";
  123. $DUMMY['log']="{xtype:'panel', title: false, frame: true, draggable: false, height: 200, html: '&nbsp;'}";
  124. };
  125. $STA = array();
  126. $END="]}";
  127. $OUT = array();
  128. if( $SP['type'] == 1 ) {
  129. //Metro
  130. $STA[0]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  131. $STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  132. $STA[2]="{ columnWidth: .50, stylse:'padding:10px 0 10px 10px', items:[";
  133. $STA[3]="{ columnWidth: 1.0, stylse:'padding:10px 0 10px 10px', items:[";
  134. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  135. $R = $DATABASE->Query( $QS );
  136. $idx = 0;
  137. if( count( $R ) ){
  138. foreach( $R as $DD ){
  139. if( $idx < 2 ){
  140. $TFN = 'report/node_' . $DD['type'] . '.js';
  141. if(!file_exists( $TFN )) continue;
  142. $TPL = file_get_contents( $TFN );
  143. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  144. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  145. $OUT[]= $STA[$idx] . $TPL . $END;
  146. } else break;
  147. $idx++;
  148. };
  149. if( $idx < 2 ){
  150. for( ;$idx<2;$idx++ ){
  151. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  152. };
  153. };
  154. } else {
  155. for( ;$idx<2;$idx++ ){
  156. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  157. };
  158. };
  159. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  160. $R = $DATABASE->Query( $QS );
  161. $idx = 0;
  162. if( count( $R ) ){
  163. foreach( $R as $DD ){
  164. if( $idx < 1 ){
  165. $TFN = 'report/node_' . $DD['type'] . '.js';
  166. if(!file_exists( $TFN )) continue;
  167. $TPL = file_get_contents( $TFN );
  168. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  169. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  170. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  171. $Z=$DATABASE->Query( $QS );
  172. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  173. $S=$DATABASE->Query( $QS );
  174. $MODULE_DATA = $S[0];
  175. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  176. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  177. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  178. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  179. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  180. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  181. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  182. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  183. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  184. $W = 244;
  185. $H = $W * $FK;
  186. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  187. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  188. $OUT[]= $STA[2+$idx] . $TPL . $END;
  189. } else break;
  190. $idx++;
  191. };
  192. if( $idx < 1 ){
  193. for( ;$idx<1;$idx++ ){
  194. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  195. $OUT[]= $STA[2+$idx] . $T . $END;
  196. };
  197. };
  198. } else {
  199. for( ;$idx<1;$idx++ ){
  200. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  201. $OUT[]= $STA[2+$idx] . $T . $END;
  202. };
  203. };
  204. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  205. } else {
  206. $STA[0]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  207. $STA[1]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  208. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  209. $STA[3]="{ columnWidth: .67, stylse:'padding:10px 0 10px 10px', items:[";
  210. $OUT[]= $STA[0] . $MAPIO . $END;
  211. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  212. $R = $DATABASE->Query( $QS );
  213. $idx = 0;
  214. if( count( $R ) ){
  215. foreach( $R as $DD ){
  216. if( $idx < 1 ){
  217. $TFN = 'report/node_' . $DD['type'] . '.js';
  218. if(!file_exists( $TFN )) continue;
  219. $TPL = file_get_contents( $TFN );
  220. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  221. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  222. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  223. $Z=$DATABASE->Query( $QS );
  224. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  225. $S=$DATABASE->Query( $QS );
  226. $MODULE_DATA = $S[0];
  227. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  228. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  229. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  230. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  231. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  232. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  233. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  234. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  235. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  236. $W = 244;
  237. $H = $W * $FK;
  238. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  239. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  240. $OUT[]= $STA[1+$idx] . $TPL . $END;
  241. } else break;
  242. $idx++;
  243. };
  244. if( $idx < 1 ){
  245. for( ;$idx<1;$idx++ ){
  246. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  247. $OUT[]= $STA[1+$idx] . $T . $END;
  248. };
  249. };
  250. } else {
  251. for( ;$idx<1;$idx++ ){
  252. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  253. $OUT[]= $STA[1+$idx] . $T . $END;
  254. };
  255. };
  256. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  257. $R = $DATABASE->Query( $QS );
  258. $idx = 0;
  259. if( count( $R ) ){
  260. foreach( $R as $DD ){
  261. if( $idx < 2 ){
  262. $TFN = 'report/node_' . $DD['type'] . '.js';
  263. if(!file_exists( $TFN )) continue;
  264. $TPL = file_get_contents( $TFN );
  265. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  266. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  267. $OUT[]= $STA[2+$idx] . $TPL . $END;
  268. } else break;
  269. $idx++;
  270. };
  271. } else {
  272. for( ;$idx<1;$idx++ ){
  273. $OUT[]= $STA[2+$idx] . $DUMMY['sensor'] . $END;
  274. };
  275. };
  276. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  277. };
  278. $Data = '[' . implode( ',' , $OUT ) . ']';
  279. } else {
  280. $Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
  281. };
  282. };
  283. if( $Data != '' ) {
  284. echo $Data;
  285. } else {
  286. echo '[]';
  287. };
  288. ?>