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.

1298 lines
38 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
​
​
​
5 years ago
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
5 years ago
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
5 years ago
​
​
5 years ago
​
​
5 years ago
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 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
​
​
​
4 years ago
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var serverToolBox = null;
  3. var currentNodeID = 0;
  4. //import * as THREE from 'three';
  5. //let camera, scene, renderer;
  6. var l3dMapOverlayTexture = new THREE.TextureLoader().load( '/lib/controller/data/assets/images/mask_3d.png' );
  7. var l3dMapOverlayMaterial = new THREE.MeshBasicMaterial( { map: l3dMapOverlayTexture, alphaTest: 0.7 } );
  8. var l3dMapOverlayGeometry = new THREE.SphereGeometry( 490, 60, 40 );
  9. // invert the geometry on the x-axis so that all of the faces point inward
  10. l3dMapOverlayGeometry.scale( -1, 1, 1 );
  11. var l3dMapOverlayMesh = new THREE.Mesh( l3dMapOverlayGeometry, l3dMapOverlayMaterial );
  12. function addl3dTarget( id, radius, az, el, color = 0xff0000 ){
  13. if( id > 0 ){
  14. var target = {};
  15. target.geometry = new THREE.BoxGeometry( 10, 10, 10 );
  16. //target.geometry = new THREE.OctahedronGeometry({ radius : 20 });
  17. //target.geometry.translate( x, y, z );
  18. // Turn back into Cartesian coordinates
  19. var fi = (Math.PI/2) - el;
  20. var x = radius * Math.sin( fi) * Math.cos( az );
  21. var y = radius * Math.sin( fi ) * Math.sin( az );
  22. var z = radius * Math.cos( fi );
  23. //alert( "Cords: "+x+" "+y+" "+z+" An:"+az+" "+el);
  24. //target.geometry.position.set( x, y, z ); //translate( x, y, z );
  25. target.material = new THREE.MeshBasicMaterial( {color: color} );
  26. target.mesh = new THREE.Mesh( target.geometry, target.material );
  27. nodeTHREEviewers[id].scene.add( target.mesh );
  28. target.mesh.position.set( x, z, y );
  29. nodeTHREEviewers[id].targets.push( target );
  30. };
  31. };
  32. function cleanup3DDraw( id ){
  33. if( typeof nodeTHREEviewers[id] !== 'undefined' ){
  34. if( typeof nodeTHREEviewers[id].targets !== 'undefined' ){
  35. for( var z=0; z < nodeTHREEviewers[id].targets.length; z++ ){
  36. nodeTHREEviewers[id].scene.remove( nodeTHREEviewers[id].targets[z].mesh );
  37. delete nodeTHREEviewers[id].targets[z].mesh;
  38. delete nodeTHREEviewers[id].targets[z].material;
  39. delete nodeTHREEviewers[id].targets[z].geometry;
  40. delete nodeTHREEviewers[id].targets[z];
  41. };
  42. nodeTHREEviewers[id].targets = [];
  43. //nodeTHREEviewers[id].renderer.render( nodeTHREEviewers[id].scene, nodeTHREEviewers[id].camera );
  44. };
  45. };
  46. };
  47. function DrawClicker( id, event ){
  48. var x = event.offsetX-100;
  49. var y = event.offsetY-100;
  50. switch( drawZoomLevels[ id ] ){
  51. case 100:{
  52. var r = Math.round( 1024.0 / 98 * Math.sqrt( x*x + y*y ) );
  53. if( r > 1024 ) r = 1024;
  54. break;
  55. };
  56. case 50:{
  57. var r = Math.round( 512.0 / 98 * Math.sqrt( x*x + y*y ) );
  58. if( r > 512 ) r = 512;
  59. break;
  60. };
  61. case 25:{
  62. var r = Math.round( 256.0 / 98 * Math.sqrt( x*x + y*y ) );
  63. if( r > 256 ) r = 256;
  64. break;
  65. };
  66. case 12:{
  67. var r = Math.round( 128.0 / 98 * Math.sqrt( x*x + y*y ) );
  68. if( r > 128 ) r = 128;
  69. break;
  70. };
  71. default:{
  72. var r = -1;
  73. break;
  74. };
  75. };
  76. if( r > -1 ){
  77. var z = Math.round( -1.0 * Math.atan2(y, x) * 3000 / Math.PI );
  78. if( z < 0 ) z += 6000 ;
  79. doDeviceOperation( id, 42, r+':'+z, true );
  80. };
  81. };
  82. function Draw3DTargets( k, b ){
  83. cleanup3DDraw( k );
  84. for( var z = 0; z < b.length; z++ ){
  85. var az = b[z].az * ( Math.PI/180.0 );
  86. var el = b[z].el * ( Math.PI/180.0 );
  87. //addl3dTarget( k, b[z].range, az, el, b[z].color );
  88. addl3dTarget( k, 280, az, el, b[z].color );
  89. };
  90. };
  91. let isUserInteracting = false, onPointerDownMouseX = 0, onPointerDownMouseY = 0,
  92. lon = 0, onPointerDownLon = 0,
  93. lat = 0, onPointerDownLat = 0,
  94. phi = 0, theta = 0;
  95. function onWindowResize() {
  96. camera.aspect = window.innerWidth / window.innerHeight;
  97. camera.updateProjectionMatrix();
  98. renderer.setSize( window.innerWidth, window.innerHeight );
  99. };
  100. function onPointerDown( event ) {
  101. if ( event.isPrimary === false ) return;
  102. isUserInteracting = true;
  103. onPointerDownMouseX = event.clientX;
  104. onPointerDownMouseY = event.clientY;
  105. onPointerDownLon = lon;
  106. onPointerDownLat = lat;
  107. document.addEventListener( 'pointermove', onPointerMove );
  108. document.addEventListener( 'pointerup', onPointerUp );
  109. };
  110. function onPointerMove( event ) {
  111. if ( event.isPrimary === false ) return;
  112. lon = ( onPointerDownMouseX - event.clientX ) * 0.1 + onPointerDownLon;
  113. lat = ( event.clientY - onPointerDownMouseY ) * 0.1 + onPointerDownLat;
  114. };
  115. function onPointerUp() {
  116. if ( event.isPrimary === false ) return;
  117. isUserInteracting = false;
  118. document.removeEventListener( 'pointermove', onPointerMove );
  119. document.removeEventListener( 'pointerup', onPointerUp );
  120. };
  121. function onDocumentMouseWheel( event ) {
  122. var id = event.currentTarget.myVID;
  123. if( id > 0 ){
  124. const fov = nodeTHREEviewers[id].camera.fov + event.deltaY * 0.05;
  125. nodeTHREEviewers[id].camera.fov = THREE.MathUtils.clamp( fov, 10, 75 );
  126. nodeTHREEviewers[id].camera.updateProjectionMatrix();
  127. };
  128. };
  129. function reload3dTexture( id ){
  130. if( typeof nodeTHREEviewers[id] !== 'undefined' ){
  131. stopAnimation();
  132. //while( nodeTHREEviewers[id].scene.children.length > 0){
  133. // nodeTHREEviewers[id].scene.remove(nodeTHREEviewers[id].scene.children[0]);
  134. //};
  135. nodeTHREEviewers[id].scene.remove( nodeTHREEviewers[id].mesh );
  136. //nodeTHREEviewers[id].mesh.geometry.dispose();
  137. //nodeTHREEviewers[id].mesh.material.dispose();
  138. delete nodeTHREEviewers[id].mesh;
  139. delete nodeTHREEviewers[id].material;
  140. delete nodeTHREEviewers[id].texture;
  141. delete nodeTHREEviewers[id].geometry;
  142. nodeTHREEviewers[id].geometry = new THREE.SphereGeometry( 500, 60, 40 );
  143. nodeTHREEviewers[id].geometry.scale( -1, 1, 1 );
  144. nodeTHREEviewers[id].texture = new THREE.TextureLoader().load( '/lib/controller/getDeviceDraw.php?NID='+id );
  145. nodeTHREEviewers[id].material = new THREE.MeshBasicMaterial( { map: nodeTHREEviewers[id].texture } );
  146. nodeTHREEviewers[id].mesh = new THREE.Mesh( nodeTHREEviewers[id].geometry, nodeTHREEviewers[id].material );
  147. nodeTHREEviewers[id].scene.add( nodeTHREEviewers[id].mesh );
  148. animate();
  149. //nodeTHREEviewers[id].material.map.needsUpdate = true;
  150. //nodeTHREEviewers[id].material.needsUpdate = true
  151. //alert( ' reloadded ' );
  152. };
  153. };
  154. function stopAnimation(){
  155. if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId );
  156. };
  157. function animate( ) {
  158. if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId );
  159. nodeTHREEanimationId = requestAnimationFrame( animate );
  160. nodeTHREEviewers.forEach( function(element, index, array){
  161. if ( isUserInteracting === false ) {
  162. lon += 0.5;
  163. }
  164. lat = Math.max( - 85, Math.min( 85, lat ) );
  165. phi = THREE.MathUtils.degToRad( 90 - lat );
  166. theta = THREE.MathUtils.degToRad( lon );
  167. const x = 500 * Math.sin( phi ) * Math.cos( theta );
  168. const y = 500 * Math.cos( phi );
  169. const z = 500 * Math.sin( phi ) * Math.sin( theta );
  170. element.camera.lookAt( x, y, z );
  171. element.renderer.render( element.scene, element.camera );
  172. });
  173. //update( id );
  174. };
  175. function animateTargets(){
  176. if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId );
  177. nodeTHREEanimationId = requestAnimationFrame( animateTargets );
  178. nodeTHREEviewers.forEach( function(element, index, array){
  179. if ( isUserInteracting === false ) {
  180. if( element.targetShowCopunter ){
  181. element.targetShowCopunter--;
  182. } else {
  183. element.camera.lookAt( element.targets[element.targetIndex].mesh.position );
  184. element.targetShowCopunter = 100;
  185. element.renderer.render( element.scene, element.camera );
  186. element.targetIndex++;
  187. if( element.targetIndex == element.targets.length ) element.targetIndex = 0;
  188. };
  189. };
  190. });
  191. };
  192. function update() {
  193. if ( isUserInteracting === false ) {
  194. lon += 0.5;
  195. }
  196. lat = Math.max( - 85, Math.min( 85, lat ) );
  197. phi = THREE.MathUtils.degToRad( 90 - lat );
  198. theta = THREE.MathUtils.degToRad( lon );
  199. const x = 500 * Math.sin( phi ) * Math.cos( theta );
  200. const y = 500 * Math.cos( phi );
  201. const z = 500 * Math.sin( phi ) * Math.sin( theta );
  202. camera.lookAt( x, y, z );
  203. renderer.render( scene, camera );
  204. };
  205. function Pie(cx, cy, radius, data) {
  206. var decimals = 4;
  207. var total = 0;
  208. var offset = 0;
  209. var offset2;
  210. var arr = [];
  211. var x;
  212. var y;
  213. var la;
  214. var radians;
  215. for (var i = 0; i < data.length; i++)
  216. total += data[i].value;
  217. for (var i = 0; i < data.length; i++) {
  218. var item = data[i];
  219. var tmp = {};
  220. tmp.index = i;
  221. tmp.value = item.value;
  222. radians = ((((item.value / total) * 360) * Math.PI) / 180).floor(decimals);
  223. offset2 = ((offset / total) * 360).floor(decimals);
  224. tmp.data = item;
  225. x = (cx + Math.sin(radians) * radius).floor(decimals);
  226. y = (cy - Math.cos(radians) * radius).floor(decimals);
  227. la = radians > Math.PI ? 1 : 0;
  228. // Arc
  229. tmp.d = 'M{0} {1},L{0} {2},A{3} {3},0 {4} 1,{5} {6}Z'.format(cx, cy, cy - radius, radius, la, x, y);
  230. tmp.transform = 'rotate({0}, {1}, {2})'.format(offset2, cx, cy);
  231. // Text
  232. x = (cx + Math.sin(radians / 2) * radius / 2).floor(decimals);
  233. y = (cy - Math.cos(radians / 2) * radius / 2).floor(decimals);
  234. tmp.text = 'x="{0}" y="{1}" transform="rotate({2},{0},{1})"'.format(x, y, -offset2);
  235. offset += item.value;
  236. arr.push(tmp);
  237. }
  238. return arr;
  239. }
  240. function Donut(cx, cy, radius, data) {
  241. function arcradius(cx, cy, radius, degrees) {
  242. var radians = (degrees - 90) * Math.PI / 180.0;
  243. return { x: cx + (radius * Math.cos(radians)), y: cy + (radius * Math.sin(radians)) };
  244. }
  245. var decimals = 4;
  246. var total = 0;
  247. var arr = [];
  248. var beg = 0;
  249. var end = 0;
  250. var count = 0;
  251. var half = radius / 2;
  252. var midpoint = radius / 2.4;
  253. for (var i = 0; i < data.length; i++)
  254. total += data[i].value;
  255. for (var i = 0; i < data.length; i++) {
  256. var item = data[i];
  257. var tmp = {};
  258. //var p = (((item.value + 1) / total) * 100).floor( 2 );
  259. var p = Math.floor(((item.value + 1) / total) * 100);
  260. count += p;
  261. if (i === length - 1 && count < 100)
  262. p = p + (100 - count);
  263. end = beg + ((360 / 100) * p);
  264. tmp.index = i;
  265. tmp.value = item.value;
  266. tmp.data = item;
  267. var b = arcradius(cx, cy, radius, end);
  268. var e = arcradius(cx, cy, radius, beg);
  269. var la = (end - beg) <= 180 ? 0 : 1;
  270. tmp.d = ['M', Math.floor( b.x ), Math.floor( b.y ), 'A', radius, radius, 0, la, 0, Math.floor( e.x ), Math.floor( e.y ) ].join(' ');
  271. arr.push(tmp);
  272. beg = end;
  273. }
  274. return arr;
  275. }
  276. //Pie Chart Usage
  277. /*
  278. var svg = $('#yoursvgelement');
  279. var data = [{ value: 33 }, { value: 20 }, { value: 80 }, { value: 48 }];
  280. var centerX = 300;
  281. var centerY = 300;
  282. var radius = 250;
  283. var color = ['#F6BB42', '#8CC152', '#3BAFDA', '#967ADC', '#DA4453'];
  284. var arr = Pie(centerX, centerY, radius, data);
  285. for (var i = 0; i < arr.length; i++) {
  286. var item = arr[i];
  287. svg.asvg('<g transform="{0}"><path d="{1}" fill="{4}" /><text fill="white" font-size="25" {2}>{3}</text></g>'.format(item.transform, item.d, item.text, item.value, color[i]));
  288. }
  289. */
  290. // Donut Chart Usage
  291. /*
  292. var svg = $('#yoursvgelement');
  293. var data = [{ value: 33 }, { value: 20 }, { value: 80 }, { value: 48 }];
  294. var centerX = 300;
  295. var centerY = 300;
  296. var radius = 250;
  297. var color = ['#F6BB42', '#8CC152', '#3BAFDA', '#967ADC', '#DA4453'];
  298. var arr = Donut(centerX, centerY, radius, data);
  299. for (var i = 0; i < arr.length; i++) {
  300. var item = arr[i];
  301. svg.asvg('<g><path d="{0}" stroke="{1}" fill="none" stroke-width="50" /></g>'.format(item.d, color[i]));
  302. }
  303. */
  304. function makePtzMove( me ){
  305. var name = me.target.id;
  306. Ext.Ajax.request({
  307. url: '/lib/controller/camMakeMove.php',
  308. params: {
  309. SITE: <?=$SiteID;?>,
  310. UID: <?=$UserID;?>,
  311. SID: '<?=$Session;?>',
  312. CMD: name
  313. },
  314. //success: function( response, opts ){
  315. //},
  316. failure: failureAJAXFunction
  317. });
  318. };
  319. function ptzCtrl( a ){
  320. };
  321. function makePtzStop( me ){
  322. var name = me.target.id;
  323. Ext.Ajax.request({
  324. url: '/lib/controller/camStop.php',
  325. params: {
  326. SITE: <?=$SiteID;?>,
  327. UID: <?=$UserID;?>,
  328. SID: '<?=$Session;?>',
  329. CMD: name
  330. },
  331. //success: function( response, opts ){
  332. //},
  333. failure: failureAJAXFunction
  334. });
  335. };
  336. function fullScreen( id = '' ){
  337. if(
  338. id == '' ||
  339. document.fullscreenElement ||
  340. document.webkitFullscreenElement ||
  341. document.mozFullScreenElement ||
  342. document.msFullscreenElement
  343. ){
  344. if( document.exitFullscreen ){
  345. document.exitFullscreen();
  346. }else if( document.mozCancelFullScreen ){
  347. document.mozCancelFullScreen();
  348. }else if( document.webkitExitFullscreen ){
  349. document.webkitExitFullscreen();
  350. }else if( document.msExitFullscreen ){
  351. document.msExitFullscreen();
  352. };
  353. }else{
  354. //element = $('#container').get(0);
  355. var element = document.getElementById( id ); //Ext.getCmp( id );
  356. if( element.requestFullscreen ){
  357. element.requestFullscreen();
  358. }else if( element.mozRequestFullScreen ){
  359. element.mozRequestFullScreen();
  360. }else if( element.webkitRequestFullscreen ){
  361. element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  362. }else if( element.msRequestFullscreen ){
  363. element.msRequestFullscreen();
  364. };
  365. };
  366. };
  367. function updateDashBoardItemLayout( id, x, y ){
  368. Ext.Ajax.request({
  369. url: '/lib/controller/updateDashBoardItems.php',
  370. params: {
  371. SITE: <?=$SiteID;?>,
  372. UID: <?=$UserID;?>,
  373. SID: '<?=$Session;?>',
  374. PANEL: id,
  375. X: x,
  376. Y: y
  377. },
  378. success: function( response, opts ){
  379. //var data = Ext.decode(response.responseText);
  380. //var tPanel = Ext.getCmp('main_portal');
  381. //tPanel.removeAll(true);
  382. //for( i=0; i < data.length; i++) tPanel.add( data[i] );
  383. //tPanel.doLayout();
  384. },
  385. failure: failureAJAXFunction
  386. });
  387. };
  388. var drawZoomLevels = Array();
  389. function cleanup2DDraw( a ){
  390. var canvas = document.getElementById('targ_canvas_'+a );
  391. var img = document.getElementById('draw_img_'+a );
  392. if( canvas != 'undefined' ){
  393. canvas.style='display: block; cursor: crosshair;'; //cursor: auto;
  394. img.style='display: none;';
  395. var ctx = canvas.getContext('2d');
  396. ctx.drawImage( img, 0, 0 );
  397. };
  398. };
  399. function Draw2DTargets( k, b ){
  400. var canvas = document.getElementById('targ_canvas_'+k );
  401. var ctx = canvas.getContext('2d');
  402. var img = document.getElementById('draw_img_'+k );
  403. ctx.drawImage( img, 0, 0 );
  404. canvas.style='display: block;';
  405. img.style='display: none;';
  406. for( var i=0; i< b.length; i++ ){
  407. switch( drawZoomLevels[k] ){
  408. case 12:{
  409. if( b[i].digital < 256 ){
  410. var cc = 255 - i ;//* ( 255 / 33 );
  411. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  412. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  413. //ctx.strokeStyle = "#FF0000";
  414. var r = (196 * b[i].digital)/ 512;
  415. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  416. var x = 100 + Math.cos( a ) * r;
  417. var y = 100 + Math.sin( a ) * r;
  418. ctx.fillRect( x, y, 24, 24 );
  419. };
  420. break;
  421. };
  422. case 25:{
  423. if( b[i].digital < 512 ){
  424. var cc = 255 - i ;//* ( 255 / 33 );
  425. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  426. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  427. //ctx.strokeStyle = "#FF0000";
  428. var r = (196 * b[i].digital)/ 1024;
  429. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  430. var x = 100 + Math.cos( a ) * r;
  431. var y = 100 + Math.sin( a ) * r;
  432. ctx.fillRect( x, y, 12, 12 );
  433. };
  434. break;
  435. };
  436. case 50:{
  437. if( b[i].digital < 1024 ){
  438. var cc = 255 - i ;//* ( 255 / 33 );
  439. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  440. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  441. //ctx.strokeStyle = "#FF0000";
  442. var r = (196 * b[i].digital) / 2048;
  443. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  444. var x = 100 + Math.cos( a ) * r;
  445. var y = 100 + Math.sin( a ) * r;
  446. ctx.fillRect( x, y, 6, 6 );
  447. };
  448. break;
  449. };
  450. case 100:{
  451. var cc = 255 - i ;//* ( 255 / 33 );
  452. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  453. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  454. //ctx.strokeStyle = "#FF0000";
  455. var r = (196 * b[i].digital)/ 4096;
  456. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  457. var x = 100 + Math.cos( a ) * r;
  458. var y = 100 + Math.sin( a ) * r;
  459. ctx.fillRect( x, y, 3, 3 );
  460. break;
  461. };
  462. };
  463. };
  464. };
  465. var lastNotificationID = 0;
  466. function setDonatStatus( node_id, param_id, value ){
  467. var val1D = document.getElementById('status_'+node_id+'_donut'+param_id+'_segment1');
  468. var val2D = document.getElementById('status_'+node_id+'_donut'+param_id+'_segment2');
  469. var val3D = document.getElementById('status_'+node_id+'_donut'+param_id+'_segment3');
  470. var val1 = (value>-1)?value:0;
  471. var val2 = (value>-1)?100 - val1:0;//data.nodes[i].cpu5 * 100;
  472. var val3 = (value>-1)?0:100;//data.nodes[i].cpu15 * 100;
  473. var totalValue = document.getElementById('status_'+node_id+'_totalValue'+param_id);
  474. var total = val1+val2+val3;
  475. var per1 = val1/total*100;
  476. var per2 = val2/total*100;
  477. var per3 = val3/total*100;
  478. var offset = 25;
  479. if( ( val1 != undefined ) && ( value > -1 ) ){
  480. totalValue.textContent = val1+'%';
  481. } else {
  482. totalValue.textContent = 'No Data';
  483. };
  484. val1D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  485. val1D.style.strokeDasharray = per1+" "+(100-per1);
  486. val1D.style.strokeDashoffset = offset;
  487. val2D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  488. val2D.style.strokeDasharray = per2+" "+(100-per2);
  489. val2D.style.strokeDashoffset = 100-per1+offset;
  490. val3D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  491. val3D.style.strokeDasharray = per3+" "+(100-per3);
  492. val3D.style.strokeDashoffset = 100-(per1+per2)+offset;
  493. };
  494. function fetchSiteStatus(){
  495. Ext.Ajax.request({
  496. url: '/lib/controller/getStatus.php',
  497. params: {
  498. SITE: <?=$SiteID;?>,
  499. LNID: lastNotificationID,
  500. SPID: StatusTS,
  501. LOAT: LoadTS,
  502. UID: <?=$UserID;?>,
  503. SID: '<?=$Session;?>'
  504. },
  505. success: function( response, opts ){
  506. var data = Ext.decode(response.responseText);
  507. StatusTS = data.CTS;
  508. if( data.nodes.length > 0 ){
  509. for( i=0; i < data.nodes.length; i++ ){
  510. if( data.nodes[i].type == 0 ){
  511. //Handle Server Status
  512. if ( data.nodes[i].status ){
  513. setDonatStatus( data.nodes[i].id, 0, data.nodes[i].cpu5 );
  514. setDonatStatus( data.nodes[i].id, 1, data.nodes[i].mem );
  515. setDonatStatus( data.nodes[i].id, 2, data.nodes[i].disk );
  516. document.getElementById('status_'+data.nodes[i].id+'_txt').innerHTML="Server is Online";
  517. document.getElementById('status_'+data.nodes[i].id+'_img').src = "/style/icons/icons/accept.png";
  518. } else {
  519. setDonatStatus( data.nodes[i].id, 0, -1 );
  520. setDonatStatus( data.nodes[i].id, 1, -1 );
  521. setDonatStatus( data.nodes[i].id, 2, -1 );
  522. document.getElementById('status_'+data.nodes[i].id+'_txt').innerHTML="Server is Offline";
  523. document.getElementById('status_'+data.nodes[i].id+'_img').src = "/style/icons/icons/stop.png";
  524. };
  525. };
  526. // Sesors
  527. if( data.nodes[i].type > 0 && data.nodes[i].type < 7 ){
  528. if( data.nodes[i].reload_draw ){
  529. reload3dTexture( data.nodes[i].id );
  530. LoadTS = StatusTS;
  531. };
  532. };
  533. // Cameras
  534. if( data.nodes[i].type > 9 && data.nodes[i].type < 14 ){
  535. var iel = document.getElementById('img-'+data.nodes[i].id );
  536. if( iel != null ){
  537. if( !data.nodes[i].valid ){
  538. if( iel.src != "/style/assets/no-signal.png" ) iel.src = "/style/assets/no-signal.png";
  539. } else {
  540. if( data.nodes[i].src != iel.src ) iel.src = data.nodes[i].src;
  541. };
  542. };
  543. };
  544. var tt = Ext.getCmp('status_'+data.nodes[i].id );
  545. if( tt != undefined ){
  546. if( data.nodes[i].type < 5 && data.nodes[i].type > 0 ){
  547. if( data.nodes[i].status == 4 ){
  548. Draw2DTargets( data.nodes[i].id, data.nodes[i].targets );
  549. } else {
  550. cleanup2DDraw( data.nodes[i].id );
  551. };
  552. };
  553. if( data.nodes[i].type == 5 ){//addl3dTarget( id, radius, az, el, color = 0xff0000 )
  554. if( data.nodes[i].status == 4 ){
  555. //DrawTargets( data.nodes[i].id, data.nodes[i].targets );
  556. //addl3dTarget( data.nodes[i].id, data.nodes[i].targets[0].digital, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el );
  557. //addl3dTarget( data.nodes[i].id, 150, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el );
  558. Draw3DTargets( data.nodes[i].id, data.nodes[i].targets );
  559. animateTargets();
  560. } else {
  561. cleanup3DDraw( data.nodes[i].id );
  562. animate();
  563. };
  564. var ca = document.getElementById( 'status_canvas_' + data.nodes[i].id );
  565. var ctx = ca.getContext('2d');
  566. //if( stat_present );
  567. ca.style='display: block;';
  568. ctx.font = "10px Arial";
  569. ctx.fillStyle = "rgba(255, 255, 255, 255)";
  570. ctx.fillText( "Master:", 5, 8 );
  571. ctx.fillText( "Slave:", 5, 24 );
  572. //var cc = 255 - i ;//* ( 255 / 33 );
  573. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  574. //ctx.fillStyle = "rgba(255, 0, 0, 100)";//+((b.length - i)/ b.length )+")";
  575. if( data.nodes[i].master_present ){
  576. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  577. } else {
  578. ctx.fillStyle = "rgba(128, 0, 0, 255)";
  579. };
  580. ctx.fillRect( 43, 1, 8, 8 );
  581. if( data.nodes[i].stat_present ){
  582. ctx.strokeStyle = "#FFFF00";
  583. ctx.strokeRect( 43, 1, 8, 8 );
  584. ctx.beginPath();
  585. ctx.moveTo( 51, 5 );
  586. ctx.lineTo( 56, 5 );
  587. ctx.lineTo( 56, 2 );
  588. ctx.lineTo( 103, 2 );
  589. ctx.lineTo( 103, 5 );
  590. ctx.moveTo( 63, 5 );
  591. ctx.lineTo( 143, 5 );
  592. ctx.stroke();
  593. for( z=0; z < 8; z++ ){
  594. //ctx.strokeStyle = "#FFFF00";
  595. //ctx.fillStyle = "rgba(0, 255, 0, 255)";
  596. ctx.fillStyle = "rgba(20, 20, 20, 255)";
  597. h = 19 - ( 19 * data.nodes[i].runtime.mp[z] );
  598. ha = 19 - h;
  599. ctx.fillRect( 64 + z*10, 7, 2, h );
  600. if( ha > 0 ) {
  601. if( data.nodes[i].runtime.mp[z] > 0.8 ){
  602. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  603. } else if ( data.nodes[i].runtime.mp[z] > 0.5 ){
  604. ctx.fillStyle = "rgba( 255, 255, 0, 255)";
  605. } else if ( data.nodes[i].runtime.mp[z] > 0.3 ){
  606. ctx.fillStyle = "rgba( 255, 128, 0, 255)";
  607. } else {
  608. ctx.fillStyle = "rgba( 255, 0, 0, 255)";
  609. };
  610. ctx.fillRect( 64 + z*10, 7+h, 2, ha );
  611. };
  612. ctx.fillStyle = "rgba(20, 20, 20, 255)";
  613. h = 19 - ( 19 * data.nodes[i].runtime.gp[z] );
  614. ha = 19 - h;
  615. ctx.fillRect( 67 + z*10, 7, 2, h );
  616. if( ha > 0 ) {
  617. if( data.nodes[i].runtime.gp[z] > 0.8 ){
  618. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  619. } else if ( data.nodes[i].runtime.gp[z] > 0.5 ){
  620. ctx.fillStyle = "rgba( 255, 255, 0, 255)";
  621. } else if ( data.nodes[i].runtime.gp[z] > 0.3 ){
  622. ctx.fillStyle = "rgba( 255, 128, 0, 255)";
  623. } else {
  624. ctx.fillStyle = "rgba( 255, 0, 0, 255)";
  625. };
  626. ctx.fillRect( 67 + z*10, 7+h, 2, ha );
  627. };
  628. ctx.fillStyle = "rgba(20, 20, 20, 255)";
  629. h = 19 - ( 19 * data.nodes[i].runtime.wp[z] );
  630. ha = 19 - h;
  631. ctx.fillRect( 70 + z*10, 7, 2, h );
  632. if( ha > 0 ){
  633. if( data.nodes[i].runtime.wp[z] > 0.8 ){
  634. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  635. } else if ( data.nodes[i].runtime.wp[z] > 0.5 ){
  636. ctx.fillStyle = "rgba( 255, 255, 0, 255)";
  637. } else if ( data.nodes[i].runtime.wp[z] > 0.3 ){
  638. ctx.fillStyle = "rgba( 255, 128, 0, 255)";
  639. } else {
  640. ctx.fillStyle = "rgba( 255, 0, 0, 255)";
  641. };
  642. ctx.fillRect( 70 + z*10, 7+h, 2, ha );
  643. };
  644. };
  645. //ffmpeg -f v4l2 -framerate <framerate> -thread_queue_size 512 -i <input device> -f alsa -thread_queue_size 512 -i <input device> -t <duration of video> -c:v h264 -c:a aac -pix_fmt yuv420p <output filename>
  646. } else {
  647. ctx.strokeStyle = "#808080";
  648. ctx.strokeRect( 43, 1, 8, 8 );
  649. ctx.beginPath();
  650. ctx.moveTo( 51, 5 );
  651. ctx.lineTo( 56, 5 );
  652. ctx.lineTo( 56, 2 );
  653. ctx.lineTo( 103, 2 );
  654. ctx.lineTo( 103, 5 );
  655. ctx.moveTo( 63, 5 );
  656. ctx.lineTo( 143, 5 );
  657. ctx.stroke();
  658. ctx.fillStyle = "rgba( 128, 0, 0, 255)";
  659. for( z=0; z < 8; z++ ){
  660. ctx.fillRect( 64 + z*10, 7, 2, 19 );
  661. ctx.fillRect( 67 + z*10, 7, 2, 19 );
  662. ctx.fillRect( 70 + z*10, 7, 2, 19 );
  663. //https://www.ebay.com/itm/304440983138
  664. };
  665. };
  666. if( data.nodes[i].slave_present ){
  667. ctx.strokeStyle = "#FFFF00";
  668. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  669. } else {
  670. ctx.strokeStyle = "#808080";
  671. ctx.fillStyle = "rgba(128, 0, 0, 255)";
  672. };
  673. ctx.fillRect( 43, 17, 8, 8 );
  674. ctx.strokeRect( 43, 17, 8, 8 );
  675. ctx.beginPath();
  676. ctx.moveTo( 51, 21 );
  677. ctx.lineTo( 56, 21 );
  678. ctx.lineTo( 56, 31 );
  679. ctx.lineTo( 187, 31 );
  680. ctx.lineTo( 187, 28 );
  681. ctx.moveTo( 147, 28 );
  682. ctx.lineTo( 227, 28 );
  683. ctx.stroke();
  684. for( z=8; z < 16; z++ ){
  685. //ctx.strokeStyle = "#FFFF00";
  686. //ctx.fillStyle = "rgba(0, 255, 0, 255)";
  687. ctx.fillRect( 68 + z*10, 7, 2, 19 );
  688. ctx.fillRect( 71 + z*10, 7, 2, 19 );
  689. ctx.fillRect( 74 + z*10, 7, 2, 19 );
  690. //ctx.strokeRect( 43, 1, 8, 8 );
  691. };
  692. };
  693. if( typeof nodeDashboardStatuses[i] === 'undefined' || nodeDashboardStatuses[i] != data.nodes[i].status ){
  694. nodeDashboardStatuses[i] = data.nodes[i].status;
  695. switch( data.nodes[i].status ){
  696. case 0:{
  697. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  698. tt.update('<table style="background-color:#808080; color:#ffff00;" border="0" width="100%"><tr><td>Offline</td><td width="16"><img width="16px" src="/style/assets/offline.png"></td></tr></table>');
  699. break;
  700. };
  701. case 1:{
  702. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  703. tt.update('<table style="background-color:#008000; color:#ffff00;" border="0" width="100%"><tr><td>Online</td><td width="16"><img width="16px" src="/style/assets/green_2.gif"></td></tr></table>');
  704. break;
  705. };
  706. case 2:{
  707. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  708. tt.update('<table style="background-color:#008000; color:#ffff00;" border="0" width="100%"><tr><td>Initializing</td><td width="16"><img width="16px" src="/style/assets/green_1.gif"></td></tr></table>');
  709. break;
  710. };
  711. case 3:{
  712. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  713. tt.update('<table style="background-color:#800000; color:#ffff00;" border="0" width="100%"><tr><td>Trouble</td><td width="16"><img width="16px" src="/style/assets/red_1.gif"></td></tr></table>');
  714. break;
  715. };
  716. case 4:{
  717. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id, data.nodes[i].targets );
  718. tt.update('<table style="background-color:#ff0000; color:#ffff00;" border="0" width="100%"><tr><td>Alarm</td><td width="16"><img width="16px" src="/style/assets/red_2.gif"></td></tr></table>');
  719. break;
  720. };
  721. };
  722. };
  723. };
  724. };
  725. };
  726. if( data.notifications.length > 0 ){
  727. sndExcl.play();
  728. for( i=0; i < data.notifications.length; i++ ){
  729. /*const not = PNotify.alert({
  730. title: 'You Will Receive a Side',
  731. text: 'You have no choice.',
  732. icon: 'fas fa-info-circle',
  733. hide: false,
  734. closer: false,
  735. sticker: false,
  736. destroy: true,
  737. modules: new Map([
  738. ...PNotify.defaultModules,
  739. [PNotifyConfirm, {
  740. confirm: true,
  741. buttons: [{
  742. text: 'Ok',
  743. primary: true,
  744. click: notice => notice.close()
  745. }]
  746. }]
  747. ])
  748. });
  749. */
  750. const l = PNotify.alert({
  751. type: data.notifications[i].type,
  752. text: data.notifications[i].msg,
  753. textTrusted: true,
  754. stack: NotificationStack,
  755. title: data.notifications[i].action,
  756. hide: data.notifications[i].hide,
  757. closer: data.notifications[i].hide,
  758. sticker: data.notifications[i].hide,
  759. destroy: true,
  760. modules: (data.notifications[i].react )? new Map([
  761. ...PNotify.defaultModules,
  762. [PNotifyConfirm, {
  763. confirm: true,
  764. buttons: [{
  765. text: 'Ok',
  766. primary: true,
  767. click: ( notice, value, evt ) => {
  768. notice.close();
  769. if( notice.title!='' ){
  770. resolveDeviceMistmatch( notice.title );
  771. };
  772. }
  773. }]
  774. }]
  775. ]): null
  776. });
  777. /*
  778. if( data.notifications[i].react ){
  779. l.on('click', (notice, value) => {
  780. notice.close();
  781. resolveDeviceMistmatch( notice.title );
  782. });
  783. };
  784. */
  785. lastNotificationID = data.notifications[i].id;
  786. };
  787. };
  788. },
  789. failure: failureAJAXFunction
  790. });
  791. };
  792. function loadDashBoard(){
  793. if( tlInterval!= null ){
  794. window.clearInterval( tlInterval );
  795. tlInterval = null;
  796. timelineObj = null;
  797. };
  798. setUserContent( 0 );
  799. Ext.Ajax.request({
  800. url: '/lib/controller/getDashBoardItems.php',
  801. params: {
  802. SITE: <?=$SiteID;?>,
  803. UID: <?=$UserID;?>,
  804. SID: '<?=$Session;?>'
  805. },
  806. success: function( response, opts ){
  807. var data = Ext.decode(response.responseText);
  808. Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>' );
  809. var tPanel = Ext.getCmp('main_portal');
  810. tPanel.removeAll(true);
  811. nodeDashboardStatuses = new Array();
  812. for( i=0; i < data.length; i++) tPanel.add( data[i] );
  813. tPanel.doLayout();
  814. $('img[data-enlargeable]').addClass('img-enlargeable').click(function() {
  815. var src = $(this).attr('src');
  816. var modal;
  817. function removeModal() {
  818. modal.remove();
  819. $('body').off('keyup.modal-close');
  820. }
  821. modal = $('<div>').css({
  822. background: 'RGBA(0,0,0,.5) url(' + src + ') no-repeat center',
  823. backgroundSize: 'contain',
  824. width: '100%',
  825. height: '100%',
  826. position: 'fixed',
  827. zIndex: '10000',
  828. top: '0',
  829. left: '0',
  830. cursor: 'zoom-out'
  831. }).click(function() {
  832. removeModal();
  833. }).appendTo('body');
  834. //handling ESC
  835. $('body').on('keyup.modal-close', function(e) {
  836. if (e.key === 'Escape') {
  837. removeModal();
  838. }
  839. });
  840. });
  841. tlInterval = window.setInterval( fetchSiteStatus, 333, selectedSite );
  842. },
  843. failure: failureAJAXFunction
  844. });
  845. };
  846. function showServerToolBox( ServerNodeId ){
  847. currentNodeID = ServerNodeId;
  848. if( serverToolBox == null ){
  849. serverToolBox = new Ext.Window({
  850. title: '<?=$Labels->GetLabel('_SERV_CTLPANEL_SHRT_');?>',
  851. modal: true,
  852. width: 400,
  853. height: 328,
  854. closeAction: 'hide',
  855. items:[{
  856. xtype: 'button',
  857. text: 'Restart',
  858. width: '100%',
  859. textAlign: 'left',
  860. iconCls: 'server_btn_restart',
  861. scale: 'large',
  862. iconAlign: 'left',
  863. handler: function(){
  864. doDeviceOperation( currentNodeID, 250,'', true );
  865. }
  866. },{
  867. xtype: 'button',
  868. text: 'Initialize Hardware',
  869. width: '100%',
  870. textAlign: 'left',
  871. iconCls: 'server_btn_hwinit',
  872. scale: 'large',
  873. iconAlign: 'left',
  874. handler: function(){
  875. doDeviceOperation( currentNodeID, 251,'', true );
  876. }
  877. },{
  878. xtype: 'button',
  879. text: 'Sync Time With Browser',
  880. width: '100%',
  881. textAlign: 'left',
  882. iconCls: 'server_btn_timeinit',
  883. scale: 'large',
  884. iconAlign: 'left',
  885. handler: function(){
  886. doDeviceOperation( currentNodeID, 252, ((new Date())/1000), true );
  887. }
  888. }]
  889. });
  890. };
  891. serverToolBox.show();
  892. };
  893. var detectionProfileWindow = null;
  894. var deviceCtrlNode = '';
  895. function showSensorToolBox( NodeID ){
  896. currentNodeID = NodeID;
  897. deviceCtrlNode = NodeID + ':0';
  898. if( detectionProfileWindow == null ){
  899. detectionProfileWindow = new Ext.Window({
  900. title: '<?=$Labels->GetLabel('_DEV_CTLPANEL_SHRT_');?>',
  901. modal: true,
  902. width: 340,
  903. height: 328,
  904. autoScroll: 'auto',
  905. closeAction: 'hide',
  906. resizable: false,
  907. items:[{
  908. xtype: 'panel',
  909. title: '<?=$Labels->GetLabel('_SPEC_FUNCTI_');?>',
  910. height: 95,
  911. id: 'sf_panel',
  912. frame: true,
  913. flex: 1,
  914. layout: 'vbox',
  915. hidden: true,
  916. items:[{
  917. xtype: 'button',
  918. text: 'Resolve Trouble',
  919. width: '100%',
  920. iconCls: 'ctrl_panel_cog',
  921. scale: 'large',
  922. iconAlign: 'left',
  923. handler: function(){
  924. detectionProfileWindow.hide();
  925. resolveDeviceMistmatch( deviceCtrlNode );
  926. }
  927. }]
  928. },{
  929. xtype: 'panel',
  930. title: '<?=$Labels->GetLabel('_DET_GENWORKS_');?>',
  931. height: 193,
  932. frame: true,
  933. flex: 1,
  934. layout: 'vbox',
  935. items:[{
  936. xtype: 'button',
  937. width: '100%',
  938. text: 'Clear Alarm',
  939. scale: 'large',
  940. iconCls: 'ctrl_panel_clean',
  941. iconAlign: 'left',
  942. handler: function(){
  943. clearDeviceEvents( deviceCtrlNode );
  944. }
  945. },{
  946. xtype: 'button',
  947. width: '100%',
  948. text: 'Draw Background',
  949. scale: 'large',
  950. iconCls: 'ctrl_panel_drawscan',
  951. iconAlign: 'left',
  952. handler: function(){
  953. doDeviceOperation( deviceCtrlNode, 3 );
  954. }
  955. },{
  956. xtype: 'button',
  957. width: '100%',
  958. text: 'Force Study Background',
  959. scale: 'large',
  960. iconCls: 'ctrl_panel_study',
  961. iconAlign: 'left',
  962. handler: function(){
  963. doDeviceOperation( deviceCtrlNode, 2 );
  964. }
  965. },{
  966. xtype: 'button',
  967. width: '100%',
  968. buttonAlign: 'left',
  969. //text: '<table width="100%" border=1><tr><td style="text-align:left">Button 1</td></tr></table>',
  970. text: 'Force Reset Sensor',
  971. scale: 'large',
  972. iconCls: 'ctrl_panel_reset',
  973. iconAlign: 'left',
  974. handler: function(){
  975. doDeviceOperation( deviceCtrlNode, 1 );
  976. }
  977. }]
  978. },{
  979. xtype: 'panel',
  980. title: 'Zone Masking Management',
  981. height: 140,
  982. frame: true,
  983. flex: 1,
  984. layout: 'vbox',
  985. items:[{
  986. xtype: 'button',
  987. text: 'Mask Editor',
  988. id: 'DMED',
  989. width: '100%',
  990. handler: function(){
  991. showMaskEditor( true, 0, deviceCtrlNode );
  992. }
  993. },{
  994. xtype: 'spacer',
  995. height: 6
  996. },{
  997. xtype: 'panel',
  998. frame: false,
  999. border: false,
  1000. flex: 1,
  1001. width: '100%',
  1002. height: 40,
  1003. layout: 'hbox',
  1004. items:[{
  1005. xtype: 'button',
  1006. enableToggle: true,
  1007. width: '20%',
  1008. scale: 'large',
  1009. id: 'mz_btn_0',
  1010. iconCls: 'mask_zone1_btn',
  1011. iconAlign: 'top',
  1012. pressed: false,
  1013. disabled: true,
  1014. handler: function(){
  1015. Ext.getCmp('MAPPLY').enable();
  1016. }
  1017. },{
  1018. xtype: 'button',
  1019. enableToggle: true,
  1020. width: '20%',
  1021. scale: 'large',
  1022. id: 'mz_btn_1',
  1023. iconCls: 'mask_zone2_btn',
  1024. iconAlign: 'top',
  1025. pressed: false,
  1026. disabled: true,
  1027. handler: function(){
  1028. Ext.getCmp('MAPPLY').enable();
  1029. }
  1030. },{
  1031. xtype: 'button',
  1032. enableToggle: true,
  1033. width: '20%',
  1034. scale: 'large',
  1035. id: 'mz_btn_2',
  1036. iconCls: 'mask_zone3_btn',
  1037. iconAlign: 'top',
  1038. pressed: false,
  1039. disabled: true,
  1040. handler: function(){
  1041. Ext.getCmp('MAPPLY').enable();
  1042. }
  1043. },{
  1044. xtype: 'button',
  1045. enableToggle: true,
  1046. width: '20%',
  1047. scale: 'large',
  1048. id: 'mz_btn_3',
  1049. iconCls: 'mask_zone4_btn',
  1050. iconAlign: 'top',
  1051. pressed: false,
  1052. disabled: true,
  1053. handler: function(){
  1054. Ext.getCmp('MAPPLY').enable();
  1055. }
  1056. },{
  1057. xtype: 'button',
  1058. enableToggle: true,
  1059. width: '20%',
  1060. scale: 'large',
  1061. id: 'mz_btn_4',
  1062. iconCls: 'mask_zone5_btn',
  1063. iconAlign: 'top',
  1064. pressed: false,
  1065. disabled: true,
  1066. handler: function(){
  1067. Ext.getCmp('MAPPLY').enable();
  1068. }
  1069. }]
  1070. },{
  1071. xtype: 'spacer',
  1072. height: 6
  1073. },{
  1074. xtype: 'button',
  1075. text: 'Apply Zone Masks',
  1076. id: 'MAPPLY',
  1077. disabled: true,
  1078. width: '100%',
  1079. handler: function(){
  1080. }
  1081. }]
  1082. },{
  1083. xtype: 'panel',
  1084. title: '<?=$Labels->GetLabel('_DET_SENSITIVITY_');?>',
  1085. height: 95,
  1086. frame: true,
  1087. flex: 1,
  1088. layout: 'hbox',
  1089. items:[<?php
  1090. if( $CUser->Data['access']>4 ){
  1091. ?>{
  1092. xtype: 'button',
  1093. text: 'Factory',
  1094. id: 'DDSPBTN0',
  1095. width: 80,
  1096. iconCls: 'detection_btn_factory',
  1097. enableToggle: true,
  1098. toggleGroup: 'det_sens_btn_grp',
  1099. disabled: true,
  1100. scale: 'large',
  1101. iconAlign: 'top'
  1102. },<?php
  1103. };
  1104. ?>{
  1105. xtype: 'button',
  1106. text: 'Low',
  1107. id: 'DDSPBTN1',
  1108. width: 80,
  1109. iconCls: 'detection_btn_low',
  1110. enableToggle: true,
  1111. toggleGroup: 'det_sens_btn_grp',
  1112. disabled: true,
  1113. scale: 'large',
  1114. iconAlign: 'top'
  1115. },{
  1116. xtype: 'button',
  1117. text: 'Meduim',
  1118. id: 'DDSPBTN2',
  1119. width: 80,
  1120. iconCls: 'detection_btn_medium',
  1121. enableToggle: true,
  1122. toggleGroup: 'det_sens_btn_grp',
  1123. disabled: true,
  1124. scale: 'large',
  1125. iconAlign: 'top'
  1126. },{
  1127. xtype: 'button',
  1128. text: 'High',
  1129. id: 'DDSPBTN3',
  1130. width: 80,
  1131. iconCls: 'detection_btn_high',
  1132. enableToggle: true,
  1133. toggleGroup: 'det_sens_btn_grp',
  1134. disabled: true,
  1135. scale: 'large',
  1136. iconAlign: 'top'
  1137. }]
  1138. }]
  1139. });
  1140. };
  1141. detectionProfileWindow.show();
  1142. var myMask = new Ext.LoadMask( detectionProfileWindow.getEl(), {msg:"Please wait..."});
  1143. myMask.show();
  1144. Ext.Ajax.request({
  1145. url: '/lib/controller/getDetectionProfile.php',
  1146. params: {
  1147. SITE: SelectedSite,
  1148. UID: <?=$UserID;?>,
  1149. SID: '<?=$Session;?>',
  1150. NID: NodeID
  1151. },
  1152. success: function( response, opts ){
  1153. var data = Ext.decode( response.responseText );
  1154. myMask.hide();
  1155. detectionProfileWindow.setTitle( '['+data.name + '] <?=$Labels->GetLabel('_DEV_CTLPANEL_SHRT_');?>');
  1156. if(data.masks_array != 'undefined' ){
  1157. for( i = 0; i < 5; i++ ){
  1158. var cE = Ext.getCmp('mz_btn_'+i );
  1159. if( data.masks_array[i]=='E'){
  1160. cE.enable();
  1161. cE.toggle( true, true );
  1162. } else {
  1163. cE.toggle( false, true );
  1164. if( data.masks_array[i]=='D' ){
  1165. cE.enable();
  1166. } else {
  1167. cE.disable();
  1168. };
  1169. };
  1170. };
  1171. };
  1172. if( data.data_status == 3 ){
  1173. if( data.profiles.length > 1 ){
  1174. for( i=0; i < data.profiles.length; i++ ){
  1175. Ext.getCmp('DDSPBTN'+i ).enable();
  1176. if( i == data.profile_id ) Ext.getCmp('DDSPBTN'+i ).toggle( true, false );
  1177. };
  1178. } else {
  1179. Ext.getCmp('DDSPBTN0').toggle( true, false );
  1180. Ext.getCmp('DDSPBTN0').disable();
  1181. };
  1182. } else if( data.data_status == 4 ){
  1183. Ext.getCmp('sf_panel').show();
  1184. };
  1185. detectionProfileWindow.doLayout();
  1186. },
  1187. failure: failureAJAXFunction
  1188. });
  1189. };