@abi-software/map-side-bar 2.5.0-beta.4 → 2.5.0-beta.5

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.
@@ -45679,10 +45679,15 @@ class Qde extends EventTarget {
45679
45679
  this.tooltip.hidden = !0;
45680
45680
  }
45681
45681
  tapNode(t) {
45682
- const n = t.target.data(), { label: r } = n, o = Y0(r), a = new CustomEvent("tap-node", {
45683
- detail: o
45682
+ const n = t.target, r = n.data();
45683
+ let { label: o } = r;
45684
+ o && n.isNode() && n.selected() && (o = "", setTimeout(() => {
45685
+ n.unselect();
45686
+ }));
45687
+ const a = Y0(o), i = new CustomEvent("tap-node", {
45688
+ detail: a
45684
45689
  });
45685
- this.dispatchEvent(a);
45690
+ this.dispatchEvent(i);
45686
45691
  }
45687
45692
  on(t, n) {
45688
45693
  this.addEventListener(t, n);
@@ -85,7 +85,7 @@ Licensed under The MIT License (http://opensource.org/licenses/MIT)
85
85
  `).map(t=>t&&t[0]>="a"&&t[0]<="z"?t.charAt(0).toUpperCase()+t.slice(1):t).join(`
86
86
  `)}function Cy(e){const t=e?e.split(`
87
87
  `):[],n=[];for(let r=0;r<t.length/2;r++)n.push({id:t[r],label:t[r+t.length/2]});return n}function ade(e,t){e.sort((n,r)=>n.id<r.id?-1:n.id>r.id?1:0),t.sort((n,r)=>n.id<r.id?-1:n.id>r.id?1:0);for(let n=0;n<e.length;n++)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}class ide extends EventTarget{constructor(t,n){var r;super(),uo(this,"cy"),uo(this,"tooltip"),this.cy=Hi({container:n,elements:t.elements,layout:{name:"breadthfirst",circle:!1,roots:t.roots},directed:!0,style:rde,minZoom:.5,maxZoom:10,wheelSensitivity:.4}).on("mouseover","node",this.overNode.bind(this)).on("mouseout","node",this.exitNode.bind(this)).on("position","node",this.moveNode.bind(this)).on("tap",this.tapNode.bind(this)),this.tooltip=document.createElement("div"),this.tooltip.className="cy-graph-tooltip",this.tooltip.hidden=!0,(r=n==null?void 0:n.lastChild)==null||r.appendChild(this.tooltip)}remove(){this.cy&&this.cy.destroy()}checkRightBoundary(t){var n;t+this.tooltip.offsetWidth>=((n=this.tooltip.parentElement)==null?void 0:n.offsetWidth)&&(this.tooltip.style.left=`${t-this.tooltip.offsetWidth}px`)}overNode(t){const n=t.target.data(),{label:r}=n,a=Cy(r).map(i=>i.label+" ("+i.id+")");this.tooltip.innerText=f4(a.join(`
88
- `)),this.tooltip.style.left=`${t.renderedPosition.x}px`,this.tooltip.style.top=`${t.renderedPosition.y}px`,this.tooltip.style.maxWidth="240px",this.tooltip.style.zIndex=2,this.tooltip.hidden=!1,this.checkRightBoundary(t.renderedPosition.x)}moveNode(t){const n=t.target;this.tooltip.style.left=`${n.renderedPosition().x}px`,this.tooltip.style.top=`${n.renderedPosition().y}px`,this.checkRightBoundary(n.renderedPosition().x)}exitNode(t){this.tooltip.hidden=!0}tapNode(t){const n=t.target.data(),{label:r}=n,a=Cy(r),i=new CustomEvent("tap-node",{detail:a});this.dispatchEvent(i)}on(t,n){this.addEventListener(t,n)}}const sde=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),lde=1.3,cde=24*60*60*1e3,dde="Reset position",p4="Lock zoom",ude="Unlock zoom",fde="Zoom in",pde="Zoom out",h4=.25,hde="#8300bf",mde=3e3,gde={name:"ConnectivityGraph",props:{entry:{type:String,default:""},mapServer:{type:String,default:""},selectedConnectivityData:{type:Array,default:[]}},data:function(){return{loading:!0,connectivityGraph:null,selectedSource:"",pathList:[],schemaVersion:"",knowledgeByPath:new Map,labelledTerms:new Set,labelCache:new Map,resetLabel:dde,zoomLockLabel:p4,zoomInLabel:fde,zoomOutLabel:pde,iconColor:hde,zoomEnabled:!1,errorMessage:"",errorConnectivities:""}},mounted(){this.refreshCache(),this.loadCacheData(),this.run().then(e=>{this.showGraph(this.entry)})},methods:{loadCacheData:function(){const e=sessionStorage.getItem("connectivity-graph-source"),t=sessionStorage.getItem("connectivity-graph-labels"),n=sessionStorage.getItem("connectivity-graph-pathlist"),r=sessionStorage.getItem("connectivity-graph-schema-version");if(e&&(this.selectedSource=e),n&&(this.pathList=JSON.parse(n)),t){const a=JSON.parse(t);this.labelCache=new Map(Object.entries(a))}r&&(this.schemaVersion=r)},removeAllCacheData:function(){["connectivity-graph-expiry","connectivity-graph-source","connectivity-graph-labels","connectivity-graph-pathlist","connectivity-graph-schema-version"].forEach(e=>{sessionStorage.removeItem(e)})},refreshCache:function(){const e=sessionStorage.getItem("connectivity-graph-expiry");new Date().getTime()>e&&this.removeAllCacheData()},updateCacheExpiry:function(){const e=new Date().getTime()+cde;sessionStorage.setItem("connectivity-graph-expiry",e)},run:async function(){if(this.schemaVersion||(this.schemaVersion=await this.getSchemaVersion(),sessionStorage.setItem("connectivity-graph-schema-version",this.schemaVersion),this.updateCacheExpiry()),this.schemaVersion<lde){console.warn("No Server!");return}this.showSpinner(),this.selectedSource||(this.selectedSource=await this.setSourceList(),sessionStorage.setItem("connectivity-graph-source",this.selectedSource),this.updateCacheExpiry()),await this.setPathList(this.selectedSource),this.hideSpinner()},showGraph:async function(e){const t=this.$refs.graphCanvas;this.showSpinner(),this.connectivityGraph=new tde(this.labelCache,t),await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(e)),this.hideSpinner(),this.connectivityGraph.showConnectivity(t),this.selectedConnectivityData.length&&this.connectivityGraph.selectConnectivity(this.selectedConnectivityData),this.connectivityGraph.on("tap-node",n=>{const r=n.detail;this.$emit("tap-node",r)})},query:async function(e,t){const n=`${this.mapServer}knowledge/query/`,r={sql:e,params:t};try{const a=await fetch(n,{method:"POST",headers:{Accept:"application/json; charset=utf-8","Cache-Control":"no-store","Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`Cannot access ${n}`);return await a.json()}catch{return{values:[]}}},setSourceList:async function(){const e=await this.getJsonData(`${this.mapServer}knowledge/sources`),t=e?e.sources||[]:[];let n="";for(const r of t)r&&n===""&&(n=r);return n},loadPathData:async function(e){const t=await this.query(`select entity, knowledge from knowledge
88
+ `)),this.tooltip.style.left=`${t.renderedPosition.x}px`,this.tooltip.style.top=`${t.renderedPosition.y}px`,this.tooltip.style.maxWidth="240px",this.tooltip.style.zIndex=2,this.tooltip.hidden=!1,this.checkRightBoundary(t.renderedPosition.x)}moveNode(t){const n=t.target;this.tooltip.style.left=`${n.renderedPosition().x}px`,this.tooltip.style.top=`${n.renderedPosition().y}px`,this.checkRightBoundary(n.renderedPosition().x)}exitNode(t){this.tooltip.hidden=!0}tapNode(t){const n=t.target,r=n.data();let{label:a}=r;a&&n.isNode()&&n.selected()&&(a="",setTimeout(()=>{n.unselect()}));const i=Cy(a),s=new CustomEvent("tap-node",{detail:i});this.dispatchEvent(s)}on(t,n){this.addEventListener(t,n)}}const sde=e=>e&&e.charAt(0).toUpperCase()+e.slice(1),lde=1.3,cde=24*60*60*1e3,dde="Reset position",p4="Lock zoom",ude="Unlock zoom",fde="Zoom in",pde="Zoom out",h4=.25,hde="#8300bf",mde=3e3,gde={name:"ConnectivityGraph",props:{entry:{type:String,default:""},mapServer:{type:String,default:""},selectedConnectivityData:{type:Array,default:[]}},data:function(){return{loading:!0,connectivityGraph:null,selectedSource:"",pathList:[],schemaVersion:"",knowledgeByPath:new Map,labelledTerms:new Set,labelCache:new Map,resetLabel:dde,zoomLockLabel:p4,zoomInLabel:fde,zoomOutLabel:pde,iconColor:hde,zoomEnabled:!1,errorMessage:"",errorConnectivities:""}},mounted(){this.refreshCache(),this.loadCacheData(),this.run().then(e=>{this.showGraph(this.entry)})},methods:{loadCacheData:function(){const e=sessionStorage.getItem("connectivity-graph-source"),t=sessionStorage.getItem("connectivity-graph-labels"),n=sessionStorage.getItem("connectivity-graph-pathlist"),r=sessionStorage.getItem("connectivity-graph-schema-version");if(e&&(this.selectedSource=e),n&&(this.pathList=JSON.parse(n)),t){const a=JSON.parse(t);this.labelCache=new Map(Object.entries(a))}r&&(this.schemaVersion=r)},removeAllCacheData:function(){["connectivity-graph-expiry","connectivity-graph-source","connectivity-graph-labels","connectivity-graph-pathlist","connectivity-graph-schema-version"].forEach(e=>{sessionStorage.removeItem(e)})},refreshCache:function(){const e=sessionStorage.getItem("connectivity-graph-expiry");new Date().getTime()>e&&this.removeAllCacheData()},updateCacheExpiry:function(){const e=new Date().getTime()+cde;sessionStorage.setItem("connectivity-graph-expiry",e)},run:async function(){if(this.schemaVersion||(this.schemaVersion=await this.getSchemaVersion(),sessionStorage.setItem("connectivity-graph-schema-version",this.schemaVersion),this.updateCacheExpiry()),this.schemaVersion<lde){console.warn("No Server!");return}this.showSpinner(),this.selectedSource||(this.selectedSource=await this.setSourceList(),sessionStorage.setItem("connectivity-graph-source",this.selectedSource),this.updateCacheExpiry()),await this.setPathList(this.selectedSource),this.hideSpinner()},showGraph:async function(e){const t=this.$refs.graphCanvas;this.showSpinner(),this.connectivityGraph=new tde(this.labelCache,t),await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(e)),this.hideSpinner(),this.connectivityGraph.showConnectivity(t),this.selectedConnectivityData.length&&this.connectivityGraph.selectConnectivity(this.selectedConnectivityData),this.connectivityGraph.on("tap-node",n=>{const r=n.detail;this.$emit("tap-node",r)})},query:async function(e,t){const n=`${this.mapServer}knowledge/query/`,r={sql:e,params:t};try{const a=await fetch(n,{method:"POST",headers:{Accept:"application/json; charset=utf-8","Cache-Control":"no-store","Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw new Error(`Cannot access ${n}`);return await a.json()}catch{return{values:[]}}},setSourceList:async function(){const e=await this.getJsonData(`${this.mapServer}knowledge/sources`),t=e?e.sources||[]:[];let n="";for(const r of t)r&&n===""&&(n=r);return n},loadPathData:async function(e){const t=await this.query(`select entity, knowledge from knowledge
89
89
  where entity like 'ilxtr:%' and source=?
90
90
  order by entity`,[e]);return t?t.values:[]},setPathList:async function(e){this.pathList.length||(this.pathList=await this.loadPathData(e),sessionStorage.setItem("connectivity-graph-pathlist",JSON.stringify(this.pathList)),this.updateCacheExpiry()),this.knowledgeByPath.clear(),this.labelledTerms=new Set;for(const[t,n]of this.pathList){const r=JSON.parse(n);"connectivity"in r&&(this.knowledgeByPath.set(t,r),this.cacheLabels(r))}return this.labelCache.size||await this.getCachedTermLabels(),""},getSchemaVersion:async function(){const e=await this.getJsonData(`${this.mapServer}knowledge/schema-version`);return e&&+e.version||0},getJsonData:async function(e){try{const t=await fetch(e,{method:"GET",headers:{Accept:"application/json; charset=utf-8","Cache-Control":"no-store","Content-Type":"application/json"}});return t.ok||console.error(`Cannot access ${e}`),await t.json()}catch{return null}},getCachedTermLabels:async function(){if(this.labelledTerms.size){const e=await this.query(`select entity, knowledge from knowledge
91
91
  where entity in (?${", ?".repeat(this.labelledTerms.size-1)})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "2.5.0-beta.4",
3
+ "version": "2.5.0-beta.5",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@abi-software/gallery": "^1.1.2",
42
- "@abi-software/map-utilities": "^1.2.1-beta.0",
42
+ "@abi-software/map-utilities": "^1.2.1-beta.1",
43
43
  "@abi-software/svg-sprite": "^1.0.1",
44
44
  "@element-plus/icons-vue": "^2.3.1",
45
45
  "algoliasearch": "^4.10.5",