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.

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