From 45db6e86fa9db59f4fe1d197b7073e38c7cf3d4a Mon Sep 17 00:00:00 2001 From: Paulo Vitor Magacho Date: Tue, 28 Feb 2023 19:01:08 -0300 Subject: [PATCH] Removed console.log --- .gitignore | 5 +++++ dist/module.js.map | 2 +- dist/plugin.json | 2 +- src/datasource.ts | 2 -- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index cc7eb6e..0db5568 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,8 @@ e2e-results/ # Editor .idea +# VS Code +.vscode + +# Codealike +codealike.json diff --git a/dist/module.js.map b/dist/module.js.map index 541c909..ae3529e 100644 --- a/dist/module.js.map +++ b/dist/module.js.map @@ -1 +1 @@ -{"version":3,"file":"module.js","mappings":";uHAAAA,EAAOC,QAAUC,OCAjBF,EAAOC,QAAUE,OCAjBH,EAAOC,QAAUG,OCAjBJ,EAAOC,QAAUI,QCAjBL,EAAOC,QAAUK,ICCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaT,QAGrB,IAAID,EAASO,EAAyBE,GAAY,CAGjDR,QAAS,CAAC,GAOX,OAHAW,EAAoBH,GAAUT,EAAQA,EAAOC,QAASO,GAG/CR,EAAOC,OACf,CCrBAO,EAAoBK,EAAKb,IACxB,IAAIc,EAASd,GAAUA,EAAOe,WAC7B,IAAOf,EAAiB,QACxB,IAAM,EAEP,OADAQ,EAAoBQ,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdN,EAAoBQ,EAAI,CAACf,EAASiB,KACjC,IAAI,IAAIC,KAAOD,EACXV,EAAoBY,EAAEF,EAAYC,KAASX,EAAoBY,EAAEnB,EAASkB,IAC5EE,OAAOC,eAAerB,EAASkB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDX,EAAoBY,EAAI,CAACK,EAAKC,IAAUL,OAAO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ia,EAAQ1Q,MAAyC,MAAnB0Q,EAAQlF,OACjC,CAAC,CAAEtS,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,UAGjEsW,EAAQ1Q,KAAKwI,KAAOpO,EAAOwL,SAAW8K,EAAQ1Q,KAAKwI,KAC5C,CAACkI,EAAQ1Q,MAClB,IAGOmJ,EAAG4D,QAAQ,sBAAwB3S,EAAOA,QAAQrB,MAAK,SAAC2X,GAC7D,YAAqBja,IAAjBia,EAAQ1Q,MAAyC,MAAnB0Q,EAAQlF,OACjC,CAAC,CAAEtS,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,UAGjEsW,EAAQ1Q,KAAKwI,KAAOpO,EAAOwL,SAAW8K,EAAQ1Q,KAAKwI,KAC5C,CAACkI,EAAQ1Q,MAClB,IAzBOmJ,EAAGiF,cAAclW,KAAKiC,SAASf,MAAQgB,EAAOA,QAAQrB,MAAK,SAAC2X,GACjE,YAAgBja,IAAZia,GAA4C,IAAnBA,EAAQhR,OAC5B,CAAC,CAAExG,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,SAE1DsW,CACT,IAVOtQ,QAAQC,QAAQ,CAAC,CAAEnH,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,SAgCnF,IA7xCF,mFA6xCG,EAhvC4B,CAAS8Y,EAAAA,eCvC3BC,GAAS,IAAIC,EAAAA,iBACxBhM,IAECiM,gBAAgBtZ,GAChBuZ,eAAe1U,GACf2U,uBAAuBvb","sources":["webpack:///external amd \"react\"","webpack:///external amd \"@grafana/ui\"","webpack:///external amd \"@grafana/data\"","webpack:///external amd \"lodash\"","webpack:///external amd \"@grafana/runtime\"","webpack:///webpack/bootstrap","webpack:///webpack/runtime/compat get default export","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./AnnotationsQueryCtrl.ts","webpack:///./ConfigEditor.tsx","webpack:///./components/Forms.tsx","webpack:///./types.ts","webpack:///./components/QueryEditorModeSwitcher.tsx","webpack:///./QueryEditor.tsx","webpack:///./datasource.ts","webpack:///./module.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","module.exports = __WEBPACK_EXTERNAL_MODULE__2__;","module.exports = __WEBPACK_EXTERNAL_MODULE__3__;","module.exports = __WEBPACK_EXTERNAL_MODULE__5__;","// 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};","export class AnnotationsQueryCtrl {\n static templateUrl = 'partials/annotations.editor.html';\n\n $scope: any;\n annotation: any;\n datasource: any;\n\n /** @ngInject */\n constructor($scope: any) {\n this.$scope = $scope;\n this.annotation = $scope.ctrl.annotation;\n this.datasource = $scope.ctrl.datasource;\n\n // load defaults\n this.annotation.query = this.annotation.query || {};\n this.annotation.databases = this.annotation.databases || [];\n this.annotation.templates = this.annotation.templates || [];\n this.annotation.regex = this.annotation.regex || {};\n this.annotation.attribute = this.annotation.attribute || {};\n this.annotation.showEndTime = this.annotation.showEndTime || false;\n\n this.datasource.getAssetServer(this.datasource.afserver.name).then((result: any) => {\n return this.getDatabases(result.WebId);\n });\n }\n templateChanged() {\n // do nothing\n }\n databaseChanged() {\n this.annotation.templates = [];\n this.getEventFrames();\n }\n getDatabases(webid: string) {\n const ctrl = this;\n ctrl.datasource.getDatabases(webid).then((dbs: any) => {\n ctrl.annotation.databases = dbs;\n this.$scope.$apply();\n });\n }\n getEventFrames() {\n const ctrl = this;\n ctrl.datasource.getEventFrameTemplates(this.annotation.database.WebId).then((templates: any) => {\n ctrl.annotation.templates = templates;\n this.$scope.$apply();\n });\n }\n}\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 onMyOptionsChange = (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 render() {\n const { options: originalOptions } = this.props;\n const options = coerceOptions(originalOptions);\n\n return (\n
\n \n\n

PI Point

