diff --git a/dist/module.js b/dist/module.js index 128248c..600222d 100644 --- a/dist/module.js +++ b/dist/module.js @@ -1,2 +1,2 @@ -define(["@grafana/data","react","@grafana/ui","lodash","rxjs","@grafana/runtime"],((e,t,a,n,l,r)=>(()=>{"use strict";var i={781:t=>{t.exports=e},531:e=>{e.exports=r},7:e=>{e.exports=a},241:e=>{e.exports=n},959:e=>{e.exports=t},269:e=>{e.exports=l}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return i[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};o.r(u),o.d(u,{plugin:()=>X});var h=o(781),m=o(959),c=o.n(m),d=o(7);function p(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function g(e){for(var t=1;tv(g({},e),{jsonData:v(g({},e.jsonData),{url:e.url})});class f extends m.PureComponent{render(){const{options:e}=this.props,t=y(e);return c().createElement("div",null,c().createElement(d.DataSourceHttpSettings,{defaultUrl:"https://server.name/piwebapi",dataSourceConfig:t,onChange:this.onHttpOptionsChange,showAccessOptions:!0}),c().createElement("h3",{className:"page-heading"},"Custom Configuration"),c().createElement("div",{className:"gf-form-group"},c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable PI Points in Query",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.pipoint,onChange:this.onPiPointChange}))),c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable New Data Format",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.newFormat,onChange:this.onNewFormatChange}))),c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable Unit in Data",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.useUnit,onChange:this.onUseUnitChange}))),c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable Experimental Features",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.useExperimental,onChange:this.onUseExperimentalChange}))),t.jsonData.useExperimental&&c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable Steaming Support",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.useStreaming,onChange:this.onUseStreamingChange})))),c().createElement("h3",{className:"page-heading"},"PI/AF Connection Details"),c().createElement("div",{className:"gf-form-group"},t.jsonData.pipoint&&c().createElement("div",{className:"gf-form"},c().createElement(b,{label:"PI Server",labelWidth:10,inputWidth:25,onChange:this.onPIServerChange,value:t.jsonData.piserver||"",placeholder:"Default PI Server to use for data requests"})),c().createElement("div",{className:"gf-form"},c().createElement(b,{label:"AF Server",labelWidth:10,inputWidth:25,onChange:this.onAFServerChange,value:t.jsonData.afserver||"",placeholder:"Default AF Server to use for data requests"})),c().createElement("div",{className:"gf-form"},c().createElement(b,{label:"AF Database",labelWidth:10,inputWidth:25,onChange:this.onAFDatabaseChange,value:t.jsonData.afdatabase||"",placeholder:"Default AF Database server for AF queries"}))))}constructor(...e){super(...e),p(this,"onPIServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{piserver:e.target.value});t(v(g({},a),{jsonData:n}))})),p(this,"onAFServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{afserver:e.target.value});t(v(g({},a),{jsonData:n}))})),p(this,"onAFDatabaseChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{afdatabase:e.target.value});t(v(g({},a),{jsonData:n}))})),p(this,"onHttpOptionsChange",(e=>{const{onOptionsChange:t}=this.props;t(y(e))})),p(this,"onPiPointChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{piserver:e.target.checked?a.jsonData.piserver:"",pipoint:e.target.checked});t(v(g({},a),{jsonData:n}))})),p(this,"onNewFormatChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{newFormat:e.target.checked});t(v(g({},a),{jsonData:n}))})),p(this,"onUseUnitChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{useUnit:e.target.checked});t(v(g({},a),{jsonData:n}))})),p(this,"onUseExperimentalChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{useExperimental:e.target.checked,useStreaming:!!e.target.checked&&a.jsonData.useStreaming});t(v(g({},a),{jsonData:n}))})),p(this,"onUseStreamingChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{useStreaming:e.target.checked});t(v(g({},a),{jsonData:n}))}))}}var E=o(241);function S(){return S=Object.assign||function(e){for(var t=1;tc().createElement(c().Fragment,null,c().createElement(d.InlineFormLabel,{width:t,tooltip:a},e),n),I=()=>c().createElement("div",{className:"gf-form gf-form--grow"},c().createElement("div",{className:"gf-form-label gf-form-label--grow"})),w=e=>{var t=S({},P(e));return c().createElement(O,null,c().createElement(C,t))},O=e=>c().createElement("div",{className:"gf-form-inline"},e.children,c().createElement(I,null)),x=e=>{var t=S({},P(e));return c().createElement(D,null,c().createElement(C,t))},D=e=>c().createElement(c().Fragment,null,e.children),F={target:";",attributes:[],segments:[],regex:{enable:!1},summary:{types:[],basis:"EventWeighted",interval:"",nodata:"Null"},expression:"",interpolate:{enable:!1},useLastValue:{enable:!1},recordedValues:{enable:!1},digitalStates:{enable:!1},enableStreaming:{enable:!1},useUnit:{enable:!1},isPiPoint:!1},j=({isRaw:e,onChange:t})=>{const[a,n]=(0,m.useState)(!1);return(0,m.useEffect)((()=>{n(!1)}),[e]),e?c().createElement(c().Fragment,null,c().createElement(d.Button,{"aria-label":"Switch to visual editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{n(!0)}}),c().createElement(d.ConfirmModal,{isOpen:a,title:"Switch to visual editor mode",body:"Are you sure to switch to visual editor mode? You will lose the changes done in raw query mode.",confirmText:"Yes, switch to editor mode",dismissText:"No, stay in raw query mode",onConfirm:()=>{t(!1)},onDismiss:()=>{n(!1)}})):c().createElement(d.Button,{"aria-label":"Switch to text editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{t(!0)}})};function A(e){return(0,E.map)(e,(e=>{var t,a;return{text:e.Name,expandable:void 0===e.HasChildren||!0===e.HasChildren||(null!==(t=e.Path)&&void 0!==t?t:"").split("\\").length<=3,HasChildren:e.HasChildren,Items:null!==(a=e.Items)&&void 0!==a?a:[],Path:e.Path,WebId:e.WebId}}))}function W(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function V(e){for(var t=1;t{var t;return e.value?c().createElement("div",{className:"gf-form-label "+("template"===e.value.type?"query-keyword":"")},null!==(t=e.label)&&void 0!==t?t:"--no label--"):c().createElement("a",{className:"gf-form-label query-part"},c().createElement(d.Icon,{name:"plus"}))};class R extends m.PureComponent{isValueEmpty(e){return!e||!e.value||!e.value.length||e.value===k}calcBasisValueChanged(e){const t=this.props.query,a=t.summary;var n;a&&(a.basis=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(N(V({},t),{summary:a}))}getCalcBasisSegments(){return(0,E.map)(this.calculationBasis,(e=>({label:e,value:{value:e,expandable:!0}})))}calcNoDataValueChanged(e){const t=this.props.query,a=t.summary;var n;a&&(a.nodata=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(N(V({},t),{summary:a}))}getNoDataSegments(){return(0,E.map)(this.noDataReplacement,(e=>({label:e,value:{value:e,expandable:!0}})))}onSummaryValueChanged(e,t){const a=this.state.summaries.slice(0);a[t]=e,this.isValueEmpty(e.value)&&a.splice(t,1),this.setState({summaries:a},this.stateCallback)}getSummarySegments(){const e=(0,E.filter)(this.summaryTypes,(e=>-1===this.state.summaries.map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.value})).indexOf(e))),t=(0,E.map)(e,(e=>({label:e,value:{value:e,expandable:!0}})));return t.unshift({label:k,value:{value:k}}),t}removeSummary(e){const t=(0,E.filter)(this.state.summaries,(t=>t!==e));this.setState({summaries:t})}onSummaryAction(e){const t=this.state.summaries.slice(0);if(!this.isValueEmpty(e.value)){var a;let n={label:e.label,value:{value:null===(a=e.value)||void 0===a?void 0:a.value,expandable:!0}};t.push(n)}this.setState({summarySegment:{},summaries:t},this.stateCallback)}removeAttribute(e){const t=(0,E.filter)(this.state.attributes,(t=>t!==e));this.attributeChangeValue(t)}onAttributeAction(e){const{query:t}=this.props,a=this.state.attributes.slice(0);if(!this.isValueEmpty(e.value)){var n;let l={label:e.label,value:{value:null===(n=e.value)||void 0===n?void 0:n.value,expandable:!t.isPiPoint}};a.push(l)}this.attributeChangeValue(a)}getSegmentPathUpTo(e,t){const a=e.slice(0,t);return(0,E.reduce)(a,((e,t)=>{var a;return t.value?(null===(a=t.value.value)||void 0===a?void 0:a.startsWith("-Select"))?e:e?e+"\\"+t.value.value:t.value.value:""}),"")}checkAttributeSegments(e,t){var a;const{datasource:n,data:l}=this.props,r=this,i={path:this.getSegmentPathUpTo(t.slice(0),t.length),type:"attributes"};var s;return n.metricFindQuery(i,Object.assign(null!==(s=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==s?s:{},{isPiPoint:!1})).then((t=>{const a={};(0,E.each)(t,(e=>{a[e.Path.substring(e.Path.indexOf("|")+1)]=e.WebId}));const l=(0,E.filter)(e,(e=>{var t;const l=n.templateSrv.replace(null===(t=e.value)||void 0===t?void 0:t.value);return void 0!==a[l]}));return r.availableAttributes=a,this.attributeChangeValue(l)})).catch((t=>(r.error=t.message||"Failed to issue metric query",this.attributeChangeValue(e))))}checkPiPointSegments(e,t){var a;const{datasource:n,data:l}=this.props,r=this,i={path:e.path,webId:r.getSelectedPIServer(),pointName:e.label,type:"pipoint"};var s;return n.metricFindQuery(i,Object.assign(null!==(s=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==s?s:{},{isPiPoint:!0})).then((()=>r.attributeChangeValue(t))).catch((e=>(r.error=e.message||"Failed to issue metric query",r.attributeChangeValue([]))))}getSelectedPIServer(){var e;let t="";return this.piServer.forEach((e=>{const a=this.props.query.target.split(";");a.length>=2&&a[0]===e.text&&(t=e.WebId)})),this.piServer.length>0?null===(e=this.piServer[0].value)||void 0===e?void 0:e.webId:t}textEditorChanged(){const{query:e}=this.props,t=e.target.split(";"),a=t.length>0?t[0].split("\\"):[];let n=[],l=[];a.length>1||1===a.length&&""!==a[0]?(t.splice(0,1),(0,E.each)(a,((e,t)=>{n.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,E.each)(t,(function(e,t){""!==e&&l.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(a.length+1,n).then((e=>{e.length>0&&n.push({label:"Select Element",value:{value:"-Select Element-"}})})).then((()=>{this.updateArray(n,l,this.state.summaries,e.isPiPoint,(()=>{this.onChange(N(V({},e),{query:void 0,rawQuery:!1,attributes:this.state.attributes,segments:this.state.segments}))}))}))):(n=this.checkAfServer(),this.updateArray(n,this.state.attributes,this.state.summaries,e.isPiPoint,(()=>{this.onChange(N(V({},e),{query:void 0,rawQuery:!1,attributes:this.state.attributes,segments:this.state.segments}))})))}render(){const{query:e,onChange:t,onRunQuery:a}=this.props,n=(0,E.defaults)(e,F),{useLastValue:l,useUnit:r,interpolate:i,query:s,rawQuery:o,digitalStates:u,enableStreaming:h,recordedValues:m,expression:p,isPiPoint:g,summary:v,display:b,regex:y}=n;return c().createElement(c().Fragment,null,this.props.datasource.piPointConfig&&c().createElement(d.InlineField,{label:"Is Pi Point?",labelWidth:T},c().createElement(d.InlineSwitch,{value:g,onChange:this.onIsPiPointChange})),!!o&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Raw Query",labelWidth:T,grow:!0},c().createElement(d.Input,{onBlur:this.stateCallback,value:s,onChange:e=>t(N(V({},n),{query:e.target.value})),placeholder:"enter query"})),c().createElement(j,{isRaw:!0,onChange:e=>this.textEditorChanged()})),!o&&c().createElement(c().Fragment,null,c().createElement("div",{className:"gf-form-inline"},c().createElement(x,{label:g?"PI Server":"AF Elements",tooltip:g?"Select PI server.":"Select AF Element."},this.state.segments.map(((e,t)=>c().createElement(d.SegmentAsync,{key:"element-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),onChange:e=>this.onSegmentChange(e,t),loadOptions:e=>this.getElementSegments(t),allowCustomValue:!0,inputMinWidth:200}))),c().createElement(I,null),!g&&c().createElement(j,{isRaw:!1,onChange:e=>{t(N(V({},n),{query:n.target,rawQuery:e}))}}))),c().createElement(w,{label:g?"Pi Points":"Attributes"},this.state.attributes.map(((e,t)=>g?c().createElement(d.SegmentAsync,{key:"attributes-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),disabled:0===this.piServer.length,onChange:e=>this.onPiPointChange(e,t),loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:B}):c().createElement(d.Segment,{key:"attributes-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),disabled:this.state.segments.length<=2,onChange:e=>this.onAttributeChange(e,t),options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:B}))),g&&c().createElement(d.SegmentAsync,{Component:c().createElement(q,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:0===this.piServer.length,onChange:this.onAttributeAction,loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:B}),!g&&c().createElement(d.Segment,{Component:c().createElement(q,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:this.state.segments.length<=2,onChange:this.onAttributeAction,options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:B}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Calculation",grow:!0,labelWidth:T,tooltip:"Modify all attributes by an equation. Use '.' for current item. Leave Attributes empty if you wish to perform element based calculations."},c().createElement(d.Input,{onBlur:a,value:p,onChange:e=>t(N(V({},n),{expression:e.target.value})),placeholder:"'.'*2"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Use Last Value",tooltip:"Fetch only last value from time range",labelWidth:T},c().createElement(d.InlineSwitch,{value:l.enable,onChange:()=>this.onChange(N(V({},n),{useLastValue:N(V({},l),{enable:!l.enable})}))})),c().createElement(d.InlineField,{label:"Digital States",labelWidth:T},c().createElement(d.InlineSwitch,{value:u.enable,onChange:()=>this.onChange(N(V({},n),{digitalStates:N(V({},u),{enable:!u.enable})}))})),c().createElement(d.InlineField,{label:"Replace Bad Data",labelWidth:T,tooltip:"Replacement for bad quality values."},c().createElement(d.Segment,{Component:c().createElement(q,{value:{value:null==v?void 0:v.nodata},label:null==v?void 0:v.nodata}),onChange:this.calcNoDataValueChanged,options:this.getNoDataSegments(),allowCustomValue:!0})),this.props.datasource.useUnitConfig&&c().createElement(d.InlineField,{label:"Use unit from datapoints",tooltip:"Use unit in label from PI tag or PI AF attribute",labelWidth:T},c().createElement(d.InlineSwitch,{value:r.enable,onChange:()=>this.onChange(N(V({},n),{useUnit:N(V({},r),{enable:!r.enable})}))})),this.props.datasource.useStreaming&&c().createElement(d.InlineField,{label:"Enable Streaming",labelWidth:T,tooltip:"Enable streaming data if it is supported for the point type."},c().createElement(d.InlineSwitch,{value:h.enable,onChange:()=>this.onChange(N(V({},n),{enableStreaming:N(V({},h),{enable:!h.enable})}))}))),c().createElement(d.InlineFieldRow,null,!l.enable&&c().createElement(d.InlineField,{label:"Max Recorded Values",labelWidth:T,tooltip:"Maximum number of recorded value to retrive from the data archive, without using interpolation."},c().createElement(d.Input,{onBlur:a,value:m.maxNumber,onChange:e=>t(N(V({},n),{recordedValues:N(V({},m),{maxNumber:parseInt(e.target.value,10)})})),type:"number",placeholder:"1000"})),c().createElement(d.InlineField,{label:"Recorded Values",labelWidth:T},c().createElement(d.InlineSwitch,{value:m.enable,onChange:()=>this.onChange(N(V({},n),{recordedValues:N(V({},m),{enable:!m.enable})}))}))),!l.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:p?"Interval Period":"Interpolate Period",labelWidth:T,tooltip:"Override time between sampling, e.g. '30s'. Defaults to timespan/chart width."},c().createElement(d.Input,{onBlur:a,value:i.interval,onChange:e=>t(N(V({},n),{interpolate:N(V({},i),{interval:e.target.value})})),placeholder:"30s"})),c().createElement(d.InlineField,{label:p?"Interval Values":"Interpolate",labelWidth:T},c().createElement(d.InlineSwitch,{value:i.enable,onChange:()=>this.onChange(N(V({},n),{interpolate:N(V({},i),{enable:!i.enable})}))}))),!l.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Summary Period",labelWidth:T,tooltip:"Define the summary period, e.g. '30s'."},c().createElement(d.Input,{onBlur:a,value:null==v?void 0:v.interval,onChange:e=>t(N(V({},n),{summary:N(V({},v),{interval:e.target.value})})),placeholder:"30s"})),c().createElement(d.InlineField,{label:"Basis",labelWidth:T,tooltip:"Defines the possible calculation options when performing summary calculations over time-series data."},c().createElement(d.Segment,{Component:c().createElement(q,{value:{value:null==v?void 0:v.basis},label:null==v?void 0:v.basis}),onChange:this.calcBasisValueChanged,options:this.getCalcBasisSegments(),allowCustomValue:!0})),c().createElement(d.InlineField,{label:"Summaries",labelWidth:T,tooltip:"PI Web API summary options."},c().createElement(d.InlineFieldRow,null,this.state.summaries.map(((e,t)=>c().createElement(d.Segment,{key:"summaries-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),onChange:e=>this.onSummaryValueChanged(e,t),options:this.getSummarySegments(),allowCustomValue:!0}))),c().createElement(d.Segment,{Component:c().createElement(q,{value:this.state.summarySegment.value,label:this.state.summarySegment.label}),onChange:this.onSummaryAction,options:this.getSummarySegments(),allowCustomValue:!0})))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Display Name",labelWidth:T,tooltip:"If single attribute, modify display name. Otherwise use regex to modify display name."},c().createElement(d.Input,{onBlur:a,value:b,onChange:e=>t(N(V({},n),{display:e.target.value})),placeholder:"Display"})),c().createElement(d.InlineField,{label:"Enable Regex Replace",labelWidth:T},c().createElement(d.InlineSwitch,{value:y.enable,onChange:()=>{this.onChange(N(V({},n),{regex:N(V({},y),{enable:!y.enable})}))}})),c().createElement(d.InlineField,{label:"Search",labelWidth:16},c().createElement(d.Input,{onBlur:a,value:y.search,onChange:e=>t(N(V({},n),{regex:N(V({},y),{search:e.target.value})})),placeholder:"(.*)"})),c().createElement(d.InlineField,{label:"Replace",labelWidth:16},c().createElement(d.Input,{onBlur:a,value:y.replace,onChange:e=>t(N(V({},n),{regex:N(V({},y),{replace:e.target.value})})),placeholder:"$1"}))))}constructor(e){super(e),W(this,"error",void 0),W(this,"piServer",[]),W(this,"availableAttributes",{}),W(this,"summaryTypes",void 0),W(this,"calculationBasis",void 0),W(this,"noDataReplacement",void 0),W(this,"state",{isPiPoint:!1,segments:[],attributes:[],summaries:[],attributeSegment:{},summarySegment:{},calculationBasisSegment:{},noDataReplacementSegment:{}}),W(this,"segmentChangeValue",(e=>{const t=this.props.query;this.setState({segments:e},(()=>this.onChange(N(V({},t),{segments:e}))))})),W(this,"attributeChangeValue",(e=>{const t=this.props.query;return new Promise((a=>this.setState({attributes:e},(()=>{this.onChange(N(V({},t),{attributes:e})),a()}))))})),W(this,"onPiPointChange",((e,t)=>{let a=this.state.attributes.slice(0);e.label===k?(0,E.remove)(a,((e,a)=>a===t)):a[t]=e,this.checkPiPointSegments(e,a)})),W(this,"onAttributeChange",((e,t)=>{var a;let n=this.state.attributes.slice(0);n[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&(n[t]=e,this.checkAttributeSegments(n,this.state.segments))})),W(this,"onSegmentChange",((e,t)=>{var a;const{query:n}=this.props;let l=this.state.segments.slice(0);l[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&this.setState({attributes:[]},(()=>e.label===k?(l=(0,E.slice)(l,0,t),void this.checkAttributeSegments([],l).then((()=>{var e;0===l.length?l.push({label:""}):(null===(e=l[l.length-1].value)||void 0===e?void 0:e.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),n.isPiPoint&&(this.piServer=[]),this.segmentChangeValue(l)}))):(l[t]=e,n.isPiPoint?(this.piServer.push(e),void this.segmentChangeValue(l)):(t{var t,a;return"template"===(null===(t=e.value)||void 0===t?void 0:t.type)?this.getElementSegments(l.length+1,l).then((e=>(e.length>0&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),this.segmentChangeValue(l),l))):((null===(a=e.value)||void 0===a?void 0:a.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),new Promise((e=>{this.segmentChangeValue(l),e(l)})))}))))))})),W(this,"getElementSegments",((e,t)=>{var a;const{datasource:n,query:l,data:r}=this.props,i=this,s=l.isPiPoint?{type:"dataserver"}:{path:this.getSegmentPathUpTo(null!=t?t:this.state.segments.slice(0),e),afServerWebId:this.state.segments.length>0&&this.state.segments[0].value?this.state.segments[0].value.webId:void 0};if(!l.isPiPoint){var o,u,h;if((null===(o=n.afserver)||void 0===o?void 0:o.name)&&0===e)return Promise.resolve([{label:n.afserver.name,value:{value:n.afserver.name,expandable:!0}}]);if((null===(u=n.afserver)||void 0===u?void 0:u.name)&&(null===(h=n.afdatabase)||void 0===h?void 0:h.name)&&1===e)return Promise.resolve([{label:n.afdatabase.name,value:{value:n.afdatabase.name,expandable:!0}}])}var m;return n.metricFindQuery(s,Object.assign(null!==(m=null==r||null===(a=r.request)||void 0===a?void 0:a.scopedVars)&&void 0!==m?m:{},{isPiPoint:l.isPiPoint})).then((e=>{const t=(0,E.map)(e,(e=>({label:e.text,value:{webId:e.WebId,value:e.text,expandable:!l.isPiPoint&&e.expandable}})));if(0===t.length)return t;const a=n.templateSrv.getVariables();return(0,E.each)(a,(e=>{let a={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!l.isPiPoint}};t.unshift(a)})),t.unshift({label:k,value:{value:k}}),t})).catch((e=>(i.error=e.message||"Failed to issue metric query",[])))})),W(this,"getAttributeSegmentsPI",(e=>{var t;const{datasource:a,query:n,data:l}=this.props,r=this,i={path:"",webId:this.getSelectedPIServer(),pointName:(null!=e?e:"")+"*",type:"pipoint"};let s=[];var o;return a.metricFindQuery(i,Object.assign(null!==(o=null==l||null===(t=l.request)||void 0===t?void 0:t.scopedVars)&&void 0!==o?o:{},{isPiPoint:n.isPiPoint})).then((t=>{s=(0,E.map)(t,(e=>({path:e.Path,label:e.text,value:{value:e.text,expandable:!1}}))),e&&e.length>0&&s.unshift({label:e,value:{value:e,expandable:!1}});const l=a.templateSrv.getVariables();return(0,E.each)(l,(e=>{let t={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!n.isPiPoint}};s.unshift(t)})),s.unshift({label:k,value:{value:k}}),s})).catch((e=>(r.error=e.message||"Failed to issue metric query",s)))})),W(this,"getAttributeSegmentsAF",(e=>{let t=[];return t.push({label:k,value:{value:k}}),(0,E.forOwn)(this.availableAttributes,((e,a)=>{let n={label:a,value:{value:a,expandable:!0}};t.push(n)})),t})),W(this,"buildFromTarget",((e,t,a)=>{const n=e.target.split(";"),l=n.length>0?n[0].split("\\"):[];return l.length>1||1===l.length&&""!==l[0]?(n.splice(0,1),(0,E.each)(l,((e,a)=>{t.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,E.each)(n,((e,t)=>{""!==e&&a.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(l.length+1,t).then((e=>(console.log("EXPANDABLE 3",e),e.length>0&&t.push({label:"Select Element",value:{value:"-Select Element-"}}),t)))):Promise.resolve(t)})),W(this,"checkAfServer",(()=>{var e;const{datasource:t}=this.props,a=[];var n;return(null===(e=t.afserver)||void 0===e?void 0:e.name)?(a.push({label:t.afserver.name,value:{value:t.afserver.name,expandable:!0}}),(null===(n=t.afdatabase)||void 0===n?void 0:n.name)&&a.push({label:t.afdatabase.name,value:{value:t.afdatabase.name,expandable:!0}}),a.push({label:"Select Element",value:{value:"-Select Element-"}})):a.push({label:""}),a})),W(this,"updateArray",((e,t,a,n,l)=>{this.setState({segments:e,attributes:t,summaries:a,isPiPoint:n},(()=>{n||this.checkAttributeSegments(t,this.state.segments).then((()=>{l&&l()}))}))})),W(this,"scopedVarsDone",!1),W(this,"componentDidMount",(()=>{this.initialLoad(!1)})),W(this,"componentDidUpdate",(()=>{var e,t,a;const{query:n}=this.props;"Done"===(null===(e=this.props.data)||void 0===e?void 0:e.state)&&(null===(a=this.props.data)||void 0===a||null===(t=a.request)||void 0===t?void 0:t.scopedVars)&&!this.scopedVarsDone&&(this.scopedVarsDone=!0,this.initialLoad(!n.isPiPoint))})),W(this,"initialLoad",(e=>{const{query:t}=this.props,a=(0,E.defaults)(t,F),{segments:n,attributes:l,summary:r,isPiPoint:i}=a;var s;let o=e?[]:null!==(s=null==n?void 0:n.slice(0))&&void 0!==s?s:[];var u;let h=e?[]:null!==(u=null==l?void 0:l.slice(0))&&void 0!==u?u:[];var m;let c=null!==(m=null==r?void 0:r.types)&&void 0!==m?m:[];if(i||0!==o.length)i&&o.length>0&&(this.piServer=o);else{if(t.target&&t.target.length>0&&";"!==t.target)return h=[],void this.buildFromTarget(t,o,h).then((e=>{this.updateArray(e,h,c,!1)})).catch((e=>console.error(e)));o=this.checkAfServer()}this.updateArray(o,h,c,!!i,(()=>{this.onChange(t)}))})),W(this,"onChange",(e=>{const{onChange:t,onRunQuery:a}=this.props;var n,l;if(e.rawQuery){if(e.target=null!==(n=e.query)&&void 0!==n?n:"",e.query){const{attributes:t,elementPath:a}=function(e){const t=e.split(";"),a=t[0].split("\\");t.splice(0,1);let n=[];if(a.length>1||1===a.length&&""!==a[0]){const e=a.join("\\");return(0,E.each)(t,(function(e,t){""!==e&&n.push({label:e,value:{value:e,expandable:!1}})})),{attributes:n,elementPath:e}}return{attributes:n,elementPath:null}}(e.target);e.attributes=t,e.elementPath=a}}else e.elementPath=this.getSegmentPathUpTo(this.state.segments,this.state.segments.length),e.target=e.elementPath+";"+(0,E.join)(null===(l=e.attributes)||void 0===l?void 0:l.map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.value})),";");const r=e.summary;r&&(r.types=this.state.summaries),t(N(V({},e),{summary:r})),this.isValidQuery(e)&&a()})),W(this,"isValidQuery",(e=>{if(e.target&&e.target.length>0&&";"!==e.target){e.target=e.target.trim();const t=e.target.split(";",2);return 2===t.length&&t[0].length>0&&t[1].length>0}return!1})),W(this,"stateCallback",(()=>{const e=this.props.query;this.onChange(e)})),W(this,"onIsPiPointChange",(e=>{const{query:t}=this.props,a=!t.isPiPoint;this.setState({segments:a?[{label:""}]:this.checkAfServer(),attributes:[],isPiPoint:a},(()=>{this.onChange(N(V({},t),{expression:"",attributes:this.state.attributes,segments:this.state.segments,isPiPoint:a}))}))})),this.onSegmentChange=this.onSegmentChange.bind(this),this.calcBasisValueChanged=this.calcBasisValueChanged.bind(this),this.calcNoDataValueChanged=this.calcNoDataValueChanged.bind(this),this.onSummaryAction=this.onSummaryAction.bind(this),this.onSummaryValueChanged=this.onSummaryValueChanged.bind(this),this.onAttributeAction=this.onAttributeAction.bind(this),this.onAttributeChange=this.onAttributeChange.bind(this),this.summaryTypes=["Total","Average","Minimum","Maximum","Range","StdDev","PopulationStdDev","Count","PercentGood","All","AllForNonNumeric"],this.calculationBasis=["TimeWeighted","EventWeighted","TimeWeightedContinuous","TimeWeightedDiscrete","EventWeightedExcludeMostRecentEvent","EventWeightedExcludeEarliestEvent","EventWeightedIncludeBothEnds"],this.noDataReplacement=["Null","Drop","Previous","0","Keep"]}}var U=o(269),M=o(531);function Q(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function L(e){for(var t=1;t{const t=u.target;if(t&&t[e])return{label:t[e].Name,value:t[e]}};var S;return o.getAssetServer(o.afserver.name).then((e=>{v(e.WebId)})),c().createElement(c().Fragment,null,c().createElement("div",{className:"gf-form-group"},c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Database",labelWidth:$,grow:!0},c().createElement(d.AsyncSelect,{key:null!=g?g:"database-key",loadOptions:()=>o.getDatabases(g).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("database"),onChange:e=>{f(e.value),h(G(L({},s),{database:e.value,template:void 0}))},defaultOptions:!0})),c().createElement(d.InlineField,{label:"Event Frames",labelWidth:$,grow:!0},c().createElement(d.AsyncSelect,{key:null!==(S=null==y?void 0:y.WebId)&&void 0!==S?S:"default-template-key",loadOptions:()=>o.getEventFrameTemplates(null==y?void 0:y.WebId).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("template"),onChange:e=>h(G(L({},s),{template:e.value})),defaultOptions:!0})),c().createElement(d.InlineField,{label:"Show Start and End Time",labelWidth:$,grow:!0},c().createElement(d.InlineSwitch,{value:!!s.showEndTime,onChange:e=>h(G(L({},s),{showEndTime:e.currentTarget.checked}))}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Category name",labelWidth:$,grow:!0},c().createElement(d.Input,{type:"text",value:s.categoryName,onBlur:e=>p(),onChange:e=>h(G(L({},s),{categoryName:e.currentTarget.value})),placeholder:"Enter category name"})),c().createElement(d.InlineField,{label:"Name Filter",labelWidth:$,grow:!0},c().createElement(d.Input,{type:"text",value:s.nameFilter,onBlur:e=>p(),onChange:e=>h(G(L({},s),{nameFilter:e.currentTarget.value})),placeholder:"Enter name filter"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Enable Name Regex Replacement",labelWidth:$,grow:!1},c().createElement(d.InlineSwitch,{value:null===(a=s.regex)||void 0===a?void 0:a.enable,onChange:e=>h(G(L({},s),{regex:G(L({},s.regex),{enable:e.currentTarget.checked})}))})),c().createElement(d.InlineField,{label:"Name Filter",labelWidth:20,grow:!1},c().createElement(d.Input,{type:"text",value:null===(n=s.regex)||void 0===n?void 0:n.search,onBlur:e=>p(),onChange:e=>h(G(L({},s),{regex:G(L({},s.regex),{search:e.currentTarget.value})})),placeholder:"(.*)",width:50})),c().createElement(d.InlineField,{label:"Replace",labelWidth:20,grow:!0},c().createElement(d.Input,{type:"text",value:null==s||null===(l=s.regex)||void 0===l?void 0:l.replace,onBlur:e=>p(),onChange:e=>h(G(L({},s),{regex:G(L({},s.regex),{replace:e.currentTarget.value})})),placeholder:"$1"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Enable Attribute Usage",labelWidth:$,grow:!1},c().createElement(d.InlineSwitch,{value:null===(r=s.attribute)||void 0===r?void 0:r.enable,onChange:e=>h(G(L({},s),{attribute:G(L({},s.attribute),{enable:e.currentTarget.checked})}))})),c().createElement(d.InlineField,{label:"Attribute Name",labelWidth:$,grow:!0},c().createElement(d.Input,{type:"text",value:null===(i=s.attribute)||void 0===i?void 0:i.name,onBlur:e=>p(),onChange:e=>h(G(L({},s),{attribute:G(L({},s.attribute),{name:e.currentTarget.value})})),placeholder:"Enter name"})))))}));function _(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function Y(e){for(var t=1;te.substring(1,e.length-2).split(",")[0]))),e.filter=null!==(l=e.filter)&&void 0!==l?l:"*",e.max=null!==(r=e.max)&&void 0!==r?r:1e4,"servers"===e.type?(null===(i=a.afserver)||void 0===i?void 0:i.name)?a.getAssetServer(a.afserver.name).then((e=>[e])).then(A):a.getAssetServers().then(A):"databases"===e.type&&e.afServerWebId?a.getDatabases(e.afServerWebId,{}).then(A):"databases"===e.type?a.getAssetServer(e.path).then((e=>{var t;return a.getDatabases(null!==(t=e.WebId)&&void 0!==t?t:"",{})})).then(A):"databaseElements"===e.type?a.getDatabase(e.path).then((e=>{var t;return a.getDatabaseElements(null!==(t=e.WebId)&&void 0!==t?t:"",{selectedFields:"Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren"})})).then(A):"elements"===e.type?a.getElement(e.path).then((t=>{var n;return a.getElements(null!==(n=t.WebId)&&void 0!==n?n:"",{selectedFields:"Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren",nameFilter:e.filter})})).then(A):"attributes"===e.type?a.getElement(e.path).then((t=>{var n;return a.getAttributes(null!==(n=t.WebId)&&void 0!==n?n:"",{searchFullHierarchy:"true",selectedFields:"Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path",nameFilter:e.filter,maxCount:e.max})})).then(A):"dataserver"===e.type?a.getDataServers().then(A):"pipoint"===e.type?a.piPointSearch(e.webId,e.pointName).then(A):Promise.reject("Bad type")}buildQueryParameters(e){return e.targets=(0,E.filter)(e.targets,(e=>{var t;return!(!e||!e.target||0===(null===(t=e.attributes)||void 0===t?void 0:t.length)||";"===e.target||e.hide||e.target.startsWith("Select AF"))})),e.maxDataPoints&&(e.maxDataPoints=e.maxDataPoints>3e4?3e4:e.maxDataPoints),e.targets=(0,E.map)(e.targets,(t=>{var a;const n={enableStreaming:t.enableStreaming,target:this.templateSrv.replace(t.target,e.scopedVars),elementPath:this.templateSrv.replace(t.elementPath,e.scopedVars),attributes:(0,E.map)(t.attributes,(t=>(t.value&&this.templateSrv.replace(t.value.value,e.scopedVars),t))),segments:(0,E.map)(t.segments,(t=>(t.value&&this.templateSrv.replace(t.value.value,e.scopedVars),t))),isAnnotation:!!t.isAnnotation,display:t.display?this.templateSrv.replace(t.display,e.scopedVars):void 0,refId:t.refId,hide:t.hide,interpolate:t.interpolate?J(Y({},t.interpolate),{interval:this.templateSrv.replace(t.interpolate.interval,e.scopedVars)}):{enable:!1},useLastValue:t.useLastValue||{enable:!1},useUnit:t.useUnit||{enable:!1},recordedValues:t.recordedValues?J(Y({},t.recordedValues),{interval:this.templateSrv.replace(t.recordedValues.maxNumber,e.scopedVars)}):{enable:!1},digitalStates:t.digitalStates||{enable:!1},webid:null!==(a=t.webid)&&void 0!==a?a:"",regex:t.regex||{enable:!1},expression:t.expression||"",summary:t.summary||{types:[]},startTime:e.range.from,endTime:e.range.to,isPiPoint:!!t.isPiPoint,scopedVars:e.scopedVars};return n.expression&&(n.expression=this.templateSrv.replace(n.expression,e.scopedVars)),void 0!==n.summary.types&&(n.summary.types=(0,E.filter)(n.summary.types,(e=>null!=e&&""!==e))),n})),e}eventFrameToAnnotation(e,t){const a=e.target,n=[],l=Intl.DateTimeFormat().resolvedOptions().locale;return t.forEach((e=>{let t=this.transformDataFrameToMap(e);for(let e=0;eStart: "+new Date(t.time[e]).toLocaleString(l)+"
End: ",t.timeEnd[e]?i+=new Date(t.timeEnd[e]).toLocaleString(l):i+="Eventframe is open";const s={time:t.time[e],timeEnd:a.showEndTime?t.timeEnd[e]:void 0,title:r,id:t.id[e],text:i,tags:["OSISoft PI"]};n.push(s)}})),n}transformDataFrameToMap(e){const t={};return e.fields.forEach((e=>{t[e.name]=e.values.toArray()})),t}restGet(e){const t=this.backendSrv.fetch({url:`/api/datasources/${this.id}/resources${e}`,method:"GET",headers:{"Content-Type":"application/json"}});return(0,U.firstValueFrom)(t).then((e=>e))}getDataServers(){return this.restGet("/dataservers").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getDataServer(e){return e?this.restGet("/dataservers?name="+e).then((e=>e.data)):Promise.resolve({})}getAssetServers(){return this.restGet("/assetservers").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getAssetServer(e){return e?this.restGet("/assetservers?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getDatabase(e){return e?this.restGet("/assetdatabases?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getDatabases(e,t){return e?this.restGet("/assetservers/"+e+"/assetdatabases").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]})):Promise.resolve([])}getElement(e){return e?this.restGet("/elements?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getEventFrameTemplates(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((e=>{var t;return(0,E.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(e=>"EventFrame"===e.InstanceType))})):Promise.resolve([])}getElementTemplates(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((e=>{var t;return(0,E.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(e=>"Element"===e.InstanceType))})):Promise.resolve([])}getAttributes(e,t){let a="?"+(0,E.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/elements/"+e+"/attributes"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getDatabaseElements(e,t){let a="?"+(0,E.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/assetdatabases/"+e+"/elements"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getElements(e,t){let a="?"+(0,E.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/elements/"+e+"/elements"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}piPointSearch(e,t){let a=this.templateSrv.replace(t),n=`${a}`,l=!1;if(a!==t){const e=RegExp("\\{(\\w|,)+\\}","gs");let t;for(;null!==(t=e.exec(a));)t.index===e.lastIndex&&e.lastIndex++,t.forEach(((e,t)=>{0===t&&(a=a.replace(e,e.replace("{","(").replace("}",")").replace(",","|")),n=n.replace(e,"*"),l=!0)}))}return this.restGet("/dataservers/"+e+"/points?maxCount=50&nameFilter="+n).then((e=>{var t;return e&&(null===(t=e.data)||void 0===t?void 0:t.Items)?l?e.data.Items.filter((e=>{var t;return null===(t=e.Name)||void 0===t?void 0:t.match(a)})):e.data.Items:[]}))}constructor(e,t=(0,M.getTemplateSrv)(),a=(0,M.getBackendSrv)()){super(e),_(this,"templateSrv",void 0),_(this,"backendSrv",void 0),_(this,"piserver",void 0),_(this,"afserver",void 0),_(this,"afdatabase",void 0),_(this,"piPointConfig",void 0),_(this,"newFormatConfig",void 0),_(this,"useUnitConfig",void 0),_(this,"useExperimental",void 0),_(this,"useStreaming",void 0),this.templateSrv=t,this.backendSrv=a,this.piserver={name:(e.jsonData||{}).piserver,webid:void 0},this.afserver={name:(e.jsonData||{}).afserver,webid:void 0},this.afdatabase={name:(e.jsonData||{}).afdatabase,webid:void 0},this.piPointConfig=e.jsonData.pipoint||!1,this.newFormatConfig=e.jsonData.newFormat||!1,this.useUnitConfig=e.jsonData.useUnit||!1,this.useExperimental=e.jsonData.useExperimental||!1,this.useStreaming=e.jsonData.useStreaming||!1,this.annotations={QueryEditor:H,prepareQuery:e=>(e.target&&(e.target.queryType="Annotation",e.target.isAnnotation=!0),e.target),processEvents:(e,t)=>(0,U.of)(this.eventFrameToAnnotation(e,t))},Promise.all([this.getDataServer(this.piserver.name).then((e=>this.piserver.webid=e.WebId)),this.getAssetServer(this.afserver.name).then((e=>this.afserver.webid=e.WebId)),this.getDatabase(this.afserver.name&&this.afdatabase.name?this.afserver.name+"\\"+this.afdatabase.name:void 0).then((e=>this.afdatabase.webid=e.WebId))])}}const X=new h.DataSourcePlugin(K).setQueryEditor(R).setConfigEditor(f);return u})())); +define(["@grafana/data","react","@grafana/ui","lodash","rxjs","@grafana/runtime"],((e,t,a,n,l,r)=>(()=>{"use strict";var i={781:t=>{t.exports=e},531:e=>{e.exports=r},7:e=>{e.exports=a},241:e=>{e.exports=n},959:e=>{e.exports=t},269:e=>{e.exports=l}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return i[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};o.r(u),o.d(u,{plugin:()=>z});var h=o(781),m=o(959),c=o.n(m),d=o(7);function p(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function g(e){for(var t=1;tv(g({},e),{jsonData:v(g({},e.jsonData),{url:e.url})});class f extends m.PureComponent{render(){const{options:e}=this.props,t=y(e);return c().createElement("div",null,c().createElement(d.DataSourceHttpSettings,{defaultUrl:"https://server.name/piwebapi",dataSourceConfig:t,onChange:this.onHttpOptionsChange,showAccessOptions:!0}),c().createElement("h3",{className:"page-heading"},"Custom Configuration"),c().createElement("div",{className:"gf-form-group"},c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable PI Points in Query",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.pipoint,onChange:this.onPiPointChange}))),c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable New Data Format",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.newFormat,onChange:this.onNewFormatChange}))),c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable Unit in Data",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.useUnit,onChange:this.onUseUnitChange}))),c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable Experimental Features",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.useExperimental,onChange:this.onUseExperimentalChange}))),t.jsonData.useExperimental&&c().createElement("div",{className:"gf-form-inline"},c().createElement(d.InlineField,{label:"Enable Steaming Support",labelWidth:24},c().createElement(d.InlineSwitch,{value:t.jsonData.useStreaming,onChange:this.onUseStreamingChange})))),c().createElement("h3",{className:"page-heading"},"PI/AF Connection Details"),c().createElement("div",{className:"gf-form-group"},t.jsonData.pipoint&&c().createElement("div",{className:"gf-form"},c().createElement(b,{label:"PI Server",labelWidth:10,inputWidth:25,onChange:this.onPIServerChange,value:t.jsonData.piserver||"",placeholder:"Default PI Server to use for data requests"})),c().createElement("div",{className:"gf-form"},c().createElement(b,{label:"AF Server",labelWidth:10,inputWidth:25,onChange:this.onAFServerChange,value:t.jsonData.afserver||"",placeholder:"Default AF Server to use for data requests"})),c().createElement("div",{className:"gf-form"},c().createElement(b,{label:"AF Database",labelWidth:10,inputWidth:25,onChange:this.onAFDatabaseChange,value:t.jsonData.afdatabase||"",placeholder:"Default AF Database server for AF queries"}))))}constructor(...e){super(...e),p(this,"onPIServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{piserver:e.target.value});t(v(g({},a),{jsonData:n}))})),p(this,"onAFServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{afserver:e.target.value});t(v(g({},a),{jsonData:n}))})),p(this,"onAFDatabaseChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{afdatabase:e.target.value});t(v(g({},a),{jsonData:n}))})),p(this,"onHttpOptionsChange",(e=>{const{onOptionsChange:t}=this.props;t(y(e))})),p(this,"onPiPointChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{piserver:e.target.checked?a.jsonData.piserver:"",pipoint:e.target.checked});t(v(g({},a),{jsonData:n}))})),p(this,"onNewFormatChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{newFormat:e.target.checked});t(v(g({},a),{jsonData:n}))})),p(this,"onUseUnitChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{useUnit:e.target.checked});t(v(g({},a),{jsonData:n}))})),p(this,"onUseExperimentalChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{useExperimental:e.target.checked,useStreaming:!!e.target.checked&&a.jsonData.useStreaming});t(v(g({},a),{jsonData:n}))})),p(this,"onUseStreamingChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=v(g({},a.jsonData),{useStreaming:e.target.checked});t(v(g({},a),{jsonData:n}))}))}}var E=o(241);function S(){return S=Object.assign||function(e){for(var t=1;tc().createElement(c().Fragment,null,c().createElement(d.InlineFormLabel,{width:t,tooltip:a},e),n),I=()=>c().createElement("div",{className:"gf-form gf-form--grow"},c().createElement("div",{className:"gf-form-label gf-form-label--grow"})),w=e=>{var t=S({},P(e));return c().createElement(O,null,c().createElement(C,t))},O=e=>c().createElement("div",{className:"gf-form-inline"},e.children,c().createElement(I,null)),x=e=>{var t=S({},P(e));return c().createElement(D,null,c().createElement(C,t))},D=e=>c().createElement(c().Fragment,null,e.children),F={target:";",attributes:[],segments:[],regex:{enable:!1},summary:{types:[],basis:"EventWeighted",interval:"",nodata:"Null"},expression:"",interpolate:{enable:!1},useLastValue:{enable:!1},recordedValues:{enable:!1},digitalStates:{enable:!1},enableStreaming:{enable:!1},useUnit:{enable:!1},isPiPoint:!1},j=({isRaw:e,onChange:t})=>{const[a,n]=(0,m.useState)(!1);return(0,m.useEffect)((()=>{n(!1)}),[e]),e?c().createElement(c().Fragment,null,c().createElement(d.Button,{"aria-label":"Switch to visual editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{n(!0)}}),c().createElement(d.ConfirmModal,{isOpen:a,title:"Switch to visual editor mode",body:"Are you sure to switch to visual editor mode? You will lose the changes done in raw query mode.",confirmText:"Yes, switch to editor mode",dismissText:"No, stay in raw query mode",onConfirm:()=>{t(!1)},onDismiss:()=>{n(!1)}})):c().createElement(d.Button,{"aria-label":"Switch to text editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{t(!0)}})};function A(e){return(0,E.map)(e,(e=>{var t,a;return{text:e.Name,expandable:void 0===e.HasChildren||!0===e.HasChildren||(null!==(t=e.Path)&&void 0!==t?t:"").split("\\").length<=3,HasChildren:e.HasChildren,Items:null!==(a=e.Items)&&void 0!==a?a:[],Path:e.Path,WebId:e.WebId}}))}function W(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function V(e){for(var t=1;t{var t;return e.value?c().createElement("div",{className:"gf-form-label "+("template"===e.value.type?"query-keyword":"")},null!==(t=e.label)&&void 0!==t?t:"--no label--"):c().createElement("a",{className:"gf-form-label query-part"},c().createElement(d.Icon,{name:"plus"}))};class R extends m.PureComponent{isValueEmpty(e){return!e||!e.value||!e.value.length||e.value===B}calcBasisValueChanged(e){const t=this.props.query,a=t.summary;var n;a&&(a.basis=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(N(V({},t),{summary:a}))}getCalcBasisSegments(){return(0,E.map)(this.calculationBasis,(e=>({label:e,value:{value:e,expandable:!0}})))}calcNoDataValueChanged(e){const t=this.props.query,a=t.summary;var n;a&&(a.nodata=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(N(V({},t),{summary:a}))}getNoDataSegments(){return(0,E.map)(this.noDataReplacement,(e=>({label:e,value:{value:e,expandable:!0}})))}onSummaryValueChanged(e,t){const a=this.state.summaries.slice(0);a[t]=e,this.isValueEmpty(e.value)&&a.splice(t,1),this.setState({summaries:a},this.stateCallback)}getSummarySegments(){const e=(0,E.filter)(this.summaryTypes,(e=>-1===this.state.summaries.map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.value})).indexOf(e))),t=(0,E.map)(e,(e=>({label:e,value:{value:e,expandable:!0}})));return t.unshift({label:B,value:{value:B}}),t}removeSummary(e){const t=(0,E.filter)(this.state.summaries,(t=>t!==e));this.setState({summaries:t})}onSummaryAction(e){const t=this.state.summaries.slice(0);if(!this.isValueEmpty(e.value)){var a;let n={label:e.label,value:{value:null===(a=e.value)||void 0===a?void 0:a.value,expandable:!0}};t.push(n)}this.setState({summarySegment:{},summaries:t},this.stateCallback)}removeAttribute(e){const t=(0,E.filter)(this.state.attributes,(t=>t!==e));this.attributeChangeValue(t)}onAttributeAction(e){const{query:t}=this.props,a=this.state.attributes.slice(0);if(!this.isValueEmpty(e.value)){var n;let l={label:e.label,value:{value:null===(n=e.value)||void 0===n?void 0:n.value,expandable:!t.isPiPoint}};a.push(l)}this.attributeChangeValue(a)}getSegmentPathUpTo(e,t){const a=e.slice(0,t);return(0,E.reduce)(a,((e,t)=>{var a;return t.value?(null===(a=t.value.value)||void 0===a?void 0:a.startsWith("-Select"))?e:e?e+"\\"+t.value.value:t.value.value:""}),"")}checkAttributeSegments(e,t){var a;const{datasource:n,data:l}=this.props,r=this,i={path:this.getSegmentPathUpTo(t.slice(0),t.length),type:"attributes"};var s;return n.metricFindQuery(i,Object.assign(null!==(s=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==s?s:{},{isPiPoint:!1})).then((t=>{const a={};(0,E.each)(t,(e=>{a[e.Path.substring(e.Path.indexOf("|")+1)]=e.WebId}));const l=(0,E.filter)(e,(e=>{var t;const l=n.templateSrv.replace(null===(t=e.value)||void 0===t?void 0:t.value);return void 0!==a[l]}));return r.availableAttributes=a,this.attributeChangeValue(l)})).catch((t=>(r.error=t.message||"Failed to issue metric query",this.attributeChangeValue(e))))}checkPiPointSegments(e,t){var a;const{datasource:n,data:l}=this.props,r=this,i={path:e.path,webId:r.getSelectedPIServer(),pointName:e.label,type:"pipoint"};var s;return n.metricFindQuery(i,Object.assign(null!==(s=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==s?s:{},{isPiPoint:!0})).then((()=>r.attributeChangeValue(t))).catch((e=>(r.error=e.message||"Failed to issue metric query",r.attributeChangeValue([]))))}getSelectedPIServer(){var e;let t="";return this.piServer.forEach((e=>{const a=this.props.query.target.split(";");a.length>=2&&a[0]===e.text&&(t=e.WebId)})),this.piServer.length>0?null===(e=this.piServer[0].value)||void 0===e?void 0:e.webId:t}textEditorChanged(){const{query:e}=this.props,t=e.target.split(";"),a=t.length>0?t[0].split("\\"):[];let n=[],l=[];a.length>1||1===a.length&&""!==a[0]?(t.splice(0,1),(0,E.each)(a,((e,t)=>{n.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,E.each)(t,(function(e,t){""!==e&&l.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(a.length+1,n).then((e=>{e.length>0&&n.push({label:"Select Element",value:{value:"-Select Element-"}})})).then((()=>{this.updateArray(n,l,this.state.summaries,e.isPiPoint,(()=>{this.onChange(N(V({},e),{query:void 0,rawQuery:!1,attributes:this.state.attributes,segments:this.state.segments}))}))}))):(n=this.checkAfServer(),this.updateArray(n,this.state.attributes,this.state.summaries,e.isPiPoint,(()=>{this.onChange(N(V({},e),{query:void 0,rawQuery:!1,attributes:this.state.attributes,segments:this.state.segments}))})))}render(){const{query:e,onChange:t,onRunQuery:a}=this.props,n=(0,E.defaults)(e,F),{useLastValue:l,useUnit:r,interpolate:i,query:s,rawQuery:o,digitalStates:u,enableStreaming:h,recordedValues:m,expression:p,isPiPoint:g,summary:v,display:b,regex:y}=n;return c().createElement(c().Fragment,null,this.props.datasource.piPointConfig&&c().createElement(d.InlineField,{label:"Is Pi Point?",labelWidth:T},c().createElement(d.InlineSwitch,{value:g,onChange:this.onIsPiPointChange})),!!o&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Raw Query",labelWidth:T,grow:!0},c().createElement(d.Input,{onBlur:this.stateCallback,value:s,onChange:e=>t(N(V({},n),{query:e.target.value})),placeholder:"enter query"})),c().createElement(j,{isRaw:!0,onChange:e=>this.textEditorChanged()})),!o&&c().createElement(c().Fragment,null,c().createElement("div",{className:"gf-form-inline"},c().createElement(x,{label:g?"PI Server":"AF Elements",tooltip:g?"Select PI server.":"Select AF Element."},this.state.segments.map(((e,t)=>c().createElement(d.SegmentAsync,{key:"element-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),onChange:e=>this.onSegmentChange(e,t),loadOptions:e=>this.getElementSegments(t),allowCustomValue:!0,inputMinWidth:200}))),c().createElement(I,null),!g&&c().createElement(j,{isRaw:!1,onChange:e=>{t(N(V({},n),{query:n.target,rawQuery:e}))}}))),c().createElement(w,{label:g?"Pi Points":"Attributes"},this.state.attributes.map(((e,t)=>g?c().createElement(d.SegmentAsync,{key:"attributes-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),disabled:0===this.piServer.length,onChange:e=>this.onPiPointChange(e,t),loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:k}):c().createElement(d.Segment,{key:"attributes-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),disabled:this.state.segments.length<=2,onChange:e=>this.onAttributeChange(e,t),options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:k}))),g&&c().createElement(d.SegmentAsync,{Component:c().createElement(q,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:0===this.piServer.length,onChange:this.onAttributeAction,loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:k}),!g&&c().createElement(d.Segment,{Component:c().createElement(q,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:this.state.segments.length<=2,onChange:this.onAttributeAction,options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:k}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Calculation",grow:!0,labelWidth:T,tooltip:"Modify all attributes by an equation. Use '.' for current item. Leave Attributes empty if you wish to perform element based calculations."},c().createElement(d.Input,{onBlur:a,value:p,onChange:e=>t(N(V({},n),{expression:e.target.value})),placeholder:"'.'*2"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Use Last Value",tooltip:"Fetch only last value from time range",labelWidth:T},c().createElement(d.InlineSwitch,{value:l.enable,onChange:()=>this.onChange(N(V({},n),{useLastValue:N(V({},l),{enable:!l.enable})}))})),c().createElement(d.InlineField,{label:"Digital States",labelWidth:T},c().createElement(d.InlineSwitch,{value:u.enable,onChange:()=>this.onChange(N(V({},n),{digitalStates:N(V({},u),{enable:!u.enable})}))})),c().createElement(d.InlineField,{label:"Replace Bad Data",labelWidth:T,tooltip:"Replacement for bad quality values."},c().createElement(d.Segment,{Component:c().createElement(q,{value:{value:null==v?void 0:v.nodata},label:null==v?void 0:v.nodata}),onChange:this.calcNoDataValueChanged,options:this.getNoDataSegments(),allowCustomValue:!0})),this.props.datasource.useUnitConfig&&c().createElement(d.InlineField,{label:"Use unit from datapoints",tooltip:"Use unit in label from PI tag or PI AF attribute",labelWidth:T},c().createElement(d.InlineSwitch,{value:r.enable,onChange:()=>this.onChange(N(V({},n),{useUnit:N(V({},r),{enable:!r.enable})}))})),this.props.datasource.useStreaming&&c().createElement(d.InlineField,{label:"Enable Streaming",labelWidth:T,tooltip:"Enable streaming data if it is supported for the point type."},c().createElement(d.InlineSwitch,{value:h.enable,onChange:()=>this.onChange(N(V({},n),{enableStreaming:N(V({},h),{enable:!h.enable})}))}))),c().createElement(d.InlineFieldRow,null,!l.enable&&c().createElement(d.InlineField,{label:"Max Recorded Values",labelWidth:T,tooltip:"Maximum number of recorded value to retrive from the data archive, without using interpolation."},c().createElement(d.Input,{onBlur:a,value:m.maxNumber,onChange:e=>t(N(V({},n),{recordedValues:N(V({},m),{maxNumber:parseInt(e.target.value,10)})})),type:"number",placeholder:"1000"})),c().createElement(d.InlineField,{label:"Recorded Values",labelWidth:T},c().createElement(d.InlineSwitch,{value:m.enable,onChange:()=>this.onChange(N(V({},n),{recordedValues:N(V({},m),{enable:!m.enable})}))}))),!l.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:p?"Interval Period":"Interpolate Period",labelWidth:T,tooltip:"Override time between sampling, e.g. '30s'. Defaults to timespan/chart width."},c().createElement(d.Input,{onBlur:a,value:i.interval,onChange:e=>t(N(V({},n),{interpolate:N(V({},i),{interval:e.target.value})})),placeholder:"30s"})),c().createElement(d.InlineField,{label:p?"Interval Values":"Interpolate",labelWidth:T},c().createElement(d.InlineSwitch,{value:i.enable,onChange:()=>this.onChange(N(V({},n),{interpolate:N(V({},i),{enable:!i.enable})}))}))),!l.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Summary Period",labelWidth:T,tooltip:"Define the summary period, e.g. '30s'."},c().createElement(d.Input,{onBlur:a,value:null==v?void 0:v.interval,onChange:e=>t(N(V({},n),{summary:N(V({},v),{interval:e.target.value})})),placeholder:"30s"})),c().createElement(d.InlineField,{label:"Basis",labelWidth:T,tooltip:"Defines the possible calculation options when performing summary calculations over time-series data."},c().createElement(d.Segment,{Component:c().createElement(q,{value:{value:null==v?void 0:v.basis},label:null==v?void 0:v.basis}),onChange:this.calcBasisValueChanged,options:this.getCalcBasisSegments(),allowCustomValue:!0})),c().createElement(d.InlineField,{label:"Summaries",labelWidth:T,tooltip:"PI Web API summary options."},c().createElement(d.InlineFieldRow,null,this.state.summaries.map(((e,t)=>c().createElement(d.Segment,{key:"summaries-"+t,Component:c().createElement(q,{value:e.value,label:e.label}),onChange:e=>this.onSummaryValueChanged(e,t),options:this.getSummarySegments(),allowCustomValue:!0}))),c().createElement(d.Segment,{Component:c().createElement(q,{value:this.state.summarySegment.value,label:this.state.summarySegment.label}),onChange:this.onSummaryAction,options:this.getSummarySegments(),allowCustomValue:!0})))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Display Name",labelWidth:T,tooltip:"If single attribute, modify display name. Otherwise use regex to modify display name."},c().createElement(d.Input,{onBlur:a,value:b,onChange:e=>t(N(V({},n),{display:e.target.value})),placeholder:"Display"})),c().createElement(d.InlineField,{label:"Enable Regex Replace",labelWidth:T},c().createElement(d.InlineSwitch,{value:y.enable,onChange:()=>{this.onChange(N(V({},n),{regex:N(V({},y),{enable:!y.enable})}))}})),c().createElement(d.InlineField,{label:"Search",labelWidth:16},c().createElement(d.Input,{onBlur:a,value:y.search,onChange:e=>t(N(V({},n),{regex:N(V({},y),{search:e.target.value})})),placeholder:"(.*)"})),c().createElement(d.InlineField,{label:"Replace",labelWidth:16},c().createElement(d.Input,{onBlur:a,value:y.replace,onChange:e=>t(N(V({},n),{regex:N(V({},y),{replace:e.target.value})})),placeholder:"$1"}))))}constructor(e){super(e),W(this,"error",void 0),W(this,"piServer",[]),W(this,"availableAttributes",{}),W(this,"summaryTypes",void 0),W(this,"calculationBasis",void 0),W(this,"noDataReplacement",void 0),W(this,"state",{isPiPoint:!1,segments:[],attributes:[],summaries:[],attributeSegment:{},summarySegment:{},calculationBasisSegment:{},noDataReplacementSegment:{}}),W(this,"segmentChangeValue",(e=>{const t=this.props.query;this.setState({segments:e},(()=>this.onChange(N(V({},t),{segments:e}))))})),W(this,"attributeChangeValue",(e=>{const t=this.props.query;return new Promise((a=>this.setState({attributes:e},(()=>{this.onChange(N(V({},t),{attributes:e})),a()}))))})),W(this,"onPiPointChange",((e,t)=>{let a=this.state.attributes.slice(0);e.label===B?(0,E.remove)(a,((e,a)=>a===t)):a[t]=e,this.checkPiPointSegments(e,a)})),W(this,"onAttributeChange",((e,t)=>{var a;let n=this.state.attributes.slice(0);n[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&(n[t]=e,this.checkAttributeSegments(n,this.state.segments))})),W(this,"onSegmentChange",((e,t)=>{var a;const{query:n}=this.props;let l=this.state.segments.slice(0);l[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&this.setState({attributes:[]},(()=>e.label===B?(l=(0,E.slice)(l,0,t),void this.checkAttributeSegments([],l).then((()=>{var e;0===l.length?l.push({label:""}):(null===(e=l[l.length-1].value)||void 0===e?void 0:e.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),n.isPiPoint&&(this.piServer=[]),this.segmentChangeValue(l)}))):(l[t]=e,n.isPiPoint?(this.piServer.push(e),void this.segmentChangeValue(l)):(t{var t,a;return"template"===(null===(t=e.value)||void 0===t?void 0:t.type)?this.getElementSegments(l.length+1,l).then((e=>(e.length>0&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),this.segmentChangeValue(l),l))):((null===(a=e.value)||void 0===a?void 0:a.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),new Promise((e=>{this.segmentChangeValue(l),e(l)})))}))))))})),W(this,"getElementSegments",((e,t)=>{var a;const{datasource:n,query:l,data:r}=this.props,i=this,s=l.isPiPoint?{type:"dataserver"}:{path:this.getSegmentPathUpTo(null!=t?t:this.state.segments.slice(0),e),afServerWebId:this.state.segments.length>0&&this.state.segments[0].value?this.state.segments[0].value.webId:void 0};if(!l.isPiPoint){var o,u,h;if((null===(o=n.afserver)||void 0===o?void 0:o.name)&&0===e)return Promise.resolve([{label:n.afserver.name,value:{value:n.afserver.name,expandable:!0}}]);if((null===(u=n.afserver)||void 0===u?void 0:u.name)&&(null===(h=n.afdatabase)||void 0===h?void 0:h.name)&&1===e)return Promise.resolve([{label:n.afdatabase.name,value:{value:n.afdatabase.name,expandable:!0}}])}var m;return n.metricFindQuery(s,Object.assign(null!==(m=null==r||null===(a=r.request)||void 0===a?void 0:a.scopedVars)&&void 0!==m?m:{},{isPiPoint:l.isPiPoint})).then((e=>{const t=(0,E.map)(e,(e=>({label:e.text,value:{webId:e.WebId,value:e.text,expandable:!l.isPiPoint&&e.expandable}})));if(0===t.length)return t;const a=n.templateSrv.getVariables();return(0,E.each)(a,(e=>{let a={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!l.isPiPoint}};t.unshift(a)})),t.unshift({label:B,value:{value:B}}),t})).catch((e=>(i.error=e.message||"Failed to issue metric query",[])))})),W(this,"getAttributeSegmentsPI",(e=>{var t;const{datasource:a,query:n,data:l}=this.props,r=this,i={path:"",webId:this.getSelectedPIServer(),pointName:(null!=e?e:"")+"*",type:"pipoint"};let s=[];var o;return a.metricFindQuery(i,Object.assign(null!==(o=null==l||null===(t=l.request)||void 0===t?void 0:t.scopedVars)&&void 0!==o?o:{},{isPiPoint:n.isPiPoint})).then((t=>{s=(0,E.map)(t,(e=>({path:e.Path,label:e.text,value:{value:e.text,expandable:!1}}))),e&&e.length>0&&s.unshift({label:e,value:{value:e,expandable:!1}});const l=a.templateSrv.getVariables();return(0,E.each)(l,(e=>{let t={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!n.isPiPoint}};s.unshift(t)})),s.unshift({label:B,value:{value:B}}),s})).catch((e=>(r.error=e.message||"Failed to issue metric query",s)))})),W(this,"getAttributeSegmentsAF",(e=>{let t=[];return t.push({label:B,value:{value:B}}),(0,E.forOwn)(this.availableAttributes,((e,a)=>{let n={label:a,value:{value:a,expandable:!0}};t.push(n)})),t})),W(this,"buildFromTarget",((e,t,a)=>{const n=e.target.split(";"),l=n.length>0?n[0].split("\\"):[];return l.length>1||1===l.length&&""!==l[0]?(n.splice(0,1),(0,E.each)(l,((e,a)=>{t.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,E.each)(n,((e,t)=>{""!==e&&a.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(l.length+1,t).then((e=>(e.length>0&&t.push({label:"Select Element",value:{value:"-Select Element-"}}),t)))):Promise.resolve(t)})),W(this,"checkAfServer",(()=>{var e;const{datasource:t}=this.props,a=[];var n;return(null===(e=t.afserver)||void 0===e?void 0:e.name)?(a.push({label:t.afserver.name,value:{value:t.afserver.name,expandable:!0}}),(null===(n=t.afdatabase)||void 0===n?void 0:n.name)&&a.push({label:t.afdatabase.name,value:{value:t.afdatabase.name,expandable:!0}}),a.push({label:"Select Element",value:{value:"-Select Element-"}})):a.push({label:""}),a})),W(this,"updateArray",((e,t,a,n,l)=>{this.setState({segments:e,attributes:t,summaries:a,isPiPoint:n},(()=>{n||this.checkAttributeSegments(t,this.state.segments).then((()=>{l&&l()}))}))})),W(this,"scopedVarsDone",!1),W(this,"componentDidMount",(()=>{this.initialLoad(!1)})),W(this,"componentDidUpdate",(()=>{var e,t,a;const{query:n}=this.props;"Done"===(null===(e=this.props.data)||void 0===e?void 0:e.state)&&(null===(a=this.props.data)||void 0===a||null===(t=a.request)||void 0===t?void 0:t.scopedVars)&&!this.scopedVarsDone&&(this.scopedVarsDone=!0,this.initialLoad(!n.isPiPoint))})),W(this,"initialLoad",(e=>{const{query:t}=this.props,a=(0,E.defaults)(t,F),{segments:n,attributes:l,summary:r,isPiPoint:i}=a;var s;let o=e?[]:null!==(s=null==n?void 0:n.slice(0))&&void 0!==s?s:[];var u;let h=e?[]:null!==(u=null==l?void 0:l.slice(0))&&void 0!==u?u:[];var m;let c=null!==(m=null==r?void 0:r.types)&&void 0!==m?m:[];if(i||0!==o.length)i&&o.length>0&&(this.piServer=o);else{if(t.target&&t.target.length>0&&";"!==t.target)return h=[],void this.buildFromTarget(t,o,h).then((e=>{this.updateArray(e,h,c,!1)})).catch((e=>console.error(e)));o=this.checkAfServer()}this.updateArray(o,h,c,!!i,(()=>{this.onChange(t)}))})),W(this,"onChange",(e=>{const{onChange:t,onRunQuery:a}=this.props;var n,l;if(e.rawQuery){if(e.target=null!==(n=e.query)&&void 0!==n?n:"",e.query){const{attributes:t,elementPath:a}=function(e){const t=e.split(";"),a=t[0].split("\\");t.splice(0,1);let n=[];if(a.length>1||1===a.length&&""!==a[0]){const e=a.join("\\");return(0,E.each)(t,(function(e,t){""!==e&&n.push({label:e,value:{value:e,expandable:!1}})})),{attributes:n,elementPath:e}}return{attributes:n,elementPath:null}}(e.target);e.attributes=t,e.elementPath=a}}else e.elementPath=this.getSegmentPathUpTo(this.state.segments,this.state.segments.length),e.target=e.elementPath+";"+(0,E.join)(null===(l=e.attributes)||void 0===l?void 0:l.map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.value})),";");const r=e.summary;r&&(r.types=this.state.summaries),t(N(V({},e),{summary:r})),this.isValidQuery(e)&&a()})),W(this,"isValidQuery",(e=>{if(e.target&&e.target.length>0&&";"!==e.target){e.target=e.target.trim();const t=e.target.split(";",2);return 2===t.length&&t[0].length>0&&t[1].length>0}return!1})),W(this,"stateCallback",(()=>{const e=this.props.query;this.onChange(e)})),W(this,"onIsPiPointChange",(e=>{const{query:t}=this.props,a=!t.isPiPoint;this.setState({segments:a?[{label:""}]:this.checkAfServer(),attributes:[],isPiPoint:a},(()=>{this.onChange(N(V({},t),{expression:"",attributes:this.state.attributes,segments:this.state.segments,isPiPoint:a}))}))})),this.onSegmentChange=this.onSegmentChange.bind(this),this.calcBasisValueChanged=this.calcBasisValueChanged.bind(this),this.calcNoDataValueChanged=this.calcNoDataValueChanged.bind(this),this.onSummaryAction=this.onSummaryAction.bind(this),this.onSummaryValueChanged=this.onSummaryValueChanged.bind(this),this.onAttributeAction=this.onAttributeAction.bind(this),this.onAttributeChange=this.onAttributeChange.bind(this),this.summaryTypes=["Total","Average","Minimum","Maximum","Range","StdDev","PopulationStdDev","Count","PercentGood","All","AllForNonNumeric"],this.calculationBasis=["TimeWeighted","EventWeighted","TimeWeightedContinuous","TimeWeightedDiscrete","EventWeightedExcludeMostRecentEvent","EventWeightedExcludeEarliestEvent","EventWeightedIncludeBothEnds"],this.noDataReplacement=["Null","Drop","Previous","0","Keep"]}}var U=o(269),M=o(531);function Q(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function G(e){for(var t=1;t{const t=u.target;if(t&&t[e])return{label:t[e].Name,value:t[e]}};var S;return o.getAssetServer(o.afserver.name).then((e=>{v(e.WebId)})),c().createElement(c().Fragment,null,c().createElement("div",{className:"gf-form-group"},c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Database",labelWidth:$,grow:!0},c().createElement(d.AsyncSelect,{key:null!=g?g:"database-key",loadOptions:()=>o.getDatabases(g).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("database"),onChange:e=>{f(e.value),h(L(G({},s),{database:e.value,template:void 0}))},defaultOptions:!0})),c().createElement(d.InlineField,{label:"Event Frames",labelWidth:$,grow:!0},c().createElement(d.AsyncSelect,{key:null!==(S=null==y?void 0:y.WebId)&&void 0!==S?S:"default-template-key",loadOptions:()=>o.getEventFrameTemplates(null==y?void 0:y.WebId).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("template"),onChange:e=>h(L(G({},s),{template:e.value})),defaultOptions:!0})),c().createElement(d.InlineField,{label:"Show Start and End Time",labelWidth:$,grow:!0},c().createElement(d.InlineSwitch,{value:!!s.showEndTime,onChange:e=>h(L(G({},s),{showEndTime:e.currentTarget.checked}))}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Category name",labelWidth:$,grow:!0},c().createElement(d.Input,{type:"text",value:s.categoryName,onBlur:e=>p(),onChange:e=>h(L(G({},s),{categoryName:e.currentTarget.value})),placeholder:"Enter category name"})),c().createElement(d.InlineField,{label:"Name Filter",labelWidth:$,grow:!0},c().createElement(d.Input,{type:"text",value:s.nameFilter,onBlur:e=>p(),onChange:e=>h(L(G({},s),{nameFilter:e.currentTarget.value})),placeholder:"Enter name filter"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Enable Name Regex Replacement",labelWidth:$,grow:!1},c().createElement(d.InlineSwitch,{value:null===(a=s.regex)||void 0===a?void 0:a.enable,onChange:e=>h(L(G({},s),{regex:L(G({},s.regex),{enable:e.currentTarget.checked})}))})),c().createElement(d.InlineField,{label:"Name Filter",labelWidth:20,grow:!1},c().createElement(d.Input,{type:"text",value:null===(n=s.regex)||void 0===n?void 0:n.search,onBlur:e=>p(),onChange:e=>h(L(G({},s),{regex:L(G({},s.regex),{search:e.currentTarget.value})})),placeholder:"(.*)",width:50})),c().createElement(d.InlineField,{label:"Replace",labelWidth:20,grow:!0},c().createElement(d.Input,{type:"text",value:null==s||null===(l=s.regex)||void 0===l?void 0:l.replace,onBlur:e=>p(),onChange:e=>h(L(G({},s),{regex:L(G({},s.regex),{replace:e.currentTarget.value})})),placeholder:"$1"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Enable Attribute Usage",labelWidth:$,grow:!1},c().createElement(d.InlineSwitch,{value:null===(r=s.attribute)||void 0===r?void 0:r.enable,onChange:e=>h(L(G({},s),{attribute:L(G({},s.attribute),{enable:e.currentTarget.checked})}))})),c().createElement(d.InlineField,{label:"Attribute Name",labelWidth:$,grow:!0},c().createElement(d.Input,{type:"text",value:null===(i=s.attribute)||void 0===i?void 0:i.name,onBlur:e=>p(),onChange:e=>h(L(G({},s),{attribute:L(G({},s.attribute),{name:e.currentTarget.value})})),placeholder:"Enter name"})))))}));function _(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function Y(e){for(var t=1;te.substring(1,e.length-2).split(",")[0]))),e.filter=null!==(l=e.filter)&&void 0!==l?l:"*",e.max=null!==(r=e.max)&&void 0!==r?r:1e4,"servers"===e.type?(null===(i=a.afserver)||void 0===i?void 0:i.name)?a.getAssetServer(a.afserver.name).then((e=>[e])).then(A):a.getAssetServers().then(A):"databases"===e.type&&e.afServerWebId?a.getDatabases(e.afServerWebId,{}).then(A):"databases"===e.type?a.getAssetServer(e.path).then((e=>{var t;return a.getDatabases(null!==(t=e.WebId)&&void 0!==t?t:"",{})})).then(A):"databaseElements"===e.type?a.getDatabase(e.path).then((e=>{var t;return a.getDatabaseElements(null!==(t=e.WebId)&&void 0!==t?t:"",{selectedFields:"Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren"})})).then(A):"elements"===e.type?a.getElement(e.path).then((t=>{var n;return a.getElements(null!==(n=t.WebId)&&void 0!==n?n:"",{selectedFields:"Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren",nameFilter:e.filter})})).then(A):"attributes"===e.type?a.getElement(e.path).then((t=>{var n;return a.getAttributes(null!==(n=t.WebId)&&void 0!==n?n:"",{searchFullHierarchy:"true",selectedFields:"Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path",nameFilter:e.filter,maxCount:e.max})})).then(A):"dataserver"===e.type?a.getDataServers().then(A):"pipoint"===e.type?a.piPointSearch(e.webId,e.pointName).then(A):Promise.reject("Bad type")}buildQueryParameters(e){return e.targets=(0,E.filter)(e.targets,(e=>{var t;return!(!e||!e.target||0===(null===(t=e.attributes)||void 0===t?void 0:t.length)||";"===e.target||e.hide||e.target.startsWith("Select AF"))})),e.maxDataPoints&&(e.maxDataPoints=e.maxDataPoints>3e4?3e4:e.maxDataPoints),e.targets=(0,E.map)(e.targets,(t=>{var a;const n={enableStreaming:t.enableStreaming,target:this.templateSrv.replace(t.target,e.scopedVars),elementPath:this.templateSrv.replace(t.elementPath,e.scopedVars),attributes:(0,E.map)(t.attributes,(t=>(t.value&&this.templateSrv.replace(t.value.value,e.scopedVars),t))),segments:(0,E.map)(t.segments,(t=>(t.value&&this.templateSrv.replace(t.value.value,e.scopedVars),t))),isAnnotation:!!t.isAnnotation,display:t.display?this.templateSrv.replace(t.display,e.scopedVars):void 0,refId:t.refId,hide:t.hide,interpolate:t.interpolate?J(Y({},t.interpolate),{interval:this.templateSrv.replace(t.interpolate.interval,e.scopedVars)}):{enable:!1},useLastValue:t.useLastValue||{enable:!1},useUnit:t.useUnit||{enable:!1},recordedValues:t.recordedValues?J(Y({},t.recordedValues),{interval:this.templateSrv.replace(t.recordedValues.maxNumber,e.scopedVars)}):{enable:!1},digitalStates:t.digitalStates||{enable:!1},webid:null!==(a=t.webid)&&void 0!==a?a:"",regex:t.regex||{enable:!1},expression:t.expression||"",summary:t.summary||{types:[]},startTime:e.range.from,endTime:e.range.to,isPiPoint:!!t.isPiPoint,scopedVars:e.scopedVars};return n.expression&&(n.expression=this.templateSrv.replace(n.expression,e.scopedVars)),void 0!==n.summary.types&&(n.summary.types=(0,E.filter)(n.summary.types,(e=>null!=e&&""!==e))),n})),e}eventFrameToAnnotation(e,t){const a=e.target,n=[],l=Intl.DateTimeFormat().resolvedOptions().locale;return t.forEach((e=>{let t=this.transformDataFrameToMap(e);for(let e=0;eStart: "+new Date(t.time[e]).toLocaleString(l)+"
End: ",t.timeEnd[e]?i+=new Date(t.timeEnd[e]).toLocaleString(l):i+="Eventframe is open";const s={time:t.time[e],timeEnd:a.showEndTime?t.timeEnd[e]:void 0,title:r,id:t.id[e],text:i,tags:["OSISoft PI"]};n.push(s)}})),n}transformDataFrameToMap(e){const t={};return e.fields.forEach((e=>{t[e.name]=e.values.toArray()})),t}restGet(e){const t=this.backendSrv.fetch({url:`/api/datasources/${this.id}/resources${e}`,method:"GET",headers:{"Content-Type":"application/json"}});return(0,U.firstValueFrom)(t).then((e=>e))}getDataServers(){return this.restGet("/dataservers").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getDataServer(e){return e?this.restGet("/dataservers?name="+e).then((e=>e.data)):Promise.resolve({})}getAssetServers(){return this.restGet("/assetservers").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getAssetServer(e){return e?this.restGet("/assetservers?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getDatabase(e){return e?this.restGet("/assetdatabases?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getDatabases(e,t){return e?this.restGet("/assetservers/"+e+"/assetdatabases").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]})):Promise.resolve([])}getElement(e){return e?this.restGet("/elements?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getEventFrameTemplates(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((e=>{var t;return(0,E.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(e=>"EventFrame"===e.InstanceType))})):Promise.resolve([])}getElementTemplates(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((e=>{var t;return(0,E.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(e=>"Element"===e.InstanceType))})):Promise.resolve([])}getAttributes(e,t){let a="?"+(0,E.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/elements/"+e+"/attributes"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getDatabaseElements(e,t){let a="?"+(0,E.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/assetdatabases/"+e+"/elements"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getElements(e,t){let a="?"+(0,E.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/elements/"+e+"/elements"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}piPointSearch(e,t){let a=this.templateSrv.replace(t),n=`${a}`,l=!1;if(a!==t){const e=RegExp("\\{(\\w|,)+\\}","gs");let t;for(;null!==(t=e.exec(a));)t.index===e.lastIndex&&e.lastIndex++,t.forEach(((e,t)=>{0===t&&(a=a.replace(e,e.replace("{","(").replace("}",")").replace(",","|")),n=n.replace(e,"*"),l=!0)}))}return this.restGet("/dataservers/"+e+"/points?maxCount=50&nameFilter="+n).then((e=>{var t;return e&&(null===(t=e.data)||void 0===t?void 0:t.Items)?l?e.data.Items.filter((e=>{var t;return null===(t=e.Name)||void 0===t?void 0:t.match(a)})):e.data.Items:[]}))}constructor(e,t=(0,M.getTemplateSrv)(),a=(0,M.getBackendSrv)()){super(e),_(this,"templateSrv",void 0),_(this,"backendSrv",void 0),_(this,"piserver",void 0),_(this,"afserver",void 0),_(this,"afdatabase",void 0),_(this,"piPointConfig",void 0),_(this,"newFormatConfig",void 0),_(this,"useUnitConfig",void 0),_(this,"useExperimental",void 0),_(this,"useStreaming",void 0),this.templateSrv=t,this.backendSrv=a,this.piserver={name:(e.jsonData||{}).piserver,webid:void 0},this.afserver={name:(e.jsonData||{}).afserver,webid:void 0},this.afdatabase={name:(e.jsonData||{}).afdatabase,webid:void 0},this.piPointConfig=e.jsonData.pipoint||!1,this.newFormatConfig=e.jsonData.newFormat||!1,this.useUnitConfig=e.jsonData.useUnit||!1,this.useExperimental=e.jsonData.useExperimental||!1,this.useStreaming=e.jsonData.useStreaming||!1,this.annotations={QueryEditor:H,prepareQuery:e=>(e.target&&(e.target.queryType="Annotation",e.target.isAnnotation=!0),e.target),processEvents:(e,t)=>(0,U.of)(this.eventFrameToAnnotation(e,t))},Promise.all([this.getDataServer(this.piserver.name).then((e=>this.piserver.webid=e.WebId)),this.getAssetServer(this.afserver.name).then((e=>this.afserver.webid=e.WebId)),this.getDatabase(this.afserver.name&&this.afdatabase.name?this.afserver.name+"\\"+this.afdatabase.name:void 0).then((e=>this.afdatabase.webid=e.WebId))])}}const z=new h.DataSourcePlugin(K).setQueryEditor(R).setConfigEditor(f);return u})())); //# sourceMappingURL=module.js.map \ No newline at end of file diff --git a/dist/module.js.map b/dist/module.js.map index b3776dd..10e74b8 100644 --- a/dist/module.js.map +++ b/dist/module.js.map @@ -1 +1 @@ -{"version":3,"file":"module.js","mappings":"oIAAAA,EAAOC,QAAUC,C,UCAjBF,EAAOC,QAAUE,C,QCAjBH,EAAOC,QAAUG,C,UCAjBJ,EAAOC,QAAUI,C,UCAjBL,EAAOC,QAAUK,C,UCAjBN,EAAOC,QAAUM,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaV,QAGrB,IAAID,EAASQ,EAAyBE,GAAY,CAGjDT,QAAS,CAAC,GAOX,OAHAY,EAAoBH,GAAUV,EAAQA,EAAOC,QAASQ,GAG/CT,EAAOC,OACf,CCrBAQ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QyJ,IAAI,CACVnX,KAAKyV,cAAczV,KAAK2B,SAAS2E,MAAMkD,MAAMZ,GAAyB5I,KAAK2B,SAAS2R,MAAQ1K,EAAO5C,QACnGhG,KAAKsQ,eAAetQ,KAAK8B,SAASwE,MAAMkD,MAAMZ,GAAyB5I,KAAK8B,SAASwR,MAAQ1K,EAAO5C,QACpGhG,KAAKoS,YACHpS,KAAK8B,SAASwE,MAAQtG,KAAKgC,WAAWsE,KAAOtG,KAAK8B,SAASwE,KAAO,KAAOtG,KAAKgC,WAAWsE,UAAOvI,GAChGyL,MAAMZ,GAAyB5I,KAAKgC,WAAWsR,MAAQ1K,EAAO5C,SAEpE,ECjEK,MAAMoR,EAAS,IAAIC,EAAAA,iBACxBlG,GAECmG,eAAe/Q,GACfgR,gBAAgB3X,G","sources":["webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/data\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/runtime\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/ui\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"lodash\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"react\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"rxjs\"","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/bootstrap","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/compat get default export","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/define property getters","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/hasOwnProperty shorthand","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/make namespace object","webpack://gridprotectionalliance-osisoftpi-datasource/./config/ConfigEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./components/Forms.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./types.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./components/QueryEditorModeSwitcher.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./helper.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./query/QueryEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./query/AnnotationsQueryEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./datasource.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./module.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__781__;","module.exports = __WEBPACK_EXTERNAL_MODULE__531__;","module.exports = __WEBPACK_EXTERNAL_MODULE__7__;","module.exports = __WEBPACK_EXTERNAL_MODULE__241__;","module.exports = __WEBPACK_EXTERNAL_MODULE__959__;","module.exports = __WEBPACK_EXTERNAL_MODULE__269__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { ChangeEvent, PureComponent } from 'react';\nimport { LegacyForms, DataSourceHttpSettings, InlineField, InlineSwitch } from '@grafana/ui';\nimport { DataSourcePluginOptionsEditorProps, DataSourceJsonData, DataSourceSettings } from '@grafana/data';\nimport { PIWebAPIDataSourceJsonData } from '../types';\n\nconst { FormField } = LegacyForms;\n\ninterface Props extends DataSourcePluginOptionsEditorProps {}\n\nconst coerceOptions = (\n options: DataSourceSettings\n): DataSourceSettings => {\n return {\n ...options,\n jsonData: {\n ...options.jsonData,\n url: options.url,\n },\n };\n};\n\ninterface State {}\n\nexport class PIWebAPIConfigEditor extends PureComponent {\n onPIServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFDatabaseChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afdatabase: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onHttpOptionsChange = (options: DataSourceSettings) => {\n const { onOptionsChange } = this.props;\n onOptionsChange(coerceOptions(options));\n };\n\n onPiPointChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.checked ? options.jsonData.piserver : '',\n pipoint: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onNewFormatChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n newFormat: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseUnitChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useUnit: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseExperimentalChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useExperimental : event.target.checked,\n useStreaming : event.target.checked ? options.jsonData.useStreaming : false,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseStreamingChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useStreaming: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n render() {\n const { options: originalOptions } = this.props;\n const options = coerceOptions(originalOptions);\n\n return (\n
\n \n\n

Custom Configuration

\n\n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n \n \n \n
\n {options.jsonData.useExperimental && (\n
\n \n \n \n
\n )}\n
\n\n

PI/AF Connection Details

\n\n
\n {options.jsonData.pipoint && (\n
\n \n
\n )}\n
\n \n
\n
\n \n
\n
\n
\n );\n }\n}\n","import React, { InputHTMLAttributes, FunctionComponent } from 'react';\nimport { InlineFormLabel } from '@grafana/ui';\n\nexport interface Props extends InputHTMLAttributes {\n label: string;\n tooltip?: string;\n labelWidth?: number;\n children?: React.ReactNode;\n queryEditor?: JSX.Element;\n}\n\nexport const QueryField: FunctionComponent> = ({ label, labelWidth = 12, tooltip, children }) => (\n <>\n \n {label}\n \n {children}\n \n);\n\nexport const QueryRowTerminator = () => {\n return (\n
\n
\n
\n );\n};\n\nexport const QueryInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryEditorRow = (props: Partial) => {\n return (\n
\n {props.children}\n \n
\n );\n};\n\nexport const QueryRawInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryRawEditorRow = (props: Partial) => {\n return <>{props.children};\n};\n","import { DataQuery } from '@grafana/schema';\nimport { DataSourceJsonData, SelectableValue } from '@grafana/data';\n\nexport interface PiwebapiElementPath {\n path: string;\n variable: string;\n}\n\nexport interface PiwebapiInternalRsp {\n data: PiwebapiRsp;\n status: number;\n url: string;\n}\n\nexport interface PiwebapiRsp {\n Name?: string;\n InstanceType?: string;\n Items?: PiwebapiRsp[];\n WebId?: string;\n HasChildren?: boolean;\n Type?: string;\n DefaultUnitsName?: string;\n Description?: string;\n Path?: string;\n}\n\nexport interface PiDataServer {\n name: string | undefined;\n webid: string | undefined;\n}\n\nexport interface PIWebAPISelectableValue {\n webId?: string;\n value?: string;\n type?: string;\n expandable?: boolean;\n}\n\nexport interface PIWebAPIAnnotationsQuery extends DataQuery {\n target: string;\n}\n\nexport interface PIWebAPIQuery extends DataQuery {\n target?: string;\n elementPath?: string;\n attributes?: Array>;\n segments?: any[];\n isPiPoint?: boolean;\n isAnnotation?: boolean;\n webid?: string;\n display?: any;\n interpolate?: any;\n recordedValues?: any;\n digitalStates?: any;\n enableStreaming: any;\n useLastValue?: any;\n useUnit?: any;\n regex?: any;\n summary?: {nodata?: string, types?: any[], basis?: string, interval?: string};\n expression?: string;\n rawQuery?: boolean;\n query?: string;\n // annotations items\n database?: PiwebapiRsp;\n template?: PiwebapiRsp;\n showEndTime?: boolean;\n attribute?: any;\n nameFilter?: string;\n categoryName?: string;\n}\n\nexport const defaultQuery: Partial = {\n target: ';',\n attributes: [],\n segments: [],\n regex: { enable: false },\n summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false },\n digitalStates: { enable: false },\n enableStreaming: { enable: false },\n useUnit: { enable: false },\n isPiPoint: false,\n};\n\n/**\n * These are options configured for each DataSource instance\n */\nexport interface PIWebAPIDataSourceJsonData extends DataSourceJsonData {\n url?: string;\n access?: string;\n piserver?: string;\n afserver?: string;\n afdatabase?: string;\n pipoint?: boolean;\n newFormat?: boolean;\n useUnit?: boolean;\n useExperimental?: boolean;\n useStreaming?: boolean;\n}\n\n/**\n * Value that is used in the backend, but never sent over HTTP to the frontend\n */\nexport interface PIWebAPISecureJsonData {\n apiKey?: string;\n}\n","import React, { useEffect, useState } from 'react';\nimport { Button, ConfirmModal } from '@grafana/ui';\n\ntype Props = {\n isRaw: boolean;\n onChange: (newIsRaw: boolean) => void;\n};\n\nexport const QueryEditorModeSwitcher = ({ isRaw, onChange }: Props): JSX.Element => {\n const [isModalOpen, setModalOpen] = useState(false);\n\n useEffect(() => {\n // if the isRaw changes, we hide the modal\n setModalOpen(false);\n }, [isRaw]);\n\n if (isRaw) {\n return (\n <>\n {\n // we show the are-you-sure modal\n setModalOpen(true);\n }}\n >\n {\n onChange(false);\n }}\n onDismiss={() => {\n setModalOpen(false);\n }}\n />\n \n );\n } else {\n return (\n {\n onChange(true);\n }}\n >\n );\n }\n};\n","import { each, map } from 'lodash';\r\n\r\nimport {\r\n AnnotationQuery,\r\n DataFrame,\r\n TableData,\r\n MetricFindValue,\r\n Field,\r\n toDataFrame,\r\n} from '@grafana/data';\r\n\r\nimport { PiwebapiElementPath, PiwebapiRsp, PIWebAPIQuery } from 'types';\r\n\r\nexport function parseRawQuery(tr: string): any {\r\n const splitAttributes = tr.split(';');\r\n const splitElements = splitAttributes[0].split('\\\\');\r\n\r\n // remove element hierarchy from attribute collection\r\n splitAttributes.splice(0, 1);\r\n\r\n let attributes: any[] = [];\r\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\r\n const elementPath: string = splitElements.join('\\\\');\r\n each(splitAttributes, function (item, index) {\r\n if (item !== '') {\r\n attributes.push({\r\n label: item,\r\n value: {\r\n value: item,\r\n expandable: false,\r\n },\r\n });\r\n }\r\n });\r\n\r\n return { attributes, elementPath };\r\n }\r\n\r\n return { attributes, elementPath: null };\r\n}\r\n\r\nexport function lowerCaseFirstLetter(string: string): string {\r\n return string.charAt(0).toLocaleLowerCase() + string.slice(1);\r\n}\r\n\r\n/**\r\n * Builds the Grafana metric segment for use on the query user interface.\r\n *\r\n * @param {any} response - response from PI Web API.\r\n * @returns - Grafana metric segment.\r\n *\r\n * @memberOf PiWebApiDatasource\r\n */\r\nexport function metricQueryTransform(response: PiwebapiRsp[]): MetricFindValue[] {\r\n return map(response, (item) => {\r\n return {\r\n text: item.Name,\r\n expandable:\r\n item.HasChildren === undefined || item.HasChildren === true || (item.Path ?? '').split('\\\\').length <= 3,\r\n HasChildren: item.HasChildren,\r\n Items: item.Items ?? [],\r\n Path: item.Path,\r\n WebId: item.WebId,\r\n } as MetricFindValue;\r\n });\r\n}\r\n\r\n/**\r\n * Check if all items are selected.\r\n *\r\n * @param {any} current the current variable selection\r\n * @return {boolean} true if all value is selected, false otherwise\r\n */\r\nexport function isAllSelected(current: any): boolean {\r\n if (!current) {\r\n return false;\r\n }\r\n if (Array.isArray(current.text)) {\r\n return current.text.indexOf('All') >= 0;\r\n }\r\n return current.text === 'All';\r\n}\r\n\r\nexport function processAnnotationQuery(annon: AnnotationQuery,data: DataFrame[]): DataFrame[] {\r\n let processedFrames: DataFrame[] = [];\r\n \r\n data.forEach((d: DataFrame) => {\r\n d.fields.forEach((f: Field) => {\r\n\r\n // check if the label has been set, if it hasn't been set then the eventframe annotation is not valid. \r\n if (!f.labels) { \r\n return \r\n }\r\n\r\n if (!('eventframe' in f.labels)) {\r\n return;\r\n }\r\n\r\n let attribute = 'attribute' in f.labels\r\n\r\n // Check whether f.values is an array or not to allow for each.\r\n // Check whether f.values is an array or not to allow for each.\r\n if (Array.isArray(f.values)) {\r\n f.values.forEach((value: any) => {\r\n\r\n if (attribute) {\r\n let annotation = value['1'].Content\r\n let valueData: any[] = []\r\n for (let i = 2; i in value; i++) {\r\n valueData.push(value[i].Content.Items)\r\n }\r\n\r\n const processedFrame = convertToTableData(annotation.Items!, valueData).map((r) => {\r\n return toDataFrame(r)});\r\n processedFrames = processedFrames.concat(processedFrame);\r\n } else {\r\n let annotation = value['1'].Content\r\n const processedFrame = convertToTableData(annotation.Items!).map((r) => {\r\n return toDataFrame(r)});\r\n processedFrames = processedFrames.concat(processedFrame);\r\n }\r\n });\r\n } \r\n });\r\n });\r\n return processedFrames;\r\n}\r\n\r\nexport function convertToTableData(items: any[], valueData?: any[]): TableData[] {\r\n const response: TableData[] = items.map((item: any, index: number) => {\r\n const columns = [{ text: 'StartTime' }, { text: 'EndTime' }];\r\n const rows = [item.StartTime, item.EndTime];\r\n if (valueData) {\r\n for (let attributeIndex = 0; attributeIndex < valueData.length; attributeIndex++) {\r\n let attributeData = valueData[attributeIndex]\r\n let eventframeAributeData = attributeData[index].Content.Items\r\n eventframeAributeData.forEach((attribute: any) => {\r\n columns.push({ text: attribute.Name });\r\n rows.push(String(attribute.Value.Value ? attribute.Value.Value.Name || attribute.Value.Value.Value || attribute.Value.Value : ''));\r\n });\r\n }\r\n }\r\n\r\n return {\r\n name: item.Name,\r\n columns,\r\n rows: [rows],\r\n };\r\n });\r\n return response;\r\n}\r\n\r\n/**\r\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\r\n *\r\n * @param {any} item - 'Item' object from PIWebAPI\r\n * @param {any} noDataReplacementMode - String state of how to replace 'No Data'\r\n * @param {any} grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns perviousValue - {any} Grafana value (value only).\r\n *\r\n */\r\nexport function noDataReplace(\r\n item: any,\r\n noDataReplacementMode: any,\r\n grafanaDataPoint: any[]\r\n): {\r\n grafanaDataPoint: any[];\r\n previousValue: any;\r\n drop: boolean;\r\n} {\r\n let previousValue = null;\r\n let drop = false;\r\n if (!item.Good || item.Value === 'No Data' || (item.Value?.Name && item.Value?.Name === 'No Data')) {\r\n if (noDataReplacementMode === 'Drop') {\r\n drop = true;\r\n } else if (noDataReplacementMode === '0') {\r\n grafanaDataPoint[0] = 0;\r\n } else if (noDataReplacementMode === 'Keep') {\r\n // Do nothing keep\r\n } else if (noDataReplacementMode === 'Null') {\r\n grafanaDataPoint[0] = null;\r\n } else if (noDataReplacementMode === 'Previous' && previousValue !== null) {\r\n grafanaDataPoint[0] = previousValue;\r\n }\r\n } else {\r\n previousValue = item.Value;\r\n }\r\n return { grafanaDataPoint, previousValue, drop };\r\n}\r\n\r\n/**\r\n * Check if the value is a number.\r\n *\r\n * @param {any} number the value to check\r\n * @returns {boolean} true if the value is a number, false otherwise\r\n */\r\nexport function checkNumber(number: any): boolean {\r\n return typeof number === 'number' && !Number.isNaN(number) && Number.isFinite(number);\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path.\r\n *\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getLastPath(path: string): string {\r\n let splitPath = path.split('|');\r\n if (splitPath.length === 0) {\r\n return '';\r\n }\r\n splitPath = splitPath[0].split('\\\\');\r\n return splitPath.length === 0 ? '' : splitPath.pop() ?? '';\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path plus variable.\r\n *\r\n * @param {PiwebapiElementPath[]} elementPathArray array of element paths\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getPath(elementPathArray: PiwebapiElementPath[], path: string): string {\r\n if (!path || elementPathArray.length === 0) {\r\n return '';\r\n }\r\n const splitStr = getLastPath(path);\r\n const foundElement = elementPathArray.find((e) => path.indexOf(e.path) >= 0)?.variable;\r\n return foundElement ? foundElement + '|' + splitStr : splitStr;\r\n}\r\n\r\n/**\r\n * Replace calculation dot in expression with PI point name.\r\n *\r\n * @param {boolean} replace - is pi point and calculation.\r\n * @param {PiwebapiRsp} webid - Pi web api response object.\r\n * @param {string} url - original url.\r\n * @returns Modified url\r\n */\r\nexport function getFinalUrl(replace: boolean, webid: PiwebapiRsp, url: string) {\r\n const newUrl = replace ? url.replace(/'\\.'/g, `'${webid.Name}'`) : url;\r\n return newUrl;\r\n}\r\n","import { each, filter, forOwn, join, reduce, map, slice, remove, defaults } from 'lodash';\n\nimport React, { PureComponent, ChangeEvent } from 'react';\nimport { Icon, InlineField, InlineFieldRow, InlineSwitch, Input, SegmentAsync, Segment } from '@grafana/ui';\nimport { QueryEditorProps, SelectableValue, TypedVariableModel } from '@grafana/data';\n\nimport { PiWebAPIDatasource } from '../datasource';\nimport { QueryInlineField, QueryRawInlineField, QueryRowTerminator } from '../components/Forms';\nimport { PIWebAPISelectableValue, PIWebAPIDataSourceJsonData, PIWebAPIQuery, defaultQuery } from '../types';\nimport { QueryEditorModeSwitcher } from 'components/QueryEditorModeSwitcher';\nimport { parseRawQuery } from 'helper';\n\nconst LABEL_WIDTH = 24;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n segments: Array>;\n attributes: Array>;\n summaries: Array>;\n attributeSegment: SelectableValue;\n summarySegment: SelectableValue;\n calculationBasisSegment: SelectableValue;\n noDataReplacementSegment: SelectableValue;\n}\n\ntype Props = QueryEditorProps;\n\nconst REMOVE_LABEL = '-REMOVE-';\n\nconst CustomLabelComponent = (props: any) => {\n if (props.value) {\n return (\n
\n {props.label ?? '--no label--'}\n
\n );\n }\n return (\n \n \n \n );\n};\n\nexport class PIWebAPIQueryEditor extends PureComponent {\n error: any;\n piServer: any[] = [];\n availableAttributes: any = {};\n summaryTypes: string[];\n calculationBasis: string[];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n segments: [],\n attributes: [],\n summaries: [],\n attributeSegment: {},\n summarySegment: {},\n calculationBasisSegment: {},\n noDataReplacementSegment: {},\n };\n\n constructor(props: any) {\n super(props);\n this.onSegmentChange = this.onSegmentChange.bind(this);\n this.calcBasisValueChanged = this.calcBasisValueChanged.bind(this);\n this.calcNoDataValueChanged = this.calcNoDataValueChanged.bind(this);\n this.onSummaryAction = this.onSummaryAction.bind(this);\n this.onSummaryValueChanged = this.onSummaryValueChanged.bind(this);\n this.onAttributeAction = this.onAttributeAction.bind(this);\n this.onAttributeChange = this.onAttributeChange.bind(this);\n\n this.summaryTypes = [\n // 'None', // A summary type is not specified.\n 'Total', // A totalization over the time range.\n 'Average', // The average value over the time range.\n 'Minimum', // The minimum value over the time range.\n 'Maximum', // The maximum value over the time range.\n 'Range', // The range value over the time range (minimum-maximum).\n 'StdDev', // The standard deviation over the time range.\n 'PopulationStdDev', // The population standard deviation over the time range.\n 'Count', // The sum of event count over the time range when calculation basis is event weighted. The sum of event time duration over the time range when calculation basis is time weighted.\n 'PercentGood', // Percent of data with good value during the calculation period. For time weighted calculations, the percentage is based on time. For event weighted calculations, the percent is based on event count.\n 'All', // A convenience for requesting all available summary calculations.\n 'AllForNonNumeric', // A convenience for requesting all available summary calculations for non-numeric data.\n ];\n\n this.calculationBasis = [\n 'TimeWeighted', // Weight the values in the calculation by the time over which they apply. Interpolation is based on whether the attribute is stepped. Interpolated events are generated at the boundaries if necessary.\n 'EventWeighted', // Evaluate values with equal weighting for each event. No interpolation is done. There must be at least one event within the time range to perform a successful calculation. Two events are required for standard deviation. In handling events at the boundary of the calculation, the AFSDK uses following rules:\n 'TimeWeightedContinuous', // Apply weighting as in TimeWeighted, but do all interpolation between values as if they represent continuous data, (standard interpolation) regardless of whether the attribute is stepped.\n 'TimeWeightedDiscrete', // Apply weighting as in TimeWeighted but interpolation between values is performed as if they represent discrete, unrelated values (stair step plot) regardless of the attribute is stepped.\n 'EventWeightedExcludeMostRecentEvent', // The calculation behaves the same as _EventWeighted_, except in the handling of events at the boundary of summary intervals in a multiple intervals calculation. Use this option to prevent events at the intervals boundary from being double count at both intervals. With this option, events at the end time (most recent time) of an interval is not used in that interval.\n 'EventWeightedExcludeEarliestEvent', // Similar to the option _EventWeightedExcludeMostRecentEvent_. Events at the start time(earliest time) of an interval is not used in that interval.\n 'EventWeightedIncludeBothEnds', // Events at both ends of the interval boundaries are included in the event weighted calculation.\n ];\n\n this.noDataReplacement = [\n 'Null', // replace with nulls\n 'Drop', // drop items\n 'Previous', // use previous value if available\n '0', // replace with 0\n 'Keep', // Keep value\n ];\n }\n\n // is selected segment empty\n isValueEmpty(value: PIWebAPISelectableValue | undefined) {\n return !value || !value.value || !value.value.length || value.value === REMOVE_LABEL;\n }\n\n segmentChangeValue = (segments: Array>) => {\n const query = this.props.query;\n this.setState({ segments }, () => this.onChange({ ...query, segments }));\n };\n\n attributeChangeValue = (attributes: Array>): Promise => {\n const query = this.props.query;\n return new Promise((resolve) => this.setState({ attributes }, () => {\n this.onChange({ ...query, attributes })\n resolve();\n }));\n };\n\n // summary calculation basis change event\n calcBasisValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n if (summary) {\n summary.basis = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, summary });\n }\n // get summary calculation basis user interface segments\n getCalcBasisSegments() {\n const segments = map(this.calculationBasis, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // no data change event\n calcNoDataValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n if (summary) {\n summary.nodata = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, summary });\n }\n // get no data user interface segments\n getNoDataSegments() {\n const segments = map(this.noDataReplacement, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // summary query change event\n onSummaryValueChanged(item: SelectableValue, index: number) {\n const summaries = this.state.summaries.slice(0) as Array>;\n summaries[index] = item;\n if (this.isValueEmpty(item.value)) {\n summaries.splice(index, 1);\n }\n this.setState({ summaries }, this.stateCallback);\n }\n // get the list of summaries available\n getSummarySegments() {\n const summaryTypes = filter(this.summaryTypes, (type) => {\n return this.state.summaries.map((s) => s.value?.value).indexOf(type) === -1;\n });\n\n const segments = map(summaryTypes, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n }\n\n // remove a summary from the user interface and the query\n removeSummary(part: SelectableValue) {\n const summaries = filter(this.state.summaries, (item: SelectableValue) => {\n return item !== part;\n });\n this.setState({ summaries });\n }\n // add a new summary to the query\n onSummaryAction(item: SelectableValue) {\n const summaries = this.state.summaries.slice(0) as Array>;\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: true,\n },\n };\n summaries.push(selectableValue);\n }\n this.setState({ summarySegment: {}, summaries }, this.stateCallback);\n }\n\n // remove an attribute from the query\n removeAttribute(part: SelectableValue) {\n const attributes = filter(this.state.attributes, (item: SelectableValue) => {\n return item !== part;\n });\n this.attributeChangeValue(attributes);\n }\n // add an attribute to the query\n onAttributeAction(item: SelectableValue) {\n const { query } = this.props;\n const attributes = this.state.attributes.slice(0);\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: !query.isPiPoint,\n },\n };\n attributes.push(selectableValue);\n }\n this.attributeChangeValue(attributes);\n }\n\n // pi point change event\n onPiPointChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n if (item.label === REMOVE_LABEL) {\n remove(attributes, (value, n) => n === index);\n } else {\n // set current value\n attributes[index] = item;\n }\n\n this.checkPiPointSegments(item, attributes);\n };\n // attribute change event\n onAttributeChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n // ignore if no change\n if (attributes[index].label === item.value?.value) {\n return;\n }\n\n // set current value\n attributes[index] = item;\n\n this.checkAttributeSegments(attributes, this.state.segments);\n };\n // segment change\n onSegmentChange = (item: SelectableValue, index: number) => {\n const { query } = this.props;\n let segments = this.state.segments.slice(0);\n\n // ignore if no change\n if (segments[index].label === item.value?.value) {\n return;\n }\n\n // reset attributes list\n this.setState({ attributes: [] }, () => {\n if (item.label === REMOVE_LABEL) {\n segments = slice(segments, 0, index);\n this.checkAttributeSegments([], segments).then(() => {\n if (segments.length === 0) {\n segments.push({\n label: '',\n });\n } else if (!!segments[segments.length - 1].value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n if (query.isPiPoint) {\n this.piServer = [];\n }\n this.segmentChangeValue(segments);\n });\n return;\n }\n\n // set current value\n segments[index] = item;\n\n // Accept only one PI server\n if (query.isPiPoint) {\n this.piServer.push(item);\n this.segmentChangeValue(segments);\n return;\n }\n\n // changed internal selection\n if (index < segments.length - 1) {\n segments = slice(segments, 0, index + 1);\n }\n this.checkAttributeSegments([], segments).then(() => {\n // add new options\n if (item.value?.type === 'template') {\n return this.getElementSegments(segments.length + 1, segments).then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n this.segmentChangeValue(segments);\n return segments;\n });\n } else if (!!item.value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return new Promise((resolve) => {\n this.segmentChangeValue(segments);\n resolve(segments);\n });\n });\n });\n };\n\n // get a ui segment for the attributes\n getElementSegments = (\n index: number,\n currentSegment?: Array>\n ): Promise>> => {\n const { datasource, query, data } = this.props;\n const ctrl = this;\n const findQuery = query.isPiPoint\n ? { type: 'dataserver' }\n : {\n path: this.getSegmentPathUpTo(currentSegment ?? this.state.segments.slice(0), index),\n afServerWebId: this.state.segments.length > 0 && this.state.segments[0].value ? this.state.segments[0].value.webId : undefined,\n };\n\n if (!query.isPiPoint) {\n if (datasource.afserver?.name && index === 0) {\n return Promise.resolve([\n {\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n },\n ]);\n }\n if (datasource.afserver?.name && datasource.afdatabase?.name && index === 1) {\n return Promise.resolve([\n {\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n },\n ]);\n }\n }\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n const altSegments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n label: item.text,\n value: {\n webId: item.WebId,\n value: item.text,\n expandable: !query.isPiPoint && item.expandable,\n },\n };\n return selectableValue;\n });\n\n if (altSegments.length === 0) {\n return altSegments;\n }\n\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: TypedVariableModel) => {\n let selectableValue: SelectableValue = {\n label: '${' + variable.name + '}',\n value: {\n type: 'template',\n value: '${' + variable.name + '}',\n expandable: !query.isPiPoint,\n },\n };\n altSegments.unshift(selectableValue);\n });\n\n // add remove label\n altSegments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return altSegments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return [];\n });\n };\n\n // get the list of attributes for the user interface - PI\n getAttributeSegmentsPI = (attributeText?: string): Promise>> => {\n const { datasource, query, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: '',\n webId: this.getSelectedPIServer(),\n pointName: (attributeText ?? '') + '*',\n type: 'pipoint',\n };\n let segments: Array> = [];\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n segments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n path: item.Path,\n label: item.text,\n value: {\n value: item.text,\n expandable: false,\n },\n };\n return selectableValue;\n });\n if (!!attributeText && attributeText.length > 0) {\n segments.unshift({\n label: attributeText,\n value: {\n value: attributeText,\n expandable: false,\n },\n });\n }\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: TypedVariableModel) => {\n let selectableValue: SelectableValue = {\n label: '${' + variable.name + '}',\n value: {\n type: 'template',\n value: '${' + variable.name + '}',\n expandable: !query.isPiPoint,\n },\n };\n segments.unshift(selectableValue);\n });\n\n // add remove label\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return segments;\n });\n };\n\n // get the list of attributes for the user interface - AF\n getAttributeSegmentsAF = (attributeText?: string): Array> => {\n const ctrl = this;\n let segments: Array> = [];\n\n segments.push({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n forOwn(ctrl.availableAttributes, (val: any, key: string) => {\n let selectableValue: SelectableValue = {\n label: key,\n value: {\n value: key,\n expandable: true,\n },\n };\n segments.push(selectableValue);\n });\n\n return segments;\n };\n\n // build data from target string\n buildFromTarget = (\n query: PIWebAPIQuery,\n segmentsArray: Array>,\n attributesArray: Array>\n ) => {\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segmentsArray.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, (item, _) => {\n if (item !== '') {\n // set current value\n attributesArray.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n return this.getElementSegments(splitElements.length + 1, segmentsArray).then((elements) => {\n console.log(\"EXPANDABLE 3\", elements)\n if (elements.length > 0) {\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return segmentsArray;\n });\n }\n return Promise.resolve(segmentsArray);\n };\n\n /**\n * Gets the segment information and parses it to a string.\n *\n * @param {any} index - Last index of segment to use.\n * @returns - AF Path or PI Point name.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSegmentPathUpTo(segments: Array>, index: number): string {\n const arr = segments.slice(0, index);\n\n return reduce(\n arr,\n (result: any, segment: SelectableValue) => {\n if (!segment.value) {\n return '';\n }\n if (!segment.value.value?.startsWith('-Select')) {\n return result ? result + '\\\\' + segment.value.value : segment.value.value;\n }\n return result;\n },\n ''\n );\n }\n\n /**\n * Get the current AF Element's child attributes. Validates when the element selection changes.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAttributeSegments(\n attributes: Array>,\n segments: Array>\n ): Promise {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: this.getSegmentPathUpTo(segments.slice(0), segments.length),\n type: 'attributes',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: false }))\n .then((attributesResponse: any) => {\n const validAttributes: any = {};\n\n each(attributesResponse, (attribute: any) => {\n validAttributes[attribute.Path.substring(attribute.Path.indexOf('|') + 1)] = attribute.WebId;\n });\n\n const filteredAttributes = filter(attributes, (attrib: SelectableValue) => {\n const changedValue = datasource.templateSrv.replace(attrib.value?.value);\n return validAttributes[changedValue] !== undefined;\n });\n\n ctrl.availableAttributes = validAttributes;\n return this.attributeChangeValue(filteredAttributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return this.attributeChangeValue(attributes);\n });\n }\n\n /**\n * Get PI points from server.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkPiPointSegments(\n attribute: SelectableValue,\n attributes: Array>\n ) {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: attribute.path,\n webId: ctrl.getSelectedPIServer(),\n pointName: attribute.label,\n type: 'pipoint',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: true }))\n .then(() => {\n return ctrl.attributeChangeValue(attributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return ctrl.attributeChangeValue([]);\n });\n }\n\n /**\n * Gets the webid of the current selected pi data server.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSelectedPIServer() {\n let webID = '';\n\n this.piServer.forEach((s) => {\n const parts = this.props.query.target!.split(';');\n if (parts.length >= 2) {\n if (parts[0] === s.text) {\n webID = s.WebId;\n return;\n }\n }\n });\n return this.piServer.length > 0 ? this.piServer[0].value?.webId : webID;\n }\n\n /**\n * Queries PI Web API for child elements and attributes when the raw query text editor is changed.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n textEditorChanged() {\n const { query } = this.props;\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n let segments: Array> = [];\n let attributes: Array> = [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segments.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n this.getElementSegments(splitElements.length + 1, segments)\n .then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n })\n .then(() => {\n this.updateArray(segments, attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n });\n } else {\n segments = this.checkAfServer();\n this.updateArray(segments, this.state.attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n }\n }\n\n /**\n * Check if the AF server and database are configured in the datasoure config.\n *\n * @returns the segments array\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAfServer = () => {\n const { datasource } = this.props;\n const segmentsArray = [];\n if (datasource.afserver?.name) {\n segmentsArray.push({\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n });\n if (datasource.afdatabase?.name) {\n segmentsArray.push({\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n });\n }\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n } else {\n segmentsArray.push({\n label: '',\n });\n }\n return segmentsArray;\n };\n\n /**\n * Update the internal state of the datasource.\n *\n * @param segmentsArray the segments array to update\n * @param attributesArray the AF attributes array to update\n * @param summariesArray the summaries array to update\n * @param isPiPoint the is PI point flag\n * @param cb optional callback function\n *\n * @memberOf PIWebAPIQueryEditor\n */\n updateArray = (\n segmentsArray: Array>,\n attributesArray: Array>,\n summariesArray: Array>,\n isPiPoint: boolean,\n cb?: (() => void) | undefined\n ) => {\n this.setState(\n {\n segments: segmentsArray,\n attributes: attributesArray,\n summaries: summariesArray,\n isPiPoint,\n },\n () => {\n if (!isPiPoint) {\n this.checkAttributeSegments(attributesArray, this.state.segments).then(() => {\n if (cb) {\n cb();\n }\n });\n }\n }\n );\n };\n\n // React action when component is initialized/updated\n scopedVarsDone = false;\n componentDidMount = () => {\n this.initialLoad(false);\n };\n\n componentDidUpdate = () => {\n const { query } = this.props;\n if (this.props.data?.state === 'Done' && !!this.props.data?.request?.scopedVars && !this.scopedVarsDone) {\n this.scopedVarsDone = true;\n this.initialLoad(!query.isPiPoint);\n }\n };\n\n initialLoad = (force: boolean) => {\n const { query } = this.props;\n const metricsQuery = defaults(query, defaultQuery) as PIWebAPIQuery;\n const { segments, attributes, summary, isPiPoint } = metricsQuery;\n\n let segmentsArray: Array> = force ? [] : segments?.slice(0) ?? [];\n let attributesArray: Array> = force ? [] : attributes?.slice(0) ?? [];\n let summariesArray = summary?.types ?? [];\n\n if (!isPiPoint && segmentsArray.length === 0) {\n if (query.target && query.target.length > 0 && query.target !== ';') {\n attributesArray = [];\n // Build query from target\n this.buildFromTarget(query, segmentsArray, attributesArray)\n .then((_segmentsArray) => {\n this.updateArray(_segmentsArray, attributesArray, summariesArray, false);\n })\n .catch((e) => console.error(e));\n return;\n } else {\n segmentsArray = this.checkAfServer();\n }\n } else if (isPiPoint && segmentsArray.length > 0) {\n this.piServer = segmentsArray;\n }\n this.updateArray(segmentsArray, attributesArray, summariesArray, !!isPiPoint, () => {\n this.onChange(query);\n });\n };\n\n onChange = (query: PIWebAPIQuery) => {\n const { onChange, onRunQuery } = this.props;\n\n if (query.rawQuery) {\n query.target = query.query ?? '';\n if (!!query.query) {\n const { attributes, elementPath } = parseRawQuery(query.target);\n query.attributes = attributes;\n query.elementPath = elementPath;\n }\n } else {\n query.elementPath = this.getSegmentPathUpTo(this.state.segments, this.state.segments.length);\n query.target =\n query.elementPath +\n ';' +\n join(\n query.attributes?.map((s) => s.value?.value),\n ';'\n );\n }\n const summary = query.summary;\n if (summary) {\n summary.types = this.state.summaries;\n }\n\n onChange({...query, summary});\n\n if (this.isValidQuery(query)) {\n onRunQuery();\n }\n };\n\n isValidQuery = (query: PIWebAPIQuery): boolean => {\n if (query.target && query.target.length > 0 && query.target !== \";\") {\n query.target = query.target.trim();\n const targetSplit = query.target.split(\";\", 2);\n return targetSplit.length === 2 && targetSplit[0].length > 0 && targetSplit[1].length > 0;\n }\n return false;\n }\n\n stateCallback = () => {\n const query = this.props.query as PIWebAPIQuery;\n this.onChange(query);\n };\n\n onIsPiPointChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const isPiPoint = !queryChange.isPiPoint;\n this.setState(\n {\n segments: isPiPoint ? [{ label: '' }] : this.checkAfServer(),\n attributes: [],\n isPiPoint,\n },\n () => {\n this.onChange({\n ...queryChange,\n expression: '',\n attributes: this.state.attributes,\n segments: this.state.segments,\n isPiPoint,\n });\n }\n );\n };\n\n render() {\n const { query: queryProps, onChange, onRunQuery } = this.props;\n const metricsQuery = defaults(queryProps, defaultQuery) as PIWebAPIQuery;\n const {\n useLastValue,\n useUnit,\n interpolate,\n query,\n rawQuery,\n digitalStates,\n enableStreaming,\n recordedValues,\n expression,\n isPiPoint,\n summary,\n display,\n regex,\n } = metricsQuery;\n\n return (\n <>\n {this.props.datasource.piPointConfig && (\n \n \n \n )}\n\n {!!rawQuery && (\n \n \n ) =>\n onChange({ ...metricsQuery, query: event.target.value })\n }\n placeholder=\"enter query\"\n />\n \n this.textEditorChanged()} />\n \n )}\n\n {!rawQuery && (\n <>\n
\n \n {this.state.segments.map((segment: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSegmentChange(item, index)}\n loadOptions={(query?: string | undefined) => {\n return this.getElementSegments(index);\n }}\n allowCustomValue\n inputMinWidth={MIN_ELEM_INPUT_WIDTH}\n />\n );\n })}\n \n {!isPiPoint && (\n {\n onChange({ ...metricsQuery, query: metricsQuery.target, rawQuery: value });\n }}\n />\n )}\n \n
\n\n \n {this.state.attributes.map((attribute: SelectableValue, index: number) => {\n if (isPiPoint) {\n return (\n }\n disabled={this.piServer.length === 0}\n onChange={(item) => this.onPiPointChange(item, index)}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n }\n return (\n }\n disabled={this.state.segments.length <= 2}\n onChange={(item) => this.onAttributeChange(item, index)}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n })}\n\n {isPiPoint && (\n \n }\n disabled={this.piServer.length === 0}\n onChange={this.onAttributeAction}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n {!isPiPoint && (\n \n }\n disabled={this.state.segments.length <= 2}\n onChange={this.onAttributeAction}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n \n \n )}\n\n \n \n ) =>\n onChange({ ...metricsQuery, expression: event.target.value })\n }\n placeholder=\"'.'*2\"\n />\n \n \n\n \n \n \n this.onChange({\n ...metricsQuery,\n useLastValue: { ...useLastValue, enable: !useLastValue.enable },\n })\n }\n />\n \n \n \n this.onChange({\n ...metricsQuery,\n digitalStates: { ...digitalStates, enable: !digitalStates.enable },\n })\n }\n />\n \n \n }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n {this.props.datasource.useUnitConfig && (\n \n \n this.onChange({\n ...metricsQuery,\n useUnit: { ...useUnit, enable: !useUnit.enable },\n })\n }\n />\n \n )}\n {this.props.datasource.useStreaming && (\n \n \n this.onChange({ ...metricsQuery, enableStreaming: { ...enableStreaming, enable: !enableStreaming.enable } })\n }\n />\n \n )}\n \n\n \n {!useLastValue.enable && (\n \n ) =>\n onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, maxNumber: parseInt(event.target.value, 10) },\n })\n }\n type=\"number\"\n placeholder=\"1000\"\n />\n \n )}\n \n \n this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable },\n })\n }\n />\n \n \n\n {!useLastValue.enable && (\n \n \n ) =>\n onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable } })\n }\n />\n \n \n )}\n\n {!useLastValue.enable && (\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n }\n onChange={this.calcBasisValueChanged}\n options={this.getCalcBasisSegments()}\n allowCustomValue\n />\n \n \n \n {this.state.summaries.map((s: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSummaryValueChanged(item, index)}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n );\n })}\n \n }\n onChange={this.onSummaryAction}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n \n \n \n )}\n\n \n \n ) =>\n onChange({ ...metricsQuery, display: event.target.value })\n }\n placeholder=\"Display\"\n />\n \n \n {\n this.onChange({ ...metricsQuery, regex: { ...regex, enable: !regex.enable } });\n }}\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, search: event.target.value } })\n }\n placeholder=\"(.*)\"\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, replace: event.target.value } })\n }\n placeholder=\"$1\"\n />\n \n \n \n );\n }\n}\n","import React, { memo, useState } from 'react';\n\nimport { AnnotationQuery, QueryEditorProps, SelectableValue } from '@grafana/data';\nimport { AsyncSelect, InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';\n\nimport { PiWebAPIDatasource } from 'datasource';\nimport { PIWebAPIDataSourceJsonData, PIWebAPIQuery, PiwebapiRsp } from 'types';\n\nconst SMALL_LABEL_WIDTH = 20;\nconst LABEL_WIDTH = 30;\nconst MIN_INPUT_WIDTH = 50;\n\ntype PiWebAPIQueryEditorProps = QueryEditorProps;\n\ntype Props = PiWebAPIQueryEditorProps & {\n annotation?: AnnotationQuery;\n onAnnotationChange?: (annotation: AnnotationQuery) => void;\n};\n\nexport const PiWebAPIAnnotationsQueryEditor = memo(function PiWebAPIAnnotationQueryEditor(props: Props) {\n const { query, datasource, annotation, onChange, onRunQuery } = props;\n\n const [afWebId, setAfWebId] = useState('');\n const [database, setDatabase] = useState(annotation?.target?.database ?? {});\n\n // this should never happen, but we want to keep typescript happy\n if (annotation === undefined) {\n return null;\n }\n\n const getEventFrames = (): Promise>> => {\n return datasource.getEventFrameTemplates(database?.WebId!).then((templ: PiwebapiRsp[]) => {\n return templ.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getDatabases = (): Promise>> => {\n return datasource.getDatabases(afWebId).then((dbs: PiwebapiRsp[]) => {\n return dbs.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getValue = (key: string) => {\n const query: any = annotation.target as any;\n if (!query || !query[key]) {\n return;\n }\n return { label: query[key].Name, value: query[key] };\n };\n\n datasource.getAssetServer(datasource.afserver.name).then((result) => {\n setAfWebId(result.WebId!);\n });\n\n return (\n <>\n
\n \n \n {\n setDatabase(e.value);\n onChange({ ...query, database: e.value, template: undefined });\n }}\n defaultOptions\n />\n \n \n onChange({ ...query, template: e.value })}\n defaultOptions\n />\n \n \n onChange({ ...query, showEndTime: e.currentTarget.checked })}\n />\n \n \n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, categoryName: e.currentTarget.value })}\n placeholder=\"Enter category name\"\n />\n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, nameFilter: e.currentTarget.value })}\n placeholder=\"Enter name filter\"\n />\n \n \n \n \n \n onChange({\n ...query,\n regex: { ...query.regex, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, search: e.currentTarget.value },\n })\n }\n placeholder=\"(.*)\"\n width={MIN_INPUT_WIDTH}\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, replace: e.currentTarget.value },\n })\n }\n placeholder=\"$1\"\n />\n \n \n \n \n \n onChange({\n ...query!,\n attribute: { ...query.attribute, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query!,\n attribute: { ...query.attribute, name: e.currentTarget.value },\n })\n }\n placeholder=\"Enter name\"\n />\n \n \n
\n \n );\n});\n","import { filter, map } from 'lodash';\n\nimport { Observable, of, firstValueFrom } from 'rxjs';\n\nimport {\n DataSourceInstanceSettings,\n MetricFindValue,\n AnnotationQuery,\n ScopedVars,\n AnnotationEvent,\n DataFrame,\n DataQueryRequest,\n DataQueryResponse,\n} from '@grafana/data';\nimport { BackendSrv, getBackendSrv, getTemplateSrv, TemplateSrv, DataSourceWithBackend } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData, PiDataServer, PiwebapiInternalRsp, PiwebapiRsp } from './types';\nimport { metricQueryTransform } from 'helper';\n\nimport { PiWebAPIAnnotationsQueryEditor } from 'query/AnnotationsQueryEditor';\n\nexport class PiWebAPIDatasource extends DataSourceWithBackend {\n piserver: PiDataServer;\n afserver: PiDataServer;\n afdatabase: PiDataServer;\n piPointConfig: boolean;\n newFormatConfig: boolean;\n useUnitConfig: boolean;\n useExperimental: boolean;\n useStreaming: boolean;\n\n constructor(\n instanceSettings: DataSourceInstanceSettings,\n readonly templateSrv: TemplateSrv = getTemplateSrv(),\n private readonly backendSrv: BackendSrv = getBackendSrv()\n ) {\n super(instanceSettings);\n\n this.piserver = { name: (instanceSettings.jsonData || {}).piserver, webid: undefined };\n this.afserver = { name: (instanceSettings.jsonData || {}).afserver, webid: undefined };\n this.afdatabase = { name: (instanceSettings.jsonData || {}).afdatabase, webid: undefined };\n this.piPointConfig = instanceSettings.jsonData.pipoint || false;\n this.newFormatConfig = instanceSettings.jsonData.newFormat || false;\n this.useUnitConfig = instanceSettings.jsonData.useUnit || false;\n this.useExperimental = instanceSettings.jsonData.useExperimental || false;\n this.useStreaming = instanceSettings.jsonData.useStreaming || false;\n\n this.annotations = {\n QueryEditor: PiWebAPIAnnotationsQueryEditor,\n prepareQuery(anno: AnnotationQuery): PIWebAPIQuery | undefined {\n if (anno.target) {\n anno.target.queryType = 'Annotation';\n anno.target.isAnnotation = true;\n }\n return anno.target;\n },\n processEvents: (\n anno: AnnotationQuery,\n data: DataFrame[]\n ): Observable => {\n return of(this.eventFrameToAnnotation(anno, data));\n },\n };\n\n Promise.all([\n this.getDataServer(this.piserver.name).then((result: PiwebapiRsp) => (this.piserver.webid = result.WebId)),\n this.getAssetServer(this.afserver.name).then((result: PiwebapiRsp) => (this.afserver.webid = result.WebId)),\n this.getDatabase(\n this.afserver.name && this.afdatabase.name ? this.afserver.name + '\\\\' + this.afdatabase.name : undefined\n ).then((result: PiwebapiRsp) => (this.afdatabase.webid = result.WebId)),\n ]);\n }\n\n /**\n * This method overrides the applyTemplateVariables() method from the DataSourceWithBackend class.\n * It is responsible for replacing the template variables in the query configuration prior\n * to sending the query to the backend. Templated variables are not able to be used for alerts\n * or public facing dashboards.\n *\n * @param {PIWebAPIQuery} query - The raw query configuration from the frontend as defined in the query editor.\n * @param {ScopedVars} scopedVars - The template variables that are defined in the query editor and dashboard.\n * @returns - PIWebAPIQuery.\n *\n * @memberOf PiWebApiDatasource\n */\n applyTemplateVariables(query: PIWebAPIQuery, scopedVars: ScopedVars) {\n return {\n ...query,\n target: query.target ? this.templateSrv.replace(query.target, scopedVars) : '',\n };\n }\n\n /**\n * This method makes the query to the backend.\n *\n * @param {DataQueryRequest} options\n *\n * @memberOf PiWebApiDatasource\n */\n query(options: DataQueryRequest): Observable {\n if (options.targets.length === 1 && !!options.targets[0].isAnnotation) {\n return super.query(options);\n }\n\n const query = this.buildQueryParameters(options);\n if (query.targets.length <= 0) {\n return of({ data: [] });\n }\n\n return super.query(query);\n }\n\n /**\n * This method does the discovery of the AF Hierarchy and populates the query user interface segments.\n *\n * @param {any} query - Parses the query configuration and builds a PI Web API query.\n * @returns - Segment information.\n *\n * @memberOf PiWebApiDatasource\n */\n metricFindQuery(query: any, queryOptions: any): Promise {\n const ds = this;\n const querydepth = ['servers', 'databases', 'databaseElements', 'elements'];\n if (typeof query === 'string') {\n query = JSON.parse(query as string);\n }\n if (queryOptions.isPiPoint) {\n query.path = this.templateSrv.replace(query.path, queryOptions);\n } else {\n if (query.path === '') {\n query.type = querydepth[0];\n } else {\n query.path = this.templateSrv.replace(query.path, queryOptions); // replace variables in the path\n query.path = query.path.split(';')[0]; // if the attribute is in the path, let's remote it\n if (query.type !== 'attributes') {\n query.type = querydepth[Math.max(0, Math.min(query.path.split('\\\\').length, querydepth.length - 1))];\n }\n }\n query.path = query.path.replace(/\\{([^\\\\])*\\}/gi, (r: string) => r.substring(1, r.length - 2).split(',')[0]);\n }\n\n query.filter = query.filter ?? '*';\n query.max = query.max ?? 10000;\n\n if (query.type === 'servers') {\n return ds.afserver?.name\n ? ds\n .getAssetServer(ds.afserver.name)\n .then((result: PiwebapiRsp) => [result])\n .then(metricQueryTransform)\n : ds.getAssetServers().then(metricQueryTransform);\n } else if (query.type === 'databases' && !!query.afServerWebId) {\n return ds.getDatabases(query.afServerWebId, {}).then(metricQueryTransform);\n } else if (query.type === 'databases') {\n return ds\n .getAssetServer(query.path)\n .then((server) => ds.getDatabases(server.WebId ?? '', {}))\n .then(metricQueryTransform);\n } else if (query.type === 'databaseElements') {\n return ds\n .getDatabase(query.path)\n .then((db) =>\n ds.getDatabaseElements(db.WebId ?? '', {\n selectedFields: 'Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'elements') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getElements(element.WebId ?? '', {\n selectedFields:\n 'Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n nameFilter: query.filter,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'attributes') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getAttributes(element.WebId ?? '', {\n searchFullHierarchy: 'true',\n selectedFields:\n 'Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path',\n nameFilter: query.filter,\n maxCount: query.max,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'dataserver') {\n return ds.getDataServers().then(metricQueryTransform);\n } else if (query.type === 'pipoint') {\n return ds.piPointSearch(query.webId, query.pointName).then(metricQueryTransform);\n }\n return Promise.reject('Bad type');\n }\n\n /** PRIVATE SECTION */\n\n /**\n * Builds the PIWebAPI query parameters.\n *\n * @param {any} options - Grafana query and panel options.\n * @returns - PIWebAPI query parameters.\n *\n * @memberOf PiWebApiDatasource\n */\n private buildQueryParameters(options: DataQueryRequest) {\n options.targets = filter(options.targets, (target) => {\n if (!target || !target.target || target.attributes?.length === 0 || target.target === ';' || !!target.hide) {\n return false;\n }\n return !target.target.startsWith('Select AF');\n });\n\n if (options.maxDataPoints) {\n options.maxDataPoints = options.maxDataPoints > 30000 ? 30000 : options.maxDataPoints;\n }\n options.targets = map(options.targets, (target) => {\n const tar = {\n enableStreaming: target.enableStreaming,\n target: this.templateSrv.replace(target.target, options.scopedVars),\n elementPath: this.templateSrv.replace(target.elementPath, options.scopedVars),\n attributes: map(target.attributes, (att) => {\n if (att.value) {\n this.templateSrv.replace(att.value.value, options.scopedVars);\n }\n return att;\n }),\n segments: map(target.segments, (att) => {\n if (att.value) {\n this.templateSrv.replace(att.value.value, options.scopedVars);\n }\n return att;\n }),\n isAnnotation: !!target.isAnnotation,\n display: !!target.display ? this.templateSrv.replace(target.display, options.scopedVars) : undefined,\n refId: target.refId,\n hide: target.hide,\n interpolate: !!target.interpolate\n ? {\n ...target.interpolate,\n interval: this.templateSrv.replace(target.interpolate.interval, options.scopedVars),\n }\n : { enable: false },\n useLastValue: target.useLastValue || { enable: false },\n useUnit: target.useUnit || { enable: false },\n recordedValues: !!target.recordedValues\n ? {\n ...target.recordedValues,\n interval: this.templateSrv.replace(target.recordedValues.maxNumber, options.scopedVars),\n }\n : { enable: false },\n digitalStates: target.digitalStates || { enable: false },\n webid: target.webid ?? '',\n regex: target.regex || { enable: false },\n expression: target.expression || '',\n summary: target.summary || { types: [] },\n startTime: options.range.from,\n endTime: options.range.to,\n isPiPoint: !!target.isPiPoint,\n scopedVars: options.scopedVars,\n };\n\n if (tar.expression) {\n tar.expression = this.templateSrv.replace(tar.expression, options.scopedVars);\n }\n\n if (tar.summary.types !== undefined) {\n tar.summary.types = filter(tar.summary.types, (item) => {\n return item !== undefined && item !== null && item !== '';\n });\n }\n\n return tar;\n });\n\n return options;\n }\n\n /**\n * Localize the eventFrame dataFrame records to Grafana Annotations.\n * @param {any} annon - The annotation object.\n * @param {any} data - The dataframe recrords.\n * @returns - Grafana Annotation\n *\n * @memberOf PiWebApiDatasource\n */\n private eventFrameToAnnotation(annon: AnnotationQuery, data: DataFrame[]): AnnotationEvent[] {\n const annotationOptions = annon.target!;\n const events: AnnotationEvent[] = [];\n const currentLocale = Intl.DateTimeFormat().resolvedOptions().locale;\n\n data.forEach((d: DataFrame) => {\n let values = this.transformDataFrameToMap(d);\n for (let i = 0; i < values['time'].length; i++) {\n // replace Dataframe name using Regex\n let title = values['title'][i];\n if (annotationOptions.regex && annotationOptions.regex.enable) {\n title = title.replace(new RegExp(annotationOptions.regex.search), annotationOptions.regex.replace);\n }\n\n // test if timeEnd is negative and if so, set it to null\n if (values['timeEnd'][i] < 0) {\n values['timeEnd'][i] = null;\n }\n\n // format the text and localize the dates to browser locale\n let text = 'Tag: ' + title;\n if (annotationOptions.attribute && annotationOptions.attribute.enable) {\n text += values['attributeText'][i];\n }\n text += '
Start: ' + new Date(values['time'][i]).toLocaleString(currentLocale) + '
End: ';\n\n if (values['timeEnd'][i]) {\n text += new Date(values['timeEnd'][i]).toLocaleString(currentLocale);\n } else {\n text += 'Eventframe is open';\n }\n\n const event: AnnotationEvent = {\n time: values['time'][i],\n timeEnd: !!annotationOptions.showEndTime ? values['timeEnd'][i] : undefined,\n title: title,\n id: values['id'][i],\n text: text,\n tags: ['OSISoft PI'],\n };\n\n events.push(event);\n }\n });\n return events;\n }\n\n /**\n *\n */\n private transformDataFrameToMap(dataFrame: DataFrame): Record {\n const map: Record = {};\n\n dataFrame.fields.forEach((field) => {\n map[field.name] = field.values.toArray();\n });\n\n return map;\n }\n\n /**\n * Abstraction for calling the PI Web API REST endpoint\n *\n * @param {any} path - the path to append to the base server URL.\n * @returns - The full URL.\n *\n * @memberOf PiWebApiDatasource\n */\n private restGet(path: string): Promise {\n const observable = this.backendSrv.fetch({\n url: `/api/datasources/${this.id}/resources${path}`,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n });\n\n return firstValueFrom(observable).then((response: any) => {\n return response as PiwebapiInternalRsp;\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.data.Items ?? []);\n }\n private getDataServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/dataservers?name=' + name).then((response) => response.data);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.data.Items ?? []);\n }\n getAssetServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/assetservers?path=\\\\\\\\' + name).then((response) => response.data);\n }\n getDatabase(path: string | undefined): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/assetdatabases?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getDatabases(serverId: string, options?: any): Promise {\n if (!serverId) {\n return Promise.resolve([]);\n }\n return this.restGet('/assetservers/' + serverId + '/assetdatabases').then((response) => response.data.Items ?? []);\n }\n getElement(path: string): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/elements?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getEventFrameTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'EventFrame');\n });\n }\n getElementTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'Element');\n });\n }\n\n /**\n * @description\n * Get the child attributes of the current resource.\n * GET attributes/{webId}/attributes\n * @param {string} elementId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.nameFilter - The name query string used for finding attributes. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned attributes must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned attributes must be members of this template. The default is no template filter.\n * @param {string} options.valueType - Specify that returned attributes' value type must be the given value type. The default is no value type filter.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include attributes nested further than the immediate attributes of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {string} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {string} options.showExcluded - Specified if the search should include attributes with the Excluded property set. The default is 'false'.\n * @param {string} options.showHidden - Specified if the search should include attributes with the Hidden property set. The default is 'false'.\n * @param {string} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getAttributes(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/attributes' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET assetdatabases/{webId}/elements\n * @param {string} databaseId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getDatabaseElements(databaseId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/assetdatabases/' + databaseId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET elements/{webId}/elements\n * @param {string} databaseId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getElements(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * Retrieve a list of points on a specified Data Server.\n *\n * @param {string} serverId - The ID of the server. See WebID for more information.\n * @param {string} nameFilter - A query string for filtering by point name. The default is no filter. *, ?, [ab], [!ab]\n */\n private piPointSearch(serverId: string, nameFilter: string): Promise {\n let filter1 = this.templateSrv.replace(nameFilter);\n let filter2 = `${filter1}`;\n let doFilter = false;\n if (filter1 !== nameFilter) {\n const regex = /\\{(\\w|,)+\\}/gs;\n let m;\n while ((m = regex.exec(filter1)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n if (groupIndex === 0) {\n filter1 = filter1.replace(match, match.replace('{', '(').replace('}', ')').replace(',', '|'));\n filter2 = filter2.replace(match, '*');\n doFilter = true;\n }\n });\n }\n }\n return this.restGet('/dataservers/' + serverId + '/points?maxCount=50&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results.data?.Items) {\n return doFilter ? results.data.Items.filter((item) => item.Name?.match(filter1)) : results.data.Items;\n }\n return [];\n });\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { PIWebAPIConfigEditor } from './config/ConfigEditor';\nimport { PIWebAPIQueryEditor } from './query/QueryEditor';\nimport { PiWebAPIDatasource } from './datasource';\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n PiWebAPIDatasource\n)\n .setQueryEditor(PIWebAPIQueryEditor)\n .setConfigEditor(PIWebAPIConfigEditor);\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__781__","__WEBPACK_EXTERNAL_MODULE__531__","__WEBPACK_EXTERNAL_MODULE__7__","__WEBPACK_EXTERNAL_MODULE__241__","__WEBPACK_EXTERNAL_MODULE__959__","__WEBPACK_EXTERNAL_MODULE__269__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","FormField","LegacyForms","coerceOptions","options","jsonData","url","PIWebAPIConfigEditor","PureComponent","render","originalOptions","this","props","div","DataSourceHttpSettings","defaultUrl","dataSourceConfig","onChange","onHttpOptionsChange","showAccessOptions","h3","className","InlineField","label","labelWidth","InlineSwitch","pipoint","onPiPointChange","newFormat","onNewFormatChange","useUnit","onUseUnitChange","useExperimental","onUseExperimentalChange","useStreaming","onUseStreamingChange","inputWidth","onPIServerChange","piserver","placeholder","onAFServerChange","afserver","onAFDatabaseChange","afdatabase","event","onOptionsChange","target","checked","QueryField","tooltip","children","InlineFormLabel","width","QueryRowTerminator","QueryInlineField","QueryEditorRow","QueryRawInlineField","QueryRawEditorRow","defaultQuery","attributes","segments","regex","enable","summary","types","basis","interval","nodata","expression","interpolate","useLastValue","recordedValues","digitalStates","enableStreaming","isPiPoint","QueryEditorModeSwitcher","isRaw","isModalOpen","setModalOpen","useState","useEffect","Button","aria-label","icon","variant","type","onClick","ConfirmModal","isOpen","title","body","confirmText","dismissText","onConfirm","onDismiss","metricQueryTransform","response","map","item","text","Name","expandable","HasChildren","Path","split","length","Items","WebId","LABEL_WIDTH","MIN_ATTR_INPUT_WIDTH","REMOVE_LABEL","CustomLabelComponent","Icon","name","PIWebAPIQueryEditor","isValueEmpty","calcBasisValueChanged","segment","metricsQuery","query","getCalcBasisSegments","calculationBasis","calcNoDataValueChanged","getNoDataSegments","noDataReplacement","onSummaryValueChanged","index","summaries","state","slice","splice","setState","stateCallback","getSummarySegments","summaryTypes","filter","s","indexOf","unshift","removeSummary","part","onSummaryAction","selectableValue","push","summarySegment","removeAttribute","attributeChangeValue","onAttributeAction","getSegmentPathUpTo","arr","reduce","result","startsWith","checkAttributeSegments","data","datasource","ctrl","findQuery","path","metricFindQuery","assign","request","scopedVars","then","attributesResponse","validAttributes","each","attribute","substring","filteredAttributes","attrib","changedValue","templateSrv","replace","availableAttributes","catch","err","error","message","checkPiPointSegments","webId","getSelectedPIServer","pointName","webID","piServer","forEach","parts","textEditorChanged","splitAttributes","splitElements","_","match","getElementSegments","elements","updateArray","rawQuery","checkAfServer","queryProps","onRunQuery","defaults","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","SegmentAsync","Component","onSegmentChange","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","onAttributeChange","getAttributeSegmentsAF","attributeSegment","useUnitConfig","maxNumber","parseInt","search","constructor","super","calculationBasisSegment","noDataReplacementSegment","segmentChangeValue","Promise","resolve","remove","currentSegment","afServerWebId","items","altSegments","variables","getVariables","variable","attributeText","forOwn","val","buildFromTarget","segmentsArray","attributesArray","console","log","summariesArray","cb","scopedVarsDone","componentDidMount","initialLoad","componentDidUpdate","force","_segmentsArray","e","elementPath","tr","join","parseRawQuery","isValidQuery","trim","targetSplit","queryChange","bind","PiWebAPIAnnotationsQueryEditor","memo","annotation","afWebId","setAfWebId","database","setDatabase","getValue","getAssetServer","AsyncSelect","getDatabases","dbs","loadingMessage","template","defaultOptions","getEventFrameTemplates","templ","showEndTime","currentTarget","categoryName","nameFilter","PiWebAPIDatasource","DataSourceWithBackend","applyTemplateVariables","targets","isAnnotation","buildQueryParameters","of","queryOptions","ds","querydepth","JSON","parse","Math","max","min","getAssetServers","server","getDatabase","db","getDatabaseElements","selectedFields","getElement","element","getElements","getAttributes","searchFullHierarchy","maxCount","getDataServers","piPointSearch","reject","hide","maxDataPoints","tar","att","refId","webid","startTime","range","from","endTime","to","annon","annotationOptions","events","currentLocale","Intl","DateTimeFormat","resolvedOptions","locale","values","transformDataFrameToMap","i","RegExp","Date","toLocaleString","time","timeEnd","id","tags","dataFrame","fields","field","toArray","observable","backendSrv","fetch","method","headers","firstValueFrom","restGet","getDataServer","serverId","databaseId","InstanceType","getElementTemplates","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","results","instanceSettings","getTemplateSrv","getBackendSrv","newFormatConfig","annotations","QueryEditor","prepareQuery","anno","queryType","processEvents","eventFrameToAnnotation","all","plugin","DataSourcePlugin","setQueryEditor","setConfigEditor"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"module.js","mappings":"oIAAAA,EAAOC,QAAUC,C,UCAjBF,EAAOC,QAAUE,C,QCAjBH,EAAOC,QAAUG,C,UCAjBJ,EAAOC,QAAUI,C,UCAjBL,EAAOC,QAAUK,C,UCAjBN,EAAOC,QAAUM,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaV,QAGrB,IAAID,EAASQ,EAAyBE,GAAY,CAGjDT,QAAS,CAAC,GAOX,OAHAY,EAAoBH,GAAUV,EAAQA,EAAOC,QAASQ,GAG/CT,EAAOC,OACf,CCrBAQ,EAAoBK,EAAKd,IACxB,IAAIe,EAASf,GAAUA,EAAOgB,WAC7B,IAAOhB,EAAiB,QACxB,IAAM,EAEP,OADAS,EAAoBQ,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdN,EAAoBQ,EAAI,CAAChB,EAASkB,KACjC,IAAI,IAAIC,KAAOD,EACXV,EAAoBY,EAAEF,EAAYC,KAASX,EAAoBY,EAAEpB,EAASmB,IAC5EE,OAAOC,eAAetB,EAASmB,EAAK,CAAEI,YAAY,EAAMC,IAA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L,MAAMZ,GAAyB5I,KAAKgC,WAAWqR,MAAQzK,EAAO5C,SAEpE,ECjEK,MAAMmR,EAAS,IAAIC,EAAAA,iBACxBlG,GAECmG,eAAe9Q,GACf+Q,gBAAgB1X,G","sources":["webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/data\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/runtime\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/ui\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"lodash\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"react\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"rxjs\"","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/bootstrap","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/compat get default export","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/define property getters","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/hasOwnProperty shorthand","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/make namespace object","webpack://gridprotectionalliance-osisoftpi-datasource/./config/ConfigEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./components/Forms.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./types.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./components/QueryEditorModeSwitcher.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./helper.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./query/QueryEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./query/AnnotationsQueryEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./datasource.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./module.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__781__;","module.exports = __WEBPACK_EXTERNAL_MODULE__531__;","module.exports = __WEBPACK_EXTERNAL_MODULE__7__;","module.exports = __WEBPACK_EXTERNAL_MODULE__241__;","module.exports = __WEBPACK_EXTERNAL_MODULE__959__;","module.exports = __WEBPACK_EXTERNAL_MODULE__269__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { ChangeEvent, PureComponent } from 'react';\nimport { LegacyForms, DataSourceHttpSettings, InlineField, InlineSwitch } from '@grafana/ui';\nimport { DataSourcePluginOptionsEditorProps, DataSourceJsonData, DataSourceSettings } from '@grafana/data';\nimport { PIWebAPIDataSourceJsonData } from '../types';\n\nconst { FormField } = LegacyForms;\n\ninterface Props extends DataSourcePluginOptionsEditorProps {}\n\nconst coerceOptions = (\n options: DataSourceSettings\n): DataSourceSettings => {\n return {\n ...options,\n jsonData: {\n ...options.jsonData,\n url: options.url,\n },\n };\n};\n\ninterface State {}\n\nexport class PIWebAPIConfigEditor extends PureComponent {\n onPIServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFDatabaseChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afdatabase: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onHttpOptionsChange = (options: DataSourceSettings) => {\n const { onOptionsChange } = this.props;\n onOptionsChange(coerceOptions(options));\n };\n\n onPiPointChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.checked ? options.jsonData.piserver : '',\n pipoint: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onNewFormatChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n newFormat: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseUnitChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useUnit: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseExperimentalChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useExperimental : event.target.checked,\n useStreaming : event.target.checked ? options.jsonData.useStreaming : false,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseStreamingChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useStreaming: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n render() {\n const { options: originalOptions } = this.props;\n const options = coerceOptions(originalOptions);\n\n return (\n
\n \n\n

Custom Configuration

\n\n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n \n \n \n
\n {options.jsonData.useExperimental && (\n
\n \n \n \n
\n )}\n
\n\n

PI/AF Connection Details

\n\n
\n {options.jsonData.pipoint && (\n
\n \n
\n )}\n
\n \n
\n
\n \n
\n
\n
\n );\n }\n}\n","import React, { InputHTMLAttributes, FunctionComponent } from 'react';\nimport { InlineFormLabel } from '@grafana/ui';\n\nexport interface Props extends InputHTMLAttributes {\n label: string;\n tooltip?: string;\n labelWidth?: number;\n children?: React.ReactNode;\n queryEditor?: JSX.Element;\n}\n\nexport const QueryField: FunctionComponent> = ({ label, labelWidth = 12, tooltip, children }) => (\n <>\n \n {label}\n \n {children}\n \n);\n\nexport const QueryRowTerminator = () => {\n return (\n
\n
\n
\n );\n};\n\nexport const QueryInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryEditorRow = (props: Partial) => {\n return (\n
\n {props.children}\n \n
\n );\n};\n\nexport const QueryRawInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryRawEditorRow = (props: Partial) => {\n return <>{props.children};\n};\n","import { DataQuery } from '@grafana/schema';\nimport { DataSourceJsonData, SelectableValue } from '@grafana/data';\n\nexport interface PiwebapiElementPath {\n path: string;\n variable: string;\n}\n\nexport interface PiwebapiInternalRsp {\n data: PiwebapiRsp;\n status: number;\n url: string;\n}\n\nexport interface PiwebapiRsp {\n Name?: string;\n InstanceType?: string;\n Items?: PiwebapiRsp[];\n WebId?: string;\n HasChildren?: boolean;\n Type?: string;\n DefaultUnitsName?: string;\n Description?: string;\n Path?: string;\n}\n\nexport interface PiDataServer {\n name: string | undefined;\n webid: string | undefined;\n}\n\nexport interface PIWebAPISelectableValue {\n webId?: string;\n value?: string;\n type?: string;\n expandable?: boolean;\n}\n\nexport interface PIWebAPIAnnotationsQuery extends DataQuery {\n target: string;\n}\n\nexport interface PIWebAPIQuery extends DataQuery {\n target?: string;\n elementPath?: string;\n attributes?: Array>;\n segments?: any[];\n isPiPoint?: boolean;\n isAnnotation?: boolean;\n webid?: string;\n display?: any;\n interpolate?: any;\n recordedValues?: any;\n digitalStates?: any;\n enableStreaming: any;\n useLastValue?: any;\n useUnit?: any;\n regex?: any;\n summary?: {nodata?: string, types?: any[], basis?: string, interval?: string};\n expression?: string;\n rawQuery?: boolean;\n query?: string;\n // annotations items\n database?: PiwebapiRsp;\n template?: PiwebapiRsp;\n showEndTime?: boolean;\n attribute?: any;\n nameFilter?: string;\n categoryName?: string;\n}\n\nexport const defaultQuery: Partial = {\n target: ';',\n attributes: [],\n segments: [],\n regex: { enable: false },\n summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false },\n digitalStates: { enable: false },\n enableStreaming: { enable: false },\n useUnit: { enable: false },\n isPiPoint: false,\n};\n\n/**\n * These are options configured for each DataSource instance\n */\nexport interface PIWebAPIDataSourceJsonData extends DataSourceJsonData {\n url?: string;\n access?: string;\n piserver?: string;\n afserver?: string;\n afdatabase?: string;\n pipoint?: boolean;\n newFormat?: boolean;\n useUnit?: boolean;\n useExperimental?: boolean;\n useStreaming?: boolean;\n}\n\n/**\n * Value that is used in the backend, but never sent over HTTP to the frontend\n */\nexport interface PIWebAPISecureJsonData {\n apiKey?: string;\n}\n","import React, { useEffect, useState } from 'react';\nimport { Button, ConfirmModal } from '@grafana/ui';\n\ntype Props = {\n isRaw: boolean;\n onChange: (newIsRaw: boolean) => void;\n};\n\nexport const QueryEditorModeSwitcher = ({ isRaw, onChange }: Props): JSX.Element => {\n const [isModalOpen, setModalOpen] = useState(false);\n\n useEffect(() => {\n // if the isRaw changes, we hide the modal\n setModalOpen(false);\n }, [isRaw]);\n\n if (isRaw) {\n return (\n <>\n {\n // we show the are-you-sure modal\n setModalOpen(true);\n }}\n >\n {\n onChange(false);\n }}\n onDismiss={() => {\n setModalOpen(false);\n }}\n />\n \n );\n } else {\n return (\n {\n onChange(true);\n }}\n >\n );\n }\n};\n","import { each, map } from 'lodash';\r\n\r\nimport {\r\n AnnotationQuery,\r\n DataFrame,\r\n TableData,\r\n MetricFindValue,\r\n Field,\r\n toDataFrame,\r\n} from '@grafana/data';\r\n\r\nimport { PiwebapiElementPath, PiwebapiRsp, PIWebAPIQuery } from 'types';\r\n\r\nexport function parseRawQuery(tr: string): any {\r\n const splitAttributes = tr.split(';');\r\n const splitElements = splitAttributes[0].split('\\\\');\r\n\r\n // remove element hierarchy from attribute collection\r\n splitAttributes.splice(0, 1);\r\n\r\n let attributes: any[] = [];\r\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\r\n const elementPath: string = splitElements.join('\\\\');\r\n each(splitAttributes, function (item, index) {\r\n if (item !== '') {\r\n attributes.push({\r\n label: item,\r\n value: {\r\n value: item,\r\n expandable: false,\r\n },\r\n });\r\n }\r\n });\r\n\r\n return { attributes, elementPath };\r\n }\r\n\r\n return { attributes, elementPath: null };\r\n}\r\n\r\nexport function lowerCaseFirstLetter(string: string): string {\r\n return string.charAt(0).toLocaleLowerCase() + string.slice(1);\r\n}\r\n\r\n/**\r\n * Builds the Grafana metric segment for use on the query user interface.\r\n *\r\n * @param {any} response - response from PI Web API.\r\n * @returns - Grafana metric segment.\r\n *\r\n * @memberOf PiWebApiDatasource\r\n */\r\nexport function metricQueryTransform(response: PiwebapiRsp[]): MetricFindValue[] {\r\n return map(response, (item) => {\r\n return {\r\n text: item.Name,\r\n expandable:\r\n item.HasChildren === undefined || item.HasChildren === true || (item.Path ?? '').split('\\\\').length <= 3,\r\n HasChildren: item.HasChildren,\r\n Items: item.Items ?? [],\r\n Path: item.Path,\r\n WebId: item.WebId,\r\n } as MetricFindValue;\r\n });\r\n}\r\n\r\n/**\r\n * Check if all items are selected.\r\n *\r\n * @param {any} current the current variable selection\r\n * @return {boolean} true if all value is selected, false otherwise\r\n */\r\nexport function isAllSelected(current: any): boolean {\r\n if (!current) {\r\n return false;\r\n }\r\n if (Array.isArray(current.text)) {\r\n return current.text.indexOf('All') >= 0;\r\n }\r\n return current.text === 'All';\r\n}\r\n\r\nexport function processAnnotationQuery(annon: AnnotationQuery,data: DataFrame[]): DataFrame[] {\r\n let processedFrames: DataFrame[] = [];\r\n \r\n data.forEach((d: DataFrame) => {\r\n d.fields.forEach((f: Field) => {\r\n\r\n // check if the label has been set, if it hasn't been set then the eventframe annotation is not valid. \r\n if (!f.labels) { \r\n return \r\n }\r\n\r\n if (!('eventframe' in f.labels)) {\r\n return;\r\n }\r\n\r\n let attribute = 'attribute' in f.labels\r\n\r\n // Check whether f.values is an array or not to allow for each.\r\n // Check whether f.values is an array or not to allow for each.\r\n if (Array.isArray(f.values)) {\r\n f.values.forEach((value: any) => {\r\n\r\n if (attribute) {\r\n let annotation = value['1'].Content\r\n let valueData: any[] = []\r\n for (let i = 2; i in value; i++) {\r\n valueData.push(value[i].Content.Items)\r\n }\r\n\r\n const processedFrame = convertToTableData(annotation.Items!, valueData).map((r) => {\r\n return toDataFrame(r)});\r\n processedFrames = processedFrames.concat(processedFrame);\r\n } else {\r\n let annotation = value['1'].Content\r\n const processedFrame = convertToTableData(annotation.Items!).map((r) => {\r\n return toDataFrame(r)});\r\n processedFrames = processedFrames.concat(processedFrame);\r\n }\r\n });\r\n } \r\n });\r\n });\r\n return processedFrames;\r\n}\r\n\r\nexport function convertToTableData(items: any[], valueData?: any[]): TableData[] {\r\n const response: TableData[] = items.map((item: any, index: number) => {\r\n const columns = [{ text: 'StartTime' }, { text: 'EndTime' }];\r\n const rows = [item.StartTime, item.EndTime];\r\n if (valueData) {\r\n for (let attributeIndex = 0; attributeIndex < valueData.length; attributeIndex++) {\r\n let attributeData = valueData[attributeIndex]\r\n let eventframeAributeData = attributeData[index].Content.Items\r\n eventframeAributeData.forEach((attribute: any) => {\r\n columns.push({ text: attribute.Name });\r\n rows.push(String(attribute.Value.Value ? attribute.Value.Value.Name || attribute.Value.Value.Value || attribute.Value.Value : ''));\r\n });\r\n }\r\n }\r\n\r\n return {\r\n name: item.Name,\r\n columns,\r\n rows: [rows],\r\n };\r\n });\r\n return response;\r\n}\r\n\r\n/**\r\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\r\n *\r\n * @param {any} item - 'Item' object from PIWebAPI\r\n * @param {any} noDataReplacementMode - String state of how to replace 'No Data'\r\n * @param {any} grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns perviousValue - {any} Grafana value (value only).\r\n *\r\n */\r\nexport function noDataReplace(\r\n item: any,\r\n noDataReplacementMode: any,\r\n grafanaDataPoint: any[]\r\n): {\r\n grafanaDataPoint: any[];\r\n previousValue: any;\r\n drop: boolean;\r\n} {\r\n let previousValue = null;\r\n let drop = false;\r\n if (!item.Good || item.Value === 'No Data' || (item.Value?.Name && item.Value?.Name === 'No Data')) {\r\n if (noDataReplacementMode === 'Drop') {\r\n drop = true;\r\n } else if (noDataReplacementMode === '0') {\r\n grafanaDataPoint[0] = 0;\r\n } else if (noDataReplacementMode === 'Keep') {\r\n // Do nothing keep\r\n } else if (noDataReplacementMode === 'Null') {\r\n grafanaDataPoint[0] = null;\r\n } else if (noDataReplacementMode === 'Previous' && previousValue !== null) {\r\n grafanaDataPoint[0] = previousValue;\r\n }\r\n } else {\r\n previousValue = item.Value;\r\n }\r\n return { grafanaDataPoint, previousValue, drop };\r\n}\r\n\r\n/**\r\n * Check if the value is a number.\r\n *\r\n * @param {any} number the value to check\r\n * @returns {boolean} true if the value is a number, false otherwise\r\n */\r\nexport function checkNumber(number: any): boolean {\r\n return typeof number === 'number' && !Number.isNaN(number) && Number.isFinite(number);\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path.\r\n *\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getLastPath(path: string): string {\r\n let splitPath = path.split('|');\r\n if (splitPath.length === 0) {\r\n return '';\r\n }\r\n splitPath = splitPath[0].split('\\\\');\r\n return splitPath.length === 0 ? '' : splitPath.pop() ?? '';\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path plus variable.\r\n *\r\n * @param {PiwebapiElementPath[]} elementPathArray array of element paths\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getPath(elementPathArray: PiwebapiElementPath[], path: string): string {\r\n if (!path || elementPathArray.length === 0) {\r\n return '';\r\n }\r\n const splitStr = getLastPath(path);\r\n const foundElement = elementPathArray.find((e) => path.indexOf(e.path) >= 0)?.variable;\r\n return foundElement ? foundElement + '|' + splitStr : splitStr;\r\n}\r\n\r\n/**\r\n * Replace calculation dot in expression with PI point name.\r\n *\r\n * @param {boolean} replace - is pi point and calculation.\r\n * @param {PiwebapiRsp} webid - Pi web api response object.\r\n * @param {string} url - original url.\r\n * @returns Modified url\r\n */\r\nexport function getFinalUrl(replace: boolean, webid: PiwebapiRsp, url: string) {\r\n const newUrl = replace ? url.replace(/'\\.'/g, `'${webid.Name}'`) : url;\r\n return newUrl;\r\n}\r\n","import { each, filter, forOwn, join, reduce, map, slice, remove, defaults } from 'lodash';\n\nimport React, { PureComponent, ChangeEvent } from 'react';\nimport { Icon, InlineField, InlineFieldRow, InlineSwitch, Input, SegmentAsync, Segment } from '@grafana/ui';\nimport { QueryEditorProps, SelectableValue, TypedVariableModel } from '@grafana/data';\n\nimport { PiWebAPIDatasource } from '../datasource';\nimport { QueryInlineField, QueryRawInlineField, QueryRowTerminator } from '../components/Forms';\nimport { PIWebAPISelectableValue, PIWebAPIDataSourceJsonData, PIWebAPIQuery, defaultQuery } from '../types';\nimport { QueryEditorModeSwitcher } from 'components/QueryEditorModeSwitcher';\nimport { parseRawQuery } from 'helper';\n\nconst LABEL_WIDTH = 24;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n segments: Array>;\n attributes: Array>;\n summaries: Array>;\n attributeSegment: SelectableValue;\n summarySegment: SelectableValue;\n calculationBasisSegment: SelectableValue;\n noDataReplacementSegment: SelectableValue;\n}\n\ntype Props = QueryEditorProps;\n\nconst REMOVE_LABEL = '-REMOVE-';\n\nconst CustomLabelComponent = (props: any) => {\n if (props.value) {\n return (\n
\n {props.label ?? '--no label--'}\n
\n );\n }\n return (\n \n \n \n );\n};\n\nexport class PIWebAPIQueryEditor extends PureComponent {\n error: any;\n piServer: any[] = [];\n availableAttributes: any = {};\n summaryTypes: string[];\n calculationBasis: string[];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n segments: [],\n attributes: [],\n summaries: [],\n attributeSegment: {},\n summarySegment: {},\n calculationBasisSegment: {},\n noDataReplacementSegment: {},\n };\n\n constructor(props: any) {\n super(props);\n this.onSegmentChange = this.onSegmentChange.bind(this);\n this.calcBasisValueChanged = this.calcBasisValueChanged.bind(this);\n this.calcNoDataValueChanged = this.calcNoDataValueChanged.bind(this);\n this.onSummaryAction = this.onSummaryAction.bind(this);\n this.onSummaryValueChanged = this.onSummaryValueChanged.bind(this);\n this.onAttributeAction = this.onAttributeAction.bind(this);\n this.onAttributeChange = this.onAttributeChange.bind(this);\n\n this.summaryTypes = [\n // 'None', // A summary type is not specified.\n 'Total', // A totalization over the time range.\n 'Average', // The average value over the time range.\n 'Minimum', // The minimum value over the time range.\n 'Maximum', // The maximum value over the time range.\n 'Range', // The range value over the time range (minimum-maximum).\n 'StdDev', // The standard deviation over the time range.\n 'PopulationStdDev', // The population standard deviation over the time range.\n 'Count', // The sum of event count over the time range when calculation basis is event weighted. The sum of event time duration over the time range when calculation basis is time weighted.\n 'PercentGood', // Percent of data with good value during the calculation period. For time weighted calculations, the percentage is based on time. For event weighted calculations, the percent is based on event count.\n 'All', // A convenience for requesting all available summary calculations.\n 'AllForNonNumeric', // A convenience for requesting all available summary calculations for non-numeric data.\n ];\n\n this.calculationBasis = [\n 'TimeWeighted', // Weight the values in the calculation by the time over which they apply. Interpolation is based on whether the attribute is stepped. Interpolated events are generated at the boundaries if necessary.\n 'EventWeighted', // Evaluate values with equal weighting for each event. No interpolation is done. There must be at least one event within the time range to perform a successful calculation. Two events are required for standard deviation. In handling events at the boundary of the calculation, the AFSDK uses following rules:\n 'TimeWeightedContinuous', // Apply weighting as in TimeWeighted, but do all interpolation between values as if they represent continuous data, (standard interpolation) regardless of whether the attribute is stepped.\n 'TimeWeightedDiscrete', // Apply weighting as in TimeWeighted but interpolation between values is performed as if they represent discrete, unrelated values (stair step plot) regardless of the attribute is stepped.\n 'EventWeightedExcludeMostRecentEvent', // The calculation behaves the same as _EventWeighted_, except in the handling of events at the boundary of summary intervals in a multiple intervals calculation. Use this option to prevent events at the intervals boundary from being double count at both intervals. With this option, events at the end time (most recent time) of an interval is not used in that interval.\n 'EventWeightedExcludeEarliestEvent', // Similar to the option _EventWeightedExcludeMostRecentEvent_. Events at the start time(earliest time) of an interval is not used in that interval.\n 'EventWeightedIncludeBothEnds', // Events at both ends of the interval boundaries are included in the event weighted calculation.\n ];\n\n this.noDataReplacement = [\n 'Null', // replace with nulls\n 'Drop', // drop items\n 'Previous', // use previous value if available\n '0', // replace with 0\n 'Keep', // Keep value\n ];\n }\n\n // is selected segment empty\n isValueEmpty(value: PIWebAPISelectableValue | undefined) {\n return !value || !value.value || !value.value.length || value.value === REMOVE_LABEL;\n }\n\n segmentChangeValue = (segments: Array>) => {\n const query = this.props.query;\n this.setState({ segments }, () => this.onChange({ ...query, segments }));\n };\n\n attributeChangeValue = (attributes: Array>): Promise => {\n const query = this.props.query;\n return new Promise((resolve) => this.setState({ attributes }, () => {\n this.onChange({ ...query, attributes })\n resolve();\n }));\n };\n\n // summary calculation basis change event\n calcBasisValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n if (summary) {\n summary.basis = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, summary });\n }\n // get summary calculation basis user interface segments\n getCalcBasisSegments() {\n const segments = map(this.calculationBasis, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // no data change event\n calcNoDataValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n if (summary) {\n summary.nodata = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, summary });\n }\n // get no data user interface segments\n getNoDataSegments() {\n const segments = map(this.noDataReplacement, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // summary query change event\n onSummaryValueChanged(item: SelectableValue, index: number) {\n const summaries = this.state.summaries.slice(0) as Array>;\n summaries[index] = item;\n if (this.isValueEmpty(item.value)) {\n summaries.splice(index, 1);\n }\n this.setState({ summaries }, this.stateCallback);\n }\n // get the list of summaries available\n getSummarySegments() {\n const summaryTypes = filter(this.summaryTypes, (type) => {\n return this.state.summaries.map((s) => s.value?.value).indexOf(type) === -1;\n });\n\n const segments = map(summaryTypes, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n }\n\n // remove a summary from the user interface and the query\n removeSummary(part: SelectableValue) {\n const summaries = filter(this.state.summaries, (item: SelectableValue) => {\n return item !== part;\n });\n this.setState({ summaries });\n }\n // add a new summary to the query\n onSummaryAction(item: SelectableValue) {\n const summaries = this.state.summaries.slice(0) as Array>;\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: true,\n },\n };\n summaries.push(selectableValue);\n }\n this.setState({ summarySegment: {}, summaries }, this.stateCallback);\n }\n\n // remove an attribute from the query\n removeAttribute(part: SelectableValue) {\n const attributes = filter(this.state.attributes, (item: SelectableValue) => {\n return item !== part;\n });\n this.attributeChangeValue(attributes);\n }\n // add an attribute to the query\n onAttributeAction(item: SelectableValue) {\n const { query } = this.props;\n const attributes = this.state.attributes.slice(0);\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: !query.isPiPoint,\n },\n };\n attributes.push(selectableValue);\n }\n this.attributeChangeValue(attributes);\n }\n\n // pi point change event\n onPiPointChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n if (item.label === REMOVE_LABEL) {\n remove(attributes, (value, n) => n === index);\n } else {\n // set current value\n attributes[index] = item;\n }\n\n this.checkPiPointSegments(item, attributes);\n };\n // attribute change event\n onAttributeChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n // ignore if no change\n if (attributes[index].label === item.value?.value) {\n return;\n }\n\n // set current value\n attributes[index] = item;\n\n this.checkAttributeSegments(attributes, this.state.segments);\n };\n // segment change\n onSegmentChange = (item: SelectableValue, index: number) => {\n const { query } = this.props;\n let segments = this.state.segments.slice(0);\n\n // ignore if no change\n if (segments[index].label === item.value?.value) {\n return;\n }\n\n // reset attributes list\n this.setState({ attributes: [] }, () => {\n if (item.label === REMOVE_LABEL) {\n segments = slice(segments, 0, index);\n this.checkAttributeSegments([], segments).then(() => {\n if (segments.length === 0) {\n segments.push({\n label: '',\n });\n } else if (!!segments[segments.length - 1].value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n if (query.isPiPoint) {\n this.piServer = [];\n }\n this.segmentChangeValue(segments);\n });\n return;\n }\n\n // set current value\n segments[index] = item;\n\n // Accept only one PI server\n if (query.isPiPoint) {\n this.piServer.push(item);\n this.segmentChangeValue(segments);\n return;\n }\n\n // changed internal selection\n if (index < segments.length - 1) {\n segments = slice(segments, 0, index + 1);\n }\n this.checkAttributeSegments([], segments).then((): Promise>> => {\n // add new options\n if (item.value?.type === 'template') { // if it's a variable we need to check for new elements\\\n return this.getElementSegments(segments.length + 1, segments).then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n this.segmentChangeValue(segments);\n return segments;\n });\n } else if (!!item.value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return new Promise((resolve) => {\n this.segmentChangeValue(segments);\n resolve(segments);\n });\n });\n });\n };\n\n // get a ui segment for the attributes\n getElementSegments = (\n index: number,\n currentSegment?: Array>\n ): Promise>> => {\n const { datasource, query, data } = this.props;\n const ctrl = this;\n const findQuery = query.isPiPoint\n ? { type: 'dataserver' }\n : {\n path: this.getSegmentPathUpTo(currentSegment ?? this.state.segments.slice(0), index),\n afServerWebId: this.state.segments.length > 0 && this.state.segments[0].value ? this.state.segments[0].value.webId : undefined,\n };\n\n if (!query.isPiPoint) {\n if (datasource.afserver?.name && index === 0) {\n return Promise.resolve([\n {\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n },\n ]);\n }\n if (datasource.afserver?.name && datasource.afdatabase?.name && index === 1) {\n return Promise.resolve([\n {\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n },\n ]);\n }\n }\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n const altSegments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n label: item.text,\n value: {\n webId: item.WebId,\n value: item.text,\n expandable: !query.isPiPoint && item.expandable,\n },\n };\n return selectableValue;\n });\n\n if (altSegments.length === 0) {\n return altSegments;\n }\n\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: TypedVariableModel) => {\n let selectableValue: SelectableValue = {\n label: '${' + variable.name + '}',\n value: {\n type: 'template',\n value: '${' + variable.name + '}',\n expandable: !query.isPiPoint,\n },\n };\n altSegments.unshift(selectableValue);\n });\n\n // add remove label\n altSegments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return altSegments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return [];\n });\n };\n\n // get the list of attributes for the user interface - PI\n getAttributeSegmentsPI = (attributeText?: string): Promise>> => {\n const { datasource, query, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: '',\n webId: this.getSelectedPIServer(),\n pointName: (attributeText ?? '') + '*',\n type: 'pipoint',\n };\n let segments: Array> = [];\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n segments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n path: item.Path,\n label: item.text,\n value: {\n value: item.text,\n expandable: false,\n },\n };\n return selectableValue;\n });\n if (!!attributeText && attributeText.length > 0) {\n segments.unshift({\n label: attributeText,\n value: {\n value: attributeText,\n expandable: false,\n },\n });\n }\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: TypedVariableModel) => {\n let selectableValue: SelectableValue = {\n label: '${' + variable.name + '}',\n value: {\n type: 'template',\n value: '${' + variable.name + '}',\n expandable: !query.isPiPoint,\n },\n };\n segments.unshift(selectableValue);\n });\n\n // add remove label\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return segments;\n });\n };\n\n // get the list of attributes for the user interface - AF\n getAttributeSegmentsAF = (attributeText?: string): Array> => {\n const ctrl = this;\n let segments: Array> = [];\n\n segments.push({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n forOwn(ctrl.availableAttributes, (val: any, key: string) => {\n let selectableValue: SelectableValue = {\n label: key,\n value: {\n value: key,\n expandable: true,\n },\n };\n segments.push(selectableValue);\n });\n\n return segments;\n };\n\n // build data from target string\n buildFromTarget = (\n query: PIWebAPIQuery,\n segmentsArray: Array>,\n attributesArray: Array>\n ) => {\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segmentsArray.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, (item, _) => {\n if (item !== '') {\n // set current value\n attributesArray.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n return this.getElementSegments(splitElements.length + 1, segmentsArray).then((elements) => {\n if (elements.length > 0) {\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return segmentsArray;\n });\n }\n return Promise.resolve(segmentsArray);\n };\n\n /**\n * Gets the segment information and parses it to a string.\n *\n * @param {any} index - Last index of segment to use.\n * @returns - AF Path or PI Point name.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSegmentPathUpTo(segments: Array>, index: number): string {\n const arr = segments.slice(0, index);\n\n return reduce(\n arr,\n (result: any, segment: SelectableValue) => {\n if (!segment.value) {\n return '';\n }\n if (!segment.value.value?.startsWith('-Select')) {\n return result ? result + '\\\\' + segment.value.value : segment.value.value;\n }\n return result;\n },\n ''\n );\n }\n\n /**\n * Get the current AF Element's child attributes. Validates when the element selection changes.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAttributeSegments(\n attributes: Array>,\n segments: Array>\n ): Promise {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: this.getSegmentPathUpTo(segments.slice(0), segments.length),\n type: 'attributes',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: false }))\n .then((attributesResponse: any) => {\n const validAttributes: any = {};\n\n each(attributesResponse, (attribute: any) => {\n validAttributes[attribute.Path.substring(attribute.Path.indexOf('|') + 1)] = attribute.WebId;\n });\n\n const filteredAttributes = filter(attributes, (attrib: SelectableValue) => {\n const changedValue = datasource.templateSrv.replace(attrib.value?.value);\n return validAttributes[changedValue] !== undefined;\n });\n\n ctrl.availableAttributes = validAttributes;\n return this.attributeChangeValue(filteredAttributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return this.attributeChangeValue(attributes);\n });\n }\n\n /**\n * Get PI points from server.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkPiPointSegments(\n attribute: SelectableValue,\n attributes: Array>\n ) {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: attribute.path,\n webId: ctrl.getSelectedPIServer(),\n pointName: attribute.label,\n type: 'pipoint',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: true }))\n .then(() => {\n return ctrl.attributeChangeValue(attributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return ctrl.attributeChangeValue([]);\n });\n }\n\n /**\n * Gets the webid of the current selected pi data server.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSelectedPIServer() {\n let webID = '';\n\n this.piServer.forEach((s) => {\n const parts = this.props.query.target!.split(';');\n if (parts.length >= 2) {\n if (parts[0] === s.text) {\n webID = s.WebId;\n return;\n }\n }\n });\n return this.piServer.length > 0 ? this.piServer[0].value?.webId : webID;\n }\n\n /**\n * Queries PI Web API for child elements and attributes when the raw query text editor is changed.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n textEditorChanged() {\n const { query } = this.props;\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n let segments: Array> = [];\n let attributes: Array> = [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segments.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n this.getElementSegments(splitElements.length + 1, segments)\n .then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n })\n .then(() => {\n this.updateArray(segments, attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n });\n } else {\n segments = this.checkAfServer();\n this.updateArray(segments, this.state.attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n }\n }\n\n /**\n * Check if the AF server and database are configured in the datasoure config.\n *\n * @returns the segments array\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAfServer = () => {\n const { datasource } = this.props;\n const segmentsArray = [];\n if (datasource.afserver?.name) {\n segmentsArray.push({\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n });\n if (datasource.afdatabase?.name) {\n segmentsArray.push({\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n });\n }\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n } else {\n segmentsArray.push({\n label: '',\n });\n }\n return segmentsArray;\n };\n\n /**\n * Update the internal state of the datasource.\n *\n * @param segmentsArray the segments array to update\n * @param attributesArray the AF attributes array to update\n * @param summariesArray the summaries array to update\n * @param isPiPoint the is PI point flag\n * @param cb optional callback function\n *\n * @memberOf PIWebAPIQueryEditor\n */\n updateArray = (\n segmentsArray: Array>,\n attributesArray: Array>,\n summariesArray: Array>,\n isPiPoint: boolean,\n cb?: (() => void) | undefined\n ) => {\n this.setState(\n {\n segments: segmentsArray,\n attributes: attributesArray,\n summaries: summariesArray,\n isPiPoint,\n },\n () => {\n if (!isPiPoint) {\n this.checkAttributeSegments(attributesArray, this.state.segments).then(() => {\n if (cb) {\n cb();\n }\n });\n }\n }\n );\n };\n\n // React action when component is initialized/updated\n scopedVarsDone = false;\n componentDidMount = () => {\n this.initialLoad(false);\n };\n\n componentDidUpdate = () => {\n const { query } = this.props;\n if (this.props.data?.state === 'Done' && !!this.props.data?.request?.scopedVars && !this.scopedVarsDone) {\n this.scopedVarsDone = true;\n this.initialLoad(!query.isPiPoint);\n }\n };\n\n initialLoad = (force: boolean) => {\n const { query } = this.props;\n const metricsQuery = defaults(query, defaultQuery) as PIWebAPIQuery;\n const { segments, attributes, summary, isPiPoint } = metricsQuery;\n\n let segmentsArray: Array> = force ? [] : segments?.slice(0) ?? [];\n let attributesArray: Array> = force ? [] : attributes?.slice(0) ?? [];\n let summariesArray = summary?.types ?? [];\n\n if (!isPiPoint && segmentsArray.length === 0) {\n if (query.target && query.target.length > 0 && query.target !== ';') {\n attributesArray = [];\n // Build query from target\n this.buildFromTarget(query, segmentsArray, attributesArray)\n .then((_segmentsArray) => {\n this.updateArray(_segmentsArray, attributesArray, summariesArray, false);\n })\n .catch((e) => console.error(e));\n return;\n } else {\n segmentsArray = this.checkAfServer();\n }\n } else if (isPiPoint && segmentsArray.length > 0) {\n this.piServer = segmentsArray;\n }\n this.updateArray(segmentsArray, attributesArray, summariesArray, !!isPiPoint, () => {\n this.onChange(query);\n });\n };\n\n onChange = (query: PIWebAPIQuery) => {\n const { onChange, onRunQuery } = this.props;\n\n if (query.rawQuery) {\n query.target = query.query ?? '';\n if (!!query.query) {\n const { attributes, elementPath } = parseRawQuery(query.target);\n query.attributes = attributes;\n query.elementPath = elementPath;\n }\n } else {\n query.elementPath = this.getSegmentPathUpTo(this.state.segments, this.state.segments.length);\n query.target =\n query.elementPath +\n ';' +\n join(\n query.attributes?.map((s) => s.value?.value),\n ';'\n );\n }\n const summary = query.summary;\n if (summary) {\n summary.types = this.state.summaries;\n }\n\n onChange({...query, summary});\n\n if (this.isValidQuery(query)) {\n onRunQuery();\n }\n };\n\n isValidQuery = (query: PIWebAPIQuery): boolean => {\n if (query.target && query.target.length > 0 && query.target !== \";\") {\n query.target = query.target.trim();\n const targetSplit = query.target.split(\";\", 2);\n return targetSplit.length === 2 && targetSplit[0].length > 0 && targetSplit[1].length > 0;\n }\n return false;\n }\n\n stateCallback = () => {\n const query = this.props.query as PIWebAPIQuery;\n this.onChange(query);\n };\n\n onIsPiPointChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const isPiPoint = !queryChange.isPiPoint;\n this.setState(\n {\n segments: isPiPoint ? [{ label: '' }] : this.checkAfServer(),\n attributes: [],\n isPiPoint,\n },\n () => {\n this.onChange({\n ...queryChange,\n expression: '',\n attributes: this.state.attributes,\n segments: this.state.segments,\n isPiPoint,\n });\n }\n );\n };\n\n render() {\n const { query: queryProps, onChange, onRunQuery } = this.props;\n const metricsQuery = defaults(queryProps, defaultQuery) as PIWebAPIQuery;\n const {\n useLastValue,\n useUnit,\n interpolate,\n query,\n rawQuery,\n digitalStates,\n enableStreaming,\n recordedValues,\n expression,\n isPiPoint,\n summary,\n display,\n regex,\n } = metricsQuery;\n\n return (\n <>\n {this.props.datasource.piPointConfig && (\n \n \n \n )}\n\n {!!rawQuery && (\n \n \n ) =>\n onChange({ ...metricsQuery, query: event.target.value })\n }\n placeholder=\"enter query\"\n />\n \n this.textEditorChanged()} />\n \n )}\n\n {!rawQuery && (\n <>\n
\n \n {this.state.segments.map((segment: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSegmentChange(item, index)}\n loadOptions={(query?: string | undefined) => {\n return this.getElementSegments(index);\n }}\n allowCustomValue\n inputMinWidth={MIN_ELEM_INPUT_WIDTH}\n />\n );\n })}\n \n {!isPiPoint && (\n {\n onChange({ ...metricsQuery, query: metricsQuery.target, rawQuery: value });\n }}\n />\n )}\n \n
\n\n \n {this.state.attributes.map((attribute: SelectableValue, index: number) => {\n if (isPiPoint) {\n return (\n }\n disabled={this.piServer.length === 0}\n onChange={(item) => this.onPiPointChange(item, index)}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n }\n return (\n }\n disabled={this.state.segments.length <= 2}\n onChange={(item) => this.onAttributeChange(item, index)}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n })}\n\n {isPiPoint && (\n \n }\n disabled={this.piServer.length === 0}\n onChange={this.onAttributeAction}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n {!isPiPoint && (\n \n }\n disabled={this.state.segments.length <= 2}\n onChange={this.onAttributeAction}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n \n \n )}\n\n \n \n ) =>\n onChange({ ...metricsQuery, expression: event.target.value })\n }\n placeholder=\"'.'*2\"\n />\n \n \n\n \n \n \n this.onChange({\n ...metricsQuery,\n useLastValue: { ...useLastValue, enable: !useLastValue.enable },\n })\n }\n />\n \n \n \n this.onChange({\n ...metricsQuery,\n digitalStates: { ...digitalStates, enable: !digitalStates.enable },\n })\n }\n />\n \n \n }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n {this.props.datasource.useUnitConfig && (\n \n \n this.onChange({\n ...metricsQuery,\n useUnit: { ...useUnit, enable: !useUnit.enable },\n })\n }\n />\n \n )}\n {this.props.datasource.useStreaming && (\n \n \n this.onChange({ ...metricsQuery, enableStreaming: { ...enableStreaming, enable: !enableStreaming.enable } })\n }\n />\n \n )}\n \n\n \n {!useLastValue.enable && (\n \n ) =>\n onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, maxNumber: parseInt(event.target.value, 10) },\n })\n }\n type=\"number\"\n placeholder=\"1000\"\n />\n \n )}\n \n \n this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable },\n })\n }\n />\n \n \n\n {!useLastValue.enable && (\n \n \n ) =>\n onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable } })\n }\n />\n \n \n )}\n\n {!useLastValue.enable && (\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n }\n onChange={this.calcBasisValueChanged}\n options={this.getCalcBasisSegments()}\n allowCustomValue\n />\n \n \n \n {this.state.summaries.map((s: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSummaryValueChanged(item, index)}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n );\n })}\n \n }\n onChange={this.onSummaryAction}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n \n \n \n )}\n\n \n \n ) =>\n onChange({ ...metricsQuery, display: event.target.value })\n }\n placeholder=\"Display\"\n />\n \n \n {\n this.onChange({ ...metricsQuery, regex: { ...regex, enable: !regex.enable } });\n }}\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, search: event.target.value } })\n }\n placeholder=\"(.*)\"\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, replace: event.target.value } })\n }\n placeholder=\"$1\"\n />\n \n \n \n );\n }\n}\n","import React, { memo, useState } from 'react';\n\nimport { AnnotationQuery, QueryEditorProps, SelectableValue } from '@grafana/data';\nimport { AsyncSelect, InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';\n\nimport { PiWebAPIDatasource } from 'datasource';\nimport { PIWebAPIDataSourceJsonData, PIWebAPIQuery, PiwebapiRsp } from 'types';\n\nconst SMALL_LABEL_WIDTH = 20;\nconst LABEL_WIDTH = 30;\nconst MIN_INPUT_WIDTH = 50;\n\ntype PiWebAPIQueryEditorProps = QueryEditorProps;\n\ntype Props = PiWebAPIQueryEditorProps & {\n annotation?: AnnotationQuery;\n onAnnotationChange?: (annotation: AnnotationQuery) => void;\n};\n\nexport const PiWebAPIAnnotationsQueryEditor = memo(function PiWebAPIAnnotationQueryEditor(props: Props) {\n const { query, datasource, annotation, onChange, onRunQuery } = props;\n\n const [afWebId, setAfWebId] = useState('');\n const [database, setDatabase] = useState(annotation?.target?.database ?? {});\n\n // this should never happen, but we want to keep typescript happy\n if (annotation === undefined) {\n return null;\n }\n\n const getEventFrames = (): Promise>> => {\n return datasource.getEventFrameTemplates(database?.WebId!).then((templ: PiwebapiRsp[]) => {\n return templ.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getDatabases = (): Promise>> => {\n return datasource.getDatabases(afWebId).then((dbs: PiwebapiRsp[]) => {\n return dbs.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getValue = (key: string) => {\n const query: any = annotation.target as any;\n if (!query || !query[key]) {\n return;\n }\n return { label: query[key].Name, value: query[key] };\n };\n\n datasource.getAssetServer(datasource.afserver.name).then((result) => {\n setAfWebId(result.WebId!);\n });\n\n return (\n <>\n
\n \n \n {\n setDatabase(e.value);\n onChange({ ...query, database: e.value, template: undefined });\n }}\n defaultOptions\n />\n \n \n onChange({ ...query, template: e.value })}\n defaultOptions\n />\n \n \n onChange({ ...query, showEndTime: e.currentTarget.checked })}\n />\n \n \n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, categoryName: e.currentTarget.value })}\n placeholder=\"Enter category name\"\n />\n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, nameFilter: e.currentTarget.value })}\n placeholder=\"Enter name filter\"\n />\n \n \n \n \n \n onChange({\n ...query,\n regex: { ...query.regex, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, search: e.currentTarget.value },\n })\n }\n placeholder=\"(.*)\"\n width={MIN_INPUT_WIDTH}\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, replace: e.currentTarget.value },\n })\n }\n placeholder=\"$1\"\n />\n \n \n \n \n \n onChange({\n ...query!,\n attribute: { ...query.attribute, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query!,\n attribute: { ...query.attribute, name: e.currentTarget.value },\n })\n }\n placeholder=\"Enter name\"\n />\n \n \n
\n \n );\n});\n","import { filter, map } from 'lodash';\n\nimport { Observable, of, firstValueFrom } from 'rxjs';\n\nimport {\n DataSourceInstanceSettings,\n MetricFindValue,\n AnnotationQuery,\n ScopedVars,\n AnnotationEvent,\n DataFrame,\n DataQueryRequest,\n DataQueryResponse,\n} from '@grafana/data';\nimport { BackendSrv, getBackendSrv, getTemplateSrv, TemplateSrv, DataSourceWithBackend } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData, PiDataServer, PiwebapiInternalRsp, PiwebapiRsp } from './types';\nimport { metricQueryTransform } from 'helper';\n\nimport { PiWebAPIAnnotationsQueryEditor } from 'query/AnnotationsQueryEditor';\n\nexport class PiWebAPIDatasource extends DataSourceWithBackend {\n piserver: PiDataServer;\n afserver: PiDataServer;\n afdatabase: PiDataServer;\n piPointConfig: boolean;\n newFormatConfig: boolean;\n useUnitConfig: boolean;\n useExperimental: boolean;\n useStreaming: boolean;\n\n constructor(\n instanceSettings: DataSourceInstanceSettings,\n readonly templateSrv: TemplateSrv = getTemplateSrv(),\n private readonly backendSrv: BackendSrv = getBackendSrv()\n ) {\n super(instanceSettings);\n\n this.piserver = { name: (instanceSettings.jsonData || {}).piserver, webid: undefined };\n this.afserver = { name: (instanceSettings.jsonData || {}).afserver, webid: undefined };\n this.afdatabase = { name: (instanceSettings.jsonData || {}).afdatabase, webid: undefined };\n this.piPointConfig = instanceSettings.jsonData.pipoint || false;\n this.newFormatConfig = instanceSettings.jsonData.newFormat || false;\n this.useUnitConfig = instanceSettings.jsonData.useUnit || false;\n this.useExperimental = instanceSettings.jsonData.useExperimental || false;\n this.useStreaming = instanceSettings.jsonData.useStreaming || false;\n\n this.annotations = {\n QueryEditor: PiWebAPIAnnotationsQueryEditor,\n prepareQuery(anno: AnnotationQuery): PIWebAPIQuery | undefined {\n if (anno.target) {\n anno.target.queryType = 'Annotation';\n anno.target.isAnnotation = true;\n }\n return anno.target;\n },\n processEvents: (\n anno: AnnotationQuery,\n data: DataFrame[]\n ): Observable => {\n return of(this.eventFrameToAnnotation(anno, data));\n },\n };\n\n Promise.all([\n this.getDataServer(this.piserver.name).then((result: PiwebapiRsp) => (this.piserver.webid = result.WebId)),\n this.getAssetServer(this.afserver.name).then((result: PiwebapiRsp) => (this.afserver.webid = result.WebId)),\n this.getDatabase(\n this.afserver.name && this.afdatabase.name ? this.afserver.name + '\\\\' + this.afdatabase.name : undefined\n ).then((result: PiwebapiRsp) => (this.afdatabase.webid = result.WebId)),\n ]);\n }\n\n /**\n * This method overrides the applyTemplateVariables() method from the DataSourceWithBackend class.\n * It is responsible for replacing the template variables in the query configuration prior\n * to sending the query to the backend. Templated variables are not able to be used for alerts\n * or public facing dashboards.\n *\n * @param {PIWebAPIQuery} query - The raw query configuration from the frontend as defined in the query editor.\n * @param {ScopedVars} scopedVars - The template variables that are defined in the query editor and dashboard.\n * @returns - PIWebAPIQuery.\n *\n * @memberOf PiWebApiDatasource\n */\n applyTemplateVariables(query: PIWebAPIQuery, scopedVars: ScopedVars) {\n return {\n ...query,\n target: query.target ? this.templateSrv.replace(query.target, scopedVars) : '',\n };\n }\n\n /**\n * This method makes the query to the backend.\n *\n * @param {DataQueryRequest} options\n *\n * @memberOf PiWebApiDatasource\n */\n query(options: DataQueryRequest): Observable {\n if (options.targets.length === 1 && !!options.targets[0].isAnnotation) {\n return super.query(options);\n }\n\n const query = this.buildQueryParameters(options);\n if (query.targets.length <= 0) {\n return of({ data: [] });\n }\n\n return super.query(query);\n }\n\n /**\n * This method does the discovery of the AF Hierarchy and populates the query user interface segments.\n *\n * @param {any} query - Parses the query configuration and builds a PI Web API query.\n * @returns - Segment information.\n *\n * @memberOf PiWebApiDatasource\n */\n metricFindQuery(query: any, queryOptions: any): Promise {\n const ds = this;\n const querydepth = ['servers', 'databases', 'databaseElements', 'elements'];\n if (typeof query === 'string') {\n query = JSON.parse(query as string);\n }\n if (queryOptions.isPiPoint) {\n query.path = this.templateSrv.replace(query.path, queryOptions);\n } else {\n if (query.path === '') {\n query.type = querydepth[0];\n } else {\n query.path = this.templateSrv.replace(query.path, queryOptions); // replace variables in the path\n query.path = query.path.split(';')[0]; // if the attribute is in the path, let's remote it\n if (query.type !== 'attributes') {\n query.type = querydepth[Math.max(0, Math.min(query.path.split('\\\\').length, querydepth.length - 1))];\n }\n }\n query.path = query.path.replace(/\\{([^\\\\])*\\}/gi, (r: string) => r.substring(1, r.length - 2).split(',')[0]);\n }\n\n query.filter = query.filter ?? '*';\n query.max = query.max ?? 10000;\n\n if (query.type === 'servers') {\n return ds.afserver?.name\n ? ds\n .getAssetServer(ds.afserver.name)\n .then((result: PiwebapiRsp) => [result])\n .then(metricQueryTransform)\n : ds.getAssetServers().then(metricQueryTransform);\n } else if (query.type === 'databases' && !!query.afServerWebId) {\n return ds.getDatabases(query.afServerWebId, {}).then(metricQueryTransform);\n } else if (query.type === 'databases') {\n return ds\n .getAssetServer(query.path)\n .then((server) => ds.getDatabases(server.WebId ?? '', {}))\n .then(metricQueryTransform);\n } else if (query.type === 'databaseElements') {\n return ds\n .getDatabase(query.path)\n .then((db) =>\n ds.getDatabaseElements(db.WebId ?? '', {\n selectedFields: 'Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'elements') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getElements(element.WebId ?? '', {\n selectedFields:\n 'Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n nameFilter: query.filter,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'attributes') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getAttributes(element.WebId ?? '', {\n searchFullHierarchy: 'true',\n selectedFields:\n 'Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path',\n nameFilter: query.filter,\n maxCount: query.max,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'dataserver') {\n return ds.getDataServers().then(metricQueryTransform);\n } else if (query.type === 'pipoint') {\n return ds.piPointSearch(query.webId, query.pointName).then(metricQueryTransform);\n }\n return Promise.reject('Bad type');\n }\n\n /** PRIVATE SECTION */\n\n /**\n * Builds the PIWebAPI query parameters.\n *\n * @param {any} options - Grafana query and panel options.\n * @returns - PIWebAPI query parameters.\n *\n * @memberOf PiWebApiDatasource\n */\n private buildQueryParameters(options: DataQueryRequest) {\n options.targets = filter(options.targets, (target) => {\n if (!target || !target.target || target.attributes?.length === 0 || target.target === ';' || !!target.hide) {\n return false;\n }\n return !target.target.startsWith('Select AF');\n });\n\n if (options.maxDataPoints) {\n options.maxDataPoints = options.maxDataPoints > 30000 ? 30000 : options.maxDataPoints;\n }\n options.targets = map(options.targets, (target) => {\n const tar = {\n enableStreaming: target.enableStreaming,\n target: this.templateSrv.replace(target.target, options.scopedVars),\n elementPath: this.templateSrv.replace(target.elementPath, options.scopedVars),\n attributes: map(target.attributes, (att) => {\n if (att.value) {\n this.templateSrv.replace(att.value.value, options.scopedVars);\n }\n return att;\n }),\n segments: map(target.segments, (att) => {\n if (att.value) {\n this.templateSrv.replace(att.value.value, options.scopedVars);\n }\n return att;\n }),\n isAnnotation: !!target.isAnnotation,\n display: !!target.display ? this.templateSrv.replace(target.display, options.scopedVars) : undefined,\n refId: target.refId,\n hide: target.hide,\n interpolate: !!target.interpolate\n ? {\n ...target.interpolate,\n interval: this.templateSrv.replace(target.interpolate.interval, options.scopedVars),\n }\n : { enable: false },\n useLastValue: target.useLastValue || { enable: false },\n useUnit: target.useUnit || { enable: false },\n recordedValues: !!target.recordedValues\n ? {\n ...target.recordedValues,\n interval: this.templateSrv.replace(target.recordedValues.maxNumber, options.scopedVars),\n }\n : { enable: false },\n digitalStates: target.digitalStates || { enable: false },\n webid: target.webid ?? '',\n regex: target.regex || { enable: false },\n expression: target.expression || '',\n summary: target.summary || { types: [] },\n startTime: options.range.from,\n endTime: options.range.to,\n isPiPoint: !!target.isPiPoint,\n scopedVars: options.scopedVars,\n };\n\n if (tar.expression) {\n tar.expression = this.templateSrv.replace(tar.expression, options.scopedVars);\n }\n\n if (tar.summary.types !== undefined) {\n tar.summary.types = filter(tar.summary.types, (item) => {\n return item !== undefined && item !== null && item !== '';\n });\n }\n\n return tar;\n });\n\n return options;\n }\n\n /**\n * Localize the eventFrame dataFrame records to Grafana Annotations.\n * @param {any} annon - The annotation object.\n * @param {any} data - The dataframe recrords.\n * @returns - Grafana Annotation\n *\n * @memberOf PiWebApiDatasource\n */\n private eventFrameToAnnotation(annon: AnnotationQuery, data: DataFrame[]): AnnotationEvent[] {\n const annotationOptions = annon.target!;\n const events: AnnotationEvent[] = [];\n const currentLocale = Intl.DateTimeFormat().resolvedOptions().locale;\n\n data.forEach((d: DataFrame) => {\n let values = this.transformDataFrameToMap(d);\n for (let i = 0; i < values['time'].length; i++) {\n // replace Dataframe name using Regex\n let title = values['title'][i];\n if (annotationOptions.regex && annotationOptions.regex.enable) {\n title = title.replace(new RegExp(annotationOptions.regex.search), annotationOptions.regex.replace);\n }\n\n // test if timeEnd is negative and if so, set it to null\n if (values['timeEnd'][i] < 0) {\n values['timeEnd'][i] = null;\n }\n\n // format the text and localize the dates to browser locale\n let text = 'Tag: ' + title;\n if (annotationOptions.attribute && annotationOptions.attribute.enable) {\n text += values['attributeText'][i];\n }\n text += '
Start: ' + new Date(values['time'][i]).toLocaleString(currentLocale) + '
End: ';\n\n if (values['timeEnd'][i]) {\n text += new Date(values['timeEnd'][i]).toLocaleString(currentLocale);\n } else {\n text += 'Eventframe is open';\n }\n\n const event: AnnotationEvent = {\n time: values['time'][i],\n timeEnd: !!annotationOptions.showEndTime ? values['timeEnd'][i] : undefined,\n title: title,\n id: values['id'][i],\n text: text,\n tags: ['OSISoft PI'],\n };\n\n events.push(event);\n }\n });\n return events;\n }\n\n /**\n *\n */\n private transformDataFrameToMap(dataFrame: DataFrame): Record {\n const map: Record = {};\n\n dataFrame.fields.forEach((field) => {\n map[field.name] = field.values.toArray();\n });\n\n return map;\n }\n\n /**\n * Abstraction for calling the PI Web API REST endpoint\n *\n * @param {any} path - the path to append to the base server URL.\n * @returns - The full URL.\n *\n * @memberOf PiWebApiDatasource\n */\n private restGet(path: string): Promise {\n const observable = this.backendSrv.fetch({\n url: `/api/datasources/${this.id}/resources${path}`,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n });\n\n return firstValueFrom(observable).then((response: any) => {\n return response as PiwebapiInternalRsp;\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.data.Items ?? []);\n }\n private getDataServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/dataservers?name=' + name).then((response) => response.data);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.data.Items ?? []);\n }\n getAssetServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/assetservers?path=\\\\\\\\' + name).then((response) => response.data);\n }\n getDatabase(path: string | undefined): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/assetdatabases?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getDatabases(serverId: string, options?: any): Promise {\n if (!serverId) {\n return Promise.resolve([]);\n }\n return this.restGet('/assetservers/' + serverId + '/assetdatabases').then((response) => response.data.Items ?? []);\n }\n getElement(path: string): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/elements?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getEventFrameTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'EventFrame');\n });\n }\n getElementTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'Element');\n });\n }\n\n /**\n * @description\n * Get the child attributes of the current resource.\n * GET attributes/{webId}/attributes\n * @param {string} elementId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.nameFilter - The name query string used for finding attributes. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned attributes must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned attributes must be members of this template. The default is no template filter.\n * @param {string} options.valueType - Specify that returned attributes' value type must be the given value type. The default is no value type filter.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include attributes nested further than the immediate attributes of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {string} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {string} options.showExcluded - Specified if the search should include attributes with the Excluded property set. The default is 'false'.\n * @param {string} options.showHidden - Specified if the search should include attributes with the Hidden property set. The default is 'false'.\n * @param {string} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getAttributes(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/attributes' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET assetdatabases/{webId}/elements\n * @param {string} databaseId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getDatabaseElements(databaseId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/assetdatabases/' + databaseId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET elements/{webId}/elements\n * @param {string} databaseId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getElements(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * Retrieve a list of points on a specified Data Server.\n *\n * @param {string} serverId - The ID of the server. See WebID for more information.\n * @param {string} nameFilter - A query string for filtering by point name. The default is no filter. *, ?, [ab], [!ab]\n */\n private piPointSearch(serverId: string, nameFilter: string): Promise {\n let filter1 = this.templateSrv.replace(nameFilter);\n let filter2 = `${filter1}`;\n let doFilter = false;\n if (filter1 !== nameFilter) {\n const regex = /\\{(\\w|,)+\\}/gs;\n let m;\n while ((m = regex.exec(filter1)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n if (groupIndex === 0) {\n filter1 = filter1.replace(match, match.replace('{', '(').replace('}', ')').replace(',', '|'));\n filter2 = filter2.replace(match, '*');\n doFilter = true;\n }\n });\n }\n }\n return this.restGet('/dataservers/' + serverId + '/points?maxCount=50&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results.data?.Items) {\n return doFilter ? results.data.Items.filter((item) => item.Name?.match(filter1)) : results.data.Items;\n }\n return [];\n });\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { PIWebAPIConfigEditor } from './config/ConfigEditor';\nimport { PIWebAPIQueryEditor } from './query/QueryEditor';\nimport { PiWebAPIDatasource } from './datasource';\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n PiWebAPIDatasource\n)\n .setQueryEditor(PIWebAPIQueryEditor)\n .setConfigEditor(PIWebAPIConfigEditor);\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__781__","__WEBPACK_EXTERNAL_MODULE__531__","__WEBPACK_EXTERNAL_MODULE__7__","__WEBPACK_EXTERNAL_MODULE__241__","__WEBPACK_EXTERNAL_MODULE__959__","__WEBPACK_EXTERNAL_MODULE__269__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","FormField","LegacyForms","coerceOptions","options","jsonData","url","PIWebAPIConfigEditor","PureComponent","render","originalOptions","this","props","div","DataSourceHttpSettings","defaultUrl","dataSourceConfig","onChange","onHttpOptionsChange","showAccessOptions","h3","className","InlineField","label","labelWidth","InlineSwitch","pipoint","onPiPointChange","newFormat","onNewFormatChange","useUnit","onUseUnitChange","useExperimental","onUseExperimentalChange","useStreaming","onUseStreamingChange","inputWidth","onPIServerChange","piserver","placeholder","onAFServerChange","afserver","onAFDatabaseChange","afdatabase","event","onOptionsChange","target","checked","QueryField","tooltip","children","InlineFormLabel","width","QueryRowTerminator","QueryInlineField","QueryEditorRow","QueryRawInlineField","QueryRawEditorRow","defaultQuery","attributes","segments","regex","enable","summary","types","basis","interval","nodata","expression","interpolate","useLastValue","recordedValues","digitalStates","enableStreaming","isPiPoint","QueryEditorModeSwitcher","isRaw","isModalOpen","setModalOpen","useState","useEffect","Button","aria-label","icon","variant","type","onClick","ConfirmModal","isOpen","title","body","confirmText","dismissText","onConfirm","onDismiss","metricQueryTransform","response","map","item","text","Name","expandable","HasChildren","Path","split","length","Items","WebId","LABEL_WIDTH","MIN_ATTR_INPUT_WIDTH","REMOVE_LABEL","CustomLabelComponent","Icon","name","PIWebAPIQueryEditor","isValueEmpty","calcBasisValueChanged","segment","metricsQuery","query","getCalcBasisSegments","calculationBasis","calcNoDataValueChanged","getNoDataSegments","noDataReplacement","onSummaryValueChanged","index","summaries","state","slice","splice","setState","stateCallback","getSummarySegments","summaryTypes","filter","s","indexOf","unshift","removeSummary","part","onSummaryAction","selectableValue","push","summarySegment","removeAttribute","attributeChangeValue","onAttributeAction","getSegmentPathUpTo","arr","reduce","result","startsWith","checkAttributeSegments","data","datasource","ctrl","findQuery","path","metricFindQuery","assign","request","scopedVars","then","attributesResponse","validAttributes","each","attribute","substring","filteredAttributes","attrib","changedValue","templateSrv","replace","availableAttributes","catch","err","error","message","checkPiPointSegments","webId","getSelectedPIServer","pointName","webID","piServer","forEach","parts","textEditorChanged","splitAttributes","splitElements","_","match","getElementSegments","elements","updateArray","rawQuery","checkAfServer","queryProps","onRunQuery","defaults","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","SegmentAsync","Component","onSegmentChange","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","onAttributeChange","getAttributeSegmentsAF","attributeSegment","useUnitConfig","maxNumber","parseInt","search","constructor","super","calculationBasisSegment","noDataReplacementSegment","segmentChangeValue","Promise","resolve","remove","currentSegment","afServerWebId","items","altSegments","variables","getVariables","variable","attributeText","forOwn","val","buildFromTarget","segmentsArray","attributesArray","summariesArray","cb","scopedVarsDone","componentDidMount","initialLoad","componentDidUpdate","force","_segmentsArray","e","console","elementPath","tr","join","parseRawQuery","isValidQuery","trim","targetSplit","queryChange","bind","PiWebAPIAnnotationsQueryEditor","memo","annotation","afWebId","setAfWebId","database","setDatabase","getValue","getAssetServer","AsyncSelect","getDatabases","dbs","loadingMessage","template","defaultOptions","getEventFrameTemplates","templ","showEndTime","currentTarget","categoryName","nameFilter","PiWebAPIDatasource","DataSourceWithBackend","applyTemplateVariables","targets","isAnnotation","buildQueryParameters","of","queryOptions","ds","querydepth","JSON","parse","Math","max","min","getAssetServers","server","getDatabase","db","getDatabaseElements","selectedFields","getElement","element","getElements","getAttributes","searchFullHierarchy","maxCount","getDataServers","piPointSearch","reject","hide","maxDataPoints","tar","att","refId","webid","startTime","range","from","endTime","to","annon","annotationOptions","events","currentLocale","Intl","DateTimeFormat","resolvedOptions","locale","values","transformDataFrameToMap","i","RegExp","Date","toLocaleString","time","timeEnd","id","tags","dataFrame","fields","field","toArray","observable","backendSrv","fetch","method","headers","firstValueFrom","restGet","getDataServer","serverId","databaseId","InstanceType","getElementTemplates","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","results","instanceSettings","getTemplateSrv","getBackendSrv","newFormatConfig","annotations","QueryEditor","prepareQuery","anno","queryType","processEvents","eventFrameToAnnotation","all","plugin","DataSourcePlugin","setQueryEditor","setConfigEditor"],"sourceRoot":""} \ No newline at end of file