From 67de00ecc789302af6756d9ce3e0200c3905d8e4 Mon Sep 17 00:00:00 2001 From: Paulo Vitor Magacho Date: Fri, 6 Sep 2024 11:56:17 -0300 Subject: [PATCH] Version 5.1.0 initial commit --- dist/module.js | 2 +- dist/module.js.map | 2 +- dist/plugin.json | 2 +- pkg/plugin/annotation_query.go | 3 +- pkg/plugin/datasource.go | 4 +- pkg/plugin/helpers.go | 5 +- pkg/plugin/timeseries_query.go | 43 ++++++++---- pkg/plugin/timeseries_query_models.go | 34 +++++----- src/datasource.ts | 15 ++-- src/query/QueryEditor.tsx | 98 ++++++++++++++++++++------- src/types.ts | 17 ++++- 11 files changed, 154 insertions(+), 71 deletions(-) diff --git a/dist/module.js b/dist/module.js index 3ed4e9e..25a5e29 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:()=>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 v(e){for(var t=1;tg(v({},e),{jsonData:g(v({},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=g(v({},a.jsonData),{piserver:e.target.value});t(g(v({},a),{jsonData:n}))})),p(this,"onAFServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{afserver:e.target.value});t(g(v({},a),{jsonData:n}))})),p(this,"onAFDatabaseChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{afdatabase:e.target.value});t(g(v({},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=g(v({},a.jsonData),{piserver:e.target.checked?a.jsonData.piserver:"",pipoint:e.target.checked});t(g(v({},a),{jsonData:n}))})),p(this,"onNewFormatChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{newFormat:e.target.checked});t(g(v({},a),{jsonData:n}))})),p(this,"onUseUnitChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{useUnit:e.target.checked});t(g(v({},a),{jsonData:n}))})),p(this,"onUseExperimentalChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{useExperimental:e.target.checked,useStreaming:!!e.target.checked&&a.jsonData.useStreaming});t(g(v({},a),{jsonData:n}))})),p(this,"onUseStreamingChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{useStreaming:e.target.checked});t(g(v({},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({},C(e));return c().createElement(O,null,c().createElement(P,t))},O=e=>c().createElement("div",{className:"gf-form-inline"},e.children,c().createElement(I,null)),x=e=>{var t=S({},C(e));return c().createElement(D,null,c().createElement(P,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,boundaryType:"Inside"},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 V(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function W(e){for(var t=1;t{var t;return e.value?c().createElement("div",{style:{width:e.width,marginRight:e.marginRight},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===q}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(T(W({},t),{summary:a}))}getCalcBasisSegments(){return(0,E.map)(this.calculationBasis,(e=>({label:e,value:{value:e,expandable:!0}})))}recordedBoundaryTypeValueChanged(e){const t=this.props.query,a=t.recordedValues;var n;a&&(a.boundaryType=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(T(W({},t),{recordedValues:a}))}getRecordedBoundaryTypeSegments(){return(0,E.map)(this.recordedBoundaryTypes,(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(T(W({},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:q,value:{value:q}}),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(null!==e.value&&"object"!=typeof e.value&&!Array.isArray(e.value)){const t=String(e.value);e.value={type:t.match(/\${\w+}/gi)?"template":void 0,value:t}}if(!this.isValueEmpty(e.value)){var n,l,r;let i={label:e.label,value:{type:(null===(n=e.value)||void 0===n?void 0:n.value)&&(null===(l=e.value)||void 0===l?void 0:l.value.match(/\${\w+}/gi))?"template":void 0,value:null===(r=e.value)||void 0===r?void 0:r.value,expandable:!t.isPiPoint}};a.push(i)}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:{type:e.match(/\${\w+}/gi)?"template":void 0,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(T(W({},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(T(W({},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:v,hideError:g,summary:b,display:y,regex:f}=n;return c().createElement(c().Fragment,null,this.props.datasource.piPointConfig&&c().createElement(d.InlineField,{label:"Is Pi Point?",labelWidth:B},c().createElement(d.InlineSwitch,{value:v,onChange:this.onIsPiPointChange})),!!o&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Raw Query",labelWidth:B,grow:!0},c().createElement(d.Input,{onBlur:this.stateCallback,value:s,onChange:e=>t(T(W({},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:v?"PI Server":"AF Elements",tooltip:v?"Select PI server.":"Select AF Element."},this.state.segments.map(((e,t)=>c().createElement(d.SegmentAsync,{key:"element-"+t,Component:c().createElement(k,{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),!v&&c().createElement(j,{isRaw:!1,onChange:e=>{t(T(W({},n),{query:n.target,rawQuery:e}))}}))),c().createElement(w,{label:v?"Pi Points":"Attributes"},this.state.attributes.map(((e,t)=>v?c().createElement(d.SegmentAsync,{key:"attributes-"+t,Component:c().createElement(k,{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:N}):c().createElement(d.Segment,{key:"attributes-"+t,Component:c().createElement(k,{value:e.value,label:e.label}),disabled:this.state.segments.length<=2,onChange:e=>this.onAttributeChange(e,t),options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:N}))),v&&c().createElement(d.SegmentAsync,{Component:c().createElement(k,{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:N}),!v&&c().createElement(d.Segment,{Component:c().createElement(k,{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:N}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Calculation",grow:!0,labelWidth:B,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(T(W({},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:B},c().createElement(d.InlineSwitch,{value:l.enable,onChange:()=>this.onChange(T(W({},n),{useLastValue:T(W({},l),{enable:!l.enable})}))})),c().createElement(d.InlineField,{label:"Digital States",labelWidth:B},c().createElement(d.InlineSwitch,{value:u.enable,onChange:()=>this.onChange(T(W({},n),{digitalStates:T(W({},u),{enable:!u.enable})}))})),c().createElement(d.InlineField,{label:"Replace Bad Data",labelWidth:B,tooltip:"Replacement for bad quality values."},c().createElement(d.Segment,{Component:c().createElement(k,{width:96,value:{value:null==b?void 0:b.nodata},label:null==b?void 0:b.nodata}),onChange:this.calcNoDataValueChanged,options:this.getNoDataSegments(),allowCustomValue:!0})),c().createElement(d.InlineField,{label:"Ignore API Error?",labelWidth:B},c().createElement(d.InlineSwitch,{value:g,onChange:this.onHideErrorChange})),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:B},c().createElement(d.InlineSwitch,{value:r.enable,onChange:()=>this.onChange(T(W({},n),{useUnit:T(W({},r),{enable:!r.enable})}))})),this.props.datasource.useStreaming&&c().createElement(d.InlineField,{label:"Enable Streaming",labelWidth:B,tooltip:"Enable streaming data if it is supported for the point type."},c().createElement(d.InlineSwitch,{value:h.enable,onChange:()=>this.onChange(T(W({},n),{enableStreaming:T(W({},h),{enable:!h.enable})}))}))),!l.enable&&!m.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:p?"Interval Values":"Interpolate",labelWidth:B},c().createElement(d.InlineSwitch,{value:i.enable,onChange:()=>this.onChange(T(W({},n),{interpolate:T(W({},i),{enable:!i.enable,interval:null})}))})),c().createElement(d.InlineField,{disabled:!i.enable,label:p?"Interval Period":"Interpolate Period",labelWidth:B,tooltip:"Override time between sampling, e.g. '30s'. Defaults to timespan/chart width."},c().createElement(d.Input,{onBlur:a,width:30.633375,value:i.interval,onChange:e=>t(T(W({},n),{interpolate:T(W({},i),{interval:e.target.value})})),placeholder:"30s"}))),!l.enable&&!i.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Recorded Values",labelWidth:B},c().createElement(d.InlineSwitch,{value:m.enable,onChange:()=>this.onChange(T(W({},n),{recordedValues:T(W({},m),{enable:!m.enable,maxNumber:null,boundaryType:"Inside"})}))})),c().createElement(d.InlineField,{disabled:!(null==m?void 0:m.enable),label:"Max Recorded Values",labelWidth:B,tooltip:"Maximum number of recorded value to retrive from the data archive, without using interpolation."},c().createElement(d.Input,{onBlur:a,width:30.633375,value:m.maxNumber,onChange:e=>t(T(W({},n),{recordedValues:T(W({},m),{maxNumber:parseInt(e.target.value,10)})})),type:"number",placeholder:"1000"})),c().createElement(d.InlineField,{disabled:!(null==m?void 0:m.enable),label:"Boundary Type",labelWidth:B,tooltip:"Defines the behavior of data retrieval at the end points of a specified time range."},c().createElement(d.Segment,{Component:c().createElement(k,{width:96,value:{value:null==m?void 0:m.boundaryType},label:null==m?void 0:m.boundaryType}),onChange:this.recordedBoundaryTypeValueChanged,options:this.getRecordedBoundaryTypeSegments(),allowCustomValue:!0}))),!l.enable&&c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Summary Period",labelWidth:B,tooltip:"Define the summary period, e.g. '30s'."},c().createElement(d.Input,{onBlur:a,width:30.633375,value:null==b?void 0:b.interval,onChange:e=>t(T(W({},n),{summary:T(W({},b),{interval:e.target.value})})),placeholder:"30s"})),c().createElement(d.InlineField,{label:"Basis",labelWidth:30.633375,tooltip:"Defines the possible calculation options when performing summary calculations over time-series data."},c().createElement(d.Segment,{Component:c().createElement(k,{width:192,marginRight:"0",value:{value:null==b?void 0:b.basis},label:null==b?void 0:b.basis}),onChange:this.calcBasisValueChanged,options:this.getCalcBasisSegments(),allowCustomValue:!0})),c().createElement(d.InlineField,{label:"Summaries",labelWidth:B,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(k,{value:e.value,label:e.label}),onChange:e=>this.onSummaryValueChanged(e,t),options:this.getSummarySegments(),allowCustomValue:!0}))),c().createElement(d.Segment,{Component:c().createElement(k,{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:B,tooltip:"If single attribute, modify display name. Otherwise use regex to modify display name."},c().createElement(d.Input,{onBlur:a,width:30.633375,value:y,onChange:e=>t(T(W({},n),{display:e.target.value})),placeholder:"Display"})),c().createElement(d.InlineField,{label:"Enable Regex Replace",labelWidth:B},c().createElement(d.InlineSwitch,{value:f.enable,onChange:()=>{this.onChange(T(W({},n),{regex:T(W({},f),{enable:!f.enable})}))}})),c().createElement(d.InlineField,{label:"Search",labelWidth:B},c().createElement(d.Input,{onBlur:a,width:B,value:f.search,onChange:e=>t(T(W({},n),{regex:T(W({},f),{search:e.target.value})})),placeholder:"(.*)"})),c().createElement(d.InlineField,{label:"Replace",labelWidth:B},c().createElement(d.Input,{onBlur:a,width:B,value:f.replace,onChange:e=>t(T(W({},n),{regex:T(W({},f),{replace:e.target.value})})),placeholder:"$1"}))))}constructor(e){super(e),V(this,"error",void 0),V(this,"piServer",[]),V(this,"availableAttributes",{}),V(this,"summaryTypes",void 0),V(this,"calculationBasis",void 0),V(this,"recordedBoundaryTypes",void 0),V(this,"noDataReplacement",void 0),V(this,"state",{isPiPoint:!1,hideError:!1,segments:[],attributes:[],summaries:[],attributeSegment:{},summarySegment:{},calculationBasisSegment:{},noDataReplacementSegment:{}}),V(this,"segmentChangeValue",(e=>{const t=this.props.query;this.setState({segments:e},(()=>this.onChange(T(W({},t),{segments:e}))))})),V(this,"attributeChangeValue",(e=>{const t=this.props.query;return new Promise((a=>this.setState({attributes:e},(()=>{this.onChange(T(W({},t),{attributes:e})),a()}))))})),V(this,"onPiPointChange",((e,t)=>{let a=this.state.attributes.slice(0);e.label===q?(0,E.remove)(a,((e,a)=>a===t)):a[t]=e,this.checkPiPointSegments(e,a)})),V(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))})),V(this,"onSegmentChange",((e,t)=>{var a;const{query:n}=this.props;let l=this.state.segments.slice(0);if(null!==e.value&&"object"!=typeof e.value&&!Array.isArray(e.value)){const t=String(e.value);e.value={type:t.match(/\${\w+}/gi)?"template":void 0,value:t}}l[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&this.setState({attributes:[]},(()=>e.label===q?(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 a,n;return"template"===(null===(a=e.value)||void 0===a?void 0:a.type)?this.getElementSegments(l.length+1,l).then((e=>(e.length>0&&(l[t].value.expandable=!0,l.push({label:"Select Element",value:{value:"-Select Element-"}})),this.segmentChangeValue(l),l))):((null===(n=e.value)||void 0===n?void 0:n.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),new Promise((e=>{this.segmentChangeValue(l),e(l)})))}))))))})),V(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:q,value:{value:q}}),t})).catch((e=>(i.error=e.message||"Failed to issue metric query",[])))})),V(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:q,value:{value:q}}),s})).catch((e=>(r.error=e.message||"Failed to issue metric query",s)))})),V(this,"getAttributeSegmentsAF",(e=>{const{datasource:t}=this.props;let a=[];a.push({label:q,value:{value:q}});const n=t.templateSrv.getVariables();return(0,E.each)(n,(e=>{let t={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!1}};a.push(t)})),(0,E.forOwn)(this.availableAttributes,((e,t)=>{let n={label:t,value:{value:t,expandable:!0}};a.push(n)})),a})),V(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:{type:e.match(/\${\w+}/gi)?"template":void 0,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)})),V(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})),V(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()}))}))})),V(this,"scopedVarsDone",!1),V(this,"componentDidMount",(()=>{this.initialLoad(!1)})),V(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))})),V(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)}))})),V(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(T(W({},e),{summary:r})),this.isValidQuery(e)&&a()})),V(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})),V(this,"stateCallback",(()=>{const e=this.props.query;this.onChange(e)})),V(this,"onIsPiPointChange",(e=>{const{query:t}=this.props,a=!t.isPiPoint;this.setState({segments:a?[{label:""}]:this.checkAfServer(),attributes:[],isPiPoint:a},(()=>{this.onChange(T(W({},t),{expression:"",attributes:this.state.attributes,segments:this.state.segments,isPiPoint:a}))}))})),V(this,"onHideErrorChange",(e=>{const{query:t}=this.props,a=!t.hideError;this.setState({hideError:a},(()=>{this.onChange(T(W({},t),{hideError:a}))}))})),this.onSegmentChange=this.onSegmentChange.bind(this),this.calcBasisValueChanged=this.calcBasisValueChanged.bind(this),this.recordedBoundaryTypeValueChanged=this.recordedBoundaryTypeValueChanged.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.recordedBoundaryTypes=["Inside","Outside","Interpolated"],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 $(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=>{g(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:G,grow:!0},c().createElement(d.AsyncSelect,{key:null!=v?v:"database-key",loadOptions:()=>o.getDatabases(v).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("database"),onChange:e=>{f(e.value),h(L($({},s),{database:e.value,template:void 0}))},defaultOptions:!0})),c().createElement(d.InlineField,{label:"Event Frames",labelWidth:G,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($({},s),{template:e.value})),defaultOptions:!0})),c().createElement(d.InlineField,{label:"Show Start and End Time",labelWidth:G,grow:!0},c().createElement(d.InlineSwitch,{value:!!s.showEndTime,onChange:e=>h(L($({},s),{showEndTime:e.currentTarget.checked}))}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Category name",labelWidth:G,grow:!0},c().createElement(d.Input,{type:"text",value:s.categoryName,onBlur:e=>p(),onChange:e=>h(L($({},s),{categoryName:e.currentTarget.value})),placeholder:"Enter category name"})),c().createElement(d.InlineField,{label:"Name Filter",labelWidth:G,grow:!0},c().createElement(d.Input,{type:"text",value:s.nameFilter,onBlur:e=>p(),onChange:e=>h(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:G,grow:!1},c().createElement(d.InlineSwitch,{value:null===(a=s.regex)||void 0===a?void 0:a.enable,onChange:e=>h(L($({},s),{regex: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(L($({},s),{regex: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(L($({},s),{regex:L($({},s.regex),{replace:e.currentTarget.value})})),placeholder:"$1"}))),c().createElement(d.InlineFieldRow,null,c().createElement(d.InlineField,{label:"Enable Attribute Usage",labelWidth:G,grow:!1},c().createElement(d.InlineSwitch,{value:null===(r=s.attribute)||void 0===r?void 0:r.enable,onChange:e=>h(L($({},s),{attribute:L($({},s.attribute),{enable:e.currentTarget.checked})}))})),c().createElement(d.InlineField,{label:"Attribute Name",labelWidth:G,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($({},s),{attribute: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&&(t.value.value=this.templateSrv.replace(t.value.value,e.scopedVars)),t))),segments:(0,E.map)(t.segments,(t=>(t.value&&(t.value.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||{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,hideError:!!t.hideError,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.summary.interval=n.summary.interval?this.templateSrv.replace(n.summary.interval,e.scopedVars):n.summary.interval),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){return this.getResource(`${e}`).then((e=>e))}getDataServers(){return this.restGet("/dataservers").then((e=>{var t;return null!==(t=e.Items)&&void 0!==t?t:[]}))}getDataServer(e){return e?this.restGet("/dataservers?name="+e).then((e=>e)):Promise.resolve({})}getAssetServers(){return this.restGet("/assetservers").then((e=>{var t;return null!==(t=e.Items)&&void 0!==t?t:[]}))}getAssetServer(e){return e?this.restGet("/assetservers?path=\\\\"+e).then((e=>e)):Promise.resolve({})}getDatabase(e){return e?this.restGet("/assetdatabases?path=\\\\"+e).then((e=>e)):Promise.resolve({})}getDatabases(e,t){return e?this.restGet("/assetservers/"+e+"/assetdatabases").then((e=>{var t;return null!==(t=e.Items)&&void 0!==t?t:[]})):Promise.resolve([])}getElement(e){return e?this.restGet("/elements?path=\\\\"+e).then((e=>e)):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.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.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.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.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.Items)&&void 0!==t?t:[]}))}piPointSearch(e,t){let a=this.templateSrv.replace(t),n=`${a}`,l=!1;if(a!==t){const e=/\{(\w|,)+\}/g;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=100&nameFilter="+n).then((e=>e&&(null==e?void 0:e.Items)?l?e.Items.filter((e=>{var t;return null===(t=e.Name)||void 0===t?void 0:t.match(a)})):e.Items:[]))}constructor(e,t=(0,M.getTemplateSrv)()){super(e),_(this,"templateSrv",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.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})())); +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 m=o(781),h=o(959),d=o.n(h),c=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 v(e){for(var t=1;tg(v({},e),{jsonData:g(v({},e.jsonData),{url:e.url})});class f extends h.PureComponent{render(){const{options:e}=this.props,t=y(e);return d().createElement("div",null,d().createElement(c.DataSourceHttpSettings,{defaultUrl:"https://server.name/piwebapi",dataSourceConfig:t,onChange:this.onHttpOptionsChange,showAccessOptions:!0}),d().createElement("h3",{className:"page-heading"},"Custom Configuration"),d().createElement("div",{className:"gf-form-group"},d().createElement("div",{className:"gf-form-inline"},d().createElement(c.InlineField,{label:"Enable PI Points in Query",labelWidth:24},d().createElement(c.InlineSwitch,{value:t.jsonData.pipoint,onChange:this.onPiPointChange}))),d().createElement("div",{className:"gf-form-inline"},d().createElement(c.InlineField,{label:"Enable New Data Format",labelWidth:24},d().createElement(c.InlineSwitch,{value:t.jsonData.newFormat,onChange:this.onNewFormatChange}))),d().createElement("div",{className:"gf-form-inline"},d().createElement(c.InlineField,{label:"Enable Unit in Data",labelWidth:24},d().createElement(c.InlineSwitch,{value:t.jsonData.useUnit,onChange:this.onUseUnitChange}))),d().createElement("div",{className:"gf-form-inline"},d().createElement(c.InlineField,{label:"Enable Experimental Features",labelWidth:24},d().createElement(c.InlineSwitch,{value:t.jsonData.useExperimental,onChange:this.onUseExperimentalChange}))),t.jsonData.useExperimental&&d().createElement("div",{className:"gf-form-inline"},d().createElement(c.InlineField,{label:"Enable Steaming Support",labelWidth:24},d().createElement(c.InlineSwitch,{value:t.jsonData.useStreaming,onChange:this.onUseStreamingChange})))),d().createElement("h3",{className:"page-heading"},"PI/AF Connection Details"),d().createElement("div",{className:"gf-form-group"},t.jsonData.pipoint&&d().createElement("div",{className:"gf-form"},d().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"})),d().createElement("div",{className:"gf-form"},d().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"})),d().createElement("div",{className:"gf-form"},d().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=g(v({},a.jsonData),{piserver:e.target.value});t(g(v({},a),{jsonData:n}))})),p(this,"onAFServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{afserver:e.target.value});t(g(v({},a),{jsonData:n}))})),p(this,"onAFDatabaseChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{afdatabase:e.target.value});t(g(v({},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=g(v({},a.jsonData),{piserver:e.target.checked?a.jsonData.piserver:"",pipoint:e.target.checked});t(g(v({},a),{jsonData:n}))})),p(this,"onNewFormatChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{newFormat:e.target.checked});t(g(v({},a),{jsonData:n}))})),p(this,"onUseUnitChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{useUnit:e.target.checked});t(g(v({},a),{jsonData:n}))})),p(this,"onUseExperimentalChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{useExperimental:e.target.checked,useStreaming:!!e.target.checked&&a.jsonData.useStreaming});t(g(v({},a),{jsonData:n}))})),p(this,"onUseStreamingChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=g(v({},a.jsonData),{useStreaming:e.target.checked});t(g(v({},a),{jsonData:n}))}))}}var E=o(241);function S(){return S=Object.assign||function(e){for(var t=1;td().createElement(d().Fragment,null,d().createElement(c.InlineFormLabel,{width:t,tooltip:a},e),n),P=()=>d().createElement("div",{className:"gf-form gf-form--grow"},d().createElement("div",{className:"gf-form-label gf-form-label--grow"})),w=e=>{var t=S({},I(e));return d().createElement(O,null,d().createElement(C,t))},O=e=>d().createElement("div",{className:"gf-form-inline"},e.children,d().createElement(P,null)),x=e=>{var t=S({},I(e));return d().createElement(F,null,d().createElement(C,t))},F=e=>d().createElement(d().Fragment,null,e.children),D={target:";",attributes:[],segments:[],regex:{enable:!1},nodata:"Null",summary:{enable:!1,types:[],basis:"EventWeighted",duration:"",sampleTypeInterval:!1,sampleInterval:""},expression:"",interpolate:{enable:!1},useLastValue:{enable:!1},recordedValues:{enable:!1,boundaryType:"Inside"},digitalStates:{enable:!1},enableStreaming:{enable:!1},useUnit:{enable:!1},isPiPoint:!1},j=({isRaw:e,onChange:t})=>{const[a,n]=(0,h.useState)(!1);return(0,h.useEffect)((()=>{n(!1)}),[e]),e?d().createElement(d().Fragment,null,d().createElement(c.Button,{"aria-label":"Switch to visual editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{n(!0)}}),d().createElement(c.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)}})):d().createElement(c.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?d().createElement("div",{style:{width:e.width,marginRight:e.marginRight},className:"gf-form-label "+("template"===e.value.type?"query-keyword":"")},null!==(t=e.label)&&void 0!==t?t:"--no label--"):d().createElement("a",{className:"gf-form-label query-part"},d().createElement(c.Icon,{name:"plus"}))};class R extends h.PureComponent{isValueEmpty(e){return!e||!e.value||!e.value.length||e.value===q}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(T(V({},t),{summary:a}))}getCalcBasisSegments(){return(0,E.map)(this.calculationBasis,(e=>({label:e,value:{value:e,expandable:!0}})))}recordedBoundaryTypeValueChanged(e){const t=this.props.query,a=t.recordedValues;var n;a&&(a.boundaryType=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(T(V({},t),{recordedValues:a}))}getRecordedBoundaryTypeSegments(){return(0,E.map)(this.recordedBoundaryTypes,(e=>({label:e,value:{value:e,expandable:!0}})))}calcNoDataValueChanged(e){var t;const a=this.props.query,n=null===(t=e.value)||void 0===t?void 0:t.value;this.onChange(T(V({},a),{nodata:n}))}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:q,value:{value:q}}),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(null!==e.value&&"object"!=typeof e.value&&!Array.isArray(e.value)){const t=String(e.value);e.value={type:t.match(/\${\w+}/gi)?"template":void 0,value:t}}if(!this.isValueEmpty(e.value)){var n,l,r;let i={label:e.label,value:{type:(null===(n=e.value)||void 0===n?void 0:n.value)&&(null===(l=e.value)||void 0===l?void 0:l.value.match(/\${\w+}/gi))?"template":void 0,value:null===(r=e.value)||void 0===r?void 0:r.value,expandable:!t.isPiPoint}};a.push(i)}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:{type:e.match(/\${\w+}/gi)?"template":void 0,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(T(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(T(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,D),{useLastValue:l,useUnit:r,interpolate:i,query:s,rawQuery:o,digitalStates:u,enableStreaming:m,recordedValues:h,expression:p,isPiPoint:v,hideError:g,summary:b,nodata:y,display:f,regex:S}=n;return d().createElement(d().Fragment,null,this.props.datasource.piPointConfig&&d().createElement(c.InlineField,{label:"Is Pi Point?",labelWidth:B},d().createElement(c.InlineSwitch,{value:v,onChange:this.onIsPiPointChange})),!!o&&d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Raw Query",labelWidth:B,grow:!0},d().createElement(c.Input,{onBlur:this.stateCallback,value:s,onChange:e=>t(T(V({},n),{query:e.target.value})),placeholder:"enter query"})),d().createElement(j,{isRaw:!0,onChange:e=>this.textEditorChanged()})),!o&&d().createElement(d().Fragment,null,d().createElement("div",{className:"gf-form-inline"},d().createElement(x,{label:v?"PI Server":"AF Elements",tooltip:v?"Select PI server.":"Select AF Element."},this.state.segments.map(((e,t)=>d().createElement(c.SegmentAsync,{key:"element-"+t,Component:d().createElement(k,{value:e.value,label:e.label}),onChange:e=>this.onSegmentChange(e,t),loadOptions:e=>this.getElementSegments(t),allowCustomValue:!0,inputMinWidth:200}))),d().createElement(P,null),!v&&d().createElement(j,{isRaw:!1,onChange:e=>{t(T(V({},n),{query:n.target,rawQuery:e}))}}))),d().createElement(w,{label:v?"Pi Points":"Attributes"},this.state.attributes.map(((e,t)=>v?d().createElement(c.SegmentAsync,{key:"attributes-"+t,Component:d().createElement(k,{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:N}):d().createElement(c.Segment,{key:"attributes-"+t,Component:d().createElement(k,{value:e.value,label:e.label}),disabled:this.state.segments.length<=2,onChange:e=>this.onAttributeChange(e,t),options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:N}))),v&&d().createElement(c.SegmentAsync,{Component:d().createElement(k,{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:N}),!v&&d().createElement(c.Segment,{Component:d().createElement(k,{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:N}))),d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Calculation",grow:!0,labelWidth:B,tooltip:"Modify all attributes by an equation. Use '.' for current item. Leave Attributes empty if you wish to perform element based calculations."},d().createElement(c.Input,{onBlur:a,value:p,onChange:e=>t(T(V({},n),{expression:e.target.value})),placeholder:"'.'*2"}))),d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Use Last Value",tooltip:"Fetch only last value from time range",labelWidth:B},d().createElement(c.InlineSwitch,{value:l.enable,onChange:()=>this.onChange(T(V({},n),{useLastValue:T(V({},l),{enable:!l.enable})}))})),d().createElement(c.InlineField,{label:"Digital States",labelWidth:B},d().createElement(c.InlineSwitch,{value:u.enable,onChange:()=>this.onChange(T(V({},n),{digitalStates:T(V({},u),{enable:!u.enable})}))})),d().createElement(c.InlineField,{label:"Replace Bad Data",labelWidth:B,tooltip:"Replacement for bad quality values."},d().createElement(c.Segment,{Component:d().createElement(k,{width:96,value:{value:y},label:y}),onChange:this.calcNoDataValueChanged,options:this.getNoDataSegments(),allowCustomValue:!0})),d().createElement(c.InlineField,{label:"Ignore API Error?",labelWidth:B},d().createElement(c.InlineSwitch,{value:g,onChange:this.onHideErrorChange})),this.props.datasource.useUnitConfig&&d().createElement(c.InlineField,{label:"Use unit from datapoints",tooltip:"Use unit in label from PI tag or PI AF attribute",labelWidth:B},d().createElement(c.InlineSwitch,{value:r.enable,onChange:()=>this.onChange(T(V({},n),{useUnit:T(V({},r),{enable:!r.enable})}))})),this.props.datasource.useStreaming&&d().createElement(c.InlineField,{label:"Enable Streaming",labelWidth:B,tooltip:"Enable streaming data if it is supported for the point type."},d().createElement(c.InlineSwitch,{value:m.enable,onChange:()=>this.onChange(T(V({},n),{enableStreaming:T(V({},m),{enable:!m.enable})}))}))),(i.enable||!l.enable&&!h.enable)&&d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:p?"Interval Values":"Interpolate",labelWidth:B},d().createElement(c.InlineSwitch,{value:i.enable,onChange:()=>this.onChange(T(V({},n),{interpolate:T(V({},i),{enable:!i.enable,interval:null})}))})),d().createElement(c.InlineField,{disabled:!i.enable,label:p?"Interval Period":"Interpolate Period",labelWidth:B,tooltip:"Override time between sampling, e.g. '30s'. Defaults to timespan/chart width."},d().createElement(c.Input,{onBlur:a,width:30.633375,value:i.interval,onChange:e=>t(T(V({},n),{interpolate:T(V({},i),{interval:e.target.value})})),placeholder:"30s"}))),(h.enable||!l.enable&&!i.enable)&&d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Recorded Values",labelWidth:B},d().createElement(c.InlineSwitch,{value:h.enable,onChange:()=>this.onChange(T(V({},n),{recordedValues:T(V({},h),{enable:!h.enable,maxNumber:null,boundaryType:"Inside"})}))})),d().createElement(c.InlineField,{disabled:!(null==h?void 0:h.enable),label:"Max Recorded Values",labelWidth:B,tooltip:"Maximum number of recorded value to retrive from the data archive, without using interpolation."},d().createElement(c.Input,{onBlur:a,width:30.633375,value:h.maxNumber,onChange:e=>t(T(V({},n),{recordedValues:T(V({},h),{maxNumber:parseInt(e.target.value,10)})})),type:"number",placeholder:"1000"})),d().createElement(c.InlineField,{disabled:!(null==h?void 0:h.enable),label:"Boundary Type",labelWidth:B,tooltip:"Defines the behavior of data retrieval at the end points of a specified time range."},d().createElement(c.Segment,{Component:d().createElement(k,{width:96,value:{value:null==h?void 0:h.boundaryType},label:null==h?void 0:h.boundaryType}),onChange:this.recordedBoundaryTypeValueChanged,options:this.getRecordedBoundaryTypeSegments(),allowCustomValue:!0}))),!l.enable&&d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Summary Enable",labelWidth:B},d().createElement(c.InlineSwitch,{value:null==b?void 0:b.enable,onChange:()=>this.onChange(T(V({},n),{summary:T(V({},b),{enable:!(null==b?void 0:b.enable)})}))})),d().createElement(c.InlineField,{disabled:!(null==b?void 0:b.enable),label:"Summary Basis",labelWidth:B,tooltip:"Defines the possible calculation options when performing summary calculations over time-series data."},d().createElement(c.Segment,{Component:d().createElement(k,{width:245.067,marginRight:"0",value:{value:null==b?void 0:b.basis},label:null==b?void 0:b.basis}),onChange:this.calcBasisValueChanged,options:this.getCalcBasisSegments(),allowCustomValue:!0})),d().createElement(c.InlineField,{disabled:!(null==b?void 0:b.enable),label:"Summaries Types",labelWidth:B,tooltip:"PI Web API summary options."},d().createElement(c.InlineFieldRow,null,this.state.summaries.map(((e,t)=>d().createElement(c.Segment,{key:"summaries-"+t,Component:d().createElement(k,{value:e.value,label:e.label}),onChange:e=>this.onSummaryValueChanged(e,t),options:this.getSummarySegments(),allowCustomValue:!0}))),d().createElement(c.Segment,{Component:d().createElement(k,{value:this.state.summarySegment.value,label:this.state.summarySegment.label}),onChange:this.onSummaryAction,options:this.getSummarySegments(),allowCustomValue:!0})))),(null==b?void 0:b.enable)&&d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Enable interval",labelWidth:B,tooltip:"Enable summary type interval."},d().createElement(c.InlineSwitch,{value:!!(null==b?void 0:b.sampleTypeInterval),onChange:()=>this.onChange(T(V({},n),{summary:T(V({},b),{sampleTypeInterval:!(null==b?void 0:b.sampleTypeInterval)})}))})),d().createElement(c.InlineField,{disabled:!b.sampleTypeInterval,label:"Sample Interval",labelWidth:B,tooltip:"A time span specifies how often the filter expression is evaluated when computing the summary for an interval, if the sampleType is enable."},d().createElement(c.Input,{onBlur:a,width:30.633375,value:null==b?void 0:b.sampleInterval,onChange:e=>t(T(V({},n),{summary:T(V({},b),{sampleInterval:e.target.value})})),placeholder:"30s"})),d().createElement(c.InlineField,{label:"Summary Period",labelWidth:B,tooltip:"The duration of each summary interval, e.g. '30s'."},d().createElement(c.Input,{onBlur:a,width:30.633375,value:null==b?void 0:b.duration,onChange:e=>t(T(V({},n),{summary:T(V({},b),{duration:e.target.value})})),placeholder:"30s"}))),d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Display Name",labelWidth:B,tooltip:"If single attribute, modify display name. Otherwise use regex to modify display name."},d().createElement(c.Input,{onBlur:a,width:30.633375,value:f,onChange:e=>t(T(V({},n),{display:e.target.value})),placeholder:"Display"})),d().createElement(c.InlineField,{label:"Enable Regex Replace",labelWidth:B},d().createElement(c.InlineSwitch,{value:S.enable,onChange:()=>{this.onChange(T(V({},n),{regex:T(V({},S),{enable:!S.enable})}))}})),d().createElement(c.InlineField,{label:"Search",labelWidth:B},d().createElement(c.Input,{onBlur:a,width:B,value:S.search,onChange:e=>t(T(V({},n),{regex:T(V({},S),{search:e.target.value})})),placeholder:"(.*)"})),d().createElement(c.InlineField,{label:"Replace",labelWidth:B},d().createElement(c.Input,{onBlur:a,width:B,value:S.replace,onChange:e=>t(T(V({},n),{regex:T(V({},S),{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,"recordedBoundaryTypes",void 0),W(this,"noDataReplacement",void 0),W(this,"state",{isPiPoint:!1,hideError:!1,segments:[],attributes:[],summaries:[],attributeSegment:{},summarySegment:{},calculationBasisSegment:{},noDataReplacementSegment:{}}),W(this,"segmentChangeValue",(e=>{const t=this.props.query;this.setState({segments:e},(()=>this.onChange(T(V({},t),{segments:e}))))})),W(this,"attributeChangeValue",(e=>{const t=this.props.query;return new Promise((a=>this.setState({attributes:e},(()=>{this.onChange(T(V({},t),{attributes:e})),a()}))))})),W(this,"onPiPointChange",((e,t)=>{let a=this.state.attributes.slice(0);e.label===q?(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);if(null!==e.value&&"object"!=typeof e.value&&!Array.isArray(e.value)){const t=String(e.value);e.value={type:t.match(/\${\w+}/gi)?"template":void 0,value:t}}l[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&this.setState({attributes:[]},(()=>e.label===q?(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 a,n;return"template"===(null===(a=e.value)||void 0===a?void 0:a.type)?this.getElementSegments(l.length+1,l).then((e=>(e.length>0&&(l[t].value.expandable=!0,l.push({label:"Select Element",value:{value:"-Select Element-"}})),this.segmentChangeValue(l),l))):((null===(n=e.value)||void 0===n?void 0:n.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,m;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===(m=n.afdatabase)||void 0===m?void 0:m.name)&&1===e)return Promise.resolve([{label:n.afdatabase.name,value:{value:n.afdatabase.name,expandable:!0}}])}var h;return n.metricFindQuery(s,Object.assign(null!==(h=null==r||null===(a=r.request)||void 0===a?void 0:a.scopedVars)&&void 0!==h?h:{},{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:q,value:{value:q}}),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:q,value:{value:q}}),s})).catch((e=>(r.error=e.message||"Failed to issue metric query",s)))})),W(this,"getAttributeSegmentsAF",(e=>{const{datasource:t}=this.props;let a=[];a.push({label:q,value:{value:q}});const n=t.templateSrv.getVariables();return(0,E.each)(n,(e=>{let t={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!1}};a.push(t)})),(0,E.forOwn)(this.availableAttributes,((e,t)=>{let n={label:t,value:{value:t,expandable:!0}};a.push(n)})),a})),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:{type:e.match(/\${\w+}/gi)?"template":void 0,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,D),{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 m=e?[]:null!==(u=null==l?void 0:l.slice(0))&&void 0!==u?u:[];var h;let d=null!==(h=null==r?void 0:r.types)&&void 0!==h?h:[];if(i||0!==o.length)i&&o.length>0&&(this.piServer=o);else{if(t.target&&t.target.length>0&&";"!==t.target)return m=[],void this.buildFromTarget(t,o,m).then((e=>{this.updateArray(e,m,d,!1)})).catch((e=>console.error(e)));o=this.checkAfServer()}this.updateArray(o,m,d,!!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(T(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(T(V({},t),{expression:"",attributes:this.state.attributes,segments:this.state.segments,isPiPoint:a}))}))})),W(this,"onHideErrorChange",(e=>{const{query:t}=this.props,a=!t.hideError;this.setState({hideError:a},(()=>{this.onChange(T(V({},t),{hideError:a}))}))})),this.onSegmentChange=this.onSegmentChange.bind(this),this.calcBasisValueChanged=this.calcBasisValueChanged.bind(this),this.recordedBoundaryTypeValueChanged=this.recordedBoundaryTypeValueChanged.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.recordedBoundaryTypes=["Inside","Outside","Interpolated"],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 $(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=>{g(e.WebId)})),d().createElement(d().Fragment,null,d().createElement("div",{className:"gf-form-group"},d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Database",labelWidth:G,grow:!0},d().createElement(c.AsyncSelect,{key:null!=v?v:"database-key",loadOptions:()=>o.getDatabases(v).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("database"),onChange:e=>{f(e.value),m(L($({},s),{database:e.value,template:void 0}))},defaultOptions:!0})),d().createElement(c.InlineField,{label:"Event Frames",labelWidth:G,grow:!0},d().createElement(c.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=>m(L($({},s),{template:e.value})),defaultOptions:!0})),d().createElement(c.InlineField,{label:"Show Start and End Time",labelWidth:G,grow:!0},d().createElement(c.InlineSwitch,{value:!!s.showEndTime,onChange:e=>m(L($({},s),{showEndTime:e.currentTarget.checked}))}))),d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Category name",labelWidth:G,grow:!0},d().createElement(c.Input,{type:"text",value:s.categoryName,onBlur:e=>p(),onChange:e=>m(L($({},s),{categoryName:e.currentTarget.value})),placeholder:"Enter category name"})),d().createElement(c.InlineField,{label:"Name Filter",labelWidth:G,grow:!0},d().createElement(c.Input,{type:"text",value:s.nameFilter,onBlur:e=>p(),onChange:e=>m(L($({},s),{nameFilter:e.currentTarget.value})),placeholder:"Enter name filter"}))),d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Enable Name Regex Replacement",labelWidth:G,grow:!1},d().createElement(c.InlineSwitch,{value:null===(a=s.regex)||void 0===a?void 0:a.enable,onChange:e=>m(L($({},s),{regex:L($({},s.regex),{enable:e.currentTarget.checked})}))})),d().createElement(c.InlineField,{label:"Name Filter",labelWidth:20,grow:!1},d().createElement(c.Input,{type:"text",value:null===(n=s.regex)||void 0===n?void 0:n.search,onBlur:e=>p(),onChange:e=>m(L($({},s),{regex:L($({},s.regex),{search:e.currentTarget.value})})),placeholder:"(.*)",width:50})),d().createElement(c.InlineField,{label:"Replace",labelWidth:20,grow:!0},d().createElement(c.Input,{type:"text",value:null==s||null===(l=s.regex)||void 0===l?void 0:l.replace,onBlur:e=>p(),onChange:e=>m(L($({},s),{regex:L($({},s.regex),{replace:e.currentTarget.value})})),placeholder:"$1"}))),d().createElement(c.InlineFieldRow,null,d().createElement(c.InlineField,{label:"Enable Attribute Usage",labelWidth:G,grow:!1},d().createElement(c.InlineSwitch,{value:null===(r=s.attribute)||void 0===r?void 0:r.enable,onChange:e=>m(L($({},s),{attribute:L($({},s.attribute),{enable:e.currentTarget.checked})}))})),d().createElement(c.InlineField,{label:"Attribute Name",labelWidth:G,grow:!0},d().createElement(c.Input,{type:"text",value:null===(i=s.attribute)||void 0===i?void 0:i.name,onBlur:e=>p(),onChange:e=>m(L($({},s),{attribute: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&&(t.value.value=this.templateSrv.replace(t.value.value,e.scopedVars)),t))),segments:(0,E.map)(t.segments,(t=>(t.value&&(t.value.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||{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||{enable:!1,types:[]},nodata:t.nodata,startTime:e.range.from,endTime:e.range.to,isPiPoint:!!t.isPiPoint,hideError:!!t.hideError,scopedVars:e.scopedVars};return n.expression&&(n.expression=this.templateSrv.replace(n.expression,e.scopedVars)),n.summary.enable&&void 0!==n.summary.types&&(n.summary.types=(0,E.filter)(n.summary.types,(e=>null!=e&&""!==e)),n.summary.duration=n.summary.duration?this.templateSrv.replace(n.summary.duration,e.scopedVars):n.summary.duration,n.summary.sampleTypeInterval=!!n.summary.sampleTypeInterval,n.summary.sampleInterval=n.summary.sampleInterval?this.templateSrv.replace(n.summary.sampleInterval,e.scopedVars):n.summary.sampleInterval),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){return this.getResource(`${e}`).then((e=>e))}getDataServers(){return this.restGet("/dataservers").then((e=>{var t;return null!==(t=e.Items)&&void 0!==t?t:[]}))}getDataServer(e){return e?this.restGet("/dataservers?name="+e).then((e=>e)):Promise.resolve({})}getAssetServers(){return this.restGet("/assetservers").then((e=>{var t;return null!==(t=e.Items)&&void 0!==t?t:[]}))}getAssetServer(e){return e?this.restGet("/assetservers?path=\\\\"+e).then((e=>e)):Promise.resolve({})}getDatabase(e){return e?this.restGet("/assetdatabases?path=\\\\"+e).then((e=>e)):Promise.resolve({})}getDatabases(e,t){return e?this.restGet("/assetservers/"+e+"/assetdatabases").then((e=>{var t;return null!==(t=e.Items)&&void 0!==t?t:[]})):Promise.resolve([])}getElement(e){return e?this.restGet("/elements?path=\\\\"+e).then((e=>e)):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.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.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.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.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.Items)&&void 0!==t?t:[]}))}piPointSearch(e,t){let a=this.templateSrv.replace(t),n=`${a}`,l=!1;if(a!==t){const e=/\{(\w|,)+\}/g;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=100&nameFilter="+n).then((e=>e&&(null==e?void 0:e.Items)?l?e.Items.filter((e=>{var t;return null===(t=e.Name)||void 0===t?void 0:t.match(a)})):e.Items:[]))}constructor(e,t=(0,M.getTemplateSrv)()){super(e),_(this,"templateSrv",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.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 m.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 82c3845..1e8c839 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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AAK8V,cAAc9V,KAAK2B,SAAS8E,MAAMyD,MAAMZ,GAAyBtJ,KAAK2B,SAASqS,MAAQ1K,EAAOrD,QACnGjG,KAAKgR,eAAehR,KAAK8B,SAAS2E,MAAMyD,MAAMZ,GAAyBtJ,KAAK8B,SAASkS,MAAQ1K,EAAOrD,QACpGjG,KAAK8S,YACH9S,KAAK8B,SAAS2E,MAAQzG,KAAKgC,WAAWyE,KAAOzG,KAAK8B,SAAS2E,KAAO,KAAOzG,KAAKgC,WAAWyE,UAAO1I,GAChGmM,MAAMZ,GAAyBtJ,KAAKgC,WAAWgS,MAAQ1K,EAAOrD,SAEpE,EChEK,MAAMuR,EAAS,IAAIC,EAAAA,iBACxB5F,GAEC6F,eAAehR,GACfiR,gBAAgB/X,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 hideError?: 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?: {\n nodata?: string,\n types?: any[],\n basis?: string,\n interval?: string\n };\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, boundaryType: 'Inside' },\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 LABEL_SWITCH_WIDTH = 49.067 / 8.0;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n hideError: 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 recordedBoundaryTypes: string [];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n hideError: 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.recordedBoundaryTypeValueChanged = this.recordedBoundaryTypeValueChanged.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.recordedBoundaryTypes = [\n 'Inside', // Default. Specifies to return the recorded values on the inside of the requested time range as the first and last values. \n 'Outside', // Specifies to return the recorded values on the outside of the requested time range as the first and last values.\n 'Interpolated', //Specifies to create an interpolated value at the end points of the requested time range if a recorded value does not exist at that time.\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 // recorded boundary type change event\n recordedBoundaryTypeValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const recordedValues = metricsQuery.recordedValues;\n if (recordedValues) {\n recordedValues.boundaryType = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, recordedValues });\n }\n // get recorded boundary type user interface segments\n getRecordedBoundaryTypeSegments() {\n const segments = map(this.recordedBoundaryTypes, (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 // partial variable\n if (item.value !== null && typeof item.value !== 'object' && !Array.isArray(item.value)) {\n const value = String(item.value! as string);\n item.value = {\n type: value.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: value,\n }\n }\n\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 type: item.value?.value && item.value?.value.match(/\\${\\w+}/gi) ? 'template' : undefined,\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, (_, 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 // partial variable\n if (item.value !== null && typeof item.value !== 'object' && !Array.isArray(item.value)) {\n const value = String(item.value! as string);\n item.value = {\n type: value.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: value,\n }\n }\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[index].value!.expandable = true;\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 { datasource } = this.props;\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 // 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: false,\n },\n };\n segments.push(selectableValue);\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 type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\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 type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\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 onHideErrorChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const hideError = !queryChange.hideError;\n this.setState(\n {\n hideError,\n },\n () => {\n this.onChange({\n ...queryChange,\n hideError,\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 hideError,\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 }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n \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 {!useLastValue.enable && !recordedValues.enable && (\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable, interval: null } })\n }\n />\n \n \n ) =>\n onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n )}\n\n {!useLastValue.enable && !interpolate.enable && (\n \n \n \n this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable, maxNumber: null, boundaryType: 'Inside' },\n })\n }\n />\n \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 onChange={this.recordedBoundaryTypeValueChanged}\n options={this.getRecordedBoundaryTypeSegments()}\n allowCustomValue\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 }\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 } 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 { getTemplateSrv, TemplateSrv, DataSourceWithBackend } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData, PiDataServer, 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 ) {\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 att.value.value = this.templateSrv.replace(att.value.value, options.scopedVars);\n }\n return att;\n }),\n segments: map(target.segments, (att) => {\n if (att.value) {\n att.value.value = 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 || { 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 hideError: !!target.hideError,\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 tar.summary.interval = !!tar.summary.interval\n ? this.templateSrv.replace(tar.summary.interval, options.scopedVars)\n : tar.summary.interval;\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 return this.getResource(`${path}`).then((response: any) => {\n return response as PiwebapiRsp;\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.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);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.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);\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);\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.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);\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.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.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.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.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.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|,)+\\}/g;\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=100&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results?.Items) {\n return doFilter ? results.Items.filter((item) => item.Name?.match(filter1)) : results.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","boundaryType","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","style","marginRight","Icon","name","PIWebAPIQueryEditor","isValueEmpty","calcBasisValueChanged","segment","metricsQuery","query","getCalcBasisSegments","calculationBasis","recordedBoundaryTypeValueChanged","getRecordedBoundaryTypeSegments","recordedBoundaryTypes","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","Array","isArray","String","match","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","_","getElementSegments","elements","updateArray","rawQuery","checkAfServer","queryProps","onRunQuery","defaults","hideError","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","SegmentAsync","Component","onSegmentChange","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","onAttributeChange","getAttributeSegmentsAF","attributeSegment","onHideErrorChange","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","getResource","restGet","getDataServer","serverId","databaseId","InstanceType","getElementTemplates","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","results","instanceSettings","getTemplateSrv","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,EAE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Q3K,EAAOrD,QACnGnG,KAAKmR,eAAenR,KAAK8B,SAAS6E,MAAMyD,MAAMZ,GAAyBxJ,KAAK8B,SAASqS,MAAQ3K,EAAOrD,QACpGnG,KAAKiT,YACHjT,KAAK8B,SAAS6E,MAAQ3G,KAAKgC,WAAW2E,KAAO3G,KAAK8B,SAAS6E,KAAO,KAAO3G,KAAKgC,WAAW2E,UAAO5I,GAChGqM,MAAMZ,GAAyBxJ,KAAKgC,WAAWmS,MAAQ3K,EAAOrD,SAEpE,EChEK,MAAMwR,EAAS,IAAIC,EAAAA,iBACxB5F,GAEC6F,eAAejR,GACfkR,gBAAgBlY,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 hideError?: 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 nodata?: string,\n summary?: {\n enable?: boolean,\n types?: any[],\n basis?: string,\n duration?: string,\n sampleTypeInterval?: boolean,\n sampleInterval?: string\n };\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 nodata: 'Null',\n summary: {\n enable: false,\n types: [],\n basis: 'EventWeighted',\n duration: '',\n sampleTypeInterval: false,\n sampleInterval: ''\n },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false, boundaryType: 'Inside' },\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';\nimport { types } from '@babel/core';\n\nconst LABEL_WIDTH = 24;\nconst LABEL_SWITCH_WIDTH = 49.067 / 8.0;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n hideError: 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 recordedBoundaryTypes: string [];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n hideError: 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.recordedBoundaryTypeValueChanged = this.recordedBoundaryTypeValueChanged.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.recordedBoundaryTypes = [\n 'Inside', // Default. Specifies to return the recorded values on the inside of the requested time range as the first and last values. \n 'Outside', // Specifies to return the recorded values on the outside of the requested time range as the first and last values.\n 'Interpolated', //Specifies to create an interpolated value at the end points of the requested time range if a recorded value does not exist at that time.\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 // recorded boundary type change event\n recordedBoundaryTypeValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const recordedValues = metricsQuery.recordedValues;\n if (recordedValues) {\n recordedValues.boundaryType = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, recordedValues });\n }\n // get recorded boundary type user interface segments\n getRecordedBoundaryTypeSegments() {\n const segments = map(this.recordedBoundaryTypes, (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 nodata = segment.value?.value;\n this.onChange({ ...metricsQuery, nodata });\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 // partial variable\n if (item.value !== null && typeof item.value !== 'object' && !Array.isArray(item.value)) {\n const value = String(item.value! as string);\n item.value = {\n type: value.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: value,\n }\n }\n\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 type: item.value?.value && item.value?.value.match(/\\${\\w+}/gi) ? 'template' : undefined,\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, (_, 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 // partial variable\n if (item.value !== null && typeof item.value !== 'object' && !Array.isArray(item.value)) {\n const value = String(item.value! as string);\n item.value = {\n type: value.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: value,\n }\n }\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[index].value!.expandable = true;\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 { datasource } = this.props;\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 // 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: false,\n },\n };\n segments.push(selectableValue);\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 type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\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 type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\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 onHideErrorChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const hideError = !queryChange.hideError;\n this.setState(\n {\n hideError,\n },\n () => {\n this.onChange({\n ...queryChange,\n hideError,\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 hideError,\n summary,\n nodata,\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 }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n \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 {(interpolate.enable || (!useLastValue.enable && !recordedValues.enable)) && (\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable, interval: null } })\n }\n />\n \n \n ) =>\n onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n )}\n\n {(recordedValues.enable || (!useLastValue.enable && !interpolate.enable)) && (\n \n \n \n this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable, maxNumber: null, boundaryType: 'Inside' },\n })\n }\n />\n \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 onChange={this.recordedBoundaryTypeValueChanged}\n options={this.getRecordedBoundaryTypeSegments()}\n allowCustomValue\n />\n \n \n )}\n\n {!useLastValue.enable && (\n \n \n \n this.onChange({\n ...metricsQuery,\n summary: { ...summary, enable: !(summary?.enable) },\n })\n }\n />\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 {summary?.enable && (\n \n \n \n this.onChange({ ...metricsQuery, summary: { ...summary, sampleTypeInterval: !(summary?.sampleTypeInterval) } })\n }\n />\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, sampleInterval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, duration: event.target.value } })\n }\n placeholder=\"30s\"\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 } 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 { getTemplateSrv, TemplateSrv, DataSourceWithBackend } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData, PiDataServer, 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 ) {\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 att.value.value = this.templateSrv.replace(att.value.value, options.scopedVars);\n }\n return att;\n }),\n segments: map(target.segments, (att) => {\n if (att.value) {\n att.value.value = 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 || { 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 || { enable: false, types: [] },\n nodata: target.nodata,\n startTime: options.range.from,\n endTime: options.range.to,\n isPiPoint: !!target.isPiPoint,\n hideError: !!target.hideError,\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.enable && tar.summary.types !== undefined) {\n tar.summary.types = filter(tar.summary.types, (item) => {\n return item !== undefined && item !== null && item !== '';\n });\n tar.summary.duration = !!tar.summary.duration\n ? this.templateSrv.replace(tar.summary.duration, options.scopedVars)\n : tar.summary.duration;\n tar.summary.sampleTypeInterval = !!tar.summary.sampleTypeInterval;\n tar.summary.sampleInterval = !!tar.summary.sampleInterval\n ? this.templateSrv.replace(tar.summary.sampleInterval, options.scopedVars)\n : tar.summary.sampleInterval;\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 return this.getResource(`${path}`).then((response: any) => {\n return response as PiwebapiRsp;\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.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);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.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);\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);\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.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);\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.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.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.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.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.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|,)+\\}/g;\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=100&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results?.Items) {\n return doFilter ? results.Items.filter((item) => item.Name?.match(filter1)) : results.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","nodata","summary","types","basis","duration","sampleTypeInterval","sampleInterval","expression","interpolate","useLastValue","recordedValues","boundaryType","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","style","marginRight","Icon","name","PIWebAPIQueryEditor","isValueEmpty","calcBasisValueChanged","segment","metricsQuery","query","getCalcBasisSegments","calculationBasis","recordedBoundaryTypeValueChanged","getRecordedBoundaryTypeSegments","recordedBoundaryTypes","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","Array","isArray","String","match","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","_","getElementSegments","elements","updateArray","rawQuery","checkAfServer","queryProps","onRunQuery","defaults","hideError","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","SegmentAsync","Component","onSegmentChange","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","onAttributeChange","getAttributeSegmentsAF","attributeSegment","onHideErrorChange","useUnitConfig","interval","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","getResource","restGet","getDataServer","serverId","databaseId","InstanceType","getElementTemplates","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","results","instanceSettings","getTemplateSrv","newFormatConfig","annotations","QueryEditor","prepareQuery","anno","queryType","processEvents","eventFrameToAnnotation","all","plugin","DataSourcePlugin","setQueryEditor","setConfigEditor"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/plugin.json b/dist/plugin.json index 703d0ad..4679431 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -40,7 +40,7 @@ {"name": "Annotations Editor", "path": "img/annotations.png"} ], "version": "5.1.0", - "updated": "2024-08-13" + "updated": "2024-09-06" }, "dependencies": { "grafanaDependency": ">=10.1.0", diff --git a/pkg/plugin/annotation_query.go b/pkg/plugin/annotation_query.go index d40c3fb..c700d71 100644 --- a/pkg/plugin/annotation_query.go +++ b/pkg/plugin/annotation_query.go @@ -80,7 +80,8 @@ func (d *Datasource) processAnnotationQuery(ctx context.Context, query backend.D } func (q PiProcessedAnnotationQuery) getTimeRangeURIComponent() string { - return "&startTime=" + q.TimeRange.From.UTC().Format(time.RFC3339) + "&endTime=" + q.TimeRange.To.UTC().Format(time.RFC3339) + return "&startTime=" + q.TimeRange.From.UTC().Truncate(time.Second).Format(time.RFC3339) + + "&endTime=" + q.TimeRange.To.UTC().Truncate(time.Second).Format(time.RFC3339) } // getEventFrameQueryURL returns the URI for the event frame query diff --git a/pkg/plugin/datasource.go b/pkg/plugin/datasource.go index d39fa9b..cce726e 100644 --- a/pkg/plugin/datasource.go +++ b/pkg/plugin/datasource.go @@ -183,8 +183,8 @@ func (d *Datasource) QueryAnnotations(ctx context.Context, req *backend.QueryDat trace.WithAttributes( attribute.String("query.ref_id", q.RefID), attribute.String("query.type", q.QueryType), - attribute.Int64("query.time_range.from", q.TimeRange.From.Unix()), - attribute.Int64("query.time_range.to", q.TimeRange.To.Unix()), + attribute.Int64("query.time_range.from", q.TimeRange.From.Truncate(time.Second).Unix()), + attribute.Int64("query.time_range.to", q.TimeRange.To.Truncate(time.Second).Unix()), ), ) diff --git a/pkg/plugin/helpers.go b/pkg/plugin/helpers.go index 577e320..e1b0af6 100644 --- a/pkg/plugin/helpers.go +++ b/pkg/plugin/helpers.go @@ -373,6 +373,7 @@ func getDataLabels(useNewFormat bool, q *PiProcessedQuery, pointType string, sum } else { label = targetParts[len(targetParts)-1] } + label += summaryLabel } if q.IsPIPoint { @@ -413,7 +414,7 @@ func convertItemsToDataFrame(processedQuery *PiProcessedQuery, d *Datasource, Su webID := processedQuery.WebID includeMetaData := processedQuery.UseUnit digitalStates := processedQuery.DigitalStates - noDataReplace := processedQuery.getSummaryNoDataReplace() + noDataReplace := processedQuery.getNoDataReplace() digitalStateValues := make([]string, 0) sliceType := d.getTypeForWebID(webID) @@ -518,7 +519,7 @@ func convertItemsToDataFrame(processedQuery *PiProcessedQuery, d *Datasource, Su // in the slice type, or values that are not "good" valuepointers := convertSliceToPointers(fP.values, fP.badValues) - timeField := data.NewField("time", nil, fP.timestamps) + timeField := data.NewField("Time", nil, fP.timestamps) if !digitalState || !digitalStates { valueField := data.NewField(frameLabel["name"], labels, valuepointers) frame.Fields = append(frame.Fields, diff --git a/pkg/plugin/timeseries_query.go b/pkg/plugin/timeseries_query.go index e12e6db..04a0a47 100644 --- a/pkg/plugin/timeseries_query.go +++ b/pkg/plugin/timeseries_query.go @@ -99,6 +99,7 @@ func (d *Datasource) processQuery(query backend.DataQuery, datasourceUID string) DigitalStates: DigitalStates, Display: PiQuery.Pi.Display, Regex: PiQuery.Pi.Regex, + Nodata: PiQuery.Pi.Nodata, Summary: PiQuery.Pi.Summary, Variable: PiQuery.Pi.getVariable(i), Index: (j + 1) + 100*(i+1), @@ -321,10 +322,10 @@ func (q *PIWebAPIQuery) isSummary() bool { if q.Summary == nil { return false } - if q.Summary.Types == nil { + if q.Summary.Enable == nil { return false } - return *q.Summary.Basis != "" && len(*q.Summary.Types) > 0 + return *q.Summary.Enable && *q.Summary.Basis != "" && len(*q.Summary.Types) > 0 } // PiProcessedQuery isRegex returns true if the query is a regex query and is enabled @@ -364,17 +365,28 @@ func (q *PiProcessedQuery) isRegexQuery() bool { // A default of 30s is returned if the summary duration is not provided by the frontend // or if the format is invalid func (q *PIWebAPIQuery) getSummaryDuration() string { + backend.Logger.Debug("Summary duration", "summary", q.Summary) // Return the default value if the summary is not provided by the frontend - if q.Summary == nil || *q.Summary.Interval == "" { + if q.Summary == nil || q.Summary.Duration == nil || *q.Summary.Duration == "" { return "30s" } + return _getDurationBase(*q.Summary.Duration) +} - // If the summary duration is provided, then validate the format piwebapi expects +func (q *PIWebAPIQuery) getSampleInterval() string { + // Return the default value if the summary is not provided by the frontend + if q.Summary == nil || q.Summary.SampleInterval == nil || *q.Summary.SampleInterval == "" { + return "30s" + } + return _getDurationBase(*q.Summary.SampleInterval) +} +func _getDurationBase(duration string) string { + // If the summary duration is provided, then validate the format piwebapi expects // Regular expression to match the format: pattern := `^(\d+(\.\d+)?)\s*(ms|s|m|h|d|mo|w|wd|yd)$` re := regexp.MustCompile(pattern) - matches := re.FindStringSubmatch(*q.Summary.Interval) + matches := re.FindStringSubmatch(duration) if len(matches) != 4 { return "30s" // Return the default value if the format is invalid @@ -394,11 +406,11 @@ func (q *PIWebAPIQuery) getSummaryDuration() string { switch shortName { case "ms", "s", "m", "h": // Fractions allowed for millisecond, second, minute, and hour - return *q.Summary.Interval + return duration case "d", "mo", "w", "wd", "yd": // No fractions allowed for day, month, week, weekday, yearday if numericPart == float64(int64(numericPart)) { - return *q.Summary.Interval + return duration } default: return "30s" // Return the default value if the short name or fractions are not allowed @@ -413,7 +425,13 @@ func (q *PIWebAPIQuery) getSummaryURIComponent() string { uri += "&summaryType=" + t.Value.Value } uri += "&summaryBasis=" + *q.Summary.Basis - uri += "&summaryDuration=" + q.getSummaryDuration() + if q.Summary.Duration != nil && *q.Summary.Duration != "" { + uri += "&summaryDuration=" + q.getSummaryDuration() + } + if q.Summary.SampleTypeInterval != nil && *q.Summary.SampleTypeInterval && + q.Summary.SampleInterval != nil && *q.Summary.SampleInterval != "" { + uri += "&sampleType=Interval&sampleInterval=" + q.getSampleInterval() + } return uri } @@ -572,10 +590,7 @@ func (q Query) getQueryBaseURL() string { uri += "/times?time=" + q.getTimeRangeURIToComponent() } else { if q.Pi.isSummary() { - uri += "/summary" + q.getTimeRangeURIComponent() - if q.Pi.isInterpolated() { - uri += fmt.Sprintf("&sampleType=Interval&sampleInterval=%s", q.getIntervalTime()) - } + uri += "/summary" + q.getTimeRangeURIComponent() + q.Pi.getSummaryURIComponent() } else if q.Pi.isInterpolated() { uri += "/intervals" + q.getTimeRangeURIComponent() uri += fmt.Sprintf("&sampleInterval=%s", q.getIntervalTime()) @@ -597,8 +612,7 @@ func (q Query) getQueryBaseURL() string { } } else { if q.Pi.isSummary() { - uri += "/summary" + q.getTimeRangeURIComponent() + fmt.Sprintf("&intervals=%d", q.getMaxDataPoints()) - uri += q.Pi.getSummaryURIComponent() + uri += "/summary" + q.getTimeRangeURIComponent() + q.Pi.getSummaryURIComponent() } else if q.Pi.isInterpolated() { uri += "/interpolated" + q.getTimeRangeURIComponent() + fmt.Sprintf("&interval=%s", q.getIntervalTime()) } else if q.Pi.isRecordedValues() { @@ -609,5 +623,6 @@ func (q Query) getQueryBaseURL() string { uri += "&webId=" } } + backend.Logger.Debug("Base url", "uri", uri) return uri } diff --git a/pkg/plugin/timeseries_query_models.go b/pkg/plugin/timeseries_query_models.go index e8fb7ee..6fdc560 100644 --- a/pkg/plugin/timeseries_query_models.go +++ b/pkg/plugin/timeseries_query_models.go @@ -43,8 +43,8 @@ func (q *Query) getIntervalTime() string { func (q *Query) getWindowedTimeStampURI() string { // Potential Improvement: Make windowWidth a user input windowWidth := q.getMaxDataPoints() - fromTime := q.TimeRange.From - toTime := q.TimeRange.To + fromTime := q.TimeRange.From.Truncate(time.Second) + toTime := q.TimeRange.To.Truncate(time.Second) diff := toTime.Sub(fromTime).Nanoseconds() / int64(windowWidth) timeQuery := "time=" + fromTime.Format(time.RFC3339) @@ -60,11 +60,12 @@ func (q *Query) getWindowedTimeStampURI() string { } func (q *Query) getTimeRangeURIComponent() string { - return "?startTime=" + q.TimeRange.From.UTC().Format(time.RFC3339) + "&endTime=" + q.TimeRange.To.UTC().Format(time.RFC3339) + return "?startTime=" + q.TimeRange.From.UTC().Truncate(time.Second).Format(time.RFC3339) + + "&endTime=" + q.TimeRange.To.UTC().Truncate(time.Second).Format(time.RFC3339) } func (q *Query) getTimeRangeURIToComponent() string { - return q.TimeRange.To.UTC().Format(time.RFC3339) + return q.TimeRange.To.UTC().Truncate(time.Second).Format(time.RFC3339) } func (q *Query) isstreamingEnabled() bool { @@ -89,14 +90,11 @@ func (q *Query) isStreamable() bool { // return *q.Summary.Basis != "" && len(*q.Summary.Types) > 0 // } -func (q *PiProcessedQuery) getSummaryNoDataReplace() string { - if q.Summary == nil { +func (q *PiProcessedQuery) getNoDataReplace() string { + if q.Nodata == nil { return "" } - if q.Summary.Nodata == nil { - return "" - } - return *q.Summary.Nodata + return *q.Nodata } type PIWebAPIQuery struct { @@ -130,8 +128,9 @@ type PIWebAPIQuery struct { MaxNumber *int `json:"maxNumber"` BoundaryType *string `json:"boundaryType"` } `json:"recordedValues"` - RefID *string `json:"refId"` - Regex *Regex `json:"regex"` + RefID *string `json:"refId"` + Regex *Regex `json:"regex"` + Nodata *string `json:"nodata"` // Segments *[]string `json:"segments"` Summary *QuerySummary `json:"summary"` Target *string `json:"target"` @@ -142,10 +141,12 @@ type PIWebAPIQuery struct { } type QuerySummary struct { - Basis *string `json:"basis"` - Interval *string `json:"interval"` - Nodata *string `json:"nodata"` - Types *[]SummaryType `json:"types"` + Enable *bool `json:"enable"` + Basis *string `json:"basis"` + Duration *string `json:"duration"` + Types *[]SummaryType `json:"types"` + SampleTypeInterval *bool `json:"sampleTypeInterval"` + SampleInterval *string `json:"sampleInterval"` } type QueryPropertiesValue struct { @@ -197,6 +198,7 @@ type PiProcessedQuery struct { UseUnit bool `json:"UseUnit"` DigitalStates bool `json:"DigitalStates"` Display *string `json:"Display"` + Nodata *string `json:"Nodata"` Error error Index int Resource string diff --git a/src/datasource.ts b/src/datasource.ts index e7abb08..d23f5f8 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -251,7 +251,8 @@ export class PiWebAPIDatasource extends DataSourceWithBackend { return item !== undefined && item !== null && item !== ''; }); - tar.summary.interval = !!tar.summary.interval - ? this.templateSrv.replace(tar.summary.interval, options.scopedVars) - : tar.summary.interval; + tar.summary.duration = !!tar.summary.duration + ? this.templateSrv.replace(tar.summary.duration, options.scopedVars) + : tar.summary.duration; + tar.summary.sampleTypeInterval = !!tar.summary.sampleTypeInterval; + tar.summary.sampleInterval = !!tar.summary.sampleInterval + ? this.templateSrv.replace(tar.summary.sampleInterval, options.scopedVars) + : tar.summary.sampleInterval; } return tar; diff --git a/src/query/QueryEditor.tsx b/src/query/QueryEditor.tsx index f7b4fa8..40906f6 100644 --- a/src/query/QueryEditor.tsx +++ b/src/query/QueryEditor.tsx @@ -9,6 +9,7 @@ import { QueryInlineField, QueryRawInlineField, QueryRowTerminator } from '../co import { PIWebAPISelectableValue, PIWebAPIDataSourceJsonData, PIWebAPIQuery, defaultQuery } from '../types'; import { QueryEditorModeSwitcher } from 'components/QueryEditorModeSwitcher'; import { parseRawQuery } from 'helper'; +import { types } from '@babel/core'; const LABEL_WIDTH = 24; const LABEL_SWITCH_WIDTH = 49.067 / 8.0; @@ -188,11 +189,8 @@ export class PIWebAPIQueryEditor extends PureComponent { // no data change event calcNoDataValueChanged(segment: SelectableValue) { const metricsQuery = this.props.query as PIWebAPIQuery; - const summary = metricsQuery.summary; - if (summary) { - summary.nodata = segment.value?.value; - } - this.onChange({ ...metricsQuery, summary }); + const nodata = segment.value?.value; + this.onChange({ ...metricsQuery, nodata }); } // get no data user interface segments getNoDataSegments() { @@ -1076,6 +1074,7 @@ export class PIWebAPIQueryEditor extends PureComponent { isPiPoint, hideError, summary, + nodata, display, regex, } = metricsQuery; @@ -1257,8 +1256,8 @@ export class PIWebAPIQueryEditor extends PureComponent { Component={ } onChange={this.calcNoDataValueChanged} @@ -1302,7 +1301,7 @@ export class PIWebAPIQueryEditor extends PureComponent { )} - {!useLastValue.enable && !recordedValues.enable && ( + {(interpolate.enable || (!useLastValue.enable && !recordedValues.enable)) && ( { )} - {!useLastValue.enable && !interpolate.enable && ( + {(recordedValues.enable || (!useLastValue.enable && !interpolate.enable)) && ( { {!useLastValue.enable && ( - - ) => - onChange({ ...metricsQuery, summary: { ...summary, interval: event.target.value } }) + + + this.onChange({ + ...metricsQuery, + summary: { ...summary, enable: !(summary?.enable) }, + }) } - placeholder="30s" /> { { allowCustomValue /> - + {this.state.summaries.map((s: SelectableValue, index: number) => { return ( @@ -1456,6 +1457,53 @@ export class PIWebAPIQueryEditor extends PureComponent { )} + {summary?.enable && ( + + + + this.onChange({ ...metricsQuery, summary: { ...summary, sampleTypeInterval: !(summary?.sampleTypeInterval) } }) + } + /> + + + ) => + onChange({ ...metricsQuery, summary: { ...summary, sampleInterval: event.target.value } }) + } + placeholder="30s" + /> + + + ) => + onChange({ ...metricsQuery, summary: { ...summary, duration: event.target.value } }) + } + placeholder="30s" + /> + + + )} = { attributes: [], segments: [], regex: { enable: false }, - summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' }, + nodata: 'Null', + summary: { + enable: false, + types: [], + basis: 'EventWeighted', + duration: '', + sampleTypeInterval: false, + sampleInterval: '' + }, expression: '', interpolate: { enable: false }, useLastValue: { enable: false },