vizor_alerts 1.3.9 → 1.4.1
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,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return n="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},n(e)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}e.d(t,{W:()=>
|
|
1
|
+
var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return n="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},n(e)}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(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,n){var r=this,i=n.tipo,a=n.field,o=n.collection,s=n.store;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.space=t,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(),document.addEventListener("change",(function(e){if(e.target.matches('input[type="radio"][name^="alert-"]')){var t=e.target.value,n=e.target.dataset.object;if(console.log("Selected alert:",t,"for object:",n),r.event_bus){var i=r.alert_registry.get(t);r.event_bus.emit("alert","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 n,r="".concat(this.collection,":").concat(e.id),i=null!==(n=this.alerted_elements.get(r))&&void 0!==n?n:[];i.push(t),this.alerted_elements.set(r,i)}},{key:"getAlertById",value:function(e,t){var n,r="".concat(this.collection,":").concat(e.id),i=this.alerted_elements.get(r);return null!==(n=null==i?void 0:i.find((function(e){return e.id===t})))&&void 0!==n?n:null}},{key:"removeAlertById",value:function(e,t){var n="".concat(this.collection,":").concat(e.id),r=this.alerted_elements.get(n);if(!r)return!1;var i=r.findIndex((function(e){return e.id===t}));return-1!==i&&(r.splice(i,1),0===r.length&&this.alerted_elements.delete(n),!0)}},{key:"getAlertsCountForObject",value:function(e){var t,n,r="".concat(this.collection,":").concat(e.id);return null!==(t=null===(n=this.alerted_elements.get(r))||void 0===n?void 0:n.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 n=this.alerted_elements.get(e.id);if(n&&0!==n.length){var r=new this.scene.THREE.Group;r.name="alert-group-".concat(e.id),n.forEach((function(e,n){var i,o=1+.3*n,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,r.add(c)})),r.position.set(e.x,e.y,e.z),this.scene.add(r),this.alerts.set(e.id,{group:r})}}},{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 n=this.alerted_elements.get(e.id);if(n&&0!==n.length){var r=new this.scene.THREE.Group;r.name="alert-group-".concat(e.id),n.forEach((function(e,n){var i,o=1+.3*n,s=o+.25,l=null!==(i=a[e.severidad])&&void 0!==i?i:16777215,c=e.estatus,d=t.statusToProgress(c),u=new t.scene.THREE.MeshBasicMaterial({color:l,side:t.scene.THREE.DoubleSide,transparent:!0,opacity:"Solucionada"===c?.25:.85,depthWrite:!1,depthTest:!0}),h=new t.scene.THREE.MeshBasicMaterial({color:l,transparent:!0,opacity:.15,side:t.scene.THREE.DoubleSide,depthWrite:!1}),p=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(o,s,64,1,0,2*Math.PI*d),u),v=new t.scene.THREE.Mesh(new t.scene.THREE.RingGeometry(o,s,64),h);p.rotation.x=Math.PI/2,v.rotation.x=Math.PI/2,p.position.y=.001,p.userData={alertId:e.id,severidad:e.severidad,status:c,progress:d,targetProgress:d,pulse:"Nueva"===c||"En Proceso"===c,pulseSpeed:"En Proceso"===c?3:1.2,rotate:"En Proceso"===c};var f=new t.scene.THREE.Group;f.add(v),f.add(p),r.add(f)})),r.position.set(e.x,e.y,e.z),this.scene.add(r),this.alerts.set(e.id,{group:r})}}},{key:"removeAlertGraphics",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:"removeAlert",value:function(e){var t="".concat(this.collection,":").concat(e.id);this.alerted_elements.delete(t),this.removeAlertGraphics(t)}},{key:"unregister_alert",value:function(e){var t=this,n=e.activos;n&&n.forEach((function(n){if(n.type==t.tipo){var r=n.identificador,i=t.store.getRecordByField(t.collection,t.field,r);i&&(t.removeAlertById(i,e.id),t.getAlertsCountForObject(i)<1&&t.removeAlertGraphics(i))}}))}},{key:"register_alert",value:function(e){var t=this,n=this.alert_registry.get(e.id);n&&(console.log("alerta preexistente"),this.unregister_alert(n)),this.alert_registry.set(e.id,e);var r=e.activos;r&&r.forEach((function(n){if(n.type==t.tipo){var r=n.identificador,i=t.store.getRecordByField(t.collection,t.field,r);i&&t.addAlertedElement(i,e)}}))}},{key:"check_all",value:function(){var e=this,t={visit:function(t,n,r){e.alerted_elements.has(r.id)&&(console.log("crea alerta para vehiculo"),e.create_alert_graphics({id:r.id,x:r.mesh.position.x,y:r.mesh.position.y,z:r.mesh.position.z}))}};this.space.applyVisitor2Objects(t)}},{key:"set",value:function(e){var t=this;e.result.data.forEach((function(e){t.register_alert(e)})),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),n=this.alerted_elements.get(t);if(!n||0===n.length)return"";var r='<div class="alert-list">';return n.forEach((function(t){r+='\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 ")})),r+="</div>"}},{key:"updateAlertAnimations",value:function(e){this.alerts.forEach((function(t){t.group.children.forEach((function(t){var n=t.userData;n&&(n.rotate&&(t.rotation.z+=.01),n.pulse&&(t.material.opacity=.65+.2*Math.sin(.002*e*n.pulseSpeed)))}))}))}},{key:"update",value:function(e){this.updateAlertAnimations(e)}}],t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}(),l=t.W;export{l as vi_alert_controller};
|