vizor_alerts 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vizor_alerts.min.js +1 -1
- package/package.json +1 -1
package/dist/vizor_alerts.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}e.d(t,{W:()=>s});var a={Baja:65280,Media:16776960,Alta:16753920,Crítica:16711680},o={Nueva:1,Vista:.75,"En Proceso":.5,Solucionada:.1},s=function(){return e=function e(t,r){var n=this,i=r.tipo,a=r.field,o=r.collection,s=r.store;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.domain="",this.space=t,"plane_earth"==this.space.class_name?this.scene=this.space:this.scene=this.space.scene,this.alert_registry=new Map,this.alerted_elements=new Map,this.alerts=new Map,this.test=!0,this.tipo=i,this.field=a,this.collection=o,this.store=s,this.event_bus=null,this.injectAlertCardStyles(),this.space.alert_controller=this,document.addEventListener("change",(function(e){if(e.target.matches('input[type="radio"][name^="alert-"]')){var t=e.target.value,r=e.target.dataset.object;if(console.log("Selected alert:",t,"for object:",r),n.event_bus){var i=n.alert_registry.get(t);n.event_bus.emit("alertas","selected",{alert:i})}}})),this.scene.addUpdatable(this)},t=[{key:"injectAlertCardStyles",value:function(){if(!document.getElementById("alert-card-styles")){var e=document.createElement("style");e.id="alert-card-styles",e.textContent="\n .alert-card {\n font-family: sans-serif;\n border-radius: 8px;\n padding: 12px;\n background: #1e1e1e;\n color: #eee;\n width: 320px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.4);\n }\n \n .alert-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 8px;\n }\n \n .alert-title {\n font-size: 16px;\n font-weight: bold;\n }\n \n .alert-status {\n font-size: 12px;\n padding: 2px 6px;\n border-radius: 4px;\n background: #444;\n }\n \n .alert-body {\n font-size: 13px;\n margin-bottom: 8px;\n }\n \n .alert-row {\n margin-bottom: 4px;\n }\n \n .alert-footer {\n font-size: 11px;\n opacity: 0.85;\n }\n \n .alert-asset {\n display: inline-block;\n background: #333;\n padding: 2px 6px;\n margin-right: 4px;\n border-radius: 4px;\n }\n\n .alert-status-select {\n background: #333;\n color: #eee;\n border: 1px solid #555;\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n }\n \n /* Severity coloring */\n .severity-baja { border-left: 4px solid #4caf50; }\n .severity-media { border-left: 4px solid #ff9800; }\n .severity-alta { border-left: 4px solid #f44336; }\n ",document.head.appendChild(e)}}},{key:"setEventBus",value:function(e){this.event_bus=e}},{key:"addAlertedElement",value:function(e,t){var r,n="".concat(this.collection,":").concat(e.id),i=null!==(r=this.alerted_elements.get(n))&&void 0!==r?r:[];i.push(t),this.alerted_elements.set(n,i)}},{key:"getAlertById",value:function(e,t){var r,n="".concat(this.collection,":").concat(e.id),i=this.alerted_elements.get(n);return null!==(r=null==i?void 0:i.find((function(e){return e.id===t})))&&void 0!==r?r:null}},{key:"removeAlertById",value:function(e,t){var r="".concat(this.collection,":").concat(e.id),n=this.alerted_elements.get(r);if(!n)return!1;var i=n.findIndex((function(e){return e.id===t}));return-1!==i&&(n.splice(i,1),0===n.length&&this.alerted_elements.delete(r),!0)}},{key:"getAlertsCountForObject",value:function(e){var t,r,n="".concat(this.collection,":").concat(e.id);return null!==(t=null===(r=this.alerted_elements.get(n))||void 0===r?void 0:r.length)&&void 0!==t?t:0}},{key:"process",value:function(e){console.log("procesando",e);var t=this.collection+":"+e.id;this.alerted_elements.get(t)&&this.create_alert_graphics({id:t,x:e.x,y:e.y,z:e.z})}},{key:"create_alert_graphics_old",value:function(e){var t=this;this.removeAlertGraphics(e);var r=this.alerted_elements.get(e.id);if(r&&0!==r.length){var n=new this.scene.THREE.Group;n.name="alert-group-".concat(e.id),r.forEach((function(e,r){var i,o=1+.3*r,s=o+.25,l=null!==(i=a[e.severidad])&&void 0!==i?i:16777215,c=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(o,s,48),new t.scene.THREE.MeshBasicMaterial({color:l,side:t.scene.THREE.DoubleSide,transparent:!0,opacity:.85,depthWrite:!1,depthTest:!0}));c.rotation.x=Math.PI/2,c.userData.alertId=e.id,c.userData.severidad=e.severidad,n.add(c)})),n.position.set(e.x,e.y,e.z),this.scene.add(n),this.alerts.set(e.id,{group:n})}}},{key:"statusToProgress",value:function(e){var t;return null!==(t=o[e])&&void 0!==t?t:0}},{key:"create_alert_graphics",value:function(e){var t=this;this.removeAlertGraphics(e);var r=this.alerted_elements.get(e.id);if(r&&0!==r.length){var n=new this.scene.THREE.Group;n.name="alert-group-".concat(e.id),r.forEach((function(r,i){var o,s=1+.3*i,l=s+.25,c=null!==(o=a[r.severidad])&&void 0!==o?o:16777215,d=r.estatus,u=t.statusToProgress(d),h=new t.scene.THREE.MeshBasicMaterial({color:c,side:t.scene.THREE.DoubleSide,transparent:!0,opacity:"Solucionada"===d?.25:.85,depthWrite:!1,depthTest:!1}),p=new t.scene.THREE.MeshBasicMaterial({color:c,transparent:!0,opacity:.15,side:t.scene.THREE.DoubleSide,depthWrite:!1,depthTest:!1}),v=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(s,l,64,1,0,2*Math.PI*u),h),f=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(s,l,64),p);v.rotation.x=Math.PI/2,f.rotation.x=Math.PI/2,v.renderOrder=1e3,f.renderOrder=999;var y=new t.scene.THREE.Group;y.name="alert-".concat(e.id,"-").concat(r.id),y.add(f),y.add(v),v.userData={alertId:r.id,severidad:r.severidad,status:d,progress:u,targetProgress:u,pulse:"Nueva"===d||"En Proceso"===d,pulseSpeed:"En Proceso"===d?3:1.2,rotate:"En Proceso"===d},n.add(y)})),n.position.set(e.x,e.y,e.z),n.renderOrder=1e3,this.scene.add(n),this.alerts.set(e.id,{group:n})}}},{key:"removeAlertGraphics_old",value:function(e){var t=this.alerts.get(e.id);t&&(t.group.traverse((function(e){e.isMesh&&(e.geometry.dispose(),e.material.dispose())})),this.scene.scene.remove(t.group),this.alerts.delete(e.id))}},{key:"destroyGroup",value:function(e,t){e&&(e.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach((function(e){return e.dispose()})):e.material.dispose())})),e.parent&&e.parent.remove(e),e.clear())}},{key:"removeAlertGraphics",value:function(e){console.log("removing");var t=this.alerts.get(e.id);if(t){var r=t.group;this.destroyGroup(r,this.scene.scene),this.alerts.delete(e.id)}}},{key:"removeAlert",value:function(e){var t="".concat(this.collection,":").concat(e.id);this.removeAlertGraphics({id:t})}},{key:"unregister_alert",value:function(e){var t=this,r=e[this.tipo];if(r){var n=this.store.getRecordByField(this.collection,this.field,r);n&&(this.removeAlertById(n,e.id),this.getAlertsCountForObject(n)<1&&this.removeAlertGraphics(n))}else{var i=e.activos;i&&i.forEach((function(r){if(r.type==t.tipo){var n=r.identificador,i=t.store.getRecordByField(t.collection,t.field,n);i&&(t.removeAlertById(i,e.id),t.getAlertsCountForObject(i)<1&&t.removeAlertGraphics(i))}}))}}},{key:"register_alert",value:function(e){var t=this,r=this.alert_registry.get(e.id);r&&(console.log("alerta preexistente"),this.unregister_alert(r)),this.alert_registry.set(e.id,e);var n=e[this.tipo];if(n){var i=this.store.getRecordByField(this.collection,this.field,n);i&&this.addAlertedElement(i,e)}else{var a=e.activos;a&&a.forEach((function(r){if(r.type==t.tipo){var n=r.identificador,i=t.store.getRecordByField(t.collection,t.field,n);i&&t.addAlertedElement(i,e)}}))}}},{key:"check_all",value:function(){var e=this,t={visit:function(t,r,n){e.alerted_elements.has(n.id)&&(console.log("crea alerta para vehiculo"),e.create_alert_graphics({id:n.id,x:n.mesh.position.x,y:n.mesh.position.y,z:n.mesh.position.z}))}};this.space.applyVisitor2Objects(t)}},{key:"set",value:function(e){var t=this;this.domain=e.collection,e.result.data.forEach((function(e){t.register_alert(e)})),console.log("CECKING ALL"),this.check_all()}},{key:"add_or_update",value:function(e){this.register_alert(e.result.data),this.check_all(),this.scene.touch()}},{key:"delete",value:function(e){var t=this.alert_registry.get(e.id);t&&(console.log("borrando alerta"),this.unregister_alert(t),this.check_all(),this.scene.touch())}},{key:"getInfo",value:function(e){var t="".concat(this.collection,":").concat(e.id),r=this.alerted_elements.get(t);if(!r||0===r.length)return"";var n='<div class="alert-list">';return r.forEach((function(t){n+='\n <label class="alert-item">\n <input \n type="radio"\n name="alert-'.concat(e.id,'"\n value="').concat(t.id,'"\n data-object="').concat(e.id,'"\n />\n ').concat(t.nombre,"\n </label><br>\n ")})),n+="</div>"}},{key:"updateAlertAnimations",value:function(e){this.alerts.forEach((function(t){t.group.children.forEach((function(t){t.children.forEach((function(t){var r=t.userData;r&&(r.rotate&&(t.rotation.z+=.01),r.pulse&&(t.material.opacity=.65+.2*Math.sin(.002*e*r.pulseSpeed)))}))}))}))}},{key:"update",value:function(e){this.updateAlertAnimations(e)}}],t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),l=t.W;export{l as vi_alert_controller};
|
|
1
|
+
var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function i(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}e.d(t,{W:()=>s});var a={Baja:65280,Media:16776960,Alta:16753920,Crítica:16711680},o={Nueva:1,Vista:.75,"En Proceso":.5,Solucionada:.1},s=function(){return e=function e(t,r){var n=this,i=r.tipo,a=r.field,o=r.collection,s=r.store;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.domain="",this.space=t,"plane_earth"==this.space.class_name?this.scene=this.space:this.scene=this.space.scene,this.alert_registry=new Map,this.alerted_elements=new Map,this.alerts=new Map,this.test=!0,this.tipo=i,this.field=a,this.collection=o,this.store=s,this.event_bus=null,this.injectAlertCardStyles(),this.space.alert_controller=this,document.addEventListener("change",(function(e){if(e.target.matches('input[type="radio"][name^="alert-"]')){var t=e.target.value,r=e.target.dataset.object;if(console.log("Selected alert:",t,"for object:",r),n.event_bus){var i=n.alert_registry.get(t);n.event_bus.emit("alertas","selected",{alert:i})}}})),this.scene.addUpdatable(this)},t=[{key:"injectAlertCardStyles",value:function(){if(!document.getElementById("alert-card-styles")){var e=document.createElement("style");e.id="alert-card-styles",e.textContent="\n .alert-card {\n font-family: sans-serif;\n border-radius: 8px;\n padding: 12px;\n background: #1e1e1e;\n color: #eee;\n width: 320px;\n box-shadow: 0 4px 12px rgba(0,0,0,0.4);\n }\n \n .alert-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 8px;\n }\n \n .alert-title {\n font-size: 16px;\n font-weight: bold;\n }\n \n .alert-status {\n font-size: 12px;\n padding: 2px 6px;\n border-radius: 4px;\n background: #444;\n }\n \n .alert-body {\n font-size: 13px;\n margin-bottom: 8px;\n }\n \n .alert-row {\n margin-bottom: 4px;\n }\n \n .alert-footer {\n font-size: 11px;\n opacity: 0.85;\n }\n \n .alert-asset {\n display: inline-block;\n background: #333;\n padding: 2px 6px;\n margin-right: 4px;\n border-radius: 4px;\n }\n\n .alert-status-select {\n background: #333;\n color: #eee;\n border: 1px solid #555;\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n }\n \n /* Severity coloring */\n .severity-baja { border-left: 4px solid #4caf50; }\n .severity-media { border-left: 4px solid #ff9800; }\n .severity-alta { border-left: 4px solid #f44336; }\n ",document.head.appendChild(e)}}},{key:"setEventBus",value:function(e){this.event_bus=e}},{key:"addAlertedElement",value:function(e,t){var r,n="".concat(this.collection,":").concat(e.id),i=null!==(r=this.alerted_elements.get(n))&&void 0!==r?r:[];i.push(t),this.alerted_elements.set(n,i)}},{key:"getAlertById",value:function(e,t){var r,n="".concat(this.collection,":").concat(e.id),i=this.alerted_elements.get(n);return null!==(r=null==i?void 0:i.find((function(e){return e.id===t})))&&void 0!==r?r:null}},{key:"removeAlertById",value:function(e,t){var r="".concat(this.collection,":").concat(e.id),n=this.alerted_elements.get(r);if(!n)return!1;var i=n.findIndex((function(e){return e.id===t}));return-1!==i&&(n.splice(i,1),0===n.length&&this.alerted_elements.delete(r),!0)}},{key:"getAlertsCountForObject",value:function(e){var t,r,n="".concat(this.collection,":").concat(e.id);return null!==(t=null===(r=this.alerted_elements.get(n))||void 0===r?void 0:r.length)&&void 0!==t?t:0}},{key:"process",value:function(e){console.log("procesando",e);var t=this.collection+":"+e.id;this.alerted_elements.get(t)&&this.create_alert_graphics({id:t,x:e.x,y:e.y,z:e.z})}},{key:"create_alert_graphics_old",value:function(e){var t=this;this.removeAlertGraphics(e);var r=this.alerted_elements.get(e.id);if(r&&0!==r.length){var n=new this.scene.THREE.Group;n.name="alert-group-".concat(e.id),r.forEach((function(e,r){var i,o=1+.3*r,s=o+.25,l=null!==(i=a[e.severidad])&&void 0!==i?i:16777215,c=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(o,s,48),new t.scene.THREE.MeshBasicMaterial({color:l,side:t.scene.THREE.DoubleSide,transparent:!0,opacity:.85,depthWrite:!1,depthTest:!0}));c.rotation.x=Math.PI/2,c.userData.alertId=e.id,c.userData.severidad=e.severidad,n.add(c)})),n.position.set(e.x,e.y,e.z),this.scene.add(n),this.alerts.set(e.id,{group:n})}}},{key:"statusToProgress",value:function(e){var t;return null!==(t=o[e])&&void 0!==t?t:0}},{key:"create_alert_graphics",value:function(e){var t=this;this.removeAlertGraphics(e);var r=this.alerted_elements.get(e.id);if(r&&0!==r.length){var n=new this.scene.THREE.Group;n.name="alert-group-".concat(e.id),r.forEach((function(r,i){var o,s=1+.3*i,l=s+.25,c=null!==(o=a[r.severidad])&&void 0!==o?o:16777215,d=r.estatus,u=t.statusToProgress(d),h=new t.scene.THREE.MeshBasicMaterial({color:c,side:t.scene.THREE.DoubleSide,transparent:!0,opacity:"Solucionada"===d?.25:.85,depthWrite:!1,depthTest:!1}),p=new t.scene.THREE.MeshBasicMaterial({color:c,transparent:!0,opacity:.15,side:t.scene.THREE.DoubleSide,depthWrite:!1,depthTest:!1}),v=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(s,l,64,1,0,2*Math.PI*u),h),f=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(s,l,64),p);v.rotation.x=Math.PI/2,f.rotation.x=Math.PI/2,v.renderOrder=1e3,f.renderOrder=999;var y=new t.scene.THREE.Group;y.name="alert-".concat(e.id,"-").concat(r.id),y.add(f),y.add(v),v.userData={alertId:r.id,severidad:r.severidad,status:d,progress:u,targetProgress:u,pulse:"Nueva"===d||"En Proceso"===d,pulseSpeed:"En Proceso"===d?3:1.2,rotate:"En Proceso"===d},n.add(y)})),n.position.set(e.x,e.y,e.z),n.renderOrder=1e3,this.scene.add(n),this.alerts.set(e.id,{group:n})}}},{key:"removeAlertGraphics_old",value:function(e){var t=this.alerts.get(e.id);t&&(t.group.traverse((function(e){e.isMesh&&(e.geometry.dispose(),e.material.dispose())})),this.scene.scene.remove(t.group),this.alerts.delete(e.id))}},{key:"destroyGroup",value:function(e,t){e&&(e.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach((function(e){return e.dispose()})):e.material.dispose())})),e.parent&&e.parent.remove(e),e.clear())}},{key:"removeAlertGraphics",value:function(e){console.log("removing");var t=this.alerts.get(e.id);if(t){var r=t.group;this.destroyGroup(r,this.scene.scene),this.alerts.delete(e.id)}}},{key:"removeAlert",value:function(e){var t="".concat(this.collection,":").concat(e.id);this.removeAlertGraphics({id:t})}},{key:"unregister_alert",value:function(e){var t=this,r=e[this.tipo];if(r){var n=this.store.getRecordByField(this.collection,this.field,r);n&&(this.removeAlertById(n,e.id),this.getAlertsCountForObject(n)<1&&this.removeAlertGraphics(n))}else{var i=e.activos;i&&i.forEach((function(r){if(r.type==t.tipo){var n=r.identificador,i=t.store.getRecordByField(t.collection,t.field,n);i&&(t.removeAlertById(i,e.id),t.getAlertsCountForObject(i)<1&&t.removeAlertGraphics(i))}}))}}},{key:"register_alert",value:function(e){var t=this,r=this.alert_registry.get(e.id);r&&(console.log("alerta preexistente"),this.unregister_alert(r)),this.alert_registry.set(e.id,e);var n=e[this.tipo];if(n){var i=this.store.getRecordByField(this.collection,this.field,n);i&&this.addAlertedElement(i,e)}else{var a=e.activos;a&&a.forEach((function(r){if(r.type==t.tipo){var n=r.identificador,i=t.store.getRecordByField(t.collection,t.field,n);i&&t.addAlertedElement(i,e)}}))}}},{key:"check_all",value:function(){var e=this,t={visit:function(t,r,n){if(e.alerted_elements.has(n.id)||e.alerted_elements.has(r)){console.log("crea alerta para vehiculo");var i={x:0,y:0,z:0};i.x=n.mesh?n.mesh.position.x:n.position.x,i.y=n.mesh?n.mesh.position.y:n.position.y,i.z=n.mesh?n.mesh.position.z:n.position.z,e.create_alert_graphics({id:n.id,x:i.x,y:i.y,z:i.z})}}};this.space.applyVisitor2Objects(t)}},{key:"set",value:function(e){var t=this;this.domain=e.collection,e.result.data.forEach((function(e){t.register_alert(e)})),console.log("CECKING ALL"),this.check_all()}},{key:"add_or_update",value:function(e){this.register_alert(e.result.data),this.check_all(),this.scene.touch()}},{key:"delete",value:function(e){var t=this.alert_registry.get(e.id);t&&(console.log("borrando alerta"),this.unregister_alert(t),this.check_all(),this.scene.touch())}},{key:"getInfo",value:function(e){var t="".concat(this.collection,":").concat(e.id),r=this.alerted_elements.get(t);if(!r||0===r.length)return"";var n='<div class="alert-list">';return r.forEach((function(t){n+='\n <label class="alert-item">\n <input \n type="radio"\n name="alert-'.concat(e.id,'"\n value="').concat(t.id,'"\n data-object="').concat(e.id,'"\n />\n ').concat(t.nombre,"\n </label><br>\n ")})),n+="</div>"}},{key:"updateAlertAnimations",value:function(e){this.alerts.forEach((function(t){t.group.children.forEach((function(t){t.children.forEach((function(t){var r=t.userData;r&&(r.rotate&&(t.rotation.z+=.01),r.pulse&&(t.material.opacity=.65+.2*Math.sin(.002*e*r.pulseSpeed)))}))}))}))}},{key:"update",value:function(e){this.updateAlertAnimations(e)}}],t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),l=t.W;export{l as vi_alert_controller};
|