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.

1298 lines
38 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. if( totalValue == undefined ) return;
  475. var total = val1+val2+val3;
  476. var per1 = val1/total*100;
  477. var per2 = val2/total*100;
  478. var per3 = val3/total*100;
  479. var offset = 25;
  480. if( ( val1 != undefined ) && ( value > -1 ) ){
  481. totalValue.textContent = val1+'%';
  482. } else {
  483. totalValue.textContent = 'No Data';
  484. };
  485. val1D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  486. val1D.style.strokeDasharray = per1+" "+(100-per1);
  487. val1D.style.strokeDashoffset = offset;
  488. val2D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  489. val2D.style.strokeDasharray = per2+" "+(100-per2);
  490. val2D.style.strokeDashoffset = 100-per1+offset;
  491. val3D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  492. val3D.style.strokeDasharray = per3+" "+(100-per3);
  493. val3D.style.strokeDashoffset = 100-(per1+per2)+offset;
  494. };
  495. function fetchSiteStatus(){
  496. Ext.Ajax.request({
  497. url: '/lib/controller/getStatus.php',
  498. params: {
  499. SITE: <?=$SiteID;?>,
  500. LNID: lastNotificationID,
  501. SPID: StatusTS,
  502. LOAT: LoadTS,
  503. UID: <?=$UserID;?>,
  504. SID: '<?=$Session;?>'
  505. },
  506. success: function( response, opts ){
  507. var data = Ext.decode(response.responseText);
  508. StatusTS = data.CTS;
  509. if( data.nodes.length > 0 ){
  510. for( i=0; i < data.nodes.length; i++ ){
  511. if( data.nodes[i].type == 0 ){
  512. //Handle Server Status
  513. if ( data.nodes[i].status ){
  514. setDonatStatus( data.nodes[i].id, 0, data.nodes[i].cpu5 );
  515. setDonatStatus( data.nodes[i].id, 1, data.nodes[i].mem );
  516. setDonatStatus( data.nodes[i].id, 2, data.nodes[i].disk );
  517. document.getElementById('status_'+data.nodes[i].id+'_txt').innerHTML="Server is Online";
  518. document.getElementById('status_'+data.nodes[i].id+'_img').src = "/style/icons/icons/accept.png";
  519. } else {
  520. setDonatStatus( data.nodes[i].id, 0, -1 );
  521. setDonatStatus( data.nodes[i].id, 1, -1 );
  522. setDonatStatus( data.nodes[i].id, 2, -1 );
  523. document.getElementById('status_'+data.nodes[i].id+'_txt').innerHTML="Server is Offline";
  524. document.getElementById('status_'+data.nodes[i].id+'_img').src = "/style/icons/icons/stop.png";
  525. };
  526. };
  527. // Sesors
  528. if( data.nodes[i].type > 0 && data.nodes[i].type < 7 ){
  529. if( data.nodes[i].reload_draw ){
  530. reload3dTexture( data.nodes[i].id );
  531. LoadTS = StatusTS;
  532. };
  533. };
  534. // Cameras
  535. if( data.nodes[i].type > 9 && data.nodes[i].type < 14 ){
  536. var iel = document.getElementById('img-'+data.nodes[i].id );
  537. if( iel != null ){
  538. if( !data.nodes[i].valid ){
  539. if( iel.src != "/style/assets/no-signal.png" ) iel.src = "/style/assets/no-signal.png";
  540. } else {
  541. if( data.nodes[i].src != iel.src ) iel.src = data.nodes[i].src;
  542. };
  543. };
  544. };
  545. var tt = Ext.getCmp('status_'+data.nodes[i].id );
  546. if( tt != undefined ){
  547. if( data.nodes[i].type < 5 && data.nodes[i].type > 0 ){
  548. if( data.nodes[i].status == 4 ){
  549. Draw2DTargets( data.nodes[i].id, data.nodes[i].targets );
  550. } else {
  551. cleanup2DDraw( data.nodes[i].id );
  552. };
  553. };
  554. if( data.nodes[i].type == 5 ){//addl3dTarget( id, radius, az, el, color = 0xff0000 )
  555. if( data.nodes[i].status == 4 ){
  556. //DrawTargets( data.nodes[i].id, data.nodes[i].targets );
  557. //addl3dTarget( data.nodes[i].id, data.nodes[i].targets[0].digital, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el );
  558. //addl3dTarget( data.nodes[i].id, 150, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el );
  559. Draw3DTargets( data.nodes[i].id, data.nodes[i].targets );
  560. animateTargets();
  561. } else {
  562. cleanup3DDraw( data.nodes[i].id );
  563. animate();
  564. };
  565. var ca = document.getElementById( 'status_canvas_' + data.nodes[i].id );
  566. var ctx = ca.getContext('2d');
  567. //if( stat_present );
  568. ca.style='display: block;';
  569. ctx.font = "10px Arial";
  570. ctx.fillStyle = "rgba(255, 255, 255, 255)";
  571. ctx.fillText( "Master:", 5, 8 );
  572. ctx.fillText( "Slave:", 5, 24 );
  573. //var cc = 255 - i ;//* ( 255 / 33 );
  574. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  575. //ctx.fillStyle = "rgba(255, 0, 0, 100)";//+((b.length - i)/ b.length )+")";
  576. if( data.nodes[i].master_present ){
  577. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  578. } else {
  579. ctx.fillStyle = "rgba(128, 0, 0, 255)";
  580. };
  581. ctx.fillRect( 43, 1, 8, 8 );
  582. if( data.nodes[i].stat_present ){
  583. ctx.strokeStyle = "#FFFF00";
  584. ctx.strokeRect( 43, 1, 8, 8 );
  585. ctx.beginPath();
  586. ctx.moveTo( 51, 5 );
  587. ctx.lineTo( 56, 5 );
  588. ctx.lineTo( 56, 2 );
  589. ctx.lineTo( 103, 2 );
  590. ctx.lineTo( 103, 5 );
  591. ctx.moveTo( 63, 5 );
  592. ctx.lineTo( 143, 5 );
  593. ctx.stroke();
  594. for( z=0; z < 8; z++ ){
  595. //ctx.strokeStyle = "#FFFF00";
  596. //ctx.fillStyle = "rgba(0, 255, 0, 255)";
  597. ctx.fillStyle = "rgba(20, 20, 20, 255)";
  598. h = 19 - ( 19 * data.nodes[i].runtime.mp[z] );
  599. ha = 19 - h;
  600. ctx.fillRect( 64 + z*10, 7, 2, h );
  601. if( ha > 0 ) {
  602. if( data.nodes[i].runtime.mp[z] > 0.8 ){
  603. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  604. } else if ( data.nodes[i].runtime.mp[z] > 0.5 ){
  605. ctx.fillStyle = "rgba( 255, 255, 0, 255)";
  606. } else if ( data.nodes[i].runtime.mp[z] > 0.3 ){
  607. ctx.fillStyle = "rgba( 255, 128, 0, 255)";
  608. } else {
  609. ctx.fillStyle = "rgba( 255, 0, 0, 255)";
  610. };
  611. ctx.fillRect( 64 + z*10, 7+h, 2, ha );
  612. };
  613. ctx.fillStyle = "rgba(20, 20, 20, 255)";
  614. h = 19 - ( 19 * data.nodes[i].runtime.gp[z] );
  615. ha = 19 - h;
  616. ctx.fillRect( 67 + z*10, 7, 2, h );
  617. if( ha > 0 ) {
  618. if( data.nodes[i].runtime.gp[z] > 0.8 ){
  619. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  620. } else if ( data.nodes[i].runtime.gp[z] > 0.5 ){
  621. ctx.fillStyle = "rgba( 255, 255, 0, 255)";
  622. } else if ( data.nodes[i].runtime.gp[z] > 0.3 ){
  623. ctx.fillStyle = "rgba( 255, 128, 0, 255)";
  624. } else {
  625. ctx.fillStyle = "rgba( 255, 0, 0, 255)";
  626. };
  627. ctx.fillRect( 67 + z*10, 7+h, 2, ha );
  628. };
  629. ctx.fillStyle = "rgba(20, 20, 20, 255)";
  630. h = 19 - ( 19 * data.nodes[i].runtime.wp[z] );
  631. ha = 19 - h;
  632. ctx.fillRect( 70 + z*10, 7, 2, h );
  633. if( ha > 0 ){
  634. if( data.nodes[i].runtime.wp[z] > 0.8 ){
  635. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  636. } else if ( data.nodes[i].runtime.wp[z] > 0.5 ){
  637. ctx.fillStyle = "rgba( 255, 255, 0, 255)";
  638. } else if ( data.nodes[i].runtime.wp[z] > 0.3 ){
  639. ctx.fillStyle = "rgba( 255, 128, 0, 255)";
  640. } else {
  641. ctx.fillStyle = "rgba( 255, 0, 0, 255)";
  642. };
  643. ctx.fillRect( 70 + z*10, 7+h, 2, ha );
  644. };
  645. };
  646. //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>
  647. } else {
  648. ctx.strokeStyle = "#808080";
  649. ctx.strokeRect( 43, 1, 8, 8 );
  650. ctx.beginPath();
  651. ctx.moveTo( 51, 5 );
  652. ctx.lineTo( 56, 5 );
  653. ctx.lineTo( 56, 2 );
  654. ctx.lineTo( 103, 2 );
  655. ctx.lineTo( 103, 5 );
  656. ctx.moveTo( 63, 5 );
  657. ctx.lineTo( 143, 5 );
  658. ctx.stroke();
  659. ctx.fillStyle = "rgba( 128, 0, 0, 255)";
  660. for( z=0; z < 8; z++ ){
  661. ctx.fillRect( 64 + z*10, 7, 2, 19 );
  662. ctx.fillRect( 67 + z*10, 7, 2, 19 );
  663. ctx.fillRect( 70 + z*10, 7, 2, 19 );
  664. //https://www.ebay.com/itm/304440983138
  665. };
  666. };
  667. if( data.nodes[i].slave_present ){
  668. ctx.strokeStyle = "#FFFF00";
  669. ctx.fillStyle = "rgba(0, 255, 0, 255)";
  670. } else {
  671. ctx.strokeStyle = "#808080";
  672. ctx.fillStyle = "rgba(128, 0, 0, 255)";
  673. };
  674. ctx.fillRect( 43, 17, 8, 8 );
  675. ctx.strokeRect( 43, 17, 8, 8 );
  676. ctx.beginPath();
  677. ctx.moveTo( 51, 21 );
  678. ctx.lineTo( 56, 21 );
  679. ctx.lineTo( 56, 31 );
  680. ctx.lineTo( 187, 31 );
  681. ctx.lineTo( 187, 28 );
  682. ctx.moveTo( 147, 28 );
  683. ctx.lineTo( 227, 28 );
  684. ctx.stroke();
  685. for( z=8; z < 16; z++ ){
  686. //ctx.strokeStyle = "#FFFF00";
  687. //ctx.fillStyle = "rgba(0, 255, 0, 255)";
  688. ctx.fillRect( 68 + z*10, 7, 2, 19 );
  689. ctx.fillRect( 71 + z*10, 7, 2, 19 );
  690. ctx.fillRect( 74 + z*10, 7, 2, 19 );
  691. //ctx.strokeRect( 43, 1, 8, 8 );
  692. };
  693. };
  694. if( typeof nodeDashboardStatuses[i] === 'undefined' || nodeDashboardStatuses[i] != data.nodes[i].status ){
  695. nodeDashboardStatuses[i] = data.nodes[i].status;
  696. switch( data.nodes[i].status ){
  697. case 0:{
  698. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  699. 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>');
  700. break;
  701. };
  702. case 1:{
  703. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  704. 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>');
  705. break;
  706. };
  707. case 2:{
  708. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  709. 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>');
  710. break;
  711. };
  712. case 3:{
  713. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id );
  714. 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>');
  715. break;
  716. };
  717. case 4:{
  718. if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id, data.nodes[i].targets );
  719. 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>');
  720. break;
  721. };
  722. };
  723. };
  724. };
  725. };
  726. };
  727. if( data.notifications.length > 0 ){
  728. sndExcl.play();
  729. for( i=0; i < data.notifications.length; i++ ){
  730. /*const not = PNotify.alert({
  731. title: 'You Will Receive a Side',
  732. text: 'You have no choice.',
  733. icon: 'fas fa-info-circle',
  734. hide: false,
  735. closer: false,
  736. sticker: false,
  737. destroy: true,
  738. modules: new Map([
  739. ...PNotify.defaultModules,
  740. [PNotifyConfirm, {
  741. confirm: true,
  742. buttons: [{
  743. text: 'Ok',
  744. primary: true,
  745. click: notice => notice.close()
  746. }]
  747. }]
  748. ])
  749. });
  750. */
  751. const l = PNotify.alert({
  752. type: data.notifications[i].type,
  753. text: data.notifications[i].msg,
  754. textTrusted: true,
  755. stack: NotificationStack,
  756. title: data.notifications[i].action,
  757. hide: data.notifications[i].hide,
  758. closer: data.notifications[i].hide,
  759. sticker: data.notifications[i].hide,
  760. destroy: true,
  761. modules: (data.notifications[i].react )? new Map([
  762. ...PNotify.defaultModules,
  763. [PNotifyConfirm, {
  764. confirm: true,
  765. buttons: [{
  766. text: 'Ok',
  767. primary: true,
  768. click: ( notice, value, evt ) => {
  769. notice.close();
  770. if( notice.title!='' ){
  771. resolveDeviceMistmatch( notice.title );
  772. };
  773. }
  774. }]
  775. }]
  776. ]): null
  777. });
  778. /*
  779. if( data.notifications[i].react ){
  780. l.on('click', (notice, value) => {
  781. notice.close();
  782. resolveDeviceMistmatch( notice.title );
  783. });
  784. };
  785. */
  786. lastNotificationID = data.notifications[i].id;
  787. };
  788. };
  789. },
  790. failure: failureAJAXFunction
  791. });
  792. };
  793. function loadDashBoard(){
  794. if( tlInterval!= null ){
  795. window.clearInterval( tlInterval );
  796. tlInterval = null;
  797. timelineObj = null;
  798. };
  799. setUserContent( 0 );
  800. Ext.Ajax.request({
  801. url: '/lib/controller/getDashBoardItems.php',
  802. params: {
  803. SITE: <?=$SiteID;?>,
  804. UID: <?=$UserID;?>,
  805. SID: '<?=$Session;?>'
  806. },
  807. success: function( response, opts ){
  808. var data = Ext.decode(response.responseText);
  809. Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>' );
  810. var tPanel = Ext.getCmp('main_portal');
  811. tPanel.removeAll(true);
  812. nodeDashboardStatuses = new Array();
  813. for( i=0; i < data.length; i++) tPanel.add( data[i] );
  814. tPanel.doLayout();
  815. $('img[data-enlargeable]').addClass('img-enlargeable').click(function() {
  816. var src = $(this).attr('src');
  817. var modal;
  818. function removeModal() {
  819. modal.remove();
  820. $('body').off('keyup.modal-close');
  821. }
  822. modal = $('<div>').css({
  823. background: 'RGBA(0,0,0,.5) url(' + src + ') no-repeat center',
  824. backgroundSize: 'contain',
  825. width: '100%',
  826. height: '100%',
  827. position: 'fixed',
  828. zIndex: '10000',
  829. top: '0',
  830. left: '0',
  831. cursor: 'zoom-out'
  832. }).click(function() {
  833. removeModal();
  834. }).appendTo('body');
  835. //handling ESC
  836. $('body').on('keyup.modal-close', function(e) {
  837. if (e.key === 'Escape') {
  838. removeModal();
  839. }
  840. });
  841. });
  842. tlInterval = window.setInterval( fetchSiteStatus, 333, selectedSite );
  843. },
  844. failure: failureAJAXFunction
  845. });
  846. };
  847. function showServerToolBox( ServerNodeId ){
  848. currentNodeID = ServerNodeId;
  849. if( serverToolBox == null ){
  850. serverToolBox = new Ext.Window({
  851. title: '<?=$Labels->GetLabel('_SERV_CTLPANEL_SHRT_');?>',
  852. modal: true,
  853. width: 400,
  854. height: 328,
  855. closeAction: 'hide',
  856. items:[{
  857. xtype: 'button',
  858. text: 'Restart',
  859. width: '100%',
  860. textAlign: 'left',
  861. iconCls: 'server_btn_restart',
  862. scale: 'large',
  863. iconAlign: 'left',
  864. handler: function(){
  865. doDeviceOperation( currentNodeID, 250,'', true );
  866. }
  867. },{
  868. xtype: 'button',
  869. text: 'Initialize Hardware',
  870. width: '100%',
  871. textAlign: 'left',
  872. iconCls: 'server_btn_hwinit',
  873. scale: 'large',
  874. iconAlign: 'left',
  875. handler: function(){
  876. doDeviceOperation( currentNodeID, 251,'', true );
  877. }
  878. },{
  879. xtype: 'button',
  880. text: 'Sync Time With Browser',
  881. width: '100%',
  882. textAlign: 'left',
  883. iconCls: 'server_btn_timeinit',
  884. scale: 'large',
  885. iconAlign: 'left',
  886. handler: function(){
  887. doDeviceOperation( currentNodeID, 252, ((new Date())/1000), true );
  888. }
  889. }]
  890. });
  891. };
  892. serverToolBox.show();
  893. };
  894. var detectionProfileWindow = null;
  895. var deviceCtrlNode = '';
  896. function showSensorToolBox( NodeID ){
  897. currentNodeID = NodeID;
  898. deviceCtrlNode = NodeID + ':0';
  899. if( detectionProfileWindow == null ){
  900. detectionProfileWindow = new Ext.Window({
  901. title: '<?=$Labels->GetLabel('_DEV_CTLPANEL_SHRT_');?>',
  902. modal: true,
  903. width: 340,
  904. height: 328,
  905. autoScroll: 'auto',
  906. closeAction: 'hide',
  907. resizable: false,
  908. items:[{
  909. xtype: 'panel',
  910. title: '<?=$Labels->GetLabel('_SPEC_FUNCTI_');?>',
  911. height: 95,
  912. id: 'sf_panel',
  913. frame: true,
  914. flex: 1,
  915. layout: 'vbox',
  916. hidden: true,
  917. items:[{
  918. xtype: 'button',
  919. text: 'Resolve Trouble',
  920. width: '100%',
  921. iconCls: 'ctrl_panel_cog',
  922. scale: 'large',
  923. iconAlign: 'left',
  924. handler: function(){
  925. detectionProfileWindow.hide();
  926. resolveDeviceMistmatch( deviceCtrlNode );
  927. }
  928. }]
  929. },{
  930. xtype: 'panel',
  931. title: '<?=$Labels->GetLabel('_DET_GENWORKS_');?>',
  932. height: 193,
  933. frame: true,
  934. flex: 1,
  935. layout: 'vbox',
  936. items:[{
  937. xtype: 'button',
  938. width: '100%',
  939. text: 'Clear Alarm',
  940. scale: 'large',
  941. iconCls: 'ctrl_panel_clean',
  942. iconAlign: 'left',
  943. handler: function(){
  944. clearDeviceEvents( deviceCtrlNode );
  945. }
  946. },{
  947. xtype: 'button',
  948. width: '100%',
  949. text: 'Draw Background',
  950. scale: 'large',
  951. iconCls: 'ctrl_panel_drawscan',
  952. iconAlign: 'left',
  953. handler: function(){
  954. doDeviceOperation( deviceCtrlNode, 3 );
  955. }
  956. },{
  957. xtype: 'button',
  958. width: '100%',
  959. text: 'Force Study Background',
  960. scale: 'large',
  961. iconCls: 'ctrl_panel_study',
  962. iconAlign: 'left',
  963. handler: function(){
  964. doDeviceOperation( deviceCtrlNode, 2 );
  965. }
  966. },{
  967. xtype: 'button',
  968. width: '100%',
  969. buttonAlign: 'left',
  970. //text: '<table width="100%" border=1><tr><td style="text-align:left">Button 1</td></tr></table>',
  971. text: 'Force Reset Sensor',
  972. scale: 'large',
  973. iconCls: 'ctrl_panel_reset',
  974. iconAlign: 'left',
  975. handler: function(){
  976. doDeviceOperation( deviceCtrlNode, 1 );
  977. }
  978. }]
  979. },{
  980. xtype: 'panel',
  981. title: 'Zone Masking Management',
  982. height: 140,
  983. frame: true,
  984. flex: 1,
  985. layout: 'vbox',
  986. items:[{
  987. xtype: 'button',
  988. text: 'Mask Editor',
  989. id: 'DMED',
  990. width: '100%',
  991. handler: function(){
  992. showMaskEditor( true, 0, deviceCtrlNode );
  993. }
  994. },{
  995. xtype: 'spacer',
  996. height: 6
  997. },{
  998. xtype: 'panel',
  999. frame: false,
  1000. border: false,
  1001. flex: 1,
  1002. width: '100%',
  1003. height: 40,
  1004. layout: 'hbox',
  1005. items:[{
  1006. xtype: 'button',
  1007. enableToggle: true,
  1008. width: '20%',
  1009. scale: 'large',
  1010. id: 'mz_btn_0',
  1011. iconCls: 'mask_zone1_btn',
  1012. iconAlign: 'top',
  1013. pressed: false,
  1014. disabled: true,
  1015. handler: function(){
  1016. Ext.getCmp('MAPPLY').enable();
  1017. }
  1018. },{
  1019. xtype: 'button',
  1020. enableToggle: true,
  1021. width: '20%',
  1022. scale: 'large',
  1023. id: 'mz_btn_1',
  1024. iconCls: 'mask_zone2_btn',
  1025. iconAlign: 'top',
  1026. pressed: false,
  1027. disabled: true,
  1028. handler: function(){
  1029. Ext.getCmp('MAPPLY').enable();
  1030. }
  1031. },{
  1032. xtype: 'button',
  1033. enableToggle: true,
  1034. width: '20%',
  1035. scale: 'large',
  1036. id: 'mz_btn_2',
  1037. iconCls: 'mask_zone3_btn',
  1038. iconAlign: 'top',
  1039. pressed: false,
  1040. disabled: true,
  1041. handler: function(){
  1042. Ext.getCmp('MAPPLY').enable();
  1043. }
  1044. },{
  1045. xtype: 'button',
  1046. enableToggle: true,
  1047. width: '20%',
  1048. scale: 'large',
  1049. id: 'mz_btn_3',
  1050. iconCls: 'mask_zone4_btn',
  1051. iconAlign: 'top',
  1052. pressed: false,
  1053. disabled: true,
  1054. handler: function(){
  1055. Ext.getCmp('MAPPLY').enable();
  1056. }
  1057. },{
  1058. xtype: 'button',
  1059. enableToggle: true,
  1060. width: '20%',
  1061. scale: 'large',
  1062. id: 'mz_btn_4',
  1063. iconCls: 'mask_zone5_btn',
  1064. iconAlign: 'top',
  1065. pressed: false,
  1066. disabled: true,
  1067. handler: function(){
  1068. Ext.getCmp('MAPPLY').enable();
  1069. }
  1070. }]
  1071. },{
  1072. xtype: 'spacer',
  1073. height: 6
  1074. },{
  1075. xtype: 'button',
  1076. text: 'Apply Zone Masks',
  1077. id: 'MAPPLY',
  1078. disabled: true,
  1079. width: '100%',
  1080. handler: function(){
  1081. }
  1082. }]
  1083. },{
  1084. xtype: 'panel',
  1085. title: '<?=$Labels->GetLabel('_DET_SENSITIVITY_');?>',
  1086. height: 95,
  1087. frame: true,
  1088. flex: 1,
  1089. layout: 'hbox',
  1090. items:[<?php
  1091. if( $CUser->Data['access']>4 ){
  1092. ?>{
  1093. xtype: 'button',
  1094. text: 'Factory',
  1095. id: 'DDSPBTN0',
  1096. width: 80,
  1097. iconCls: 'detection_btn_factory',
  1098. enableToggle: true,
  1099. toggleGroup: 'det_sens_btn_grp',
  1100. disabled: true,
  1101. scale: 'large',
  1102. iconAlign: 'top'
  1103. },<?php
  1104. };
  1105. ?>{
  1106. xtype: 'button',
  1107. text: 'Low',
  1108. id: 'DDSPBTN1',
  1109. width: 80,
  1110. iconCls: 'detection_btn_low',
  1111. enableToggle: true,
  1112. toggleGroup: 'det_sens_btn_grp',
  1113. disabled: true,
  1114. scale: 'large',
  1115. iconAlign: 'top'
  1116. },{
  1117. xtype: 'button',
  1118. text: 'Meduim',
  1119. id: 'DDSPBTN2',
  1120. width: 80,
  1121. iconCls: 'detection_btn_medium',
  1122. enableToggle: true,
  1123. toggleGroup: 'det_sens_btn_grp',
  1124. disabled: true,
  1125. scale: 'large',
  1126. iconAlign: 'top'
  1127. },{
  1128. xtype: 'button',
  1129. text: 'High',
  1130. id: 'DDSPBTN3',
  1131. width: 80,
  1132. iconCls: 'detection_btn_high',
  1133. enableToggle: true,
  1134. toggleGroup: 'det_sens_btn_grp',
  1135. disabled: true,
  1136. scale: 'large',
  1137. iconAlign: 'top'
  1138. }]
  1139. }]
  1140. });
  1141. };
  1142. detectionProfileWindow.show();
  1143. var myMask = new Ext.LoadMask( detectionProfileWindow.getEl(), {msg:"Please wait..."});
  1144. myMask.show();
  1145. Ext.Ajax.request({
  1146. url: '/lib/controller/getDetectionProfile.php',
  1147. params: {
  1148. SITE: SelectedSite,
  1149. UID: <?=$UserID;?>,
  1150. SID: '<?=$Session;?>',
  1151. NID: NodeID
  1152. },
  1153. success: function( response, opts ){
  1154. var data = Ext.decode( response.responseText );
  1155. myMask.hide();
  1156. detectionProfileWindow.setTitle( '['+data.name + '] <?=$Labels->GetLabel('_DEV_CTLPANEL_SHRT_');?>');
  1157. if(data.masks_array != 'undefined' ){
  1158. for( i = 0; i < 5; i++ ){
  1159. var cE = Ext.getCmp('mz_btn_'+i );
  1160. if( data.masks_array[i]=='E'){
  1161. cE.enable();
  1162. cE.toggle( true, true );
  1163. } else {
  1164. cE.toggle( false, true );
  1165. if( data.masks_array[i]=='D' ){
  1166. cE.enable();
  1167. } else {
  1168. cE.disable();
  1169. };
  1170. };
  1171. };
  1172. };
  1173. if( data.data_status == 3 ){
  1174. if( data.profiles.length > 1 ){
  1175. for( i=0; i < data.profiles.length; i++ ){
  1176. Ext.getCmp('DDSPBTN'+i ).enable();
  1177. if( i == data.profile_id ) Ext.getCmp('DDSPBTN'+i ).toggle( true, false );
  1178. };
  1179. } else {
  1180. Ext.getCmp('DDSPBTN0').toggle( true, false );
  1181. Ext.getCmp('DDSPBTN0').disable();
  1182. };
  1183. } else if( data.data_status == 4 ){
  1184. Ext.getCmp('sf_panel').show();
  1185. };
  1186. detectionProfileWindow.doLayout();
  1187. },
  1188. failure: failureAJAXFunction
  1189. });
  1190. };