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.

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