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.

1170 lines
36 KiB

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