@ixon-cdk/iframe-adapter 1.3.0 → 1.4.0-next.0
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/index.d.ts +13 -0
- package/dist/index.js +829 -0
- package/dist/index.umd.cjs +1 -0
- package/package.json +16 -7
- package/index.d.ts +0 -9
- package/index.js +0 -603
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(u,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(u=typeof globalThis<"u"?globalThis:u||self,i(u["@ixon-cdk/iframe-adapter"]={}))})(this,function(u){"use strict";var et=Object.defineProperty;var tt=(u,i,s)=>i in u?et(u,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):u[i]=s;var g=(u,i,s)=>(tt(u,typeof i!="symbol"?i+"":i,s),s);const i="cdk:cmpctx:",s={Create:`${i}create`,Created:`${i}created`,Destroy:`${i}destroy`,BackendComponentClientCreate:`${i}bcc:create`,BackendComponentClientDestroy:`${i}bcc:destroy`,BackendComponentClientCall:`${i}bcc:call`,BackendComponentClientCallResult:`${i}bcc:callresult`,LoggingDataClientCreate:`${i}ldc:create`,LoggingDataClientDestroy:`${i}ldc:destroy`,LoggingDataClientQuery:`${i}ldc:query`,LoggingDataClientQueryResult:`${i}ldc:queryresult`,ResourceDataClientCreate:`${i}rdc:create`,ResourceDataClientDestroy:`${i}rdc:destroy`,ResourceDataClientQuery:`${i}rdc:query`,ResourceDataClientQueryResult:`${i}rdc:queryresult`,ResourceDataClientRender:`${i}rdc:render`,ResourceDataClientRenderResult:`${i}rdc:renderresult`,ResourceDataClientUpdate:`${i}rdc:update`,ResourceDataClientUpdated:`${i}rdc:updated`,OpenActionBottomSheet:`${i}openactionbottomsheet`,OpenActionBottomSheetResult:`${i}openactionbottomsheetresult`,OpenAlertDialog:`${i}openalertdialog`,OpenAlertDialogResult:`${i}openalertdialogresult`,OpenConfirmDialog:`${i}openconfirmdialog`,OpenConfirmDialogResult:`${i}openconfirmdialogresult`,OpenFormDialog:`${i}openformdialog`,OpenFormDialogResult:`${i}openformdialogresult`,ShowVpnStatusDetails:`${i}showvpnstatusdetails`,ToggleVpn:`${i}togglevpn`,VpnClientStatusChange:`${i}vpnclientstatuschange`,NavigateByUrl:`${i}navigatebyurl`,SetTimeRange:`${i}settimerange`,TimeRangeChange:`${i}timerangechange`};function k({iframe:t,context:e}){return window.addEventListener("message",a,!1),e.ontimerangechange=(...r)=>{t.contentWindow&&t.contentWindow.postMessage({type:s.TimeRangeChange,payload:r},"*")},e.onvpnclientstatuschange=(...r)=>{t.contentWindow&&t.contentWindow.postMessage({type:s.VpnClientStatusChange,payload:r},"*")},{destroy(){window.removeEventListener("message",a,!1)}};function n(r){return{_apiLinkEntries:[...r._getApiLinks().entries()],appData:r.appData,componentBaseUrl:r.componentBaseUrl,destroyed:r.destroyed,mode:r.mode,inputs:r.inputs,timeRange:r.timeRange,timeRangeIsAdjustable:r.timeRangeIsAdjustable,vpnClientStatus:r.vpnClientStatus}}function a(r){if(a._clients=a._clients||new Map([]),r.source===t.contentWindow)switch(r.data.type){case s.Create:t.contentWindow.postMessage({type:s.Created,payload:n(e)},"*");break;case s.Destroy:e.destroy();break;case s.BackendComponentClientCreate:{const{clientId:o}=r.data.payload,l=e.createBackendComponentClient(o);a._clients.set(o,l);break}case s.BackendComponentClientDestroy:{const{clientId:o}=r.data.payload;a._clients.has(o)&&(a._clients.get(o).destroy(),a._clients.delete(o));break}case s.BackendComponentClientCall:{const{clientId:o,callId:l,functionName:c,functionArguments:d}=r.data.payload;let p=a._clients.get(o);p&&!p._destroyed&&p.call(c,d).then(O=>{p&&!p.destroyed&&t.contentWindow.postMessage({type:s.BackendComponentClientCallResult,payload:{callId:l,result:O}},"*")});break}case s.LoggingDataClientCreate:{const{clientId:o}=r.data.payload,l=e.createLoggingDataClient(o);a._clients.set(o,l);break}case s.LoggingDataClientDestroy:{const{clientId:o}=r.data.payload;a._clients.has(o)&&(a._clients.get(o).destroy(),a._clients.delete(o));break}case s.LoggingDataClientQuery:{const{clientId:o,queryId:l,query:c}=r.data.payload;let d=a._clients.get(o);d&&!d._destroyed&&d.query(c,p=>{d._destroyed||t.contentWindow.postMessage({type:s.LoggingDataClientQueryResult,payload:{queryId:l,results:p}},"*")});break}case s.ResourceDataClientCreate:{const{clientId:o}=r.data.payload,l=e.createResourceDataClient(o);a._clients.set(o,l);break}case s.ResourceDataClientDestroy:{const{clientId:o}=r.data.payload;a._clients.has(o)&&(a._clients.get(o).destroy(),a._clients.delete(o));break}case s.ResourceDataClientQuery:{const{clientId:o,queryId:l,query:c}=r.data.payload;let d=a._clients.get(o);d&&!d._destroyed&&d.query(c,p=>{d._destroyed||t.contentWindow.postMessage({type:s.ResourceDataClientQueryResult,payload:{queryId:l,results:p}},"*")});break}case s.ResourceDataClientRender:{const{clientId:o,queryId:l,query:c}=r.data.payload;let d=a._clients.get(o);d&&!d._destroyed&&d.render(c,p=>{d._destroyed||t.contentWindow.postMessage({type:s.ResourceDataClientRenderResult,payload:{queryId:l,results:p}},"*")});break}case s.ResourceDataClientUpdate:{const{clientId:o,updateId:l,update:c}=r.data.payload;let d=a._clients.get(o);d&&!d._destroyed&&d.update(c).then(()=>{d&&!d._destroyed&&t.contentWindow.postMessage({type:s.ResourceDataClientUpdated,payload:{updateId:l}},"*")});break}case s.OpenActionBottomSheet:e.openActionBottomSheet(r.data.payload.options).then(o=>{t.contentWindow.postMessage({type:s.OpenActionBottomSheetResult,payload:{result:o}},"*")});break;case s.OpenAlertDialog:e.openAlertDialog(r.data.payload.options).then(o=>{t.contentWindow.postMessage({type:s.OpenAlertDialogResult,payload:{result:o}},"*")});break;case s.OpenConfirmDialog:e.openConfirmDialog(r.data.payload.options).then(o=>{t.contentWindow.postMessage({type:s.OpenConfirmDialogResult,payload:{result:o}},"*")});break;case s.OpenFormDialog:e.openFormDialog(r.data.payload.options).then(o=>{t.contentWindow.postMessage({type:s.OpenFormDialogResult,payload:{result:o}},"*")});break;case s.ShowVpnStatusDetails:e.showVpnStatusDetails(r.data.payload.agentId);break;case s.ToggleVpn:e.toggleVpn(r.data.payload.agentId);break;case s.NavigateByUrl:e.navigateByUrl(r.data.payload.url);break;case s.SetTimeRange:e.setTimeRange(r.data.payload.timeRange);break}}}class B{constructor(e,n,a,r){this.query=e,this.variable=n,this.tag=a,this._onCancel=r,Object.freeze(this)}cancel(){this._onCancel&&this._onCancel()}}var F=typeof global=="object"&&global&&global.Object===Object&&global;const V=F;var P=typeof self=="object"&&self&&self.Object===Object&&self,H=V||P||Function("return this")();const v=H;var N=v.Symbol;const _=N;var L=Object.prototype,W=L.hasOwnProperty,Q=L.toString,w=_?_.toStringTag:void 0;function z(t){var e=W.call(t,w),n=t[w];try{t[w]=void 0;var a=!0}catch{}var r=Q.call(t);return a&&(e?t[w]=n:delete t[w]),r}var G=Object.prototype,J=G.toString;function K(t){return J.call(t)}var X="[object Null]",Y="[object Undefined]",M=_?_.toStringTag:void 0;function Z(t){return t==null?t===void 0?Y:X:M&&M in Object(t)?z(t):K(t)}function E(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var x="[object AsyncFunction]",ee="[object Function]",te="[object GeneratorFunction]",ae="[object Proxy]";function ne(t){if(!E(t))return!1;var e=Z(t);return e==ee||e==te||e==x||e==ae}var re=v["__core-js_shared__"];const $=re;var U=function(){var t=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function oe(t){return!!U&&U in t}var se=Function.prototype,ie=se.toString;function le(t){if(t!=null){try{return ie.call(t)}catch{}try{return t+""}catch{}}return""}var de=/[\\^$.*+?()[\]{}|]/g,ce=/^\[object .+?Constructor\]$/,pe=Function.prototype,ue=Object.prototype,ge=pe.toString,ye=ue.hasOwnProperty,he=RegExp("^"+ge.call(ye).replace(de,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fe(t){if(!E(t)||oe(t))return!1;var e=ne(t)?he:ce;return e.test(le(t))}function me(t,e){return t==null?void 0:t[e]}function T(t,e){var n=me(t,e);return fe(n)?n:void 0}function we(t,e){return t===e||t!==t&&e!==e}var Ce=T(Object,"create");const C=Ce;function _e(){this.__data__=C?C(null):{},this.size=0}function De(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re="__lodash_hash_undefined__",be=Object.prototype,Ie=be.hasOwnProperty;function ve(t){var e=this.__data__;if(C){var n=e[t];return n===Re?void 0:n}return Ie.call(e,t)?e[t]:void 0}var $e=Object.prototype,Se=$e.hasOwnProperty;function Oe(t){var e=this.__data__;return C?e[t]!==void 0:Se.call(e,t)}var Le="__lodash_hash_undefined__";function Me(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=C&&e===void 0?Le:e,this}function y(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var a=t[e];this.set(a[0],a[1])}}y.prototype.clear=_e,y.prototype.delete=De,y.prototype.get=ve,y.prototype.has=Oe,y.prototype.set=Me;function Ee(){this.__data__=[],this.size=0}function D(t,e){for(var n=t.length;n--;)if(we(t[n][0],e))return n;return-1}var Ue=Array.prototype,Te=Ue.splice;function qe(t){var e=this.__data__,n=D(e,t);if(n<0)return!1;var a=e.length-1;return n==a?e.pop():Te.call(e,n,1),--this.size,!0}function je(t){var e=this.__data__,n=D(e,t);return n<0?void 0:e[n][1]}function Ae(t){return D(this.__data__,t)>-1}function ke(t,e){var n=this.__data__,a=D(n,t);return a<0?(++this.size,n.push([t,e])):n[a][1]=e,this}function f(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var a=t[e];this.set(a[0],a[1])}}f.prototype.clear=Ee,f.prototype.delete=qe,f.prototype.get=je,f.prototype.has=Ae,f.prototype.set=ke;var Be=T(v,"Map");const Fe=Be;function Ve(){this.size=0,this.__data__={hash:new y,map:new(Fe||f),string:new y}}function Pe(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function R(t,e){var n=t.__data__;return Pe(e)?n[typeof e=="string"?"string":"hash"]:n.map}function He(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e}function Ne(t){return R(this,t).get(t)}function We(t){return R(this,t).has(t)}function Qe(t,e){var n=R(this,t),a=n.size;return n.set(t,e),this.size+=n.size==a?0:1,this}function h(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var a=t[e];this.set(a[0],a[1])}}h.prototype.clear=Ve,h.prototype.delete=He,h.prototype.get=Ne,h.prototype.has=We,h.prototype.set=Qe;var ze="Expected a function";function S(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ze);var n=function(){var a=arguments,r=e?e.apply(this,a):a[0],o=n.cache;if(o.has(r))return o.get(r);var l=t.apply(this,a);return n.cache=o.set(r,l)||o,l};return n.cache=new(S.Cache||h),n}S.Cache=h;const Ge=2,q=1,j="";class b{constructor(e,n,a){this.locale=e,this.queryRef=n,this.rawValue=a}static create(e,n,a){return n.query.postAggr==="count"?new Je(e,n,a):new b(e,n,a)}getDecimals(e=Ge){return this.decimals??this.queryRef.query.decimals??e}getFactor(){var e,n,a;return this.factor??this.queryRef.query.factor??((n=(e=this.queryRef.tag)==null?void 0:e.variable)==null?void 0:n.factor)??((a=this.queryRef.variable)==null?void 0:a.factor)??q}getUnit(){var e,n,a;return this.unit??this.queryRef.query.unit??((n=(e=this.queryRef.tag)==null?void 0:e.variable)==null?void 0:n.unit)??((a=this.queryRef.variable)==null?void 0:a.unit)??j}setDecimals(e){this.decimals=e}setFactor(e){this.factor=e}setUnit(e){this.unit=e}getValue(){return this.rawValue}toString(){var a,r,o,l;const e=this.locale!==null?this.locale:void 0,n=S((c,d,p,O)=>{const xe={style:"decimal",minimumFractionDigits:Math.floor(d),maximumFractionDigits:Math.floor(d)};return`${new Intl.NumberFormat(O,xe).format(c)}${p?" "+p:""}`});return this.rawValue===null?"":this.queryRef.query.postAggr==="count"?n(this.rawValue,this.getDecimals(0),this.unit??this.queryRef.query.unit,e):((a=this.queryRef.variable)==null?void 0:a.type)==="str"?this.rawValue:((r=this.queryRef.variable)==null?void 0:r.type)==="bool"?this.rawValue?"True":"False":((o=this.queryRef.variable)==null?void 0:o.type)==="int"?n(this.rawValue,Number.isInteger(this.getFactor())?this.getDecimals(0):this.getDecimals(),this.getUnit(),e):((l=this.queryRef.variable)==null?void 0:l.type)==="float"?n(this.rawValue,this.getDecimals(),this.getUnit(),e):String(this.getValue())}}class Je extends b{getFactor(){return this.factor??this.queryRef.query.factor??q}getUnit(){return this.unit??this.queryRef.query.unit??j}}function A(t){return t.map(({queryRef:n,time:a,value:r})=>{const o=new B(n.query,n.variable,n.tag),l=b.create(r.locale,o,r.rawValue);return{queryRef:o,time:a,value:l}})}class m extends Error{constructor(){super("Method is not implemented"),this.name="NotImplementedError",this.message="Method is not implemented",this.stack="NotImplementedError: Method is not implemented"}}class Ke{constructor(e){g(this,"ontimerangechange",null);g(this,"onvpnclientstatuschange",null);g(this,"_getApiLinks");g(this,"appData");g(this,"componentBaseUrl");g(this,"destroyed");g(this,"mode");g(this,"inputs");g(this,"inputMap");g(this,"timeRange");g(this,"timeRangeIsAdjustable");g(this,"vpnClientStatus");this._getApiLinks=()=>new Map(e._apiLinkEntries),this.appData=e.appData,this.componentBaseUrl=e.componentBaseUrl,this.destroyed=e.destroyed,this.mode=e.mode,this.inputs=e.inputs,this.inputMap=new Map(Object.entries(this.inputs)),this.timeRange=e.timeRange,this.timeRangeIsAdjustable=e.timeRangeIsAdjustable,this.vpnClientStatus=e.vpnClientStatus,this._messageHandler=this._messageHandler.bind(this),window.addEventListener("message",this._messageHandler,!1)}_messageHandler(e){if(e.source===window.parent)switch(e.data.type){case s.TimeRangeChange:this.ontimerangechange&&this.ontimerangechange(...e.data.payload);break;case s.VpnClientStatusChange:this.onvpnclientstatuschange&&this.onvpnclientstatuschange(...e.data.payload);break}}createBackendComponentClient(){const e=crypto.randomUUID();return window.parent.postMessage({type:s.BackendComponentClientCreate,payload:{clientId:e}},"*"),new Xe(e)}createLoggingDataClient(){const e=crypto.randomUUID();return window.parent.postMessage({type:s.LoggingDataClientCreate,payload:{clientId:e}},"*"),new Ye(e)}createObjectStorageClient(){throw new m}createResourceDataClient(){const e=crypto.randomUUID();return window.parent.postMessage({type:s.ResourceDataClientCreate,payload:{clientId:e}},"*"),new Ze(e)}createTooltip(){throw new m}destroy(){window.parent.postMessage({type:s.Destroy},"*"),window.removeEventListener("message",this._messageHandler,!1),this.destroyed=!0}getApiUrl(e,n){const a=this._getApiLinks().get(e);if(!a)throw new Error("IxApiError: entry not found");return n?Object.keys(n).sort().reduce((r,o)=>{if(r.includes(`{${o}}`))return r.replace(`{${o}}`,n[o]);const l=new URL(r);return l.searchParams.set(o,n[o]),decodeURIComponent(l.href)},a.href):a.href}navigateByUrl(e){window.parent.postMessage({type:s.NavigateByUrl,payload:{url:e}},"*")}openActionBottomSheet(e){return new Promise(n=>{window.addEventListener("message",a,!1),window.parent.postMessage({type:s.OpenActionBottomSheet,payload:{options:e}},"*");function a(r){r.source===window.parent&&r.data.type===s.OpenActionBottomSheetResult&&(window.removeEventListener("message",a,!1),n(r.data.payload.result))}})}openAlertDialog(e){return new Promise(n=>{window.addEventListener("message",a,!1),window.parent.postMessage({type:s.OpenAlertDialog,payload:{options:e}},"*");function a(r){r.source===window.parent&&r.data.type===s.OpenAlertDialogResult&&(window.removeEventListener("message",a,!1),n(r.data.payload.result))}})}openConfirmDialog(e){return new Promise(n=>{window.addEventListener("message",a,!1),window.parent.postMessage({type:s.OpenConfirmDialog,payload:{options:e}},"*");function a(r){r.source===window.parent&&r.data.type===s.OpenConfirmDialogResult&&(window.removeEventListener("message",a,!1),n(r.data.payload.result))}})}openFormDialog(e){return new Promise(n=>{window.addEventListener("message",a,!1),window.parent.postMessage({type:s.OpenFormDialog,payload:{options:e}},"*");function a(r){r.source===window.parent&&r.data.type===s.OpenFormDialogResult&&(window.removeEventListener("message",a,!1),n(r.data.payload.result))}})}saveAsFile(){throw new m}setTimeRange(e){window.parent.postMessage({type:s.SetTimeRange,payload:{timeRange:e}},"*")}showVpnStatusDetails(e){window.parent.postMessage({type:s.ShowVpnStatusDetails,payload:{agentId:e}},"*")}testVpnAccess(){throw new m}toggleVpn(e){window.parent.postMessage({type:s.ToggleVpn,payload:{agentId:e}},"*")}translate(){throw new m}}class Xe{constructor(e){this.id=e}call(e,n){return new Promise(a=>{const r=crypto.randomUUID();window.addEventListener("message",o,!1),window.parent.postMessage({type:s.BackendComponentClientCall,payload:{clientId:this.id,callId:r,functionName:e,functionArguments:n}});function o(l){l.source===window.parent&&l.data.type===s.BackendComponentClientCallResult&&l.data.payload.callId===r&&(window.removeEventListener("message",o,!1),a(l.data.payload.result))}})}destroy(){window.parent.postMessage({type:s.BackendComponentClientDestroy,payload:{clientId:this.id}},"*")}}class Ye{constructor(e){this.id=e}query(e,n){const a=crypto.randomUUID();return window.addEventListener("message",r,!1),window.parent.postMessage({type:s.LoggingDataClientQuery,payload:{clientId:this.id,queryId:a,query:e}},"*"),()=>{window.removeEventListener("message",r,!1)};function r(o){if(o.source===window.parent&&o.data.type===s.LoggingDataClientQueryResult&&o.data.payload.queryId===a){const{results:l}=o.data.payload;if(e.length)if(!e.queries||e.format!=="csv"){const c=l.map(d=>A(d));n(c)}else throw new m;else{const c=A(l);n(c)}}}}destroy(){window.parent.postMessage({type:s.LoggingDataClientDestroy,payload:{clientId:this.id}},"*")}}class Ze{constructor(e){this.id=e}query(e,n){const a=crypto.randomUUID();return window.addEventListener("message",r,!1),window.parent.postMessage({type:s.ResourceDataClientQuery,payload:{clientId:this.id,queryId:a,query:e}},"*"),()=>{window.removeEventListener("message",r,!1)};function r(o){o.source===window.parent&&o.data.type===s.ResourceDataClientQueryResult&&o.data.payload.queryId===a&&n(o.data.payload.results)}}update(e){return new Promise(n=>{const a=crypto.randomUUID();window.addEventListener("message",r,!1),window.parent.postMessage({type:s.ResourceDataClientUpdate,payload:{clientId:this.id,updateId:a,update:e}},"*");function r(o){o.source===window.parent&&o.data.type===s.ResourceDataClientUpdated&&o.data.payload.updateId===a&&(window.removeEventListener("message",r,!1),n())}})}render(e,n){const a=crypto.randomUUID();return window.addEventListener("message",r,!1),window.parent.postMessage({type:s.ResourceDataClientRender,payload:{clientId:this.id,queryId:a,query:e}},"*"),()=>{window.removeEventListener("message",r,!1)};function r(o){o.source===window.parent&&o.data.type===s.ResourceDataClientRenderResult&&o.data.payload.queryId===a&&n(o.data.payload.results)}}destroy(){window.parent.postMessage({type:s.ResourceDataClientDestroy,payload:{clientId:this.id}},"*")}}function I(t){const e=!!(t&&t.migrateInputs);return!e&&I.__cache__?Promise.resolve(I.__cache__):new Promise(n=>{window.addEventListener("message",function a(r){if(r.source===window.parent&&r.data&&r.data.type===s.Created){let o=r.data.payload;e&&(o.inputs=t.migrateInputs(o.inputs,null));const l=new Ke(o);n(l),e||(I.__cache__=l),window.removeEventListener("message",a,!1)}},!1),window.parent.postMessage({type:s.Create},"*")})}u.connect=k,u.getComponentContext=I,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixon-cdk/iframe-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-next.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"postinstall": "vite build"
|
|
9
|
+
},
|
|
8
10
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"index.d.ts"
|
|
11
|
+
"dist/**"
|
|
11
12
|
],
|
|
13
|
+
"author": "",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"license": "ISC",
|
|
12
16
|
"peerDependencies": {
|
|
13
|
-
"@ixon-cdk/types": "^1.
|
|
17
|
+
"@ixon-cdk/types": "^1.4.0-next.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "~5.1.6",
|
|
21
|
+
"vite": "4.1.5",
|
|
22
|
+
"vite-plugin-dts": "3.6.4"
|
|
14
23
|
}
|
|
15
24
|
}
|
package/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ComponentContext, ComponentContextOptions } from '@ixon-cdk/types';
|
|
2
|
-
|
|
3
|
-
declare module '@ixon-cdk/iframe-adapter' {
|
|
4
|
-
function connect(options: { iframe: HTMLIFrameElement; context: ComponentContext }): {
|
|
5
|
-
destroy(): void;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
function getComponentContext(options?: ComponentContextOptions): Promise<ComponentContext>;
|
|
9
|
-
}
|
package/index.js
DELETED
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
const EVENT_NS = 'cdk:cmpctx:';
|
|
2
|
-
|
|
3
|
-
const EVENTS = {
|
|
4
|
-
// Lifecycle
|
|
5
|
-
Create: `${EVENT_NS}create`,
|
|
6
|
-
Created: `${EVENT_NS}created`,
|
|
7
|
-
Destroy: `${EVENT_NS}destroy`,
|
|
8
|
-
|
|
9
|
-
// ResourceDataClient
|
|
10
|
-
ResourceDataClientCreate: `${EVENT_NS}rdc:create`,
|
|
11
|
-
ResourceDataClientDestroy: `${EVENT_NS}rdc:destroy`,
|
|
12
|
-
ResourceDataClientQuery: `${EVENT_NS}rdc:query`,
|
|
13
|
-
ResourceDataClientQueryResult: `${EVENT_NS}rdc:queryresult`,
|
|
14
|
-
ResourceDataClientRender: `${EVENT_NS}rdc:render`,
|
|
15
|
-
ResourceDataClientRenderResult: `${EVENT_NS}rdc:renderresult`,
|
|
16
|
-
|
|
17
|
-
// ActionBottomSheet
|
|
18
|
-
OpenActionBottomSheet: `${EVENT_NS}openactionbottomsheet`,
|
|
19
|
-
OpenActionBottomSheetResult: `${EVENT_NS}openactionbottomsheetresult`,
|
|
20
|
-
|
|
21
|
-
// Dialogs
|
|
22
|
-
OpenAlertDialog: `${EVENT_NS}openalertdialog`,
|
|
23
|
-
OpenAlertDialogResult: `${EVENT_NS}openalertdialogresult`,
|
|
24
|
-
OpenConfirmDialog: `${EVENT_NS}openconfirmdialog`,
|
|
25
|
-
OpenConfirmDialogResult: `${EVENT_NS}openconfirmdialogresult`,
|
|
26
|
-
OpenFormDialog: `${EVENT_NS}openformdialog`,
|
|
27
|
-
OpenFormDialogResult: `${EVENT_NS}openformdialogresult`,
|
|
28
|
-
|
|
29
|
-
// VPN
|
|
30
|
-
ShowVpnStatusDetails: `${EVENT_NS}showvpnstatusdetails`,
|
|
31
|
-
ToggleVpn: `${EVENT_NS}togglevpn`,
|
|
32
|
-
VpnClientStatusChange: `${EVENT_NS}vpnclientstatuschange`,
|
|
33
|
-
|
|
34
|
-
// Miscellaneous
|
|
35
|
-
NavigateByUrl: `${EVENT_NS}navigatebyurl`,
|
|
36
|
-
SetTimeRange: `${EVENT_NS}settimerange`,
|
|
37
|
-
TimeRangeChange: `${EVENT_NS}timerangechange`,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
class NotImplementedError extends Error {
|
|
41
|
-
constructor() {
|
|
42
|
-
super('Method is not implemented');
|
|
43
|
-
this.name = 'NotImplementedError';
|
|
44
|
-
this.message = 'Method is not implemented';
|
|
45
|
-
this.stack = 'NotImplementedError: Method is not implemented';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
class ComponentContext {
|
|
50
|
-
ontimerangechange = null;
|
|
51
|
-
onvpnclientstatuschange = null;
|
|
52
|
-
|
|
53
|
-
constructor(serializableContext) {
|
|
54
|
-
this._getApiLinks = () => new Map(serializableContext._apiLinkEntries);
|
|
55
|
-
this.appData = serializableContext.appData;
|
|
56
|
-
this.componentBaseUrl = serializableContext.componentBaseUrl;
|
|
57
|
-
this.destroyed = serializableContext.destroyed;
|
|
58
|
-
this.mode = serializableContext.mode;
|
|
59
|
-
this.inputs = serializableContext.inputs;
|
|
60
|
-
this.inputMap = new Map(Object.entries(this.inputs));
|
|
61
|
-
this.timeRange = serializableContext.timeRange;
|
|
62
|
-
this.timeRangeIsAdjustable = serializableContext.timeRangeIsAdjustable;
|
|
63
|
-
this.vpnClientStatus = serializableContext.vpnClientStatus;
|
|
64
|
-
this._messageHandler = this._messageHandler.bind(this);
|
|
65
|
-
window.addEventListener('message', this._messageHandler, false);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
_messageHandler(event) {
|
|
69
|
-
if (event.source !== window.parent) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
switch (event.data.type) {
|
|
74
|
-
case EVENTS.TimeRangeChange:
|
|
75
|
-
if (this.ontimerangechange) {
|
|
76
|
-
this.ontimerangechange(...event.data.payload);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case EVENTS.VpnClientStatusChange:
|
|
80
|
-
if (this.onvpnclientstatuschange) {
|
|
81
|
-
this.onvpnclientstatuschange(...event.data.payload);
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
createBackendComponentClient() {
|
|
88
|
-
throw new NotImplementedError();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
createLoggingDataClient() {
|
|
92
|
-
throw new NotImplementedError();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
createObjectStorageClient() {
|
|
96
|
-
throw new NotImplementedError();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
createResourceDataClient() {
|
|
100
|
-
const clientId = crypto.randomUUID();
|
|
101
|
-
window.parent.postMessage(
|
|
102
|
-
{
|
|
103
|
-
type: EVENTS.ResourceDataClientCreate,
|
|
104
|
-
payload: { clientId },
|
|
105
|
-
},
|
|
106
|
-
'*',
|
|
107
|
-
);
|
|
108
|
-
return new ResourceDataClient(clientId);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
createTooltip() {
|
|
112
|
-
throw new NotImplementedError();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
destroy() {
|
|
116
|
-
window.parent.postMessage({ type: EVENTS.Destroy }, '*');
|
|
117
|
-
window.removeEventListener('message', this._messageHandler, false);
|
|
118
|
-
this.destroyed = true;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
getApiUrl(rel, params) {
|
|
122
|
-
const link = this._getApiLinks().get(rel);
|
|
123
|
-
if (!link) {
|
|
124
|
-
throw new Error('IxApiError: entry not found');
|
|
125
|
-
}
|
|
126
|
-
// NOTE:
|
|
127
|
-
// This implementation part is an exact copy of the shared `getLinkUrl` utility
|
|
128
|
-
// function which can be found in `@lib/ixon/ixapi/ixapi.utils.ts
|
|
129
|
-
if (params) {
|
|
130
|
-
return Object.keys(params)
|
|
131
|
-
.sort()
|
|
132
|
-
.reduce((href, key) => {
|
|
133
|
-
if (href.includes(`{${key}}`)) {
|
|
134
|
-
return href.replace(`{${key}}`, params[key]);
|
|
135
|
-
}
|
|
136
|
-
const url = new URL(href);
|
|
137
|
-
url.searchParams.set(key, params[key]);
|
|
138
|
-
return decodeURIComponent(url.href);
|
|
139
|
-
}, link.href);
|
|
140
|
-
}
|
|
141
|
-
return link.href;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
navigateByUrl(url) {
|
|
145
|
-
window.parent.postMessage(
|
|
146
|
-
{ type: EVENTS.NavigateByUrl, payload: { url } },
|
|
147
|
-
'*',
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
openActionBottomSheet(options) {
|
|
152
|
-
return new Promise(resolve => {
|
|
153
|
-
window.addEventListener(
|
|
154
|
-
'message',
|
|
155
|
-
_actionBottomSheetResultHandler,
|
|
156
|
-
false,
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
window.parent.postMessage(
|
|
160
|
-
{ type: EVENTS.OpenActionBottomSheet, payload: { options } },
|
|
161
|
-
'*',
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
function _actionBottomSheetResultHandler(event) {
|
|
165
|
-
if (event.source !== window.parent) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (event.data.type === EVENTS.OpenActionBottomSheetResult) {
|
|
170
|
-
window.removeEventListener(
|
|
171
|
-
'message',
|
|
172
|
-
_actionBottomSheetResultHandler,
|
|
173
|
-
false,
|
|
174
|
-
);
|
|
175
|
-
resolve(event.data.payload.result);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
openAlertDialog(options) {
|
|
182
|
-
return new Promise(resolve => {
|
|
183
|
-
window.addEventListener('message', _dialogResultHandler, false);
|
|
184
|
-
|
|
185
|
-
window.parent.postMessage(
|
|
186
|
-
{ type: EVENTS.OpenAlertDialog, payload: { options } },
|
|
187
|
-
'*',
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
function _dialogResultHandler(event) {
|
|
191
|
-
if (event.source !== window.parent) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (event.data.type === EVENTS.OpenAlertDialogResult) {
|
|
196
|
-
window.removeEventListener('message', _dialogResultHandler, false);
|
|
197
|
-
resolve(event.data.payload.result);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
openConfirmDialog(options) {
|
|
204
|
-
return new Promise(resolve => {
|
|
205
|
-
window.addEventListener('message', _dialogResultHandler, false);
|
|
206
|
-
|
|
207
|
-
window.parent.postMessage(
|
|
208
|
-
{ type: EVENTS.OpenConfirmDialog, payload: { options } },
|
|
209
|
-
'*',
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
function _dialogResultHandler(event) {
|
|
213
|
-
if (event.source !== window.parent) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (event.data.type === EVENTS.OpenConfirmDialogResult) {
|
|
218
|
-
window.removeEventListener('message', _dialogResultHandler, false);
|
|
219
|
-
resolve(event.data.payload.result);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
openFormDialog(options) {
|
|
226
|
-
return new Promise(resolve => {
|
|
227
|
-
window.addEventListener('message', _dialogResultHandler, false);
|
|
228
|
-
|
|
229
|
-
window.parent.postMessage(
|
|
230
|
-
{ type: EVENTS.OpenFormDialog, payload: { options } },
|
|
231
|
-
'*',
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
function _dialogResultHandler(event) {
|
|
235
|
-
if (event.source !== window.parent) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (event.data.type === EVENTS.OpenFormDialogResult) {
|
|
240
|
-
window.removeEventListener('message', _dialogResultHandler, false);
|
|
241
|
-
resolve(event.data.payload.result);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
saveAsFile() {
|
|
248
|
-
throw new NotImplementedError();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
setTimeRange(timeRange) {
|
|
252
|
-
window.parent.postMessage(
|
|
253
|
-
{
|
|
254
|
-
type: EVENTS.SetTimeRange,
|
|
255
|
-
payload: { timeRange },
|
|
256
|
-
},
|
|
257
|
-
'*',
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
showVpnStatusDetails(agentId) {
|
|
262
|
-
window.parent.postMessage(
|
|
263
|
-
{
|
|
264
|
-
type: EVENTS.ShowVpnStatusDetails,
|
|
265
|
-
payload: { agentId },
|
|
266
|
-
},
|
|
267
|
-
'*',
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
testVpnAccess() {
|
|
272
|
-
throw new NotImplementedError();
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
toggleVpn(agentId) {
|
|
276
|
-
window.parent.postMessage(
|
|
277
|
-
{ type: EVENTS.ToggleVpn, payload: { agentId } },
|
|
278
|
-
'*',
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
translate() {
|
|
283
|
-
throw new NotImplementedError();
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
class ResourceDataClient {
|
|
288
|
-
constructor(id) {
|
|
289
|
-
this.id = id;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
query(query, listener) {
|
|
293
|
-
const queryId = crypto.randomUUID();
|
|
294
|
-
|
|
295
|
-
window.addEventListener('message', _queryHandler, false);
|
|
296
|
-
|
|
297
|
-
window.parent.postMessage(
|
|
298
|
-
{
|
|
299
|
-
type: EVENTS.ResourceDataClientQuery,
|
|
300
|
-
payload: { clientId: this.id, queryId, query },
|
|
301
|
-
},
|
|
302
|
-
'*',
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
return () => {
|
|
306
|
-
window.removeEventListener('message', _queryHandler, false);
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
function _queryHandler(event) {
|
|
310
|
-
if (event.source !== window.parent) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (
|
|
315
|
-
event.data.type === EVENTS.ResourceDataClientQueryResult &&
|
|
316
|
-
event.data.payload.queryId === queryId
|
|
317
|
-
) {
|
|
318
|
-
listener(event.data.payload.results);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
render(query, listener) {
|
|
324
|
-
const queryId = crypto.randomUUID();
|
|
325
|
-
|
|
326
|
-
window.addEventListener('message', _queryHandler, false);
|
|
327
|
-
|
|
328
|
-
window.parent.postMessage(
|
|
329
|
-
{
|
|
330
|
-
type: EVENTS.ResourceDataClientRender,
|
|
331
|
-
payload: { clientId: this.id, queryId, query },
|
|
332
|
-
},
|
|
333
|
-
'*',
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
return () => {
|
|
337
|
-
window.removeEventListener('message', _queryHandler, false);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
function _queryHandler(event) {
|
|
341
|
-
if (event.source !== window.parent) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (
|
|
346
|
-
event.data.type === EVENTS.ResourceDataClientRenderResult &&
|
|
347
|
-
event.data.payload.queryId === queryId
|
|
348
|
-
) {
|
|
349
|
-
listener(event.data.payload.results);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
destroy() {
|
|
355
|
-
window.parent.postMessage(
|
|
356
|
-
{
|
|
357
|
-
type: EVENTS.ResourceDataClientDestroy,
|
|
358
|
-
payload: { clientId: this.id },
|
|
359
|
-
},
|
|
360
|
-
'*',
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export function getComponentContext(options) {
|
|
366
|
-
const hasInputMigrations = !!(options && options.migrateInputs);
|
|
367
|
-
|
|
368
|
-
if (!hasInputMigrations && getComponentContext.__cache__) {
|
|
369
|
-
return Promise.resolve(getComponentContext.__cache__);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return new Promise(resolve => {
|
|
373
|
-
window.addEventListener(
|
|
374
|
-
'message',
|
|
375
|
-
function messageHandler(event) {
|
|
376
|
-
if (event.source !== window.parent) {
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (event.data && event.data.type === EVENTS.Created) {
|
|
381
|
-
let serializableContext = event.data.payload;
|
|
382
|
-
|
|
383
|
-
if (hasInputMigrations) {
|
|
384
|
-
serializableContext.inputs = options.migrateInputs(
|
|
385
|
-
serializableContext.inputs,
|
|
386
|
-
null,
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const context = new ComponentContext(serializableContext);
|
|
391
|
-
resolve(context);
|
|
392
|
-
|
|
393
|
-
// memoize
|
|
394
|
-
if (!hasInputMigrations) {
|
|
395
|
-
getComponentContext.__cache__ = context;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
window.removeEventListener('message', messageHandler, false);
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
false,
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
// dispatch "create" event
|
|
405
|
-
window.parent.postMessage({ type: EVENTS.Create }, '*');
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export function connect({ iframe, context }) {
|
|
410
|
-
window.addEventListener('message', _adapterMessageHandler, false);
|
|
411
|
-
|
|
412
|
-
// Broadcasts time range changes to connected iframe
|
|
413
|
-
context.ontimerangechange = (...args) => {
|
|
414
|
-
if (iframe.contentWindow) {
|
|
415
|
-
iframe.contentWindow.postMessage(
|
|
416
|
-
{
|
|
417
|
-
type: EVENTS.TimeRangeChange,
|
|
418
|
-
payload: args,
|
|
419
|
-
},
|
|
420
|
-
'*',
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
// Broadcasts VPN Client status changes to connected iframe
|
|
426
|
-
context.onvpnclientstatuschange = (...args) => {
|
|
427
|
-
if (iframe.contentWindow) {
|
|
428
|
-
iframe.contentWindow.postMessage(
|
|
429
|
-
{
|
|
430
|
-
type: EVENTS.VpnClientStatusChange,
|
|
431
|
-
payload: args,
|
|
432
|
-
},
|
|
433
|
-
'*',
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
return {
|
|
439
|
-
destroy() {
|
|
440
|
-
window.removeEventListener('message', _adapterMessageHandler, false);
|
|
441
|
-
},
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Returns a serializable object for the passed CompontContext instance
|
|
446
|
-
*/
|
|
447
|
-
function _getSerializableContext(context) {
|
|
448
|
-
return {
|
|
449
|
-
_apiLinkEntries: [...context._getApiLinks().entries()],
|
|
450
|
-
appData: context.appData,
|
|
451
|
-
componentBaseUrl: context.componentBaseUrl,
|
|
452
|
-
destroyed: context.destroyed,
|
|
453
|
-
mode: context.mode,
|
|
454
|
-
inputs: context.inputs,
|
|
455
|
-
timeRange: context.timeRange,
|
|
456
|
-
timeRangeIsAdjustable: context.timeRangeIsAdjustable,
|
|
457
|
-
vpnClientStatus: context.vpnClientStatus,
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function _adapterMessageHandler(event) {
|
|
462
|
-
_adapterMessageHandler._clients =
|
|
463
|
-
_adapterMessageHandler._clients || new Map([]);
|
|
464
|
-
|
|
465
|
-
if (event.source !== iframe.contentWindow) {
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
switch (event.data.type) {
|
|
470
|
-
/**
|
|
471
|
-
* Lifecycle
|
|
472
|
-
*/
|
|
473
|
-
case EVENTS.Create:
|
|
474
|
-
iframe.contentWindow.postMessage(
|
|
475
|
-
{
|
|
476
|
-
type: EVENTS.Created,
|
|
477
|
-
payload: _getSerializableContext(context),
|
|
478
|
-
},
|
|
479
|
-
'*',
|
|
480
|
-
);
|
|
481
|
-
break;
|
|
482
|
-
case EVENTS.Destroy:
|
|
483
|
-
context.destroy();
|
|
484
|
-
break;
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
* ResourceDataClient
|
|
488
|
-
*/
|
|
489
|
-
case EVENTS.ResourceDataClientCreate: {
|
|
490
|
-
const { clientId } = event.data.payload;
|
|
491
|
-
const client = context.createResourceDataClient(clientId);
|
|
492
|
-
_adapterMessageHandler._clients.set(clientId, client);
|
|
493
|
-
break;
|
|
494
|
-
}
|
|
495
|
-
case EVENTS.ResourceDataClientDestroy: {
|
|
496
|
-
const { clientId } = event.data.payload;
|
|
497
|
-
if (_adapterMessageHandler._clients.has(clientId)) {
|
|
498
|
-
_adapterMessageHandler._clients.get(clientId).destroy();
|
|
499
|
-
_adapterMessageHandler._clients.delete(clientId);
|
|
500
|
-
}
|
|
501
|
-
break;
|
|
502
|
-
}
|
|
503
|
-
case EVENTS.ResourceDataClientQuery: {
|
|
504
|
-
const { clientId, queryId, query } = event.data.payload;
|
|
505
|
-
let client = _adapterMessageHandler._clients.get(clientId);
|
|
506
|
-
if (client && !client._destroyed) {
|
|
507
|
-
client.query(query, results => {
|
|
508
|
-
if (!client._destroyed) {
|
|
509
|
-
iframe.contentWindow.postMessage(
|
|
510
|
-
{
|
|
511
|
-
type: EVENTS.ResourceDataClientQueryResult,
|
|
512
|
-
payload: { queryId, results },
|
|
513
|
-
},
|
|
514
|
-
'*',
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
break;
|
|
520
|
-
}
|
|
521
|
-
case EVENTS.ResourceDataClientRender: {
|
|
522
|
-
const { clientId, queryId, query } = event.data.payload;
|
|
523
|
-
let client = _adapterMessageHandler._clients.get(clientId);
|
|
524
|
-
if (client && !client._destroyed) {
|
|
525
|
-
client.render(query, results => {
|
|
526
|
-
if (!client._destroyed) {
|
|
527
|
-
iframe.contentWindow.postMessage(
|
|
528
|
-
{
|
|
529
|
-
type: EVENTS.ResourceDataClientRenderResult,
|
|
530
|
-
payload: { queryId, results },
|
|
531
|
-
},
|
|
532
|
-
'*',
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* ActionBottomSheet
|
|
542
|
-
*/
|
|
543
|
-
case EVENTS.OpenActionBottomSheet:
|
|
544
|
-
context
|
|
545
|
-
.openActionBottomSheet(event.data.payload.options)
|
|
546
|
-
.then(result => {
|
|
547
|
-
iframe.contentWindow.postMessage(
|
|
548
|
-
{ type: EVENTS.OpenActionBottomSheetResult, payload: { result } },
|
|
549
|
-
'*',
|
|
550
|
-
);
|
|
551
|
-
});
|
|
552
|
-
break;
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Dialogs
|
|
556
|
-
*/
|
|
557
|
-
case EVENTS.OpenAlertDialog:
|
|
558
|
-
context.openAlertDialog(event.data.payload.options).then(result => {
|
|
559
|
-
iframe.contentWindow.postMessage(
|
|
560
|
-
{ type: EVENTS.OpenAlertDialogResult, payload: { result } },
|
|
561
|
-
'*',
|
|
562
|
-
);
|
|
563
|
-
});
|
|
564
|
-
break;
|
|
565
|
-
case EVENTS.OpenConfirmDialog:
|
|
566
|
-
context.openConfirmDialog(event.data.payload.options).then(result => {
|
|
567
|
-
iframe.contentWindow.postMessage(
|
|
568
|
-
{ type: EVENTS.OpenConfirmDialogResult, payload: { result } },
|
|
569
|
-
'*',
|
|
570
|
-
);
|
|
571
|
-
});
|
|
572
|
-
break;
|
|
573
|
-
case EVENTS.OpenFormDialog:
|
|
574
|
-
context.openFormDialog(event.data.payload.options).then(result => {
|
|
575
|
-
iframe.contentWindow.postMessage(
|
|
576
|
-
{ type: EVENTS.OpenFormDialogResult, payload: { result } },
|
|
577
|
-
'*',
|
|
578
|
-
);
|
|
579
|
-
});
|
|
580
|
-
break;
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* VPN
|
|
584
|
-
*/
|
|
585
|
-
case EVENTS.ShowVpnStatusDetails:
|
|
586
|
-
context.showVpnStatusDetails(event.data.payload.agentId);
|
|
587
|
-
break;
|
|
588
|
-
case EVENTS.ToggleVpn:
|
|
589
|
-
context.toggleVpn(event.data.payload.agentId);
|
|
590
|
-
break;
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* Miscellaneous
|
|
594
|
-
*/
|
|
595
|
-
case EVENTS.NavigateByUrl:
|
|
596
|
-
context.navigateByUrl(event.data.payload.url);
|
|
597
|
-
break;
|
|
598
|
-
case EVENTS.SetTimeRange:
|
|
599
|
-
context.setTimeRange(event.data.payload.timeRange);
|
|
600
|
-
break;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
}
|