@senx/discovery-plugin-marauder
Version:
Discovery plugin - Marauder's map
2 lines • 14.3 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,i,e,n){function r(t){return t instanceof e?t:new e((function(i){i(t)}))}return new(e||(e=Promise))((function(e,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function u(t){try{a(n["throw"](t))}catch(t){s(t)}}function a(t){t.done?e(t.value):r(t.value).then(o,u)}a((n=n.apply(t,i||[])).next())}))};var __generator=this&&this.__generator||function(t,i){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,o;return o={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(t){return function(i){return a([t,i])}}function a(u){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,u[0]&&(e=0)),e)try{if(n=1,r&&(s=u[0]&2?r["return"]:u[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;if(r=0,s)u=[u[0]&2,s.value];switch(u[0]){case 0:case 1:s=u;break;case 4:e.label++;return{value:u[1],done:false};case 5:e.label++;r=u[1];u=[0];continue;case 7:u=e.ops.pop();e.trys.pop();continue;default:if(!(s=e.trys,s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){e.label=u[1];break}if(u[0]===6&&e.label<s[1]){e.label=s[1];s=u;break}if(s&&e.label<s[2]){e.label=s[2];e.ops.push(u);break}if(s[2])e.ops.pop();e.trys.pop();continue}u=i.call(t,e)}catch(t){u=[6,t];r=0}finally{n=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-f2d2b9b0.system.js","./p-17ad0a00.system.js","./p-a66f6e87.system.js","./p-c59742af.system.js"],(function(t){"use strict";var i,e,n,r,s,o,u,a,c,h,f;return{setters:[function(t){i=t.r;e=t.c;n=t.h;r=t.g},function(t){s=t.P;o=t.U},function(t){u=t.l;a=t.L;c=t.v;h=t.G},function(t){f=t.L}],execute:function(){var d='/*!\n * Copyright 2022-2024 SenX S.A.S.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *//*!\n * Copyright 2022-2024 SenX S.A.S.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */:host{width:100%;height:100%;position:relative}:host>div{width:100%;height:100%;position:relative}:host #ws{color:transparent;font-size:0;height:0;overflow:hidden}:host .discovery-tile-spinner{position:absolute;top:0;left:0;width:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:100%}:host .discovery-tile-error{background-color:var(--warp-view-error-bg-color, #dc3545);color:var(--warp-view-error-color, #ffffff);text-align:center}:host .discovery-tile-status{background-color:var(--warp-view-status-bg-color, #d1ecf1);color:var(--warp-view-status-color, #0c5460);text-align:center;position:relative;padding:5px 10px;width:calc(100% - 40px);margin-top:12px}';var l=d;var v=t("discovery_tile",function(){function t(t){i(this,t);this.statusHeaders=e(this,"statusHeaders",7);this.statusError=e(this,"statusError",7);this.execResult=e(this,"execResult",7);this.selfType=e(this,"selfType",7);this.innerVars={};this.innerOptions=new s;this.firstExec=false;this.url=undefined;this.chartTitle=undefined;this.chartDescription=undefined;this.type=undefined;this.options=new s;this.language="warpscript";this.debug=false;this.unit="";this.autoRefresh=-1;this.vars="{}";this.loaded=false;this.result="[]";this.width=undefined;this.height=undefined;this.headers=undefined;this.start=undefined;this.showLoader=false;this.hasError=false;this.errorMessage="";this.statusMessage=""}t.prototype.optionsUpdate=function(t,i){var e,n;(e=this.LOG)===null||e===void 0?void 0:e.debug(["optionsUpdate"],t,i);var r=t;if(!!t&&typeof t==="string"){r=JSON.parse(t)}if(!u.exports.isEqual(r,this.innerOptions)){this.innerOptions=Object.assign({},r);(n=this.LOG)===null||n===void 0?void 0:n.debug(["optionsUpdate 2"],{options:this.innerOptions,newValue:t,oldValue:i})}console.log("optionsUpdate",this.type,this.innerOptions)};t.prototype.varsUpdate=function(t,i){return __awaiter(this,void 0,void 0,(function(){var e,n;return __generator(this,(function(r){switch(r.label){case 0:n=this.vars;if(!!this.vars&&typeof this.vars==="string"){n=JSON.parse(this.vars)}if(!!u.exports.isEqual(n,this.innerVars))return[3,2];this.innerVars=n;return[4,this.exec(true)];case 1:r.sent();r.label=2;case 2:if(this.LOG){(e=this.LOG)===null||e===void 0?void 0:e.debug(["varsUpdate"],{vars:this.vars,newValue:t,oldValue:i})}return[2]}}))}))};t.prototype.discoveryEventHandler=function(t){return __awaiter(this,void 0,void 0,(function(){var i;return __generator(this,(function(e){switch(e.label){case 0:i=o.parseEventData(t.detail,this.innerOptions.eventHandler,this.componentId);if(!i.vars)return[3,2];this.innerVars=Object.assign(Object.assign({},this.innerVars||{}),i.vars);if(!!(this.innerOptions.mutedVars||[]).includes(t.detail.selector))return[3,2];return[4,this.exec(true)];case 1:e.sent();e.label=2;case 2:if(!i.selected)return[3,4];this.innerVars=Object.assign(Object.assign({},this.innerVars||{}),i.selected);if(!!(this.innerOptions.mutedVars||[]).includes(t.detail.selector))return[3,4];return[4,this.exec(true)];case 3:e.sent();e.label=4;case 4:return[2]}}))}))};t.prototype.resize=function(){return __awaiter(this,void 0,void 0,(function(){var t,i;return __generator(this,(function(e){i=o.getContentBounds(this.el.parentElement);this.width=i.w-15;this.height=i.h;(t=this.LOG)===null||t===void 0?void 0:t.debug(["componentDidLoad"],"Tile - resize",this.tileResult);if(this.tileResult){return[2,this.tileResult.resize()]}return[2]}))}))};t.prototype.show=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){switch(i.label){case 0:if(!this.tileResult)return[3,2];return[4,this.tileResult.show(t)];case 1:i.sent();i.label=2;case 2:return[2]}}))}))};t.prototype.showById=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){switch(i.label){case 0:if(!this.tileResult)return[3,2];return[4,this.tileResult.showById(t)];case 1:i.sent();i.label=2;case 2:return[2]}}))}))};t.prototype.hide=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){switch(i.label){case 0:if(!this.tileResult)return[3,2];return[4,this.tileResult.hide(t)];case 1:i.sent();i.label=2;case 2:return[2]}}))}))};t.prototype.hideById=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){switch(i.label){case 0:if(!this.tileResult)return[3,2];return[4,this.tileResult.hideById(t)];case 1:i.sent();i.label=2;case 2:return[2]}}))}))};t.prototype.setFocus=function(t,i,e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:if(!this.tileResult)return[3,2];return[4,this.tileResult.setFocus(t,i,e)];case 1:n.sent();n.label=2;case 2:return[2]}}))}))};t.prototype.unFocus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!this.tileResult)return[3,2];return[4,this.tileResult.unFocus()];case 1:t.sent();t.label=2;case 2:return[2]}}))}))};t.prototype.componentWillLoad=function(){var t,i;this.LOG=new a(v,this.debug);this.componentId=c();(t=this.LOG)===null||t===void 0?void 0:t.debug(["componentWillLoad"],{url:this.url,type:this.type,options:this.options,language:this.language,innerVars:this.innerVars});if(!!this.options&&typeof this.options==="string"&&this.options!=="undefined"){this.innerOptions=JSON.parse(this.options)}else{this.innerOptions=Object.assign({},(i=this.options)!==null&&i!==void 0?i:new s)}this.innerVars=JSON.parse(this.vars||"{}");var e=o.getContentBounds(this.el.parentElement);this.width=e.w-15;this.height=e.h};t.prototype.componentDidLoad=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:if(!!this.firstExec)return[3,2];return[4,this.exec()];case 1:t.sent();t.label=2;case 2:return[2]}}))}))};t.prototype.disconnectedCallback=function(){var t;(t=this.LOG)===null||t===void 0?void 0:t.debug(["disconnectedCallback"],"disconnected");if(this.timer){window.clearInterval(this.timer)}if(!!this.socket){this.socket.close()}};t.prototype.export=function(){return __awaiter(this,arguments,void 0,(function(t){if(t===void 0){t="png"}return __generator(this,(function(i){if(this.tileResult){return[2,this.tileResult.export(t)]}else{return[2,undefined]}return[2]}))}))};t.prototype.exec=function(){return __awaiter(this,arguments,void 0,(function(t){var i=this;if(t===void 0){t=false}return __generator(this,(function(e){return[2,new Promise((function(e){var n,r,s;if(((n=i.el)===null||n===void 0?void 0:n.innerHTML)!==undefined){if(!t){setTimeout((function(){return i.loaded=false}))}i.ws=f.prepare(o.unsescape(i.el.innerHTML),i.innerVars||{},((r=i.innerOptions)===null||r===void 0?void 0:r.skippedVars)||[],i.type,i.language);if(!!window){var u=window;var a=u.DiscoveryPluginRegistry;a=a||{};if(!!(a||{})[i.type]&&!!a[i.type].scriptWrapper&&typeof a[i.type].scriptWrapper==="function"){i.ws=a[i.type].scriptWrapper(i.ws)}}(s=i.LOG)===null||s===void 0?void 0:s.debug(["exec"],i.ws,i.type);i.url=o.getUrl(i.url);if(i.url.toLowerCase().startsWith("http")){setTimeout((function(){i.hasError=false;i.errorMessage="";i.statusMessage=undefined;if(i.innerOptions.showLoader){i.showLoader=true}}));o.httpPost(i.url,i.ws,i.innerOptions.httpHeaders).then((function(n){var r;var s=i.result===n.data;if((i.type||"").startsWith("input")){i.result=""}i.headers=n.headers;i.headers.statusText="Your script execution took ".concat(h.formatElapsedTime(n.status.elapsed)," serverside, fetched ").concat(n.status.fetched," datapoints and performed ").concat(n.status.ops," WarpLib operations.");(r=i.LOG)===null||r===void 0?void 0:r.debug(["exec","headers"],i.headers);i.statusHeaders.emit(i.headers);if(i.innerOptions.showStatus){i.statusMessage=i.headers.statusText}i.start=(new Date).getTime();if(i.autoRefresh!==i.innerOptions.autoRefresh){i.autoRefresh=i.innerOptions.autoRefresh;if(i.timer){window.clearInterval(i.timer)}if(i.autoRefresh&&i.autoRefresh>0){i.timer=window.setInterval((function(){return void i.exec(true)}),i.autoRefresh*1e3)}}setTimeout((function(){void function(){return __awaiter(i,void 0,void 0,(function(){var i;return __generator(this,(function(r){switch(r.label){case 0:this.loaded=true;this.showLoader=false;(i=this.LOG)===null||i===void 0?void 0:i.debug(["exec","result"],this.result);this.result=n.data;this.execResult.emit(this.result);if(!(s&&t&&!!this.tileResult))return[3,2];return[4,this.tileResult.parseEvents()];case 1:r.sent();r.label=2;case 2:e(true);return[2]}}))}))}()}))})).catch((function(t){var n;i.statusError.emit(t);setTimeout((function(){i.loaded=true;i.showLoader=false;i.hasError=i.innerOptions.showErrors;i.errorMessage=t.message||t.statusText}));(n=i.LOG)===null||n===void 0?void 0:n.error(["exec"],t);e(true)}))}else if(i.url.toLowerCase().startsWith("ws")){if(!!i.socket){i.socket.close()}i.socket=new WebSocket(i.url);i.socket.onopen=function(){i.socket.onmessage=function(t){var e;var n=t.data;setTimeout((function(){i.loaded=true;i.showLoader=false}));if(n.startsWith("[\"Exception at 'EVERY")){i.hasError=i.innerOptions.showErrors;i.errorMessage=JSON.parse(n)[0]||"Error";i.statusError.emit(i.errorMessage)}else{i.result=n;i.hasError=false;i.errorMessage="";(e=i.LOG)===null||e===void 0?void 0:e.debug(["exec","result"],i.result);i.execResult.emit(i.result)}};i.socket.send("<% ".concat(i.ws," %> ").concat(i.innerOptions.autoRefresh||1e3," EVERY"));e(true)}}}}))]}))}))};t.prototype.setZoom=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){switch(i.label){case 0:return[4,this.tileResult.setZoom(t)];case 1:i.sent();return[2]}}))}))};t.prototype.handleSelfType=function(t){this.selfType.emit(t)};t.prototype.render=function(){var t=this;return n("div",{key:"919e5adf56b4263b461a1ff2877c7bc4b47362f2"},this.loaded?this.hasError?n("div",{class:"discovery-tile-error"},this.errorMessage):n("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column"}},n("discovery-tile-result",{url:this.url,start:this.start,result:this.result,type:this.type,options:this.innerOptions,unit:this.unit,debug:this.debug,height:this.height,width:this.width,language:this.language,"chart-title":this.chartTitle,"chart-description":this.chartDescription,onSelfType:function(i){return t.handleSelfType(i)},vars:JSON.stringify(this.innerVars),ref:function(i){return t.tileResult=i},id:this.componentId}),this.statusMessage?n("div",{class:"discovery-tile-status"},this.statusMessage):""):n("div",{class:"discovery-tile-spinner"},this.showLoader?n("discovery-spinner",null,"Requesting data..."):""),this.showLoader?n("div",{class:"discovery-tile-spinner"},n("discovery-spinner",null,"Requesting data...")):"",n("pre",{key:"b406cafb81b093bf5b2150dd55ae2be3ff1fdbb1",id:"ws"},n("slot",{key:"e07f266a931e56bbfeed86f3ec71daf8cd5074e2"})))};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{options:["optionsUpdate"],vars:["varsUpdate"]}},enumerable:false,configurable:true});return t}());v.style=l}}}));
//# sourceMappingURL=p-1e4ff5e3.system.entry.js.map