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.

762 lines
21 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. function Pie(cx, cy, radius, data) {
  3. var decimals = 4;
  4. var total = 0;
  5. var offset = 0;
  6. var offset2;
  7. var arr = [];
  8. var x;
  9. var y;
  10. var la;
  11. var radians;
  12. for (var i = 0; i < data.length; i++)
  13. total += data[i].value;
  14. for (var i = 0; i < data.length; i++) {
  15. var item = data[i];
  16. var tmp = {};
  17. tmp.index = i;
  18. tmp.value = item.value;
  19. radians = ((((item.value / total) * 360) * Math.PI) / 180).floor(decimals);
  20. offset2 = ((offset / total) * 360).floor(decimals);
  21. tmp.data = item;
  22. x = (cx + Math.sin(radians) * radius).floor(decimals);
  23. y = (cy - Math.cos(radians) * radius).floor(decimals);
  24. la = radians > Math.PI ? 1 : 0;
  25. // Arc
  26. 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);
  27. tmp.transform = 'rotate({0}, {1}, {2})'.format(offset2, cx, cy);
  28. // Text
  29. x = (cx + Math.sin(radians / 2) * radius / 2).floor(decimals);
  30. y = (cy - Math.cos(radians / 2) * radius / 2).floor(decimals);
  31. tmp.text = 'x="{0}" y="{1}" transform="rotate({2},{0},{1})"'.format(x, y, -offset2);
  32. offset += item.value;
  33. arr.push(tmp);
  34. }
  35. return arr;
  36. }
  37. function Donut(cx, cy, radius, data) {
  38. function arcradius(cx, cy, radius, degrees) {
  39. var radians = (degrees - 90) * Math.PI / 180.0;
  40. return { x: cx + (radius * Math.cos(radians)), y: cy + (radius * Math.sin(radians)) };
  41. }
  42. var decimals = 4;
  43. var total = 0;
  44. var arr = [];
  45. var beg = 0;
  46. var end = 0;
  47. var count = 0;
  48. var half = radius / 2;
  49. var midpoint = radius / 2.4;
  50. for (var i = 0; i < data.length; i++)
  51. total += data[i].value;
  52. for (var i = 0; i < data.length; i++) {
  53. var item = data[i];
  54. var tmp = {};
  55. //var p = (((item.value + 1) / total) * 100).floor( 2 );
  56. var p = Math.floor(((item.value + 1) / total) * 100);
  57. count += p;
  58. if (i === length - 1 && count < 100)
  59. p = p + (100 - count);
  60. end = beg + ((360 / 100) * p);
  61. tmp.index = i;
  62. tmp.value = item.value;
  63. tmp.data = item;
  64. var b = arcradius(cx, cy, radius, end);
  65. var e = arcradius(cx, cy, radius, beg);
  66. var la = (end - beg) <= 180 ? 0 : 1;
  67. 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(' ');
  68. arr.push(tmp);
  69. beg = end;
  70. }
  71. return arr;
  72. }
  73. //Pie Chart Usage
  74. /*
  75. var svg = $('#yoursvgelement');
  76. var data = [{ value: 33 }, { value: 20 }, { value: 80 }, { value: 48 }];
  77. var centerX = 300;
  78. var centerY = 300;
  79. var radius = 250;
  80. var color = ['#F6BB42', '#8CC152', '#3BAFDA', '#967ADC', '#DA4453'];
  81. var arr = Pie(centerX, centerY, radius, data);
  82. for (var i = 0; i < arr.length; i++) {
  83. var item = arr[i];
  84. 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]));
  85. }
  86. */
  87. // Donut Chart Usage
  88. /*
  89. var svg = $('#yoursvgelement');
  90. var data = [{ value: 33 }, { value: 20 }, { value: 80 }, { value: 48 }];
  91. var centerX = 300;
  92. var centerY = 300;
  93. var radius = 250;
  94. var color = ['#F6BB42', '#8CC152', '#3BAFDA', '#967ADC', '#DA4453'];
  95. var arr = Donut(centerX, centerY, radius, data);
  96. for (var i = 0; i < arr.length; i++) {
  97. var item = arr[i];
  98. svg.asvg('<g><path d="{0}" stroke="{1}" fill="none" stroke-width="50" /></g>'.format(item.d, color[i]));
  99. }
  100. */
  101. function makePtzMove( me ){
  102. var name = me.target.id;
  103. Ext.Ajax.request({
  104. url: '/lib/controller/camMakeMove.php',
  105. params: {
  106. SITE: <?=$SiteID;?>,
  107. UID: <?=$UserID;?>,
  108. SID: '<?=$Session;?>',
  109. CMD: name
  110. },
  111. //success: function( response, opts ){
  112. //},
  113. failure: failureAJAXFunction
  114. });
  115. };
  116. function ptzCtrl( a ){
  117. };
  118. function makePtzStop( me ){
  119. var name = me.target.id;
  120. Ext.Ajax.request({
  121. url: '/lib/controller/camStop.php',
  122. params: {
  123. SITE: <?=$SiteID;?>,
  124. UID: <?=$UserID;?>,
  125. SID: '<?=$Session;?>',
  126. CMD: name
  127. },
  128. //success: function( response, opts ){
  129. //},
  130. failure: failureAJAXFunction
  131. });
  132. };
  133. function fullScreen( id ){
  134. // if already full screen; exit
  135. // else go fullscreen
  136. if(
  137. document.fullscreenElement ||
  138. document.webkitFullscreenElement ||
  139. document.mozFullScreenElement ||
  140. document.msFullscreenElement
  141. ){
  142. if( document.exitFullscreen ){
  143. document.exitFullscreen();
  144. }else if( document.mozCancelFullScreen ){
  145. document.mozCancelFullScreen();
  146. }else if( document.webkitExitFullscreen ){
  147. document.webkitExitFullscreen();
  148. }else if( document.msExitFullscreen ){
  149. document.msExitFullscreen();
  150. };
  151. }else{
  152. //element = $('#container').get(0);
  153. var element = document.getElementById( id ); //Ext.getCmp( id );
  154. if( element.requestFullscreen ){
  155. element.requestFullscreen();
  156. }else if( element.mozRequestFullScreen ){
  157. element.mozRequestFullScreen();
  158. }else if( element.webkitRequestFullscreen ){
  159. element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  160. }else if( element.msRequestFullscreen ){
  161. element.msRequestFullscreen();
  162. };
  163. };
  164. };
  165. function updateDashBoardItemLayout( id, x, y ){
  166. Ext.Ajax.request({
  167. url: '/lib/controller/updateDashBoardItems.php',
  168. params: {
  169. SITE: <?=$SiteID;?>,
  170. UID: <?=$UserID;?>,
  171. SID: '<?=$Session;?>',
  172. PANEL: id,
  173. X: x,
  174. Y: y
  175. },
  176. success: function( response, opts ){
  177. //var data = Ext.decode(response.responseText);
  178. //var tPanel = Ext.getCmp('main_portal');
  179. //tPanel.removeAll(true);
  180. //for( i=0; i < data.length; i++) tPanel.add( data[i] );
  181. //tPanel.doLayout();
  182. },
  183. failure: failureAJAXFunction
  184. });
  185. };
  186. var drawZoomLevels = Array();
  187. function cleanupDraw( a ){
  188. var canvas = document.getElementById('targ_canvas_'+a );
  189. var ctx = canvas.getContext('2d');
  190. var img = document.getElementById('draw_img_'+a );
  191. ctx.drawImage( img, 0, 0 );
  192. canvas.style='display: block;';
  193. img.style='display: none;';
  194. };
  195. function DrawTargets( k, b ){
  196. var canvas = document.getElementById('targ_canvas_'+k );
  197. var ctx = canvas.getContext('2d');
  198. var img = document.getElementById('draw_img_'+k );
  199. ctx.drawImage( img, 0, 0 );
  200. canvas.style='display: block;';
  201. img.style='display: none;';
  202. for( var i=0; i< b.length; i++ ){
  203. switch( drawZoomLevels[k] ){
  204. case 12:{
  205. if( b[i].digital < 256 ){
  206. var cc = 255 - i ;//* ( 255 / 33 );
  207. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  208. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  209. //ctx.strokeStyle = "#FF0000";
  210. var r = (196 * b[i].digital)/ 512;
  211. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  212. var x = 100 + Math.cos( a ) * r;
  213. var y = 100 + Math.sin( a ) * r;
  214. ctx.fillRect( x, y, 24, 24 );
  215. };
  216. break;
  217. };
  218. case 25:{
  219. if( b[i].digital < 512 ){
  220. var cc = 255 - i ;//* ( 255 / 33 );
  221. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  222. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  223. //ctx.strokeStyle = "#FF0000";
  224. var r = (196 * b[i].digital)/ 1024;
  225. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  226. var x = 100 + Math.cos( a ) * r;
  227. var y = 100 + Math.sin( a ) * r;
  228. ctx.fillRect( x, y, 12, 12 );
  229. };
  230. break;
  231. };
  232. case 50:{
  233. if( b[i].digital < 1024 ){
  234. var cc = 255 - i ;//* ( 255 / 33 );
  235. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  236. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  237. //ctx.strokeStyle = "#FF0000";
  238. var r = (196 * b[i].digital) / 2048;
  239. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  240. var x = 100 + Math.cos( a ) * r;
  241. var y = 100 + Math.sin( a ) * r;
  242. ctx.fillRect( x, y, 6, 6 );
  243. };
  244. break;
  245. };
  246. case 100:{
  247. var cc = 255 - i ;//* ( 255 / 33 );
  248. //ctx.fillStyle = "#" + cc.toString(16) + "0000";
  249. ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")";
  250. //ctx.strokeStyle = "#FF0000";
  251. var r = (196 * b[i].digital)/ 4096;
  252. var a = -1.0 * b[i].az * ( Math.PI / 180 );
  253. var x = 100 + Math.cos( a ) * r;
  254. var y = 100 + Math.sin( a ) * r;
  255. ctx.fillRect( x, y, 3, 3 );
  256. break;
  257. };
  258. };
  259. };
  260. };
  261. var lastNotificationID = 0;
  262. function setDonatStatus( id , value ){
  263. var val1D = document.getElementById('donut'+id+'-segment1');
  264. var val2D = document.getElementById('donut'+id+'-segment2');
  265. var val3D = document.getElementById('donut'+id+'-segment3');
  266. var val1 = (value>-1)?value:0;
  267. var val2 = (value>-1)?100 - val1:0;//data.nodes[i].cpu5 * 100;
  268. var val3 = (value>-1)?0:100;//data.nodes[i].cpu15 * 100;
  269. var totalValue = document.getElementById('totalValue'+id);
  270. var total = val1+val2+val3;
  271. var per1 = val1/total*100;
  272. var per2 = val2/total*100;
  273. var per3 = val3/total*100;
  274. var offset = 25;
  275. if( ( val1 != undefined ) && ( value > -1 ) ){
  276. totalValue.textContent = val1+'%';
  277. } else {
  278. totalValue.textContent = 'No Data';
  279. };
  280. val1D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  281. val1D.style.strokeDasharray = per1+" "+(100-per1);
  282. val1D.style.strokeDashoffset = offset;
  283. val2D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  284. val2D.style.strokeDasharray = per2+" "+(100-per2);
  285. val2D.style.strokeDashoffset = 100-per1+offset;
  286. val3D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out";
  287. val3D.style.strokeDasharray = per3+" "+(100-per3);
  288. val3D.style.strokeDashoffset = 100-(per1+per2)+offset;
  289. };
  290. function fetchSiteStatus(){
  291. Ext.Ajax.request({
  292. url: '/lib/controller/getStatus.php',
  293. params: {
  294. SITE: <?=$SiteID;?>,
  295. LNID: lastNotificationID,
  296. SPID: ServerPID,
  297. UID: <?=$UserID;?>,
  298. SID: '<?=$Session;?>'
  299. },
  300. success: function( response, opts ){
  301. var data = Ext.decode(response.responseText);
  302. if( data.nodes.length > 0 ){
  303. for( i=0; i < data.nodes.length; i++ ){
  304. if( data.nodes[i].type == 0 ){
  305. //Handle Server Status
  306. if ( data.nodes[i].status ){
  307. setDonatStatus( '' , data.nodes[i].cpu5 );
  308. setDonatStatus( '1' , data.nodes[i].mem );
  309. setDonatStatus( '2' , data.nodes[i].disk );
  310. } else {
  311. setDonatStatus( '' , -1 );
  312. setDonatStatus( '1' , -1 );
  313. setDonatStatus( '2' , -1 );
  314. };
  315. };
  316. if( data.nodes[i].type > 9 && data.nodes[i].type < 14 ){
  317. var iel = document.getElementById('img-'+data.nodes[i].id );
  318. if( !data.nodes[i].valid ){
  319. if( iel.src != "/style/assets/no-signal.png" ) iel.src = "/style/assets/no-signal.png";
  320. } else {
  321. if( data.nodes[i].src != iel.src ) iel.src = data.nodes[i].src;
  322. };//else {
  323. //https://man7.org/linux/man-pages/man2/getrusage.2.html
  324. //https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode
  325. //https://stackoverflow.com/questions/13465073/how-to-catch-an-exception-from-image-onload
  326. //if( data.nodes[i].valid && ServerIsOnline ){
  327. //iel.src = "/style/assets/no-signal.png";
  328. /*
  329. iel.onerror = function(){
  330. //alert("IMG onerror!");
  331. iel.troubled = true;
  332. };
  333. iel.decode()
  334. .then(() => {
  335. //document.body.appendChild(img);
  336. })
  337. .catch((encodingError) => {
  338. //alert('Stream Ended!');
  339. iel.troubled = true;
  340. })
  341. */
  342. //};
  343. //};
  344. };
  345. var tt = Ext.getCmp('status_'+data.nodes[i].id );
  346. if( tt != undefined ){
  347. switch( data.nodes[i].status ){
  348. case 0:{
  349. cleanupDraw( data.nodes[i].id );
  350. 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>');
  351. break;
  352. };
  353. case 1:{
  354. cleanupDraw( data.nodes[i].id );
  355. 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>');
  356. break;
  357. };
  358. case 2:{
  359. cleanupDraw( data.nodes[i].id );
  360. 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>');
  361. break;
  362. };
  363. case 3:{
  364. cleanupDraw( data.nodes[i].id );
  365. 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>');
  366. break;
  367. };
  368. case 4:{
  369. DrawTargets( data.nodes[i].id, data.nodes[i].targets );
  370. 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>');
  371. break;
  372. };
  373. };
  374. };
  375. };
  376. };
  377. if( data.notifications.length > 0 ){
  378. sndExcl.play();
  379. for( i=0; i < data.notifications.length; i++ ){
  380. /*const not = PNotify.alert({
  381. title: 'You Will Receive a Side',
  382. text: 'You have no choice.',
  383. icon: 'fas fa-info-circle',
  384. hide: false,
  385. closer: false,
  386. sticker: false,
  387. destroy: true,
  388. modules: new Map([
  389. ...PNotify.defaultModules,
  390. [PNotifyConfirm, {
  391. confirm: true,
  392. buttons: [{
  393. text: 'Ok',
  394. primary: true,
  395. click: notice => notice.close()
  396. }]
  397. }]
  398. ])
  399. });
  400. */
  401. const l = PNotify.alert({
  402. type: data.notifications[i].type,
  403. text: data.notifications[i].msg,
  404. textTrusted: true,
  405. stack: NotificationStack,
  406. title: data.notifications[i].action,
  407. hide: data.notifications[i].hide,
  408. closer: data.notifications[i].hide,
  409. sticker: data.notifications[i].hide,
  410. destroy: true,
  411. modules: (data.notifications[i].react )? new Map([
  412. ...PNotify.defaultModules,
  413. [PNotifyConfirm, {
  414. confirm: true,
  415. buttons: [{
  416. text: 'Ok',
  417. primary: true,
  418. click: ( notice, value, evt ) => {
  419. notice.close();
  420. if( notice.title!='' ){
  421. resolveDeviceMistmatch( notice.title );
  422. };
  423. }
  424. }]
  425. }]
  426. ]): null
  427. });
  428. /*
  429. if( data.notifications[i].react ){
  430. l.on('click', (notice, value) => {
  431. notice.close();
  432. resolveDeviceMistmatch( notice.title );
  433. });
  434. };
  435. */
  436. lastNotificationID = data.notifications[i].id;
  437. };
  438. };
  439. },
  440. failure: failureAJAXFunction
  441. });
  442. };
  443. function loadDashBoard(){
  444. if( tlInterval!= null ){
  445. window.clearInterval( tlInterval );
  446. tlInterval = null;
  447. timelineObj = null;
  448. };
  449. Ext.Ajax.request({
  450. url: '/lib/controller/getDashBoardItems.php',
  451. params: {
  452. SITE: <?=$SiteID;?>,
  453. UID: <?=$UserID;?>,
  454. SID: '<?=$Session;?>'
  455. },
  456. success: function( response, opts ){
  457. var data = Ext.decode(response.responseText);
  458. Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_SYS_DASHBOARD_');?>' );
  459. var tPanel = Ext.getCmp('main_portal');
  460. tPanel.removeAll(true);
  461. for( i=0; i < data.length; i++) tPanel.add( data[i] );
  462. tPanel.doLayout();
  463. $('img[data-enlargeable]').addClass('img-enlargeable').click(function() {
  464. var src = $(this).attr('src');
  465. var modal;
  466. function removeModal() {
  467. modal.remove();
  468. $('body').off('keyup.modal-close');
  469. }
  470. modal = $('<div>').css({
  471. background: 'RGBA(0,0,0,.5) url(' + src + ') no-repeat center',
  472. backgroundSize: 'contain',
  473. width: '100%',
  474. height: '100%',
  475. position: 'fixed',
  476. zIndex: '10000',
  477. top: '0',
  478. left: '0',
  479. cursor: 'zoom-out'
  480. }).click(function() {
  481. removeModal();
  482. }).appendTo('body');
  483. //handling ESC
  484. $('body').on('keyup.modal-close', function(e) {
  485. if (e.key === 'Escape') {
  486. removeModal();
  487. }
  488. });
  489. });
  490. tlInterval = window.setInterval( fetchSiteStatus, 333, selectedSite );
  491. },
  492. failure: failureAJAXFunction
  493. });
  494. };
  495. var serverToolBox = null;
  496. function showServerToolBox( ServerNodeId ){
  497. if( serverToolBox == null ){
  498. serverToolBox = new Ext.Window({
  499. title: '<?=$Labels->GetLabel('_SERV_CTLPANEL_SHRT_');?>',
  500. modal: true,
  501. width: 400,
  502. height: 328,
  503. closeAction: 'hide',
  504. items:[{
  505. xtype: 'button',
  506. text: 'Restart',
  507. width: '100%',
  508. textAlign: 'left',
  509. iconCls: 'server_btn_restart',
  510. scale: 'large',
  511. iconAlign: 'left'
  512. },{
  513. xtype: 'button',
  514. text: 'Clear Site',
  515. width: '100%',
  516. textAlign: 'left',
  517. iconCls: 'server_btn_restart',
  518. scale: 'large',
  519. iconAlign: 'left'
  520. }]
  521. });
  522. };
  523. serverToolBox.show();
  524. };
  525. var detectionProfileWindow = null;
  526. var deviceCtrlNode = '';
  527. function showDetectionProfile( NodeID ){
  528. deviceCtrlNode = NodeID + ':0';
  529. <?php if( $CUser->Data['access']>4 ) $ColSpan = 4; else $ColSpan = 3; ?>
  530. if( detectionProfileWindow == null ){
  531. detectionProfileWindow = new Ext.Window({
  532. title: '<?=$Labels->GetLabel('_DEV_CTLPANEL_SHRT_');?>',
  533. modal: true,
  534. width: <?=$ColSpan*80+16;?>,
  535. height: 328,
  536. closeAction: 'hide',
  537. items:[]
  538. });
  539. };
  540. Ext.Ajax.request({
  541. url: '/lib/controller/getDetectionProfile.php',
  542. params: {
  543. SITE: SelectedSite,
  544. UID: <?=$UserID;?>,
  545. SID: '<?=$Session;?>',
  546. NID: NodeID
  547. },
  548. success: function( response, opts ){
  549. var data = Ext.decode( response.responseText );
  550. detectionProfileWindow.setTitle( '['+data.name + '] <?=$Labels->GetLabel('_DEV_CTLPANEL_SHRT_');?>');
  551. detectionProfileWindow.removeAll( true );
  552. if( data.data_status == 3 ){
  553. detectionProfileWindow.add({
  554. xtype: 'panel',
  555. layout: 'table',
  556. layoutConfig: {
  557. columns: <?=$ColSpan;?>
  558. },
  559. items:[{
  560. xtype: 'spacer',
  561. height: 30,
  562. style: {
  563. marginTop: '13px'
  564. },
  565. html: '<center><?=$Labels->GetLabel('_DET_SENSITIVITY_');?></center>',
  566. colspan: <?=$ColSpan;?>
  567. },<?php
  568. if( $CUser->Data['access']>4 ){
  569. ?>{
  570. xtype: 'button',
  571. text: 'Factory',
  572. id: 'DDSPBTN0',
  573. width: 80,
  574. iconCls: 'detection_btn_factory',
  575. enableToggle: true,
  576. toggleGroup: 'det_sens_btn_grp',
  577. disabled: true,
  578. scale: 'large',
  579. iconAlign: 'top'
  580. },<?php
  581. };
  582. ?>{
  583. xtype: 'button',
  584. text: 'Low',
  585. id: 'DDSPBTN1',
  586. width: 80,
  587. iconCls: 'detection_btn_low',
  588. enableToggle: true,
  589. toggleGroup: 'det_sens_btn_grp',
  590. disabled: true,
  591. scale: 'large',
  592. iconAlign: 'top'
  593. },{
  594. xtype: 'button',
  595. text: 'Meduim',
  596. id: 'DDSPBTN2',
  597. width: 80,
  598. iconCls: 'detection_btn_medium',
  599. enableToggle: true,
  600. toggleGroup: 'det_sens_btn_grp',
  601. disabled: true,
  602. scale: 'large',
  603. iconAlign: 'top'
  604. },{
  605. xtype: 'button',
  606. text: 'High',
  607. id: 'DDSPBTN3',
  608. width: 80,
  609. iconCls: 'detection_btn_high',
  610. enableToggle: true,
  611. toggleGroup: 'det_sens_btn_grp',
  612. disabled: true,
  613. scale: 'large',
  614. iconAlign: 'top'
  615. }]
  616. });
  617. for( i=0; i < data.profiles.length; i++ ){
  618. Ext.getCmp('DDSPBTN'+data.profiles[i] ).enable();
  619. if( i == data.profile_id ) Ext.getCmp('DDSPBTN'+data.profiles[i] ).toggle();
  620. };
  621. } else if( data.data_status == 4 ){
  622. detectionProfileWindow.add({
  623. xtype: 'panel',
  624. //layout: 'fit',
  625. //layoutConfig: {
  626. // columns: 3
  627. //},
  628. items:[{
  629. xtype: 'spacer',
  630. height: 40,
  631. //colspan: 3,
  632. style: {
  633. marginTop: '20px'
  634. },
  635. html: '<center><?=$Labels->GetLabel('_DET_SENSITIVITY_');?></center>',
  636. }<?php
  637. if( $CUser->Data['access']>4 ){
  638. ?>,{
  639. xtype: 'button',
  640. text: 'Resolve Trouble',
  641. width: '100%',
  642. //colspan: 3,
  643. iconCls: 'ctrl_panel_cog',
  644. scale: 'large',
  645. iconAlign: 'left',
  646. handler: function(){
  647. detectionProfileWindow.hide();
  648. resolveDeviceMistmatch( deviceCtrlNode );
  649. }
  650. }<?php
  651. };
  652. ?>]
  653. });
  654. };
  655. detectionProfileWindow.add({
  656. xtype: 'spacer',
  657. height: 30,
  658. style: {
  659. marginTop: '13px'
  660. },
  661. html: '<center><?=$Labels->GetLabel('_DET_GENWORKS_');?></center>',
  662. });
  663. detectionProfileWindow.add({
  664. xtype: 'button',
  665. width: '100%',
  666. text: 'Clear Alarm',
  667. scale: 'large',
  668. iconCls: 'ctrl_panel_clean',
  669. iconAlign: 'left'
  670. });
  671. detectionProfileWindow.add({
  672. xtype: 'button',
  673. width: '100%',
  674. text: 'Draw Background',
  675. scale: 'large',
  676. iconCls: 'ctrl_panel_drawscan',
  677. iconAlign: 'left',
  678. handler: function(){
  679. doDeviceOperation( deviceCtrlNode, 3 );
  680. }
  681. });
  682. detectionProfileWindow.add({
  683. xtype: 'button',
  684. width: '100%',
  685. text: 'Force Study Background',
  686. scale: 'large',
  687. iconCls: 'ctrl_panel_study',
  688. iconAlign: 'left'
  689. });
  690. detectionProfileWindow.add({
  691. xtype: 'button',
  692. width: '100%',
  693. buttonAlign: 'left',
  694. //text: '<table width="100%" border=1><tr><td style="text-align:left">Button 1</td></tr></table>',
  695. text: 'Force Reset Sensor',
  696. scale: 'large',
  697. iconCls: 'ctrl_panel_reset',
  698. iconAlign: 'left',
  699. handler: function(){
  700. doDeviceOperation( deviceCtrlNode, 1 );
  701. }
  702. });
  703. detectionProfileWindow.show();
  704. },
  705. failure: failureAJAXFunction
  706. });
  707. };