@hpcc-js/eclwatch 3.1.1 → 3.2.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.js CHANGED
@@ -1,52 +1,1154 @@
1
- var O=Object.defineProperty;var l=(c,e)=>O(c,"name",{value:e,configurable:!0});var we="@hpcc-js/eclwatch",xe="3.1.1",ke="3.2.1";import{Editor as N}from"@hpcc-js/codemirror";import{Workunit as j}from"@hpcc-js/comms";import{SplitPanel as B}from"@hpcc-js/phosphor";import{DirectoryTree as q}from"@hpcc-js/tree";import{hashSum as z,xml2json as X}from"@hpcc-js/util";var p=class extends B{static{l(this,"ECLArchiveViewer")}_prevHash;_contentStr;_directoryPane=new q;_fileEditorPane=new N().text("");constructor(){super("horizontal"),this._directoryPane.rowClick=e=>{this._fileEditorPane.text(e).render()}}transformArchiveTreeData(e){let t={label:e.name,children:e._children.map(r).filter(s=>s)};if(t.children&&t.children[0]&&t.children[0].label==="html")return{label:"root",children:[{label:"error",content:JSON.stringify(t,null,4)}]};return t;function r(s){let a={};if(a.label=s.name+(s.$&&s.$.key?` (${s.$.key})`:""),s._children&&s._children.length>0)a.children=s._children.map(i=>r(i)).filter(i=>i);else if(typeof s.content=="string"&&s.content.trim())a.content=s.content;else return!1;return a}}updateDirectoryPane(e){let t;if(e)try{t=JSON.parse(e)}catch{t=X(e)}if(t){let r=this.transformArchiveTreeData(t);this._directoryPane.data(r).render()}}enter(e,t){super.enter(e,t),this.addWidget(this._directoryPane).addWidget(this._fileEditorPane)}update(e,t){super.update(e,t);let r=z({baseUrl:this.baseUrl(),wuid:this.wuid()});this._prevHash!==r||typeof this._contentStr>"u"?j.attach({baseUrl:this.baseUrl()},this.wuid()).fetchArchive().then(s=>{this._contentStr=s,this.updateDirectoryPane(this._contentStr),this._prevHash=r}):this.updateDirectoryPane(this._contentStr),this.relativeSizes([this.directoryWidthRatio(),1-this.directoryWidthRatio()])}};p.prototype._class+=" eclwatch_ECLArchiveViewer";p.prototype.publish("baseUrl","","string","HPCC Platform Base URL");p.prototype.publish("wuid","","string","Workunit ID");p.prototype.publish("directoryWidthRatio",.38,"number","Default directory panel width ratio relative to the full width");p.prototype.publish("contentString",null,"string","XML/JSON archive content string");p.prototype.publishProxy("directoryPaneColor","_directoryPane","backgroundColor");p.prototype.publishProxy("directoryPaneHoverColor","_directoryPane","hoverBackgroundColor");p.prototype.publishProxy("iconSize","_directoryPane");p.prototype.publishProxy("fontColor","_directoryPane");p.prototype.publishProxy("fontFamily","_directoryPane");p.prototype.publishProxy("fontSize","_directoryPane");p.prototype.publishProxy("folderIconOpen","_directoryPane");p.prototype.publishProxy("folderIconClosed","_directoryPane");p.prototype.publishProxy("textFileIcon","_directoryPane");p.prototype.publishProxy("codeFileIcon","_directoryPane");p.prototype.publishProxy("verticalScroll","_directoryPane");import{Button as W,Spacer as P,ToggleButton as v}from"@hpcc-js/common";import{Workunit as Y}from"@hpcc-js/comms";import{Table as D}from"@hpcc-js/dgrid";import{Graph as Z}from"@hpcc-js/graph";import{Carousel as ee,ChartPanel as te}from"@hpcc-js/layout";import{hashSum as re}from"@hpcc-js/util";import{Vertex as $}from"@hpcc-js/graph";import{Legend as K}from"@hpcc-js/layout";import{local as J,select as Q}from"@hpcc-js/common";(function(){if(!document.getElementById("9b8733e7")){var c=document.createElement("style");c.id="9b8733e7",c.textContent=`.eclwatch_WUGraphLegend .graph_Vertex {
2
- cursor: auto;
3
- }
4
-
5
- .eclwatch_WUGraphLegend .graph_Vertex .common_Icon {
6
- cursor: pointer;
7
- }
8
- `,document.head.appendChild(c)}})();var E=class extends ${static{l(this,"LegendVertex")}constructor(){super()}enter(e,t){super.enter(e,t),this._icon.on("click",()=>{this.click(this.data())})}click(e){}},S=class extends K{static{l(this,"WUGraphLegend")}icon=J();_disabled2={};disabled(e){if(!arguments.length){let t=[];for(let r in this._disabled2)this._disabled2[r]&&t.push(r);return t}return this._disabled2={},e.forEach(t=>this._disabled2[t]=!0),this}toggle(e){this._disabled2[e]=!this._disabled2[e]}update(e,t){super.update(e,t);let r=this,s=this._g.selectAll(".legendItem").data(this.data(),i=>i.kind);s.enter().append("g").attr("class","legendItem").each(function(i){r.icon.set(this,new E().target(this).data(i.kind).textbox_shape_colorStroke("none").textbox_shape_colorFill("none").iconAnchor("left").faChar(i.faChar).text(`${i.label} (${i.count})`).tooltip(`${i.kind} - ${i.label}`).on("click",o=>{r.toggle(o),r.render(),r.click(o)}).on("mouseover",o=>{r.mouseover(o)}).on("mouseout",o=>{r.mouseout(o)}))}).merge(s).each(function(i,o){let n=r.icon.get(this).icon_shape_colorFill(r._disabled2[i.kind]?"gray":null).render().getBBox();Q(this).attr("transform",`translate(${+n.width/2}, ${o*30})`)}),s.exit().each(function(i){r.icon.get(this).target(null).render()}).remove();let a=this.getBBox(!0,!0);this._g.attr("transform",`translate(16, ${this.height()/2-a.height/2})`)}click(e){}mouseover(e){}mouseout(e){}};S.prototype._class+=" eclwatch_WUGraphLegend";import{Icon as M}from"@hpcc-js/common";import{BaseScope as x}from"@hpcc-js/comms";import{Edge as U,Subgraph as G,Vertex as R}from"@hpcc-js/graph";import{Edge as T,Subgraph as L,Vertex as F}from"@hpcc-js/util";function H(c){switch(c){case"2":return"\uF0C7";case"3":return"\uF15D";case"5":return"\uF0B0";case"6":return"\uF1E0";case"12":return"\uF039";case"15":return"\uF126";case"17":return"\uF126";case"22":return"\uF1E6";case"23":return"\uF078";case"25":return"\uF0CE";case"26":return"\uF074";case"29":return"\uF005";case"36":return"\uF128";case"44":return"\uF0C7";case"47":return"\uF0C7";case"54":return"\uF013";case"56":return"\uF0C7";case"59":return"\uF126";case"61":return"\uF0C7";case"82":return"\uF1C0";case"88":return"\uF1C0";case"92":return"\uF129";case"93":return"\uF129";case"99":return"\uF1C0";case"105":return"\uF1C0";case"7":return"\uF090";case"9":return"\uF0E2";case"16":return"\uF005";case"19":return"\uF074";case"21":return"\uF275";case"35":return"\uF0C7";case"37":return"\uF0C7";case"71":return"\uF1C0";case"133":return"\uF0CE";case"148":return"\uF0CE";case"168":return"\uF275"}return"\uF063"}l(H,"faCharFactory");var k=class{static{l(this,"WUScopeController")}graphDB;subgraphsMap={};rSubgraphsMap={};verticesMap={};rVerticesMap={};edgesMap={};rEdgesMap={};kindMap={};_disabled={};constructor(){}clear(){this.subgraphsMap={},this.rSubgraphsMap={},this.verticesMap={},this.rVerticesMap={},this.edgesMap={},this.rEdgesMap={}}set(e){this.graphDB=e,this.graphGui(this.graphDB),this.kindMap={},this.graphDB.walk(t=>{if(!(t instanceof L))if(t instanceof F){let r=t._.attr("Kind").RawValue;this.kindMap[r]||(this.kindMap[r]=[]),this.kindMap[r].push(t)}else t instanceof T})}disabled(e){if(!arguments.length){let t=[];for(let r in this._disabled)this._disabled[r]&&t.push(r);return t}return this._disabled={},e.forEach(t=>this._disabled[t]=!0),this}graphGui(e){let t={subgraphs:[],vertices:[],edges:[],hierarchy:[]};return e.walk(r=>{if(r instanceof L){let s=this.appendSubgraph(r,t.hierarchy,t.subgraphs);s.showMinMax(r.vertices.length>3||s.minState()!=="normal")}else r instanceof F?this.appendVertex(r,t.hierarchy,t.vertices):r instanceof T&&this.appendEdge(r,t.edges)}),t}format(e,t){let r="",s=e.indexOf("%"),a=-1;for(;s>=0;){if(r+=e.substring(a+1,s),a=e.indexOf("%",s+1),a<0){console.warn("Invalid Label Template");break}let i=e.substring(s+1,a);r+=i?t[e.substring(s+1,a)]||"":"%",s=e.indexOf("%",a+1)}return r+=e.substring(a+1,e.length),r.split("\\n").join(`
9
- `)}createSubgraph(e){let t=this.subgraphsMap[e._.Id];return t||(t=new G().title(e._.Id).on("minClick",()=>{this.minClick(t)}),this.subgraphsMap[e._.Id]=t,this.rSubgraphsMap[t.id()]=e),t}createVertex(e){let t=this.verticesMap[e._.Id];if(!t){let r=e._.rawAttrs();if(e._.ScopeType==="dummy"){let s=this.subgraphsMap[e.parent._.Id];t=new M().shape_colorFill("darkred").shape_colorStroke("darkred").image_colorFill("white").faChar("\uF067").on("click",()=>{s.minState("normal"),this.minClick(s)})}else{t=new R().icon_shape_colorFill("#1f77b4").icon_image_colorFill("white").faChar(H(r.Kind)).text(r.Label);let s=[];e._.hasAttr("Definition")&&s.push({faChar:"\uF036",tooltip:"Definition",shape_colorFill:"lightgray",shape_colorStroke:"lightgray",image_colorFill:"black"}),e._.hasAttr("IsInternal")&&s.push({faChar:"\uF085",tooltip:"IsInternal",shape_colorFill:"red",shape_colorStroke:"red",image_colorFill:"white"}),t.annotationIcons(s)}this.verticesMap[e._.Id]=t,this.rVerticesMap[t.id()]=e}return t}isSpill(e){let t=e.source._.attr("Kind").RawValue,r=e.target._.attr("Kind").RawValue;return t==="2"||r==="71"}spansSubgraph(e){return e.source.parent._.Id!==e.target.parent._.Id}createEdge(e){let t=this.edgesMap[e._.Id];if(!t){let r=e._.rawAttrs(),s=this.verticesMap[e.source._.Id],a=this.verticesMap[e.target._.Id];if(s&&a){let i=this.isSpill(e),o=this.spansSubgraph(e),n=this.format(`%Label%
10
- %NumRowsProcessed%`,r),h=null,g=100;r.IsDependency?(g=10,h="1,5"):r._childGraph?h="5,5":i?(g=25,h="5,5,10,5"):o&&(g=5,h="5,5"),t=new U().sourceVertex(s).targetVertex(a).sourceMarker("circle").targetMarker("arrow").weight(g).strokeDasharray(h).text(n),this.edgesMap[e._.Id]=t,this.rEdgesMap[t.id()]=e}}return t}appendSubgraph(e,t,r){let s=this.createSubgraph(e);r.push(s);let a=this.subgraphsMap[e.parent._.Id];return a&&t.push({parent:a,child:s}),s}appendVertex(e,t,r){let s=this.createVertex(e);r.push(s);let a=this.subgraphsMap[e.parent._.Id];return a&&t.push({parent:a,child:s}),s}appendEdge(e,t){let r=this.createEdge(e);return r&&t.push(r),r}filterLegend(e){for(let t=e.vertices.length-1;t>=0;--t){let r=e.vertices[t],s=r._.attr("Kind").RawValue;this._disabled[s]&&r.remove(!1,(a,i)=>new x({ScopeName:r._.ScopeName+":in",Id:a.Id+"->"+i.Id,ScopeType:"dummy-edge",Properties:{Property:[r._.attr("Label")]},Notes:{Note:[]},SinkActivity:""}))}}filterPartial(e){for(let t of e.subgraphs)switch(this.subgraphsMap[t._.Id].minState()){case"partial":let s=t.vertices,a=[],i=[];for(let o of s)o.inEdges.length===0||o.inEdges.some(n=>n.source.parent!==n.target.parent)||o.outEdges.length===0||o.outEdges.some(n=>n.source.parent!==n.target.parent)?a.push(o):i.push(o);if(i.length>1){let o={ScopeName:t._.ScopeName,Id:t._.Id+":dummy",ScopeType:"dummy",Properties:{Property:[{Name:"Activities",RawValue:""+i.length,Formatted:""+i.length,Measure:"count",Creator:"",CreatorType:""}]},Notes:{Note:[]},SinkActivity:""},n=new x(o),h=t.createVertex(n);for(let g of i){for(let f of g.inEdges)if(a.indexOf(f.source)>=0){let C=new x({ScopeName:f.source._.ScopeName,Id:f.source._.Id+"->"+h._.Id,ScopeType:"dummy-in",Properties:{Property:[]},Notes:{Note:[]},SinkActivity:""});t.createEdge(f.source,h,C)}for(let f of g.outEdges)if(a.indexOf(f.target)>=0){let C=new x({ScopeName:f.target._.ScopeName,Id:h._.Id+"->"+f.target._.Id,ScopeType:"dummy-out",Properties:{Property:[]},Notes:{Note:[]},SinkActivity:""});t.createEdge(h,f.target,C)}}i.forEach(g=>g.remove(!0))}break}}filterEmptySubgraphs(e){for(;;){let t=e.subgraphs.filter(r=>r.subgraphs.length===0&&r.vertices.length===0);if(t.length===0)break;t.forEach(r=>r.remove(!0))}}removeObsoleteSubgraphs(e){for(let t of[...e.subgraphs])t.vertices.length===0&&t.remove(!1)}graphData(){let e=this.graphDB.clone();return this.filterLegend(e),this.filterPartial(e),this.filterEmptySubgraphs(e),this.removeObsoleteSubgraphs(e),this.graphGui(e)}calcLegend(){let e=[];for(let t in this.kindMap)e.push({kind:parseInt(t),faChar:H(t),label:this.kindMap[t][0]._.attr("Label").RawValue.split(`
11
- `)[0],count:this.kindMap[t].length});return e}vertices(e){let t=[];for(let r of this.kindMap[e])t.push(this.verticesMap[r._.Id]);return t}formatRow(e,t,r){let s=e._.formattedAttrs();for(let a in s){let i=t.indexOf(a);i===-1?(t.push(a),r.push(s[a])):r[i]=s[a]}for(let a=0;a<100;++a)r[a]===void 0&&(r[a]="");return r}activityData(){let e=["Id","Kind","Label"],t=this.graphDB.vertices.map(r=>{let s=[parseInt(r._.Id.split("a")[1])];return this.formatRow(r,e,s)});return{columns:e,data:t}}edgeData(){let e=["Id","Label"],t=this.graphDB.edges.map(r=>{let s=[r._.Id];return this.formatRow(r,e,s)});return{columns:e,data:t}}subgraphData(){let e=["Id","Label"],t=this.graphDB.subgraphs.map(r=>{let s=[r._.Id];return this.formatRow(r,e,s)});return{columns:e,data:t}}calcGraphTooltip(e){let t,r;if(e instanceof G){let s=this.rSubgraphsMap[e.id()];t=s._,r=s.parent._}else if(e instanceof R||e instanceof M){let s=this.rVerticesMap[e.id()];t=s._,r=s.parent._}else if(e instanceof U){let s=this.rEdgesMap[e.id()];t=s._,r=s.parent._}return t?t.calcTooltip(r):""}subgraph(e){return this.subgraphsMap[e]}vertex(e){return this.verticesMap[e]}edge(e){return this.edgesMap[e]}minClick(e){}};(function(){if(!document.getElementById("641d6c4b")){var c=document.createElement("style");c.id="641d6c4b",c.textContent=`.eclwatch_WUGraph .graph_Vertex {
12
- cursor: auto;
13
- }
14
-
15
- .eclwatch_WUGraph .marker {
16
- fill: #656565;
17
- stroke: none;
18
- stroke-width: 1.0px;
19
- }
20
-
21
- .eclwatch_WUGraph .zoom {
22
- fill: none;
23
- pointer-events: all;
24
- }
25
-
26
- .eclwatch_WUGraph .selectionBrush {
27
- fill: none;
28
- stroke: darkgray;
29
- }
30
-
31
- .d3-tip .eclwatch_WUGraph_Tooltip h3 {
32
- margin:0px;
33
- }
34
-
35
- .d3-tip .eclwatch_WUGraph_Tooltip h4 {
36
- margin:0px;
37
- }
38
-
39
- .d3-tip .eclwatch_WUGraph_Tooltip table {
40
- border-collapse: separate;
41
- border-spacing: 5px;
42
- }
43
-
44
- .d3-tip .eclwatch_WUGraph_Tooltip table .key {
45
- font-weight: bold;
46
- }
47
-
48
- .d3-tip .eclwatch_WUGraph_Tooltip table .value {
49
- font-weight: normal;
50
- }
51
- `,document.head.appendChild(c)}})();var m=class extends te{static{l(this,"WUGraph")}_partialAll=new W().faChar("fa-window-restore").tooltip("Partial All").on("click",()=>{this.stateClick(this._partialAll)});_maxAll=new W().faChar("fa-window-maximize").tooltip("Max All").on("click",()=>{this.stateClick(this._maxAll)});_toggleGraph=new v().faChar("fa-chain").tooltip("Graph").selected(!0).on("click",()=>{this.viewClick(this._toggleGraph)});_toggleActivities=new v().faChar("fa-table").tooltip("Activitiies").selected(!1).on("click",()=>{this.viewClick(this._toggleActivities)});_toggleEdges=new v().faChar("fa-table").tooltip("Edges").selected(!1).on("click",()=>{this.viewClick(this._toggleEdges)});_toggleSubgraphs=new v().faChar("fa-table").tooltip("Subgraphs").selected(!1).on("click",()=>{this.viewClick(this._toggleSubgraphs)});_graph=new Z().layout("Hierarchy").applyScaleOnLayout(!0).showToolbar(!1).allowDragging(!1);_activities=new D().pagination(!1);_edges=new D().pagination(!1);_subgraphs=new D().pagination(!1);_legend=new S(this).on("click",e=>{this.render()}).on("mouseover",e=>{let t={};for(let r of this._gc.vertices(e))t[r.id()]=!0;this._graph.highlightVerticies(t)}).on("mouseout",e=>{this._graph.highlightVerticies()});_view=new ee().widgets([this._graph,this._activities,this._edges,this._subgraphs]);_gc=new k;constructor(){super(),this.topOverlay(!1),this.widget(this._view);let e=[this._toggleGraph,this._toggleActivities,this._toggleEdges,this._toggleSubgraphs,new P,this._partialAll,this._maxAll,new P,...this._graph.iconBarButtons(),new P];this.buttons(e.concat(this.buttons())),this._gc.minClick=t=>{this.loadGraph(),this._graph.render(r=>{this._graph.selection([t]).centerOnItem(t)})},this._graph.tooltipHTML(t=>this._gc.calcGraphTooltip(t))}stateClick(e){switch(e){case this._partialAll:this._graph.data().subgraphs.forEach(t=>{t.minState("partial")});break;case this._maxAll:this._graph.data().subgraphs.forEach(t=>{t.minState("normal")});break}this.render()}viewClick(e){switch(this._toggleGraph.selected(e===this._toggleGraph),this._toggleActivities.selected(e===this._toggleActivities),this._toggleEdges.selected(e===this._toggleEdges),this._toggleSubgraphs.selected(e===this._toggleSubgraphs),e){case this._toggleGraph:this._view.active(0);break;case this._toggleActivities:this._view.active(1);break;case this._toggleEdges:this._view.active(2);break;case this._toggleSubgraphs:this._view.active(3);break}this.render(t=>{})}_prevHashSum;_prevScopeGraph;fetchScopeGraph(){let e=re({baseUrl:this.baseUrl(),wuid:this.wuid(),graphID:this.graphID(),subgraphID:this.subgraphID()});return!this._prevScopeGraph||this._prevHashSum!==e?(this.startProgress(),this._prevHashSum=e,this._gc.clear(),Y.attach({baseUrl:this.baseUrl()},this.wuid()).fetchGraphs().then(r=>{for(let s of r)if(s.Name===this.graphID())return this.finishProgress(),s.fetchScopeGraph(this.subgraphID())}).then(r=>(this._prevScopeGraph=r,this._prevScopeGraph))):Promise.resolve(this._prevScopeGraph)}enter(e,t){super.enter(e,t)}update(e,t){super.update(e,t)}exit(e,t){super.exit(e,t)}loadGraph(){this._gc.disabled(this._legend.disabled()),this._graph.data(this._gc.graphData(),!0);{let{columns:e,data:t}=this._gc.activityData();this._activities.columns(e).data(t)}{let{columns:e,data:t}=this._gc.edgeData();this._edges.columns(e).data(t)}{let{columns:e,data:t}=this._gc.subgraphData();this._subgraphs.columns(e).data(t)}}render(e){return this.wuid()&&this.graphID()?this.fetchScopeGraph().then(t=>{this._gc.set(t),this._legend.data(this._gc.calcLegend()),this.loadGraph(),super.render(e)}):super.render(e),this}selection(e){if(!arguments.length)return this._graph.selection();let t=this._gc.vertex(e)||this._gc.edge(e)||this._gc.subgraph(e);return t&&this._graph.selection([t]),this}};m.prototype._class+=" eclwatch_WUGraph";m.prototype.publish("baseUrl","","string","HPCC Platform Base URL");m.prototype.publish("wuid","","string","Workunit ID");m.prototype.publish("graphID","","string","Graph ID");m.prototype.publish("subgraphID","","string","Subgraph ID");import{Result as V}from"@hpcc-js/comms";import{Common as ne}from"@hpcc-js/dgrid";import{hashSum as ce}from"@hpcc-js/util";import{Deferred as se,domConstruct as d,QueryResults as ie,RowFormatter as ae}from"@hpcc-js/dgrid";function oe(c){return String(c).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}l(oe,"entitiesEncode");function y(c){switch(Object.prototype.toString.call(c)){case"[object Undefined]":case"[object Boolean]":case"[object Number]":return c;case"[object String]":return oe(c);default:console.warn("Unknown cell type: "+Object.prototype.toString.call(c))}return c}l(y,"safeEncode");var I=class{static{l(this,"Store")}wuResult;schema;_columns;_cache={};rowFormatter;_filter={};constructor(e,t,r,s={}){this.wuResult=e,this.schema=t,this._columns=this.schema2Columns(this.schema.root),this.rowFormatter=new ae(this._columns,r),this._filter=s}columns(){return this._columns}schema2Columns(e,t=""){return e?e.children().filter(r=>r.name.indexOf("__hidden",r.name.length-8)===-1).map((r,s)=>{let a=r.name,i=r.attrs["hpcc:keyed"],o={field:t+a,leafID:a,idx:s,label:a+(i?" (i)":""),className:"resultGridCell",sortable:!1,width:i?16:0,isSet:r.isSet},n=this.schema2Columns(r,t+a+"_");return n.length?(o.width+=10+n.reduce((h,g)=>h+g.width,0),o.children=n):(o.width+=r.charWidth()*9,o.formatter=(h,g)=>{switch(typeof h){case"string":return{html:h.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;").trim()};case"undefined":return""}return h}),o}):[]}isChildDataset(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=0,r=null;for(let s in e)r||(r=Object.prototype.toString.call(e[s])),t++;return t===1&&r==="[object Array]"}rowToTable(e,t,r){if(this.isChildDataset(e)){for(let a in e)this.rowToTable(e[a],t,r);return}let s=d.create("table",{border:1,cellspacing:0,width:"100%"},r);switch(Object.prototype.toString.call(e)){case"[object Object]":let a=d.create("tr",null,s);for(let i in e)d.create("th",{innerHTML:y(i)},a);a=d.create("tr",null,s);for(let i in e)switch(Object.prototype.toString.call(e[i])){case"[object Object]":case"[object Array]":this.rowToTable(e[i],t,r);break;default:d.create("td",{innerHTML:y(e[i])},a);break}break;case"[object Array]":for(let i=0;i<e.length;++i)switch(Object.prototype.toString.call(e[i])){case"[object Boolean]":case"[object Number]":case"[object String]":let o=d.create("tr",null,s);d.create("td",{innerHTML:y(e[i])},o);break;default:if(i===0){let n=d.create("tr",null,s);for(let h in e[i])d.create("th",{innerHTML:y(h)},n)}d.create("tr",null,s);for(let n in e[i])if(e[i][n])if(Object.prototype.toString.call(e[i][n])==="[object Object]"||Object.prototype.toString.call(e[i][n])==="[object Array]"){let h=d.create("td",null,o);this.rowToTable(e[i][n],e[i],h)}else if(n.indexOf("__html",n.length-6)!==-1)d.create("td",{innerHTML:e[i][n]},o);else if(n.indexOf("__javascript",n.length-12)!==-1)d.create("td",null,o);else{let h=e[i][n];d.create("td",{innerHTML:y(h)},o)}else d.create("td",{innerHTML:""},o)}break}}getIdentity(e){return e.__hpcc_id}_request(e,t){if(!this.wuResult)return Promise.resolve({totalLength:0,data:[]});let r=`${e}->${t}`;if(this._cache[r])return this._cache[r];let s=this.wuResult.fetchRows(e,t-e,!1,this._filter).then(a=>({totalLength:this.wuResult.Total,data:a.map((i,o)=>{let n=this.rowFormatter.format(i);return n.__hpcc_id=e+o,n.__hpcc_orig=i,n})}));return this._cache[r]=s,s}fetchRange(e){let t=new se;return this._request(e.start,e.end).then(r=>t.resolve(r)),new ie(t.then(r=>r.data),{totalLength:t.then(r=>r.totalLength)})}};var _=class extends ne{static{l(this,"WUResult")}_result;_localStore;constructor(){super(),this.renderHtml(!1)}hashSum(e={}){return ce({baseUrl:this.baseUrl(),wuid:this.wuid(),resultName:this.resultName(),sequence:this.sequence(),nodeGroup:this.nodeGroup(),logicalFile:this.logicalFile(),userID:this.user(),password:this.password(),...e})}_prevResultHash;calcResult(){let e=this.hashSum();if(this._prevResultHash!==e){this._prevResultHash=e;let t={baseUrl:this.baseUrl(),userID:this.user(),password:this.password()};this.wuid()&&this.resultName()?this._result=V.attach(t,this.wuid(),this.resultName()):this.wuid()&&this.sequence()!==void 0?this._result=V.attach(t,this.wuid(),this.sequence()):this.logicalFile()&&this.nodeGroup()?this._result=V.attachLogicalFile(t,this.nodeGroup(),this.logicalFile()):this.logicalFile()&&(this._result=V.attachLogicalFile(t,"",this.logicalFile()))}return this._result}fetch(e,t,r=new AbortController){let s=this.calcResult();return s?s.fetchRows(e,t,!1,{},r.signal):Promise.resolve([])}_prevStoreHash;_prevQueryHash;update(e,t){super.update(e,t);let r=this.hashSum({renderHtml:this.renderHtml(),filter:this.filter()});if(this._prevStoreHash!==r){this._prevStoreHash=r;let s=this.calcResult();s&&s.fetchXMLSchema().then(a=>{this._localStore=new I(s,a,this.renderHtml(),this.filter()),this._dgrid?.set("columns",this._localStore.columns()),this._dgrid?.set("collection",this._localStore)})}}click(e,t,r){}};_.prototype._class+=" eclwatch_WUResult";_.prototype.publish("baseUrl","","string","URL to WsWorkunits");_.prototype.publish("user","","string","User ID");_.prototype.publish("password","","string","Password");_.prototype.publish("wuid","","string","Workunit ID");_.prototype.publish("resultName","","string","Result Name");_.prototype.publish("sequence",void 0,"number","Sequence Number");_.prototype.publish("nodeGroup","","string","NodeGroup");_.prototype.publish("logicalFile","","string","Logical File Name");_.prototype.publish("filter",{},"object","Filter");import{Workunit as he,WUStateID as u}from"@hpcc-js/comms";import{Edge as le,Graph as pe,Vertex as ue}from"@hpcc-js/graph";import{hashSum as de}from"@hpcc-js/util";var ge=(s=>(s.CREATE="Created",s.COMPILE="Compiled",s.EXECUTE="Executed",s.COMPLETE="Completed",s))(ge||{}),_e=(s=>(s.CREATE="Creating",s.COMPILE="Compiling",s.EXECUTE="Executing",s.COMPLETE="Completed",s))(_e||{}),w=class extends pe{static{l(this,"WUStatus")}_wu;_wuHandle;_create;_compile;_execute;_complete;constructor(){super(),this.zoomable(!1).zoomToFitLimit(1).layout("Hierarchy").hierarchyRankDirection("LR").showToolbar(!1).allowDragging(!1)}_prevHash;attachWorkunit(){let e=de({baseUrl:this.baseUrl(),wuid:this.wuid()});this._prevHash!==e&&(this._prevHash=e,this._wu=he.attach({baseUrl:this.baseUrl()},this.wuid()),this._wuHandle&&this._wuHandle.release(),this._wuHandle=this._wu.watch(t=>{this.lazyRender()}))}createVertex(e){return new ue().icon_diameter(32).icon_shape_colorFill("none").icon_shape_colorStroke("none").icon_image_colorFill("darkgray").iconAnchor("middle").textbox_shape_colorFill("none").textbox_shape_colorStroke("none").textbox_text_colorFill("darkgray").faChar(e)}updateVertex(e,t){e.icon_image_colorFill(t).textbox_text_colorFill(t)}updateVertexStatus(e,t=!1){let r=this._wu.isFailed()?"darkred":"darkgreen";switch(this._create.text("Created"),this._compile.text("Compiled"),this._execute.text("Executed"),this._complete.text("Completed"),e){case 0:this.updateVertex(this._create,"darkgray"),this.updateVertex(this._compile,"darkgray"),this.updateVertex(this._execute,"darkgray"),this.updateVertex(this._complete,"darkgray");break;case 1:this._create.text("Creating"),this.updateVertex(this._create,t?"orange":r),this.updateVertex(this._compile,"darkgray"),this.updateVertex(this._execute,"darkgray"),this.updateVertex(this._complete,"darkgray");break;case 2:this._compile.text("Compiling"),this.updateVertex(this._create,r),this.updateVertex(this._compile,t?"orange":r),this.updateVertex(this._execute,r),this.updateVertex(this._complete,"darkgray");break;case 3:this._execute.text("Executing"),this.updateVertex(this._create,r),this.updateVertex(this._compile,r),this.updateVertex(this._execute,t?"orange":r),this.updateVertex(this._complete,"darkgray");break;case 4:this.updateVertex(this._create,r),this.updateVertex(this._compile,r),this.updateVertex(this._execute,r),this.updateVertex(this._complete,r);break}}createEdge(e,t){return new le().sourceVertex(e).targetVertex(t).strokeColor("black").showArc(!1)}enter(e,t){super.enter(e,t),this._create=this.createVertex("\uF11D"),this._compile=this.createVertex("\uF085"),this._execute=this.createVertex("\uF275"),this._complete=this.createVertex("\uF11E");let r=this.createEdge(this._create,this._compile),s=this.createEdge(this._compile,this._execute),a=this.createEdge(this._execute,this._complete);this.data({vertices:[this._create,this._compile,this._execute,this._complete],edges:[r,s,a]})}update(e,t){switch(this.attachWorkunit(),this._wu.StateID){case u.Blocked:case u.Wait:case u.Scheduled:case u.UploadingFiled:this.updateVertexStatus(1);break;case u.Compiling:this.updateVertexStatus(2,!0);break;case u.Submitted:this.updateVertexStatus(1,!0);break;case u.Compiled:this.updateVertexStatus(2);break;case u.Aborting:case u.Running:this.updateVertexStatus(3,!0);break;case u.Aborted:case u.Archived:case u.Completed:this.updateVertexStatus(4);break;case u.Failed:this.updateVertexStatus(4,!1);break;case u.DebugPaused:case u.DebugRunning:case u.Paused:case u.Unknown:default:this.updateVertexStatus(0);break}super.update(e,t),this.zoomToFit()}exit(e,t){this._wuHandle&&this._wuHandle.release(),super.exit(e,t)}};w.prototype._class+=" eclwatch_WUStatus";w.prototype.publish("baseUrl","","string","HPCC Platform Base URL");w.prototype.publish("wuid","","string","Workunit ID");import{Palette as fe}from"@hpcc-js/common";import{Workunit as me}from"@hpcc-js/comms";import{ReactTimelineSeries as be}from"@hpcc-js/timeline";import{hashSum as Se}from"@hpcc-js/util";var A=["label","start","end","icon","color","series"],b=class extends be{static{l(this,"WUTimeline")}_palette=fe.ordinal("default");constructor(){super(),this.columns(A).titleColumn("label").iconColumn("icon").colorColumn("color").seriesColumn("series").timePattern("%Y-%m-%dT%H:%M:%S.%LZ").tickFormat("%H:%M").tooltipTimeFormat("%H:%M:%S.%L").tooltipHTML(e=>e[A.length].calcTooltip())}_prevHashSum;clear(){return delete this._prevHashSum,this}fetchScopes(){let e=Se({baseUrl:this.baseUrl(),wuid:this.wuid(),request:this.request()});this._prevHashSum!==e&&(this._prevHashSum=e,me.attach({baseUrl:this.baseUrl()},this.wuid()).fetchDetails(this.request()).then(r=>r.filter(s=>s.Id&&s.attr("WhenStarted").RawValue).map(s=>{let a=+s.attr("WhenStarted").RawValue/1e3,i=+s.attr("TimeElapsed").RawValue/1e6;return[s.Id,new Date(a).toISOString(),i?new Date(a+i).toISOString():void 0,null,this._palette(s.ScopeType),s.ScopeName.split("::").join(":").split(":").slice(0,1),s]})).then(r=>{this.data(r).render()}))}enter(e,t){super.enter(e,t)}update(e,t){this.fetchScopes(),super.update(e,t)}exit(e,t){super.exit(e,t)}};b.prototype._class+=" eclwatch_WUTimeline";b.prototype.publish("baseUrl","","string","HPCC Platform Base URL");b.prototype.publish("wuid","","string","Workunit ID");b.prototype.publish("request",{ScopeFilter:{MaxDepth:3,ScopeTypes:["graph","subgraph"]},NestedFilter:{Depth:0,ScopeTypes:[]},PropertiesToReturn:{AllProperties:!1,AllStatistics:!0,AllHints:!1,Properties:["WhenStarted","TimeElapsed"]},ScopeOptions:{IncludeId:!0,IncludeScope:!0,IncludeScopeType:!0},PropertyOptions:{IncludeName:!0,IncludeRawValue:!0,IncludeFormatted:!0,IncludeMeasure:!0,IncludeCreator:!1,IncludeCreatorType:!1}},"object","WUDetails Request");export{ke as BUILD_VERSION,p as ECLArchiveViewer,we as PKG_NAME,xe as PKG_VERSION,ge as STATUS,_e as STATUS_ACTIVE,m as WUGraph,_ as WUResult,k as WUScopeController,w as WUStatus,b as WUTimeline};
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".eclwatch_WUGraphLegend .graph_Vertex{cursor:auto}.eclwatch_WUGraphLegend .graph_Vertex .common_Icon{cursor:pointer}.eclwatch_WUGraph .graph_Vertex{cursor:auto}.eclwatch_WUGraph .marker{fill:#656565;stroke:none;stroke-width:1px}.eclwatch_WUGraph .zoom{fill:none;pointer-events:all}.eclwatch_WUGraph .selectionBrush{fill:none;stroke:#a9a9a9}.d3-tip .eclwatch_WUGraph_Tooltip h3,.d3-tip .eclwatch_WUGraph_Tooltip h4{margin:0}.d3-tip .eclwatch_WUGraph_Tooltip table{border-collapse:separate;border-spacing:5px}.d3-tip .eclwatch_WUGraph_Tooltip table .key{font-weight:700}.d3-tip .eclwatch_WUGraph_Tooltip table .value{font-weight:400}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { Editor } from "@hpcc-js/codemirror";
6
+ import { Workunit, BaseScope, Result, WUStateID } from "@hpcc-js/comms";
7
+ import { SplitPanel } from "@hpcc-js/phosphor";
8
+ import { DirectoryTree } from "@hpcc-js/tree";
9
+ import { xml2json, hashSum, Subgraph, Vertex as Vertex$1, Edge } from "@hpcc-js/util";
10
+ import { local, select, Icon, Button, ToggleButton, Spacer, Palette } from "@hpcc-js/common";
11
+ import { Table, RowFormatter, domConstruct, Deferred, QueryResults, Common } from "@hpcc-js/dgrid";
12
+ import { Vertex, Subgraph as Subgraph$1, Edge as Edge$1, Graph } from "@hpcc-js/graph";
13
+ import { Legend, ChartPanel, Carousel } from "@hpcc-js/layout";
14
+ import { ReactTimelineSeries } from "@hpcc-js/timeline";
15
+ const PKG_NAME = "@hpcc-js/eclwatch", PKG_VERSION = "3.1.1", BUILD_VERSION = "3.2.1";
16
+ class ECLArchiveViewer extends SplitPanel {
17
+ constructor() {
18
+ super("horizontal");
19
+ __publicField(this, "_prevHash");
20
+ __publicField(this, "_contentStr");
21
+ __publicField(this, "_directoryPane", new DirectoryTree());
22
+ __publicField(this, "_fileEditorPane", new Editor().text(""));
23
+ this._directoryPane.rowClick = (text) => {
24
+ this._fileEditorPane.text(text).render();
25
+ };
26
+ }
27
+ transformArchiveTreeData(json) {
28
+ const ret = {
29
+ label: json.name,
30
+ children: json._children.map(transformNode).filter((n) => n)
31
+ };
32
+ if (ret.children && ret.children[0] && ret.children[0].label === "html")
33
+ return {
34
+ label: "root",
35
+ children: [
36
+ {
37
+ label: "error",
38
+ content: JSON.stringify(ret, null, 4)
39
+ }
40
+ ]
41
+ };
42
+ return ret;
43
+ function transformNode(node) {
44
+ const _node = {};
45
+ if (_node.label = node.name + (node.$ && node.$.key ? ` (${node.$.key})` : ""), node._children && node._children.length > 0)
46
+ _node.children = node._children.map((_node2) => transformNode(_node2)).filter((n) => n);
47
+ else if (typeof node.content == "string" && node.content.trim())
48
+ _node.content = node.content;
49
+ else
50
+ return !1;
51
+ return _node;
52
+ }
53
+ }
54
+ updateDirectoryPane(contentStr) {
55
+ let json;
56
+ if (contentStr)
57
+ try {
58
+ json = JSON.parse(contentStr);
59
+ } catch {
60
+ json = xml2json(contentStr);
61
+ }
62
+ if (json) {
63
+ const _data = this.transformArchiveTreeData(json);
64
+ this._directoryPane.data(_data).render();
65
+ }
66
+ }
67
+ enter(domNode, element) {
68
+ super.enter(domNode, element), this.addWidget(this._directoryPane).addWidget(this._fileEditorPane);
69
+ }
70
+ update(domNode, element) {
71
+ super.update(domNode, element);
72
+ const hash = hashSum({
73
+ baseUrl: this.baseUrl(),
74
+ wuid: this.wuid()
75
+ });
76
+ this._prevHash !== hash || typeof this._contentStr > "u" ? Workunit.attach({ baseUrl: this.baseUrl() }, this.wuid()).fetchArchive().then((resp) => {
77
+ this._contentStr = resp, this.updateDirectoryPane(this._contentStr), this._prevHash = hash;
78
+ }) : this.updateDirectoryPane(this._contentStr), this.relativeSizes([this.directoryWidthRatio(), 1 - this.directoryWidthRatio()]);
79
+ }
80
+ }
81
+ ECLArchiveViewer.prototype._class += " eclwatch_ECLArchiveViewer";
82
+ ECLArchiveViewer.prototype.publish("baseUrl", "", "string", "HPCC Platform Base URL");
83
+ ECLArchiveViewer.prototype.publish("wuid", "", "string", "Workunit ID");
84
+ ECLArchiveViewer.prototype.publish("directoryWidthRatio", 0.38, "number", "Default directory panel width ratio relative to the full width");
85
+ ECLArchiveViewer.prototype.publish("contentString", null, "string", "XML/JSON archive content string");
86
+ ECLArchiveViewer.prototype.publishProxy("directoryPaneColor", "_directoryPane", "backgroundColor");
87
+ ECLArchiveViewer.prototype.publishProxy("directoryPaneHoverColor", "_directoryPane", "hoverBackgroundColor");
88
+ ECLArchiveViewer.prototype.publishProxy("iconSize", "_directoryPane");
89
+ ECLArchiveViewer.prototype.publishProxy("fontColor", "_directoryPane");
90
+ ECLArchiveViewer.prototype.publishProxy("fontFamily", "_directoryPane");
91
+ ECLArchiveViewer.prototype.publishProxy("fontSize", "_directoryPane");
92
+ ECLArchiveViewer.prototype.publishProxy("folderIconOpen", "_directoryPane");
93
+ ECLArchiveViewer.prototype.publishProxy("folderIconClosed", "_directoryPane");
94
+ ECLArchiveViewer.prototype.publishProxy("textFileIcon", "_directoryPane");
95
+ ECLArchiveViewer.prototype.publishProxy("codeFileIcon", "_directoryPane");
96
+ ECLArchiveViewer.prototype.publishProxy("verticalScroll", "_directoryPane");
97
+ class LegendVertex extends Vertex {
98
+ constructor() {
99
+ super();
100
+ }
101
+ enter(domNode, element) {
102
+ super.enter(domNode, element), this._icon.on("click", () => {
103
+ this.click(this.data());
104
+ });
105
+ }
106
+ click(kind) {
107
+ }
108
+ }
109
+ class WUGraphLegend extends Legend {
110
+ constructor() {
111
+ super(...arguments);
112
+ __publicField(this, "icon", local());
113
+ __publicField(this, "_disabled2", {
114
+ /* TODO: Default some to disabled?
115
+ 43: true,
116
+ 71: true,
117
+ 82: true,
118
+ 88: true
119
+ */
120
+ });
121
+ }
122
+ disabled(_) {
123
+ if (!arguments.length) {
124
+ const retVal = [];
125
+ for (const key in this._disabled2)
126
+ this._disabled2[key] && retVal.push(key);
127
+ return retVal;
128
+ }
129
+ return this._disabled2 = {}, _.forEach((kind) => this._disabled2[kind] = !0), this;
130
+ }
131
+ toggle(kind) {
132
+ this._disabled2[kind] = !this._disabled2[kind];
133
+ }
134
+ update(domNode, element) {
135
+ super.update(domNode, element);
136
+ const context = this, items = this._g.selectAll(".legendItem").data(this.data(), (d) => d.kind);
137
+ items.enter().append("g").attr("class", "legendItem").each(function(d) {
138
+ context.icon.set(
139
+ this,
140
+ new LegendVertex().target(this).data(d.kind).textbox_shape_colorStroke("none").textbox_shape_colorFill("none").iconAnchor("left").faChar(d.faChar).text(`${d.label} (${d.count})`).tooltip(`${d.kind} - ${d.label}`).on("click", (kind) => {
141
+ context.toggle(kind), context.render(), context.click(kind);
142
+ }).on("mouseover", (kind) => {
143
+ context.mouseover(kind);
144
+ }).on("mouseout", (kind) => {
145
+ context.mouseout(kind);
146
+ })
147
+ );
148
+ }).merge(items).each(function(d, i) {
149
+ const bbox2 = context.icon.get(this).icon_shape_colorFill(context._disabled2[d.kind] ? "gray" : null).render().getBBox();
150
+ select(this).attr("transform", `translate(${+bbox2.width / 2}, ${i * 30})`);
151
+ }), items.exit().each(function(d) {
152
+ context.icon.get(this).target(null).render();
153
+ }).remove();
154
+ const bbox = this.getBBox(!0, !0);
155
+ this._g.attr("transform", `translate(16, ${this.height() / 2 - bbox.height / 2})`);
156
+ }
157
+ // Events ---
158
+ click(kind) {
159
+ }
160
+ mouseover(kind) {
161
+ }
162
+ mouseout(kind) {
163
+ }
164
+ }
165
+ WUGraphLegend.prototype._class += " eclwatch_WUGraphLegend";
166
+ function faCharFactory(kind) {
167
+ switch (kind) {
168
+ case "2":
169
+ return "";
170
+ // Disk Write
171
+ case "3":
172
+ return "";
173
+ // sort
174
+ case "5":
175
+ return "";
176
+ // Filter
177
+ case "6":
178
+ return "";
179
+ // Split
180
+ case "12":
181
+ return "";
182
+ // First N
183
+ case "15":
184
+ return "";
185
+ // Lightweight Join
186
+ case "17":
187
+ return "";
188
+ // Lookup Join
189
+ case "22":
190
+ return "";
191
+ // Pipe Output
192
+ case "23":
193
+ return "";
194
+ // Funnel
195
+ case "25":
196
+ return "";
197
+ // Inline Dataset
198
+ case "26":
199
+ return "";
200
+ // distribute
201
+ case "29":
202
+ return "";
203
+ // Store Internal Result
204
+ case "36":
205
+ return "";
206
+ // If
207
+ case "44":
208
+ return "";
209
+ // write csv
210
+ case "47":
211
+ return "";
212
+ // write
213
+ case "54":
214
+ return "";
215
+ // Workunit Read
216
+ case "56":
217
+ return "";
218
+ // Spill
219
+ case "59":
220
+ return "";
221
+ // Merge
222
+ case "61":
223
+ return "";
224
+ // write xml
225
+ case "82":
226
+ return "";
227
+ // Projected Disk Read Spill
228
+ case "88":
229
+ return "";
230
+ // Projected Disk Read Spill
231
+ case "92":
232
+ return "";
233
+ // Limted Index Read
234
+ case "93":
235
+ return "";
236
+ // Limted Index Read
237
+ case "99":
238
+ return "";
239
+ // CSV Read
240
+ case "105":
241
+ return "";
242
+ // CSV Read
243
+ case "7":
244
+ return "";
245
+ // Project
246
+ case "9":
247
+ return "";
248
+ // Local Iterate
249
+ case "16":
250
+ return "";
251
+ // Output Internal
252
+ case "19":
253
+ return "";
254
+ // Hash Distribute
255
+ case "21":
256
+ return "";
257
+ // Normalize
258
+ case "35":
259
+ return "";
260
+ // CSV Write
261
+ case "37":
262
+ return "";
263
+ // Index Write
264
+ case "71":
265
+ return "";
266
+ // Disk Read Spill
267
+ case "133":
268
+ return "";
269
+ // Inline Dataset
270
+ case "148":
271
+ return "";
272
+ // Inline Dataset
273
+ case "168":
274
+ return "";
275
+ }
276
+ return "";
277
+ }
278
+ class WUScopeController {
279
+ constructor() {
280
+ __publicField(this, "graphDB");
281
+ __publicField(this, "subgraphsMap", {});
282
+ __publicField(this, "rSubgraphsMap", {});
283
+ __publicField(this, "verticesMap", {});
284
+ __publicField(this, "rVerticesMap", {});
285
+ __publicField(this, "edgesMap", {});
286
+ __publicField(this, "rEdgesMap", {});
287
+ __publicField(this, "kindMap", {});
288
+ __publicField(this, "_disabled", {});
289
+ }
290
+ clear() {
291
+ this.subgraphsMap = {}, this.rSubgraphsMap = {}, this.verticesMap = {}, this.rVerticesMap = {}, this.edgesMap = {}, this.rEdgesMap = {};
292
+ }
293
+ set(masterGraph) {
294
+ this.graphDB = masterGraph, this.graphGui(this.graphDB), this.kindMap = {}, this.graphDB.walk((item) => {
295
+ if (!(item instanceof Subgraph)) {
296
+ if (item instanceof Vertex$1) {
297
+ const kind = item._.attr("Kind").RawValue;
298
+ this.kindMap[kind] || (this.kindMap[kind] = []), this.kindMap[kind].push(item);
299
+ }
300
+ }
301
+ });
302
+ }
303
+ disabled(_) {
304
+ if (!arguments.length) {
305
+ const retVal = [];
306
+ for (const key in this._disabled)
307
+ this._disabled[key] && retVal.push(key);
308
+ return retVal;
309
+ }
310
+ return this._disabled = {}, _.forEach((kind) => this._disabled[kind] = !0), this;
311
+ }
312
+ graphGui(graphDB) {
313
+ const graphGui = {
314
+ subgraphs: [],
315
+ vertices: [],
316
+ edges: [],
317
+ hierarchy: []
318
+ };
319
+ return graphDB.walk((item) => {
320
+ if (item instanceof Subgraph) {
321
+ const subgraph = this.appendSubgraph(item, graphGui.hierarchy, graphGui.subgraphs);
322
+ subgraph.showMinMax(item.vertices.length > 3 || subgraph.minState() !== "normal");
323
+ } else item instanceof Vertex$1 ? this.appendVertex(item, graphGui.hierarchy, graphGui.vertices) : item instanceof Edge && this.appendEdge(item, graphGui.edges);
324
+ }), graphGui;
325
+ }
326
+ format(labelTpl, obj) {
327
+ let retVal = "", lpos = labelTpl.indexOf("%"), rpos = -1;
328
+ for (; lpos >= 0; ) {
329
+ if (retVal += labelTpl.substring(rpos + 1, lpos), rpos = labelTpl.indexOf("%", lpos + 1), rpos < 0) {
330
+ console.warn("Invalid Label Template");
331
+ break;
332
+ }
333
+ const key = labelTpl.substring(lpos + 1, rpos);
334
+ retVal += key ? obj[labelTpl.substring(lpos + 1, rpos)] || "" : "%", lpos = labelTpl.indexOf("%", rpos + 1);
335
+ }
336
+ return retVal += labelTpl.substring(rpos + 1, labelTpl.length), retVal.split("\\n").join(`
337
+ `);
338
+ }
339
+ createSubgraph(subgraph) {
340
+ let sg = this.subgraphsMap[subgraph._.Id];
341
+ return sg || (sg = new Subgraph$1().title(subgraph._.Id).on("minClick", () => {
342
+ this.minClick(sg);
343
+ }), this.subgraphsMap[subgraph._.Id] = sg, this.rSubgraphsMap[sg.id()] = subgraph), sg;
344
+ }
345
+ createVertex(vertex) {
346
+ let v = this.verticesMap[vertex._.Id];
347
+ if (!v) {
348
+ const attrs = vertex._.rawAttrs();
349
+ if (vertex._.ScopeType === "dummy") {
350
+ const parent = this.subgraphsMap[vertex.parent._.Id];
351
+ v = new Icon().shape_colorFill("darkred").shape_colorStroke("darkred").image_colorFill("white").faChar("").on("click", () => {
352
+ parent.minState("normal"), this.minClick(parent);
353
+ });
354
+ } else {
355
+ v = new Vertex().icon_shape_colorFill("#1f77b4").icon_image_colorFill("white").faChar(faCharFactory(attrs.Kind)).text(attrs.Label);
356
+ const annotations = [];
357
+ vertex._.hasAttr("Definition") && annotations.push({
358
+ faChar: "",
359
+ tooltip: "Definition",
360
+ shape_colorFill: "lightgray",
361
+ shape_colorStroke: "lightgray",
362
+ image_colorFill: "black"
363
+ }), vertex._.hasAttr("IsInternal") && annotations.push({
364
+ faChar: "",
365
+ tooltip: "IsInternal",
366
+ shape_colorFill: "red",
367
+ shape_colorStroke: "red",
368
+ image_colorFill: "white"
369
+ }), v.annotationIcons(annotations);
370
+ }
371
+ this.verticesMap[vertex._.Id] = v, this.rVerticesMap[v.id()] = vertex;
372
+ }
373
+ return v;
374
+ }
375
+ isSpill(edge) {
376
+ const sourceKind = edge.source._.attr("Kind").RawValue, targetKind = edge.target._.attr("Kind").RawValue;
377
+ return sourceKind === "2" || targetKind === "71";
378
+ }
379
+ spansSubgraph(edge) {
380
+ return edge.source.parent._.Id !== edge.target.parent._.Id;
381
+ }
382
+ createEdge(edge) {
383
+ let e = this.edgesMap[edge._.Id];
384
+ if (!e) {
385
+ const attrs = edge._.rawAttrs(), sourceV = this.verticesMap[edge.source._.Id], targetV = this.verticesMap[edge.target._.Id];
386
+ if (sourceV && targetV) {
387
+ const isSpill = this.isSpill(edge), spansSubgraph = this.spansSubgraph(edge), label = this.format(`%Label%
388
+ %NumRowsProcessed%`, attrs);
389
+ let strokeDasharray = null, weight = 100;
390
+ attrs.IsDependency ? (weight = 10, strokeDasharray = "1,5") : attrs._childGraph ? strokeDasharray = "5,5" : isSpill ? (weight = 25, strokeDasharray = "5,5,10,5") : spansSubgraph && (weight = 5, strokeDasharray = "5,5"), e = new Edge$1().sourceVertex(sourceV).targetVertex(targetV).sourceMarker("circle").targetMarker("arrow").weight(weight).strokeDasharray(strokeDasharray).text(label), this.edgesMap[edge._.Id] = e, this.rEdgesMap[e.id()] = edge;
391
+ }
392
+ }
393
+ return e;
394
+ }
395
+ appendSubgraph(subgraph, hierarchy, subgraphs) {
396
+ const sg = this.createSubgraph(subgraph);
397
+ subgraphs.push(sg);
398
+ const parent = this.subgraphsMap[subgraph.parent._.Id];
399
+ return parent && hierarchy.push({ parent, child: sg }), sg;
400
+ }
401
+ appendVertex(vertex, hierarchy, vertices) {
402
+ const v = this.createVertex(vertex);
403
+ vertices.push(v);
404
+ const parent = this.subgraphsMap[vertex.parent._.Id];
405
+ return parent && hierarchy.push({ parent, child: v }), v;
406
+ }
407
+ appendEdge(edge, edges) {
408
+ const e = this.createEdge(edge);
409
+ return e && edges.push(e), e;
410
+ }
411
+ filterLegend(graphDB) {
412
+ for (let i = graphDB.vertices.length - 1; i >= 0; --i) {
413
+ const vertex = graphDB.vertices[i], kind = vertex._.attr("Kind").RawValue;
414
+ this._disabled[kind] && vertex.remove(!1, (source, target) => new BaseScope({
415
+ ScopeName: vertex._.ScopeName + ":in",
416
+ Id: source.Id + "->" + target.Id,
417
+ ScopeType: "dummy-edge",
418
+ Properties: {
419
+ Property: [vertex._.attr("Label")]
420
+ },
421
+ Notes: {
422
+ Note: []
423
+ },
424
+ SinkActivity: ""
425
+ }));
426
+ }
427
+ }
428
+ filterPartial(graphDB) {
429
+ for (const subgraph of graphDB.subgraphs)
430
+ switch (this.subgraphsMap[subgraph._.Id].minState()) {
431
+ case "partial":
432
+ const childVertices = subgraph.vertices, vShow = [], vHide = [];
433
+ for (const vertex of childVertices)
434
+ vertex.inEdges.length === 0 || vertex.inEdges.some((edge) => edge.source.parent !== edge.target.parent) || vertex.outEdges.length === 0 || vertex.outEdges.some((edge) => edge.source.parent !== edge.target.parent) ? vShow.push(vertex) : vHide.push(vertex);
435
+ if (vHide.length > 1) {
436
+ const dummyDetails = {
437
+ ScopeName: subgraph._.ScopeName,
438
+ Id: subgraph._.Id + ":dummy",
439
+ ScopeType: "dummy",
440
+ Properties: {
441
+ Property: [{
442
+ Name: "Activities",
443
+ RawValue: "" + vHide.length,
444
+ Formatted: "" + vHide.length,
445
+ Measure: "count",
446
+ Creator: "",
447
+ CreatorType: ""
448
+ }]
449
+ },
450
+ Notes: {
451
+ Note: []
452
+ },
453
+ SinkActivity: ""
454
+ }, dummyScope = new BaseScope(dummyDetails), dummyVertex = subgraph.createVertex(dummyScope);
455
+ for (const vertex of vHide) {
456
+ for (const edge of vertex.inEdges)
457
+ if (vShow.indexOf(edge.source) >= 0) {
458
+ const dummyEdgeScope = new BaseScope({
459
+ ScopeName: edge.source._.ScopeName,
460
+ Id: edge.source._.Id + "->" + dummyVertex._.Id,
461
+ ScopeType: "dummy-in",
462
+ Properties: {
463
+ Property: []
464
+ },
465
+ Notes: {
466
+ Note: []
467
+ },
468
+ SinkActivity: ""
469
+ });
470
+ subgraph.createEdge(edge.source, dummyVertex, dummyEdgeScope);
471
+ }
472
+ for (const edge of vertex.outEdges)
473
+ if (vShow.indexOf(edge.target) >= 0) {
474
+ const dummyEdgeScope = new BaseScope({
475
+ ScopeName: edge.target._.ScopeName,
476
+ Id: dummyVertex._.Id + "->" + edge.target._.Id,
477
+ ScopeType: "dummy-out",
478
+ Properties: {
479
+ Property: []
480
+ },
481
+ Notes: {
482
+ Note: []
483
+ },
484
+ SinkActivity: ""
485
+ });
486
+ subgraph.createEdge(dummyVertex, edge.target, dummyEdgeScope);
487
+ }
488
+ }
489
+ vHide.forEach((vertex) => vertex.remove(!0));
490
+ }
491
+ break;
492
+ }
493
+ }
494
+ filterEmptySubgraphs(graphDB) {
495
+ for (; ; ) {
496
+ const emptySubgraphs = graphDB.subgraphs.filter((subgraph) => subgraph.subgraphs.length === 0 && subgraph.vertices.length === 0);
497
+ if (emptySubgraphs.length === 0) break;
498
+ emptySubgraphs.forEach((subgraph) => subgraph.remove(!0));
499
+ }
500
+ }
501
+ removeObsoleteSubgraphs(graphDB) {
502
+ for (const subgraph of [...graphDB.subgraphs])
503
+ subgraph.vertices.length === 0 && subgraph.remove(!1);
504
+ }
505
+ graphData() {
506
+ const graphDB = this.graphDB.clone();
507
+ return this.filterLegend(graphDB), this.filterPartial(graphDB), this.filterEmptySubgraphs(graphDB), this.removeObsoleteSubgraphs(graphDB), this.graphGui(graphDB);
508
+ }
509
+ calcLegend() {
510
+ const retVal = [];
511
+ for (const kind in this.kindMap)
512
+ retVal.push({
513
+ kind: parseInt(kind),
514
+ faChar: faCharFactory(kind),
515
+ label: this.kindMap[kind][0]._.attr("Label").RawValue.split(`
516
+ `)[0],
517
+ count: this.kindMap[kind].length
518
+ });
519
+ return retVal;
520
+ }
521
+ vertices(kind) {
522
+ const retVal = [];
523
+ for (const v of this.kindMap[kind])
524
+ retVal.push(this.verticesMap[v._.Id]);
525
+ return retVal;
526
+ }
527
+ formatRow(item, columns2, row) {
528
+ const attrs = item._.formattedAttrs();
529
+ for (const key in attrs) {
530
+ const idx = columns2.indexOf(key);
531
+ idx === -1 ? (columns2.push(key), row.push(attrs[key])) : row[idx] = attrs[key];
532
+ }
533
+ for (let i = 0; i < 100; ++i)
534
+ row[i] === void 0 && (row[i] = "");
535
+ return row;
536
+ }
537
+ activityData() {
538
+ const columns2 = ["Id", "Kind", "Label"], data = this.graphDB.vertices.map((v) => {
539
+ const row = [parseInt(v._.Id.split("a")[1])];
540
+ return this.formatRow(v, columns2, row);
541
+ });
542
+ return { columns: columns2, data };
543
+ }
544
+ edgeData() {
545
+ const columns2 = ["Id", "Label"], data = this.graphDB.edges.map((e) => {
546
+ const row = [e._.Id];
547
+ return this.formatRow(e, columns2, row);
548
+ });
549
+ return { columns: columns2, data };
550
+ }
551
+ subgraphData() {
552
+ const columns2 = ["Id", "Label"], data = this.graphDB.subgraphs.map((sg) => {
553
+ const row = [sg._.Id];
554
+ return this.formatRow(sg, columns2, row);
555
+ });
556
+ return { columns: columns2, data };
557
+ }
558
+ calcGraphTooltip(item) {
559
+ let scope, parentScope;
560
+ if (item instanceof Subgraph$1) {
561
+ const subgraph = this.rSubgraphsMap[item.id()];
562
+ scope = subgraph._, parentScope = subgraph.parent._;
563
+ } else if (item instanceof Vertex || item instanceof Icon) {
564
+ const vertex = this.rVerticesMap[item.id()];
565
+ scope = vertex._, parentScope = vertex.parent._;
566
+ } else if (item instanceof Edge$1) {
567
+ const edge = this.rEdgesMap[item.id()];
568
+ scope = edge._, parentScope = edge.parent._;
569
+ }
570
+ return scope ? scope.calcTooltip(parentScope) : "";
571
+ }
572
+ subgraph(id) {
573
+ return this.subgraphsMap[id];
574
+ }
575
+ vertex(id) {
576
+ return this.verticesMap[id];
577
+ }
578
+ edge(id) {
579
+ return this.edgesMap[id];
580
+ }
581
+ // Events ---
582
+ minClick(sg) {
583
+ }
584
+ }
585
+ class WUGraph extends ChartPanel {
586
+ constructor() {
587
+ super();
588
+ __publicField(this, "_partialAll", new Button().faChar("fa-window-restore").tooltip("Partial All").on("click", () => {
589
+ this.stateClick(this._partialAll);
590
+ }));
591
+ __publicField(this, "_maxAll", new Button().faChar("fa-window-maximize").tooltip("Max All").on("click", () => {
592
+ this.stateClick(this._maxAll);
593
+ }));
594
+ __publicField(this, "_toggleGraph", new ToggleButton().faChar("fa-chain").tooltip("Graph").selected(!0).on("click", () => {
595
+ this.viewClick(this._toggleGraph);
596
+ }));
597
+ __publicField(this, "_toggleActivities", new ToggleButton().faChar("fa-table").tooltip("Activitiies").selected(!1).on("click", () => {
598
+ this.viewClick(this._toggleActivities);
599
+ }));
600
+ __publicField(this, "_toggleEdges", new ToggleButton().faChar("fa-table").tooltip("Edges").selected(!1).on("click", () => {
601
+ this.viewClick(this._toggleEdges);
602
+ }));
603
+ __publicField(this, "_toggleSubgraphs", new ToggleButton().faChar("fa-table").tooltip("Subgraphs").selected(!1).on("click", () => {
604
+ this.viewClick(this._toggleSubgraphs);
605
+ }));
606
+ __publicField(this, "_graph", new Graph().layout("Hierarchy").applyScaleOnLayout(!0).showToolbar(!1).allowDragging(!1));
607
+ __publicField(this, "_activities", new Table().pagination(!1));
608
+ __publicField(this, "_edges", new Table().pagination(!1));
609
+ __publicField(this, "_subgraphs", new Table().pagination(!1));
610
+ __publicField(this, "_legend", new WUGraphLegend(this).on("click", (kind) => {
611
+ this.render();
612
+ }).on("mouseover", (kind) => {
613
+ const verticesMap = {};
614
+ for (const vertex of this._gc.vertices(kind))
615
+ verticesMap[vertex.id()] = !0;
616
+ this._graph.highlightVerticies(verticesMap);
617
+ }).on("mouseout", (kind) => {
618
+ this._graph.highlightVerticies();
619
+ }));
620
+ __publicField(this, "_view", new Carousel().widgets([this._graph, this._activities, this._edges, this._subgraphs]));
621
+ __publicField(this, "_gc", new WUScopeController());
622
+ __publicField(this, "_prevHashSum");
623
+ __publicField(this, "_prevScopeGraph");
624
+ this.topOverlay(!1), this.widget(this._view);
625
+ const buttons = [
626
+ this._toggleGraph,
627
+ this._toggleActivities,
628
+ this._toggleEdges,
629
+ this._toggleSubgraphs,
630
+ new Spacer(),
631
+ this._partialAll,
632
+ this._maxAll,
633
+ new Spacer(),
634
+ ...this._graph.iconBarButtons(),
635
+ new Spacer()
636
+ ];
637
+ this.buttons(buttons.concat(this.buttons())), this._gc.minClick = (sg) => {
638
+ this.loadGraph(), this._graph.render((w) => {
639
+ this._graph.selection([sg]).centerOnItem(sg);
640
+ });
641
+ }, this._graph.tooltipHTML((v) => this._gc.calcGraphTooltip(v));
642
+ }
643
+ stateClick(sourceB) {
644
+ switch (sourceB) {
645
+ case this._partialAll:
646
+ this._graph.data().subgraphs.forEach((sg) => {
647
+ sg.minState("partial");
648
+ });
649
+ break;
650
+ case this._maxAll:
651
+ this._graph.data().subgraphs.forEach((sg) => {
652
+ sg.minState("normal");
653
+ });
654
+ break;
655
+ }
656
+ this.render();
657
+ }
658
+ viewClick(sourceTB) {
659
+ switch (this._toggleGraph.selected(sourceTB === this._toggleGraph), this._toggleActivities.selected(sourceTB === this._toggleActivities), this._toggleEdges.selected(sourceTB === this._toggleEdges), this._toggleSubgraphs.selected(sourceTB === this._toggleSubgraphs), sourceTB) {
660
+ case this._toggleGraph:
661
+ this._view.active(0);
662
+ break;
663
+ case this._toggleActivities:
664
+ this._view.active(1);
665
+ break;
666
+ case this._toggleEdges:
667
+ this._view.active(2);
668
+ break;
669
+ case this._toggleSubgraphs:
670
+ this._view.active(3);
671
+ break;
672
+ }
673
+ this.render((w) => {
674
+ });
675
+ }
676
+ fetchScopeGraph() {
677
+ const hash = hashSum({
678
+ baseUrl: this.baseUrl(),
679
+ wuid: this.wuid(),
680
+ graphID: this.graphID(),
681
+ subgraphID: this.subgraphID()
682
+ });
683
+ return !this._prevScopeGraph || this._prevHashSum !== hash ? (this.startProgress(), this._prevHashSum = hash, this._gc.clear(), Workunit.attach({ baseUrl: this.baseUrl() }, this.wuid()).fetchGraphs().then((graphs) => {
684
+ for (const graph of graphs)
685
+ if (graph.Name === this.graphID())
686
+ return this.finishProgress(), graph.fetchScopeGraph(this.subgraphID());
687
+ }).then((scopeGraph) => (this._prevScopeGraph = scopeGraph, this._prevScopeGraph))) : Promise.resolve(this._prevScopeGraph);
688
+ }
689
+ enter(domNode, _element) {
690
+ super.enter(domNode, _element);
691
+ }
692
+ update(domNode, element) {
693
+ super.update(domNode, element);
694
+ }
695
+ exit(domNode, element) {
696
+ super.exit(domNode, element);
697
+ }
698
+ loadGraph() {
699
+ this._gc.disabled(this._legend.disabled()), this._graph.data(this._gc.graphData(), !0);
700
+ {
701
+ const { columns: columns2, data } = this._gc.activityData();
702
+ this._activities.columns(columns2).data(data);
703
+ }
704
+ {
705
+ const { columns: columns2, data } = this._gc.edgeData();
706
+ this._edges.columns(columns2).data(data);
707
+ }
708
+ {
709
+ const { columns: columns2, data } = this._gc.subgraphData();
710
+ this._subgraphs.columns(columns2).data(data);
711
+ }
712
+ }
713
+ render(callback) {
714
+ return this.wuid() && this.graphID() ? this.fetchScopeGraph().then((scopedGraph) => {
715
+ this._gc.set(scopedGraph), this._legend.data(this._gc.calcLegend()), this.loadGraph(), super.render(callback);
716
+ }) : super.render(callback), this;
717
+ }
718
+ selection(_) {
719
+ if (!arguments.length) return this._graph.selection();
720
+ const item = this._gc.vertex(_) || this._gc.edge(_) || this._gc.subgraph(_);
721
+ return item && this._graph.selection([item]), this;
722
+ }
723
+ }
724
+ WUGraph.prototype._class += " eclwatch_WUGraph";
725
+ WUGraph.prototype.publish("baseUrl", "", "string", "HPCC Platform Base URL");
726
+ WUGraph.prototype.publish("wuid", "", "string", "Workunit ID");
727
+ WUGraph.prototype.publish("graphID", "", "string", "Graph ID");
728
+ WUGraph.prototype.publish("subgraphID", "", "string", "Subgraph ID");
729
+ function entitiesEncode(str) {
730
+ return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
731
+ }
732
+ function safeEncode(item) {
733
+ switch (Object.prototype.toString.call(item)) {
734
+ case "[object Undefined]":
735
+ case "[object Boolean]":
736
+ case "[object Number]":
737
+ return item;
738
+ case "[object String]":
739
+ return entitiesEncode(item);
740
+ default:
741
+ console.warn("Unknown cell type: " + Object.prototype.toString.call(item));
742
+ }
743
+ return item;
744
+ }
745
+ class Store {
746
+ constructor(wuResult, schema, renderHtml, filter = {}) {
747
+ __publicField(this, "wuResult");
748
+ __publicField(this, "schema");
749
+ __publicField(this, "_columns");
750
+ __publicField(this, "_cache", {});
751
+ __publicField(this, "rowFormatter");
752
+ __publicField(this, "_filter", {});
753
+ this.wuResult = wuResult, this.schema = schema, this._columns = this.schema2Columns(this.schema.root), this.rowFormatter = new RowFormatter(this._columns, renderHtml), this._filter = filter;
754
+ }
755
+ columns() {
756
+ return this._columns;
757
+ }
758
+ schema2Columns(parentNode, prefix = "") {
759
+ return parentNode ? parentNode.children().filter((node) => node.name.indexOf("__hidden", node.name.length - 8) === -1).map((node, idx) => {
760
+ const label = node.name, keyed = node.attrs["hpcc:keyed"], column = {
761
+ field: prefix + label,
762
+ leafID: label,
763
+ idx,
764
+ label: label + (keyed ? " (i)" : ""),
765
+ className: "resultGridCell",
766
+ sortable: !1,
767
+ width: keyed ? 16 : 0,
768
+ isSet: node.isSet
769
+ }, children = this.schema2Columns(node, prefix + label + "_");
770
+ return children.length ? (column.width += 10 + children.reduce((prev, childNode) => prev + childNode.width, 0), column.children = children) : (column.width += node.charWidth() * 9, column.formatter = (cell, row) => {
771
+ switch (typeof cell) {
772
+ case "string":
773
+ return {
774
+ html: cell.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").trim()
775
+ };
776
+ case "undefined":
777
+ return "";
778
+ }
779
+ return cell;
780
+ }), column;
781
+ }) : [];
782
+ }
783
+ isChildDataset(cell) {
784
+ if (Object.prototype.toString.call(cell) !== "[object Object]")
785
+ return !1;
786
+ let propCount = 0, firstPropType = null;
787
+ for (const key in cell)
788
+ firstPropType || (firstPropType = Object.prototype.toString.call(cell[key])), propCount++;
789
+ return propCount === 1 && firstPropType === "[object Array]";
790
+ }
791
+ rowToTable(cell, __row, node) {
792
+ if (this.isChildDataset(cell)) {
793
+ for (const key in cell)
794
+ this.rowToTable(cell[key], __row, node);
795
+ return;
796
+ }
797
+ const table = domConstruct.create("table", { border: 1, cellspacing: 0, width: "100%" }, node);
798
+ switch (Object.prototype.toString.call(cell)) {
799
+ case "[object Object]":
800
+ let tr = domConstruct.create("tr", null, table);
801
+ for (const key in cell)
802
+ domConstruct.create("th", { innerHTML: safeEncode(key) }, tr);
803
+ tr = domConstruct.create("tr", null, table);
804
+ for (const key in cell)
805
+ switch (Object.prototype.toString.call(cell[key])) {
806
+ case "[object Object]":
807
+ case "[object Array]":
808
+ this.rowToTable(cell[key], __row, node);
809
+ break;
810
+ default:
811
+ domConstruct.create("td", { innerHTML: safeEncode(cell[key]) }, tr);
812
+ break;
813
+ }
814
+ break;
815
+ case "[object Array]":
816
+ for (let i = 0; i < cell.length; ++i)
817
+ switch (Object.prototype.toString.call(cell[i])) {
818
+ case "[object Boolean]":
819
+ case "[object Number]":
820
+ case "[object String]":
821
+ const tr1 = domConstruct.create("tr", null, table);
822
+ domConstruct.create("td", { innerHTML: safeEncode(cell[i]) }, tr1);
823
+ break;
824
+ default:
825
+ if (i === 0) {
826
+ const tr2 = domConstruct.create("tr", null, table);
827
+ for (const key in cell[i])
828
+ domConstruct.create("th", { innerHTML: safeEncode(key) }, tr2);
829
+ }
830
+ domConstruct.create("tr", null, table);
831
+ for (const key in cell[i])
832
+ if (cell[i][key])
833
+ if (Object.prototype.toString.call(cell[i][key]) === "[object Object]" || Object.prototype.toString.call(cell[i][key]) === "[object Array]") {
834
+ const td = domConstruct.create("td", null, tr1);
835
+ this.rowToTable(cell[i][key], cell[i], td);
836
+ } else if (key.indexOf("__html", key.length - 6) !== -1)
837
+ domConstruct.create("td", { innerHTML: cell[i][key] }, tr1);
838
+ else if (key.indexOf("__javascript", key.length - 12) !== -1)
839
+ domConstruct.create("td", null, tr1);
840
+ else {
841
+ const val = cell[i][key];
842
+ domConstruct.create("td", { innerHTML: safeEncode(val) }, tr1);
843
+ }
844
+ else
845
+ domConstruct.create("td", { innerHTML: "" }, tr1);
846
+ }
847
+ break;
848
+ }
849
+ }
850
+ getIdentity(row) {
851
+ return row.__hpcc_id;
852
+ }
853
+ _request(start, end) {
854
+ if (!this.wuResult) return Promise.resolve({ totalLength: 0, data: [] });
855
+ const cacheKey = `${start}->${end}`;
856
+ if (this._cache[cacheKey]) return this._cache[cacheKey];
857
+ const retVal = this.wuResult.fetchRows(start, end - start, !1, this._filter).then((rows) => ({
858
+ totalLength: this.wuResult.Total,
859
+ data: rows.map((row, idx) => {
860
+ const formattedRow = this.rowFormatter.format(row);
861
+ return formattedRow.__hpcc_id = start + idx, formattedRow.__hpcc_orig = row, formattedRow;
862
+ })
863
+ }));
864
+ return this._cache[cacheKey] = retVal, retVal;
865
+ }
866
+ fetchRange(options) {
867
+ const retVal = new Deferred();
868
+ return this._request(options.start, options.end).then((response) => retVal.resolve(response)), new QueryResults(retVal.then((response) => response.data), {
869
+ totalLength: retVal.then((response) => response.totalLength)
870
+ });
871
+ }
872
+ }
873
+ class WUResult extends Common {
874
+ constructor() {
875
+ super();
876
+ __publicField(this, "_result");
877
+ __publicField(this, "_localStore");
878
+ __publicField(this, "_prevResultHash");
879
+ __publicField(this, "_prevStoreHash");
880
+ __publicField(this, "_prevQueryHash");
881
+ this.renderHtml(!1);
882
+ }
883
+ hashSum(opts = {}) {
884
+ return hashSum({
885
+ baseUrl: this.baseUrl(),
886
+ wuid: this.wuid(),
887
+ resultName: this.resultName(),
888
+ sequence: this.sequence(),
889
+ nodeGroup: this.nodeGroup(),
890
+ logicalFile: this.logicalFile(),
891
+ userID: this.user(),
892
+ password: this.password(),
893
+ ...opts
894
+ });
895
+ }
896
+ calcResult() {
897
+ const resultHash = this.hashSum();
898
+ if (this._prevResultHash !== resultHash) {
899
+ this._prevResultHash = resultHash;
900
+ const opts = {
901
+ baseUrl: this.baseUrl(),
902
+ userID: this.user(),
903
+ password: this.password()
904
+ };
905
+ this.wuid() && this.resultName() ? this._result = Result.attach(opts, this.wuid(), this.resultName()) : this.wuid() && this.sequence() !== void 0 ? this._result = Result.attach(opts, this.wuid(), this.sequence()) : this.logicalFile() && this.nodeGroup() ? this._result = Result.attachLogicalFile(opts, this.nodeGroup(), this.logicalFile()) : this.logicalFile() && (this._result = Result.attachLogicalFile(opts, "", this.logicalFile()));
906
+ }
907
+ return this._result;
908
+ }
909
+ fetch(row, count, abortController = new AbortController()) {
910
+ const result = this.calcResult();
911
+ return result ? result.fetchRows(row, count, !1, {}, abortController.signal) : Promise.resolve([]);
912
+ }
913
+ update(domNode, element) {
914
+ super.update(domNode, element);
915
+ const storeHash = this.hashSum({
916
+ renderHtml: this.renderHtml(),
917
+ filter: this.filter()
918
+ });
919
+ if (this._prevStoreHash !== storeHash) {
920
+ this._prevStoreHash = storeHash;
921
+ const result = this.calcResult();
922
+ result && result.fetchXMLSchema().then((schema) => {
923
+ var _a, _b;
924
+ this._localStore = new Store(result, schema, this.renderHtml(), this.filter()), (_a = this._dgrid) == null || _a.set("columns", this._localStore.columns()), (_b = this._dgrid) == null || _b.set("collection", this._localStore);
925
+ });
926
+ }
927
+ }
928
+ click(row, col, sel) {
929
+ }
930
+ }
931
+ WUResult.prototype._class += " eclwatch_WUResult";
932
+ WUResult.prototype.publish("baseUrl", "", "string", "URL to WsWorkunits");
933
+ WUResult.prototype.publish("user", "", "string", "User ID");
934
+ WUResult.prototype.publish("password", "", "string", "Password");
935
+ WUResult.prototype.publish("wuid", "", "string", "Workunit ID");
936
+ WUResult.prototype.publish("resultName", "", "string", "Result Name");
937
+ WUResult.prototype.publish("sequence", void 0, "number", "Sequence Number");
938
+ WUResult.prototype.publish("nodeGroup", "", "string", "NodeGroup");
939
+ WUResult.prototype.publish("logicalFile", "", "string", "Logical File Name");
940
+ WUResult.prototype.publish("filter", {}, "object", "Filter");
941
+ var STATUS = /* @__PURE__ */ ((STATUS2) => (STATUS2.CREATE = "Created", STATUS2.COMPILE = "Compiled", STATUS2.EXECUTE = "Executed", STATUS2.COMPLETE = "Completed", STATUS2))(STATUS || {}), STATUS_ACTIVE = /* @__PURE__ */ ((STATUS_ACTIVE2) => (STATUS_ACTIVE2.CREATE = "Creating", STATUS_ACTIVE2.COMPILE = "Compiling", STATUS_ACTIVE2.EXECUTE = "Executing", STATUS_ACTIVE2.COMPLETE = "Completed", STATUS_ACTIVE2))(STATUS_ACTIVE || {});
942
+ class WUStatus extends Graph {
943
+ constructor() {
944
+ super();
945
+ __publicField(this, "_wu");
946
+ __publicField(this, "_wuHandle");
947
+ __publicField(this, "_create");
948
+ __publicField(this, "_compile");
949
+ __publicField(this, "_execute");
950
+ __publicField(this, "_complete");
951
+ __publicField(this, "_prevHash");
952
+ this.zoomable(!1).zoomToFitLimit(1).layout("Hierarchy").hierarchyRankDirection("LR").showToolbar(!1).allowDragging(!1);
953
+ }
954
+ attachWorkunit() {
955
+ const hash = hashSum({
956
+ baseUrl: this.baseUrl(),
957
+ wuid: this.wuid()
958
+ });
959
+ this._prevHash !== hash && (this._prevHash = hash, this._wu = Workunit.attach({ baseUrl: this.baseUrl() }, this.wuid()), this._wuHandle && this._wuHandle.release(), this._wuHandle = this._wu.watch((changes) => {
960
+ this.lazyRender();
961
+ }));
962
+ }
963
+ createVertex(faChar) {
964
+ return new Vertex().icon_diameter(32).icon_shape_colorFill("none").icon_shape_colorStroke("none").icon_image_colorFill("darkgray").iconAnchor("middle").textbox_shape_colorFill("none").textbox_shape_colorStroke("none").textbox_text_colorFill("darkgray").faChar(faChar);
965
+ }
966
+ updateVertex(vertex, color) {
967
+ vertex.icon_image_colorFill(color).textbox_text_colorFill(color);
968
+ }
969
+ updateVertexStatus(level, active = !1) {
970
+ const completeColor = this._wu.isFailed() ? "darkred" : "darkgreen";
971
+ switch (this._create.text(
972
+ "Created"
973
+ /* CREATE */
974
+ ), this._compile.text(
975
+ "Compiled"
976
+ /* COMPILE */
977
+ ), this._execute.text(
978
+ "Executed"
979
+ /* EXECUTE */
980
+ ), this._complete.text(
981
+ "Completed"
982
+ /* COMPLETE */
983
+ ), level) {
984
+ case 0:
985
+ this.updateVertex(this._create, "darkgray"), this.updateVertex(this._compile, "darkgray"), this.updateVertex(this._execute, "darkgray"), this.updateVertex(this._complete, "darkgray");
986
+ break;
987
+ case 1:
988
+ this._create.text(
989
+ "Creating"
990
+ /* CREATE */
991
+ ), this.updateVertex(this._create, active ? "orange" : completeColor), this.updateVertex(this._compile, "darkgray"), this.updateVertex(this._execute, "darkgray"), this.updateVertex(this._complete, "darkgray");
992
+ break;
993
+ case 2:
994
+ this._compile.text(
995
+ "Compiling"
996
+ /* COMPILE */
997
+ ), this.updateVertex(this._create, completeColor), this.updateVertex(this._compile, active ? "orange" : completeColor), this.updateVertex(this._execute, completeColor), this.updateVertex(this._complete, "darkgray");
998
+ break;
999
+ case 3:
1000
+ this._execute.text(
1001
+ "Executing"
1002
+ /* EXECUTE */
1003
+ ), this.updateVertex(this._create, completeColor), this.updateVertex(this._compile, completeColor), this.updateVertex(this._execute, active ? "orange" : completeColor), this.updateVertex(this._complete, "darkgray");
1004
+ break;
1005
+ case 4:
1006
+ this.updateVertex(this._create, completeColor), this.updateVertex(this._compile, completeColor), this.updateVertex(this._execute, completeColor), this.updateVertex(this._complete, completeColor);
1007
+ break;
1008
+ }
1009
+ }
1010
+ createEdge(source, target) {
1011
+ return new Edge$1().sourceVertex(source).targetVertex(target).strokeColor("black").showArc(!1);
1012
+ }
1013
+ enter(domNode, element) {
1014
+ super.enter(domNode, element), this._create = this.createVertex(""), this._compile = this.createVertex(""), this._execute = this.createVertex(""), this._complete = this.createVertex("");
1015
+ const e1 = this.createEdge(this._create, this._compile), e2 = this.createEdge(this._compile, this._execute), e3 = this.createEdge(this._execute, this._complete);
1016
+ this.data({
1017
+ vertices: [this._create, this._compile, this._execute, this._complete],
1018
+ edges: [e1, e2, e3]
1019
+ });
1020
+ }
1021
+ update(domNode, element) {
1022
+ switch (this.attachWorkunit(), this._wu.StateID) {
1023
+ case WUStateID.Blocked:
1024
+ case WUStateID.Wait:
1025
+ case WUStateID.Scheduled:
1026
+ case WUStateID.UploadingFiled:
1027
+ this.updateVertexStatus(1);
1028
+ break;
1029
+ case WUStateID.Compiling:
1030
+ this.updateVertexStatus(2, !0);
1031
+ break;
1032
+ case WUStateID.Submitted:
1033
+ this.updateVertexStatus(1, !0);
1034
+ break;
1035
+ case WUStateID.Compiled:
1036
+ this.updateVertexStatus(2);
1037
+ break;
1038
+ case WUStateID.Aborting:
1039
+ case WUStateID.Running:
1040
+ this.updateVertexStatus(3, !0);
1041
+ break;
1042
+ case WUStateID.Aborted:
1043
+ case WUStateID.Archived:
1044
+ case WUStateID.Completed:
1045
+ this.updateVertexStatus(4);
1046
+ break;
1047
+ case WUStateID.Failed:
1048
+ this.updateVertexStatus(4, !1);
1049
+ break;
1050
+ case WUStateID.DebugPaused:
1051
+ case WUStateID.DebugRunning:
1052
+ case WUStateID.Paused:
1053
+ case WUStateID.Unknown:
1054
+ default:
1055
+ this.updateVertexStatus(0);
1056
+ break;
1057
+ }
1058
+ super.update(domNode, element), this.zoomToFit();
1059
+ }
1060
+ exit(domNode, element) {
1061
+ this._wuHandle && this._wuHandle.release(), super.exit(domNode, element);
1062
+ }
1063
+ }
1064
+ WUStatus.prototype._class += " eclwatch_WUStatus";
1065
+ WUStatus.prototype.publish("baseUrl", "", "string", "HPCC Platform Base URL");
1066
+ WUStatus.prototype.publish("wuid", "", "string", "Workunit ID");
1067
+ const columns = ["label", "start", "end", "icon", "color", "series"];
1068
+ class WUTimeline extends ReactTimelineSeries {
1069
+ constructor() {
1070
+ super();
1071
+ __publicField(this, "_palette", Palette.ordinal("default"));
1072
+ __publicField(this, "_prevHashSum");
1073
+ this.columns(columns).titleColumn("label").iconColumn("icon").colorColumn("color").seriesColumn("series").timePattern("%Y-%m-%dT%H:%M:%S.%LZ").tickFormat("%H:%M").tooltipTimeFormat("%H:%M:%S.%L").tooltipHTML((d) => d[columns.length].calcTooltip());
1074
+ }
1075
+ clear() {
1076
+ return delete this._prevHashSum, this;
1077
+ }
1078
+ fetchScopes() {
1079
+ const hash = hashSum({
1080
+ baseUrl: this.baseUrl(),
1081
+ wuid: this.wuid(),
1082
+ request: this.request()
1083
+ });
1084
+ this._prevHashSum !== hash && (this._prevHashSum = hash, Workunit.attach({ baseUrl: this.baseUrl() }, this.wuid()).fetchDetails(this.request()).then((scopes) => scopes.filter((scope) => scope.Id && scope.attr("WhenStarted").RawValue).map((scope) => {
1085
+ const whenStarted = +scope.attr("WhenStarted").RawValue / 1e3, timeElapsed = +scope.attr("TimeElapsed").RawValue / 1e6;
1086
+ return [
1087
+ scope.Id,
1088
+ new Date(whenStarted).toISOString(),
1089
+ timeElapsed ? new Date(whenStarted + timeElapsed).toISOString() : void 0,
1090
+ null,
1091
+ this._palette(scope.ScopeType),
1092
+ scope.ScopeName.split("::").join(":").split(":").slice(0, 1),
1093
+ scope
1094
+ ];
1095
+ })).then((scopes) => {
1096
+ this.data(scopes).render();
1097
+ }));
1098
+ }
1099
+ enter(domNode, _element) {
1100
+ super.enter(domNode, _element);
1101
+ }
1102
+ update(domNode, element) {
1103
+ this.fetchScopes(), super.update(domNode, element);
1104
+ }
1105
+ exit(domNode, element) {
1106
+ super.exit(domNode, element);
1107
+ }
1108
+ }
1109
+ WUTimeline.prototype._class += " eclwatch_WUTimeline";
1110
+ WUTimeline.prototype.publish("baseUrl", "", "string", "HPCC Platform Base URL");
1111
+ WUTimeline.prototype.publish("wuid", "", "string", "Workunit ID");
1112
+ WUTimeline.prototype.publish("request", {
1113
+ ScopeFilter: {
1114
+ MaxDepth: 3,
1115
+ ScopeTypes: ["graph", "subgraph"]
1116
+ },
1117
+ NestedFilter: {
1118
+ Depth: 0,
1119
+ ScopeTypes: []
1120
+ },
1121
+ PropertiesToReturn: {
1122
+ AllProperties: !1,
1123
+ AllStatistics: !0,
1124
+ AllHints: !1,
1125
+ Properties: ["WhenStarted", "TimeElapsed"]
1126
+ },
1127
+ ScopeOptions: {
1128
+ IncludeId: !0,
1129
+ IncludeScope: !0,
1130
+ IncludeScopeType: !0
1131
+ },
1132
+ PropertyOptions: {
1133
+ IncludeName: !0,
1134
+ IncludeRawValue: !0,
1135
+ IncludeFormatted: !0,
1136
+ IncludeMeasure: !0,
1137
+ IncludeCreator: !1,
1138
+ IncludeCreatorType: !1
1139
+ }
1140
+ }, "object", "WUDetails Request");
1141
+ export {
1142
+ BUILD_VERSION,
1143
+ ECLArchiveViewer,
1144
+ PKG_NAME,
1145
+ PKG_VERSION,
1146
+ STATUS,
1147
+ STATUS_ACTIVE,
1148
+ WUGraph,
1149
+ WUResult,
1150
+ WUScopeController,
1151
+ WUStatus,
1152
+ WUTimeline
1153
+ };
52
1154
  //# sourceMappingURL=index.js.map