// var serverToolBox = null; var currentNodeID = 0; //import * as THREE from 'three'; //let camera, scene, renderer; var l3dMapOverlayTexture = new THREE.TextureLoader().load( '/lib/controller/data/assets/images/mask_3d.png' ); var l3dMapOverlayMaterial = new THREE.MeshBasicMaterial( { map: l3dMapOverlayTexture, alphaTest: 0.7 } ); var l3dMapOverlayGeometry = new THREE.SphereGeometry( 490, 60, 40 ); // invert the geometry on the x-axis so that all of the faces point inward l3dMapOverlayGeometry.scale( -1, 1, 1 ); var l3dMapOverlayMesh = new THREE.Mesh( l3dMapOverlayGeometry, l3dMapOverlayMaterial ); function addl3dTarget( id, radius, az, el, color = 0xff0000 ){ if( id > 0 ){ var target = {}; target.geometry = new THREE.BoxGeometry( 10, 10, 10 ); //target.geometry = new THREE.OctahedronGeometry({ radius : 20 }); //target.geometry.translate( x, y, z ); // Turn back into Cartesian coordinates var fi = (Math.PI/2) - el; var x = radius * Math.sin( fi) * Math.cos( az ); var y = radius * Math.sin( fi ) * Math.sin( az ); var z = radius * Math.cos( fi ); //alert( "Cords: "+x+" "+y+" "+z+" An:"+az+" "+el); //target.geometry.position.set( x, y, z ); //translate( x, y, z ); target.material = new THREE.MeshBasicMaterial( {color: color} ); target.mesh = new THREE.Mesh( target.geometry, target.material ); nodeTHREEviewers[id].scene.add( target.mesh ); target.mesh.position.set( x, z, y ); nodeTHREEviewers[id].targets.push( target ); }; }; function cleanup3DDraw( id ){ if( typeof nodeTHREEviewers[id] !== 'undefined' ){ if( typeof nodeTHREEviewers[id].targets !== 'undefined' ){ for( var z=0; z < nodeTHREEviewers[id].targets.length; z++ ){ nodeTHREEviewers[id].scene.remove( nodeTHREEviewers[id].targets[z].mesh ); delete nodeTHREEviewers[id].targets[z].mesh; delete nodeTHREEviewers[id].targets[z].material; delete nodeTHREEviewers[id].targets[z].geometry; delete nodeTHREEviewers[id].targets[z]; }; nodeTHREEviewers[id].targets = []; //nodeTHREEviewers[id].renderer.render( nodeTHREEviewers[id].scene, nodeTHREEviewers[id].camera ); }; }; }; function Draw3DTargets( k, b ){ cleanup3DDraw( k ); for( var z = 0; z < b.length; z++ ){ var az = b[z].az * ( Math.PI/180.0 ); var el = b[z].el * ( Math.PI/180.0 ); //addl3dTarget( k, b[z].range, az, el, b[z].color ); addl3dTarget( k, 280, az, el, b[z].color ); }; }; let isUserInteracting = false, onPointerDownMouseX = 0, onPointerDownMouseY = 0, lon = 0, onPointerDownLon = 0, lat = 0, onPointerDownLat = 0, phi = 0, theta = 0; function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize( window.innerWidth, window.innerHeight ); }; function onPointerDown( event ) { if ( event.isPrimary === false ) return; isUserInteracting = true; onPointerDownMouseX = event.clientX; onPointerDownMouseY = event.clientY; onPointerDownLon = lon; onPointerDownLat = lat; document.addEventListener( 'pointermove', onPointerMove ); document.addEventListener( 'pointerup', onPointerUp ); }; function onPointerMove( event ) { if ( event.isPrimary === false ) return; lon = ( onPointerDownMouseX - event.clientX ) * 0.1 + onPointerDownLon; lat = ( event.clientY - onPointerDownMouseY ) * 0.1 + onPointerDownLat; }; function onPointerUp() { if ( event.isPrimary === false ) return; isUserInteracting = false; document.removeEventListener( 'pointermove', onPointerMove ); document.removeEventListener( 'pointerup', onPointerUp ); }; function onDocumentMouseWheel( event ) { var id = event.currentTarget.myVID; if( id > 0 ){ const fov = nodeTHREEviewers[id].camera.fov + event.deltaY * 0.05; nodeTHREEviewers[id].camera.fov = THREE.MathUtils.clamp( fov, 10, 75 ); nodeTHREEviewers[id].camera.updateProjectionMatrix(); }; }; function reload3dTexture( id ){ if( typeof nodeTHREEviewers[id] !== 'undefined' ){ stopAnimation(); //while( nodeTHREEviewers[id].scene.children.length > 0){ // nodeTHREEviewers[id].scene.remove(nodeTHREEviewers[id].scene.children[0]); //}; nodeTHREEviewers[id].scene.remove( nodeTHREEviewers[id].mesh ); //nodeTHREEviewers[id].mesh.geometry.dispose(); //nodeTHREEviewers[id].mesh.material.dispose(); delete nodeTHREEviewers[id].mesh; delete nodeTHREEviewers[id].material; delete nodeTHREEviewers[id].texture; delete nodeTHREEviewers[id].geometry; nodeTHREEviewers[id].geometry = new THREE.SphereGeometry( 500, 60, 40 ); nodeTHREEviewers[id].geometry.scale( -1, 1, 1 ); nodeTHREEviewers[id].texture = new THREE.TextureLoader().load( '/lib/controller/getDeviceDraw.php?NID='+id ); nodeTHREEviewers[id].material = new THREE.MeshBasicMaterial( { map: nodeTHREEviewers[id].texture } ); nodeTHREEviewers[id].mesh = new THREE.Mesh( nodeTHREEviewers[id].geometry, nodeTHREEviewers[id].material ); nodeTHREEviewers[id].scene.add( nodeTHREEviewers[id].mesh ); animate(); //nodeTHREEviewers[id].material.map.needsUpdate = true; //nodeTHREEviewers[id].material.needsUpdate = true //alert( ' reloadded ' ); }; }; function stopAnimation(){ if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId ); }; function animate( ) { if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId ); nodeTHREEanimationId = requestAnimationFrame( animate ); nodeTHREEviewers.forEach( function(element, index, array){ if ( isUserInteracting === false ) { lon += 0.5; } lat = Math.max( - 85, Math.min( 85, lat ) ); phi = THREE.MathUtils.degToRad( 90 - lat ); theta = THREE.MathUtils.degToRad( lon ); const x = 500 * Math.sin( phi ) * Math.cos( theta ); const y = 500 * Math.cos( phi ); const z = 500 * Math.sin( phi ) * Math.sin( theta ); element.camera.lookAt( x, y, z ); element.renderer.render( element.scene, element.camera ); }); //update( id ); }; function animateTargets(){ if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId ); nodeTHREEanimationId = requestAnimationFrame( animateTargets ); nodeTHREEviewers.forEach( function(element, index, array){ if ( isUserInteracting === false ) { if( element.targetShowCopunter ){ element.targetShowCopunter--; } else { element.camera.lookAt( element.targets[element.targetIndex].mesh.position ); element.targetShowCopunter = 100; element.renderer.render( element.scene, element.camera ); element.targetIndex++; if( element.targetIndex == element.targets.length ) element.targetIndex = 0; }; }; }); }; function update() { if ( isUserInteracting === false ) { lon += 0.5; } lat = Math.max( - 85, Math.min( 85, lat ) ); phi = THREE.MathUtils.degToRad( 90 - lat ); theta = THREE.MathUtils.degToRad( lon ); const x = 500 * Math.sin( phi ) * Math.cos( theta ); const y = 500 * Math.cos( phi ); const z = 500 * Math.sin( phi ) * Math.sin( theta ); camera.lookAt( x, y, z ); renderer.render( scene, camera ); }; function Pie(cx, cy, radius, data) { var decimals = 4; var total = 0; var offset = 0; var offset2; var arr = []; var x; var y; var la; var radians; for (var i = 0; i < data.length; i++) total += data[i].value; for (var i = 0; i < data.length; i++) { var item = data[i]; var tmp = {}; tmp.index = i; tmp.value = item.value; radians = ((((item.value / total) * 360) * Math.PI) / 180).floor(decimals); offset2 = ((offset / total) * 360).floor(decimals); tmp.data = item; x = (cx + Math.sin(radians) * radius).floor(decimals); y = (cy - Math.cos(radians) * radius).floor(decimals); la = radians > Math.PI ? 1 : 0; // Arc 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); tmp.transform = 'rotate({0}, {1}, {2})'.format(offset2, cx, cy); // Text x = (cx + Math.sin(radians / 2) * radius / 2).floor(decimals); y = (cy - Math.cos(radians / 2) * radius / 2).floor(decimals); tmp.text = 'x="{0}" y="{1}" transform="rotate({2},{0},{1})"'.format(x, y, -offset2); offset += item.value; arr.push(tmp); } return arr; } function Donut(cx, cy, radius, data) { function arcradius(cx, cy, radius, degrees) { var radians = (degrees - 90) * Math.PI / 180.0; return { x: cx + (radius * Math.cos(radians)), y: cy + (radius * Math.sin(radians)) }; } var decimals = 4; var total = 0; var arr = []; var beg = 0; var end = 0; var count = 0; var half = radius / 2; var midpoint = radius / 2.4; for (var i = 0; i < data.length; i++) total += data[i].value; for (var i = 0; i < data.length; i++) { var item = data[i]; var tmp = {}; //var p = (((item.value + 1) / total) * 100).floor( 2 ); var p = Math.floor(((item.value + 1) / total) * 100); count += p; if (i === length - 1 && count < 100) p = p + (100 - count); end = beg + ((360 / 100) * p); tmp.index = i; tmp.value = item.value; tmp.data = item; var b = arcradius(cx, cy, radius, end); var e = arcradius(cx, cy, radius, beg); var la = (end - beg) <= 180 ? 0 : 1; 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(' '); arr.push(tmp); beg = end; } return arr; } //Pie Chart Usage /* var svg = $('#yoursvgelement'); var data = [{ value: 33 }, { value: 20 }, { value: 80 }, { value: 48 }]; var centerX = 300; var centerY = 300; var radius = 250; var color = ['#F6BB42', '#8CC152', '#3BAFDA', '#967ADC', '#DA4453']; var arr = Pie(centerX, centerY, radius, data); for (var i = 0; i < arr.length; i++) { var item = arr[i]; svg.asvg('{3}'.format(item.transform, item.d, item.text, item.value, color[i])); } */ // Donut Chart Usage /* var svg = $('#yoursvgelement'); var data = [{ value: 33 }, { value: 20 }, { value: 80 }, { value: 48 }]; var centerX = 300; var centerY = 300; var radius = 250; var color = ['#F6BB42', '#8CC152', '#3BAFDA', '#967ADC', '#DA4453']; var arr = Donut(centerX, centerY, radius, data); for (var i = 0; i < arr.length; i++) { var item = arr[i]; svg.asvg(''.format(item.d, color[i])); } */ function makePtzMove( me ){ var name = me.target.id; Ext.Ajax.request({ url: '/lib/controller/camMakeMove.php', params: { SITE: , UID: , SID: '', CMD: name }, //success: function( response, opts ){ //}, failure: failureAJAXFunction }); }; function ptzCtrl( a ){ }; function makePtzStop( me ){ var name = me.target.id; Ext.Ajax.request({ url: '/lib/controller/camStop.php', params: { SITE: , UID: , SID: '', CMD: name }, //success: function( response, opts ){ //}, failure: failureAJAXFunction }); }; function fullScreen( id ){ // if already full screen; exit // else go fullscreen if( document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement ){ if( document.exitFullscreen ){ document.exitFullscreen(); }else if( document.mozCancelFullScreen ){ document.mozCancelFullScreen(); }else if( document.webkitExitFullscreen ){ document.webkitExitFullscreen(); }else if( document.msExitFullscreen ){ document.msExitFullscreen(); }; }else{ //element = $('#container').get(0); var element = document.getElementById( id ); //Ext.getCmp( id ); if( element.requestFullscreen ){ element.requestFullscreen(); }else if( element.mozRequestFullScreen ){ element.mozRequestFullScreen(); }else if( element.webkitRequestFullscreen ){ element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); }else if( element.msRequestFullscreen ){ element.msRequestFullscreen(); }; }; }; function updateDashBoardItemLayout( id, x, y ){ Ext.Ajax.request({ url: '/lib/controller/updateDashBoardItems.php', params: { SITE: , UID: , SID: '', PANEL: id, X: x, Y: y }, success: function( response, opts ){ //var data = Ext.decode(response.responseText); //var tPanel = Ext.getCmp('main_portal'); //tPanel.removeAll(true); //for( i=0; i < data.length; i++) tPanel.add( data[i] ); //tPanel.doLayout(); }, failure: failureAJAXFunction }); }; var drawZoomLevels = Array(); function cleanup2DDraw( a ){ var canvas = document.getElementById('targ_canvas_'+a ); var ctx = canvas.getContext('2d'); var img = document.getElementById('draw_img_'+a ); ctx.drawImage( img, 0, 0 ); canvas.style='display: block;'; img.style='display: none;'; }; function Draw2DTargets( k, b ){ var canvas = document.getElementById('targ_canvas_'+k ); var ctx = canvas.getContext('2d'); var img = document.getElementById('draw_img_'+k ); ctx.drawImage( img, 0, 0 ); canvas.style='display: block;'; img.style='display: none;'; for( var i=0; i< b.length; i++ ){ switch( drawZoomLevels[k] ){ case 12:{ if( b[i].digital < 256 ){ var cc = 255 - i ;//* ( 255 / 33 ); //ctx.fillStyle = "#" + cc.toString(16) + "0000"; ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")"; //ctx.strokeStyle = "#FF0000"; var r = (196 * b[i].digital)/ 512; var a = -1.0 * b[i].az * ( Math.PI / 180 ); var x = 100 + Math.cos( a ) * r; var y = 100 + Math.sin( a ) * r; ctx.fillRect( x, y, 24, 24 ); }; break; }; case 25:{ if( b[i].digital < 512 ){ var cc = 255 - i ;//* ( 255 / 33 ); //ctx.fillStyle = "#" + cc.toString(16) + "0000"; ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")"; //ctx.strokeStyle = "#FF0000"; var r = (196 * b[i].digital)/ 1024; var a = -1.0 * b[i].az * ( Math.PI / 180 ); var x = 100 + Math.cos( a ) * r; var y = 100 + Math.sin( a ) * r; ctx.fillRect( x, y, 12, 12 ); }; break; }; case 50:{ if( b[i].digital < 1024 ){ var cc = 255 - i ;//* ( 255 / 33 ); //ctx.fillStyle = "#" + cc.toString(16) + "0000"; ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")"; //ctx.strokeStyle = "#FF0000"; var r = (196 * b[i].digital) / 2048; var a = -1.0 * b[i].az * ( Math.PI / 180 ); var x = 100 + Math.cos( a ) * r; var y = 100 + Math.sin( a ) * r; ctx.fillRect( x, y, 6, 6 ); }; break; }; case 100:{ var cc = 255 - i ;//* ( 255 / 33 ); //ctx.fillStyle = "#" + cc.toString(16) + "0000"; ctx.fillStyle = "rgba(255, 0, 0,"+((b.length - i)/ b.length )+")"; //ctx.strokeStyle = "#FF0000"; var r = (196 * b[i].digital)/ 4096; var a = -1.0 * b[i].az * ( Math.PI / 180 ); var x = 100 + Math.cos( a ) * r; var y = 100 + Math.sin( a ) * r; ctx.fillRect( x, y, 3, 3 ); break; }; }; }; }; var lastNotificationID = 0; function setDonatStatus( id , value ){ var val1D = document.getElementById('donut'+id+'-segment1'); var val2D = document.getElementById('donut'+id+'-segment2'); var val3D = document.getElementById('donut'+id+'-segment3'); var val1 = (value>-1)?value:0; var val2 = (value>-1)?100 - val1:0;//data.nodes[i].cpu5 * 100; var val3 = (value>-1)?0:100;//data.nodes[i].cpu15 * 100; var totalValue = document.getElementById('totalValue'+id); var total = val1+val2+val3; var per1 = val1/total*100; var per2 = val2/total*100; var per3 = val3/total*100; var offset = 25; if( ( val1 != undefined ) && ( value > -1 ) ){ totalValue.textContent = val1+'%'; } else { totalValue.textContent = 'No Data'; }; val1D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out"; val1D.style.strokeDasharray = per1+" "+(100-per1); val1D.style.strokeDashoffset = offset; val2D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out"; val2D.style.strokeDasharray = per2+" "+(100-per2); val2D.style.strokeDashoffset = 100-per1+offset; val3D.style.transition = "stroke-dasharray 0.5s ease-in-out, stroke-dashoffset 0.5s ease-in-out"; val3D.style.strokeDasharray = per3+" "+(100-per3); val3D.style.strokeDashoffset = 100-(per1+per2)+offset; }; function fetchSiteStatus(){ Ext.Ajax.request({ url: '/lib/controller/getStatus.php', params: { SITE: , LNID: lastNotificationID, SPID: StatusTS, LOAT: LoadTS, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); StatusTS = data.CTS; if( data.nodes.length > 0 ){ for( i=0; i < data.nodes.length; i++ ){ if( data.nodes[i].type == 0 ){ //Handle Server Status if ( data.nodes[i].status ){ setDonatStatus( '' , data.nodes[i].cpu5 ); setDonatStatus( '1' , data.nodes[i].mem ); setDonatStatus( '2' , data.nodes[i].disk ); } else { setDonatStatus( '' , -1 ); setDonatStatus( '1' , -1 ); setDonatStatus( '2' , -1 ); }; }; // Sesors if( data.nodes[i].type > 0 && data.nodes[i].type < 7 ){ if( data.nodes[i].reload_draw ){ reload3dTexture( data.nodes[i].id ); LoadTS = StatusTS; }; }; // Cameras if( data.nodes[i].type > 9 && data.nodes[i].type < 14 ){ var iel = document.getElementById('img-'+data.nodes[i].id ); if( iel != null ){ if( !data.nodes[i].valid ){ if( iel.src != "/style/assets/no-signal.png" ) iel.src = "/style/assets/no-signal.png"; } else { if( data.nodes[i].src != iel.src ) iel.src = data.nodes[i].src; }; }; //else { //https://man7.org/linux/man-pages/man2/getrusage.2.html //https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode //https://stackoverflow.com/questions/13465073/how-to-catch-an-exception-from-image-onload //if( data.nodes[i].valid && ServerIsOnline ){ //iel.src = "/style/assets/no-signal.png"; /* iel.onerror = function(){ //alert("IMG onerror!"); iel.troubled = true; }; iel.decode() .then(() => { //document.body.appendChild(img); }) .catch((encodingError) => { //alert('Stream Ended!'); iel.troubled = true; }) */ //}; //}; }; var tt = Ext.getCmp('status_'+data.nodes[i].id ); if( tt != undefined ){ if( data.nodes[i].type == 3 ){ if( data.nodes[i].status == 4 ){ Draw2DTargets( data.nodes[i].id, data.nodes[i].targets ); } else { cleanup2DDraw( data.nodes[i].id ); }; }; if( data.nodes[i].type == 5 ){//addl3dTarget( id, radius, az, el, color = 0xff0000 ) if( data.nodes[i].status == 4 ){ //DrawTargets( data.nodes[i].id, data.nodes[i].targets ); //addl3dTarget( data.nodes[i].id, data.nodes[i].targets[0].digital, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el ); //addl3dTarget( data.nodes[i].id, 150, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el ); Draw3DTargets( data.nodes[i].id, data.nodes[i].targets ); animateTargets(); } else { cleanup3DDraw( data.nodes[i].id ); animate(); }; var ca = document.getElementById( 'status_canvas_' + data.nodes[i].id ); var ctx = ca.getContext('2d'); //if( stat_present ); ca.style='display: block;'; ctx.font = "10px Arial"; ctx.fillStyle = "rgba(255, 255, 255, 255)"; ctx.fillText( "Master:", 5, 8 ); ctx.fillText( "Slave:", 5, 24 ); //var cc = 255 - i ;//* ( 255 / 33 ); //ctx.fillStyle = "#" + cc.toString(16) + "0000"; //ctx.fillStyle = "rgba(255, 0, 0, 100)";//+((b.length - i)/ b.length )+")"; if( data.nodes[i].master_present ){ ctx.fillStyle = "rgba(0, 255, 0, 255)"; } else { ctx.fillStyle = "rgba(128, 0, 0, 255)"; }; ctx.fillRect( 43, 1, 8, 8 ); if( data.nodes[i].stat_present ){ ctx.strokeStyle = "#FFFF00"; ctx.strokeRect( 43, 1, 8, 8 ); ctx.beginPath(); ctx.moveTo( 51, 5 ); ctx.lineTo( 56, 5 ); ctx.lineTo( 56, 2 ); ctx.lineTo( 103, 2 ); ctx.lineTo( 103, 5 ); ctx.moveTo( 63, 5 ); ctx.lineTo( 143, 5 ); ctx.stroke(); for( z=0; z < 8; z++ ){ //ctx.strokeStyle = "#FFFF00"; //ctx.fillStyle = "rgba(0, 255, 0, 255)"; ctx.fillStyle = "rgba(20, 20, 20, 255)"; h = 19 - ( 19 * data.nodes[i].runtime.mp[z] ); ha = 19 - h; ctx.fillRect( 64 + z*10, 7, 2, h ); if( ha > 0 ) { if( data.nodes[i].runtime.mp[z] > 0.8 ){ ctx.fillStyle = "rgba(0, 255, 0, 255)"; } else if ( data.nodes[i].runtime.mp[z] > 0.5 ){ ctx.fillStyle = "rgba( 255, 255, 0, 255)"; } else if ( data.nodes[i].runtime.mp[z] > 0.3 ){ ctx.fillStyle = "rgba( 255, 128, 0, 255)"; } else { ctx.fillStyle = "rgba( 255, 0, 0, 255)"; }; ctx.fillRect( 64 + z*10, 7+h, 2, ha ); }; ctx.fillStyle = "rgba(20, 20, 20, 255)"; h = 19 - ( 19 * data.nodes[i].runtime.gp[z] ); ha = 19 - h; ctx.fillRect( 67 + z*10, 7, 2, h ); if( ha > 0 ) { if( data.nodes[i].runtime.gp[z] > 0.8 ){ ctx.fillStyle = "rgba(0, 255, 0, 255)"; } else if ( data.nodes[i].runtime.gp[z] > 0.5 ){ ctx.fillStyle = "rgba( 255, 255, 0, 255)"; } else if ( data.nodes[i].runtime.gp[z] > 0.3 ){ ctx.fillStyle = "rgba( 255, 128, 0, 255)"; } else { ctx.fillStyle = "rgba( 255, 0, 0, 255)"; }; ctx.fillRect( 67 + z*10, 7+h, 2, ha ); }; ctx.fillStyle = "rgba(20, 20, 20, 255)"; h = 19 - ( 19 * data.nodes[i].runtime.wp[z] ); ha = 19 - h; ctx.fillRect( 70 + z*10, 7, 2, h ); if( ha > 0 ){ if( data.nodes[i].runtime.wp[z] > 0.8 ){ ctx.fillStyle = "rgba(0, 255, 0, 255)"; } else if ( data.nodes[i].runtime.wp[z] > 0.5 ){ ctx.fillStyle = "rgba( 255, 255, 0, 255)"; } else if ( data.nodes[i].runtime.wp[z] > 0.3 ){ ctx.fillStyle = "rgba( 255, 128, 0, 255)"; } else { ctx.fillStyle = "rgba( 255, 0, 0, 255)"; }; ctx.fillRect( 70 + z*10, 7+h, 2, ha ); }; }; //ffmpeg -f v4l2 -framerate -thread_queue_size 512 -i -f alsa -thread_queue_size 512 -i -t -c:v h264 -c:a aac -pix_fmt yuv420p } else { ctx.strokeStyle = "#808080"; ctx.strokeRect( 43, 1, 8, 8 ); ctx.beginPath(); ctx.moveTo( 51, 5 ); ctx.lineTo( 56, 5 ); ctx.lineTo( 56, 2 ); ctx.lineTo( 103, 2 ); ctx.lineTo( 103, 5 ); ctx.moveTo( 63, 5 ); ctx.lineTo( 143, 5 ); ctx.stroke(); ctx.fillStyle = "rgba( 128, 0, 0, 255)"; for( z=0; z < 8; z++ ){ ctx.fillRect( 64 + z*10, 7, 2, 19 ); ctx.fillRect( 67 + z*10, 7, 2, 19 ); ctx.fillRect( 70 + z*10, 7, 2, 19 ); //https://www.ebay.com/itm/304440983138 }; }; if( data.nodes[i].slave_present ){ ctx.strokeStyle = "#FFFF00"; ctx.fillStyle = "rgba(0, 255, 0, 255)"; } else { ctx.strokeStyle = "#808080"; ctx.fillStyle = "rgba(128, 0, 0, 255)"; }; ctx.fillRect( 43, 17, 8, 8 ); ctx.strokeRect( 43, 17, 8, 8 ); ctx.beginPath(); ctx.moveTo( 51, 21 ); ctx.lineTo( 56, 21 ); ctx.lineTo( 56, 31 ); ctx.lineTo( 187, 31 ); ctx.lineTo( 187, 28 ); ctx.moveTo( 147, 28 ); ctx.lineTo( 227, 28 ); ctx.stroke(); for( z=8; z < 16; z++ ){ //ctx.strokeStyle = "#FFFF00"; //ctx.fillStyle = "rgba(0, 255, 0, 255)"; ctx.fillRect( 68 + z*10, 7, 2, 19 ); ctx.fillRect( 71 + z*10, 7, 2, 19 ); ctx.fillRect( 74 + z*10, 7, 2, 19 ); //ctx.strokeRect( 43, 1, 8, 8 ); }; }; if( typeof nodeDashboardStatuses[i] === 'undefined' || nodeDashboardStatuses[i] != data.nodes[i].status ){ nodeDashboardStatuses[i] = data.nodes[i].status; switch( data.nodes[i].status ){ case 0:{ if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id ); tt.update('
Offline
'); break; }; case 1:{ if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id ); tt.update('
Online
'); break; }; case 2:{ if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id ); tt.update('
Initializing
'); break; }; case 3:{ if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id ); tt.update('
Trouble
'); break; }; case 4:{ if( data.nodes[i].type == 3 ) cleanup2DDraw( data.nodes[i].id, data.nodes[i].targets ); tt.update('
Alarm
'); break; }; }; }; }; }; }; if( data.notifications.length > 0 ){ sndExcl.play(); for( i=0; i < data.notifications.length; i++ ){ /*const not = PNotify.alert({ title: 'You Will Receive a Side', text: 'You have no choice.', icon: 'fas fa-info-circle', hide: false, closer: false, sticker: false, destroy: true, modules: new Map([ ...PNotify.defaultModules, [PNotifyConfirm, { confirm: true, buttons: [{ text: 'Ok', primary: true, click: notice => notice.close() }] }] ]) }); */ const l = PNotify.alert({ type: data.notifications[i].type, text: data.notifications[i].msg, textTrusted: true, stack: NotificationStack, title: data.notifications[i].action, hide: data.notifications[i].hide, closer: data.notifications[i].hide, sticker: data.notifications[i].hide, destroy: true, modules: (data.notifications[i].react )? new Map([ ...PNotify.defaultModules, [PNotifyConfirm, { confirm: true, buttons: [{ text: 'Ok', primary: true, click: ( notice, value, evt ) => { notice.close(); if( notice.title!='' ){ resolveDeviceMistmatch( notice.title ); }; } }] }] ]): null }); /* if( data.notifications[i].react ){ l.on('click', (notice, value) => { notice.close(); resolveDeviceMistmatch( notice.title ); }); }; */ lastNotificationID = data.notifications[i].id; }; }; }, failure: failureAJAXFunction }); }; function loadDashBoard(){ if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; timelineObj = null; }; setUserContent( 0 ); Ext.Ajax.request({ url: '/lib/controller/getDashBoardItems.php', params: { SITE: , UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); Ext.getCmp('main_content').setTitle( 'GetLabel('_SYS_DASHBOARD_');?>' ); var tPanel = Ext.getCmp('main_portal'); tPanel.removeAll(true); for( i=0; i < data.length; i++) tPanel.add( data[i] ); tPanel.doLayout(); $('img[data-enlargeable]').addClass('img-enlargeable').click(function() { var src = $(this).attr('src'); var modal; function removeModal() { modal.remove(); $('body').off('keyup.modal-close'); } modal = $('
').css({ background: 'RGBA(0,0,0,.5) url(' + src + ') no-repeat center', backgroundSize: 'contain', width: '100%', height: '100%', position: 'fixed', zIndex: '10000', top: '0', left: '0', cursor: 'zoom-out' }).click(function() { removeModal(); }).appendTo('body'); //handling ESC $('body').on('keyup.modal-close', function(e) { if (e.key === 'Escape') { removeModal(); } }); }); tlInterval = window.setInterval( fetchSiteStatus, 333, selectedSite ); }, failure: failureAJAXFunction }); }; function showServerToolBox( ServerNodeId ){ currentNodeID = ServerNodeId; if( serverToolBox == null ){ serverToolBox = new Ext.Window({ title: 'GetLabel('_SERV_CTLPANEL_SHRT_');?>', modal: true, width: 400, height: 328, closeAction: 'hide', items:[{ xtype: 'button', text: 'Restart', width: '100%', textAlign: 'left', iconCls: 'server_btn_restart', scale: 'large', iconAlign: 'left', handler: function(){ doDeviceOperation( currentNodeID, 250 ); } },{ xtype: 'button', text: 'Initialize Hardware', width: '100%', textAlign: 'left', iconCls: 'server_btn_hwinit', scale: 'large', iconAlign: 'left', handler: function(){ doDeviceOperation( currentNodeID, 251 ); } },{ xtype: 'button', text: 'Clear Site', width: '100%', textAlign: 'left', iconCls: 'server_btn_restart', scale: 'large', iconAlign: 'left' }] }); }; serverToolBox.show(); }; var detectionProfileWindow = null; var deviceCtrlNode = ''; function showSensorToolBox( NodeID ){ currentNodeID = NodeID; deviceCtrlNode = NodeID + ':0'; Data['access']>4 ) $ColSpan = 4; else $ColSpan = 3; ?> if( detectionProfileWindow == null ){ detectionProfileWindow = new Ext.Window({ title: 'GetLabel('_DEV_CTLPANEL_SHRT_');?>', modal: true, width: , height: 328, closeAction: 'hide', items:[] }); }; detectionProfileWindow.show(); var myMask = new Ext.LoadMask( detectionProfileWindow.getEl(), {msg:"Please wait..."}); myMask.show(); Ext.Ajax.request({ url: '/lib/controller/getDetectionProfile.php', params: { SITE: SelectedSite, UID: , SID: '', NID: NodeID }, success: function( response, opts ){ var data = Ext.decode( response.responseText ); myMask.hide(); detectionProfileWindow.setTitle( '['+data.name + '] GetLabel('_DEV_CTLPANEL_SHRT_');?>'); detectionProfileWindow.removeAll( true ); //detectionProfileWindow.setSize( data.width, data.height ); if( data.additional !== 'undefined' ){ var addi = Ext.decode( data.additional ); detectionProfileWindow.add( addi ); }; if( data.data_status == 3 ){ detectionProfileWindow.add({ xtype: 'panel', layout: 'table', layoutConfig: { columns: }, items:[{ xtype: 'spacer', height: 30, style: { marginTop: '13px' }, html: '
GetLabel('_DET_SENSITIVITY_');?>
', colspan: },Data['access']>4 ){ ?>{ xtype: 'button', text: 'Factory', id: 'DDSPBTN0', width: 80, iconCls: 'detection_btn_factory', enableToggle: true, toggleGroup: 'det_sens_btn_grp', disabled: true, scale: 'large', iconAlign: 'top' },{ xtype: 'button', text: 'Low', id: 'DDSPBTN1', width: 80, iconCls: 'detection_btn_low', enableToggle: true, toggleGroup: 'det_sens_btn_grp', disabled: true, scale: 'large', iconAlign: 'top' },{ xtype: 'button', text: 'Meduim', id: 'DDSPBTN2', width: 80, iconCls: 'detection_btn_medium', enableToggle: true, toggleGroup: 'det_sens_btn_grp', disabled: true, scale: 'large', iconAlign: 'top' },{ xtype: 'button', text: 'High', id: 'DDSPBTN3', width: 80, iconCls: 'detection_btn_high', enableToggle: true, toggleGroup: 'det_sens_btn_grp', disabled: true, scale: 'large', iconAlign: 'top' }] }); for( i=0; i < data.profiles.length; i++ ){ Ext.getCmp('DDSPBTN'+data.profiles[i] ).enable(); if( i == data.profile_id ) Ext.getCmp('DDSPBTN'+data.profiles[i] ).toggle(); }; } else if( data.data_status == 4 ){ detectionProfileWindow.add({ xtype: 'panel', //layout: 'fit', //layoutConfig: { // columns: 3 //}, items:[{ xtype: 'spacer', height: 40, //colspan: 3, style: { marginTop: '20px' }, html: '
GetLabel('_DET_SENSITIVITY_');?>
', }Data['access']>4 ){ ?>,{ xtype: 'button', text: 'Resolve Trouble', width: '100%', //colspan: 3, iconCls: 'ctrl_panel_cog', scale: 'large', iconAlign: 'left', handler: function(){ detectionProfileWindow.hide(); resolveDeviceMistmatch( deviceCtrlNode ); } }] }); }; detectionProfileWindow.add({ xtype: 'spacer', height: 30, style: { marginTop: '13px' }, html: '
GetLabel('_DET_GENWORKS_');?>
', }); detectionProfileWindow.add({ xtype: 'button', width: '100%', text: 'Clear Alarm', scale: 'large', iconCls: 'ctrl_panel_clean', iconAlign: 'left' }); detectionProfileWindow.add({ xtype: 'button', width: '100%', text: 'Draw Background', scale: 'large', iconCls: 'ctrl_panel_drawscan', iconAlign: 'left', handler: function(){ doDeviceOperation( deviceCtrlNode, 3 ); } }); detectionProfileWindow.add({ xtype: 'button', width: '100%', text: 'Force Study Background', scale: 'large', iconCls: 'ctrl_panel_study', iconAlign: 'left', handler: function(){ doDeviceOperation( deviceCtrlNode, 2 ); } }); detectionProfileWindow.add({ xtype: 'button', width: '100%', buttonAlign: 'left', //text: '
Button 1
', text: 'Force Reset Sensor', scale: 'large', iconCls: 'ctrl_panel_reset', iconAlign: 'left', handler: function(){ doDeviceOperation( deviceCtrlNode, 1 ); } }); detectionProfileWindow.doLayout(); //detectionProfileWindow.show(); }, failure: failureAJAXFunction }); };