\n\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, DataSourceJsonData } from '@grafana/data';\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: any[];\n segments: any[];\n display: any;\n interpolate: any;\n recordedValues: any;\n digitalStates: any;\n useLastValue: any,\n webid: string;\n webids: string[];\n regex: any;\n summary: any;\n expression: string;\n isPiPoint: boolean;\n rawQuery?: boolean;\n query?: string;\n}\n\nexport const defaultQuery: Partial = {\n target: ';',\n attributes: [],\n segments: [],\n regex: { enable: false },\n summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false },\n digitalStates: { enable: false },\n 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}\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, 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, VariableModel } 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';\n\nconst LABEL_WIDTH = 24;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n segments: Array>;\n attributes: Array>;\n summaries: Array>;\n attributeSegment: SelectableValue;\n summarySegment: SelectableValue;\n calculationBasisSegment: SelectableValue;\n noDataReplacementSegment: SelectableValue;\n}\n\ntype Props = QueryEditorProps;\n\nconst REMOVE_LABEL = '-REMOVE-';\n\nconst CustomLabelComponent = (props: any) => {\n if (props.value) {\n return (\n
\n {props.label ?? '--no label--'}\n
\n );\n }\n return (\n \n \n \n );\n};\n\nexport class PIWebAPIQueryEditor extends PureComponent {\n error: any;\n piServer: any[] = [];\n availableAttributes: any = {};\n summaryTypes: string[];\n calculationBasis: string[];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n segments: [],\n attributes: [],\n summaries: [],\n attributeSegment: {},\n summarySegment: {},\n calculationBasisSegment: {},\n noDataReplacementSegment: {},\n };\n\n constructor(props: any) {\n super(props);\n this.onSegmentChange = this.onSegmentChange.bind(this);\n this.calcBasisValueChanged = this.calcBasisValueChanged.bind(this);\n this.calcNoDataValueChanged = this.calcNoDataValueChanged.bind(this);\n this.onSummaryAction = this.onSummaryAction.bind(this);\n this.onSummaryValueChanged = this.onSummaryValueChanged.bind(this);\n this.onAttributeAction = this.onAttributeAction.bind(this);\n this.onAttributeChange = this.onAttributeChange.bind(this);\n\n this.summaryTypes = [\n // 'None', // A summary type is not specified.\n 'Total', // A totalization over the time range.\n 'Average', // The average value over the time range.\n 'Minimum', // The minimum value over the time range.\n 'Maximum', // The maximum value over the time range.\n 'Range', // The range value over the time range (minimum-maximum).\n 'StdDev', // The standard deviation over the time range.\n 'PopulationStdDev', // The population standard deviation over the time range.\n 'Count', // The sum of event count over the time range when calculation basis is event weighted. The sum of event time duration over the time range when calculation basis is time weighted.\n 'PercentGood', // Percent of data with good value during the calculation period. For time weighted calculations, the percentage is based on time. For event weighted calculations, the percent is based on event count.\n 'All', // A convenience for requesting all available summary calculations.\n 'AllForNonNumeric', // A convenience for requesting all available summary calculations for non-numeric data.\n ];\n\n this.calculationBasis = [\n 'TimeWeighted', // Weight the values in the calculation by the time over which they apply. Interpolation is based on whether the attribute is stepped. Interpolated events are generated at the boundaries if necessary.\n 'EventWeighted', // Evaluate values with equal weighting for each event. No interpolation is done. There must be at least one event within the time range to perform a successful calculation. Two events are required for standard deviation. In handling events at the boundary of the calculation, the AFSDK uses following rules:\n 'TimeWeightedContinuous', // Apply weighting as in TimeWeighted, but do all interpolation between values as if they represent continuous data, (standard interpolation) regardless of whether the attribute is stepped.\n 'TimeWeightedDiscrete', // Apply weighting as in TimeWeighted but interpolation between values is performed as if they represent discrete, unrelated values (stair step plot) regardless of the attribute is stepped.\n 'EventWeightedExcludeMostRecentEvent', // The calculation behaves the same as _EventWeighted_, except in the handling of events at the boundary of summary intervals in a multiple intervals calculation. Use this option to prevent events at the intervals boundary from being double count at both intervals. With this option, events at the end time (most recent time) of an interval is not used in that interval.\n 'EventWeightedExcludeEarliestEvent', // Similar to the option _EventWeightedExcludeMostRecentEvent_. Events at the start time(earliest time) of an interval is not used in that interval.\n 'EventWeightedIncludeBothEnds', // Events at both ends of the interval boundaries are included in the event weighted calculation.\n ];\n\n this.noDataReplacement = [\n 'Null', // replace with nulls\n 'Drop', // drop items\n 'Previous', // use previous value if available\n '0', // replace with 0\n 'Keep', // Keep value\n ];\n }\n\n // is selected segment empty\n isValueEmpty(value: PIWebAPISelectableValue | undefined) {\n return !value || !value.value || !value.value.length || value.value === REMOVE_LABEL;\n }\n\n segmentChangeValue = (segments: Array>) => {\n const query = this.props.query;\n this.setState({ segments }, () => this.onChange({ ...query, segments }));\n };\n\n attributeChangeValue = (attributes: Array>) => {\n const query = this.props.query;\n this.setState({ attributes }, () => this.onChange({ ...query, attributes }));\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 summary.basis = segment.value?.value;\n this.onChange({ ...metricsQuery, summary });\n }\n // get summary calculation basis user interface segments\n getCalcBasisSegments() {\n const segments = map(this.calculationBasis, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // no data change event\n calcNoDataValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n summary.nodata = segment.value?.value;\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 ctrl = this;\n const summaryTypes = filter(ctrl.summaryTypes, (type) => {\n return this.state.summaries.map((s) => s.value?.value).indexOf(type) === -1;\n });\n const segments = map(summaryTypes, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n }\n\n // remove a summary from the user interface and the query\n removeSummary(part: SelectableValue) {\n const summaries = filter(this.state.summaries, (item: SelectableValue) => {\n return item !== part;\n });\n this.setState({ summaries });\n }\n // add a new summary to the query\n onSummaryAction(item: SelectableValue) {\n const summaries = this.state.summaries.slice(0) as Array>;\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: true,\n },\n };\n summaries.push(selectableValue);\n }\n this.setState({ summarySegment: {}, summaries }, this.stateCallback);\n }\n\n // remove an attribute from the query\n removeAttribute(part: SelectableValue) {\n const attributes = filter(this.state.attributes, (item: SelectableValue) => {\n return item !== part;\n });\n this.attributeChangeValue(attributes);\n }\n // add an attribute to the query\n onAttributeAction(item: SelectableValue) {\n const { query } = this.props;\n const attributes = this.state.attributes.slice(0);\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: !query.isPiPoint,\n },\n };\n attributes.push(selectableValue);\n }\n this.attributeChangeValue(attributes);\n }\n\n // pi point change event\n onPiPointChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n if (item.label === REMOVE_LABEL) {\n remove(attributes, (value, n) => n === index);\n } else {\n // set current value\n attributes[index] = item;\n }\n\n this.checkPiPointSegments(item, attributes);\n };\n // attribute change event\n onAttributeChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n // 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 if (item.label === REMOVE_LABEL) {\n segments = slice(segments, 0, index);\n this.checkAttributeSegments([], segments);\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 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);\n // add new options\n if (!!item.value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n this.segmentChangeValue(segments);\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 : { path: this.getSegmentPathUpTo(currentSegment ?? this.state.segments.slice(0), index) };\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 // if (!findQuery.path?.length) {\n // return Promise.resolve([]);\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: VariableModel) => {\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 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: VariableModel) => {\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 segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n return segments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return segments;\n });\n };\n\n // get the list of attributes for the user interface - AF\n getAttributeSegmentsAF = (attributeText?: string): Array> => {\n const ctrl = this;\n let segments: Array> = [];\n\n 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 segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\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 value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, (item, _) => {\n if (item !== '') {\n // set current value\n attributesArray.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n return this.getElementSegments(splitElements.length + 1, segmentsArray).then((elements) => {\n if (elements.length > 0) {\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return segmentsArray;\n });\n }\n return Promise.resolve(segmentsArray);\n };\n\n /**\n * Gets the segment information and parses it to a string.\n *\n * @param {any} index - Last index of segment to use.\n * @returns - AF Path or PI Point name.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSegmentPathUpTo(segments: Array>, index: number): string {\n const arr = segments.slice(0, index);\n\n return reduce(\n arr,\n (result: any, segment: SelectableValue) => {\n if (!segment.value) {\n return '';\n }\n if (!segment.value.value?.startsWith('-Select')) {\n return result ? result + '\\\\' + segment.value.value : segment.value.value;\n }\n return result;\n },\n ''\n );\n }\n\n /**\n * Get the current AF Element's child attributes. Validates when the element selection changes.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAttributeSegments(\n attributes: Array>,\n segments: Array>\n ): Promise {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: this.getSegmentPathUpTo(segments.slice(0), segments.length),\n type: 'attributes',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: false }))\n .then((attributesResponse: any) => {\n const validAttributes: any = {};\n\n each(attributesResponse, (attribute: any) => {\n validAttributes[attribute.Path.substring(attribute.Path.indexOf('|') + 1)] = attribute.WebId;\n });\n\n const filteredAttributes = filter(attributes, (attrib: SelectableValue) => {\n const changedValue = datasource.templateSrv.replace(attrib.value?.value);\n return validAttributes[changedValue] !== undefined;\n });\n\n ctrl.availableAttributes = validAttributes;\n this.attributeChangeValue(filteredAttributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n 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 ctrl.attributeChangeValue(attributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n 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, onChange } = 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 this.getElementSegments(splitElements.length + 1, segments).then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n });\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n this.updateArray(segments, attributes, this.state.summaries, query.isPiPoint, () => {\n onChange({ ...query, query: undefined, rawQuery: false });\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, isPiPoint);\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 query.summary.types = this.state.summaries;\n if (query.rawQuery) {\n query.target = query.query ?? '';\n\n if (query.target !== '') {\n const splitAttributes = query.target.split(';');\n const splitElements = splitAttributes[0].split('\\\\');\n\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n query.attributes = [];\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n query.elementPath = splitElements.join('\\\\');\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n query.attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n }\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\n onChange(query);\n\n if (query.target && query.target.length > 0 && query.attributes.length > 0) {\n onRunQuery();\n }\n };\n\n stateCallback = () => {\n const query = this.props.query as PIWebAPIQuery;\n this.onChange(query);\n };\n\n onIsPiPointChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const isPiPoint = !queryChange.isPiPoint;\n this.setState(\n {\n segments: isPiPoint ? [{ label: '' }] : this.checkAfServer(),\n attributes: [],\n isPiPoint,\n },\n () => {\n this.onChange({\n ...queryChange,\n expression: '',\n attributes: this.state.attributes,\n segments: this.state.segments,\n isPiPoint,\n });\n }\n );\n };\n\n render() {\n const { query: queryProps, onChange, onRunQuery } = this.props;\n const metricsQuery = defaults(queryProps, defaultQuery) as PIWebAPIQuery;\n const {\n useLastValue,\n interpolate,\n query,\n rawQuery,\n digitalStates,\n recordedValues,\n expression,\n isPiPoint,\n summary,\n display,\n regex,\n } = metricsQuery;\n\n return (\n <>\n {this.props.datasource.piPointConfig && (\n \n \n \n )}\n\n {!!rawQuery && (\n \n \n ) =>\n onChange({ ...metricsQuery, query: event.target.value })\n }\n placeholder=\"enter query\"\n />\n \n this.textEditorChanged()} />\n \n )}\n\n {!rawQuery && (\n <>\n
\n \n {this.state.segments.map((segment: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSegmentChange(item, index)}\n loadOptions={(query?: string | undefined) => {\n return this.getElementSegments(index);\n }}\n allowCustomValue\n inputMinWidth={MIN_ELEM_INPUT_WIDTH}\n />\n );\n })}\n \n {!isPiPoint && (\n {\n onChange({ ...metricsQuery, query: metricsQuery.target, rawQuery: value });\n }}\n />\n )}\n \n
\n\n \n {this.state.attributes.map((attribute: SelectableValue, index: number) => {\n if (isPiPoint) {\n return (\n }\n disabled={this.piServer.length === 0}\n onChange={(item) => this.onPiPointChange(item, index)}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n }\n return (\n }\n disabled={this.state.segments.length <= 2}\n onChange={(item) => this.onAttributeChange(item, index)}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n })}\n\n {isPiPoint && (\n \n }\n disabled={this.piServer.length === 0}\n onChange={this.onAttributeAction}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n {!isPiPoint && (\n \n }\n disabled={this.state.segments.length <= 2}\n onChange={this.onAttributeAction}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n \n \n )}\n\n \n \n \n this.onChange({\n ...metricsQuery,\n useLastValue: { ...useLastValue, enable: !useLastValue.enable },\n })\n }\n />\n \n \n\n {!useLastValue.enable && (\n <>\n \n ) =>\n this.onChange({ ...metricsQuery, expression: event.target.value })\n }\n placeholder=\"'.'*2\"\n />\n \n\n \n \n ) =>\n this.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 this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable },\n })\n }\n />\n \n \n \n this.onChange({ ...metricsQuery, digitalStates: { ...digitalStates, enable: !digitalStates.enable } })\n }\n />\n \n \n\n \n \n ) =>\n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable } })\n }\n />\n \n \n }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n \n\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n }\n onChange={this.calcBasisValueChanged}\n options={this.getCalcBasisSegments()}\n allowCustomValue\n />\n \n \n \n {this.state.summaries.map((s: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSummaryValueChanged(item, index)}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n );\n })}\n \n }\n onChange={this.onSummaryAction}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n \n \n \n \n )}\n\n \n \n ) =>\n this.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 this.onChange({ ...metricsQuery, regex: { ...regex, search: event.target.value } })\n }\n placeholder=\"(.*)\"\n />\n \n \n ) =>\n this.onChange({ ...metricsQuery, regex: { ...regex, replace: event.target.value } })\n }\n placeholder=\"$1\"\n />\n \n \n \n );\n }\n}\n","import { curry, each, filter, flatten, forOwn, groupBy, keys, map, uniq } from 'lodash';\n\nimport {\n DataQueryRequest,\n DataQueryResponse,\n DataSourceApi,\n DataSourceInstanceSettings,\n AnnotationEvent,\n toDataFrame,\n MetricFindValue,\n} from '@grafana/data';\nimport { BackendSrv, getBackendSrv, getTemplateSrv, TemplateSrv } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\ninterface PiwebapiElementPath {\n path: string;\n variable: string;\n}\n\ninterface PiwebapiInternalRsp {\n data: PiwebapiRsp;\n status: number;\n url: string;\n}\n\ninterface PiwebapTargetRsp {\n refId: string;\n target: string;\n datapoints: any[];\n}\n\ninterface PiwebapiRsp {\n Name?: string;\n InstanceType?: string;\n Items?: PiwebapiRsp[];\n WebId?: string;\n HasChildren?: boolean;\n Path?: string;\n}\n\ninterface PiDataServer {\n name: string | undefined;\n webid: string | undefined;\n}\n\nexport class PiWebAPIDatasource extends DataSourceApi {\n piserver: PiDataServer;\n afserver: PiDataServer;\n afdatabase: PiDataServer;\n piPointConfig: boolean;\n\n basicAuth?: string;\n withCredentials?: boolean;\n url: string;\n name: string;\n isProxy = false;\n\n templateSrv: TemplateSrv;\n backendSrv: BackendSrv;\n\n piwebapiurl?: string;\n webidCache: Map = new Map();\n\n error: any;\n\n constructor(instanceSettings: DataSourceInstanceSettings) {\n super(instanceSettings);\n this.basicAuth = instanceSettings.basicAuth;\n this.withCredentials = instanceSettings.withCredentials;\n this.url = instanceSettings.url!;\n this.name = instanceSettings.name;\n this.templateSrv = getTemplateSrv();\n this.backendSrv = getBackendSrv();\n\n this.piwebapiurl = instanceSettings.jsonData.url?.toString();\n this.isProxy = /^http(s)?:\\/\\//.test(this.url) || instanceSettings.jsonData.access === 'proxy';\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\n Promise.all([\n this.getAssetServer(this.afserver.name).then((result: PiwebapiRsp) => (this.afserver.webid = result.WebId)),\n this.getDataServer(this.piserver.name).then((result: PiwebapiRsp) => (this.piserver.webid = result.WebId)),\n this.getDatabase(this.afserver.name ? this.afserver.name + '\\\\' + this.afdatabase.name : undefined).then(\n (result: PiwebapiRsp) => (this.afdatabase.webid = result.WebId)\n ),\n ]);\n }\n\n /**\n * Converts a PIWebAPI Event Frame response to a Grafana Annotation\n *\n * @param {any} annotationOptions - Options data from configuration panel.\n * @param {any} endTime - End time of the Event Frame.\n * @param {any} eventFrame - The Event Frame data.\n * @returns - Grafana Annotation\n *\n * @memberOf PiWebApiDatasource\n */\n private eventFrameToAnnotation(\n annotationOptions: any,\n endTime: any,\n eventFrame: any,\n attributeDataItems: any\n ): AnnotationEvent {\n if (annotationOptions.regex && annotationOptions.regex.enable) {\n eventFrame.Name = eventFrame.Name.replace(\n new RegExp(annotationOptions.regex.search),\n annotationOptions.regex.replace\n );\n }\n\n let attributeText = '';\n if (attributeDataItems) {\n each(attributeDataItems, (attributeData: any) => {\n const attributeValue = attributeData.Value.Value\n ? attributeData.Value.Value.Name || attributeData.Value.Value.Value || attributeData.Value.Value\n : null;\n attributeText += '
' + attributeData.Name + ': ' + attributeValue;\n });\n }\n return {\n annotation: annotationOptions,\n title: (endTime ? 'END ' : annotationOptions.showEndTime ? 'START ' : '') + annotationOptions.name,\n time: new Date(endTime ? eventFrame.EndTime : eventFrame.StartTime).getTime(),\n text:\n eventFrame.Name + attributeText + '
Start: ' + eventFrame.StartTime + '
End: ' + eventFrame.EndTime,\n };\n }\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) {\n return false;\n }\n return !target.target.startsWith('Select AF');\n });\n\n options.targets = map(options.targets, (target) => {\n const ds = this;\n const tar = {\n target: this.templateSrv.replace(target.elementPath, options.scopedVars),\n elementPath: this.templateSrv.replace(target.elementPath, options.scopedVars),\n elementPathArray: [\n {\n path: this.templateSrv.replace(target.elementPath, options.scopedVars),\n variable: '',\n } as PiwebapiElementPath,\n ],\n attributes: map(target.attributes, (att) =>\n this.templateSrv.replace(att.value?.value || att, options.scopedVars)\n ),\n segments: map(target.segments, (att) => this.templateSrv.replace(att.value?.value, options.scopedVars)),\n display: target.display,\n refId: target.refId,\n hide: target.hide,\n interpolate: target.interpolate || { enable: false },\n useLastValue: target.useLastValue || { enable: false },\n recordedValues: target.recordedValues || { enable: false },\n digitalStates: target.digitalStates || { enable: false },\n webid: target.webid,\n webids: target.webids || [],\n regex: target.regex || { enable: false },\n expression: target.expression || '',\n summary: target.summary || { types: [] },\n startTime: options.range.from,\n endTime: options.range.to,\n isPiPoint: target.isPiPoint,\n scopedVars: options.scopedVars,\n };\n\n if (tar.expression) {\n tar.expression = this.templateSrv.replace(tar.expression, options.scopedVars);\n }\n\n if (tar.summary.types !== undefined) {\n tar.summary.types = filter(tar.summary.types, (item) => {\n return item !== undefined && item !== null && item !== '';\n });\n }\n\n // explode All or Multi-selection\n const varsKeys = keys(options.scopedVars);\n this.templateSrv.getVariables().forEach((v: any) => {\n if (ds.isAllSelected(v.current) && varsKeys.indexOf(v.name) < 0) {\n // All selection\n const variables = v.options.filter((o: any) => !o.selected);\n // attributes\n tar.attributes = tar.attributes.map((attr: string) =>\n variables.map((vv: any) =>\n !!v.allValue ? attr.replace(v.allValue, vv.value) : attr.replace(/{[a-zA-z0-9,-_]+}/gi, vv.value)\n )\n );\n tar.attributes = uniq(flatten(tar.attributes));\n // elementPath\n tar.elementPathArray = ds.getElementPath(tar.elementPathArray, variables, v.allValue);\n } else if (Array.isArray(v.current.text) && varsKeys.indexOf(v.name) < 0) {\n // Multi-selection\n const variables = v.options.filter((o: any) => o.selected);\n // attributes\n const query = v.current.value.join(',');\n tar.attributes = tar.attributes.map((attr: string) =>\n variables.map((vv: any) => attr.replace(`{${query}}`, vv.value))\n );\n tar.attributes = uniq(flatten(tar.attributes));\n // elementPath\n tar.elementPathArray = ds.getElementPath(tar.elementPathArray, variables, `{${query}}`);\n }\n });\n\n return tar;\n });\n\n return options;\n }\n\n /**\n * Datasource Implementation. Primary entry point for data source.\n * This takes the panel configuration and queries, sends them to PI Web API and parses the response.\n *\n * @param {any} options - Grafana query and panel options.\n * @returns - Promise of data in the format for Grafana panels.\n *\n * @memberOf PiWebApiDatasource\n */\n async query(options: DataQueryRequest): Promise {\n const ds = this;\n const query = this.buildQueryParameters(options);\n query.targets = filter(query.targets, (t) => !t.hide);\n\n if (query.targets.length <= 0) {\n return Promise.resolve({ data: [] });\n } else {\n return Promise.all(ds.getStream(query)).then((targetResponses) => {\n let flattened: PiwebapTargetRsp[] = [];\n each(targetResponses, (tr) => {\n each(tr, (item) => flattened.push(item));\n });\n const response: DataQueryResponse = {\n data: flattened\n .sort((a, b) => {\n return +(a.target > b.target) || +(a.target === b.target) - 1;\n })\n .map((d) => toDataFrame(d)),\n };\n return response;\n });\n }\n }\n\n /**\n * Datasource Implementation.\n * Used for testing datasource in datasource configuration pange\n *\n * @returns - Success or failure message.\n *\n * @memberOf PiWebApiDatasource\n */\n testDatasource(): Promise {\n return this.backendSrv\n .datasourceRequest({\n url: this.url + '/',\n method: 'GET',\n })\n .then((response: any) => {\n if (response.status === 200) {\n return { status: 'success', message: 'Data source is working', title: 'Success' };\n }\n throw new Error('Failed');\n });\n }\n\n /**\n * Datasource Implementation.\n * This queries PI Web API for Event Frames and converts them into annotations.\n *\n * @param {any} options - Annotation options, usually the Event Frame Category.\n * @returns - A Grafana annotation.\n *\n * @memberOf PiWebApiDatasource\n */\n annotationQuery(options: any): Promise {\n if (!this.afdatabase.webid) {\n return Promise.resolve([]);\n }\n\n const categoryName = options.annotation.query.categoryName\n ? this.templateSrv.replace(options.annotation.query.categoryName, options.scopedVars, 'glob')\n : null;\n const nameFilter = options.annotation.query.nameFilter\n ? this.templateSrv.replace(options.annotation.query.nameFilter, options.scopedVars, 'glob')\n : null;\n const templateName = options.annotation.template ? options.annotation.template.Name : null;\n const annotationOptions = {\n name: options.annotation.name,\n datasource: options.annotation.datasource,\n enable: options.annotation.enable,\n iconColor: options.annotation.iconColor,\n showEndTime: options.annotation.showEndTime,\n regex: options.annotation.regex,\n attribute: options.annotation.attribute,\n categoryName: categoryName,\n templateName: templateName,\n nameFilter: nameFilter,\n };\n\n const filter = [];\n if (!!annotationOptions.categoryName) {\n filter.push('categoryName=' + annotationOptions.categoryName);\n }\n if (!!annotationOptions.nameFilter) {\n filter.push('nameFilter=' + annotationOptions.nameFilter);\n }\n if (!!annotationOptions.templateName) {\n filter.push('templateName=' + annotationOptions.templateName);\n }\n if (!filter.length) {\n return Promise.resolve([]);\n }\n filter.push('startTime=' + options.range.from.toJSON());\n filter.push('endTime=' + options.range.to.toJSON());\n\n if (annotationOptions.attribute && annotationOptions.attribute.enable) {\n let resourceUrl =\n this.piwebapiurl + '/streamsets/{0}/value?selectedFields=Items.WebId%3BItems.Value%3BItems.Name';\n if (!!annotationOptions.attribute.name) {\n resourceUrl =\n this.piwebapiurl +\n '/streamsets/{0}/value?nameFilter=' +\n annotationOptions.attribute.name +\n '&selectedFields=Items.WebId%3BItems.Value%3BItems.Name';\n }\n const query: any = {};\n query['1'] = {\n Method: 'GET',\n Resource: this.piwebapiurl + '/assetdatabases/' + this.afdatabase.webid + '/eventframes?' + filter.join('&'),\n };\n query['2'] = {\n Method: 'GET',\n RequestTemplate: {\n Resource: resourceUrl,\n },\n Parameters: ['$.1.Content.Items[*].WebId'],\n ParentIds: ['1'],\n };\n return this.restBatch(query).then((result: any) => {\n const data = result.data['1'].Content;\n const valueData = result.data['2'].Content;\n\n const annotations = map(data.Items, (item: any, index: any) => {\n return curry(this.eventFrameToAnnotation)(\n annotationOptions,\n false,\n item,\n valueData.Items[index].Content.Items\n );\n });\n\n if (options.annotation.showEndTime) {\n const ends = map(data.Items, (item: any, index: number) => {\n return curry(this.eventFrameToAnnotation)(\n annotationOptions,\n true,\n item,\n valueData.Items[index].Content.Items\n );\n });\n each(ends, (end) => {\n annotations.push(end);\n });\n }\n\n return annotations;\n });\n } else {\n return this.restGet('/assetdatabases/' + this.afdatabase.webid + '/eventframes?' + filter.join('&')).then(\n (result) => {\n const annotations = map(result.data.Items, curry(this.eventFrameToAnnotation)(annotationOptions, false));\n if (options.annotation.showEndTime) {\n const ends = map(result.data.Items, curry(this.eventFrameToAnnotation)(annotationOptions, true));\n each(ends, (end) => {\n annotations.push(end);\n });\n }\n return annotations;\n }\n );\n }\n }\n\n /**\n * Builds the Grafana metric segment for use on the query user interface.\n *\n * @param {any} response - response from PI Web API.\n * @returns - Grafana metric segment.\n *\n * @memberOf PiWebApiDatasource\n */\n private metricQueryTransform(response: PiwebapiRsp[]): MetricFindValue[] {\n return map(response, (item) => {\n return {\n text: item.Name,\n expandable:\n item.HasChildren === undefined || item.HasChildren === true || (item.Path ?? '').split('\\\\').length <= 3,\n HasChildren: item.HasChildren,\n Items: item.Items ?? [],\n Path: item.Path,\n WebId: item.WebId,\n } as MetricFindValue;\n });\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 if (query.type !== 'attributes') {\n query.type = querydepth[Math.max(0, Math.min(query.path.split('\\\\').length, querydepth.length - 1))];\n }\n query.path = this.templateSrv.replace(query.path, queryOptions);\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\n if (query.type === 'servers') {\n return ds.afserver?.name\n ? ds\n .getAssetServer(ds.afserver.name)\n .then((result: PiwebapiRsp) => [result])\n .then(ds.metricQueryTransform)\n : ds.getAssetServers().then(ds.metricQueryTransform);\n } else if (query.type === 'databases') {\n return ds\n .getAssetServer(query.path)\n .then((server) => ds.getDatabases(server.WebId ?? '', {}))\n .then(ds.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(ds.metricQueryTransform);\n } else if (query.type === 'elements') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getElements(element.WebId ?? '', {\n selectedFields: 'Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n nameFilter: query.filter,\n })\n )\n .then(ds.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: 'Items.WebId%3BItems.Name%3BItems.Path',\n nameFilter: query.filter,\n })\n )\n .then(ds.metricQueryTransform);\n } else if (query.type === 'dataserver') {\n return ds.getDataServers().then(ds.metricQueryTransform);\n } else if (query.type === 'pipoint') {\n return ds.piPointSearch(query.webId, query.pointName).then(ds.metricQueryTransform);\n }\n return Promise.reject('Bad type');\n }\n\n /**\n * Gets the url of summary data from the query configuration.\n *\n * @param {any} summary - Query summary configuration.\n * @returns - URL append string.\n *\n * @memberOf PiWebApiDatasource\n */\n getSummaryUrl(summary: any) {\n if (summary.interval.trim() === '') {\n return (\n '&summaryType=' +\n summary.types.map((s: any) => s.value?.value).join('&summaryType=') +\n '&calculationBasis=' +\n summary.basis\n );\n }\n return (\n '&summaryType=' +\n summary.types.map((s: any) => s.value?.value).join('&summaryType=') +\n '&calculationBasis=' +\n summary.basis +\n '&summaryDuration=' +\n summary.interval.trim()\n );\n }\n\n /** PRIVATE SECTION */\n\n /**\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\n *\n * @param {any} value - A list of PIWebAPI values.\n * @param {any} target - The target Grafana metric.\n * @param {boolean} isSummary - Boolean for tracking if data is of summary class.\n * @returns - An array of Grafana value, timestamp pairs.\n *\n */\n private parsePiPointValueData(value: any, target: any, isSummary: boolean) {\n const datapoints: any[] = [];\n if (Array.isArray(value)) {\n each(value, (item) => {\n this.piPointValue(isSummary ? item.Value : item, target, false, datapoints);\n });\n } else {\n this.piPointValue(value, target, false, datapoints);\n }\n return datapoints;\n }\n\n /**\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\n *\n * @param {any} value - PI Point value.\n * @param {any} target - The target grafana metric.\n * @param {boolean} isSummary - Boolean for tracking if data is of summary class.\n * @param {any[]} datapoints - Array with Grafana datapoints.\n *\n */\n private piPointValue(value: any, target: any, isSummary: boolean, datapoints: any[]) {\n // @ts-ignore\n const { grafanaDataPoint, previousValue, drop } = this.noDataReplace(\n value,\n target.summary.nodata,\n this.parsePiPointValue(value, target, isSummary)\n );\n if (!drop) {\n datapoints.push(grafanaDataPoint);\n }\n }\n\n /**\n * Convert a PI Point value to use Grafana value/timestamp.\n *\n * @param {any} value - PI Point value.\n * @param {any} target - The target grafana metric.\n * @param {boolean} isSummary - Boolean for tracking if data is of summary class.\n * @returns - Grafana value pair.\n *\n */\n private parsePiPointValue(value: any, target: any, isSummary: boolean) {\n let num = !isSummary && typeof value.Value === 'object' ? value.Value?.Value : value.Value;\n\n if (!value.Good || !!target.digitalStates?.enable) {\n num = (!isSummary && typeof value.Value === 'object' ? value.Value?.Name : value.Name) ?? '';\n return [this.checkNumber(num) ? Number(num) : num.trim(), new Date(value.Timestamp).getTime()];\n }\n\n return [this.checkNumber(num) ? Number(num) : num.trim(), new Date(value.Timestamp).getTime()];\n }\n\n /**\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\n *\n * @param {any} item - 'Item' object from PIWebAPI\n * @param {any} noDataReplacementMode - String state of how to replace 'No Data'\n * @param {any} grafanaDataPoint - Single Grafana value pair (value, timestamp).\n * @returns grafanaDataPoint - Single Grafana value pair (value, timestamp).\n * @returns perviousValue - {any} Grafana value (value only).\n *\n */\n private noDataReplace(\n item: any,\n noDataReplacementMode: any,\n grafanaDataPoint: any[]\n ): {\n grafanaDataPoint: any[];\n previousValue: any;\n drop: boolean;\n } {\n let previousValue = null;\n let drop = false;\n if (!item.Good || item.Value === 'No Data' || (item.Value?.Name && item.Value?.Name === 'No Data')) {\n if (noDataReplacementMode === 'Drop') {\n drop = true;\n } else if (noDataReplacementMode === '0') {\n grafanaDataPoint[0] = 0;\n } else if (noDataReplacementMode === 'Keep') {\n // Do nothing keep\n } else if (noDataReplacementMode === 'Null') {\n grafanaDataPoint[0] = null;\n } else if (noDataReplacementMode === 'Previous' && previousValue !== null) {\n grafanaDataPoint[0] = previousValue;\n }\n } else {\n previousValue = item.Value;\n }\n return { grafanaDataPoint, previousValue, drop };\n }\n\n /**\n * Process the response from PI Web API for a single item.\n *\n * @param {any} content - Web response data.\n * @param {any} target - The target grafana metric.\n * @param {any} name - The target metric name.\n * @returns - Parsed metric in target/datapoint json format.\n *\n * @memberOf PiWebApiDatasource\n */\n private processResults(content: any, target: any, name: any, noTemplate: boolean): PiwebapTargetRsp[] {\n const api = this;\n const isSummary: boolean = target.summary && target.summary.types && target.summary.types.length > 0;\n name = noTemplate ? name : this.getPath(target.elementPathArray, content.Path) + '|' + name;\n if (target.regex && target.regex.enable && target.regex.search.length && target.regex.replace.length) {\n name = name.replace(new RegExp(target.regex.search), target.regex.replace);\n }\n if (isSummary) {\n const innerResults: any[] = [];\n const groups = groupBy(content.Items, (item: any) => item.Type);\n forOwn(groups, (value, key) => {\n innerResults.push({\n refId: target.refId,\n target: name + '[' + key + ']',\n datapoints: api.parsePiPointValueData(value, target, isSummary),\n });\n });\n return innerResults;\n }\n return [\n {\n refId: target.refId,\n target: name,\n datapoints: api.parsePiPointValueData(content.Items || content.Value, target, isSummary),\n },\n ];\n }\n\n /**\n * Check if all items are selected.\n *\n * @param {any} current the current variable selection\n * @return {boolean} true if all value is selected, false otherwise\n */\n private isAllSelected(current: any): boolean {\n if (!current) {\n return false;\n }\n if (Array.isArray(current.text)) {\n return current.text.indexOf('All') >= 0;\n }\n return current.text === 'All';\n }\n\n /**\n * Check if the value is a number.\n *\n * @param {any} number the value to check\n * @returns {boolean} true if the value is a number, false otherwise\n */\n private checkNumber(number: any): boolean {\n return typeof number === 'number' && !Number.isNaN(number) && Number.isFinite(number);\n }\n\n /**\n * Returns a new element path list based on the panel variables.\n *\n * @param {string} elementPathArray array of element paths\n * @param {string} variables the list of variable values\n * @param {string} allValue the all value value for the variable\n * @returns {PiwebapiElementPath[]} new element path list\n */\n private getElementPath(\n elementPathArray: PiwebapiElementPath[],\n variables: any[],\n allValue: string\n ): PiwebapiElementPath[] {\n // elementPath\n let newElementPathArray: PiwebapiElementPath[] = [];\n elementPathArray.forEach((elem: PiwebapiElementPath) => {\n if ((!!allValue && elem.path.indexOf(allValue) >= 0) || (!allValue && elem.path.match(/{[a-zA-z0-9,-_]+}/gi))) {\n const temp: PiwebapiElementPath[] = variables.map((vv: any) => {\n return {\n path: !!allValue\n ? elem.path.replace(allValue, vv.value)\n : elem.path.replace(/{[a-zA-z0-9,-_]+}/gi, vv.value),\n variable: vv.value,\n } as PiwebapiElementPath;\n });\n newElementPathArray = newElementPathArray.concat(temp);\n }\n });\n if (newElementPathArray.length) {\n return uniq(flatten(newElementPathArray));\n }\n return elementPathArray;\n }\n\n /**\n * Returns the last item of the element path.\n *\n * @param {string} path element path\n * @returns {string} last item of the element path\n */\n private getPath(elementPathArray: PiwebapiElementPath[], path: string): string {\n let splitPath = path.split('|');\n if (splitPath.length === 0) {\n return '';\n }\n if (elementPathArray.length === 0) {\n return '';\n }\n splitPath = splitPath[0].split('\\\\');\n const splitStr = splitPath.length === 0 ? '' : splitPath.pop() ?? '';\n const foundElement = elementPathArray.find((e) => path.indexOf(e.path) >= 0)?.variable;\n return foundElement ? foundElement + '|' + splitStr : splitStr;\n }\n\n /**\n * Gets historical data from a PI Web API stream source.\n *\n * @param {any} query - Grafana query.\n * @returns - Metric data.\n *\n * @memberOf PiWebApiDatasource\n */\n private getStream(query: any): Array> {\n const ds = this;\n const results: Array> = [];\n\n each(query.targets, (target) => {\n // pi point config disabled\n if (target.isPiPoint && !ds.piPointConfig) {\n console.error('Trying to call Pi Point server with Pi Point config disabled');\n return;\n }\n target.attributes = filter(target.attributes || [], (attribute) => {\n return 1 && attribute;\n });\n let url = '';\n const isSummary = target.summary && target.summary.types && target.summary.types.length > 0;\n const isInterpolated = target.interpolate && target.interpolate.enable;\n // perhaps add a check to see if interpolate override time < query.interval\n const intervalTime = target.interpolate.interval ? target.interpolate.interval : query.interval;\n const timeRange = '?startTime=' + query.range.from.toJSON() + '&endTime=' + query.range.to.toJSON();\n const targetName = target.expression || target.elementPath;\n const displayName = target.display ? this.templateSrv.replace(target.display, query.scopedVars) : null;\n if (target.expression) {\n url += '/calculation';\n if (isSummary) {\n url += '/summary' + timeRange + (isInterpolated ? '&sampleType=Interval&sampleInterval=' + intervalTime : '');\n } else if (isInterpolated) {\n url += '/intervals' + timeRange + '&sampleInterval=' + intervalTime;\n } else {\n url += '/recorded' + timeRange;\n }\n url += '&expression=' + encodeURIComponent(target.expression.replace(/\\${intervalTime}/g, intervalTime));\n if (target.attributes.length > 0) {\n results.push(ds.internalStream(query, target, url));\n } else if (target.isPiPoint) {\n ds\n .restPost(url + '&webId=' + ds.piserver.webid!)\n .then((response: any) => ds.processResults(response.data, target, displayName || targetName, false))\n .catch((err: any) => (ds.error = err));\n } else {\n results.push(\n ds.restGetWebId(target.elementPath, false).then((webidresponse: any) => {\n return ds\n .restPost(url + webidresponse.WebId)\n .then((response: any) => ds.processResults(response.data, target, displayName || targetName, false))\n .catch((err: any) => (ds.error = err));\n })\n );\n }\n } else {\n url += '/streamsets';\n console.log(target);\n if (isSummary) {\n url += '/summary' + timeRange + '&intervals=' + query.maxDataPoints + this.getSummaryUrl(target.summary);\n } else if (target.interpolate && target.interpolate.enable) {\n url += '/interpolated' + timeRange + '&interval=' + intervalTime;\n } else if (target.recordedValues && target.recordedValues.enable) {\n const maxNumber =\n target.recordedValues.maxNumber && !isNaN(target.recordedValues.maxNumber)\n ? target.recordedValues.maxNumber\n : 10000;\n url += '/recorded' + timeRange + '&maxCount=' + maxNumber;\n } else if (target.useLastValue?.enable) {\n url += '/value?time=' + query.range.to.toJSON();\n } else {\n url += '/plot' + timeRange + '&intervals=' + query.maxDataPoints;\n }\n\n results.push(ds.internalStream(query, target, url));\n }\n });\n\n return results;\n }\n\n /**\n * Return the data points from the provided Grafana query.\n *\n * @param {any} query - Grafana query.\n * @param {any} target - Grafana query target.\n * @param {string} url - The base URL for the query.\n * @returns - Metric data.\n *\n * @memberOf PiWebApiDatasource\n */\n private internalStream(query: any, target: any, url: string): Promise {\n const ds = this;\n const targetName = target.expression || target.elementPath;\n const displayName = target.display ? this.templateSrv.replace(target.display, query.scopedVars) : null;\n const noTemplate = target.elementPathArray.length === 1 && target.elementPath === target.elementPathArray[0].path;\n let promises: Promise;\n\n if (noTemplate) {\n if (target.attributes.length > 1 && !target.isPiPoint) {\n promises = ds\n .restGetWebId(target.elementPath, target.isPiPoint)\n .then((datarsp) =>\n ds.getAttributes(datarsp.WebId!, {\n searchFullHierarchy: 'true',\n nameFilter: '*',\n })\n )\n .then((datarspa) =>\n datarspa.filter(\n (d) =>\n target.attributes.indexOf(d.Name) >= 0 ||\n target.attributes.indexOf(d.Path?.split('|').splice(1).join('|')) >= 0\n )\n );\n } else {\n promises = Promise.all(\n map(target.attributes, (attribute: string) => {\n if (target.expression) {\n return this.getDataServer(this.piserver.name).then((data) => {\n data.Path = attribute;\n return data;\n });\n } else {\n return ds.restGetWebId(target.elementPath + '|' + attribute, target.isPiPoint);\n }\n })\n );\n }\n } else {\n if (target.attributes.length > 1 && !target.isPiPoint) {\n promises = Promise.all(\n target.elementPathArray.map((elementPath: PiwebapiElementPath) => {\n return ds\n .restGetWebId(elementPath.path, target.isPiPoint)\n .then((datarsp) =>\n ds.getAttributes(datarsp.WebId!, {\n searchFullHierarchy: 'true',\n nameFilter: '*',\n })\n )\n .then((datarspa) =>\n datarspa.filter(\n (d) =>\n target.attributes.indexOf(d.Name) >= 0 ||\n target.attributes.indexOf(d.Path?.split('|').splice(1).join('|')) >= 0\n )\n );\n })\n );\n } else {\n promises = Promise.all(\n flatten(\n map(target.attributes, (attribute: string) => {\n return target.elementPathArray.map((elementPath: PiwebapiElementPath) => {\n if (target.expression) {\n return this.getDataServer(this.piserver.name).then((data) => {\n data.Path = attribute;\n return data;\n });\n } else {\n return ds.restGetWebId(elementPath.path + '|' + attribute, target.isPiPoint);\n }\n })\n })\n )\n );\n }\n }\n\n const getFinalUrl = (replace: boolean, webid: PiwebapiRsp, url: string): string => {\n const newUrl = (replace ? url.replace(/'\\.'/g, `'${webid.Path}'`) : url);\n return newUrl;\n }\n\n return promises.then((webidresponse) => {\n const query: any = {};\n each(flatten(webidresponse), (webid, index) => {\n query[index + 1] = {\n Method: 'GET',\n Resource: ds.piwebapiurl + getFinalUrl(target.isPiPoint && !!target.expression, webid, url) + '&webId=' + webid.WebId,\n };\n });\n\n return ds\n .restBatch(query)\n .then((response: any) => {\n const targetResults: any[] = [];\n each(response.data, (value, key) => {\n if (target.expression) {\n const webid = webidresponse[parseInt(key, 10) - 1];\n const attribute = target.isPiPoint ? webid.Path : webid.Name;\n each(\n ds.processResults(value.Content, target, displayName || attribute || targetName, noTemplate),\n (targetResult) => targetResults.push(targetResult)\n );\n } else {\n each(value.Content.Items, (item) => {\n console.log(item);\n each(\n ds.processResults(item, target, displayName || item.Name || targetName, noTemplate),\n (targetResult) => targetResults.push(targetResult)\n );\n });\n }\n });\n return targetResults;\n })\n .catch((err: any) => (ds.error = err));\n });\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.backendSrv\n .datasourceRequest({\n url: this.url + path,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n })\n .then((response: any) => {\n return response as PiwebapiInternalRsp;\n });\n }\n\n /**\n * Resolve a Grafana query into a PI Web API webid. Uses client side cache when possible to reduce lookups.\n *\n * @param {string} assetPath - The AF Path or the Pi Point Path (\\\\ServerName\\piPointName) to the asset.\n * @param {boolean} isPiPoint - Flag indicating it's a PI Point\n * @returns - URL query parameters.\n *\n * @memberOf PiWebApiDatasource\n */\n private restGetWebId(assetPath: string, isPiPoint: boolean): Promise {\n const ds = this;\n\n // check cache\n const cachedWebId = ds.webidCache.get(assetPath);\n if (cachedWebId) {\n return Promise.resolve({ Path: assetPath, WebId: cachedWebId.WebId, Name: cachedWebId.Name });\n }\n\n let path = '';\n if (isPiPoint) {\n path = '/points?selectedFields=WebId%3BName%3BPath&path=\\\\\\\\' + assetPath.replace('|', '\\\\');\n } else {\n // no cache hit, query server\n path =\n (assetPath.indexOf('|') >= 0\n ? '/attributes?selectedFields=WebId%3BName%3BPath&path=\\\\\\\\'\n : '/elements?selectedFields=WebId%3BName%3BPath&path=\\\\\\\\') + assetPath;\n }\n\n return this.backendSrv\n .datasourceRequest({\n url: this.url + path,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n })\n .then((response: any) => {\n ds.webidCache.set(assetPath, response.data);\n return { Path: assetPath, WebId: response.data.WebId, Name: response.data.Name };\n });\n }\n\n /**\n * Execute a batch query on the PI Web API.\n *\n * @param {any} batch - Batch JSON query data.\n * @returns - Batch response.\n *\n * @memberOf PiWebApiDatasource\n */\n private restBatch(batch: any) {\n return this.backendSrv.datasourceRequest({\n url: this.url + '/batch',\n data: batch,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Requested-With': 'message/http',\n },\n });\n }\n\n /**\n * Execute a POST on the PI Web API.\n *\n * @param {string} path - The full url of the POST.\n * @returns - POST response data.\n *\n * @memberOf PiWebApiDatasource\n */\n private restPost(path: string) {\n return this.backendSrv.datasourceRequest({\n url: this.url,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Requested-With': 'message/http',\n 'X-PIWEBAPI-HTTP-METHOD': 'GET',\n 'X-PIWEBAPI-RESOURCE-ADDRESS': path,\n },\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.data.Items ?? []);\n }\n private getDataServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/dataservers?name=' + name).then((response) => response.data);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.data.Items ?? []);\n }\n private getAssetServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/assetservers?path=\\\\\\\\' + name).then((response) => response.data);\n }\n private getDatabase(path: string | undefined): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/assetdatabases?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getDatabases(serverId: string, options?: any): Promise {\n if (!serverId) {\n return Promise.resolve([]);\n }\n return this.restGet('/assetservers/' + serverId + '/assetdatabases').then((response) => response.data.Items ?? []);\n }\n getElement(path: string): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/elements?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getEventFrameTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'EventFrame');\n });\n }\n getElementTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'Element');\n });\n }\n\n /**\n * @description\n * Get the child attributes of the current resource.\n * GET attributes/{webId}/attributes\n * @param {string} elementId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.nameFilter - The name query string used for finding attributes. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned attributes must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned attributes must be members of this template. The default is no template filter.\n * @param {string} options.valueType - Specify that returned attributes' value type must be the given value type. The default is no value type filter.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include attributes nested further than the immediate attributes of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {string} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {string} options.showExcluded - Specified if the search should include attributes with the Excluded property set. The default is 'false'.\n * @param {string} options.showHidden - Specified if the search should include attributes with the Hidden property set. The default is 'false'.\n * @param {string} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getAttributes(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/attributes' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET assetdatabases/{webId}/elements\n * @param {string} databaseId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getDatabaseElements(databaseId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/assetdatabases/' + databaseId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET elements/{webId}/elements\n * @param {string} databaseId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getElements(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * Retrieve a list of points on a specified Data Server.\n *\n * @param {string} serverId - The ID of the server. See WebID for more information.\n * @param {string} nameFilter - A query string for filtering by point name. The default is no filter. *, ?, [ab], [!ab]\n */\n private piPointSearch(serverId: string, nameFilter: string): Promise {\n let filter1 = this.templateSrv.replace(nameFilter);\n let filter2 = `${filter1}`;\n let doFilter = false;\n if (filter1 !== nameFilter) {\n const regex = /\\{(\\w|,)+\\}/gs;\n let m;\n while ((m = regex.exec(filter1)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n if (groupIndex === 0) {\n filter1 = filter1.replace(match, match.replace('{', '(').replace('}', ')').replace(',', '|'));\n filter2 = filter2.replace(match, '*');\n doFilter = true;\n }\n });\n }\n }\n return this.restGet('/dataservers/' + serverId + '/points?maxCount=20&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results.data?.Items) {\n return doFilter ? results.data.Items.filter((item) => item.Name?.match(filter1)) : results.data.Items;\n }\n return [];\n });\n }\n\n /**\n * Get the PI Web API webid or PI Point.\n *\n * @param {any} target - AF Path or Point name.\n * @returns - webid.\n *\n * @memberOf PiWebApiDatasource\n */\n getWebId(target: any) {\n const ds = this;\n const isAf = target.target.indexOf('\\\\') >= 0;\n const isAttribute = target.target.indexOf('|') >= 0;\n if (!isAf && target.target.indexOf('.') === -1) {\n return Promise.resolve([{ WebId: target.target, Name: target.display || target.target }]);\n }\n\n if (!isAf) {\n // pi point lookup\n return ds.piPointSearch(this.piserver.webid!, target.target).then((results) => {\n if (results === undefined || results.length === 0) {\n return [{ WebId: target.target, Name: target.display || target.target }];\n }\n return results;\n });\n } else if (isAf && isAttribute) {\n // af attribute lookup\n return ds.restGet('/attributes?path=\\\\\\\\' + target.target).then((results) => {\n if (results.data === undefined || results.status !== 200) {\n return [{ WebId: target.target, Name: target.display || target.target }];\n }\n // rewrite name if specified\n results.data.Name = target.display || results.data.Name;\n return [results.data];\n });\n } else {\n // af element lookup\n return ds.restGet('/elements?path=\\\\\\\\' + target.target).then((results) => {\n if (results.data === undefined || results.status !== 200) {\n return [{ WebId: target.target, Name: target.display || target.target }];\n }\n // rewrite name if specified\n results.data.Name = target.display || results.data.Name;\n return [results.data];\n });\n }\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { AnnotationsQueryCtrl } from './AnnotationsQueryCtrl';\nimport { PIWebAPIConfigEditor } from './ConfigEditor';\nimport { PIWebAPIQueryEditor } from './QueryEditor';\nimport { PiWebAPIDatasource } from './datasource';\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n PiWebAPIDatasource\n)\n .setConfigEditor(PIWebAPIConfigEditor)\n .setQueryEditor(PIWebAPIQueryEditor)\n .setAnnotationQueryCtrl(AnnotationsQueryCtrl);\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__0__","__WEBPACK_EXTERNAL_MODULE__1__","__WEBPACK_EXTERNAL_MODULE__2__","__WEBPACK_EXTERNAL_MODULE__3__","__WEBPACK_EXTERNAL_MODULE__5__","__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","AnnotationsQueryCtrl","$scope","this","annotation","ctrl","datasource","query","databases","templates","regex","attribute","showEndTime","getAssetServer","afserver","name","then","result","getDatabases","WebId","getEventFrames","webid","dbs","$apply","getEventFrameTemplates","database","FormField","LegacyForms","coerceOptions","options","jsonData","url","PIWebAPIConfigEditor","event","props","onOptionsChange","piserver","target","afdatabase","checked","pipoint","originalOptions","DataSourceHttpSettings","defaultUrl","dataSourceConfig","onChange","onMyOptionsChange","showAccessOptions","className","InlineField","label","labelWidth","InlineSwitch","onPiPointChange","inputWidth","onPIServerChange","placeholder","onAFServerChange","onAFDatabaseChange","PureComponent","QueryField","tooltip","children","InlineFormLabel","width","QueryRowTerminator","QueryInlineField","QueryEditorRow","QueryRawInlineField","QueryRawEditorRow","defaultQuery","attributes","segments","enable","summary","types","basis","interval","nodata","expression","interpolate","useLastValue","recordedValues","digitalStates","isPiPoint","QueryEditorModeSwitcher","isRaw","useState","isModalOpen","setModalOpen","useEffect","Button","icon","variant","type","onClick","ConfirmModal","isOpen","title","body","confirmText","dismissText","onConfirm","onDismiss","LABEL_WIDTH","MIN_ATTR_INPUT_WIDTH","REMOVE_LABEL","CustomLabelComponent","Icon","PIWebAPIQueryEditor","summaries","attributeSegment","summarySegment","calculationBasisSegment","noDataReplacementSegment","setState","item","index","state","slice","remove","checkPiPointSegments","checkAttributeSegments","length","push","expandable","piServer","segmentChangeValue","currentSegment","data","findQuery","path","getSegmentPathUpTo","Promise","resolve","metricFindQuery","assign","request","scopedVars","items","altSegments","map","text","webId","variables","templateSrv","getVariables","each","variable","selectableValue","unshift","err","error","message","attributeText","getSelectedPIServer","pointName","Path","forOwn","availableAttributes","val","segmentsArray","attributesArray","splitAttributes","split","splitElements","splice","_","getElementSegments","elements","summariesArray","cb","initialLoad","scopedVarsDone","force","metricsQuery","defaults","buildFromTarget","_segmentsArray","updateArray","e","checkAfServer","onRunQuery","rawQuery","elementPath","join","s","queryChange","onSegmentChange","bind","calcBasisValueChanged","calcNoDataValueChanged","onSummaryAction","onSummaryValueChanged","onAttributeAction","onAttributeChange","summaryTypes","calculationBasis","noDataReplacement","segment","isValueEmpty","stateCallback","filter","indexOf","part","attributeChangeValue","arr","reduce","startsWith","attributesResponse","validAttributes","substring","filteredAttributes","attrib","changedValue","replace","webID","forEach","parts","match","queryProps","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","textEditorChanged","SegmentAsync","Component","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","getAttributeSegmentsAF","maxNumber","parseInt","getNoDataSegments","getCalcBasisSegments","getSummarySegments","search","PiWebAPIDatasource","instanceSettings","Map","basicAuth","withCredentials","getTemplateSrv","backendSrv","getBackendSrv","piwebapiurl","toString","isProxy","test","access","all","getDataServer","getDatabase","annotationOptions","endTime","eventFrame","attributeDataItems","Name","RegExp","attributeData","attributeValue","Value","time","Date","EndTime","StartTime","getTime","targets","ds","tar","elementPathArray","att","refId","hide","webids","startTime","range","from","to","varsKeys","keys","v","isAllSelected","current","selected","attr","vv","allValue","uniq","flatten","getElementPath","Array","isArray","buildQueryParameters","t","getStream","targetResponses","flattened","tr","sort","b","toDataFrame","datasourceRequest","method","response","status","Error","categoryName","nameFilter","templateName","template","iconColor","toJSON","resourceUrl","Method","Resource","RequestTemplate","Parameters","ParentIds","restBatch","Content","valueData","annotations","Items","curry","eventFrameToAnnotation","ends","end","restGet","HasChildren","queryOptions","querydepth","JSON","parse","Math","max","min","metricQueryTransform","getAssetServers","server","db","getDatabaseElements","selectedFields","getElement","element","getElements","getAttributes","searchFullHierarchy","getDataServers","piPointSearch","reject","trim","isSummary","datapoints","piPointValue","noDataReplace","parsePiPointValue","grafanaDataPoint","previousValue","drop","num","Good","checkNumber","Number","Timestamp","noDataReplacementMode","content","noTemplate","api","getPath","innerResults","groups","groupBy","Type","parsePiPointValueData","number","isNaN","isFinite","newElementPathArray","elem","temp","concat","splitPath","splitStr","pop","foundElement","find","results","isInterpolated","intervalTime","timeRange","targetName","displayName","encodeURIComponent","internalStream","restPost","processResults","restGetWebId","webidresponse","maxDataPoints","getSummaryUrl","promises","datarsp","datarspa","getFinalUrl","targetResults","targetResult","headers","assetPath","cachedWebId","webidCache","set","batch","serverId","databaseId","InstanceType","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","isAf","isAttribute","DataSourceApi","plugin","DataSourcePlugin","setConfigEditor","setQueryEditor","setAnnotationQueryCtrl"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"module.js","mappings":";uHAAAA,EAAOC,QAAUC,OCAjBF,EAAOC,QAAUE,OCAjBH,EAAOC,QAAUG,OCAjBJ,EAAOC,QAAUI,QCAjBL,EAAOC,QAAUK,ICCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaT,QAGrB,IAAID,EAASO,EAAyBE,GAAY,CAGjDR,QAAS,CAAC,GAOX,OAHAW,EAAoBH,GAAUT,EAAQA,EAAOC,QAASO,GAG/CR,EAAOC,OACf,CCrBAO,EAAoBK,EAAKb,IACxB,IAAIc,EAASd,GAAUA,EAAOe,WAC7B,IAAOf,EAAiB,QACxB,IAAM,EAEP,OADAQ,EAAoBQ,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdN,EAAoBQ,EAAI,CAACf,EAASiB,KACjC,IAAI,IAAIC,KAAOD,EACXV,EAAoBY,EAAEF,EAAYC,KAASX,EAAoBY,EAAEnB,EAASkB,IAC5EE,OAAOC,eAAerB,EAASkB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDX,EAAoBY,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFlB,EAAoBsB,EAAK7B,IACH,oBAAX8B,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAerB,EAAS8B,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAerB,EAAS,aAAc,CAAEgC,OAAO,GAAO,8VCLvD,IAAMC,EAAoB,W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EAAG4D,QAAQ,sBAAwB3S,EAAOA,QAAQrB,MAAK,SAAC2X,GAC7D,YAAqBja,IAAjBia,EAAQ1Q,MAAyC,MAAnB0Q,EAAQlF,OACjC,CAAC,CAAEtS,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,UAGjEsW,EAAQ1Q,KAAKwI,KAAOpO,EAAOwL,SAAW8K,EAAQ1Q,KAAKwI,KAC5C,CAACkI,EAAQ1Q,MAClB,IAzBOmJ,EAAGiF,cAAclW,KAAKiC,SAASf,MAAQgB,EAAOA,QAAQrB,MAAK,SAAC2X,GACjE,YAAgBja,IAAZia,GAA4C,IAAnBA,EAAQhR,OAC5B,CAAC,CAAExG,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,SAE1DsW,CACT,IAVOtQ,QAAQC,QAAQ,CAAC,CAAEnH,MAAOkB,EAAOA,OAAQoO,KAAMpO,EAAOwL,SAAWxL,EAAOA,SAgCnF,IA3xCF,mFA2xCG,EA9uC4B,CAAS8Y,EAAAA,eCvC3BC,GAAS,IAAIC,EAAAA,iBACxBhM,IAECiM,gBAAgBtZ,GAChBuZ,eAAe1U,GACf2U,uBAAuBvb","sources":["webpack:///external amd \"react\"","webpack:///external amd \"@grafana/ui\"","webpack:///external amd \"@grafana/data\"","webpack:///external amd \"lodash\"","webpack:///external amd \"@grafana/runtime\"","webpack:///webpack/bootstrap","webpack:///webpack/runtime/compat get default export","webpack:///webpack/runtime/define property getters","webpack:///webpack/runtime/hasOwnProperty shorthand","webpack:///webpack/runtime/make namespace object","webpack:///./AnnotationsQueryCtrl.ts","webpack:///./ConfigEditor.tsx","webpack:///./components/Forms.tsx","webpack:///./types.ts","webpack:///./components/QueryEditorModeSwitcher.tsx","webpack:///./QueryEditor.tsx","webpack:///./datasource.ts","webpack:///./module.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","module.exports = __WEBPACK_EXTERNAL_MODULE__2__;","module.exports = __WEBPACK_EXTERNAL_MODULE__3__;","module.exports = __WEBPACK_EXTERNAL_MODULE__5__;","// 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};","export class AnnotationsQueryCtrl {\n static templateUrl = 'partials/annotations.editor.html';\n\n $scope: any;\n annotation: any;\n datasource: any;\n\n /** @ngInject */\n constructor($scope: any) {\n this.$scope = $scope;\n this.annotation = $scope.ctrl.annotation;\n this.datasource = $scope.ctrl.datasource;\n\n // load defaults\n this.annotation.query = this.annotation.query || {};\n this.annotation.databases = this.annotation.databases || [];\n this.annotation.templates = this.annotation.templates || [];\n this.annotation.regex = this.annotation.regex || {};\n this.annotation.attribute = this.annotation.attribute || {};\n this.annotation.showEndTime = this.annotation.showEndTime || false;\n\n this.datasource.getAssetServer(this.datasource.afserver.name).then((result: any) => {\n return this.getDatabases(result.WebId);\n });\n }\n templateChanged() {\n // do nothing\n }\n databaseChanged() {\n this.annotation.templates = [];\n this.getEventFrames();\n }\n getDatabases(webid: string) {\n const ctrl = this;\n ctrl.datasource.getDatabases(webid).then((dbs: any) => {\n ctrl.annotation.databases = dbs;\n this.$scope.$apply();\n });\n }\n getEventFrames() {\n const ctrl = this;\n ctrl.datasource.getEventFrameTemplates(this.annotation.database.WebId).then((templates: any) => {\n ctrl.annotation.templates = templates;\n this.$scope.$apply();\n });\n }\n}\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 onMyOptionsChange = (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 render() {\n const { options: originalOptions } = this.props;\n const options = coerceOptions(originalOptions);\n\n return (\n
\n \n\n

PI Point

\n\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, DataSourceJsonData } from '@grafana/data';\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: any[];\n segments: any[];\n display: any;\n interpolate: any;\n recordedValues: any;\n digitalStates: any;\n useLastValue: any,\n webid: string;\n webids: string[];\n regex: any;\n summary: any;\n expression: string;\n isPiPoint: boolean;\n rawQuery?: boolean;\n query?: string;\n}\n\nexport const defaultQuery: Partial = {\n target: ';',\n attributes: [],\n segments: [],\n regex: { enable: false },\n summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false },\n digitalStates: { enable: false },\n 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}\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, 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, VariableModel } 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';\n\nconst LABEL_WIDTH = 24;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n segments: Array>;\n attributes: Array>;\n summaries: Array>;\n attributeSegment: SelectableValue;\n summarySegment: SelectableValue;\n calculationBasisSegment: SelectableValue;\n noDataReplacementSegment: SelectableValue;\n}\n\ntype Props = QueryEditorProps;\n\nconst REMOVE_LABEL = '-REMOVE-';\n\nconst CustomLabelComponent = (props: any) => {\n if (props.value) {\n return (\n
\n {props.label ?? '--no label--'}\n
\n );\n }\n return (\n \n \n \n );\n};\n\nexport class PIWebAPIQueryEditor extends PureComponent {\n error: any;\n piServer: any[] = [];\n availableAttributes: any = {};\n summaryTypes: string[];\n calculationBasis: string[];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n segments: [],\n attributes: [],\n summaries: [],\n attributeSegment: {},\n summarySegment: {},\n calculationBasisSegment: {},\n noDataReplacementSegment: {},\n };\n\n constructor(props: any) {\n super(props);\n this.onSegmentChange = this.onSegmentChange.bind(this);\n this.calcBasisValueChanged = this.calcBasisValueChanged.bind(this);\n this.calcNoDataValueChanged = this.calcNoDataValueChanged.bind(this);\n this.onSummaryAction = this.onSummaryAction.bind(this);\n this.onSummaryValueChanged = this.onSummaryValueChanged.bind(this);\n this.onAttributeAction = this.onAttributeAction.bind(this);\n this.onAttributeChange = this.onAttributeChange.bind(this);\n\n this.summaryTypes = [\n // 'None', // A summary type is not specified.\n 'Total', // A totalization over the time range.\n 'Average', // The average value over the time range.\n 'Minimum', // The minimum value over the time range.\n 'Maximum', // The maximum value over the time range.\n 'Range', // The range value over the time range (minimum-maximum).\n 'StdDev', // The standard deviation over the time range.\n 'PopulationStdDev', // The population standard deviation over the time range.\n 'Count', // The sum of event count over the time range when calculation basis is event weighted. The sum of event time duration over the time range when calculation basis is time weighted.\n 'PercentGood', // Percent of data with good value during the calculation period. For time weighted calculations, the percentage is based on time. For event weighted calculations, the percent is based on event count.\n 'All', // A convenience for requesting all available summary calculations.\n 'AllForNonNumeric', // A convenience for requesting all available summary calculations for non-numeric data.\n ];\n\n this.calculationBasis = [\n 'TimeWeighted', // Weight the values in the calculation by the time over which they apply. Interpolation is based on whether the attribute is stepped. Interpolated events are generated at the boundaries if necessary.\n 'EventWeighted', // Evaluate values with equal weighting for each event. No interpolation is done. There must be at least one event within the time range to perform a successful calculation. Two events are required for standard deviation. In handling events at the boundary of the calculation, the AFSDK uses following rules:\n 'TimeWeightedContinuous', // Apply weighting as in TimeWeighted, but do all interpolation between values as if they represent continuous data, (standard interpolation) regardless of whether the attribute is stepped.\n 'TimeWeightedDiscrete', // Apply weighting as in TimeWeighted but interpolation between values is performed as if they represent discrete, unrelated values (stair step plot) regardless of the attribute is stepped.\n 'EventWeightedExcludeMostRecentEvent', // The calculation behaves the same as _EventWeighted_, except in the handling of events at the boundary of summary intervals in a multiple intervals calculation. Use this option to prevent events at the intervals boundary from being double count at both intervals. With this option, events at the end time (most recent time) of an interval is not used in that interval.\n 'EventWeightedExcludeEarliestEvent', // Similar to the option _EventWeightedExcludeMostRecentEvent_. Events at the start time(earliest time) of an interval is not used in that interval.\n 'EventWeightedIncludeBothEnds', // Events at both ends of the interval boundaries are included in the event weighted calculation.\n ];\n\n this.noDataReplacement = [\n 'Null', // replace with nulls\n 'Drop', // drop items\n 'Previous', // use previous value if available\n '0', // replace with 0\n 'Keep', // Keep value\n ];\n }\n\n // is selected segment empty\n isValueEmpty(value: PIWebAPISelectableValue | undefined) {\n return !value || !value.value || !value.value.length || value.value === REMOVE_LABEL;\n }\n\n segmentChangeValue = (segments: Array>) => {\n const query = this.props.query;\n this.setState({ segments }, () => this.onChange({ ...query, segments }));\n };\n\n attributeChangeValue = (attributes: Array>) => {\n const query = this.props.query;\n this.setState({ attributes }, () => this.onChange({ ...query, attributes }));\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 summary.basis = segment.value?.value;\n this.onChange({ ...metricsQuery, summary });\n }\n // get summary calculation basis user interface segments\n getCalcBasisSegments() {\n const segments = map(this.calculationBasis, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // no data change event\n calcNoDataValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n summary.nodata = segment.value?.value;\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 ctrl = this;\n const summaryTypes = filter(ctrl.summaryTypes, (type) => {\n return this.state.summaries.map((s) => s.value?.value).indexOf(type) === -1;\n });\n const segments = map(summaryTypes, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n }\n\n // remove a summary from the user interface and the query\n removeSummary(part: SelectableValue) {\n const summaries = filter(this.state.summaries, (item: SelectableValue) => {\n return item !== part;\n });\n this.setState({ summaries });\n }\n // add a new summary to the query\n onSummaryAction(item: SelectableValue) {\n const summaries = this.state.summaries.slice(0) as Array>;\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: true,\n },\n };\n summaries.push(selectableValue);\n }\n this.setState({ summarySegment: {}, summaries }, this.stateCallback);\n }\n\n // remove an attribute from the query\n removeAttribute(part: SelectableValue) {\n const attributes = filter(this.state.attributes, (item: SelectableValue) => {\n return item !== part;\n });\n this.attributeChangeValue(attributes);\n }\n // add an attribute to the query\n onAttributeAction(item: SelectableValue) {\n const { query } = this.props;\n const attributes = this.state.attributes.slice(0);\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: !query.isPiPoint,\n },\n };\n attributes.push(selectableValue);\n }\n this.attributeChangeValue(attributes);\n }\n\n // pi point change event\n onPiPointChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n if (item.label === REMOVE_LABEL) {\n remove(attributes, (value, n) => n === index);\n } else {\n // set current value\n attributes[index] = item;\n }\n\n this.checkPiPointSegments(item, attributes);\n };\n // attribute change event\n onAttributeChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n // 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 if (item.label === REMOVE_LABEL) {\n segments = slice(segments, 0, index);\n this.checkAttributeSegments([], segments);\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 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);\n // add new options\n if (!!item.value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n this.segmentChangeValue(segments);\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 : { path: this.getSegmentPathUpTo(currentSegment ?? this.state.segments.slice(0), index) };\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 // if (!findQuery.path?.length) {\n // return Promise.resolve([]);\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: VariableModel) => {\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 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: VariableModel) => {\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 segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n return segments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return segments;\n });\n };\n\n // get the list of attributes for the user interface - AF\n getAttributeSegmentsAF = (attributeText?: string): Array> => {\n const ctrl = this;\n let segments: Array> = [];\n\n 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 segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\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 value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, (item, _) => {\n if (item !== '') {\n // set current value\n attributesArray.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n return this.getElementSegments(splitElements.length + 1, segmentsArray).then((elements) => {\n if (elements.length > 0) {\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return segmentsArray;\n });\n }\n return Promise.resolve(segmentsArray);\n };\n\n /**\n * Gets the segment information and parses it to a string.\n *\n * @param {any} index - Last index of segment to use.\n * @returns - AF Path or PI Point name.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSegmentPathUpTo(segments: Array>, index: number): string {\n const arr = segments.slice(0, index);\n\n return reduce(\n arr,\n (result: any, segment: SelectableValue) => {\n if (!segment.value) {\n return '';\n }\n if (!segment.value.value?.startsWith('-Select')) {\n return result ? result + '\\\\' + segment.value.value : segment.value.value;\n }\n return result;\n },\n ''\n );\n }\n\n /**\n * Get the current AF Element's child attributes. Validates when the element selection changes.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAttributeSegments(\n attributes: Array>,\n segments: Array>\n ): Promise {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: this.getSegmentPathUpTo(segments.slice(0), segments.length),\n type: 'attributes',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: false }))\n .then((attributesResponse: any) => {\n const validAttributes: any = {};\n\n each(attributesResponse, (attribute: any) => {\n validAttributes[attribute.Path.substring(attribute.Path.indexOf('|') + 1)] = attribute.WebId;\n });\n\n const filteredAttributes = filter(attributes, (attrib: SelectableValue) => {\n const changedValue = datasource.templateSrv.replace(attrib.value?.value);\n return validAttributes[changedValue] !== undefined;\n });\n\n ctrl.availableAttributes = validAttributes;\n this.attributeChangeValue(filteredAttributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n 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 ctrl.attributeChangeValue(attributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n 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, onChange } = 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 this.getElementSegments(splitElements.length + 1, segments).then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n });\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n this.updateArray(segments, attributes, this.state.summaries, query.isPiPoint, () => {\n onChange({ ...query, query: undefined, rawQuery: false });\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, isPiPoint);\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 query.summary.types = this.state.summaries;\n if (query.rawQuery) {\n query.target = query.query ?? '';\n\n if (query.target !== '') {\n const splitAttributes = query.target.split(';');\n const splitElements = splitAttributes[0].split('\\\\');\n\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n query.attributes = [];\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n query.elementPath = splitElements.join('\\\\');\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n query.attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n }\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\n onChange(query);\n\n if (query.target && query.target.length > 0 && query.attributes.length > 0) {\n onRunQuery();\n }\n };\n\n stateCallback = () => {\n const query = this.props.query as PIWebAPIQuery;\n this.onChange(query);\n };\n\n onIsPiPointChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const isPiPoint = !queryChange.isPiPoint;\n this.setState(\n {\n segments: isPiPoint ? [{ label: '' }] : this.checkAfServer(),\n attributes: [],\n isPiPoint,\n },\n () => {\n this.onChange({\n ...queryChange,\n expression: '',\n attributes: this.state.attributes,\n segments: this.state.segments,\n isPiPoint,\n });\n }\n );\n };\n\n render() {\n const { query: queryProps, onChange, onRunQuery } = this.props;\n const metricsQuery = defaults(queryProps, defaultQuery) as PIWebAPIQuery;\n const {\n useLastValue,\n interpolate,\n query,\n rawQuery,\n digitalStates,\n recordedValues,\n expression,\n isPiPoint,\n summary,\n display,\n regex,\n } = metricsQuery;\n\n return (\n <>\n {this.props.datasource.piPointConfig && (\n \n \n \n )}\n\n {!!rawQuery && (\n \n \n ) =>\n onChange({ ...metricsQuery, query: event.target.value })\n }\n placeholder=\"enter query\"\n />\n \n this.textEditorChanged()} />\n \n )}\n\n {!rawQuery && (\n <>\n
\n \n {this.state.segments.map((segment: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSegmentChange(item, index)}\n loadOptions={(query?: string | undefined) => {\n return this.getElementSegments(index);\n }}\n allowCustomValue\n inputMinWidth={MIN_ELEM_INPUT_WIDTH}\n />\n );\n })}\n \n {!isPiPoint && (\n {\n onChange({ ...metricsQuery, query: metricsQuery.target, rawQuery: value });\n }}\n />\n )}\n \n
\n\n \n {this.state.attributes.map((attribute: SelectableValue, index: number) => {\n if (isPiPoint) {\n return (\n }\n disabled={this.piServer.length === 0}\n onChange={(item) => this.onPiPointChange(item, index)}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n }\n return (\n }\n disabled={this.state.segments.length <= 2}\n onChange={(item) => this.onAttributeChange(item, index)}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n })}\n\n {isPiPoint && (\n \n }\n disabled={this.piServer.length === 0}\n onChange={this.onAttributeAction}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n {!isPiPoint && (\n \n }\n disabled={this.state.segments.length <= 2}\n onChange={this.onAttributeAction}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n \n \n )}\n\n \n \n \n this.onChange({\n ...metricsQuery,\n useLastValue: { ...useLastValue, enable: !useLastValue.enable },\n })\n }\n />\n \n \n\n {!useLastValue.enable && (\n <>\n \n ) =>\n this.onChange({ ...metricsQuery, expression: event.target.value })\n }\n placeholder=\"'.'*2\"\n />\n \n\n \n \n ) =>\n this.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 this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable },\n })\n }\n />\n \n \n \n this.onChange({ ...metricsQuery, digitalStates: { ...digitalStates, enable: !digitalStates.enable } })\n }\n />\n \n \n\n \n \n ) =>\n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable } })\n }\n />\n \n \n }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n \n\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n }\n onChange={this.calcBasisValueChanged}\n options={this.getCalcBasisSegments()}\n allowCustomValue\n />\n \n \n \n {this.state.summaries.map((s: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSummaryValueChanged(item, index)}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n );\n })}\n \n }\n onChange={this.onSummaryAction}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n \n \n \n \n )}\n\n \n \n ) =>\n this.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 this.onChange({ ...metricsQuery, regex: { ...regex, search: event.target.value } })\n }\n placeholder=\"(.*)\"\n />\n \n \n ) =>\n this.onChange({ ...metricsQuery, regex: { ...regex, replace: event.target.value } })\n }\n placeholder=\"$1\"\n />\n \n \n \n );\n }\n}\n","import { curry, each, filter, flatten, forOwn, groupBy, keys, map, uniq } from 'lodash';\n\nimport {\n DataQueryRequest,\n DataQueryResponse,\n DataSourceApi,\n DataSourceInstanceSettings,\n AnnotationEvent,\n toDataFrame,\n MetricFindValue,\n} from '@grafana/data';\nimport { BackendSrv, getBackendSrv, getTemplateSrv, TemplateSrv } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\ninterface PiwebapiElementPath {\n path: string;\n variable: string;\n}\n\ninterface PiwebapiInternalRsp {\n data: PiwebapiRsp;\n status: number;\n url: string;\n}\n\ninterface PiwebapTargetRsp {\n refId: string;\n target: string;\n datapoints: any[];\n}\n\ninterface PiwebapiRsp {\n Name?: string;\n InstanceType?: string;\n Items?: PiwebapiRsp[];\n WebId?: string;\n HasChildren?: boolean;\n Path?: string;\n}\n\ninterface PiDataServer {\n name: string | undefined;\n webid: string | undefined;\n}\n\nexport class PiWebAPIDatasource extends DataSourceApi {\n piserver: PiDataServer;\n afserver: PiDataServer;\n afdatabase: PiDataServer;\n piPointConfig: boolean;\n\n basicAuth?: string;\n withCredentials?: boolean;\n url: string;\n name: string;\n isProxy = false;\n\n templateSrv: TemplateSrv;\n backendSrv: BackendSrv;\n\n piwebapiurl?: string;\n webidCache: Map = new Map();\n\n error: any;\n\n constructor(instanceSettings: DataSourceInstanceSettings) {\n super(instanceSettings);\n this.basicAuth = instanceSettings.basicAuth;\n this.withCredentials = instanceSettings.withCredentials;\n this.url = instanceSettings.url!;\n this.name = instanceSettings.name;\n this.templateSrv = getTemplateSrv();\n this.backendSrv = getBackendSrv();\n\n this.piwebapiurl = instanceSettings.jsonData.url?.toString();\n this.isProxy = /^http(s)?:\\/\\//.test(this.url) || instanceSettings.jsonData.access === 'proxy';\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\n Promise.all([\n this.getAssetServer(this.afserver.name).then((result: PiwebapiRsp) => (this.afserver.webid = result.WebId)),\n this.getDataServer(this.piserver.name).then((result: PiwebapiRsp) => (this.piserver.webid = result.WebId)),\n this.getDatabase(this.afserver.name ? this.afserver.name + '\\\\' + this.afdatabase.name : undefined).then(\n (result: PiwebapiRsp) => (this.afdatabase.webid = result.WebId)\n ),\n ]);\n }\n\n /**\n * Converts a PIWebAPI Event Frame response to a Grafana Annotation\n *\n * @param {any} annotationOptions - Options data from configuration panel.\n * @param {any} endTime - End time of the Event Frame.\n * @param {any} eventFrame - The Event Frame data.\n * @returns - Grafana Annotation\n *\n * @memberOf PiWebApiDatasource\n */\n private eventFrameToAnnotation(\n annotationOptions: any,\n endTime: any,\n eventFrame: any,\n attributeDataItems: any\n ): AnnotationEvent {\n if (annotationOptions.regex && annotationOptions.regex.enable) {\n eventFrame.Name = eventFrame.Name.replace(\n new RegExp(annotationOptions.regex.search),\n annotationOptions.regex.replace\n );\n }\n\n let attributeText = '';\n if (attributeDataItems) {\n each(attributeDataItems, (attributeData: any) => {\n const attributeValue = attributeData.Value.Value\n ? attributeData.Value.Value.Name || attributeData.Value.Value.Value || attributeData.Value.Value\n : null;\n attributeText += '
' + attributeData.Name + ': ' + attributeValue;\n });\n }\n return {\n annotation: annotationOptions,\n title: (endTime ? 'END ' : annotationOptions.showEndTime ? 'START ' : '') + annotationOptions.name,\n time: new Date(endTime ? eventFrame.EndTime : eventFrame.StartTime).getTime(),\n text:\n eventFrame.Name + attributeText + '
Start: ' + eventFrame.StartTime + '
End: ' + eventFrame.EndTime,\n };\n }\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) {\n return false;\n }\n return !target.target.startsWith('Select AF');\n });\n\n options.targets = map(options.targets, (target) => {\n const ds = this;\n const tar = {\n target: this.templateSrv.replace(target.elementPath, options.scopedVars),\n elementPath: this.templateSrv.replace(target.elementPath, options.scopedVars),\n elementPathArray: [\n {\n path: this.templateSrv.replace(target.elementPath, options.scopedVars),\n variable: '',\n } as PiwebapiElementPath,\n ],\n attributes: map(target.attributes, (att) =>\n this.templateSrv.replace(att.value?.value || att, options.scopedVars)\n ),\n segments: map(target.segments, (att) => this.templateSrv.replace(att.value?.value, options.scopedVars)),\n display: target.display,\n refId: target.refId,\n hide: target.hide,\n interpolate: target.interpolate || { enable: false },\n useLastValue: target.useLastValue || { enable: false },\n recordedValues: target.recordedValues || { enable: false },\n digitalStates: target.digitalStates || { enable: false },\n webid: target.webid,\n webids: target.webids || [],\n regex: target.regex || { enable: false },\n expression: target.expression || '',\n summary: target.summary || { types: [] },\n startTime: options.range.from,\n endTime: options.range.to,\n isPiPoint: target.isPiPoint,\n scopedVars: options.scopedVars,\n };\n\n if (tar.expression) {\n tar.expression = this.templateSrv.replace(tar.expression, options.scopedVars);\n }\n\n if (tar.summary.types !== undefined) {\n tar.summary.types = filter(tar.summary.types, (item) => {\n return item !== undefined && item !== null && item !== '';\n });\n }\n\n // explode All or Multi-selection\n const varsKeys = keys(options.scopedVars);\n this.templateSrv.getVariables().forEach((v: any) => {\n if (ds.isAllSelected(v.current) && varsKeys.indexOf(v.name) < 0) {\n // All selection\n const variables = v.options.filter((o: any) => !o.selected);\n // attributes\n tar.attributes = tar.attributes.map((attr: string) =>\n variables.map((vv: any) =>\n !!v.allValue ? attr.replace(v.allValue, vv.value) : attr.replace(/{[a-zA-z0-9,-_]+}/gi, vv.value)\n )\n );\n tar.attributes = uniq(flatten(tar.attributes));\n // elementPath\n tar.elementPathArray = ds.getElementPath(tar.elementPathArray, variables, v.allValue);\n } else if (Array.isArray(v.current.text) && varsKeys.indexOf(v.name) < 0) {\n // Multi-selection\n const variables = v.options.filter((o: any) => o.selected);\n // attributes\n const query = v.current.value.join(',');\n tar.attributes = tar.attributes.map((attr: string) =>\n variables.map((vv: any) => attr.replace(`{${query}}`, vv.value))\n );\n tar.attributes = uniq(flatten(tar.attributes));\n // elementPath\n tar.elementPathArray = ds.getElementPath(tar.elementPathArray, variables, `{${query}}`);\n }\n });\n\n return tar;\n });\n\n return options;\n }\n\n /**\n * Datasource Implementation. Primary entry point for data source.\n * This takes the panel configuration and queries, sends them to PI Web API and parses the response.\n *\n * @param {any} options - Grafana query and panel options.\n * @returns - Promise of data in the format for Grafana panels.\n *\n * @memberOf PiWebApiDatasource\n */\n async query(options: DataQueryRequest): Promise {\n const ds = this;\n const query = this.buildQueryParameters(options);\n query.targets = filter(query.targets, (t) => !t.hide);\n\n if (query.targets.length <= 0) {\n return Promise.resolve({ data: [] });\n } else {\n return Promise.all(ds.getStream(query)).then((targetResponses) => {\n let flattened: PiwebapTargetRsp[] = [];\n each(targetResponses, (tr) => {\n each(tr, (item) => flattened.push(item));\n });\n const response: DataQueryResponse = {\n data: flattened\n .sort((a, b) => {\n return +(a.target > b.target) || +(a.target === b.target) - 1;\n })\n .map((d) => toDataFrame(d)),\n };\n return response;\n });\n }\n }\n\n /**\n * Datasource Implementation.\n * Used for testing datasource in datasource configuration pange\n *\n * @returns - Success or failure message.\n *\n * @memberOf PiWebApiDatasource\n */\n testDatasource(): Promise {\n return this.backendSrv\n .datasourceRequest({\n url: this.url + '/',\n method: 'GET',\n })\n .then((response: any) => {\n if (response.status === 200) {\n return { status: 'success', message: 'Data source is working', title: 'Success' };\n }\n throw new Error('Failed');\n });\n }\n\n /**\n * Datasource Implementation.\n * This queries PI Web API for Event Frames and converts them into annotations.\n *\n * @param {any} options - Annotation options, usually the Event Frame Category.\n * @returns - A Grafana annotation.\n *\n * @memberOf PiWebApiDatasource\n */\n annotationQuery(options: any): Promise {\n if (!this.afdatabase.webid) {\n return Promise.resolve([]);\n }\n\n const categoryName = options.annotation.query.categoryName\n ? this.templateSrv.replace(options.annotation.query.categoryName, options.scopedVars, 'glob')\n : null;\n const nameFilter = options.annotation.query.nameFilter\n ? this.templateSrv.replace(options.annotation.query.nameFilter, options.scopedVars, 'glob')\n : null;\n const templateName = options.annotation.template ? options.annotation.template.Name : null;\n const annotationOptions = {\n name: options.annotation.name,\n datasource: options.annotation.datasource,\n enable: options.annotation.enable,\n iconColor: options.annotation.iconColor,\n showEndTime: options.annotation.showEndTime,\n regex: options.annotation.regex,\n attribute: options.annotation.attribute,\n categoryName: categoryName,\n templateName: templateName,\n nameFilter: nameFilter,\n };\n\n const filter = [];\n if (!!annotationOptions.categoryName) {\n filter.push('categoryName=' + annotationOptions.categoryName);\n }\n if (!!annotationOptions.nameFilter) {\n filter.push('nameFilter=' + annotationOptions.nameFilter);\n }\n if (!!annotationOptions.templateName) {\n filter.push('templateName=' + annotationOptions.templateName);\n }\n if (!filter.length) {\n return Promise.resolve([]);\n }\n filter.push('startTime=' + options.range.from.toJSON());\n filter.push('endTime=' + options.range.to.toJSON());\n\n if (annotationOptions.attribute && annotationOptions.attribute.enable) {\n let resourceUrl =\n this.piwebapiurl + '/streamsets/{0}/value?selectedFields=Items.WebId%3BItems.Value%3BItems.Name';\n if (!!annotationOptions.attribute.name) {\n resourceUrl =\n this.piwebapiurl +\n '/streamsets/{0}/value?nameFilter=' +\n annotationOptions.attribute.name +\n '&selectedFields=Items.WebId%3BItems.Value%3BItems.Name';\n }\n const query: any = {};\n query['1'] = {\n Method: 'GET',\n Resource: this.piwebapiurl + '/assetdatabases/' + this.afdatabase.webid + '/eventframes?' + filter.join('&'),\n };\n query['2'] = {\n Method: 'GET',\n RequestTemplate: {\n Resource: resourceUrl,\n },\n Parameters: ['$.1.Content.Items[*].WebId'],\n ParentIds: ['1'],\n };\n return this.restBatch(query).then((result: any) => {\n const data = result.data['1'].Content;\n const valueData = result.data['2'].Content;\n\n const annotations = map(data.Items, (item: any, index: any) => {\n return curry(this.eventFrameToAnnotation)(\n annotationOptions,\n false,\n item,\n valueData.Items[index].Content.Items\n );\n });\n\n if (options.annotation.showEndTime) {\n const ends = map(data.Items, (item: any, index: number) => {\n return curry(this.eventFrameToAnnotation)(\n annotationOptions,\n true,\n item,\n valueData.Items[index].Content.Items\n );\n });\n each(ends, (end) => {\n annotations.push(end);\n });\n }\n\n return annotations;\n });\n } else {\n return this.restGet('/assetdatabases/' + this.afdatabase.webid + '/eventframes?' + filter.join('&')).then(\n (result) => {\n const annotations = map(result.data.Items, curry(this.eventFrameToAnnotation)(annotationOptions, false));\n if (options.annotation.showEndTime) {\n const ends = map(result.data.Items, curry(this.eventFrameToAnnotation)(annotationOptions, true));\n each(ends, (end) => {\n annotations.push(end);\n });\n }\n return annotations;\n }\n );\n }\n }\n\n /**\n * Builds the Grafana metric segment for use on the query user interface.\n *\n * @param {any} response - response from PI Web API.\n * @returns - Grafana metric segment.\n *\n * @memberOf PiWebApiDatasource\n */\n private metricQueryTransform(response: PiwebapiRsp[]): MetricFindValue[] {\n return map(response, (item) => {\n return {\n text: item.Name,\n expandable:\n item.HasChildren === undefined || item.HasChildren === true || (item.Path ?? '').split('\\\\').length <= 3,\n HasChildren: item.HasChildren,\n Items: item.Items ?? [],\n Path: item.Path,\n WebId: item.WebId,\n } as MetricFindValue;\n });\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 if (query.type !== 'attributes') {\n query.type = querydepth[Math.max(0, Math.min(query.path.split('\\\\').length, querydepth.length - 1))];\n }\n query.path = this.templateSrv.replace(query.path, queryOptions);\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\n if (query.type === 'servers') {\n return ds.afserver?.name\n ? ds\n .getAssetServer(ds.afserver.name)\n .then((result: PiwebapiRsp) => [result])\n .then(ds.metricQueryTransform)\n : ds.getAssetServers().then(ds.metricQueryTransform);\n } else if (query.type === 'databases') {\n return ds\n .getAssetServer(query.path)\n .then((server) => ds.getDatabases(server.WebId ?? '', {}))\n .then(ds.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(ds.metricQueryTransform);\n } else if (query.type === 'elements') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getElements(element.WebId ?? '', {\n selectedFields: 'Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n nameFilter: query.filter,\n })\n )\n .then(ds.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: 'Items.WebId%3BItems.Name%3BItems.Path',\n nameFilter: query.filter,\n })\n )\n .then(ds.metricQueryTransform);\n } else if (query.type === 'dataserver') {\n return ds.getDataServers().then(ds.metricQueryTransform);\n } else if (query.type === 'pipoint') {\n return ds.piPointSearch(query.webId, query.pointName).then(ds.metricQueryTransform);\n }\n return Promise.reject('Bad type');\n }\n\n /**\n * Gets the url of summary data from the query configuration.\n *\n * @param {any} summary - Query summary configuration.\n * @returns - URL append string.\n *\n * @memberOf PiWebApiDatasource\n */\n getSummaryUrl(summary: any) {\n if (summary.interval.trim() === '') {\n return (\n '&summaryType=' +\n summary.types.map((s: any) => s.value?.value).join('&summaryType=') +\n '&calculationBasis=' +\n summary.basis\n );\n }\n return (\n '&summaryType=' +\n summary.types.map((s: any) => s.value?.value).join('&summaryType=') +\n '&calculationBasis=' +\n summary.basis +\n '&summaryDuration=' +\n summary.interval.trim()\n );\n }\n\n /** PRIVATE SECTION */\n\n /**\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\n *\n * @param {any} value - A list of PIWebAPI values.\n * @param {any} target - The target Grafana metric.\n * @param {boolean} isSummary - Boolean for tracking if data is of summary class.\n * @returns - An array of Grafana value, timestamp pairs.\n *\n */\n private parsePiPointValueData(value: any, target: any, isSummary: boolean) {\n const datapoints: any[] = [];\n if (Array.isArray(value)) {\n each(value, (item) => {\n this.piPointValue(isSummary ? item.Value : item, target, false, datapoints);\n });\n } else {\n this.piPointValue(value, target, false, datapoints);\n }\n return datapoints;\n }\n\n /**\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\n *\n * @param {any} value - PI Point value.\n * @param {any} target - The target grafana metric.\n * @param {boolean} isSummary - Boolean for tracking if data is of summary class.\n * @param {any[]} datapoints - Array with Grafana datapoints.\n *\n */\n private piPointValue(value: any, target: any, isSummary: boolean, datapoints: any[]) {\n // @ts-ignore\n const { grafanaDataPoint, previousValue, drop } = this.noDataReplace(\n value,\n target.summary.nodata,\n this.parsePiPointValue(value, target, isSummary)\n );\n if (!drop) {\n datapoints.push(grafanaDataPoint);\n }\n }\n\n /**\n * Convert a PI Point value to use Grafana value/timestamp.\n *\n * @param {any} value - PI Point value.\n * @param {any} target - The target grafana metric.\n * @param {boolean} isSummary - Boolean for tracking if data is of summary class.\n * @returns - Grafana value pair.\n *\n */\n private parsePiPointValue(value: any, target: any, isSummary: boolean) {\n let num = !isSummary && typeof value.Value === 'object' ? value.Value?.Value : value.Value;\n\n if (!value.Good || !!target.digitalStates?.enable) {\n num = (!isSummary && typeof value.Value === 'object' ? value.Value?.Name : value.Name) ?? '';\n return [this.checkNumber(num) ? Number(num) : num.trim(), new Date(value.Timestamp).getTime()];\n }\n\n return [this.checkNumber(num) ? Number(num) : num.trim(), new Date(value.Timestamp).getTime()];\n }\n\n /**\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\n *\n * @param {any} item - 'Item' object from PIWebAPI\n * @param {any} noDataReplacementMode - String state of how to replace 'No Data'\n * @param {any} grafanaDataPoint - Single Grafana value pair (value, timestamp).\n * @returns grafanaDataPoint - Single Grafana value pair (value, timestamp).\n * @returns perviousValue - {any} Grafana value (value only).\n *\n */\n private noDataReplace(\n item: any,\n noDataReplacementMode: any,\n grafanaDataPoint: any[]\n ): {\n grafanaDataPoint: any[];\n previousValue: any;\n drop: boolean;\n } {\n let previousValue = null;\n let drop = false;\n if (!item.Good || item.Value === 'No Data' || (item.Value?.Name && item.Value?.Name === 'No Data')) {\n if (noDataReplacementMode === 'Drop') {\n drop = true;\n } else if (noDataReplacementMode === '0') {\n grafanaDataPoint[0] = 0;\n } else if (noDataReplacementMode === 'Keep') {\n // Do nothing keep\n } else if (noDataReplacementMode === 'Null') {\n grafanaDataPoint[0] = null;\n } else if (noDataReplacementMode === 'Previous' && previousValue !== null) {\n grafanaDataPoint[0] = previousValue;\n }\n } else {\n previousValue = item.Value;\n }\n return { grafanaDataPoint, previousValue, drop };\n }\n\n /**\n * Process the response from PI Web API for a single item.\n *\n * @param {any} content - Web response data.\n * @param {any} target - The target grafana metric.\n * @param {any} name - The target metric name.\n * @returns - Parsed metric in target/datapoint json format.\n *\n * @memberOf PiWebApiDatasource\n */\n private processResults(content: any, target: any, name: any, noTemplate: boolean): PiwebapTargetRsp[] {\n const api = this;\n const isSummary: boolean = target.summary && target.summary.types && target.summary.types.length > 0;\n name = noTemplate ? name : this.getPath(target.elementPathArray, content.Path) + '|' + name;\n if (target.regex && target.regex.enable && target.regex.search.length && target.regex.replace.length) {\n name = name.replace(new RegExp(target.regex.search), target.regex.replace);\n }\n if (isSummary) {\n const innerResults: any[] = [];\n const groups = groupBy(content.Items, (item: any) => item.Type);\n forOwn(groups, (value, key) => {\n innerResults.push({\n refId: target.refId,\n target: name + '[' + key + ']',\n datapoints: api.parsePiPointValueData(value, target, isSummary),\n });\n });\n return innerResults;\n }\n return [\n {\n refId: target.refId,\n target: name,\n datapoints: api.parsePiPointValueData(content.Items || content.Value, target, isSummary),\n },\n ];\n }\n\n /**\n * Check if all items are selected.\n *\n * @param {any} current the current variable selection\n * @return {boolean} true if all value is selected, false otherwise\n */\n private isAllSelected(current: any): boolean {\n if (!current) {\n return false;\n }\n if (Array.isArray(current.text)) {\n return current.text.indexOf('All') >= 0;\n }\n return current.text === 'All';\n }\n\n /**\n * Check if the value is a number.\n *\n * @param {any} number the value to check\n * @returns {boolean} true if the value is a number, false otherwise\n */\n private checkNumber(number: any): boolean {\n return typeof number === 'number' && !Number.isNaN(number) && Number.isFinite(number);\n }\n\n /**\n * Returns a new element path list based on the panel variables.\n *\n * @param {string} elementPathArray array of element paths\n * @param {string} variables the list of variable values\n * @param {string} allValue the all value value for the variable\n * @returns {PiwebapiElementPath[]} new element path list\n */\n private getElementPath(\n elementPathArray: PiwebapiElementPath[],\n variables: any[],\n allValue: string\n ): PiwebapiElementPath[] {\n // elementPath\n let newElementPathArray: PiwebapiElementPath[] = [];\n elementPathArray.forEach((elem: PiwebapiElementPath) => {\n if ((!!allValue && elem.path.indexOf(allValue) >= 0) || (!allValue && elem.path.match(/{[a-zA-z0-9,-_]+}/gi))) {\n const temp: PiwebapiElementPath[] = variables.map((vv: any) => {\n return {\n path: !!allValue\n ? elem.path.replace(allValue, vv.value)\n : elem.path.replace(/{[a-zA-z0-9,-_]+}/gi, vv.value),\n variable: vv.value,\n } as PiwebapiElementPath;\n });\n newElementPathArray = newElementPathArray.concat(temp);\n }\n });\n if (newElementPathArray.length) {\n return uniq(flatten(newElementPathArray));\n }\n return elementPathArray;\n }\n\n /**\n * Returns the last item of the element path.\n *\n * @param {string} path element path\n * @returns {string} last item of the element path\n */\n private getPath(elementPathArray: PiwebapiElementPath[], path: string): string {\n let splitPath = path.split('|');\n if (splitPath.length === 0) {\n return '';\n }\n if (elementPathArray.length === 0) {\n return '';\n }\n splitPath = splitPath[0].split('\\\\');\n const splitStr = splitPath.length === 0 ? '' : splitPath.pop() ?? '';\n const foundElement = elementPathArray.find((e) => path.indexOf(e.path) >= 0)?.variable;\n return foundElement ? foundElement + '|' + splitStr : splitStr;\n }\n\n /**\n * Gets historical data from a PI Web API stream source.\n *\n * @param {any} query - Grafana query.\n * @returns - Metric data.\n *\n * @memberOf PiWebApiDatasource\n */\n private getStream(query: any): Array> {\n const ds = this;\n const results: Array> = [];\n\n each(query.targets, (target) => {\n // pi point config disabled\n if (target.isPiPoint && !ds.piPointConfig) {\n console.error('Trying to call Pi Point server with Pi Point config disabled');\n return;\n }\n target.attributes = filter(target.attributes || [], (attribute) => {\n return 1 && attribute;\n });\n let url = '';\n const isSummary = target.summary && target.summary.types && target.summary.types.length > 0;\n const isInterpolated = target.interpolate && target.interpolate.enable;\n // perhaps add a check to see if interpolate override time < query.interval\n const intervalTime = target.interpolate.interval ? target.interpolate.interval : query.interval;\n const timeRange = '?startTime=' + query.range.from.toJSON() + '&endTime=' + query.range.to.toJSON();\n const targetName = target.expression || target.elementPath;\n const displayName = target.display ? this.templateSrv.replace(target.display, query.scopedVars) : null;\n if (target.expression) {\n url += '/calculation';\n if (isSummary) {\n url += '/summary' + timeRange + (isInterpolated ? '&sampleType=Interval&sampleInterval=' + intervalTime : '');\n } else if (isInterpolated) {\n url += '/intervals' + timeRange + '&sampleInterval=' + intervalTime;\n } else {\n url += '/recorded' + timeRange;\n }\n url += '&expression=' + encodeURIComponent(target.expression.replace(/\\${intervalTime}/g, intervalTime));\n if (target.attributes.length > 0) {\n results.push(ds.internalStream(query, target, url));\n } else if (target.isPiPoint) {\n ds\n .restPost(url + '&webId=' + ds.piserver.webid!)\n .then((response: any) => ds.processResults(response.data, target, displayName || targetName, false))\n .catch((err: any) => (ds.error = err));\n } else {\n results.push(\n ds.restGetWebId(target.elementPath, false).then((webidresponse: any) => {\n return ds\n .restPost(url + webidresponse.WebId)\n .then((response: any) => ds.processResults(response.data, target, displayName || targetName, false))\n .catch((err: any) => (ds.error = err));\n })\n );\n }\n } else {\n url += '/streamsets';\n if (isSummary) {\n url += '/summary' + timeRange + '&intervals=' + query.maxDataPoints + this.getSummaryUrl(target.summary);\n } else if (target.interpolate && target.interpolate.enable) {\n url += '/interpolated' + timeRange + '&interval=' + intervalTime;\n } else if (target.recordedValues && target.recordedValues.enable) {\n const maxNumber =\n target.recordedValues.maxNumber && !isNaN(target.recordedValues.maxNumber)\n ? target.recordedValues.maxNumber\n : 10000;\n url += '/recorded' + timeRange + '&maxCount=' + maxNumber;\n } else if (target.useLastValue?.enable) {\n url += '/value?time=' + query.range.to.toJSON();\n } else {\n url += '/plot' + timeRange + '&intervals=' + query.maxDataPoints;\n }\n\n results.push(ds.internalStream(query, target, url));\n }\n });\n\n return results;\n }\n\n /**\n * Return the data points from the provided Grafana query.\n *\n * @param {any} query - Grafana query.\n * @param {any} target - Grafana query target.\n * @param {string} url - The base URL for the query.\n * @returns - Metric data.\n *\n * @memberOf PiWebApiDatasource\n */\n private internalStream(query: any, target: any, url: string): Promise {\n const ds = this;\n const targetName = target.expression || target.elementPath;\n const displayName = target.display ? this.templateSrv.replace(target.display, query.scopedVars) : null;\n const noTemplate = target.elementPathArray.length === 1 && target.elementPath === target.elementPathArray[0].path;\n let promises: Promise;\n\n if (noTemplate) {\n if (target.attributes.length > 1 && !target.isPiPoint) {\n promises = ds\n .restGetWebId(target.elementPath, target.isPiPoint)\n .then((datarsp) =>\n ds.getAttributes(datarsp.WebId!, {\n searchFullHierarchy: 'true',\n nameFilter: '*',\n })\n )\n .then((datarspa) =>\n datarspa.filter(\n (d) =>\n target.attributes.indexOf(d.Name) >= 0 ||\n target.attributes.indexOf(d.Path?.split('|').splice(1).join('|')) >= 0\n )\n );\n } else {\n promises = Promise.all(\n map(target.attributes, (attribute: string) => {\n if (target.expression) {\n return this.getDataServer(this.piserver.name).then((data) => {\n data.Path = attribute;\n return data;\n });\n } else {\n return ds.restGetWebId(target.elementPath + '|' + attribute, target.isPiPoint);\n }\n })\n );\n }\n } else {\n if (target.attributes.length > 1 && !target.isPiPoint) {\n promises = Promise.all(\n target.elementPathArray.map((elementPath: PiwebapiElementPath) => {\n return ds\n .restGetWebId(elementPath.path, target.isPiPoint)\n .then((datarsp) =>\n ds.getAttributes(datarsp.WebId!, {\n searchFullHierarchy: 'true',\n nameFilter: '*',\n })\n )\n .then((datarspa) =>\n datarspa.filter(\n (d) =>\n target.attributes.indexOf(d.Name) >= 0 ||\n target.attributes.indexOf(d.Path?.split('|').splice(1).join('|')) >= 0\n )\n );\n })\n );\n } else {\n promises = Promise.all(\n flatten(\n map(target.attributes, (attribute: string) => {\n return target.elementPathArray.map((elementPath: PiwebapiElementPath) => {\n if (target.expression) {\n return this.getDataServer(this.piserver.name).then((data) => {\n data.Path = attribute;\n return data;\n });\n } else {\n return ds.restGetWebId(elementPath.path + '|' + attribute, target.isPiPoint);\n }\n })\n })\n )\n );\n }\n }\n\n const getFinalUrl = (replace: boolean, webid: PiwebapiRsp, url: string): string => {\n const newUrl = (replace ? url.replace(/'\\.'/g, `'${webid.Path}'`) : url);\n return newUrl;\n }\n\n return promises.then((webidresponse) => {\n const query: any = {};\n each(flatten(webidresponse), (webid, index) => {\n query[index + 1] = {\n Method: 'GET',\n Resource: ds.piwebapiurl + getFinalUrl(target.isPiPoint && !!target.expression, webid, url) + '&webId=' + webid.WebId,\n };\n });\n\n return ds\n .restBatch(query)\n .then((response: any) => {\n const targetResults: any[] = [];\n each(response.data, (value, key) => {\n if (target.expression) {\n const webid = webidresponse[parseInt(key, 10) - 1];\n const attribute = target.isPiPoint ? webid.Path : webid.Name;\n each(\n ds.processResults(value.Content, target, displayName || attribute || targetName, noTemplate),\n (targetResult) => targetResults.push(targetResult)\n );\n } else {\n each(value.Content.Items, (item) => {\n each(\n ds.processResults(item, target, displayName || item.Name || targetName, noTemplate),\n (targetResult) => targetResults.push(targetResult)\n );\n });\n }\n });\n return targetResults;\n })\n .catch((err: any) => (ds.error = err));\n });\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.backendSrv\n .datasourceRequest({\n url: this.url + path,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n })\n .then((response: any) => {\n return response as PiwebapiInternalRsp;\n });\n }\n\n /**\n * Resolve a Grafana query into a PI Web API webid. Uses client side cache when possible to reduce lookups.\n *\n * @param {string} assetPath - The AF Path or the Pi Point Path (\\\\ServerName\\piPointName) to the asset.\n * @param {boolean} isPiPoint - Flag indicating it's a PI Point\n * @returns - URL query parameters.\n *\n * @memberOf PiWebApiDatasource\n */\n private restGetWebId(assetPath: string, isPiPoint: boolean): Promise {\n const ds = this;\n\n // check cache\n const cachedWebId = ds.webidCache.get(assetPath);\n if (cachedWebId) {\n return Promise.resolve({ Path: assetPath, WebId: cachedWebId.WebId, Name: cachedWebId.Name });\n }\n\n let path = '';\n if (isPiPoint) {\n path = '/points?selectedFields=WebId%3BName%3BPath&path=\\\\\\\\' + assetPath.replace('|', '\\\\');\n } else {\n // no cache hit, query server\n path =\n (assetPath.indexOf('|') >= 0\n ? '/attributes?selectedFields=WebId%3BName%3BPath&path=\\\\\\\\'\n : '/elements?selectedFields=WebId%3BName%3BPath&path=\\\\\\\\') + assetPath;\n }\n\n return this.backendSrv\n .datasourceRequest({\n url: this.url + path,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n })\n .then((response: any) => {\n ds.webidCache.set(assetPath, response.data);\n return { Path: assetPath, WebId: response.data.WebId, Name: response.data.Name };\n });\n }\n\n /**\n * Execute a batch query on the PI Web API.\n *\n * @param {any} batch - Batch JSON query data.\n * @returns - Batch response.\n *\n * @memberOf PiWebApiDatasource\n */\n private restBatch(batch: any) {\n return this.backendSrv.datasourceRequest({\n url: this.url + '/batch',\n data: batch,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Requested-With': 'message/http',\n },\n });\n }\n\n /**\n * Execute a POST on the PI Web API.\n *\n * @param {string} path - The full url of the POST.\n * @returns - POST response data.\n *\n * @memberOf PiWebApiDatasource\n */\n private restPost(path: string) {\n return this.backendSrv.datasourceRequest({\n url: this.url,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Requested-With': 'message/http',\n 'X-PIWEBAPI-HTTP-METHOD': 'GET',\n 'X-PIWEBAPI-RESOURCE-ADDRESS': path,\n },\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.data.Items ?? []);\n }\n private getDataServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/dataservers?name=' + name).then((response) => response.data);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.data.Items ?? []);\n }\n private getAssetServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/assetservers?path=\\\\\\\\' + name).then((response) => response.data);\n }\n private getDatabase(path: string | undefined): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/assetdatabases?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getDatabases(serverId: string, options?: any): Promise {\n if (!serverId) {\n return Promise.resolve([]);\n }\n return this.restGet('/assetservers/' + serverId + '/assetdatabases').then((response) => response.data.Items ?? []);\n }\n getElement(path: string): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/elements?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getEventFrameTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'EventFrame');\n });\n }\n getElementTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'Element');\n });\n }\n\n /**\n * @description\n * Get the child attributes of the current resource.\n * GET attributes/{webId}/attributes\n * @param {string} elementId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.nameFilter - The name query string used for finding attributes. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned attributes must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned attributes must be members of this template. The default is no template filter.\n * @param {string} options.valueType - Specify that returned attributes' value type must be the given value type. The default is no value type filter.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include attributes nested further than the immediate attributes of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {string} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {string} options.showExcluded - Specified if the search should include attributes with the Excluded property set. The default is 'false'.\n * @param {string} options.showHidden - Specified if the search should include attributes with the Hidden property set. The default is 'false'.\n * @param {string} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getAttributes(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/attributes' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET assetdatabases/{webId}/elements\n * @param {string} databaseId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getDatabaseElements(databaseId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/assetdatabases/' + databaseId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET elements/{webId}/elements\n * @param {string} databaseId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getElements(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * Retrieve a list of points on a specified Data Server.\n *\n * @param {string} serverId - The ID of the server. See WebID for more information.\n * @param {string} nameFilter - A query string for filtering by point name. The default is no filter. *, ?, [ab], [!ab]\n */\n private piPointSearch(serverId: string, nameFilter: string): Promise {\n let filter1 = this.templateSrv.replace(nameFilter);\n let filter2 = `${filter1}`;\n let doFilter = false;\n if (filter1 !== nameFilter) {\n const regex = /\\{(\\w|,)+\\}/gs;\n let m;\n while ((m = regex.exec(filter1)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n if (groupIndex === 0) {\n filter1 = filter1.replace(match, match.replace('{', '(').replace('}', ')').replace(',', '|'));\n filter2 = filter2.replace(match, '*');\n doFilter = true;\n }\n });\n }\n }\n return this.restGet('/dataservers/' + serverId + '/points?maxCount=20&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results.data?.Items) {\n return doFilter ? results.data.Items.filter((item) => item.Name?.match(filter1)) : results.data.Items;\n }\n return [];\n });\n }\n\n /**\n * Get the PI Web API webid or PI Point.\n *\n * @param {any} target - AF Path or Point name.\n * @returns - webid.\n *\n * @memberOf PiWebApiDatasource\n */\n getWebId(target: any) {\n const ds = this;\n const isAf = target.target.indexOf('\\\\') >= 0;\n const isAttribute = target.target.indexOf('|') >= 0;\n if (!isAf && target.target.indexOf('.') === -1) {\n return Promise.resolve([{ WebId: target.target, Name: target.display || target.target }]);\n }\n\n if (!isAf) {\n // pi point lookup\n return ds.piPointSearch(this.piserver.webid!, target.target).then((results) => {\n if (results === undefined || results.length === 0) {\n return [{ WebId: target.target, Name: target.display || target.target }];\n }\n return results;\n });\n } else if (isAf && isAttribute) {\n // af attribute lookup\n return ds.restGet('/attributes?path=\\\\\\\\' + target.target).then((results) => {\n if (results.data === undefined || results.status !== 200) {\n return [{ WebId: target.target, Name: target.display || target.target }];\n }\n // rewrite name if specified\n results.data.Name = target.display || results.data.Name;\n return [results.data];\n });\n } else {\n // af element lookup\n return ds.restGet('/elements?path=\\\\\\\\' + target.target).then((results) => {\n if (results.data === undefined || results.status !== 200) {\n return [{ WebId: target.target, Name: target.display || target.target }];\n }\n // rewrite name if specified\n results.data.Name = target.display || results.data.Name;\n return [results.data];\n });\n }\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { AnnotationsQueryCtrl } from './AnnotationsQueryCtrl';\nimport { PIWebAPIConfigEditor } from './ConfigEditor';\nimport { PIWebAPIQueryEditor } from './QueryEditor';\nimport { PiWebAPIDatasource } from './datasource';\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n PiWebAPIDatasource\n)\n .setConfigEditor(PIWebAPIConfigEditor)\n .setQueryEditor(PIWebAPIQueryEditor)\n .setAnnotationQueryCtrl(AnnotationsQueryCtrl);\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__0__","__WEBPACK_EXTERNAL_MODULE__1__","__WEBPACK_EXTERNAL_MODULE__2__","__WEBPACK_EXTERNAL_MODULE__3__","__WEBPACK_EXTERNAL_MODULE__5__","__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","AnnotationsQueryCtrl","$scope","this","annotation","ctrl","datasource","query","databases","templates","regex","attribute","showEndTime","getAssetServer","afserver","name","then","result","getDatabases","WebId","getEventFrames","webid","dbs","$apply","getEventFrameTemplates","database","FormField","LegacyForms","coerceOptions","options","jsonData","url","PIWebAPIConfigEditor","event","props","onOptionsChange","piserver","target","afdatabase","checked","pipoint","originalOptions","DataSourceHttpSettings","defaultUrl","dataSourceConfig","onChange","onMyOptionsChange","showAccessOptions","className","InlineField","label","labelWidth","InlineSwitch","onPiPointChange","inputWidth","onPIServerChange","placeholder","onAFServerChange","onAFDatabaseChange","PureComponent","QueryField","tooltip","children","InlineFormLabel","width","QueryRowTerminator","QueryInlineField","QueryEditorRow","QueryRawInlineField","QueryRawEditorRow","defaultQuery","attributes","segments","enable","summary","types","basis","interval","nodata","expression","interpolate","useLastValue","recordedValues","digitalStates","isPiPoint","QueryEditorModeSwitcher","isRaw","useState","isModalOpen","setModalOpen","useEffect","Button","icon","variant","type","onClick","ConfirmModal","isOpen","title","body","confirmText","dismissText","onConfirm","onDismiss","LABEL_WIDTH","MIN_ATTR_INPUT_WIDTH","REMOVE_LABEL","CustomLabelComponent","Icon","PIWebAPIQueryEditor","summaries","attributeSegment","summarySegment","calculationBasisSegment","noDataReplacementSegment","setState","item","index","state","slice","remove","checkPiPointSegments","checkAttributeSegments","length","push","expandable","piServer","segmentChangeValue","currentSegment","data","findQuery","path","getSegmentPathUpTo","Promise","resolve","metricFindQuery","assign","request","scopedVars","items","altSegments","map","text","webId","variables","templateSrv","getVariables","each","variable","selectableValue","unshift","err","error","message","attributeText","getSelectedPIServer","pointName","Path","forOwn","availableAttributes","val","segmentsArray","attributesArray","splitAttributes","split","splitElements","splice","_","getElementSegments","elements","summariesArray","cb","initialLoad","scopedVarsDone","force","metricsQuery","defaults","buildFromTarget","_segmentsArray","updateArray","e","checkAfServer","onRunQuery","rawQuery","elementPath","join","s","queryChange","onSegmentChange","bind","calcBasisValueChanged","calcNoDataValueChanged","onSummaryAction","onSummaryValueChanged","onAttributeAction","onAttributeChange","summaryTypes","calculationBasis","noDataReplacement","segment","isValueEmpty","stateCallback","filter","indexOf","part","attributeChangeValue","arr","reduce","startsWith","attributesResponse","validAttributes","substring","filteredAttributes","attrib","changedValue","replace","webID","forEach","parts","match","queryProps","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","textEditorChanged","SegmentAsync","Component","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","getAttributeSegmentsAF","maxNumber","parseInt","getNoDataSegments","getCalcBasisSegments","getSummarySegments","search","PiWebAPIDatasource","instanceSettings","Map","basicAuth","withCredentials","getTemplateSrv","backendSrv","getBackendSrv","piwebapiurl","toString","isProxy","test","access","all","getDataServer","getDatabase","annotationOptions","endTime","eventFrame","attributeDataItems","Name","RegExp","attributeData","attributeValue","Value","time","Date","EndTime","StartTime","getTime","targets","ds","tar","elementPathArray","att","refId","hide","webids","startTime","range","from","to","varsKeys","keys","v","isAllSelected","current","selected","attr","vv","allValue","uniq","flatten","getElementPath","Array","isArray","buildQueryParameters","t","getStream","targetResponses","flattened","tr","sort","b","toDataFrame","datasourceRequest","method","response","status","Error","categoryName","nameFilter","templateName","template","iconColor","toJSON","resourceUrl","Method","Resource","RequestTemplate","Parameters","ParentIds","restBatch","Content","valueData","annotations","Items","curry","eventFrameToAnnotation","ends","end","restGet","HasChildren","queryOptions","querydepth","JSON","parse","Math","max","min","metricQueryTransform","getAssetServers","server","db","getDatabaseElements","selectedFields","getElement","element","getElements","getAttributes","searchFullHierarchy","getDataServers","piPointSearch","reject","trim","isSummary","datapoints","piPointValue","noDataReplace","parsePiPointValue","grafanaDataPoint","previousValue","drop","num","Good","checkNumber","Number","Timestamp","noDataReplacementMode","content","noTemplate","api","getPath","innerResults","groups","groupBy","Type","parsePiPointValueData","number","isNaN","isFinite","newElementPathArray","elem","temp","concat","splitPath","splitStr","pop","foundElement","find","results","isInterpolated","intervalTime","timeRange","targetName","displayName","encodeURIComponent","internalStream","restPost","processResults","restGetWebId","webidresponse","maxDataPoints","getSummaryUrl","promises","datarsp","datarspa","getFinalUrl","targetResults","targetResult","headers","assetPath","cachedWebId","webidCache","set","batch","serverId","databaseId","InstanceType","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","isAf","isAttribute","DataSourceApi","plugin","DataSourcePlugin","setConfigEditor","setQueryEditor","setAnnotationQueryCtrl"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/plugin.json b/dist/plugin.json index 0e0667c..40170e2 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -33,7 +33,7 @@ ], "screenshots": [], "version": "3.1.0", - "updated": "2023-02-09" + "updated": "2023-02-28" }, "dependencies": { "grafanaDependency": ">=8.4.0", diff --git a/src/datasource.ts b/src/datasource.ts index 669c9c6..2ae5aea 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -805,7 +805,6 @@ export class PiWebAPIDatasource extends DataSourceApi