diff --git a/.config/.cprc.json b/.config/.cprc.json new file mode 100644 index 0000000..99f06ad --- /dev/null +++ b/.config/.cprc.json @@ -0,0 +1,3 @@ +{ + "version": "4.2.1" +} diff --git a/.config/.eslintrc b/.config/.eslintrc new file mode 100644 index 0000000..1486ed2 --- /dev/null +++ b/.config/.eslintrc @@ -0,0 +1,25 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config + */ +{ + "extends": ["@grafana/eslint-config"], + "root": true, + "rules": { + "react/prop-types": "off" + }, + "overrides": [ + { + "plugins": ["deprecation"], + "files": ["src/**/*.{ts,tsx}"], + "rules": { + "deprecation/deprecation": "warn" + }, + "parserOptions": { + "project": "./tsconfig.json" + } + } + ] +} diff --git a/.config/.prettierrc.js b/.config/.prettierrc.js new file mode 100644 index 0000000..bf506f5 --- /dev/null +++ b/.config/.prettierrc.js @@ -0,0 +1,16 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in .config/README.md + */ + +module.exports = { + endOfLine: 'auto', + printWidth: 120, + trailingComma: 'es5', + semi: true, + jsxSingleQuote: false, + singleQuote: true, + useTabs: false, + tabWidth: 2, +}; diff --git a/.config/Dockerfile b/.config/Dockerfile new file mode 100644 index 0000000..e0f1b2d --- /dev/null +++ b/.config/Dockerfile @@ -0,0 +1,16 @@ +ARG grafana_version=latest +ARG grafana_image=grafana-enterprise + +FROM grafana/${grafana_image}:${grafana_version} + +# Make it as simple as possible to access the grafana instance for development purposes +# Do NOT enable these settings in a public facing / production grafana instance +ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin" +ENV GF_AUTH_ANONYMOUS_ENABLED "true" +ENV GF_AUTH_BASIC_ENABLED "false" +# Set development mode so plugins can be loaded without the need to sign +ENV GF_DEFAULT_APP_MODE "development" + +# Inject livereload script into grafana index.html +USER root +RUN sed -i 's|||g' /usr/share/grafana/public/views/index.html diff --git a/.config/README.md b/.config/README.md new file mode 100644 index 0000000..a23b6d1 --- /dev/null +++ b/.config/README.md @@ -0,0 +1,164 @@ +# Default build configuration by Grafana + +**This is an auto-generated directory and is not intended to be changed! ⚠️** + +The `.config/` directory holds basic configuration for the different tools +that are used to develop, test and build the project. In order to make it updates easier we ask you to +not edit files in this folder to extend configuration. + +## How to extend the basic configs? + +Bear in mind that you are doing it at your own risk, and that extending any of the basic configuration can lead +to issues around working with the project. + +### Extending the ESLint config + +Edit the `.eslintrc` file in the project root in order to extend the ESLint configuration. + +**Example:** + +```json +{ + "extends": "./.config/.eslintrc", + "rules": { + "react/prop-types": "off" + } +} +``` + +--- + +### Extending the Prettier config + +Edit the `.prettierrc.js` file in the project root in order to extend the Prettier configuration. + +**Example:** + +```javascript +module.exports = { + // Prettier configuration provided by Grafana scaffolding + ...require('./.config/.prettierrc.js'), + + semi: false, +}; +``` + +--- + +### Extending the Jest config + +There are two configuration in the project root that belong to Jest: `jest-setup.js` and `jest.config.js`. + +**`jest-setup.js`:** A file that is run before each test file in the suite is executed. We are using it to +set up the Jest DOM for the testing library and to apply some polyfills. ([link to Jest docs](https://jestjs.io/docs/configuration#setupfilesafterenv-array)) + +**`jest.config.js`:** The main Jest configuration file that extends the Grafana recommended setup. ([link to Jest docs](https://jestjs.io/docs/configuration)) + +#### ESM errors with Jest + +A common issue with the current jest config involves importing an npm package that only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this, we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be, this can be extended in the following way: + +```javascript +process.env.TZ = 'UTC'; +const { grafanaESModules, nodeModulesToTransform } = require('./config/jest/utils'); + +module.exports = { + // Jest configuration provided by Grafana + ...require('./.config/jest.config'), + // Inform jest to only transform specific node_module packages. + transformIgnorePatterns: [nodeModulesToTransform([...grafanaESModules, 'packageName'])], +}; +``` + +--- + +### Extending the TypeScript config + +Edit the `tsconfig.json` file in the project root in order to extend the TypeScript configuration. + +**Example:** + +```json +{ + "extends": "./.config/tsconfig.json", + "compilerOptions": { + "preserveConstEnums": true + } +} +``` + +--- + +### Extending the Webpack config + +Follow these steps to extend the basic Webpack configuration that lives under `.config/`: + +#### 1. Create a new Webpack configuration file + +Create a new config file that is going to extend the basic one provided by Grafana. +It can live in the project root, e.g. `webpack.config.ts`. + +#### 2. Merge the basic config provided by Grafana and your custom setup + +We are going to use [`webpack-merge`](https://github.com/survivejs/webpack-merge) for this. + +```typescript +// webpack.config.ts +import type { Configuration } from 'webpack'; +import { merge } from 'webpack-merge'; +import grafanaConfig from './.config/webpack/webpack.config'; + +const config = async (env): Promise => { + const baseConfig = await grafanaConfig(env); + + return merge(baseConfig, { + // Add custom config here... + output: { + asyncChunks: true, + }, + }); +}; + +export default config; +``` + +#### 3. Update the `package.json` to use the new Webpack config + +We need to update the `scripts` in the `package.json` to use the extended Webpack configuration. + +**Update for `build`:** + +```diff +-"build": "webpack -c ./.config/webpack/webpack.config.ts --env production", ++"build": "webpack -c ./webpack.config.ts --env production", +``` + +**Update for `dev`:** + +```diff +-"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", ++"dev": "webpack -w -c ./webpack.config.ts --env development", +``` + +### Configure grafana image to use when running docker + +By default, `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behavior, simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`. + +**Example:** + +```yaml +version: '3.7' + +services: + grafana: + container_name: 'myorg-basic-app' + build: + context: ./.config + args: + grafana_version: ${GRAFANA_VERSION:-9.1.2} + grafana_image: ${GRAFANA_IMAGE:-grafana} +``` + +In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker-compose commands, which might be convenient in some scenarios. + +--- diff --git a/.config/jest-setup.js b/.config/jest-setup.js new file mode 100644 index 0000000..1b9fc2f --- /dev/null +++ b/.config/jest-setup.js @@ -0,0 +1,25 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config + */ + +import '@testing-library/jest-dom'; + +// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom +Object.defineProperty(global, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // deprecated + removeListener: jest.fn(), // deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), + })), +}); + +HTMLCanvasElement.prototype.getContext = () => {}; diff --git a/.config/jest.config.js b/.config/jest.config.js new file mode 100644 index 0000000..94489cb --- /dev/null +++ b/.config/jest.config.js @@ -0,0 +1,43 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config + */ + +const path = require('path'); +const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils'); + +module.exports = { + moduleNameMapper: { + '\\.(css|scss|sass)$': 'identity-obj-proxy', + 'react-inlinesvg': path.resolve(__dirname, 'jest', 'mocks', 'react-inlinesvg.tsx'), + }, + modulePaths: ['/src'], + setupFilesAfterEnv: ['/jest-setup.js'], + testEnvironment: 'jest-environment-jsdom', + testMatch: [ + '/src/**/__tests__/**/*.{js,jsx,ts,tsx}', + '/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}', + '/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}', + ], + transform: { + '^.+\\.(t|j)sx?$': [ + '@swc/jest', + { + sourceMaps: 'inline', + jsc: { + parser: { + syntax: 'typescript', + tsx: true, + decorators: false, + dynamicImport: true, + }, + }, + }, + ], + }, + // Jest will throw `Cannot use import statement outside module` if it tries to load an + // ES module without it being transformed first. ./config/README.md#esm-errors-with-jest + transformIgnorePatterns: [nodeModulesToTransform(grafanaESModules)], +}; diff --git a/.config/jest/mocks/react-inlinesvg.tsx b/.config/jest/mocks/react-inlinesvg.tsx new file mode 100644 index 0000000..d540f3a --- /dev/null +++ b/.config/jest/mocks/react-inlinesvg.tsx @@ -0,0 +1,25 @@ +// Due to the grafana/ui Icon component making fetch requests to +// `/public/img/icon/.svg` we need to mock react-inlinesvg to prevent +// the failed fetch requests from displaying errors in console. + +import React from 'react'; + +type Callback = (...args: any[]) => void; + +export interface StorageItem { + content: string; + queue: Callback[]; + status: string; +} + +export const cacheStore: { [key: string]: StorageItem } = Object.create(null); + +const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; + +const InlineSVG = ({ src }: { src: string }) => { + // testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) + const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); + return ; +}; + +export default InlineSVG; diff --git a/.config/jest/utils.js b/.config/jest/utils.js new file mode 100644 index 0000000..fdca0de --- /dev/null +++ b/.config/jest/utils.js @@ -0,0 +1,31 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in .config/README.md + */ + +/* + * This utility function is useful in combination with jest `transformIgnorePatterns` config + * to transform specific packages (e.g.ES modules) in a projects node_modules folder. + */ +const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNames.join('|')})\/.*)`; + +// Array of known nested grafana package dependencies that only bundle an ESM version +const grafanaESModules = [ + '.pnpm', // Support using pnpm symlinked packages + '@grafana/schema', + 'd3', + 'd3-color', + 'd3-force', + 'd3-interpolate', + 'd3-scale-chromatic', + 'ol', + 'react-colorful', + 'rxjs', + 'uuid', +]; + +module.exports = { + nodeModulesToTransform, + grafanaESModules, +}; diff --git a/.config/tsconfig.json b/.config/tsconfig.json new file mode 100644 index 0000000..207b28f --- /dev/null +++ b/.config/tsconfig.json @@ -0,0 +1,26 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-typescript-config + */ +{ + "compilerOptions": { + "alwaysStrict": true, + "declaration": false, + "rootDir": "../src", + "baseUrl": "../src", + "typeRoots": ["../node_modules/@types"], + "resolveJsonModule": true + }, + "ts-node": { + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "esModuleInterop": true + }, + "transpileOnly": true + }, + "include": ["../src", "./types"], + "extends": "@grafana/tsconfig" +} diff --git a/.config/types/custom.d.ts b/.config/types/custom.d.ts new file mode 100644 index 0000000..64e6eaa --- /dev/null +++ b/.config/types/custom.d.ts @@ -0,0 +1,37 @@ +// Image declarations +declare module '*.gif' { + const src: string; + export default src; +} + +declare module '*.jpg' { + const src: string; + export default src; +} + +declare module '*.jpeg' { + const src: string; + export default src; +} + +declare module '*.png' { + const src: string; + export default src; +} + +declare module '*.webp' { + const src: string; + export default src; +} + +declare module '*.svg' { + const content: string; + export default content; +} + +// Font declarations +declare module '*.woff'; +declare module '*.woff2'; +declare module '*.eot'; +declare module '*.ttf'; +declare module '*.otf'; diff --git a/.config/webpack/constants.ts b/.config/webpack/constants.ts new file mode 100644 index 0000000..071e4fd --- /dev/null +++ b/.config/webpack/constants.ts @@ -0,0 +1,2 @@ +export const SOURCE_DIR = 'src'; +export const DIST_DIR = 'dist'; diff --git a/.config/webpack/utils.ts b/.config/webpack/utils.ts new file mode 100644 index 0000000..07eea6e --- /dev/null +++ b/.config/webpack/utils.ts @@ -0,0 +1,58 @@ +import fs from 'fs'; +import process from 'process'; +import os from 'os'; +import path from 'path'; +import { glob } from 'glob'; +import { SOURCE_DIR } from './constants'; + +export function isWSL() { + if (process.platform !== 'linux') { + return false; + } + + if (os.release().toLowerCase().includes('microsoft')) { + return true; + } + + try { + return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft'); + } catch { + return false; + } +} + +export function getPackageJson() { + return require(path.resolve(process.cwd(), 'package.json')); +} + +export function getPluginJson() { + return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`)); +} + +export function hasReadme() { + return fs.existsSync(path.resolve(process.cwd(), SOURCE_DIR, 'README.md')); +} + +// Support bundling nested plugins by finding all plugin.json files in src directory +// then checking for a sibling module.[jt]sx? file. +export async function getEntries(): Promise> { + const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); + + const plugins = await Promise.all( + pluginsJson.map((pluginJson) => { + const folder = path.dirname(pluginJson); + return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); + }) + ); + + return plugins.reduce((result, modules) => { + return modules.reduce((result, module) => { + const pluginPath = path.dirname(module); + const pluginName = path.relative(process.cwd(), pluginPath).replace(/src\/?/i, ''); + const entryName = pluginName === '' ? 'module' : `${pluginName}/module`; + + result[entryName] = module; + return result; + }, result); + }, {}); +} diff --git a/.config/webpack/webpack.config.ts b/.config/webpack/webpack.config.ts new file mode 100644 index 0000000..2865de0 --- /dev/null +++ b/.config/webpack/webpack.config.ts @@ -0,0 +1,216 @@ +/* + * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ + * + * In order to extend the configuration follow the steps in + * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-webpack-config + */ + +import CopyWebpackPlugin from 'copy-webpack-plugin'; +import ESLintPlugin from 'eslint-webpack-plugin'; +import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; +import LiveReloadPlugin from 'webpack-livereload-plugin'; +import path from 'path'; +import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; +import { Configuration } from 'webpack'; + +import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; +import { SOURCE_DIR, DIST_DIR } from './constants'; + +const pluginJson = getPluginJson(); + +const config = async (env): Promise => { + const baseConfig: Configuration = { + cache: { + type: 'filesystem', + buildDependencies: { + config: [__filename], + }, + }, + + context: path.join(process.cwd(), SOURCE_DIR), + + devtool: env.production ? 'source-map' : 'eval-source-map', + + entry: await getEntries(), + + externals: [ + 'lodash', + 'jquery', + 'moment', + 'slate', + 'emotion', + '@emotion/react', + '@emotion/css', + 'prismjs', + 'slate-plain-serializer', + '@grafana/slate-react', + 'react', + 'react-dom', + 'react-redux', + 'redux', + 'rxjs', + 'react-router', + 'react-router-dom', + 'd3', + 'angular', + '@grafana/ui', + '@grafana/runtime', + '@grafana/data', + + // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix + ({ request }, callback) => { + const prefix = 'grafana/'; + const hasPrefix = (request) => request.indexOf(prefix) === 0; + const stripPrefix = (request) => request.substr(prefix.length); + + if (hasPrefix(request)) { + return callback(undefined, stripPrefix(request)); + } + + callback(); + }, + ], + + mode: env.production ? 'production' : 'development', + + module: { + rules: [ + { + exclude: /(node_modules)/, + test: /\.[tj]sx?$/, + use: { + loader: 'swc-loader', + options: { + jsc: { + baseUrl: path.resolve(__dirname, 'src'), + target: 'es2015', + loose: false, + parser: { + syntax: 'typescript', + tsx: true, + decorators: false, + dynamicImport: true, + }, + }, + }, + }, + }, + { + test: /\.css$/, + use: ['style-loader', 'css-loader'], + }, + { + test: /\.s[ac]ss$/, + use: ['style-loader', 'css-loader', 'sass-loader'], + }, + { + test: /\.(png|jpe?g|gif|svg)$/, + type: 'asset/resource', + generator: { + // Keep publicPath relative for host.com/grafana/ deployments + publicPath: `public/plugins/${pluginJson.id}/img/`, + outputPath: 'img/', + filename: Boolean(env.production) ? '[hash][ext]' : '[file]', + }, + }, + { + test: /\.(woff|woff2|eot|ttf|otf)(\?v=\d+\.\d+\.\d+)?$/, + type: 'asset/resource', + generator: { + // Keep publicPath relative for host.com/grafana/ deployments + publicPath: `public/plugins/${pluginJson.id}/fonts/`, + outputPath: 'fonts/', + filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', + }, + }, + ], + }, + + output: { + clean: { + keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`), + }, + filename: '[name].js', + library: { + type: 'amd', + }, + path: path.resolve(process.cwd(), DIST_DIR), + publicPath: `public/plugins/${pluginJson.id}/`, + uniqueName: pluginJson.id, + }, + + plugins: [ + new CopyWebpackPlugin({ + patterns: [ + // If src/README.md exists use it; otherwise the root README + // To `compiler.options.output` + { from: hasReadme() ? 'README.md' : '../README.md', to: '.', force: true }, + { from: 'plugin.json', to: '.' }, + { from: '../LICENSE', to: '.' }, + { from: '../CHANGELOG.md', to: '.', force: true }, + { from: '**/*.json', to: '.' }, // TODO + { from: '**/*.svg', to: '.', noErrorOnMissing: true }, // Optional + { from: '**/*.png', to: '.', noErrorOnMissing: true }, // Optional + { from: '**/*.html', to: '.', noErrorOnMissing: true }, // Optional + { from: 'img/**/*', to: '.', noErrorOnMissing: true }, // Optional + { from: 'libs/**/*', to: '.', noErrorOnMissing: true }, // Optional + { from: 'static/**/*', to: '.', noErrorOnMissing: true }, // Optional + { from: '**/query_help.md', to: '.', noErrorOnMissing: true }, // Optional + ], + }), + // Replace certain template-variables in the README and plugin.json + new ReplaceInFileWebpackPlugin([ + { + dir: DIST_DIR, + files: ['plugin.json', 'README.md'], + rules: [ + { + search: /\%VERSION\%/g, + replace: getPackageJson().version, + }, + { + search: /\%TODAY\%/g, + replace: new Date().toISOString().substring(0, 10), + }, + { + search: /\%PLUGIN_ID\%/g, + replace: pluginJson.id, + }, + ], + }, + ]), + ...(env.development ? [ + new LiveReloadPlugin(), + new ForkTsCheckerWebpackPlugin({ + async: Boolean(env.development), + issue: { + include: [{ file: '**/*.{ts,tsx}' }], + }, + typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') }, + }), + new ESLintPlugin({ + extensions: ['.ts', '.tsx'], + lintDirtyModulesOnly: Boolean(env.development), // don't lint on start, only lint changed files + }), + ] : []), + ], + + resolve: { + extensions: ['.js', '.jsx', '.ts', '.tsx'], + // handle resolving "rootDir" paths + modules: [path.resolve(process.cwd(), 'src'), 'node_modules'], + unsafeCache: true, + }, + }; + + if (isWSL()) { + baseConfig.watchOptions = { + poll: 3000, + ignored: /node_modules/, + }; + } + + return baseConfig; +}; + +export default config; diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..476a147 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "./.config/.eslintrc" +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e0576d..2f6b3d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,19 +11,19 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Node.js environment uses: actions/setup-node@v2.1.2 with: - node-version: "14.x" + node-version: "20.x" - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - name: Cache yarn cache - uses: actions/cache@v2 + uses: actions/cache@v4 id: cache-yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} @@ -33,7 +33,7 @@ jobs: - name: Cache node_modules id: cache-node-modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} @@ -56,20 +56,20 @@ jobs: - name: Setup Go environment if: steps.check-for-backend.outputs.has-backend == 'true' - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: - go-version: "1.15" + go-version: "1.20" - name: Test backend if: steps.check-for-backend.outputs.has-backend == 'true' - uses: magefile/mage-action@v1 + uses: magefile/mage-action@v3 with: version: latest args: coverage - name: Build backend if: steps.check-for-backend.outputs.has-backend == 'true' - uses: magefile/mage-action@v1 + uses: magefile/mage-action@v3 with: version: latest args: buildAll diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3115aec..58d4e7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,18 +12,18 @@ jobs: GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Node.js environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '20' cache: 'yarn' - name: Setup Go environment - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: '1.19' + go-version: '1.20' - name: Install dependencies run: yarn install --immutable --prefer-offline @@ -41,14 +41,14 @@ jobs: - name: Test backend if: steps.check-for-backend.outputs.has-backend == 'true' - uses: magefile/mage-action@v1 + uses: magefile/mage-action@v3 with: version: latest args: coverage - name: Build backend if: steps.check-for-backend.outputs.has-backend == 'true' - uses: magefile/mage-action@v1 + uses: magefile/mage-action@v3 with: version: latest args: buildAll @@ -108,7 +108,7 @@ jobs: plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }} - name: Create Github release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: draft: true generate_release_notes: true diff --git a/.gitignore b/.gitignore index e26b968..289a2a0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* -node_modules/ - # Runtime data pids *.pid @@ -19,12 +17,16 @@ lib-cov # Coverage directory used by tools like istanbul coverage -# Compiled binary addons (https://nodejs.org/api/addons.html) -dist/ -artifacts/ -work/ -ci/ -e2e-results/ +node_modules +dist +vendor +.tscache +coverage +.idea +.vscode + +# OS generated files +.DS_Store # Editor .idea diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/.prettierrc.js b/.prettierrc.js index e404661..6c79e24 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,4 +1,4 @@ module.exports = { - ...require("./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json"), - "tabWidth": 2, + // Prettier configuration provided by Grafana scaffolding + ...require('./.config/.prettierrc.js'), }; diff --git a/CHANGELOG.md b/CHANGELOG.md index 1542066..adca2ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,3 +38,8 @@ - Fixed issue that only odd attributes were been shown - Fixed issue when fetching afServerWebId + +## 5.0.0-beta + +- Migrated backend to Go language (still beta) +- Changed the query editor layout diff --git a/Magefile.go b/Magefile.go new file mode 100644 index 0000000..4710a8a --- /dev/null +++ b/Magefile.go @@ -0,0 +1,12 @@ +//go:build mage +// +build mage + +package main + +import ( + // mage:import + build "github.com/grafana/grafana-plugin-sdk-go/build" +) + +// Default configures the default target. +var Default = build.BuildAll diff --git a/dist/module.js b/dist/module.js index fcc45bc..8067d0e 100644 --- a/dist/module.js +++ b/dist/module.js @@ -1,3 +1,2 @@ -/*! For license information please see module.js.LICENSE.txt */ -define(["@grafana/data","@grafana/runtime","@grafana/ui","lodash","react","rxjs"],((e,t,n,a,r,i)=>(()=>{"use strict";var l=[e=>{e.exports=r},e=>{e.exports=n},t=>{t.exports=e},e=>{e.exports=a},,e=>{e.exports=i},e=>{e.exports=t}],o={};function u(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return l[e](n,n.exports,u),n.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{u.r(s),u.d(s,{plugin:()=>Ae});var e,t,n=u(2),a=u(0),r=u.n(a),i=u(1);function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,a=new Array(t);n0&&t.state.segments[0].value?t.state.segments[0].value.webId:void 0};if(!o.isPiPoint){var m,p,f;if(null!==(m=l.afserver)&&void 0!==m&&m.name&&0===e)return Promise.resolve([{label:l.afserver.name,value:{value:l.afserver.name,expandable:!0}}]);if(null!==(p=l.afserver)&&void 0!==p&&p.name&&null!==(f=l.afdatabase)&&void 0!==f&&f.name&&1===e)return Promise.resolve([{label:l.afdatabase.name,value:{value:l.afdatabase.name,expandable:!0}}])}return l.metricFindQuery(c,Object.assign(null!==(a=null==u||null===(r=u.request)||void 0===r?void 0:r.scopedVars)&&void 0!==a?a:{},{isPiPoint:o.isPiPoint})).then((function(e){var t=(0,w.map)(e,(function(e){return{label:e.text,value:{webId:e.WebId,value:e.text,expandable:!o.isPiPoint&&e.expandable}}}));if(0===t.length)return t;var n=l.templateSrv.getVariables();return(0,w.each)(n,(function(e){var n={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!o.isPiPoint}};t.unshift(n)})),t.unshift({label:J,value:{value:J}}),t})).catch((function(e){return s.error=e.message||"Failed to issue metric query",[]}))})),Q(G(t),"getAttributeSegmentsPI",(function(e){var n,a,r=t.props,i=r.datasource,l=r.query,o=r.data,u=G(t),s={path:"",webId:t.getSelectedPIServer(),pointName:(null!=e?e:"")+"*",type:"pipoint"},c=[];return c.push({label:J,value:{value:J}}),i.metricFindQuery(s,Object.assign(null!==(n=null==o||null===(a=o.request)||void 0===a?void 0:a.scopedVars)&&void 0!==n?n:{},{isPiPoint:l.isPiPoint})).then((function(t){c=(0,w.map)(t,(function(e){return{path:e.Path,label:e.text,value:{value:e.text,expandable:!1}}})),e&&e.length>0&&c.unshift({label:e,value:{value:e,expandable:!1}});var n=i.templateSrv.getVariables();return(0,w.each)(n,(function(e){var t={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!l.isPiPoint}};c.unshift(t)})),c})).catch((function(e){return u.error=e.message||"Failed to issue metric query",c}))})),Q(G(t),"getAttributeSegmentsAF",(function(e){var n=G(t),a=[];return a.push({label:J,value:{value:J}}),(0,w.forOwn)(n.availableAttributes,(function(e,t){var n={label:t,value:{value:t,expandable:!0}};a.push(n)})),a})),Q(G(t),"buildFromTarget",(function(e,n,a){var r=e.target.split(";"),i=r.length>0?r[0].split("\\"):[];return i.length>1||1===i.length&&""!==i[0]?(r.splice(0,1),(0,w.each)(i,(function(e,t){n.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,w.each)(r,(function(e,t){""!==e&&a.push({label:e,value:{value:e,expandable:!1}})})),t.getElementSegments(i.length+1,n).then((function(e){return e.length>0&&n.push({label:"Select Element",value:{value:"-Select Element-"}}),n}))):Promise.resolve(n)})),Q(G(t),"checkAfServer",(function(){var e,n,a=t.props.datasource,r=[];null!==(e=a.afserver)&&void 0!==e&&e.name?(r.push({label:a.afserver.name,value:{value:a.afserver.name,expandable:!0}}),null!==(n=a.afdatabase)&&void 0!==n&&n.name&&r.push({label:a.afdatabase.name,value:{value:a.afdatabase.name,expandable:!0}}),r.push({label:"Select Element",value:{value:"-Select Element-"}})):r.push({label:""});return r})),Q(G(t),"updateArray",(function(e,n,a,r,i){t.setState({segments:e,attributes:n,summaries:a,isPiPoint:r},(function(){r||t.checkAttributeSegments(n,t.state.segments).then((function(){i&&i()}))}))})),Q(G(t),"scopedVarsDone",!1),Q(G(t),"componentDidMount",(function(){t.initialLoad(!1)})),Q(G(t),"componentDidUpdate",(function(){var e,n,a,r=t.props.query;"Done"===(null===(e=t.props.data)||void 0===e?void 0:e.state)&&null!==(n=t.props.data)&&void 0!==n&&null!==(a=n.request)&&void 0!==a&&a.scopedVars&&!t.scopedVarsDone&&(t.scopedVarsDone=!0,t.initialLoad(!r.isPiPoint))})),Q(G(t),"initialLoad",(function(e){var n,a,r,i=t.props.query,l=(0,w.defaults)(i,j),o=l.segments,u=l.attributes,s=l.summary,c=l.isPiPoint,m=e?[]:null!==(n=null==o?void 0:o.slice(0))&&void 0!==n?n:[],p=e?[]:null!==(a=null==u?void 0:u.slice(0))&&void 0!==a?a:[],f=null!==(r=null==s?void 0:s.types)&&void 0!==r?r:[];if(c||0!==m.length)c&&m.length>0&&(t.piServer=m);else{if(i.target&&i.target.length>0&&";"!==i.target)return p=[],void t.buildFromTarget(i,m,p).then((function(e){t.updateArray(e,p,f,!1)})).catch((function(e){}));m=t.checkAfServer()}t.updateArray(m,p,f,!!c,(function(){t.onChange(i)}))})),Q(G(t),"onChange",(function(e){var n,a,r=t.props,i=r.onChange,l=r.onRunQuery;(e.summary.types=t.state.summaries,e.rawQuery)?e.target=null!==(n=e.query)&&void 0!==n?n:"":(e.elementPath=t.getSegmentPathUpTo(t.state.segments,t.state.segments.length),e.target=e.elementPath+";"+(0,w.join)(null===(a=e.attributes)||void 0===a?void 0:a.map((function(e){var t;return null===(t=e.value)||void 0===t?void 0:t.value})),";"));i(e),e.target&&e.target.length>0&&l()})),Q(G(t),"stateCallback",(function(){var e=t.props.query;t.onChange(e)})),Q(G(t),"onIsPiPointChange",(function(e){var n=t.props.query,a=!n.isPiPoint;t.setState({segments:a?[{label:""}]:t.checkAfServer(),attributes:[],isPiPoint:a},(function(){t.onChange(R({},n,{expression:"",attributes:t.state.attributes,segments:t.state.segments,isPiPoint:a}))}))})),t.onSegmentChange=t.onSegmentChange.bind(G(t)),t.calcBasisValueChanged=t.calcBasisValueChanged.bind(G(t)),t.calcNoDataValueChanged=t.calcNoDataValueChanged.bind(G(t)),t.onSummaryAction=t.onSummaryAction.bind(G(t)),t.onSummaryValueChanged=t.onSummaryValueChanged.bind(G(t)),t.onAttributeAction=t.onAttributeAction.bind(G(t)),t.onAttributeChange=t.onAttributeChange.bind(G(t)),t.summaryTypes=["Total","Average","Minimum","Maximum","Range","StdDev","PopulationStdDev","Count","PercentGood","All","AllForNonNumeric"],t.calculationBasis=["TimeWeighted","EventWeighted","TimeWeightedContinuous","TimeWeightedDiscrete","EventWeightedExcludeMostRecentEvent","EventWeightedExcludeEarliestEvent","EventWeightedIncludeBothEnds"],t.noDataReplacement=["Null","Drop","Previous","0","Keep"],t}return t=o,(n=[{key:"isValueEmpty",value:function(e){return!e||!e.value||!e.value.length||e.value===J}},{key:"calcBasisValueChanged",value:function(e){var t,n=this.props.query,a=n.summary;a.basis=null===(t=e.value)||void 0===t?void 0:t.value,this.onChange(R({},n,{summary:a}))}},{key:"getCalcBasisSegments",value:function(){return(0,w.map)(this.calculationBasis,(function(e){return{label:e,value:{value:e,expandable:!0}}}))}},{key:"calcNoDataValueChanged",value:function(e){var t,n=this.props.query,a=n.summary;a.nodata=null===(t=e.value)||void 0===t?void 0:t.value,this.onChange(R({},n,{summary:a}))}},{key:"getNoDataSegments",value:function(){return(0,w.map)(this.noDataReplacement,(function(e){return{label:e,value:{value:e,expandable:!0}}}))}},{key:"onSummaryValueChanged",value:function(e,t){var n=this.state.summaries.slice(0);n[t]=e,this.isValueEmpty(e.value)&&n.splice(t,1),this.setState({summaries:n},this.stateCallback)}},{key:"getSummarySegments",value:function(){var e=this,t=(0,w.filter)(this.summaryTypes,(function(t){return-1===e.state.summaries.map((function(e){var t;return null===(t=e.value)||void 0===t?void 0:t.value})).indexOf(t)})),n=(0,w.map)(t,(function(e){return{label:e,value:{value:e,expandable:!0}}}));return n.unshift({label:J,value:{value:J}}),n}},{key:"removeSummary",value:function(e){var t=(0,w.filter)(this.state.summaries,(function(t){return t!==e}));this.setState({summaries:t})}},{key:"onSummaryAction",value:function(e){var t=this.state.summaries.slice(0);if(!this.isValueEmpty(e.value)){var n,a={label:e.label,value:{value:null===(n=e.value)||void 0===n?void 0:n.value,expandable:!0}};t.push(a)}this.setState({summarySegment:{},summaries:t},this.stateCallback)}},{key:"removeAttribute",value:function(e){var t=(0,w.filter)(this.state.attributes,(function(t){return t!==e}));this.attributeChangeValue(t)}},{key:"onAttributeAction",value:function(e){var t=this.props.query,n=this.state.attributes.slice(0);if(!this.isValueEmpty(e.value)){var a,r={label:e.label,value:{value:null===(a=e.value)||void 0===a?void 0:a.value,expandable:!t.isPiPoint}};n.push(r)}this.attributeChangeValue(n)}},{key:"getSegmentPathUpTo",value:function(e,t){var n=e.slice(0,t);return(0,w.reduce)(n,(function(e,t){var n;return t.value?null!==(n=t.value.value)&&void 0!==n&&n.startsWith("-Select")?e:e?e+"\\"+t.value.value:t.value.value:""}),"")}},{key:"checkAttributeSegments",value:function(e,t){var n,a,r=this,i=this.props,l=i.datasource,o=i.data,u=this,s={path:this.getSegmentPathUpTo(t.slice(0),t.length),type:"attributes"};return l.metricFindQuery(s,Object.assign(null!==(n=null==o||null===(a=o.request)||void 0===a?void 0:a.scopedVars)&&void 0!==n?n:{},{isPiPoint:!1})).then((function(t){var n={};(0,w.each)(t,(function(e){n[e.Path.substring(e.Path.indexOf("|")+1)]=e.WebId}));var a=(0,w.filter)(e,(function(e){var t,a=l.templateSrv.replace(null===(t=e.value)||void 0===t?void 0:t.value);return void 0!==n[a]}));u.availableAttributes=n,r.attributeChangeValue(a)})).catch((function(t){u.error=t.message||"Failed to issue metric query",r.attributeChangeValue(e)}))}},{key:"checkPiPointSegments",value:function(e,t){var n,a,r=this.props,i=r.datasource,l=r.data,o=this,u={path:e.path,webId:o.getSelectedPIServer(),pointName:e.label,type:"pipoint"};return i.metricFindQuery(u,Object.assign(null!==(n=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==n?n:{},{isPiPoint:!0})).then((function(){o.attributeChangeValue(t)})).catch((function(e){o.error=e.message||"Failed to issue metric query",o.attributeChangeValue([])}))}},{key:"getSelectedPIServer",value:function(){var e,t=this,n="";return this.piServer.forEach((function(e){var a=t.props.query.target.split(";");a.length>=2&&a[0]===e.text&&(n=e.WebId)})),this.piServer.length>0?null===(e=this.piServer[0].value)||void 0===e?void 0:e.webId:n}},{key:"textEditorChanged",value:function(){var e=this,t=this.props,n=t.query,a=t.onChange,r=n.target.split(";"),i=r.length>0?r[0].split("\\"):[],l=[],o=[];i.length>1||1===i.length&&""!==i[0]?(r.splice(0,1),(0,w.each)(i,(function(e,t){l.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,w.each)(r,(function(e,t){""!==e&&o.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(i.length+1,l).then((function(e){e.length>0&&l.push({label:"Select Element",value:{value:"-Select Element-"}})})).then((function(){e.updateArray(l,o,e.state.summaries,n.isPiPoint,(function(){a(R({},n,{query:void 0,rawQuery:!1}))}))}))):(l=this.checkAfServer(),this.updateArray(l,this.state.attributes,this.state.summaries,n.isPiPoint,(function(){e.onChange(R({},n,{query:void 0,rawQuery:!1,attributes:e.state.attributes,segments:e.state.segments}))})))}},{key:"render",value:function(){var e=this,t=this.props,n=t.query,a=t.onChange,l=t.onRunQuery,o=(0,w.defaults)(n,j),u=o.useLastValue,s=o.useUnit,c=o.interpolate,m=o.query,p=o.rawQuery,f=o.digitalStates,d=o.recordedValues,h=o.expression,v=o.isPiPoint,g=o.summary,b=o.display,y=o.regex;return r().createElement(r().Fragment,null,this.props.datasource.piPointConfig&&r().createElement(i.InlineField,{label:"Is Pi Point?",labelWidth:H},r().createElement(i.InlineSwitch,{value:v,onChange:this.onIsPiPointChange})),!!p&&r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:"Raw Query",labelWidth:H,grow:!0},r().createElement(i.Input,{onBlur:this.stateCallback,value:m,onChange:function(e){return a(R({},o,{query:e.target.value}))},placeholder:"enter query"})),r().createElement(W,{isRaw:!0,onChange:function(t){return e.textEditorChanged()}})),!p&&r().createElement(r().Fragment,null,r().createElement("div",{className:"gf-form-inline"},r().createElement(F,{label:v?"PI Server":"AF Elements",tooltip:v?"Select PI server.":"Select AF Element."},this.state.segments.map((function(t,n){return r().createElement(i.SegmentAsync,{key:"element-"+n,Component:r().createElement(X,{value:t.value,label:t.label}),onChange:function(t){return e.onSegmentChange(t,n)},loadOptions:function(t){return e.getElementSegments(n)},allowCustomValue:!0,inputMinWidth:200})})),k||(k=r().createElement(x,null)),!v&&r().createElement(W,{isRaw:!1,onChange:function(e){a(R({},o,{query:o.target,rawQuery:e}))}}))),r().createElement(O,{label:v?"Pi Points":"Attributes"},this.state.attributes.map((function(t,n){return v?r().createElement(i.SegmentAsync,{key:"attributes-"+n,Component:r().createElement(X,{value:t.value,label:t.label}),disabled:0===e.piServer.length,onChange:function(t){return e.onPiPointChange(t,n)},loadOptions:e.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:$}):r().createElement(i.Segment,{key:"attributes-"+n,Component:r().createElement(X,{value:t.value,label:t.label}),disabled:e.state.segments.length<=2,onChange:function(t){return e.onAttributeChange(t,n)},options:e.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:$})})),v&&r().createElement(i.SegmentAsync,{Component:r().createElement(X,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:0===this.piServer.length,onChange:this.onAttributeAction,loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:$}),!v&&r().createElement(i.Segment,{Component:r().createElement(X,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:this.state.segments.length<=2,onChange:this.onAttributeAction,options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:$}))),r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:"Use Last Value",tooltip:"Fetch only last value from time range",labelWidth:H},r().createElement(i.InlineSwitch,{value:u.enable,onChange:function(){return e.onChange(R({},o,{useLastValue:R({},u,{enable:!u.enable})}))}})),this.props.datasource.useUnitConfig&&r().createElement(i.InlineField,{label:"Use unit from datapoints",tooltip:"Use unit in label from PI tag or PI AF attribute",labelWidth:H},r().createElement(i.InlineSwitch,{value:s.enable,onChange:function(){return e.onChange(R({},o,{useUnit:R({},s,{enable:!s.enable})}))}}))),r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:"Calculation",labelWidth:H,tooltip:"Modify all attributes by an equation. Use '.' for current item. Leave Attributes empty if you wish to perform element based calculations."},r().createElement(i.Input,{onBlur:l,value:h,onChange:function(e){return a(R({},o,{expression:e.target.value}))},placeholder:"'.'*2"}))),!u.enable&&r().createElement(r().Fragment,null,r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:"Max Recorded Values",labelWidth:H,tooltip:"Maximum number of recorded value to retrive from the data archive, without using interpolation."},r().createElement(i.Input,{onBlur:l,value:d.maxNumber,onChange:function(e){return a(R({},o,{recordedValues:R({},d,{maxNumber:parseInt(e.target.value,10)})}))},type:"number",placeholder:"1000"})),r().createElement(i.InlineField,{label:"Recorded Values",labelWidth:H},r().createElement(i.InlineSwitch,{value:d.enable,onChange:function(){return e.onChange(R({},o,{recordedValues:R({},d,{enable:!d.enable})}))}})),r().createElement(i.InlineField,{label:"Digital States",labelWidth:H},r().createElement(i.InlineSwitch,{value:f.enable,onChange:function(){return e.onChange(R({},o,{digitalStates:R({},f,{enable:!f.enable})}))}}))),r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:h?"Interval Period":"Interpolate Period",labelWidth:H,tooltip:"Override time between sampling, e.g. '30s'. Defaults to timespan/chart width."},r().createElement(i.Input,{onBlur:l,value:c.interval,onChange:function(e){return a(R({},o,{interpolate:R({},c,{interval:e.target.value})}))},placeholder:"30s"})),r().createElement(i.InlineField,{label:h?"Interval Values":"Interpolate",labelWidth:H},r().createElement(i.InlineSwitch,{value:c.enable,onChange:function(){return e.onChange(R({},o,{interpolate:R({},c,{enable:!c.enable})}))}})),r().createElement(i.InlineField,{label:"Replace Bad Data",labelWidth:H,tooltip:"Replacement for bad quality values."},r().createElement(i.Segment,{Component:r().createElement(X,{value:{value:g.nodata},label:g.nodata}),onChange:this.calcNoDataValueChanged,options:this.getNoDataSegments(),allowCustomValue:!0}))),r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:"Summary Period",labelWidth:H,tooltip:"Define the summary period, e.g. '30s'."},r().createElement(i.Input,{onBlur:l,value:g.interval,onChange:function(e){return a(R({},o,{summary:R({},g,{interval:e.target.value})}))},placeholder:"30s"})),r().createElement(i.InlineField,{label:"Basis",labelWidth:H,tooltip:"Defines the possible calculation options when performing summary calculations over time-series data."},r().createElement(i.Segment,{Component:r().createElement(X,{value:{value:g.basis},label:g.basis}),onChange:this.calcBasisValueChanged,options:this.getCalcBasisSegments(),allowCustomValue:!0})),r().createElement(i.InlineField,{label:"Summaries",labelWidth:H,tooltip:"PI Web API summary options."},r().createElement(i.InlineFieldRow,null,this.state.summaries.map((function(t,n){return r().createElement(i.Segment,{key:"summaries-"+n,Component:r().createElement(X,{value:t.value,label:t.label}),onChange:function(t){return e.onSummaryValueChanged(t,n)},options:e.getSummarySegments(),allowCustomValue:!0})})),r().createElement(i.Segment,{Component:r().createElement(X,{value:this.state.summarySegment.value,label:this.state.summarySegment.label}),onChange:this.onSummaryAction,options:this.getSummarySegments(),allowCustomValue:!0}))))),r().createElement(i.InlineFieldRow,null,r().createElement(i.InlineField,{label:"Display Name",labelWidth:H,tooltip:"If single attribute, modify display name. Otherwise use regex to modify display name."},r().createElement(i.Input,{onBlur:l,value:b,onChange:function(e){return a(R({},o,{display:e.target.value}))},placeholder:"Display"})),r().createElement(i.InlineField,{label:"Enable Regex Replace",labelWidth:H},r().createElement(i.InlineSwitch,{value:y.enable,onChange:function(){e.onChange(R({},o,{regex:R({},y,{enable:!y.enable})}))}})),r().createElement(i.InlineField,{label:"Search",labelWidth:16},r().createElement(i.Input,{onBlur:l,value:y.search,onChange:function(e){return a(R({},o,{regex:R({},y,{search:e.target.value})}))},placeholder:"(.*)"})),r().createElement(i.InlineField,{label:"Replace",labelWidth:16},r().createElement(i.Input,{onBlur:l,value:y.replace,onChange:function(e){return a(R({},o,{regex:R({},y,{replace:e.target.value})}))},placeholder:"$1"}))))}}])&&q(t.prototype,n),a&&q(t,a),Object.defineProperty(t,"prototype",{writable:!1}),o}(a.PureComponent),z=u(5),K=u(6);function Z(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ee(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,r=function(){};return{s:r,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){o=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(o)throw i}}}}function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n=0})))||void 0===n?void 0:n.variable;return r?r+"|"+a:a}function oe(e,t,n){return e?n.replace(/'\.'/g,"'".concat(t.Name,"'")):n}function ue(){return ue=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,a=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){o=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(o)throw i}}}}function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n=0;--r){var i=this.tryEntries[r],l=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var o=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(o&&u){if(this.prev=0;--a){var r=this.tryEntries[a];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var r=a.arg;S(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:I(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function be(e,t,n,a,r,i,l){try{var o=e[i](l),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(a,r)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:(0,K.getTemplateSrv)(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,K.getBackendSrv)();return ye(this,u),xe(Ie(n=o.call(this,e)),"piserver",void 0),xe(Ie(n),"afserver",void 0),xe(Ie(n),"afdatabase",void 0),xe(Ie(n),"piPointConfig",void 0),xe(Ie(n),"newFormatConfig",void 0),xe(Ie(n),"useUnitConfig",void 0),xe(Ie(n),"url",void 0),xe(Ie(n),"name",void 0),xe(Ie(n),"isProxy",!1),xe(Ie(n),"piwebapiurl",void 0),xe(Ie(n),"webidCache",new Map),xe(Ie(n),"error",void 0),n.templateSrv=a,n.backendSrv=r,n.url=e.url,n.name=e.name,n.piwebapiurl=null===(t=e.jsonData.url)||void 0===t?void 0:t.toString(),n.isProxy=/^http(s)?:\/\//.test(n.url)||"proxy"===e.jsonData.access,n.piserver={name:(e.jsonData||{}).piserver,webid:void 0},n.afserver={name:(e.jsonData||{}).afserver,webid:void 0},n.afdatabase={name:(e.jsonData||{}).afdatabase,webid:void 0},n.piPointConfig=e.jsonData.pipoint||!1,n.newFormatConfig=e.jsonData.newFormat||!1,n.useUnitConfig=e.jsonData.useUnit||!1,n.annotations={QueryEditor:pe,prepareQuery:function(e){return e.target&&(e.target.isAnnotation=!0),e.target},processEvents:function(e,t){return(0,z.of)(n.eventFrameToAnnotation(e,t))}},Promise.all([n.getDataServer(n.piserver.name).then((function(e){return n.piserver.webid=e.WebId})),n.getAssetServer(n.afserver.name).then((function(e){return n.afserver.webid=e.WebId})),n.getDatabase(n.afserver.name&&n.afdatabase.name?n.afserver.name+"\\"+n.afdatabase.name:void 0).then((function(e){return n.afdatabase.webid=e.WebId}))]),n}return t=u,a=[{key:"query",value:(i=ge().mark((function e(t){var n;return ge().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==t.targets.length||!t.targets[0].isAnnotation){e.next=2;break}return e.abrupt("return",this.processAnnotationQuery(t));case 2:if(!((n=this.buildQueryParameters(t)).targets.length<=0)){e.next=7;break}return e.abrupt("return",Promise.resolve({data:[]}));case 7:return e.abrupt("return",Promise.all(this.getStream(n)).then((function(e){var t=[];return(0,w.each)(e,(function(e){(0,w.each)(e,(function(e){return t.push(e)}))})),0===(t=t.filter((function(e){return e.datapoints.length>0}))).length?{data:[]}:{data:t.sort((function(e,t){return+(e.target>t.target)||+(e.target===t.target)-1})).map((function(e){return te(e)}))}})));case 8:case"end":return e.stop()}}),e,this)})),l=function(){var e=this,t=arguments;return new Promise((function(n,a){var r=i.apply(e,t);function l(e){be(r,n,a,l,o,"next",e)}function o(e){be(r,n,a,l,o,"throw",e)}l(void 0)}))},function(e){return l.apply(this,arguments)})},{key:"testDatasource",value:function(){return this.backendSrv.datasourceRequest({url:this.url+"/",method:"GET"}).then((function(e){if(e.status<300)return{status:"success",message:"Data source is working",title:"Success"};throw new Error("Failed")}))}},{key:"metricFindQuery",value:function(e,t){var n,a,r=this,i=["servers","databases","databaseElements","elements"];return"string"==typeof e&&(e=JSON.parse(e)),t.isPiPoint?e.path=this.templateSrv.replace(e.path,t):(""===e.path?e.type=i[0]:(e.path=this.templateSrv.replace(e.path,t),e.path=e.path.split(";")[0],"attributes"!==e.type&&(e.type=i[Math.max(0,Math.min(e.path.split("\\").length,i.length-1))])),e.path=e.path.replace(/\{([^\\])*\}/gi,(function(e){return e.substring(1,e.length-2).split(",")[0]}))),e.filter=null!==(n=e.filter)&&void 0!==n?n:"*","servers"===e.type?null!==(a=r.afserver)&&void 0!==a&&a.name?r.getAssetServer(r.afserver.name).then((function(e){return[e]})).then(ne):r.getAssetServers().then(ne):"databases"===e.type&&e.afServerWebId?r.getDatabases(e.afServerWebId,{}).then(ne):"databases"===e.type?r.getAssetServer(e.path).then((function(e){var t;return r.getDatabases(null!==(t=e.WebId)&&void 0!==t?t:"",{})})).then(ne):"databaseElements"===e.type?r.getDatabase(e.path).then((function(e){var t;return r.getDatabaseElements(null!==(t=e.WebId)&&void 0!==t?t:"",{selectedFields:"Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren"})})).then(ne):"elements"===e.type?r.getElement(e.path).then((function(t){var n;return r.getElements(null!==(n=t.WebId)&&void 0!==n?n:"",{selectedFields:"Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren",nameFilter:e.filter})})).then(ne):"attributes"===e.type?r.getElement(e.path).then((function(t){var n;return r.getAttributes(null!==(n=t.WebId)&&void 0!==n?n:"",{searchFullHierarchy:"true",selectedFields:"Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path",nameFilter:e.filter})})).then(ne):"dataserver"===e.type?r.getDataServers().then(ne):"pipoint"===e.type?r.piPointSearch(e.webId,e.pointName).then(ne):Promise.reject("Bad type")}},{key:"getSummaryUrl",value:function(e){return""===e.interval.trim()?"&summaryType="+e.types.map((function(e){var t;return null===(t=e.value)||void 0===t?void 0:t.value})).join("&summaryType=")+"&calculationBasis="+e.basis:"&summaryType="+e.types.map((function(e){var t;return null===(t=e.value)||void 0===t?void 0:t.value})).join("&summaryType=")+"&calculationBasis="+e.basis+"&summaryDuration="+e.interval.trim()}},{key:"processAnnotationQuery",value:function(e){var t,a=e.targets[0],r=a.categoryName?this.templateSrv.replace(a.categoryName,e.scopedVars,"glob"):null,i=a.nameFilter?this.templateSrv.replace(a.nameFilter,e.scopedVars,"glob"):null,l=a.template?a.template.Name:null,o={datasource:a.datasource,showEndTime:a.showEndTime,regex:a.regex,attribute:a.attribute,categoryName:r,templateName:l,nameFilter:i},u=[];if(o.categoryName&&u.push("categoryName="+o.categoryName),o.nameFilter&&u.push("nameFilter="+o.nameFilter),o.templateName&&u.push("templateName="+o.templateName),!u.length)return Promise.resolve({data:[]});if(u.push("startTime="+e.range.from.toISOString()),u.push("endTime="+e.range.to.toISOString()),o.attribute&&o.attribute.enable){var s,c=this.piwebapiurl+"/streamsets/{0}/value?selectedFields=Items.WebId%3BItems.Value%3BItems.Name";o.attribute.name&&o.attribute.name.trim().length>0&&(c+="&nameFilter="+o.attribute.name.trim());var m={1:{Method:"GET",Resource:this.piwebapiurl+"/assetdatabases/"+(null===(s=a.database)||void 0===s?void 0:s.WebId)+"/eventframes?"+u.join("&")},2:{Method:"GET",RequestTemplate:{Resource:c},Parameters:["$.1.Content.Items[*].WebId"],ParentIds:["1"]}};return this.restBatch(m).then((function(e){var t=e.data[1].Content,a=e.data[2].Content;return{data:ae(t.Items,a.Items).map((function(e){return(0,n.toDataFrame)(e)}))}}))}return this.restGet("/assetdatabases/"+(null===(t=a.database)||void 0===t?void 0:t.WebId)+"/eventframes?"+u.join("&")).then((function(e){return{data:ae(e.data.Items).map((function(e){return(0,n.toDataFrame)(e)}))}}))}},{key:"eventFrameToAnnotation",value:function(e,t){var n=e.target,a=[];return t.forEach((function(t){var r,i,l,o="",u=t.name,s=null===(r=t.fields.find((function(e){return"EndTime"===e.name})))||void 0===r?void 0:r.values.get(0),c=null===(i=t.fields.find((function(e){return"StartTime"===e.name})))||void 0===i?void 0:i.values.get(0),m=t.fields.filter((function(e){return["StartTime","EndTime"].indexOf(e.name)<0}));m&&(0,w.each)(m,(function(e){o+="
"+e.name+": "+e.values.get(0)})),n.regex&&n.regex.enable&&(u=u.replace(new RegExp(n.regex.search),n.regex.replace)),a.push({id:null===(l=n.database)||void 0===l?void 0:l.WebId,annotation:e,title:"Name: ".concat(e.name),time:new Date(c).getTime(),timeEnd:n.showEndTime?new Date(s).getTime():void 0,text:"Tag: ".concat(u)+o+"
Start: "+new Date(c).toLocaleString("pt-BR")+"
End: "+new Date(s).toLocaleString("pt-BR"),tags:["OSISoft PI"]})})),a}},{key:"buildQueryParameters",value:function(e){var t=this;return e.targets=(0,w.filter)(e.targets,(function(e){return!(!e||!e.target||e.hide||e.target.startsWith("Select AF"))})),e.targets=(0,w.map)(e.targets,(function(n){var a;if(n.rawQuery&&n.target){var r=function(e){var t=e.split(";"),n=t[0].split("\\");t.splice(0,1);var a=[];if(n.length>1||1===n.length&&""!==n[0]){var r=n.join("\\");return(0,w.each)(t,(function(e,t){""!==e&&a.push({label:e,value:{value:e,expandable:!1}})})),{attributes:a,elementPath:r}}return{attributes:a,elementPath:null}}(t.templateSrv.replace(n.target,e.scopedVars)),i=r.attributes,l=r.elementPath;n.attributes=i,n.elementPath=l}var o=t,u={target:t.templateSrv.replace(n.elementPath,e.scopedVars),elementPath:t.templateSrv.replace(n.elementPath,e.scopedVars),elementPathArray:[{path:t.templateSrv.replace(n.elementPath,e.scopedVars),variable:""}],attributes:(0,w.map)(n.attributes,(function(n){var a;return t.templateSrv.replace((null===(a=n.value)||void 0===a?void 0:a.value)||n,e.scopedVars)})),isAnnotation:!!n.isAnnotation,segments:(0,w.map)(n.segments,(function(n){var a;return t.templateSrv.replace(null===(a=n.value)||void 0===a?void 0:a.value,e.scopedVars)})),display:n.display,refId:n.refId,hide:n.hide,interpolate:n.interpolate||{enable:!1},useLastValue:n.useLastValue||{enable:!1},useUnit:n.useUnit||{enable:!1},recordedValues:n.recordedValues||{enable:!1},digitalStates:n.digitalStates||{enable:!1},webid:null!==(a=n.webid)&&void 0!==a?a:"",webids:n.webids||[],regex:n.regex||{enable:!1},expression:n.expression||"",summary:n.summary||{types:[]},startTime:e.range.from,endTime:e.range.to,isPiPoint:!!n.isPiPoint,scopedVars:e.scopedVars};u.expression&&(u.expression=t.templateSrv.replace(u.expression,e.scopedVars)),void 0!==u.summary.types&&(u.summary.types=(0,w.filter)(u.summary.types,(function(e){return null!=e&&""!==e})));var s=(0,w.keys)(e.scopedVars);return t.templateSrv.getVariables().forEach((function(e){if((r=e.current)&&(Array.isArray(r.text)?r.text.indexOf("All")>=0:"All"===r.text)&&s.indexOf(e.name)<0){var t=e.options.filter((function(e){return!e.selected}));u.attributes=u.attributes.map((function(n){return t.map((function(t){return e.allValue?n.replace(e.allValue,t.value):n.replace(/{[a-z 0-9,-_]+}/gi,t.value)}))})),u.attributes=(0,w.uniq)((0,w.flatten)(u.attributes)),u.elementPathArray=o.getElementPath(u.elementPathArray,t,e.allValue)}else if(Array.isArray(e.current.text)&&s.indexOf(e.name)<0){var n=e.options.filter((function(e){return e.selected})),a=e.current.value.join(",");u.attributes=u.attributes.map((function(e){return n.map((function(t){return e.replace("{".concat(a,"}"),t.value)}))})),u.attributes=(0,w.uniq)((0,w.flatten)(u.attributes)),u.elementPathArray=o.getElementPath(u.elementPathArray,n,"{".concat(a,"}"))}var r})),u})),e}},{key:"parsePiPointValueData",value:function(e,t,n){var a=this,r=[];return Array.isArray(e)?(0,w.each)(e,(function(e){a.piPointValue(n?e.Value:e,t,n,r)})):this.piPointValue(e,t,n,r),r}},{key:"piPointValue",value:function(e,t,n,a){var r=function(e,t,n){var a,r,i=null,l=!1;return!e.Good||"No Data"===e.Value||null!==(a=e.Value)&&void 0!==a&&a.Name&&"No Data"===(null===(r=e.Value)||void 0===r?void 0:r.Name)?"Drop"===t?l=!0:"0"===t?n[0]=0:"Keep"===t||("Null"===t?n[0]=null:"Previous"===t&&null!==i&&(n[0]=i)):i=e.Value,{grafanaDataPoint:n,previousValue:i,drop:l}}(e,t.summary.nodata,this.parsePiPointValue(e,t,n)),i=r.grafanaDataPoint;r.previousValue,r.drop||a.push(i)}},{key:"parsePiPointValue",value:function(e,t,n){var a,r,i,l,o=n||"object"!==ve(e.Value)?e.Value:null===(a=e.Value)||void 0===a?void 0:a.Value;return!e.Good||null!==(r=t.digitalStates)&&void 0!==r&&r.enable?[re(o=null!==(i=n||"object"!==ve(e.Value)?e.Name:null===(l=e.Value)||void 0===l?void 0:l.Name)&&void 0!==i?i:"")?Number(o):o.trim(),new Date(e.Timestamp).getTime()]:[re(o)?Number(o):o.trim(),new Date(e.Timestamp).getTime()]}},{key:"toTags",value:function(e,t){var n,a=["Path","WebId","Id","ServerTime","ServerVersion"],r=(0,w.omitBy)(e,(function(e,t){return!e||!e.length||a.indexOf(t)>=0}));return r.Element=t?this.piserver.name:ie(null!==(n=e.Path)&&void 0!==n?n:""),Object.keys(r).sort().reduce((function(e,t){var n;return e[(n=t,n.charAt(0).toLocaleLowerCase()+n.slice(1))]=r[t],e}),{})}},{key:"processResults",value:function(e,t,n,a,r){var i=this,l=t.summary&&t.summary.types&&t.summary.types.length>0;if(t.isPiPoint||t.display||!e.Path||(n=i.newFormatConfig?(a?ie(e.Path):le(t.elementPathArray,e.Path))+"|"+n:a?n:le(t.elementPathArray,e.Path)+"|"+n),t.regex&&t.regex.enable&&t.regex.search.length&&t.regex.replace.length&&(n=n.replace(new RegExp(t.regex.search),t.regex.replace)),l){var o=[],u=(0,w.groupBy)(e.Items,(function(e){return e.Type}));return(0,w.forOwn)(u,(function(e,a){o.push({refId:t.refId,target:n+"["+a+"]",meta:{path:r.Path,pathSeparator:"\\"},tags:i.newFormatConfig?i.toTags(r,t.isPiPoint):{},datapoints:i.parsePiPointValueData(e,t,l),path:r.Path,unit:i.useUnitConfig&&t.useUnit.enable?r.DefaultUnitsName:void 0})})),o}return[{refId:t.refId,target:n,meta:{path:r.Path,pathSeparator:"\\"},tags:i.newFormatConfig?i.toTags(r,t.isPiPoint):{},datapoints:i.parsePiPointValueData(e.Items||e.Value,t,l),path:r.Path,unit:i.useUnitConfig&&t.useUnit.enable?r.DefaultUnitsName:void 0}]}},{key:"getElementPath",value:function(e,t,n){var a=[];return e.forEach((function(e){if(n&&e.path.indexOf(n)>=0||!n&&e.path.match(/{[a-z 0-9,-_]+}/gi)){var r=t.map((function(t){return{path:n?e.path.replace(n,t.value):e.path.replace(/{[a-z 0-9,-_]+}/gi,t.value),variable:t.value}}));a=a.concat(r)}})),a.length?(0,w.uniq)((0,w.flatten)(a)):e}},{key:"getStream",value:function(e){var t=this,n=this,a=[];return(0,w.each)(e.targets,(function(r){if(!r.isPiPoint||n.piPointConfig){r.attributes=(0,w.filter)(r.attributes||[],(function(e){return e}));var i="",l=r.summary&&r.summary.types&&r.summary.types.length>0,o=r.interpolate&&r.interpolate.enable,u=r.recordedValues&&r.recordedValues.enable,s=r.interpolate.interval?r.interpolate.interval:e.interval,c="?startTime="+e.range.from.toJSON()+"&endTime="+e.range.to.toJSON(),m=r.expression||r.elementPath,p=r.display?t.templateSrv.replace(r.display,e.scopedVars):null;if(r.expression){var f;if(i+="/calculation",null!==(f=r.useLastValue)&&void 0!==f&&f.enable)i+="/times?&time="+e.range.to.toJSON();else if(l)i+="/summary"+c+(o?"&sampleType=Interval&sampleInterval="+s:"");else if(o)i+="/intervals"+c+"&sampleInterval="+s;else if(u)i+="/recorded"+c;else{for(var d=Math.floor((e.range.to.valueOf()-e.range.from.valueOf())/40),h="time="+e.range.from.toJSON(),v=1;v<40;v++){var g=e.range.from.valueOf()+v*d;h+="&time="+new Date(g).toISOString()}h+="&time="+e.range.to.toJSON(),i+="/times?"+h}i+="&expression="+encodeURIComponent(r.expression.replace(/\${intervalTime}/g,s)),r.attributes.length>0?a.push(n.createBatchGetWebId(r,i,p)):a.push(n.restGetWebId(r.elementPath,!1).then((function(e){return n.restPost(i+"&webId="+e.WebId).then((function(t){return n.processResults(t.data,r,p||m,!1,e)})).catch((function(e){return n.error=e}))})))}else{var b;if(i+="/streamsets",null!==(b=r.useLastValue)&&void 0!==b&&b.enable)i+="/value?time="+e.range.to.toJSON();else if(l)i+="/summary"+c+"&intervals="+e.maxDataPoints+t.getSummaryUrl(r.summary);else if(o)i+="/interpolated"+c+"&interval="+s;else if(u){var y=r.recordedValues.maxNumber&&!isNaN(r.recordedValues.maxNumber)?r.recordedValues.maxNumber:e.maxDataPoints;i+="/recorded"+c+"&maxCount="+y}else i+="/plot"+c+"&intervals="+e.maxDataPoints;a.push(n.createBatchGetWebId(r,i,p))}}})),a}},{key:"handleBatchResponse",value:function(e,t,n){for(var a=this,r=t.expression||t.elementPath,i=1===t.elementPathArray.length&&t.elementPath===t.elementPathArray[0].path,l=i?t.attributes.length:t.elementPathArray.length,o=[],u=function(l){var u="Req".concat(l+1e3),s=e.config.data[u].Headers?e.config.data[u].Headers["Asset-Path"]:null,c=e.data[u];if(c.Status>=400)return"continue";var m=void 0;if(s)m=a.webidCache.get(s);else{var p=e.data["Req".concat(l)].Content;m={Path:p.Path,Type:p.Type||p.PointType,DefaultUnitsName:p.DefaultUnitsName||p.EngineeringUnits,Description:p.Description||p.Descriptor,WebId:p.WebId,Name:p.Name},a.webidCache.set(m.Path,m)}t.expression?(0,w.each)(a.processResults(c.Content,t,n||m.Name||r,i,m),(function(e){return o.push(e)})):(0,w.each)(c.Content.Items,(function(e){(0,w.each)(a.processResults(e,t,n||e.Name||r,i,m),(function(e){return o.push(e)}))}))},s=1;s<=l;s++)u(s);return Promise.resolve(o)}},{key:"createQueryPair",value:function(e,t,n,a,r,i,l){var o="",u="";o=e?"/points?selectedFields=Descriptor%3BPointType%3BEngineeringUnits%3BWebId%3BName%3BPath&path="+(u="\\\\"+t+"\\"+n):"/attributes?selectedFields=Type%3BDefaultUnitsName%3BDescription%3BWebId%3BName%3BPath&path="+(u="\\\\"+t+"|"+n);var s=this.webidCache.get(u);s?a["Req".concat(r+1e3)]={Method:"GET",Resource:this.piwebapiurl+oe(i,{Name:n},l)+"&webId="+(i?this.piserver.webid:s.WebId),Headers:{"Asset-Path":u}}:(a["Req".concat(r)]={Method:"GET",Resource:this.piwebapiurl+o},a["Req".concat(r+1e3)]={Method:"GET",ParentIds:["Req".concat(r)],Parameters:["$.Req".concat(r,".Content.WebId")],Resource:this.piwebapiurl+oe(i,{Name:n},l)+(i?"&webId="+this.piserver.webid:"&webId={0}")})}},{key:"createBatchGetWebId",value:function(e,t,n){var a,r=this,i=1===e.elementPathArray.length&&e.elementPath===e.elementPathArray[0].path,l=e.isPiPoint&&!!e.expression,o={},u=1,s=de(e.attributes);try{var c=function(){var n=a.value;i?(r.createQueryPair(e.isPiPoint,e.elementPath,n,o,u,l,t),u++):e.elementPathArray.forEach((function(a){r.createQueryPair(e.isPiPoint,a.path,n,o,u,l,t),u++}))};for(s.s();!(a=s.n()).done;)c()}catch(e){s.e(e)}finally{s.f()}return this.restBatch(o).then((function(t){return r.handleBatchResponse(t,e,n)}))}},{key:"restGet",value:function(e){return this.backendSrv.datasourceRequest({url:this.url+e,method:"GET",headers:{"Content-Type":"application/json"}}).then((function(e){return e}))}},{key:"restGetWebId",value:function(e,t){var n=this,a=n.webidCache.get(e);if(a)return Promise.resolve(fe({},a));var r="";return r=t?"/points?selectedFields=Descriptor%3BPointType%3BEngineeringUnits%3BWebId%3BName%3BPath&path=\\\\"+e.replace("|","\\"):(e.indexOf("|")>=0?"/attributes?selectedFields=Type%3BDefaultUnitsName%3BDescription%3BWebId%3BName%3BPath&path=\\\\":"/elements?selectedFields=Description%3BWebId%3BName%3BPath&path=\\\\")+e,this.backendSrv.datasourceRequest({url:this.url+r,method:"GET",headers:{"Content-Type":"application/json"}}).then((function(t){var a={Path:e,Type:t.data.Type||t.data.PointType,DefaultUnitsName:t.data.DefaultUnitsName||t.data.EngineeringUnits,Description:t.data.Description||t.data.Descriptor,WebId:t.data.WebId,Name:t.data.Name};return n.webidCache.set(e,a),fe({},a)}))}},{key:"restBatch",value:function(e){return this.backendSrv.datasourceRequest({url:this.url+"/batch",data:e,method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"message/http"}})}},{key:"restPost",value:function(e){return this.backendSrv.datasourceRequest({url:this.url,method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"message/http","X-PIWEBAPI-HTTP-METHOD":"GET","X-PIWEBAPI-RESOURCE-ADDRESS":e}})}},{key:"getDataServers",value:function(){return this.restGet("/dataservers").then((function(e){var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}},{key:"getDataServer",value:function(e){return e?this.restGet("/dataservers?name="+e).then((function(e){return e.data})):Promise.resolve({})}},{key:"getAssetServers",value:function(){return this.restGet("/assetservers").then((function(e){var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}},{key:"getAssetServer",value:function(e){return e?this.restGet("/assetservers?path=\\\\"+e).then((function(e){return e.data})):Promise.resolve({})}},{key:"getDatabase",value:function(e){return e?this.restGet("/assetdatabases?path=\\\\"+e).then((function(e){return e.data})):Promise.resolve({})}},{key:"getDatabases",value:function(e,t){return e?this.restGet("/assetservers/"+e+"/assetdatabases").then((function(e){var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]})):Promise.resolve([])}},{key:"getElement",value:function(e){return e?this.restGet("/elements?path=\\\\"+e).then((function(e){return e.data})):Promise.resolve({})}},{key:"getEventFrameTemplates",value:function(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((function(e){var t;return(0,w.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(function(e){return"EventFrame"===e.InstanceType}))})):Promise.resolve([])}},{key:"getElementTemplates",value:function(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((function(e){var t;return(0,w.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(function(e){return"Element"===e.InstanceType}))})):Promise.resolve([])}},{key:"getAttributes",value:function(e,t){var n="?"+(0,w.map)(t,(function(e,t){return t+"="+e})).join("&");return"?"===n&&(n=""),this.restGet("/elements/"+e+"/attributes"+n).then((function(e){var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}},{key:"getDatabaseElements",value:function(e,t){var n="?"+(0,w.map)(t,(function(e,t){return t+"="+e})).join("&");return"?"===n&&(n=""),this.restGet("/assetdatabases/"+e+"/elements"+n).then((function(e){var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}},{key:"getElements",value:function(e,t){var n="?"+(0,w.map)(t,(function(e,t){return t+"="+e})).join("&");return"?"===n&&(n=""),this.restGet("/elements/"+e+"/elements"+n).then((function(e){var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}},{key:"piPointSearch",value:function(e,t){var n=this.templateSrv.replace(t),a="".concat(n),r=!1;if(n!==t)for(var i,l=/\{(\w|,)+\}/g;null!==(i=l.exec(n));)i.index===l.lastIndex&&l.lastIndex++,i.forEach((function(e,t){0===t&&(n=n.replace(e,e.replace("{","(").replace("}",")").replace(",","|")),a=a.replace(e,"*"),r=!0)}));return this.restGet("/dataservers/"+e+"/points?maxCount=50&nameFilter="+a).then((function(e){var t;return e&&null!==(t=e.data)&&void 0!==t&&t.Items?r?e.data.Items.filter((function(e){var t;return null===(t=e.Name)||void 0===t?void 0:t.match(n)})):e.data.Items:[]}))}}],a&&Pe(t.prototype,a),r&&Pe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),u}(n.DataSourceApi),Ae=new n.DataSourcePlugin(Oe).setQueryEditor(Y).setConfigEditor(S)})(),s})())); +define(["@grafana/data","react","@grafana/ui","lodash","rxjs","@grafana/runtime"],((e,t,a,n,l,r)=>(()=>{"use strict";var i={781:t=>{t.exports=e},531:e=>{e.exports=r},7:e=>{e.exports=a},241:e=>{e.exports=n},959:e=>{e.exports=t},269:e=>{e.exports=l}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return i[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};return(()=>{o.r(u),o.d(u,{plugin:()=>M});var e=o(781),t=o(959),a=o.n(t),n=o(7);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function r(e){for(var t=1;ti(r({},e),{jsonData:i(r({},e.jsonData),{url:e.url})});class m extends t.PureComponent{render(){const{options:e}=this.props,t=h(e);return a().createElement("div",null,a().createElement(n.DataSourceHttpSettings,{defaultUrl:"https://server.name/piwebapi",dataSourceConfig:t,onChange:this.onHttpOptionsChange,showAccessOptions:!0}),a().createElement("h3",{className:"page-heading"},"Custom Configuration"),a().createElement("div",{className:"gf-form-group"},a().createElement("div",{className:"gf-form-inline"},a().createElement(n.InlineField,{label:"Enable PI Points in Query",labelWidth:24},a().createElement(n.InlineSwitch,{value:t.jsonData.pipoint,onChange:this.onPiPointChange}))),a().createElement("div",{className:"gf-form-inline"},a().createElement(n.InlineField,{label:"Enable New Data Format",labelWidth:24},a().createElement(n.InlineSwitch,{value:t.jsonData.newFormat,onChange:this.onNewFormatChange}))),a().createElement("div",{className:"gf-form-inline"},a().createElement(n.InlineField,{label:"Enable Unit in Data",labelWidth:24},a().createElement(n.InlineSwitch,{value:t.jsonData.useUnit,onChange:this.onUseUnitChange}))),a().createElement("div",{className:"gf-form-inline"},a().createElement(n.InlineField,{label:"Enable Experimental Features",labelWidth:24},a().createElement(n.InlineSwitch,{value:t.jsonData.useExperimental,onChange:this.onUseExperimentalChange}))),t.jsonData.useExperimental&&a().createElement("div",{className:"gf-form-inline"},a().createElement(n.InlineField,{label:"Enable Steaming Support",labelWidth:24},a().createElement(n.InlineSwitch,{value:t.jsonData.useStreaming,onChange:this.onUseStreamingChange})))),a().createElement("h3",{className:"page-heading"},"PI/AF Connection Details"),a().createElement("div",{className:"gf-form-group"},t.jsonData.pipoint&&a().createElement("div",{className:"gf-form"},a().createElement(s,{label:"PI Server",labelWidth:10,inputWidth:25,onChange:this.onPIServerChange,value:t.jsonData.piserver||"",placeholder:"Default PI Server to use for data requests"})),a().createElement("div",{className:"gf-form"},a().createElement(s,{label:"AF Server",labelWidth:10,inputWidth:25,onChange:this.onAFServerChange,value:t.jsonData.afserver||"",placeholder:"Default AF Server to use for data requests"})),a().createElement("div",{className:"gf-form"},a().createElement(s,{label:"AF Database",labelWidth:10,inputWidth:25,onChange:this.onAFDatabaseChange,value:t.jsonData.afdatabase||"",placeholder:"Default AF Database server for AF queries"}))))}constructor(...e){super(...e),l(this,"onPIServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{piserver:e.target.value});t(i(r({},a),{jsonData:n}))})),l(this,"onAFServerChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{afserver:e.target.value});t(i(r({},a),{jsonData:n}))})),l(this,"onAFDatabaseChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{afdatabase:e.target.value});t(i(r({},a),{jsonData:n}))})),l(this,"onHttpOptionsChange",(e=>{const{onOptionsChange:t}=this.props;t(h(e))})),l(this,"onPiPointChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{piserver:e.target.checked?a.jsonData.piserver:"",pipoint:e.target.checked});t(i(r({},a),{jsonData:n}))})),l(this,"onNewFormatChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{newFormat:e.target.checked});t(i(r({},a),{jsonData:n}))})),l(this,"onUseUnitChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{useUnit:e.target.checked});t(i(r({},a),{jsonData:n}))})),l(this,"onUseExperimentalChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{useExperimental:e.target.checked,useStreaming:!!e.target.checked&&a.jsonData.useStreaming});t(i(r({},a),{jsonData:n}))})),l(this,"onUseStreamingChange",(e=>{const{onOptionsChange:t,options:a}=this.props,n=i(r({},a.jsonData),{useStreaming:e.target.checked});t(i(r({},a),{jsonData:n}))}))}}var c=o(241);function d(){return d=Object.assign||function(e){for(var t=1;ta().createElement(a().Fragment,null,a().createElement(n.InlineFormLabel,{width:t,tooltip:l},e),r),v=()=>a().createElement("div",{className:"gf-form gf-form--grow"},a().createElement("div",{className:"gf-form-label gf-form-label--grow"})),b=e=>{var t=d({},p(e));return a().createElement(y,null,a().createElement(g,t))},y=e=>a().createElement("div",{className:"gf-form-inline"},e.children,a().createElement(v,null)),f=e=>{var t=d({},p(e));return a().createElement(E,null,a().createElement(g,t))},E=e=>a().createElement(a().Fragment,null,e.children),S={target:";",attributes:[],segments:[],regex:{enable:!1},summary:{types:[],basis:"EventWeighted",interval:"",nodata:"Null"},expression:"",interpolate:{enable:!1},useLastValue:{enable:!1},recordedValues:{enable:!1},digitalStates:{enable:!1},enableStreaming:{enable:!1},useUnit:{enable:!1},isPiPoint:!1},P=({isRaw:e,onChange:l})=>{const[r,i]=(0,t.useState)(!1);return(0,t.useEffect)((()=>{i(!1)}),[e]),e?a().createElement(a().Fragment,null,a().createElement(n.Button,{"aria-label":"Switch to visual editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{i(!0)}}),a().createElement(n.ConfirmModal,{isOpen:r,title:"Switch to visual editor mode",body:"Are you sure to switch to visual editor mode? You will lose the changes done in raw query mode.",confirmText:"Yes, switch to editor mode",dismissText:"No, stay in raw query mode",onConfirm:()=>{l(!1)},onDismiss:()=>{i(!1)}})):a().createElement(n.Button,{"aria-label":"Switch to text editor",icon:"pen",variant:"secondary",type:"button",onClick:()=>{l(!0)}})};function C(e){return(0,c.map)(e,(e=>{var t,a;return{text:e.Name,expandable:void 0===e.HasChildren||!0===e.HasChildren||(null!==(t=e.Path)&&void 0!==t?t:"").split("\\").length<=3,HasChildren:e.HasChildren,Items:null!==(a=e.Items)&&void 0!==a?a:[],Path:e.Path,WebId:e.WebId}}))}function I(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function w(e){for(var t=1;t{var t;return e.value?a().createElement("div",{className:"gf-form-label "+("template"===e.value.type?"query-keyword":"")},null!==(t=e.label)&&void 0!==t?t:"--no label--"):a().createElement("a",{className:"gf-form-label query-part"},a().createElement(n.Icon,{name:"plus"}))};class A extends t.PureComponent{isValueEmpty(e){return!e||!e.value||!e.value.length||e.value===F}calcBasisValueChanged(e){const t=this.props.query,a=t.summary;var n;a&&(a.basis=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(O(w({},t),{summary:a}))}getCalcBasisSegments(){return(0,c.map)(this.calculationBasis,(e=>({label:e,value:{value:e,expandable:!0}})))}calcNoDataValueChanged(e){const t=this.props.query,a=t.summary;var n;a&&(a.nodata=null===(n=e.value)||void 0===n?void 0:n.value),this.onChange(O(w({},t),{summary:a}))}getNoDataSegments(){return(0,c.map)(this.noDataReplacement,(e=>({label:e,value:{value:e,expandable:!0}})))}onSummaryValueChanged(e,t){const a=this.state.summaries.slice(0);a[t]=e,this.isValueEmpty(e.value)&&a.splice(t,1),this.setState({summaries:a},this.stateCallback)}getSummarySegments(){const e=(0,c.filter)(this.summaryTypes,(e=>-1===this.state.summaries.map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.value})).indexOf(e))),t=(0,c.map)(e,(e=>({label:e,value:{value:e,expandable:!0}})));return t.unshift({label:F,value:{value:F}}),t}removeSummary(e){const t=(0,c.filter)(this.state.summaries,(t=>t!==e));this.setState({summaries:t})}onSummaryAction(e){const t=this.state.summaries.slice(0);if(!this.isValueEmpty(e.value)){var a;let n={label:e.label,value:{value:null===(a=e.value)||void 0===a?void 0:a.value,expandable:!0}};t.push(n)}this.setState({summarySegment:{},summaries:t},this.stateCallback)}removeAttribute(e){const t=(0,c.filter)(this.state.attributes,(t=>t!==e));this.attributeChangeValue(t)}onAttributeAction(e){const{query:t}=this.props,a=this.state.attributes.slice(0);if(!this.isValueEmpty(e.value)){var n;let l={label:e.label,value:{value:null===(n=e.value)||void 0===n?void 0:n.value,expandable:!t.isPiPoint}};a.push(l)}this.attributeChangeValue(a)}getSegmentPathUpTo(e,t){const a=e.slice(0,t);return(0,c.reduce)(a,((e,t)=>{var a;return t.value?(null===(a=t.value.value)||void 0===a?void 0:a.startsWith("-Select"))?e:e?e+"\\"+t.value.value:t.value.value:""}),"")}checkAttributeSegments(e,t){var a;const{datasource:n,data:l}=this.props,r=this,i={path:this.getSegmentPathUpTo(t.slice(0),t.length),type:"attributes"};var s;return n.metricFindQuery(i,Object.assign(null!==(s=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==s?s:{},{isPiPoint:!1})).then((t=>{const a={};(0,c.each)(t,(e=>{a[e.Path.substring(e.Path.indexOf("|")+1)]=e.WebId}));const l=(0,c.filter)(e,(e=>{var t;const l=n.templateSrv.replace(null===(t=e.value)||void 0===t?void 0:t.value);return void 0!==a[l]}));return r.availableAttributes=a,this.attributeChangeValue(l)})).catch((t=>(r.error=t.message||"Failed to issue metric query",this.attributeChangeValue(e))))}checkPiPointSegments(e,t){var a;const{datasource:n,data:l}=this.props,r=this,i={path:e.path,webId:r.getSelectedPIServer(),pointName:e.label,type:"pipoint"};var s;return n.metricFindQuery(i,Object.assign(null!==(s=null==l||null===(a=l.request)||void 0===a?void 0:a.scopedVars)&&void 0!==s?s:{},{isPiPoint:!0})).then((()=>r.attributeChangeValue(t))).catch((e=>(r.error=e.message||"Failed to issue metric query",r.attributeChangeValue([]))))}getSelectedPIServer(){var e;let t="";return this.piServer.forEach((e=>{const a=this.props.query.target.split(";");a.length>=2&&a[0]===e.text&&(t=e.WebId)})),this.piServer.length>0?null===(e=this.piServer[0].value)||void 0===e?void 0:e.webId:t}textEditorChanged(){const{query:e}=this.props,t=e.target.split(";"),a=t.length>0?t[0].split("\\"):[];let n=[],l=[];a.length>1||1===a.length&&""!==a[0]?(t.splice(0,1),(0,c.each)(a,((e,t)=>{n.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,c.each)(t,(function(e,t){""!==e&&l.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(a.length+1,n).then((e=>{e.length>0&&n.push({label:"Select Element",value:{value:"-Select Element-"}})})).then((()=>{this.updateArray(n,l,this.state.summaries,e.isPiPoint,(()=>{this.onChange(O(w({},e),{query:void 0,rawQuery:!1,attributes:this.state.attributes,segments:this.state.segments}))}))}))):(n=this.checkAfServer(),this.updateArray(n,this.state.attributes,this.state.summaries,e.isPiPoint,(()=>{this.onChange(O(w({},e),{query:void 0,rawQuery:!1,attributes:this.state.attributes,segments:this.state.segments}))})))}render(){const{query:e,onChange:t,onRunQuery:l}=this.props,r=(0,c.defaults)(e,S),{useLastValue:i,useUnit:s,interpolate:o,query:u,rawQuery:h,digitalStates:m,enableStreaming:d,recordedValues:p,expression:g,isPiPoint:y,summary:E,display:C,regex:I}=r;return a().createElement(a().Fragment,null,this.props.datasource.piPointConfig&&a().createElement(n.InlineField,{label:"Is Pi Point?",labelWidth:D},a().createElement(n.InlineSwitch,{value:y,onChange:this.onIsPiPointChange})),!!h&&a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Raw Query",labelWidth:D,grow:!0},a().createElement(n.Input,{onBlur:this.stateCallback,value:u,onChange:e=>t(O(w({},r),{query:e.target.value})),placeholder:"enter query"})),a().createElement(P,{isRaw:!0,onChange:e=>this.textEditorChanged()})),!h&&a().createElement(a().Fragment,null,a().createElement("div",{className:"gf-form-inline"},a().createElement(f,{label:y?"PI Server":"AF Elements",tooltip:y?"Select PI server.":"Select AF Element."},this.state.segments.map(((e,t)=>a().createElement(n.SegmentAsync,{key:"element-"+t,Component:a().createElement(j,{value:e.value,label:e.label}),onChange:e=>this.onSegmentChange(e,t),loadOptions:e=>this.getElementSegments(t),allowCustomValue:!0,inputMinWidth:200}))),a().createElement(v,null),!y&&a().createElement(P,{isRaw:!1,onChange:e=>{t(O(w({},r),{query:r.target,rawQuery:e}))}}))),a().createElement(b,{label:y?"Pi Points":"Attributes"},this.state.attributes.map(((e,t)=>y?a().createElement(n.SegmentAsync,{key:"attributes-"+t,Component:a().createElement(j,{value:e.value,label:e.label}),disabled:0===this.piServer.length,onChange:e=>this.onPiPointChange(e,t),loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:x}):a().createElement(n.Segment,{key:"attributes-"+t,Component:a().createElement(j,{value:e.value,label:e.label}),disabled:this.state.segments.length<=2,onChange:e=>this.onAttributeChange(e,t),options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:x}))),y&&a().createElement(n.SegmentAsync,{Component:a().createElement(j,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:0===this.piServer.length,onChange:this.onAttributeAction,loadOptions:this.getAttributeSegmentsPI,reloadOptionsOnChange:!0,allowCustomValue:!0,inputMinWidth:x}),!y&&a().createElement(n.Segment,{Component:a().createElement(j,{value:this.state.attributeSegment.value,label:this.state.attributeSegment.label}),disabled:this.state.segments.length<=2,onChange:this.onAttributeAction,options:this.getAttributeSegmentsAF(),allowCustomValue:!0,inputMinWidth:x}))),a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Calculation",grow:!0,labelWidth:D,tooltip:"Modify all attributes by an equation. Use '.' for current item. Leave Attributes empty if you wish to perform element based calculations."},a().createElement(n.Input,{onBlur:l,value:g,onChange:e=>t(O(w({},r),{expression:e.target.value})),placeholder:"'.'*2"}))),a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Use Last Value",tooltip:"Fetch only last value from time range",labelWidth:D},a().createElement(n.InlineSwitch,{value:i.enable,onChange:()=>this.onChange(O(w({},r),{useLastValue:O(w({},i),{enable:!i.enable})}))})),a().createElement(n.InlineField,{label:"Digital States",labelWidth:D},a().createElement(n.InlineSwitch,{value:m.enable,onChange:()=>this.onChange(O(w({},r),{digitalStates:O(w({},m),{enable:!m.enable})}))})),a().createElement(n.InlineField,{label:"Replace Bad Data",labelWidth:D,tooltip:"Replacement for bad quality values."},a().createElement(n.Segment,{Component:a().createElement(j,{value:{value:null==E?void 0:E.nodata},label:null==E?void 0:E.nodata}),onChange:this.calcNoDataValueChanged,options:this.getNoDataSegments(),allowCustomValue:!0})),this.props.datasource.useUnitConfig&&a().createElement(n.InlineField,{label:"Use unit from datapoints",tooltip:"Use unit in label from PI tag or PI AF attribute",labelWidth:D},a().createElement(n.InlineSwitch,{value:s.enable,onChange:()=>this.onChange(O(w({},r),{useUnit:O(w({},s),{enable:!s.enable})}))})),this.props.datasource.useStreaming&&a().createElement(n.InlineField,{label:"Enable Streaming",labelWidth:D,tooltip:"Enable streaming data if it is supported for the point type."},a().createElement(n.InlineSwitch,{value:d.enable,onChange:()=>this.onChange(O(w({},r),{enableStreaming:O(w({},d),{enable:!d.enable})}))}))),a().createElement(n.InlineFieldRow,null,!i.enable&&a().createElement(n.InlineField,{label:"Max Recorded Values",labelWidth:D,tooltip:"Maximum number of recorded value to retrive from the data archive, without using interpolation."},a().createElement(n.Input,{onBlur:l,value:p.maxNumber,onChange:e=>t(O(w({},r),{recordedValues:O(w({},p),{maxNumber:parseInt(e.target.value,10)})})),type:"number",placeholder:"1000"})),a().createElement(n.InlineField,{label:"Recorded Values",labelWidth:D},a().createElement(n.InlineSwitch,{value:p.enable,onChange:()=>this.onChange(O(w({},r),{recordedValues:O(w({},p),{enable:!p.enable})}))}))),!i.enable&&a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:g?"Interval Period":"Interpolate Period",labelWidth:D,tooltip:"Override time between sampling, e.g. '30s'. Defaults to timespan/chart width."},a().createElement(n.Input,{onBlur:l,value:o.interval,onChange:e=>t(O(w({},r),{interpolate:O(w({},o),{interval:e.target.value})})),placeholder:"30s"})),a().createElement(n.InlineField,{label:g?"Interval Values":"Interpolate",labelWidth:D},a().createElement(n.InlineSwitch,{value:o.enable,onChange:()=>this.onChange(O(w({},r),{interpolate:O(w({},o),{enable:!o.enable})}))}))),!i.enable&&a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Summary Period",labelWidth:D,tooltip:"Define the summary period, e.g. '30s'."},a().createElement(n.Input,{onBlur:l,value:null==E?void 0:E.interval,onChange:e=>t(O(w({},r),{summary:O(w({},E),{interval:e.target.value})})),placeholder:"30s"})),a().createElement(n.InlineField,{label:"Basis",labelWidth:D,tooltip:"Defines the possible calculation options when performing summary calculations over time-series data."},a().createElement(n.Segment,{Component:a().createElement(j,{value:{value:null==E?void 0:E.basis},label:null==E?void 0:E.basis}),onChange:this.calcBasisValueChanged,options:this.getCalcBasisSegments(),allowCustomValue:!0})),a().createElement(n.InlineField,{label:"Summaries",labelWidth:D,tooltip:"PI Web API summary options."},a().createElement(n.InlineFieldRow,null,this.state.summaries.map(((e,t)=>a().createElement(n.Segment,{key:"summaries-"+t,Component:a().createElement(j,{value:e.value,label:e.label}),onChange:e=>this.onSummaryValueChanged(e,t),options:this.getSummarySegments(),allowCustomValue:!0}))),a().createElement(n.Segment,{Component:a().createElement(j,{value:this.state.summarySegment.value,label:this.state.summarySegment.label}),onChange:this.onSummaryAction,options:this.getSummarySegments(),allowCustomValue:!0})))),a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Display Name",labelWidth:D,tooltip:"If single attribute, modify display name. Otherwise use regex to modify display name."},a().createElement(n.Input,{onBlur:l,value:C,onChange:e=>t(O(w({},r),{display:e.target.value})),placeholder:"Display"})),a().createElement(n.InlineField,{label:"Enable Regex Replace",labelWidth:D},a().createElement(n.InlineSwitch,{value:I.enable,onChange:()=>{this.onChange(O(w({},r),{regex:O(w({},I),{enable:!I.enable})}))}})),a().createElement(n.InlineField,{label:"Search",labelWidth:16},a().createElement(n.Input,{onBlur:l,value:I.search,onChange:e=>t(O(w({},r),{regex:O(w({},I),{search:e.target.value})})),placeholder:"(.*)"})),a().createElement(n.InlineField,{label:"Replace",labelWidth:16},a().createElement(n.Input,{onBlur:l,value:I.replace,onChange:e=>t(O(w({},r),{regex:O(w({},I),{replace:e.target.value})})),placeholder:"$1"}))))}constructor(e){super(e),I(this,"error",void 0),I(this,"piServer",[]),I(this,"availableAttributes",{}),I(this,"summaryTypes",void 0),I(this,"calculationBasis",void 0),I(this,"noDataReplacement",void 0),I(this,"state",{isPiPoint:!1,segments:[],attributes:[],summaries:[],attributeSegment:{},summarySegment:{},calculationBasisSegment:{},noDataReplacementSegment:{}}),I(this,"segmentChangeValue",(e=>{const t=this.props.query;this.setState({segments:e},(()=>this.onChange(O(w({},t),{segments:e}))))})),I(this,"attributeChangeValue",(e=>{const t=this.props.query;return new Promise((a=>this.setState({attributes:e},(()=>{this.onChange(O(w({},t),{attributes:e})),a()}))))})),I(this,"onPiPointChange",((e,t)=>{let a=this.state.attributes.slice(0);e.label===F?(0,c.remove)(a,((e,a)=>a===t)):a[t]=e,this.checkPiPointSegments(e,a)})),I(this,"onAttributeChange",((e,t)=>{var a;let n=this.state.attributes.slice(0);n[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&(n[t]=e,this.checkAttributeSegments(n,this.state.segments))})),I(this,"onSegmentChange",((e,t)=>{var a;const{query:n}=this.props;let l=this.state.segments.slice(0);l[t].label!==(null===(a=e.value)||void 0===a?void 0:a.value)&&this.setState({attributes:[]},(()=>e.label===F?(l=(0,c.slice)(l,0,t),void this.checkAttributeSegments([],l).then((()=>{var e;0===l.length?l.push({label:""}):(null===(e=l[l.length-1].value)||void 0===e?void 0:e.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),n.isPiPoint&&(this.piServer=[]),this.segmentChangeValue(l)}))):(l[t]=e,n.isPiPoint?(this.piServer.push(e),void this.segmentChangeValue(l)):(t{var t;(null===(t=e.value)||void 0===t?void 0:t.expandable)&&l.push({label:"Select Element",value:{value:"-Select Element-"}}),this.segmentChangeValue(l)}))))))})),I(this,"getElementSegments",((e,t)=>{var a;const{datasource:n,query:l,data:r}=this.props,i=this,s=l.isPiPoint?{type:"dataserver"}:{path:this.getSegmentPathUpTo(null!=t?t:this.state.segments.slice(0),e),afServerWebId:this.state.segments.length>0&&this.state.segments[0].value?this.state.segments[0].value.webId:void 0};if(!l.isPiPoint){var o,u,h;if((null===(o=n.afserver)||void 0===o?void 0:o.name)&&0===e)return Promise.resolve([{label:n.afserver.name,value:{value:n.afserver.name,expandable:!0}}]);if((null===(u=n.afserver)||void 0===u?void 0:u.name)&&(null===(h=n.afdatabase)||void 0===h?void 0:h.name)&&1===e)return Promise.resolve([{label:n.afdatabase.name,value:{value:n.afdatabase.name,expandable:!0}}])}var m;return n.metricFindQuery(s,Object.assign(null!==(m=null==r||null===(a=r.request)||void 0===a?void 0:a.scopedVars)&&void 0!==m?m:{},{isPiPoint:l.isPiPoint})).then((e=>{const t=(0,c.map)(e,(e=>({label:e.text,value:{webId:e.WebId,value:e.text,expandable:!l.isPiPoint&&e.expandable}})));if(0===t.length)return t;const a=n.templateSrv.getVariables();return(0,c.each)(a,(e=>{let a={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!l.isPiPoint}};t.unshift(a)})),t.unshift({label:F,value:{value:F}}),t})).catch((e=>(i.error=e.message||"Failed to issue metric query",[])))})),I(this,"getAttributeSegmentsPI",(e=>{var t;const{datasource:a,query:n,data:l}=this.props,r=this,i={path:"",webId:this.getSelectedPIServer(),pointName:(null!=e?e:"")+"*",type:"pipoint"};let s=[];var o;return s.push({label:F,value:{value:F}}),a.metricFindQuery(i,Object.assign(null!==(o=null==l||null===(t=l.request)||void 0===t?void 0:t.scopedVars)&&void 0!==o?o:{},{isPiPoint:n.isPiPoint})).then((t=>{s=(0,c.map)(t,(e=>({path:e.Path,label:e.text,value:{value:e.text,expandable:!1}}))),e&&e.length>0&&s.unshift({label:e,value:{value:e,expandable:!1}});const l=a.templateSrv.getVariables();return(0,c.each)(l,(e=>{let t={label:"${"+e.name+"}",value:{type:"template",value:"${"+e.name+"}",expandable:!n.isPiPoint}};s.unshift(t)})),s})).catch((e=>(r.error=e.message||"Failed to issue metric query",s)))})),I(this,"getAttributeSegmentsAF",(e=>{let t=[];return t.push({label:F,value:{value:F}}),(0,c.forOwn)(this.availableAttributes,((e,a)=>{let n={label:a,value:{value:a,expandable:!0}};t.push(n)})),t})),I(this,"buildFromTarget",((e,t,a)=>{const n=e.target.split(";"),l=n.length>0?n[0].split("\\"):[];return l.length>1||1===l.length&&""!==l[0]?(n.splice(0,1),(0,c.each)(l,((e,a)=>{t.push({label:e,value:{type:e.match(/\${\w+}/gi)?"template":void 0,value:e,expandable:!0}})})),(0,c.each)(n,((e,t)=>{""!==e&&a.push({label:e,value:{value:e,expandable:!1}})})),this.getElementSegments(l.length+1,t).then((e=>(e.length>0&&t.push({label:"Select Element",value:{value:"-Select Element-"}}),t)))):Promise.resolve(t)})),I(this,"checkAfServer",(()=>{var e;const{datasource:t}=this.props,a=[];var n;return(null===(e=t.afserver)||void 0===e?void 0:e.name)?(a.push({label:t.afserver.name,value:{value:t.afserver.name,expandable:!0}}),(null===(n=t.afdatabase)||void 0===n?void 0:n.name)&&a.push({label:t.afdatabase.name,value:{value:t.afdatabase.name,expandable:!0}}),a.push({label:"Select Element",value:{value:"-Select Element-"}})):a.push({label:""}),a})),I(this,"updateArray",((e,t,a,n,l)=>{this.setState({segments:e,attributes:t,summaries:a,isPiPoint:n},(()=>{n||this.checkAttributeSegments(t,this.state.segments).then((()=>{l&&l()}))}))})),I(this,"scopedVarsDone",!1),I(this,"componentDidMount",(()=>{this.initialLoad(!1)})),I(this,"componentDidUpdate",(()=>{var e,t,a;const{query:n}=this.props;"Done"===(null===(e=this.props.data)||void 0===e?void 0:e.state)&&(null===(a=this.props.data)||void 0===a||null===(t=a.request)||void 0===t?void 0:t.scopedVars)&&!this.scopedVarsDone&&(this.scopedVarsDone=!0,this.initialLoad(!n.isPiPoint))})),I(this,"initialLoad",(e=>{const{query:t}=this.props,a=(0,c.defaults)(t,S),{segments:n,attributes:l,summary:r,isPiPoint:i}=a;var s;let o=e?[]:null!==(s=null==n?void 0:n.slice(0))&&void 0!==s?s:[];var u;let h=e?[]:null!==(u=null==l?void 0:l.slice(0))&&void 0!==u?u:[];var m;let d=null!==(m=null==r?void 0:r.types)&&void 0!==m?m:[];if(i||0!==o.length)i&&o.length>0&&(this.piServer=o);else{if(t.target&&t.target.length>0&&";"!==t.target)return h=[],void this.buildFromTarget(t,o,h).then((e=>{this.updateArray(e,h,d,!1)})).catch((e=>console.error(e)));o=this.checkAfServer()}this.updateArray(o,h,d,!!i,(()=>{this.onChange(t)}))})),I(this,"onChange",(e=>{const{onChange:t,onRunQuery:a}=this.props;var n,l;if(e.rawQuery){if(e.target=null!==(n=e.query)&&void 0!==n?n:"",e.query){const{attributes:t,elementPath:a}=function(e){const t=e.split(";"),a=t[0].split("\\");t.splice(0,1);let n=[];if(a.length>1||1===a.length&&""!==a[0]){const e=a.join("\\");return(0,c.each)(t,(function(e,t){""!==e&&n.push({label:e,value:{value:e,expandable:!1}})})),{attributes:n,elementPath:e}}return{attributes:n,elementPath:null}}(e.target);e.attributes=t,e.elementPath=a}}else e.elementPath=this.getSegmentPathUpTo(this.state.segments,this.state.segments.length),e.target=e.elementPath+";"+(0,c.join)(null===(l=e.attributes)||void 0===l?void 0:l.map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.value})),";");const r=e.summary;r&&(r.types=this.state.summaries),t(O(w({},e),{summary:r})),console.log("QUERY",e.elementPath,e.attributes,e.target),this.isValidQuery(e)&&a()})),I(this,"isValidQuery",(e=>{if(e.target&&e.target.length>0&&";"!==e.target){e.target=e.target.trim();const t=e.target.split(";",2);return 2===t.length&&t[0].length>0&&t[1].length>0}return!1})),I(this,"stateCallback",(()=>{const e=this.props.query;this.onChange(e)})),I(this,"onIsPiPointChange",(e=>{const{query:t}=this.props,a=!t.isPiPoint;this.setState({segments:a?[{label:""}]:this.checkAfServer(),attributes:[],isPiPoint:a},(()=>{this.onChange(O(w({},t),{expression:"",attributes:this.state.attributes,segments:this.state.segments,isPiPoint:a}))}))})),this.onSegmentChange=this.onSegmentChange.bind(this),this.calcBasisValueChanged=this.calcBasisValueChanged.bind(this),this.calcNoDataValueChanged=this.calcNoDataValueChanged.bind(this),this.onSummaryAction=this.onSummaryAction.bind(this),this.onSummaryValueChanged=this.onSummaryValueChanged.bind(this),this.onAttributeAction=this.onAttributeAction.bind(this),this.onAttributeChange=this.onAttributeChange.bind(this),this.summaryTypes=["Total","Average","Minimum","Maximum","Range","StdDev","PopulationStdDev","Count","PercentGood","All","AllForNonNumeric"],this.calculationBasis=["TimeWeighted","EventWeighted","TimeWeightedContinuous","TimeWeightedDiscrete","EventWeightedExcludeMostRecentEvent","EventWeightedExcludeEarliestEvent","EventWeightedIncludeBothEnds"],this.noDataReplacement=["Null","Drop","Previous","0","Keep"]}}var W=o(269),V=o(531);function N(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function T(e){for(var t=1;t{const t=c.target;if(t&&t[e])return{label:t[e].Name,value:t[e]}};var S;return m.getAssetServer(m.afserver.name).then((e=>{v(e.WebId)})),a().createElement(a().Fragment,null,a().createElement("div",{className:"gf-form-group"},a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Database",labelWidth:B,grow:!0},a().createElement(n.AsyncSelect,{key:null!=g?g:"database-key",loadOptions:()=>m.getDatabases(g).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("database"),onChange:e=>{f(e.value),d(k(T({},h),{database:e.value,template:void 0}))},defaultOptions:!0})),a().createElement(n.InlineField,{label:"Event Frames",labelWidth:B,grow:!0},a().createElement(n.AsyncSelect,{key:null!==(S=null==y?void 0:y.WebId)&&void 0!==S?S:"default-template-key",loadOptions:()=>m.getEventFrameTemplates(null==y?void 0:y.WebId).then((e=>e.map((e=>({label:e.Name,value:e}))))),loadingMessage:"Loading",value:E("template"),onChange:e=>d(k(T({},h),{template:e.value})),defaultOptions:!0})),a().createElement(n.InlineField,{label:"Show Start and End Time",labelWidth:B,grow:!0},a().createElement(n.InlineSwitch,{value:!!h.showEndTime,onChange:e=>d(k(T({},h),{showEndTime:e.currentTarget.checked}))}))),a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Category name",labelWidth:B,grow:!0},a().createElement(n.Input,{type:"text",value:h.categoryName,onBlur:e=>p(),onChange:e=>d(k(T({},h),{categoryName:e.currentTarget.value})),placeholder:"Enter category name"})),a().createElement(n.InlineField,{label:"Name Filter",labelWidth:B,grow:!0},a().createElement(n.Input,{type:"text",value:h.nameFilter,onBlur:e=>p(),onChange:e=>d(k(T({},h),{nameFilter:e.currentTarget.value})),placeholder:"Enter name filter"}))),a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Enable Name Regex Replacement",labelWidth:B,grow:!1},a().createElement(n.InlineSwitch,{value:null===(r=h.regex)||void 0===r?void 0:r.enable,onChange:e=>d(k(T({},h),{regex:k(T({},h.regex),{enable:e.currentTarget.checked})}))})),a().createElement(n.InlineField,{label:"Name Filter",labelWidth:20,grow:!1},a().createElement(n.Input,{type:"text",value:null===(i=h.regex)||void 0===i?void 0:i.search,onBlur:e=>p(),onChange:e=>d(k(T({},h),{regex:k(T({},h.regex),{search:e.currentTarget.value})})),placeholder:"(.*)",width:50})),a().createElement(n.InlineField,{label:"Replace",labelWidth:20,grow:!0},a().createElement(n.Input,{type:"text",value:null==h||null===(s=h.regex)||void 0===s?void 0:s.replace,onBlur:e=>p(),onChange:e=>d(k(T({},h),{regex:k(T({},h.regex),{replace:e.currentTarget.value})})),placeholder:"$1"}))),a().createElement(n.InlineFieldRow,null,a().createElement(n.InlineField,{label:"Enable Attribute Usage",labelWidth:B,grow:!1},a().createElement(n.InlineSwitch,{value:null===(o=h.attribute)||void 0===o?void 0:o.enable,onChange:e=>d(k(T({},h),{attribute:k(T({},h.attribute),{enable:e.currentTarget.checked})}))})),a().createElement(n.InlineField,{label:"Attribute Name",labelWidth:B,grow:!0},a().createElement(n.Input,{type:"text",value:null===(u=h.attribute)||void 0===u?void 0:u.name,onBlur:e=>p(),onChange:e=>d(k(T({},h),{attribute:k(T({},h.attribute),{name:e.currentTarget.value})})),placeholder:"Enter name"})))))}));function R(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class U extends V.DataSourceWithBackend{applyTemplateVariables(e,t){return a=function(e){for(var t=1;te.substring(1,e.length-2).split(",")[0]))),e.filter=null!==(l=e.filter)&&void 0!==l?l:"*","servers"===e.type?(null===(r=a.afserver)||void 0===r?void 0:r.name)?a.getAssetServer(a.afserver.name).then((e=>[e])).then(C):a.getAssetServers().then(C):"databases"===e.type&&e.afServerWebId?a.getDatabases(e.afServerWebId,{}).then(C):"databases"===e.type?a.getAssetServer(e.path).then((e=>{var t;return a.getDatabases(null!==(t=e.WebId)&&void 0!==t?t:"",{})})).then(C):"databaseElements"===e.type?a.getDatabase(e.path).then((e=>{var t;return a.getDatabaseElements(null!==(t=e.WebId)&&void 0!==t?t:"",{selectedFields:"Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren"})})).then(C):"elements"===e.type?a.getElement(e.path).then((t=>{var n;return a.getElements(null!==(n=t.WebId)&&void 0!==n?n:"",{selectedFields:"Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren",nameFilter:e.filter})})).then(C):"attributes"===e.type?a.getElement(e.path).then((t=>{var n;return a.getAttributes(null!==(n=t.WebId)&&void 0!==n?n:"",{searchFullHierarchy:"true",selectedFields:"Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path",nameFilter:e.filter})})).then(C):"dataserver"===e.type?a.getDataServers().then(C):"pipoint"===e.type?a.piPointSearch(e.webId,e.pointName).then(C):Promise.reject("Bad type")}buildQueryParameters(e){return e.targets=(0,c.filter)(e.targets,(e=>{var t;return!(!e||!e.target||0===(null===(t=e.attributes)||void 0===t?void 0:t.length)||";"===e.target||e.hide||e.target.startsWith("Select AF"))})),e.maxDataPoints&&(e.maxDataPoints=e.maxDataPoints>3e4?3e4:e.maxDataPoints),e.targets=(0,c.map)(e.targets,(t=>{var a;const n={enableStreaming:t.enableStreaming,target:this.templateSrv.replace(t.target,e.scopedVars),elementPath:this.templateSrv.replace(t.elementPath,e.scopedVars),attributes:(0,c.map)(t.attributes,(t=>(t.value&&this.templateSrv.replace(t.value.value,e.scopedVars),t))),segments:(0,c.map)(t.segments,(t=>(t.value&&this.templateSrv.replace(t.value.value,e.scopedVars),t))),isAnnotation:!!t.isAnnotation,display:t.display?this.templateSrv.replace(t.display,e.scopedVars):void 0,refId:t.refId,hide:t.hide,interpolate:t.interpolate||{enable:!1},useLastValue:t.useLastValue||{enable:!1},useUnit:t.useUnit||{enable:!1},recordedValues:t.recordedValues||{enable:!1},digitalStates:t.digitalStates||{enable:!1},webid:null!==(a=t.webid)&&void 0!==a?a:"",regex:t.regex||{enable:!1},expression:t.expression||"",summary:t.summary||{types:[]},startTime:e.range.from,endTime:e.range.to,isPiPoint:!!t.isPiPoint,scopedVars:e.scopedVars};return n.expression&&(n.expression=this.templateSrv.replace(n.expression,e.scopedVars)),void 0!==n.summary.types&&(n.summary.types=(0,c.filter)(n.summary.types,(e=>null!=e&&""!==e))),n})),e}eventFrameToAnnotation(e,t){const a=e.target,n=[],l=Intl.DateTimeFormat().resolvedOptions().locale;return t.forEach((e=>{let t=this.transformDataFrameToMap(e);for(let e=0;eStart: "+new Date(t.time[e]).toLocaleString(l)+"
End: ",t.timeEnd[e]?i+=new Date(t.timeEnd[e]).toLocaleString(l):i+="Eventframe is open";const s={time:t.time[e],timeEnd:a.showEndTime?t.timeEnd[e]:void 0,title:r,id:t.id[e],text:i,tags:["OSISoft PI"]};n.push(s)}})),n}transformDataFrameToMap(e){const t={};return e.fields.forEach((e=>{t[e.name]=e.values.toArray()})),t}restGet(e){const t=this.backendSrv.fetch({url:`/api/datasources/${this.id}/resources${e}`,method:"GET",headers:{"Content-Type":"application/json"}});return(0,W.firstValueFrom)(t).then((e=>e))}getDataServers(){return this.restGet("/dataservers").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getDataServer(e){return e?this.restGet("/dataservers?name="+e).then((e=>e.data)):Promise.resolve({})}getAssetServers(){return this.restGet("/assetservers").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getAssetServer(e){return e?this.restGet("/assetservers?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getDatabase(e){return e?this.restGet("/assetdatabases?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getDatabases(e,t){return e?this.restGet("/assetservers/"+e+"/assetdatabases").then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]})):Promise.resolve([])}getElement(e){return e?this.restGet("/elements?path=\\\\"+e).then((e=>e.data)):Promise.resolve({})}getEventFrameTemplates(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((e=>{var t;return(0,c.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(e=>"EventFrame"===e.InstanceType))})):Promise.resolve([])}getElementTemplates(e){return e?this.restGet("/assetdatabases/"+e+"/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId").then((e=>{var t;return(0,c.filter)(null!==(t=e.data.Items)&&void 0!==t?t:[],(e=>"Element"===e.InstanceType))})):Promise.resolve([])}getAttributes(e,t){let a="?"+(0,c.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/elements/"+e+"/attributes"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getDatabaseElements(e,t){let a="?"+(0,c.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/assetdatabases/"+e+"/elements"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}getElements(e,t){let a="?"+(0,c.map)(t,((e,t)=>t+"="+e)).join("&");return"?"===a&&(a=""),this.restGet("/elements/"+e+"/elements"+a).then((e=>{var t;return null!==(t=e.data.Items)&&void 0!==t?t:[]}))}piPointSearch(e,t){let a=this.templateSrv.replace(t),n=`${a}`,l=!1;if(a!==t){const e=RegExp("\\{(\\w|,)+\\}","gs");let t;for(;null!==(t=e.exec(a));)t.index===e.lastIndex&&e.lastIndex++,t.forEach(((e,t)=>{0===t&&(a=a.replace(e,e.replace("{","(").replace("}",")").replace(",","|")),n=n.replace(e,"*"),l=!0)}))}return this.restGet("/dataservers/"+e+"/points?maxCount=50&nameFilter="+n).then((e=>{var t;return e&&(null===(t=e.data)||void 0===t?void 0:t.Items)?l?e.data.Items.filter((e=>{var t;return null===(t=e.Name)||void 0===t?void 0:t.match(a)})):e.data.Items:[]}))}constructor(e,t=(0,V.getTemplateSrv)(),a=(0,V.getBackendSrv)()){super(e),R(this,"templateSrv",void 0),R(this,"backendSrv",void 0),R(this,"piserver",void 0),R(this,"afserver",void 0),R(this,"afdatabase",void 0),R(this,"piPointConfig",void 0),R(this,"newFormatConfig",void 0),R(this,"useUnitConfig",void 0),R(this,"useExperimental",void 0),R(this,"useStreaming",void 0),this.templateSrv=t,this.backendSrv=a,this.piserver={name:(e.jsonData||{}).piserver,webid:void 0},this.afserver={name:(e.jsonData||{}).afserver,webid:void 0},this.afdatabase={name:(e.jsonData||{}).afdatabase,webid:void 0},this.piPointConfig=e.jsonData.pipoint||!1,this.newFormatConfig=e.jsonData.newFormat||!1,this.useUnitConfig=e.jsonData.useUnit||!1,this.useExperimental=e.jsonData.useExperimental||!1,this.useStreaming=e.jsonData.useStreaming||!1,this.annotations={QueryEditor:q,prepareQuery:e=>(e.target&&(e.target.queryType="Annotation",e.target.isAnnotation=!0),e.target),processEvents:(e,t)=>(0,W.of)(this.eventFrameToAnnotation(e,t))},Promise.all([this.getDataServer(this.piserver.name).then((e=>this.piserver.webid=e.WebId)),this.getAssetServer(this.afserver.name).then((e=>this.afserver.webid=e.WebId)),this.getDatabase(this.afserver.name&&this.afdatabase.name?this.afserver.name+"\\"+this.afdatabase.name:void 0).then((e=>this.afdatabase.webid=e.WebId))])}}const M=new e.DataSourcePlugin(U).setQueryEditor(A).setConfigEditor(m)})(),u})())); //# sourceMappingURL=module.js.map \ No newline at end of file diff --git a/dist/module.js.map b/dist/module.js.map index 127c4ca..b57a9ce 100644 --- a/dist/module.js.map +++ b/dist/module.js.map @@ -1 +1 @@ -{"version":3,"file":"module.js","mappings":";gIAAAA,EAAOC,QAAUC,OCAjBF,EAAOC,QAAUE,OCAjBH,EAAOC,QAAUG,OCAjBJ,EAAOC,QAAUI,QCAjBL,EAAOC,QAAUK,OCAjBN,EAAOC,QAAUM,ICCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA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,OAAOzd,KAAKyW,QAAQ,gBAAkByG,EAAW,kCAAoCM,GAASjY,MAAK,SAACmV,GAAY,MAC9G,OAAMA,GAAyB,QAAb,EAACA,EAAQ3U,YAAI,OAAZ,EAAcgJ,MACxB0O,EAAW/C,EAAQ3U,KAAKgJ,MAAMnE,QAAO,SAAC5F,GAAI,aAAc,QAAd,EAAKA,EAAK6J,YAAI,aAAT,EAAWpG,MAAM8U,EAAQ,IAAI7C,EAAQ3U,KAAKgJ,MAE3F,EACT,GACF,IA3tCF,mFA2tCG,EAlrC4B,CAAS+O,EAAAA,eCpC3BC,GAAS,IAAIC,EAAAA,iBACxBjM,IAECkM,eAAezZ,GACf0Z,gBAAgB/e","sources":["webpack:///external amd \"react\"","webpack:///external amd \"@grafana/ui\"","webpack:///external amd \"@grafana/data\"","webpack:///external amd \"lodash\"","webpack:///external amd \"rxjs\"","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:///./config/ConfigEditor.tsx","webpack:///./components/Forms.tsx","webpack:///./types.ts","webpack:///./components/QueryEditorModeSwitcher.tsx","webpack:///./query/QueryEditor.tsx","webpack:///./helper.ts","webpack:///./query/AnnotationsQueryEditor.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__;","module.exports = __WEBPACK_EXTERNAL_MODULE__6__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { ChangeEvent, PureComponent } from 'react';\nimport { LegacyForms, DataSourceHttpSettings, InlineField, InlineSwitch } from '@grafana/ui';\nimport { DataSourcePluginOptionsEditorProps, DataSourceJsonData, DataSourceSettings } from '@grafana/data';\nimport { PIWebAPIDataSourceJsonData } from '../types';\n\nconst { FormField } = LegacyForms;\n\ninterface Props extends DataSourcePluginOptionsEditorProps {}\n\nconst coerceOptions = (\n options: DataSourceSettings\n): DataSourceSettings => {\n return {\n ...options,\n jsonData: {\n ...options.jsonData,\n url: options.url,\n },\n };\n};\n\ninterface State {}\n\nexport class PIWebAPIConfigEditor extends PureComponent {\n onPIServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFDatabaseChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afdatabase: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onHttpOptionsChange = (options: DataSourceSettings) => {\n const { onOptionsChange } = this.props;\n onOptionsChange(coerceOptions(options));\n };\n\n onPiPointChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.checked ? options.jsonData.piserver : '',\n pipoint: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onNewFormatChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n newFormat: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseUnitChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useUnit: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n render() {\n const { options: originalOptions } = this.props;\n const options = coerceOptions(originalOptions);\n\n return (\n
\n \n\n

Custom Configuration

\n\n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n\n

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, Labels, QueryResultMeta, TimeSeriesPoints } from '@grafana/data';\n\nexport interface PiwebapiElementPath {\n path: string;\n variable: string;\n}\n\nexport interface PiwebapiInternalRsp {\n data: PiwebapiRsp;\n status: number;\n url: string;\n}\n\nexport interface PiwebapTargetRsp {\n refId: string;\n target: string;\n tags: Labels;\n datapoints: TimeSeriesPoints;\n path?: string;\n meta?: QueryResultMeta;\n unit?: string;\n}\n\nexport interface PiwebapiRsp {\n Name?: string;\n InstanceType?: string;\n Items?: PiwebapiRsp[];\n WebId?: string;\n HasChildren?: boolean;\n Type?: string;\n DefaultUnitsName?: string;\n Description?: string;\n Path?: string;\n}\n\nexport interface PiDataServer {\n name: string | undefined;\n webid: string | undefined;\n}\n\nexport interface PIWebAPISelectableValue {\n webId?: string;\n value?: string;\n type?: string;\n expandable?: boolean;\n}\n\nexport interface PIWebAPIAnnotationsQuery extends DataQuery {\n target: string;\n}\n\nexport interface PIWebAPIQuery extends DataQuery {\n target?: string;\n elementPath?: string;\n attributes?: any[];\n segments?: any[];\n isPiPoint?: boolean;\n isAnnotation?: boolean;\n webid?: string;\n webids?: string[];\n display?: any;\n interpolate?: any;\n recordedValues?: any;\n digitalStates?: any;\n useLastValue?: any;\n useUnit?: any;\n regex?: any;\n summary?: any;\n expression?: string;\n rawQuery?: boolean;\n query?: string;\n // annotations items\n database?: PiwebapiRsp;\n template?: PiwebapiRsp;\n showEndTime?: boolean;\n attribute?: any;\n nameFilter?: string;\n categoryName?: string;\n}\n\nexport const defaultQuery: Partial = {\n target: ';',\n attributes: [],\n segments: [],\n regex: { enable: false },\n summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false },\n digitalStates: { enable: false },\n useUnit: { enable: false },\n isPiPoint: false,\n};\n\n/**\n * These are options configured for each DataSource instance\n */\nexport interface PIWebAPIDataSourceJsonData extends DataSourceJsonData {\n url?: string;\n access?: string;\n piserver?: string;\n afserver?: string;\n afdatabase?: string;\n pipoint?: boolean;\n newFormat?: boolean;\n useUnit?: boolean;\n}\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 summaryTypes = filter(this.summaryTypes, (type) => {\n return this.state.summaries.map((s) => s.value?.value).indexOf(type) === -1;\n });\n\n const segments = map(summaryTypes, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n }\n\n // remove a summary from the user interface and the query\n removeSummary(part: SelectableValue) {\n const summaries = filter(this.state.summaries, (item: SelectableValue) => {\n return item !== part;\n });\n this.setState({ summaries });\n }\n // add a new summary to the query\n onSummaryAction(item: SelectableValue) {\n const summaries = this.state.summaries.slice(0) as Array>;\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: true,\n },\n };\n summaries.push(selectableValue);\n }\n this.setState({ summarySegment: {}, summaries }, this.stateCallback);\n }\n\n // remove an attribute from the query\n removeAttribute(part: SelectableValue) {\n const attributes = filter(this.state.attributes, (item: SelectableValue) => {\n return item !== part;\n });\n this.attributeChangeValue(attributes);\n }\n // add an attribute to the query\n onAttributeAction(item: SelectableValue) {\n const { query } = this.props;\n const attributes = this.state.attributes.slice(0);\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: !query.isPiPoint,\n },\n };\n attributes.push(selectableValue);\n }\n this.attributeChangeValue(attributes);\n }\n\n // pi point change event\n onPiPointChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n if (item.label === REMOVE_LABEL) {\n remove(attributes, (value, n) => n === index);\n } else {\n // set current value\n attributes[index] = item;\n }\n\n this.checkPiPointSegments(item, attributes);\n };\n // attribute change event\n onAttributeChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n // ignore if no change\n if (attributes[index].label === item.value?.value) {\n return;\n }\n\n // set current value\n attributes[index] = item;\n\n this.checkAttributeSegments(attributes, this.state.segments);\n };\n // segment change\n onSegmentChange = (item: SelectableValue, index: number) => {\n const { query } = this.props;\n let segments = this.state.segments.slice(0);\n\n // ignore if no change\n if (segments[index].label === item.value?.value) {\n return;\n }\n\n // reset attributes list\n this.setState({ attributes: [] }, () => {\n if (item.label === REMOVE_LABEL) {\n segments = slice(segments, 0, index);\n this.checkAttributeSegments([], segments).then(() => {\n if (segments.length === 0) {\n segments.push({\n label: '',\n });\n } else if (!!segments[segments.length - 1].value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n if (query.isPiPoint) {\n this.piServer = [];\n }\n this.segmentChangeValue(segments);\n });\n return;\n }\n\n // set current value\n segments[index] = item;\n\n // Accept only one PI server\n if (query.isPiPoint) {\n this.piServer.push(item);\n this.segmentChangeValue(segments);\n return;\n }\n\n // changed internal selection\n if (index < segments.length - 1) {\n segments = slice(segments, 0, index + 1);\n }\n this.checkAttributeSegments([], segments).then(() => {\n // add new options\n if (!!item.value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n this.segmentChangeValue(segments);\n });\n });\n };\n\n // get a ui segment for the attributes\n getElementSegments = (\n index: number,\n currentSegment?: Array>\n ): Promise>> => {\n const { datasource, query, data } = this.props;\n const ctrl = this;\n const findQuery = query.isPiPoint\n ? { type: 'dataserver' }\n : {\n path: this.getSegmentPathUpTo(currentSegment ?? this.state.segments.slice(0), index),\n afServerWebId: this.state.segments.length > 0 && this.state.segments[0].value ? this.state.segments[0].value.webId : undefined,\n };\n\n if (!query.isPiPoint) {\n if (datasource.afserver?.name && index === 0) {\n return Promise.resolve([\n {\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n },\n ]);\n }\n if (datasource.afserver?.name && datasource.afdatabase?.name && index === 1) {\n return Promise.resolve([\n {\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n },\n ]);\n }\n }\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n const altSegments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n label: item.text,\n value: {\n webId: item.WebId,\n value: item.text,\n expandable: !query.isPiPoint && item.expandable,\n },\n };\n return selectableValue;\n });\n\n if (altSegments.length === 0) {\n return altSegments;\n }\n\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: 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 segments.push({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\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 return segments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return segments;\n });\n };\n\n // get the list of attributes for the user interface - AF\n getAttributeSegmentsAF = (attributeText?: string): Array> => {\n const ctrl = this;\n let segments: Array> = [];\n\n segments.push({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n forOwn(ctrl.availableAttributes, (val: any, key: string) => {\n let selectableValue: SelectableValue = {\n label: key,\n value: {\n value: key,\n expandable: true,\n },\n };\n segments.push(selectableValue);\n });\n\n return segments;\n };\n\n // build data from target string\n buildFromTarget = (\n query: PIWebAPIQuery,\n segmentsArray: Array>,\n attributesArray: Array>\n ) => {\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segmentsArray.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, (item, _) => {\n if (item !== '') {\n // set current value\n attributesArray.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n return this.getElementSegments(splitElements.length + 1, segmentsArray).then((elements) => {\n if (elements.length > 0) {\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return segmentsArray;\n });\n }\n return Promise.resolve(segmentsArray);\n };\n\n /**\n * Gets the segment information and parses it to a string.\n *\n * @param {any} index - Last index of segment to use.\n * @returns - AF Path or PI Point name.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSegmentPathUpTo(segments: Array>, index: number): string {\n const arr = segments.slice(0, index);\n\n return reduce(\n arr,\n (result: any, segment: SelectableValue) => {\n if (!segment.value) {\n return '';\n }\n if (!segment.value.value?.startsWith('-Select')) {\n return result ? result + '\\\\' + segment.value.value : segment.value.value;\n }\n return result;\n },\n ''\n );\n }\n\n /**\n * Get the current AF Element's child attributes. Validates when the element selection changes.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAttributeSegments(\n attributes: Array>,\n segments: Array>\n ): Promise {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: this.getSegmentPathUpTo(segments.slice(0), segments.length),\n type: 'attributes',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: false }))\n .then((attributesResponse: any) => {\n const validAttributes: any = {};\n\n each(attributesResponse, (attribute: any) => {\n validAttributes[attribute.Path.substring(attribute.Path.indexOf('|') + 1)] = attribute.WebId;\n });\n\n const filteredAttributes = filter(attributes, (attrib: SelectableValue) => {\n const changedValue = datasource.templateSrv.replace(attrib.value?.value);\n return validAttributes[changedValue] !== undefined;\n });\n\n ctrl.availableAttributes = validAttributes;\n 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 each(splitAttributes, function (item, index) {\n if (item !== '') {\n attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n this.getElementSegments(splitElements.length + 1, segments)\n .then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n })\n .then(() => {\n this.updateArray(segments, attributes, this.state.summaries, query.isPiPoint!, () => {\n onChange({ ...query, query: undefined, rawQuery: false });\n });\n });\n } else {\n segments = this.checkAfServer();\n this.updateArray(segments, this.state.attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n }\n }\n\n /**\n * Check if the AF server and database are configured in the datasoure config.\n *\n * @returns the segments array\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAfServer = () => {\n const { datasource } = this.props;\n const segmentsArray = [];\n if (datasource.afserver?.name) {\n segmentsArray.push({\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n });\n if (datasource.afdatabase?.name) {\n segmentsArray.push({\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n });\n }\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n } else {\n segmentsArray.push({\n label: '',\n });\n }\n return segmentsArray;\n };\n\n /**\n * Update the internal state of the datasource.\n *\n * @param segmentsArray the segments array to update\n * @param attributesArray the AF attributes array to update\n * @param summariesArray the summaries array to update\n * @param isPiPoint the is PI point flag\n * @param cb optional callback function\n *\n * @memberOf PIWebAPIQueryEditor\n */\n updateArray = (\n segmentsArray: Array>,\n attributesArray: Array>,\n summariesArray: Array>,\n isPiPoint: boolean,\n cb?: (() => void) | undefined\n ) => {\n this.setState(\n {\n segments: segmentsArray,\n attributes: attributesArray,\n summaries: summariesArray,\n isPiPoint,\n },\n () => {\n if (!isPiPoint) {\n this.checkAttributeSegments(attributesArray, this.state.segments).then(() => {\n if (cb) {\n cb();\n }\n });\n }\n }\n );\n };\n\n // React action when component is initialized/updated\n scopedVarsDone = false;\n componentDidMount = () => {\n this.initialLoad(false);\n };\n\n componentDidUpdate = () => {\n const { query } = this.props;\n if (this.props.data?.state === 'Done' && !!this.props.data?.request?.scopedVars && !this.scopedVarsDone) {\n this.scopedVarsDone = true;\n this.initialLoad(!query.isPiPoint);\n }\n };\n\n initialLoad = (force: boolean) => {\n const { query } = this.props;\n const metricsQuery = defaults(query, defaultQuery) as PIWebAPIQuery;\n const { segments, attributes, summary, isPiPoint } = metricsQuery;\n\n let segmentsArray: Array> = force ? [] : segments?.slice(0) ?? [];\n let attributesArray: Array> = force ? [] : attributes?.slice(0) ?? [];\n let summariesArray = summary?.types ?? [];\n\n if (!isPiPoint && segmentsArray.length === 0) {\n if (query.target && query.target.length > 0 && query.target !== ';') {\n attributesArray = [];\n // Build query from target\n this.buildFromTarget(query, segmentsArray, attributesArray)\n .then((_segmentsArray) => {\n this.updateArray(_segmentsArray, attributesArray, summariesArray, false);\n })\n .catch((e) => console.error(e));\n return;\n } else {\n segmentsArray = this.checkAfServer();\n }\n } else if (isPiPoint && segmentsArray.length > 0) {\n this.piServer = segmentsArray;\n }\n this.updateArray(segmentsArray, attributesArray, summariesArray, !!isPiPoint, () => {\n this.onChange(query);\n });\n };\n\n onChange = (query: PIWebAPIQuery) => {\n const { onChange, onRunQuery } = this.props;\n\n query.summary.types = this.state.summaries;\n if (query.rawQuery) {\n query.target = query.query ?? '';\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) {\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 useUnit,\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 {this.props.datasource.useUnitConfig && (\n \n \n this.onChange({\n ...metricsQuery,\n useUnit: { ...useUnit, enable: !useUnit.enable },\n })\n }\n />\n \n )}\n \n\n \n \n ) =>\n onChange({ ...metricsQuery, expression: event.target.value })\n }\n placeholder=\"'.'*2\"\n />\n \n \n\n {!useLastValue.enable && (\n <>\n \n \n ) =>\n onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, maxNumber: parseInt(event.target.value, 10) },\n })\n }\n type=\"number\"\n placeholder=\"1000\"\n />\n \n \n \n this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable },\n })\n }\n />\n \n \n \n this.onChange({\n ...metricsQuery,\n digitalStates: { ...digitalStates, enable: !digitalStates.enable },\n })\n }\n />\n \n \n\n \n \n ) =>\n onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable } })\n }\n />\n \n \n }\n 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 onChange({ ...metricsQuery, display: event.target.value })\n }\n placeholder=\"Display\"\n />\n \n \n {\n this.onChange({ ...metricsQuery, regex: { ...regex, enable: !regex.enable } });\n }}\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, search: event.target.value } })\n }\n placeholder=\"(.*)\"\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, replace: event.target.value } })\n }\n placeholder=\"$1\"\n />\n \n \n \n );\n }\n}\n","import { each, map } from 'lodash';\r\n\r\nimport {\r\n DataFrame,\r\n FieldConfig,\r\n TimeSeries,\r\n FieldType,\r\n TimeSeriesValue,\r\n TIME_SERIES_VALUE_FIELD_NAME,\r\n TIME_SERIES_TIME_FIELD_NAME,\r\n ArrayVector,\r\n TableData,\r\n MetricFindValue,\r\n} from '@grafana/data';\r\nimport { PiwebapiElementPath, PiwebapiRsp } from 'types';\r\n\r\nexport function parseRawQuery(tr: string): any {\r\n const splitAttributes = tr.split(';');\r\n const splitElements = splitAttributes[0].split('\\\\');\r\n\r\n // remove element hierarchy from attribute collection\r\n splitAttributes.splice(0, 1);\r\n\r\n let attributes: any[] = [];\r\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\r\n const elementPath: string = splitElements.join('\\\\');\r\n each(splitAttributes, function (item, index) {\r\n if (item !== '') {\r\n attributes.push({\r\n label: item,\r\n value: {\r\n value: item,\r\n expandable: false,\r\n },\r\n });\r\n }\r\n });\r\n\r\n return { attributes, elementPath };\r\n }\r\n\r\n return { attributes, elementPath: null };\r\n}\r\n\r\nexport function lowerCaseFirstLetter(string: string): string {\r\n return string.charAt(0).toLocaleLowerCase() + string.slice(1);\r\n}\r\n\r\nexport function convertTimeSeriesToDataFrame(timeSeries: TimeSeries): DataFrame {\r\n const times: number[] = [];\r\n const values: TimeSeriesValue[] = [];\r\n\r\n // Sometimes the points are sent as datapoints\r\n const points = timeSeries.datapoints;\r\n for (const point of points) {\r\n values.push(point[0]);\r\n times.push(point[1] as number);\r\n }\r\n\r\n const fields = [\r\n {\r\n name: TIME_SERIES_TIME_FIELD_NAME,\r\n type: FieldType.time,\r\n config: {},\r\n values: new ArrayVector(times),\r\n },\r\n {\r\n name: timeSeries.target ?? TIME_SERIES_VALUE_FIELD_NAME,\r\n type: FieldType.number,\r\n config: {\r\n unit: timeSeries.unit,\r\n },\r\n values: new ArrayVector(values),\r\n labels: timeSeries.tags,\r\n },\r\n ];\r\n\r\n if (timeSeries.title) {\r\n (fields[1].config as FieldConfig).displayNameFromDS = timeSeries.title;\r\n }\r\n\r\n return {\r\n name: '',\r\n refId: timeSeries.refId,\r\n meta: timeSeries.meta,\r\n fields,\r\n length: values.length,\r\n };\r\n}\r\n\r\n/**\r\n * Builds the Grafana metric segment for use on the query user interface.\r\n *\r\n * @param {any} response - response from PI Web API.\r\n * @returns - Grafana metric segment.\r\n *\r\n * @memberOf PiWebApiDatasource\r\n */\r\nexport function metricQueryTransform(response: PiwebapiRsp[]): MetricFindValue[] {\r\n return map(response, (item) => {\r\n return {\r\n text: item.Name,\r\n expandable:\r\n item.HasChildren === undefined || item.HasChildren === true || (item.Path ?? '').split('\\\\').length <= 3,\r\n HasChildren: item.HasChildren,\r\n Items: item.Items ?? [],\r\n Path: item.Path,\r\n WebId: item.WebId,\r\n } as MetricFindValue;\r\n });\r\n}\r\n\r\n/**\r\n * Check if all items are selected.\r\n *\r\n * @param {any} current the current variable selection\r\n * @return {boolean} true if all value is selected, false otherwise\r\n */\r\nexport function isAllSelected(current: any): boolean {\r\n if (!current) {\r\n return false;\r\n }\r\n if (Array.isArray(current.text)) {\r\n return current.text.indexOf('All') >= 0;\r\n }\r\n return current.text === 'All';\r\n}\r\n\r\nexport function convertToTableData(items: any[], valueData?: any[]): TableData[] {\r\n // convert to TableData\r\n const response: TableData[] = items.map((item: any, index: number) => {\r\n const columns = [{ text: 'StartTime' }, { text: 'EndTime' }];\r\n const rows = [item.StartTime, item.EndTime];\r\n if (valueData) {\r\n valueData[index].Content.Items.forEach((it: any) => {\r\n columns.push({ text: it.Name });\r\n rows.push(String(it.Value.Value ? it.Value.Value.Name || it.Value.Value.Value || it.Value.Value : ''));\r\n });\r\n }\r\n return {\r\n name: item.Name,\r\n columns,\r\n rows: [rows],\r\n };\r\n });\r\n return response;\r\n}\r\n\r\n/**\r\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\r\n *\r\n * @param {any} item - 'Item' object from PIWebAPI\r\n * @param {any} noDataReplacementMode - String state of how to replace 'No Data'\r\n * @param {any} grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns perviousValue - {any} Grafana value (value only).\r\n *\r\n */\r\nexport function noDataReplace(\r\n item: any,\r\n noDataReplacementMode: any,\r\n grafanaDataPoint: any[]\r\n): {\r\n grafanaDataPoint: any[];\r\n previousValue: any;\r\n drop: boolean;\r\n} {\r\n let previousValue = null;\r\n let drop = false;\r\n if (!item.Good || item.Value === 'No Data' || (item.Value?.Name && item.Value?.Name === 'No Data')) {\r\n if (noDataReplacementMode === 'Drop') {\r\n drop = true;\r\n } else if (noDataReplacementMode === '0') {\r\n grafanaDataPoint[0] = 0;\r\n } else if (noDataReplacementMode === 'Keep') {\r\n // Do nothing keep\r\n } else if (noDataReplacementMode === 'Null') {\r\n grafanaDataPoint[0] = null;\r\n } else if (noDataReplacementMode === 'Previous' && previousValue !== null) {\r\n grafanaDataPoint[0] = previousValue;\r\n }\r\n } else {\r\n previousValue = item.Value;\r\n }\r\n return { grafanaDataPoint, previousValue, drop };\r\n}\r\n\r\n/**\r\n * Check if the value is a number.\r\n *\r\n * @param {any} number the value to check\r\n * @returns {boolean} true if the value is a number, false otherwise\r\n */\r\nexport function checkNumber(number: any): boolean {\r\n return typeof number === 'number' && !Number.isNaN(number) && Number.isFinite(number);\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path.\r\n *\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getLastPath(path: string): string {\r\n let splitPath = path.split('|');\r\n if (splitPath.length === 0) {\r\n return '';\r\n }\r\n splitPath = splitPath[0].split('\\\\');\r\n return splitPath.length === 0 ? '' : splitPath.pop() ?? '';\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path plus variable.\r\n *\r\n * @param {PiwebapiElementPath[]} elementPathArray array of element paths\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getPath(elementPathArray: PiwebapiElementPath[], path: string): string {\r\n if (!path || elementPathArray.length === 0) {\r\n return '';\r\n }\r\n const splitStr = getLastPath(path);\r\n const foundElement = elementPathArray.find((e) => path.indexOf(e.path) >= 0)?.variable;\r\n return foundElement ? foundElement + '|' + splitStr : splitStr;\r\n}\r\n\r\n/**\r\n * Replace calculation dot in expression with PI point name.\r\n *\r\n * @param {boolean} replace - is pi point and calculation.\r\n * @param {PiwebapiRsp} webid - Pi web api response object.\r\n * @param {string} url - original url.\r\n * @returns Modified url\r\n */\r\nexport function getFinalUrl(replace: boolean, webid: PiwebapiRsp, url: string) {\r\n const newUrl = replace ? url.replace(/'\\.'/g, `'${webid.Name}'`) : url;\r\n return newUrl;\r\n}\r\n","import React, { memo, useState } from 'react';\n\nimport { AnnotationQuery, QueryEditorProps, SelectableValue } from '@grafana/data';\nimport { AsyncSelect, InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';\n\nimport { PiWebAPIDatasource } from 'datasource';\nimport { PIWebAPIDataSourceJsonData, PIWebAPIQuery, PiwebapiRsp } from 'types';\n\nconst SMALL_LABEL_WIDTH = 20;\nconst LABEL_WIDTH = 30;\nconst MIN_INPUT_WIDTH = 50;\n\ntype PiWebAPIQueryEditorProps = QueryEditorProps;\n\ntype Props = PiWebAPIQueryEditorProps & {\n annotation?: AnnotationQuery;\n onAnnotationChange?: (annotation: AnnotationQuery) => void;\n};\n\nexport const PiWebAPIAnnotationsQueryEditor = memo(function PiWebAPIAnnotationQueryEditor(props: Props) {\n const { query, datasource, annotation, onChange, onRunQuery } = props;\n\n const [afWebId, setAfWebId] = useState('');\n const [database, setDatabase] = useState(annotation?.target?.database ?? {});\n\n // this should never happen, but we want to keep typescript happy\n if (annotation === undefined) {\n return null;\n }\n\n const getEventFrames = (): Promise>> => {\n return datasource.getEventFrameTemplates(database?.WebId!).then((templ: PiwebapiRsp[]) => {\n return templ.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getDatabases = (): Promise>> => {\n return datasource.getDatabases(afWebId).then((dbs: PiwebapiRsp[]) => {\n return dbs.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getValue = (key: string) => {\n const query: any = annotation.target as any;\n if (!query || !query[key]) {\n return;\n }\n return { label: query[key].Name, value: query[key] };\n };\n\n datasource.getAssetServer(datasource.afserver.name).then((result) => {\n setAfWebId(result.WebId!);\n });\n\n return (\n <>\n
\n \n \n {\n setDatabase(e.value);\n onChange({ ...query, database: e.value, template: undefined });\n }}\n defaultOptions\n />\n \n \n onChange({ ...query, template: e.value })}\n defaultOptions\n />\n \n \n onChange({ ...query, showEndTime: e.currentTarget.checked })}\n />\n \n \n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, categoryName: e.currentTarget.value })}\n placeholder=\"Enter category name\"\n />\n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, nameFilter: e.currentTarget.value })}\n placeholder=\"Enter name filter\"\n />\n \n \n \n \n \n onChange({\n ...query,\n regex: { ...query.regex, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, search: e.currentTarget.value },\n })\n }\n placeholder=\"(.*)\"\n width={MIN_INPUT_WIDTH}\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, replace: e.currentTarget.value },\n })\n }\n placeholder=\"$1\"\n />\n \n \n \n \n \n onChange({\n ...query!,\n attribute: { ...query.attribute, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query!,\n attribute: { ...query.attribute, name: e.currentTarget.value },\n })\n }\n placeholder=\"Enter name\"\n />\n \n \n
\n \n );\n});\n","import { each, filter, flatten, forOwn, groupBy, keys, map, uniq, omitBy } from 'lodash';\nimport { Observable, of } from 'rxjs';\n\nimport {\n DataQueryRequest,\n DataQueryResponse,\n DataSourceApi,\n DataSourceInstanceSettings,\n AnnotationEvent,\n MetricFindValue,\n Labels,\n AnnotationQuery,\n DataFrame,\n toDataFrame,\n} from '@grafana/data';\nimport { BackendSrv, getBackendSrv, getTemplateSrv, TemplateSrv } from '@grafana/runtime';\n\nimport {\n PIWebAPIQuery,\n PIWebAPIDataSourceJsonData,\n PiDataServer,\n PiwebapTargetRsp,\n PiwebapiElementPath,\n PiwebapiInternalRsp,\n PiwebapiRsp,\n} from './types';\nimport {\n checkNumber,\n convertTimeSeriesToDataFrame,\n convertToTableData,\n getFinalUrl,\n getLastPath,\n getPath,\n isAllSelected,\n lowerCaseFirstLetter,\n metricQueryTransform,\n noDataReplace,\n parseRawQuery,\n} from 'helper';\n\nimport { PiWebAPIAnnotationsQueryEditor } from 'query/AnnotationsQueryEditor';\n\nexport class PiWebAPIDatasource extends DataSourceApi {\n piserver: PiDataServer;\n afserver: PiDataServer;\n afdatabase: PiDataServer;\n piPointConfig: boolean;\n newFormatConfig: boolean;\n useUnitConfig: boolean;\n\n url: string;\n name: string;\n isProxy = false;\n\n piwebapiurl?: string;\n webidCache: Map = new Map();\n\n error: any;\n\n constructor(\n instanceSettings: DataSourceInstanceSettings,\n readonly templateSrv: TemplateSrv = getTemplateSrv(),\n private readonly backendSrv: BackendSrv = getBackendSrv()\n ) {\n super(instanceSettings);\n\n this.url = instanceSettings.url!;\n this.name = instanceSettings.name;\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 this.newFormatConfig = instanceSettings.jsonData.newFormat || false;\n this.useUnitConfig = instanceSettings.jsonData.useUnit || false;\n\n this.annotations = {\n QueryEditor: PiWebAPIAnnotationsQueryEditor,\n prepareQuery(anno: AnnotationQuery): PIWebAPIQuery | undefined {\n if (anno.target) {\n anno.target.isAnnotation = true;\n }\n return anno.target;\n },\n processEvents: (\n anno: AnnotationQuery,\n data: DataFrame[]\n ): Observable => {\n return of(this.eventFrameToAnnotation(anno, data));\n },\n };\n\n Promise.all([\n this.getDataServer(this.piserver.name).then((result: PiwebapiRsp) => (this.piserver.webid = result.WebId)),\n this.getAssetServer(this.afserver.name).then((result: PiwebapiRsp) => (this.afserver.webid = result.WebId)),\n this.getDatabase(\n this.afserver.name && this.afdatabase.name ? this.afserver.name + '\\\\' + this.afdatabase.name : undefined\n ).then((result: PiwebapiRsp) => (this.afdatabase.webid = result.WebId)),\n ]);\n }\n\n /**\n * 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 if (options.targets.length === 1 && !!options.targets[0].isAnnotation) {\n return this.processAnnotationQuery(options);\n }\n\n const query = this.buildQueryParameters(options);\n\n if (query.targets.length <= 0) {\n return Promise.resolve({ data: [] });\n } else {\n return Promise.all(this.getStream(query)).then((targetResponses) => {\n let flattened: PiwebapTargetRsp[] = [];\n each(targetResponses, (tr) => {\n each(tr, (item) => flattened.push(item));\n });\n flattened = flattened.filter((v) => v.datapoints.length > 0);\n // handle no data properly\n if (flattened.length === 0) {\n return { data: [] };\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) => convertTimeSeriesToDataFrame(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 < 300) {\n return { status: 'success', message: 'Data source is working', title: 'Success' };\n }\n throw new Error('Failed');\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 {\n query.path = this.templateSrv.replace(query.path, queryOptions); // replace variables in the path\n query.path = query.path.split(';')[0]; // if the attribute is in the path, let's remote it\n if (query.type !== 'attributes') {\n query.type = querydepth[Math.max(0, Math.min(query.path.split('\\\\').length, querydepth.length - 1))];\n }\n }\n query.path = query.path.replace(/\\{([^\\\\])*\\}/gi, (r: string) => r.substring(1, r.length - 2).split(',')[0]);\n }\n\n query.filter = query.filter ?? '*';\n\n if (query.type === 'servers') {\n return ds.afserver?.name\n ? ds\n .getAssetServer(ds.afserver.name)\n .then((result: PiwebapiRsp) => [result])\n .then(metricQueryTransform)\n : ds.getAssetServers().then(metricQueryTransform);\n } else if (query.type === 'databases' && !!query.afServerWebId) {\n return ds.getDatabases(query.afServerWebId, {}).then(metricQueryTransform);\n } else if (query.type === 'databases') {\n return ds\n .getAssetServer(query.path)\n .then((server) => ds.getDatabases(server.WebId ?? '', {}))\n .then(metricQueryTransform);\n } else if (query.type === 'databaseElements') {\n return ds\n .getDatabase(query.path)\n .then((db) =>\n ds.getDatabaseElements(db.WebId ?? '', {\n selectedFields: 'Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'elements') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getElements(element.WebId ?? '', {\n selectedFields:\n 'Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n nameFilter: query.filter,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'attributes') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getAttributes(element.WebId ?? '', {\n searchFullHierarchy: 'true',\n selectedFields:\n 'Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path',\n nameFilter: query.filter,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'dataserver') {\n return ds.getDataServers().then(metricQueryTransform);\n } else if (query.type === 'pipoint') {\n return ds.piPointSearch(query.webId, query.pointName).then(metricQueryTransform);\n }\n return Promise.reject('Bad type');\n }\n\n /**\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 * 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 private processAnnotationQuery(options: DataQueryRequest): Promise {\n const annotationQuery = options.targets[0];\n\n const categoryName = annotationQuery.categoryName\n ? this.templateSrv.replace(annotationQuery.categoryName, options.scopedVars, 'glob')\n : null;\n const nameFilter = annotationQuery.nameFilter\n ? this.templateSrv.replace(annotationQuery.nameFilter, options.scopedVars, 'glob')\n : null;\n const templateName = annotationQuery.template ? annotationQuery.template.Name : null;\n const annotationOptions = {\n datasource: annotationQuery.datasource,\n showEndTime: annotationQuery.showEndTime,\n regex: annotationQuery.regex,\n attribute: annotationQuery.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({ data: [] });\n }\n filter.push('startTime=' + options.range.from.toISOString());\n filter.push('endTime=' + options.range.to.toISOString());\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 && annotationOptions.attribute.name.trim().length > 0) {\n resourceUrl += '&nameFilter=' + annotationOptions.attribute.name.trim();\n }\n const query: any = {\n '1': {\n Method: 'GET',\n Resource:\n this.piwebapiurl +\n '/assetdatabases/' +\n annotationQuery.database?.WebId +\n '/eventframes?' +\n filter.join('&'),\n },\n '2': {\n Method: 'GET',\n RequestTemplate: {\n Resource: resourceUrl,\n },\n Parameters: ['$.1.Content.Items[*].WebId'],\n ParentIds: ['1'],\n },\n };\n return this.restBatch(query).then((result) => {\n const data = result.data['1'].Content;\n const valueData = result.data['2'].Content;\n return {\n data: convertToTableData(data.Items!, valueData.Items).map((r) => toDataFrame(r)),\n };\n });\n } else {\n return this.restGet(\n '/assetdatabases/' + annotationQuery.database?.WebId + '/eventframes?' + filter.join('&')\n ).then((result) => {\n return {\n data: convertToTableData(result.data.Items!).map((r) => toDataFrame(r)),\n };\n });\n }\n }\n\n /**\n * Converts a PIWebAPI Event Frame response to a Grafana Annotation\n *\n * @param {any} annon - The annotation object.\n * @param {any} data - The dataframe recrords.\n * @returns - Grafana Annotation\n *\n * @memberOf PiWebApiDatasource\n */\n private eventFrameToAnnotation(annon: AnnotationQuery, data: DataFrame[]): AnnotationEvent[] {\n const annotationOptions = annon.target!;\n const events: AnnotationEvent[] = [];\n data.forEach((d: DataFrame) => {\n let attributeText = '';\n let name = d.name!;\n const endTime = d.fields.find((f) => f.name === 'EndTime')?.values.get(0);\n const startTime = d.fields.find((f) => f.name === 'StartTime')?.values.get(0);\n // check if we have more attributes in the table data\n const attributeDataItems = d.fields.filter((f) => ['StartTime', 'EndTime'].indexOf(f.name) < 0);\n if (attributeDataItems) {\n each(attributeDataItems, (attributeData) => {\n attributeText += '
' + attributeData.name + ': ' + attributeData.values.get(0);\n });\n }\n // replace Dataframe name using Regex\n if (annotationOptions.regex && annotationOptions.regex.enable) {\n name = name.replace(new RegExp(annotationOptions.regex.search), annotationOptions.regex.replace);\n }\n // create the event\n events.push({\n id: annotationOptions.database?.WebId,\n annotation: annon,\n title: `Name: ${annon.name}`,\n time: new Date(startTime).getTime(),\n timeEnd: !!annotationOptions.showEndTime ? new Date(endTime).getTime() : undefined,\n text:\n `Tag: ${name}` +\n attributeText +\n '
Start: ' +\n new Date(startTime).toLocaleString('pt-BR') +\n '
End: ' +\n new Date(endTime).toLocaleString('pt-BR'),\n tags: ['OSISoft PI'],\n });\n });\n return events;\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 || !!target.hide) {\n return false;\n }\n return !target.target.startsWith('Select AF');\n });\n\n options.targets = map(options.targets, (target) => {\n if (!!target.rawQuery && !!target.target) {\n const { attributes, elementPath } = parseRawQuery(this.templateSrv.replace(target.target, options.scopedVars));\n target.attributes = attributes;\n target.elementPath = elementPath;\n }\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 isAnnotation: !!target.isAnnotation,\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 useUnit: target.useUnit || { 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 (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-z 0-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 * 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, isSummary, datapoints);\n });\n } else {\n this.piPointValue(value, target, isSummary, 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 } = 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 [checkNumber(num) ? Number(num) : num.trim(), new Date(value.Timestamp).getTime()];\n }\n\n return [checkNumber(num) ? Number(num) : num.trim(), new Date(value.Timestamp).getTime()];\n }\n\n /**\n * Convert the Pi web api response object to the Grafana Labels object.\n *\n * @param {PiwebapiRsp} webid - Pi web api response object.\n * @returns The converted Labels object.\n */\n private toTags(webid: PiwebapiRsp, isPiPoint: boolean): Labels {\n const omitArray = ['Path', 'WebId', 'Id', 'ServerTime', 'ServerVersion'];\n const obj = omitBy(webid, (value: any, key: string) => !value || !value.length || omitArray.indexOf(key) >= 0);\n obj.Element = isPiPoint ? this.piserver.name : getLastPath(webid.Path ?? '');\n const sorted = Object.keys(obj)\n .sort()\n .reduce((accumulator: any, key: string) => {\n accumulator[lowerCaseFirstLetter(key)] = obj[key];\n return accumulator;\n }, {});\n return sorted as Labels;\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(\n content: any,\n target: any,\n name: any,\n noTemplate: boolean,\n webid: PiwebapiRsp\n ): PiwebapTargetRsp[] {\n const api = this;\n const isSummary: boolean = target.summary && target.summary.types && target.summary.types.length > 0;\n if (!target.isPiPoint && !target.display && content.Path) {\n if (api.newFormatConfig) {\n name = (noTemplate ? getLastPath(content.Path) : getPath(target.elementPathArray, content.Path)) + '|' + name;\n } else {\n name = noTemplate ? name : getPath(target.elementPathArray, content.Path) + '|' + name;\n }\n }\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: PiwebapTargetRsp[] = [];\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 meta: {\n path: webid.Path,\n pathSeparator: '\\\\',\n },\n tags: api.newFormatConfig ? api.toTags(webid, target.isPiPoint) : {},\n datapoints: api.parsePiPointValueData(value, target, isSummary),\n path: webid.Path,\n unit: api.useUnitConfig && target.useUnit.enable ? webid.DefaultUnitsName : undefined,\n });\n });\n return innerResults;\n }\n const results: PiwebapTargetRsp[] = [\n {\n refId: target.refId,\n target: name,\n meta: {\n path: webid.Path,\n pathSeparator: '\\\\',\n },\n tags: api.newFormatConfig ? api.toTags(webid, target.isPiPoint) : {},\n datapoints: api.parsePiPointValueData(content.Items || content.Value, target, isSummary),\n path: webid.Path,\n unit: api.useUnitConfig && target.useUnit.enable ? webid.DefaultUnitsName : undefined,\n },\n ];\n return results;\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-z 0-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-z 0-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 * 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 const isRecorded = target.recordedValues && target.recordedValues.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 (target.useLastValue?.enable) {\n url += '/times?&time=' + query.range.to.toJSON();\n } else if (isSummary) {\n url += '/summary' + timeRange + (isInterpolated ? '&sampleType=Interval&sampleInterval=' + intervalTime : '');\n } else if (isInterpolated) {\n url += '/intervals' + timeRange + '&sampleInterval=' + intervalTime;\n } else if (isRecorded) {\n url += '/recorded' + timeRange;\n } else {\n const windowWidth = 40;\n const diff = Math.floor((query.range.to.valueOf() - query.range.from.valueOf()) / windowWidth);\n let timeQuery = 'time=' + query.range.from.toJSON();\n for (let i = 1; i < windowWidth; i ++) {\n const newTime = query.range.from.valueOf() + i * diff;\n timeQuery += '&time=' + new Date(newTime).toISOString();\n }\n timeQuery += '&time=' + query.range.to.toJSON();\n url += '/times?' + timeQuery;\n }\n url += '&expression=' + encodeURIComponent(target.expression.replace(/\\${intervalTime}/g, intervalTime));\n if (target.attributes.length > 0) {\n results.push(ds.createBatchGetWebId(target, url, displayName));\n } else {\n results.push(\n ds.restGetWebId(target.elementPath, false).then((webidresponse: PiwebapiRsp) => {\n return ds\n .restPost(url + '&webId=' + webidresponse.WebId)\n .then((response: any) =>\n ds.processResults(response.data, target, displayName || targetName, false, webidresponse)\n )\n .catch((err: any) => (ds.error = err));\n })\n );\n }\n } else {\n url += '/streamsets';\n if (target.useLastValue?.enable) {\n url += '/value?time=' + query.range.to.toJSON();\n } else if (isSummary) {\n url += '/summary' + timeRange + '&intervals=' + query.maxDataPoints + this.getSummaryUrl(target.summary);\n } else if (isInterpolated) {\n url += '/interpolated' + timeRange + '&interval=' + intervalTime;\n } else if (isRecorded) {\n const maxNumber =\n target.recordedValues.maxNumber && !isNaN(target.recordedValues.maxNumber)\n ? target.recordedValues.maxNumber\n : query.maxDataPoints;\n url += '/recorded' + timeRange + '&maxCount=' + maxNumber;\n } else {\n url += '/plot' + timeRange + '&intervals=' + query.maxDataPoints;\n }\n results.push(ds.createBatchGetWebId(target, url, displayName));\n }\n });\n\n return results;\n }\n\n /**\n * Process batch response to metric data.\n *\n * @param {any} response - The batch response.\n * @param {any} target - Grafana query target.\n * @param {string} displayName - The display name.\n * @returns - Process metric data.\n */\n private handleBatchResponse(response: any, target: any, displayName: string | null): Promise {\n const targetName = target.expression || target.elementPath;\n const noTemplate = target.elementPathArray.length === 1 && target.elementPath === target.elementPathArray[0].path;\n const totalSize = noTemplate ? target.attributes.length : target.elementPathArray.length;\n const targetResults: PiwebapTargetRsp[] = [];\n for (let index = 1; index <= totalSize; index++) {\n const dataKey = `Req${index + 1000}`;\n const path = response.config.data[dataKey].Headers ? response.config.data[dataKey].Headers['Asset-Path'] : null;\n const data = response.data[dataKey];\n if (data.Status >= 400) {\n continue;\n }\n\n let webid: PiwebapiRsp;\n if (!!path) {\n webid = this.webidCache.get(path);\n } else {\n const respData = response.data[`Req${index}`].Content;\n webid = {\n Path: respData.Path!,\n Type: respData.Type || respData.PointType,\n DefaultUnitsName: respData.DefaultUnitsName || respData.EngineeringUnits,\n Description: respData.Description || respData.Descriptor,\n WebId: respData.WebId,\n Name: respData.Name,\n };\n this.webidCache.set(webid.Path!, webid);\n }\n\n if (target.expression) {\n each(\n this.processResults(data.Content, target, displayName || webid.Name || targetName, noTemplate, webid),\n (targetResult) => targetResults.push(targetResult)\n );\n } else {\n each(data.Content.Items, (item) => {\n each(\n this.processResults(item, target, displayName || item.Name || targetName, noTemplate, webid),\n (targetResult) => targetResults.push(targetResult)\n );\n });\n }\n }\n return Promise.resolve(targetResults);\n }\n\n /**\n * Creates a batch query pair.\n *\n * @param {boolean} isPiPoint - is Pi point flag.\n * @param {string} elementPath - the PI element path or PI Data server name.\n * @param {string} attribute - the attribute or PI point name.\n * @param {any} query - the batch query to build.\n * @param {number} index - the current query index.\n * @param {boolean} replace - is pi point and calculation.\n * @param {string} url - the base url to call.\n */\n private createQueryPair(\n isPiPoint: boolean,\n elementPath: string,\n attribute: string,\n query: any,\n index: number,\n replace: boolean,\n url: string\n ) {\n let path = '';\n let assetPath = '';\n if (isPiPoint) {\n assetPath = '\\\\\\\\' + elementPath + '\\\\' + attribute;\n path = '/points?selectedFields=Descriptor%3BPointType%3BEngineeringUnits%3BWebId%3BName%3BPath&path=' + assetPath;\n } else {\n assetPath = '\\\\\\\\' + elementPath + '|' + attribute;\n path = '/attributes?selectedFields=Type%3BDefaultUnitsName%3BDescription%3BWebId%3BName%3BPath&path=' + assetPath;\n }\n\n const data = this.webidCache.get(assetPath);\n if (!!data) {\n query[`Req${index + 1000}`] = {\n Method: 'GET',\n Resource:\n this.piwebapiurl +\n getFinalUrl(replace, { Name: attribute }, url) +\n '&webId=' +\n (replace ? this.piserver.webid : data.WebId),\n Headers: {\n 'Asset-Path': assetPath,\n },\n };\n } else {\n query[`Req${index}`] = {\n Method: 'GET',\n Resource: this.piwebapiurl + path,\n };\n query[`Req${index + 1000}`] = {\n Method: 'GET',\n ParentIds: [`Req${index}`],\n Parameters: [`$.Req${index}.Content.WebId`],\n Resource:\n this.piwebapiurl +\n getFinalUrl(replace, { Name: attribute }, url) +\n (replace ? '&webId=' + this.piserver.webid : '&webId={0}'),\n };\n }\n }\n\n /**\n * Get metric data using Batch.\n *\n * @param {any} target - Grafana query target.\n * @param {string} url The base URL for the query.\n * @param {string} displayName - The display name.\n * @returns - Metric data.\n */\n private createBatchGetWebId(target: any, url: string, displayName: string | null): Promise {\n const noTemplate = target.elementPathArray.length === 1 && target.elementPath === target.elementPathArray[0].path;\n const replace = target.isPiPoint && !!target.expression;\n const query: any = {};\n let index = 1;\n for (const attribute of target.attributes) {\n if (noTemplate) {\n this.createQueryPair(target.isPiPoint, target.elementPath, attribute, query, index, replace, url);\n index++;\n } else {\n target.elementPathArray.forEach((elementPath: PiwebapiElementPath) => {\n this.createQueryPair(target.isPiPoint, elementPath.path, attribute, query, index, replace, url);\n index++;\n });\n }\n }\n return this.restBatch(query).then((response: any) => this.handleBatchResponse(response, target, displayName));\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({\n ...cachedWebId,\n });\n }\n\n // no cache hit, query server\n let path = '';\n if (isPiPoint) {\n path =\n '/points?selectedFields=Descriptor%3BPointType%3BEngineeringUnits%3BWebId%3BName%3BPath&path=\\\\\\\\' +\n assetPath.replace('|', '\\\\');\n } else {\n path =\n (assetPath.indexOf('|') >= 0\n ? '/attributes?selectedFields=Type%3BDefaultUnitsName%3BDescription%3BWebId%3BName%3BPath&path=\\\\\\\\'\n : '/elements?selectedFields=Description%3BWebId%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 const data = {\n Path: assetPath,\n Type: response.data.Type || response.data.PointType,\n DefaultUnitsName: response.data.DefaultUnitsName || response.data.EngineeringUnits,\n Description: response.data.Description || response.data.Descriptor,\n WebId: response.data.WebId,\n Name: response.data.Name,\n };\n ds.webidCache.set(assetPath, data);\n return {\n ...data,\n };\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 getAssetServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/assetservers?path=\\\\\\\\' + name).then((response) => response.data);\n }\n getDatabase(path: string | undefined): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/assetdatabases?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getDatabases(serverId: string, options?: any): Promise {\n if (!serverId) {\n return Promise.resolve([]);\n }\n return this.restGet('/assetservers/' + serverId + '/assetdatabases').then((response) => response.data.Items ?? []);\n }\n getElement(path: string): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/elements?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getEventFrameTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'EventFrame');\n });\n }\n getElementTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'Element');\n });\n }\n\n /**\n * @description\n * Get the child attributes of the current resource.\n * GET attributes/{webId}/attributes\n * @param {string} elementId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.nameFilter - The name query string used for finding attributes. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned attributes must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned attributes must be members of this template. The default is no template filter.\n * @param {string} options.valueType - Specify that returned attributes' value type must be the given value type. The default is no value type filter.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include attributes nested further than the immediate attributes of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {string} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {string} options.showExcluded - Specified if the search should include attributes with the Excluded property set. The default is 'false'.\n * @param {string} options.showHidden - Specified if the search should include attributes with the Hidden property set. The default is 'false'.\n * @param {string} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getAttributes(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/attributes' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET assetdatabases/{webId}/elements\n * @param {string} databaseId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getDatabaseElements(databaseId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/assetdatabases/' + databaseId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET elements/{webId}/elements\n * @param {string} databaseId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getElements(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * Retrieve a list of points on a specified Data Server.\n *\n * @param {string} serverId - The ID of the server. See WebID for more information.\n * @param {string} nameFilter - A query string for filtering by point name. The default is no filter. *, ?, [ab], [!ab]\n */\n private piPointSearch(serverId: string, nameFilter: string): Promise {\n let filter1 = this.templateSrv.replace(nameFilter);\n let filter2 = `${filter1}`;\n let doFilter = false;\n if (filter1 !== nameFilter) {\n const regex = /\\{(\\w|,)+\\}/gs;\n let m;\n while ((m = regex.exec(filter1)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n if (groupIndex === 0) {\n filter1 = filter1.replace(match, match.replace('{', '(').replace('}', ')').replace(',', '|'));\n filter2 = filter2.replace(match, '*');\n doFilter = true;\n }\n });\n }\n }\n return this.restGet('/dataservers/' + serverId + '/points?maxCount=50&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results.data?.Items) {\n return doFilter ? results.data.Items.filter((item) => item.Name?.match(filter1)) : results.data.Items;\n }\n return [];\n });\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { PIWebAPIConfigEditor } from './config/ConfigEditor';\nimport { PIWebAPIQueryEditor } from './query/QueryEditor';\nimport { PiWebAPIDatasource } from './datasource';\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n PiWebAPIDatasource\n)\n .setQueryEditor(PIWebAPIQueryEditor)\n .setConfigEditor(PIWebAPIConfigEditor);\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__0__","__WEBPACK_EXTERNAL_MODULE__1__","__WEBPACK_EXTERNAL_MODULE__2__","__WEBPACK_EXTERNAL_MODULE__3__","__WEBPACK_EXTERNAL_MODULE__5__","__WEBPACK_EXTERNAL_MODULE__6__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","FormField","LegacyForms","coerceOptions","options","jsonData","url","PIWebAPIConfigEditor","event","props","onOptionsChange","piserver","target","afserver","afdatabase","checked","pipoint","newFormat","useUnit","originalOptions","this","DataSourceHttpSettings","defaultUrl","dataSourceConfig","onChange","onHttpOptionsChange","showAccessOptions","className","InlineField","label","labelWidth","InlineSwitch","onPiPointChange","onNewFormatChange","onUseUnitChange","inputWidth","onPIServerChange","placeholder","onAFServerChange","onAFDatabaseChange","PureComponent","QueryField","tooltip","children","InlineFormLabel","width","QueryRowTerminator","QueryInlineField","QueryEditorRow","QueryRawInlineField","QueryRawEditorRow","defaultQuery","attributes","segments","regex","enable","summary","types","basis","interval","nodata","expression","interpolate","useLastValue","recordedValues","digitalStates","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","name","PIWebAPIQueryEditor","summaries","attributeSegment","summarySegment","calculationBasisSegment","noDataReplacementSegment","query","setState","item","index","state","slice","remove","checkPiPointSegments","checkAttributeSegments","then","length","push","expandable","piServer","segmentChangeValue","currentSegment","datasource","data","ctrl","findQuery","path","getSegmentPathUpTo","afServerWebId","webId","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","_","match","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","result","startsWith","attributesResponse","validAttributes","attribute","substring","filteredAttributes","attrib","changedValue","replace","webID","forEach","parts","queryProps","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","textEditorChanged","SegmentAsync","Component","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","getAttributeSegmentsAF","useUnitConfig","maxNumber","parseInt","getNoDataSegments","getCalcBasisSegments","getSummarySegments","search","convertTimeSeriesToDataFrame","timeSeries","times","values","datapoints","point","fields","TIME_SERIES_TIME_FIELD_NAME","FieldType","config","ArrayVector","TIME_SERIES_VALUE_FIELD_NAME","unit","labels","tags","displayNameFromDS","refId","meta","metricQueryTransform","response","Name","HasChildren","Items","convertToTableData","valueData","columns","rows","StartTime","EndTime","Content","it","String","Value","checkNumber","number","Number","isNaN","isFinite","getLastPath","splitPath","pop","getPath","elementPathArray","splitStr","foundElement","find","getFinalUrl","webid","PiWebAPIAnnotationsQueryEditor","memo","annotation","afWebId","setAfWebId","database","setDatabase","getValue","getAssetServer","AsyncSelect","getDatabases","dbs","loadingMessage","template","defaultOptions","getEventFrameTemplates","templ","showEndTime","currentTarget","categoryName","nameFilter","i","PiWebAPIDatasource","instanceSettings","getTemplateSrv","backendSrv","getBackendSrv","Map","piwebapiurl","toString","isProxy","test","access","newFormatConfig","annotations","QueryEditor","prepareQuery","anno","isAnnotation","processEvents","of","eventFrameToAnnotation","all","getDataServer","getDatabase","targets","processAnnotationQuery","buildQueryParameters","getStream","targetResponses","flattened","tr","v","sort","b","datasourceRequest","method","status","Error","queryOptions","ds","querydepth","JSON","parse","Math","max","min","getAssetServers","server","db","getDatabaseElements","selectedFields","getElement","element","getElements","getAttributes","searchFullHierarchy","getDataServers","piPointSearch","reject","trim","annotationQuery","templateName","annotationOptions","range","from","toISOString","to","resourceUrl","Method","Resource","RequestTemplate","Parameters","ParentIds","restBatch","toDataFrame","restGet","annon","events","endTime","f","startTime","attributeDataItems","attributeData","RegExp","id","time","Date","getTime","timeEnd","toLocaleString","hide","parseRawQuery","tar","att","webids","varsKeys","keys","current","Array","isArray","selected","attr","vv","allValue","uniq","flatten","getElementPath","isSummary","piPointValue","noDataReplacementMode","grafanaDataPoint","previousValue","drop","Good","noDataReplace","parsePiPointValue","num","Timestamp","omitArray","omitBy","Element","accumulator","string","charAt","toLocaleLowerCase","content","noTemplate","api","innerResults","groups","groupBy","Type","pathSeparator","toTags","parsePiPointValueData","DefaultUnitsName","newElementPathArray","elem","temp","concat","results","isInterpolated","isRecorded","intervalTime","timeRange","toJSON","targetName","displayName","diff","floor","valueOf","timeQuery","newTime","encodeURIComponent","createBatchGetWebId","restGetWebId","webidresponse","restPost","processResults","maxDataPoints","getSummaryUrl","totalSize","targetResults","dataKey","Headers","Status","webidCache","respData","PointType","EngineeringUnits","Description","Descriptor","set","targetResult","assetPath","createQueryPair","handleBatchResponse","headers","cachedWebId","batch","serverId","databaseId","InstanceType","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","DataSourceApi","plugin","DataSourcePlugin","setQueryEditor","setConfigEditor"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"module.js","mappings":"oIAAAA,EAAOC,QAAUC,C,UCAjBF,E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B,SAASuR,MAAQzK,EAAO5C,QACpGhG,KAAKoS,YACHpS,KAAK8B,SAASwE,MAAQtG,KAAKgC,WAAWsE,KAAOtG,KAAK8B,SAASwE,KAAO,KAAOtG,KAAKgC,WAAWsE,UAAOvI,GAChGyL,MAAMZ,GAAyB5I,KAAKgC,WAAWqR,MAAQzK,EAAO5C,SAEpE,ECjEK,MAAMmR,EAAS,IAAIC,EAAAA,iBACxBjG,GAECkG,eAAe9Q,GACf+Q,gBAAgB1X,E","sources":["webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/data\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/runtime\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"@grafana/ui\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"lodash\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"react\"","webpack://gridprotectionalliance-osisoftpi-datasource/external amd \"rxjs\"","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/bootstrap","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/compat get default export","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/define property getters","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/hasOwnProperty shorthand","webpack://gridprotectionalliance-osisoftpi-datasource/webpack/runtime/make namespace object","webpack://gridprotectionalliance-osisoftpi-datasource/./config/ConfigEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./components/Forms.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./types.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./components/QueryEditorModeSwitcher.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./helper.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./query/QueryEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./query/AnnotationsQueryEditor.tsx","webpack://gridprotectionalliance-osisoftpi-datasource/./datasource.ts","webpack://gridprotectionalliance-osisoftpi-datasource/./module.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__781__;","module.exports = __WEBPACK_EXTERNAL_MODULE__531__;","module.exports = __WEBPACK_EXTERNAL_MODULE__7__;","module.exports = __WEBPACK_EXTERNAL_MODULE__241__;","module.exports = __WEBPACK_EXTERNAL_MODULE__959__;","module.exports = __WEBPACK_EXTERNAL_MODULE__269__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { ChangeEvent, PureComponent } from 'react';\nimport { LegacyForms, DataSourceHttpSettings, InlineField, InlineSwitch } from '@grafana/ui';\nimport { DataSourcePluginOptionsEditorProps, DataSourceJsonData, DataSourceSettings } from '@grafana/data';\nimport { PIWebAPIDataSourceJsonData } from '../types';\n\nconst { FormField } = LegacyForms;\n\ninterface Props extends DataSourcePluginOptionsEditorProps {}\n\nconst coerceOptions = (\n options: DataSourceSettings\n): DataSourceSettings => {\n return {\n ...options,\n jsonData: {\n ...options.jsonData,\n url: options.url,\n },\n };\n};\n\ninterface State {}\n\nexport class PIWebAPIConfigEditor extends PureComponent {\n onPIServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFServerChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afserver: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onAFDatabaseChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n afdatabase: event.target.value,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onHttpOptionsChange = (options: DataSourceSettings) => {\n const { onOptionsChange } = this.props;\n onOptionsChange(coerceOptions(options));\n };\n\n onPiPointChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n piserver: event.target.checked ? options.jsonData.piserver : '',\n pipoint: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onNewFormatChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n newFormat: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseUnitChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useUnit: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseExperimentalChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useExperimental : event.target.checked,\n useStreaming : event.target.checked ? options.jsonData.useStreaming : false,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n onUseStreamingChange = (event: ChangeEvent) => {\n const { onOptionsChange, options } = this.props;\n const jsonData = {\n ...options.jsonData,\n useStreaming: event.target.checked,\n };\n onOptionsChange({ ...options, jsonData });\n };\n\n render() {\n const { options: originalOptions } = this.props;\n const options = coerceOptions(originalOptions);\n\n return (\n
\n \n\n

Custom Configuration

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

PI/AF Connection Details

\n\n
\n {options.jsonData.pipoint && (\n
\n \n
\n )}\n
\n \n
\n
\n \n
\n
\n
\n );\n }\n}\n","import React, { InputHTMLAttributes, FunctionComponent } from 'react';\nimport { InlineFormLabel } from '@grafana/ui';\n\nexport interface Props extends InputHTMLAttributes {\n label: string;\n tooltip?: string;\n labelWidth?: number;\n children?: React.ReactNode;\n queryEditor?: JSX.Element;\n}\n\nexport const QueryField: FunctionComponent> = ({ label, labelWidth = 12, tooltip, children }) => (\n <>\n \n {label}\n \n {children}\n \n);\n\nexport const QueryRowTerminator = () => {\n return (\n
\n
\n
\n );\n};\n\nexport const QueryInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryEditorRow = (props: Partial) => {\n return (\n
\n {props.children}\n \n
\n );\n};\n\nexport const QueryRawInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryRawEditorRow = (props: Partial) => {\n return <>{props.children};\n};\n","import { DataQuery } from '@grafana/schema';\nimport { DataSourceJsonData, SelectableValue } from '@grafana/data';\n\nexport interface PiwebapiElementPath {\n path: string;\n variable: string;\n}\n\nexport interface PiwebapiInternalRsp {\n data: PiwebapiRsp;\n status: number;\n url: string;\n}\n\nexport interface PiwebapiRsp {\n Name?: string;\n InstanceType?: string;\n Items?: PiwebapiRsp[];\n WebId?: string;\n HasChildren?: boolean;\n Type?: string;\n DefaultUnitsName?: string;\n Description?: string;\n Path?: string;\n}\n\nexport interface PiDataServer {\n name: string | undefined;\n webid: string | undefined;\n}\n\nexport interface PIWebAPISelectableValue {\n webId?: string;\n value?: string;\n type?: string;\n expandable?: boolean;\n}\n\nexport interface PIWebAPIAnnotationsQuery extends DataQuery {\n target: string;\n}\n\nexport interface PIWebAPIQuery extends DataQuery {\n target?: string;\n elementPath?: string;\n attributes?: Array>;\n segments?: any[];\n isPiPoint?: boolean;\n isAnnotation?: boolean;\n webid?: string;\n display?: any;\n interpolate?: any;\n recordedValues?: any;\n digitalStates?: any;\n enableStreaming: any;\n useLastValue?: any;\n useUnit?: any;\n regex?: any;\n summary?: {nodata?: string, types?: any[], basis?: string, interval?: string};\n expression?: string;\n rawQuery?: boolean;\n query?: string;\n // annotations items\n database?: PiwebapiRsp;\n template?: PiwebapiRsp;\n showEndTime?: boolean;\n attribute?: any;\n nameFilter?: string;\n categoryName?: string;\n}\n\nexport const defaultQuery: Partial = {\n target: ';',\n attributes: [],\n segments: [],\n regex: { enable: false },\n summary: { types: [], basis: 'EventWeighted', interval: '', nodata: 'Null' },\n expression: '',\n interpolate: { enable: false },\n useLastValue: { enable: false },\n recordedValues: { enable: false },\n digitalStates: { enable: false },\n enableStreaming: { enable: false },\n useUnit: { enable: false },\n isPiPoint: false,\n};\n\n/**\n * These are options configured for each DataSource instance\n */\nexport interface PIWebAPIDataSourceJsonData extends DataSourceJsonData {\n url?: string;\n access?: string;\n piserver?: string;\n afserver?: string;\n afdatabase?: string;\n pipoint?: boolean;\n newFormat?: boolean;\n useUnit?: boolean;\n useExperimental?: boolean;\n useStreaming?: boolean;\n}\n\n/**\n * Value that is used in the backend, but never sent over HTTP to the frontend\n */\nexport interface PIWebAPISecureJsonData {\n apiKey?: string;\n}\n","import React, { useEffect, useState } from 'react';\nimport { Button, ConfirmModal } from '@grafana/ui';\n\ntype Props = {\n isRaw: boolean;\n onChange: (newIsRaw: boolean) => void;\n};\n\nexport const QueryEditorModeSwitcher = ({ isRaw, onChange }: Props): JSX.Element => {\n const [isModalOpen, setModalOpen] = useState(false);\n\n useEffect(() => {\n // if the isRaw changes, we hide the modal\n setModalOpen(false);\n }, [isRaw]);\n\n if (isRaw) {\n return (\n <>\n {\n // we show the are-you-sure modal\n setModalOpen(true);\n }}\n >\n {\n onChange(false);\n }}\n onDismiss={() => {\n setModalOpen(false);\n }}\n />\n \n );\n } else {\n return (\n {\n onChange(true);\n }}\n >\n );\n }\n};\n","import { each, map } from 'lodash';\r\n\r\nimport {\r\n AnnotationQuery,\r\n DataFrame,\r\n TableData,\r\n MetricFindValue,\r\n Field,\r\n toDataFrame,\r\n} from '@grafana/data';\r\n\r\nimport { PiwebapiElementPath, PiwebapiRsp, PIWebAPIQuery } from 'types';\r\n\r\nexport function parseRawQuery(tr: string): any {\r\n const splitAttributes = tr.split(';');\r\n const splitElements = splitAttributes[0].split('\\\\');\r\n\r\n // remove element hierarchy from attribute collection\r\n splitAttributes.splice(0, 1);\r\n\r\n let attributes: any[] = [];\r\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\r\n const elementPath: string = splitElements.join('\\\\');\r\n each(splitAttributes, function (item, index) {\r\n if (item !== '') {\r\n attributes.push({\r\n label: item,\r\n value: {\r\n value: item,\r\n expandable: false,\r\n },\r\n });\r\n }\r\n });\r\n\r\n return { attributes, elementPath };\r\n }\r\n\r\n return { attributes, elementPath: null };\r\n}\r\n\r\nexport function lowerCaseFirstLetter(string: string): string {\r\n return string.charAt(0).toLocaleLowerCase() + string.slice(1);\r\n}\r\n\r\n/**\r\n * Builds the Grafana metric segment for use on the query user interface.\r\n *\r\n * @param {any} response - response from PI Web API.\r\n * @returns - Grafana metric segment.\r\n *\r\n * @memberOf PiWebApiDatasource\r\n */\r\nexport function metricQueryTransform(response: PiwebapiRsp[]): MetricFindValue[] {\r\n return map(response, (item) => {\r\n return {\r\n text: item.Name,\r\n expandable:\r\n item.HasChildren === undefined || item.HasChildren === true || (item.Path ?? '').split('\\\\').length <= 3,\r\n HasChildren: item.HasChildren,\r\n Items: item.Items ?? [],\r\n Path: item.Path,\r\n WebId: item.WebId,\r\n } as MetricFindValue;\r\n });\r\n}\r\n\r\n/**\r\n * Check if all items are selected.\r\n *\r\n * @param {any} current the current variable selection\r\n * @return {boolean} true if all value is selected, false otherwise\r\n */\r\nexport function isAllSelected(current: any): boolean {\r\n if (!current) {\r\n return false;\r\n }\r\n if (Array.isArray(current.text)) {\r\n return current.text.indexOf('All') >= 0;\r\n }\r\n return current.text === 'All';\r\n}\r\n\r\nexport function processAnnotationQuery(annon: AnnotationQuery,data: DataFrame[]): DataFrame[] {\r\n let processedFrames: DataFrame[] = [];\r\n \r\n data.forEach((d: DataFrame) => {\r\n d.fields.forEach((f: Field) => {\r\n\r\n // check if the label has been set, if it hasn't been set then the eventframe annotation is not valid. \r\n if (!f.labels) { \r\n return \r\n }\r\n\r\n if (!('eventframe' in f.labels)) {\r\n return;\r\n }\r\n\r\n let attribute = 'attribute' in f.labels\r\n\r\n // Check whether f.values is an array or not to allow for each.\r\n // Check whether f.values is an array or not to allow for each.\r\n if (Array.isArray(f.values)) {\r\n f.values.forEach((value: any) => {\r\n\r\n if (attribute) {\r\n let annotation = value['1'].Content\r\n let valueData: any[] = []\r\n for (let i = 2; i in value; i++) {\r\n valueData.push(value[i].Content.Items)\r\n }\r\n\r\n const processedFrame = convertToTableData(annotation.Items!, valueData).map((r) => {\r\n return toDataFrame(r)});\r\n processedFrames = processedFrames.concat(processedFrame);\r\n } else {\r\n let annotation = value['1'].Content\r\n const processedFrame = convertToTableData(annotation.Items!).map((r) => {\r\n return toDataFrame(r)});\r\n processedFrames = processedFrames.concat(processedFrame);\r\n }\r\n });\r\n } \r\n });\r\n });\r\n return processedFrames;\r\n}\r\n\r\nexport function convertToTableData(items: any[], valueData?: any[]): TableData[] {\r\n const response: TableData[] = items.map((item: any, index: number) => {\r\n const columns = [{ text: 'StartTime' }, { text: 'EndTime' }];\r\n const rows = [item.StartTime, item.EndTime];\r\n if (valueData) {\r\n for (let attributeIndex = 0; attributeIndex < valueData.length; attributeIndex++) {\r\n let attributeData = valueData[attributeIndex]\r\n let eventframeAributeData = attributeData[index].Content.Items\r\n eventframeAributeData.forEach((attribute: any) => {\r\n columns.push({ text: attribute.Name });\r\n rows.push(String(attribute.Value.Value ? attribute.Value.Value.Name || attribute.Value.Value.Value || attribute.Value.Value : ''));\r\n });\r\n }\r\n }\r\n\r\n return {\r\n name: item.Name,\r\n columns,\r\n rows: [rows],\r\n };\r\n });\r\n return response;\r\n}\r\n\r\n/**\r\n * Resolve PIWebAPI response 'value' data to value - timestamp pairs.\r\n *\r\n * @param {any} item - 'Item' object from PIWebAPI\r\n * @param {any} noDataReplacementMode - String state of how to replace 'No Data'\r\n * @param {any} grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns grafanaDataPoint - Single Grafana value pair (value, timestamp).\r\n * @returns perviousValue - {any} Grafana value (value only).\r\n *\r\n */\r\nexport function noDataReplace(\r\n item: any,\r\n noDataReplacementMode: any,\r\n grafanaDataPoint: any[]\r\n): {\r\n grafanaDataPoint: any[];\r\n previousValue: any;\r\n drop: boolean;\r\n} {\r\n let previousValue = null;\r\n let drop = false;\r\n if (!item.Good || item.Value === 'No Data' || (item.Value?.Name && item.Value?.Name === 'No Data')) {\r\n if (noDataReplacementMode === 'Drop') {\r\n drop = true;\r\n } else if (noDataReplacementMode === '0') {\r\n grafanaDataPoint[0] = 0;\r\n } else if (noDataReplacementMode === 'Keep') {\r\n // Do nothing keep\r\n } else if (noDataReplacementMode === 'Null') {\r\n grafanaDataPoint[0] = null;\r\n } else if (noDataReplacementMode === 'Previous' && previousValue !== null) {\r\n grafanaDataPoint[0] = previousValue;\r\n }\r\n } else {\r\n previousValue = item.Value;\r\n }\r\n return { grafanaDataPoint, previousValue, drop };\r\n}\r\n\r\n/**\r\n * Check if the value is a number.\r\n *\r\n * @param {any} number the value to check\r\n * @returns {boolean} true if the value is a number, false otherwise\r\n */\r\nexport function checkNumber(number: any): boolean {\r\n return typeof number === 'number' && !Number.isNaN(number) && Number.isFinite(number);\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path.\r\n *\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getLastPath(path: string): string {\r\n let splitPath = path.split('|');\r\n if (splitPath.length === 0) {\r\n return '';\r\n }\r\n splitPath = splitPath[0].split('\\\\');\r\n return splitPath.length === 0 ? '' : splitPath.pop() ?? '';\r\n}\r\n\r\n/**\r\n * Returns the last item of the element path plus variable.\r\n *\r\n * @param {PiwebapiElementPath[]} elementPathArray array of element paths\r\n * @param {string} path element path\r\n * @returns {string} last item of the element path\r\n */\r\nexport function getPath(elementPathArray: PiwebapiElementPath[], path: string): string {\r\n if (!path || elementPathArray.length === 0) {\r\n return '';\r\n }\r\n const splitStr = getLastPath(path);\r\n const foundElement = elementPathArray.find((e) => path.indexOf(e.path) >= 0)?.variable;\r\n return foundElement ? foundElement + '|' + splitStr : splitStr;\r\n}\r\n\r\n/**\r\n * Replace calculation dot in expression with PI point name.\r\n *\r\n * @param {boolean} replace - is pi point and calculation.\r\n * @param {PiwebapiRsp} webid - Pi web api response object.\r\n * @param {string} url - original url.\r\n * @returns Modified url\r\n */\r\nexport function getFinalUrl(replace: boolean, webid: PiwebapiRsp, url: string) {\r\n const newUrl = replace ? url.replace(/'\\.'/g, `'${webid.Name}'`) : url;\r\n return newUrl;\r\n}\r\n","import { each, filter, forOwn, join, reduce, map, slice, remove, defaults } from 'lodash';\n\nimport React, { PureComponent, ChangeEvent } from 'react';\nimport { Icon, InlineField, InlineFieldRow, InlineSwitch, Input, SegmentAsync, Segment } from '@grafana/ui';\nimport { QueryEditorProps, SelectableValue, TypedVariableModel } from '@grafana/data';\n\nimport { PiWebAPIDatasource } from '../datasource';\nimport { QueryInlineField, QueryRawInlineField, QueryRowTerminator } from '../components/Forms';\nimport { PIWebAPISelectableValue, PIWebAPIDataSourceJsonData, PIWebAPIQuery, defaultQuery } from '../types';\nimport { QueryEditorModeSwitcher } from 'components/QueryEditorModeSwitcher';\nimport { parseRawQuery } from 'helper';\n\nconst LABEL_WIDTH = 24;\nconst MIN_ELEM_INPUT_WIDTH = 200;\nconst MIN_ATTR_INPUT_WIDTH = 250;\n\ninterface State {\n isPiPoint: boolean;\n segments: Array>;\n attributes: Array>;\n summaries: Array>;\n attributeSegment: SelectableValue;\n summarySegment: SelectableValue;\n calculationBasisSegment: SelectableValue;\n noDataReplacementSegment: SelectableValue;\n}\n\ntype Props = QueryEditorProps;\n\nconst REMOVE_LABEL = '-REMOVE-';\n\nconst CustomLabelComponent = (props: any) => {\n if (props.value) {\n return (\n
\n {props.label ?? '--no label--'}\n
\n );\n }\n return (\n \n \n \n );\n};\n\nexport class PIWebAPIQueryEditor extends PureComponent {\n error: any;\n piServer: any[] = [];\n availableAttributes: any = {};\n summaryTypes: string[];\n calculationBasis: string[];\n noDataReplacement: string[];\n state: State = {\n isPiPoint: false,\n segments: [],\n attributes: [],\n summaries: [],\n attributeSegment: {},\n summarySegment: {},\n calculationBasisSegment: {},\n noDataReplacementSegment: {},\n };\n\n constructor(props: any) {\n super(props);\n this.onSegmentChange = this.onSegmentChange.bind(this);\n this.calcBasisValueChanged = this.calcBasisValueChanged.bind(this);\n this.calcNoDataValueChanged = this.calcNoDataValueChanged.bind(this);\n this.onSummaryAction = this.onSummaryAction.bind(this);\n this.onSummaryValueChanged = this.onSummaryValueChanged.bind(this);\n this.onAttributeAction = this.onAttributeAction.bind(this);\n this.onAttributeChange = this.onAttributeChange.bind(this);\n\n this.summaryTypes = [\n // 'None', // A summary type is not specified.\n 'Total', // A totalization over the time range.\n 'Average', // The average value over the time range.\n 'Minimum', // The minimum value over the time range.\n 'Maximum', // The maximum value over the time range.\n 'Range', // The range value over the time range (minimum-maximum).\n 'StdDev', // The standard deviation over the time range.\n 'PopulationStdDev', // The population standard deviation over the time range.\n 'Count', // The sum of event count over the time range when calculation basis is event weighted. The sum of event time duration over the time range when calculation basis is time weighted.\n 'PercentGood', // Percent of data with good value during the calculation period. For time weighted calculations, the percentage is based on time. For event weighted calculations, the percent is based on event count.\n 'All', // A convenience for requesting all available summary calculations.\n 'AllForNonNumeric', // A convenience for requesting all available summary calculations for non-numeric data.\n ];\n\n this.calculationBasis = [\n 'TimeWeighted', // Weight the values in the calculation by the time over which they apply. Interpolation is based on whether the attribute is stepped. Interpolated events are generated at the boundaries if necessary.\n 'EventWeighted', // Evaluate values with equal weighting for each event. No interpolation is done. There must be at least one event within the time range to perform a successful calculation. Two events are required for standard deviation. In handling events at the boundary of the calculation, the AFSDK uses following rules:\n 'TimeWeightedContinuous', // Apply weighting as in TimeWeighted, but do all interpolation between values as if they represent continuous data, (standard interpolation) regardless of whether the attribute is stepped.\n 'TimeWeightedDiscrete', // Apply weighting as in TimeWeighted but interpolation between values is performed as if they represent discrete, unrelated values (stair step plot) regardless of the attribute is stepped.\n 'EventWeightedExcludeMostRecentEvent', // The calculation behaves the same as _EventWeighted_, except in the handling of events at the boundary of summary intervals in a multiple intervals calculation. Use this option to prevent events at the intervals boundary from being double count at both intervals. With this option, events at the end time (most recent time) of an interval is not used in that interval.\n 'EventWeightedExcludeEarliestEvent', // Similar to the option _EventWeightedExcludeMostRecentEvent_. Events at the start time(earliest time) of an interval is not used in that interval.\n 'EventWeightedIncludeBothEnds', // Events at both ends of the interval boundaries are included in the event weighted calculation.\n ];\n\n this.noDataReplacement = [\n 'Null', // replace with nulls\n 'Drop', // drop items\n 'Previous', // use previous value if available\n '0', // replace with 0\n 'Keep', // Keep value\n ];\n }\n\n // is selected segment empty\n isValueEmpty(value: PIWebAPISelectableValue | undefined) {\n return !value || !value.value || !value.value.length || value.value === REMOVE_LABEL;\n }\n\n segmentChangeValue = (segments: Array>) => {\n const query = this.props.query;\n this.setState({ segments }, () => this.onChange({ ...query, segments }));\n };\n\n attributeChangeValue = (attributes: Array>): Promise => {\n const query = this.props.query;\n return new Promise((resolve) => this.setState({ attributes }, () => {\n this.onChange({ ...query, attributes })\n resolve();\n }));\n };\n\n // summary calculation basis change event\n calcBasisValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n if (summary) {\n summary.basis = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, summary });\n }\n // get summary calculation basis user interface segments\n getCalcBasisSegments() {\n const segments = map(this.calculationBasis, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // no data change event\n calcNoDataValueChanged(segment: SelectableValue) {\n const metricsQuery = this.props.query as PIWebAPIQuery;\n const summary = metricsQuery.summary;\n if (summary) {\n summary.nodata = segment.value?.value;\n }\n this.onChange({ ...metricsQuery, summary });\n }\n // get no data user interface segments\n getNoDataSegments() {\n const segments = map(this.noDataReplacement, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n return segments;\n }\n\n // summary query change event\n onSummaryValueChanged(item: SelectableValue, index: number) {\n const summaries = this.state.summaries.slice(0) as Array>;\n summaries[index] = item;\n if (this.isValueEmpty(item.value)) {\n summaries.splice(index, 1);\n }\n this.setState({ summaries }, this.stateCallback);\n }\n // get the list of summaries available\n getSummarySegments() {\n const summaryTypes = filter(this.summaryTypes, (type) => {\n return this.state.summaries.map((s) => s.value?.value).indexOf(type) === -1;\n });\n\n const segments = map(summaryTypes, (item: string) => {\n let selectableValue: SelectableValue = {\n label: item,\n value: {\n value: item,\n expandable: true,\n },\n };\n return selectableValue;\n });\n\n segments.unshift({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n return segments;\n }\n\n // remove a summary from the user interface and the query\n removeSummary(part: SelectableValue) {\n const summaries = filter(this.state.summaries, (item: SelectableValue) => {\n return item !== part;\n });\n this.setState({ summaries });\n }\n // add a new summary to the query\n onSummaryAction(item: SelectableValue) {\n const summaries = this.state.summaries.slice(0) as Array>;\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: true,\n },\n };\n summaries.push(selectableValue);\n }\n this.setState({ summarySegment: {}, summaries }, this.stateCallback);\n }\n\n // remove an attribute from the query\n removeAttribute(part: SelectableValue) {\n const attributes = filter(this.state.attributes, (item: SelectableValue) => {\n return item !== part;\n });\n this.attributeChangeValue(attributes);\n }\n // add an attribute to the query\n onAttributeAction(item: SelectableValue) {\n const { query } = this.props;\n const attributes = this.state.attributes.slice(0);\n // if value is not empty, add new attribute segment\n if (!this.isValueEmpty(item.value)) {\n let selectableValue: SelectableValue = {\n label: item.label,\n value: {\n value: item.value?.value,\n expandable: !query.isPiPoint,\n },\n };\n attributes.push(selectableValue);\n }\n this.attributeChangeValue(attributes);\n }\n\n // pi point change event\n onPiPointChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n if (item.label === REMOVE_LABEL) {\n remove(attributes, (value, n) => n === index);\n } else {\n // set current value\n attributes[index] = item;\n }\n\n this.checkPiPointSegments(item, attributes);\n };\n // attribute change event\n onAttributeChange = (item: SelectableValue, index: number) => {\n let attributes = this.state.attributes.slice(0);\n\n // ignore if no change\n if (attributes[index].label === item.value?.value) {\n return;\n }\n\n // set current value\n attributes[index] = item;\n\n this.checkAttributeSegments(attributes, this.state.segments);\n };\n // segment change\n onSegmentChange = (item: SelectableValue, index: number) => {\n const { query } = this.props;\n let segments = this.state.segments.slice(0);\n\n // ignore if no change\n if (segments[index].label === item.value?.value) {\n return;\n }\n\n // reset attributes list\n this.setState({ attributes: [] }, () => {\n if (item.label === REMOVE_LABEL) {\n segments = slice(segments, 0, index);\n this.checkAttributeSegments([], segments).then(() => {\n if (segments.length === 0) {\n segments.push({\n label: '',\n });\n } else if (!!segments[segments.length - 1].value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n if (query.isPiPoint) {\n this.piServer = [];\n }\n this.segmentChangeValue(segments);\n });\n return;\n }\n\n // set current value\n segments[index] = item;\n\n // Accept only one PI server\n if (query.isPiPoint) {\n this.piServer.push(item);\n this.segmentChangeValue(segments);\n return;\n }\n\n // changed internal selection\n if (index < segments.length - 1) {\n segments = slice(segments, 0, index + 1);\n }\n this.checkAttributeSegments([], segments).then(() => {\n // add new options\n if (!!item.value?.expandable) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n this.segmentChangeValue(segments);\n });\n });\n };\n\n // get a ui segment for the attributes\n getElementSegments = (\n index: number,\n currentSegment?: Array>\n ): Promise>> => {\n const { datasource, query, data } = this.props;\n const ctrl = this;\n const findQuery = query.isPiPoint\n ? { type: 'dataserver' }\n : {\n path: this.getSegmentPathUpTo(currentSegment ?? this.state.segments.slice(0), index),\n afServerWebId: this.state.segments.length > 0 && this.state.segments[0].value ? this.state.segments[0].value.webId : undefined,\n };\n\n if (!query.isPiPoint) {\n if (datasource.afserver?.name && index === 0) {\n return Promise.resolve([\n {\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n },\n ]);\n }\n if (datasource.afserver?.name && datasource.afdatabase?.name && index === 1) {\n return Promise.resolve([\n {\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n },\n ]);\n }\n }\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n const altSegments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n label: item.text,\n value: {\n webId: item.WebId,\n value: item.text,\n expandable: !query.isPiPoint && item.expandable,\n },\n };\n return selectableValue;\n });\n\n if (altSegments.length === 0) {\n return altSegments;\n }\n\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: TypedVariableModel) => {\n let selectableValue: SelectableValue = {\n label: '${' + variable.name + '}',\n value: {\n type: 'template',\n value: '${' + variable.name + '}',\n expandable: !query.isPiPoint,\n },\n };\n altSegments.unshift(selectableValue);\n });\n\n 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 segments.push({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: query.isPiPoint }))\n .then((items: any[]) => {\n segments = map(items, (item: any) => {\n let selectableValue: SelectableValue = {\n path: item.Path,\n label: item.text,\n value: {\n value: item.text,\n expandable: false,\n },\n };\n return selectableValue;\n });\n if (!!attributeText && attributeText.length > 0) {\n segments.unshift({\n label: attributeText,\n value: {\n value: attributeText,\n expandable: false,\n },\n });\n }\n // add template variables\n const variables = datasource.templateSrv.getVariables();\n each(variables, (variable: TypedVariableModel) => {\n let selectableValue: SelectableValue = {\n label: '${' + variable.name + '}',\n value: {\n type: 'template',\n value: '${' + variable.name + '}',\n expandable: !query.isPiPoint,\n },\n };\n segments.unshift(selectableValue);\n });\n return segments;\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return segments;\n });\n };\n\n // get the list of attributes for the user interface - AF\n getAttributeSegmentsAF = (attributeText?: string): Array> => {\n const ctrl = this;\n let segments: Array> = [];\n\n segments.push({\n label: REMOVE_LABEL,\n value: {\n value: REMOVE_LABEL,\n },\n });\n\n forOwn(ctrl.availableAttributes, (val: any, key: string) => {\n let selectableValue: SelectableValue = {\n label: key,\n value: {\n value: key,\n expandable: true,\n },\n };\n segments.push(selectableValue);\n });\n\n return segments;\n };\n\n // build data from target string\n buildFromTarget = (\n query: PIWebAPIQuery,\n segmentsArray: Array>,\n attributesArray: Array>\n ) => {\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segmentsArray.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, (item, _) => {\n if (item !== '') {\n // set current value\n attributesArray.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n return this.getElementSegments(splitElements.length + 1, segmentsArray).then((elements) => {\n if (elements.length > 0) {\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n return segmentsArray;\n });\n }\n return Promise.resolve(segmentsArray);\n };\n\n /**\n * Gets the segment information and parses it to a string.\n *\n * @param {any} index - Last index of segment to use.\n * @returns - AF Path or PI Point name.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSegmentPathUpTo(segments: Array>, index: number): string {\n const arr = segments.slice(0, index);\n\n return reduce(\n arr,\n (result: any, segment: SelectableValue) => {\n if (!segment.value) {\n return '';\n }\n if (!segment.value.value?.startsWith('-Select')) {\n return result ? result + '\\\\' + segment.value.value : segment.value.value;\n }\n return result;\n },\n ''\n );\n }\n\n /**\n * Get the current AF Element's child attributes. Validates when the element selection changes.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAttributeSegments(\n attributes: Array>,\n segments: Array>\n ): Promise {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: this.getSegmentPathUpTo(segments.slice(0), segments.length),\n type: 'attributes',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: false }))\n .then((attributesResponse: any) => {\n const validAttributes: any = {};\n\n each(attributesResponse, (attribute: any) => {\n validAttributes[attribute.Path.substring(attribute.Path.indexOf('|') + 1)] = attribute.WebId;\n });\n\n const filteredAttributes = filter(attributes, (attrib: SelectableValue) => {\n const changedValue = datasource.templateSrv.replace(attrib.value?.value);\n return validAttributes[changedValue] !== undefined;\n });\n\n ctrl.availableAttributes = validAttributes;\n return this.attributeChangeValue(filteredAttributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return this.attributeChangeValue(attributes);\n });\n }\n\n /**\n * Get PI points from server.\n *\n * @returns - Collection of attributes.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkPiPointSegments(\n attribute: SelectableValue,\n attributes: Array>\n ) {\n const { datasource, data } = this.props;\n const ctrl = this;\n const findQuery = {\n path: attribute.path,\n webId: ctrl.getSelectedPIServer(),\n pointName: attribute.label,\n type: 'pipoint',\n };\n return datasource\n .metricFindQuery(findQuery, Object.assign(data?.request?.scopedVars ?? {}, { isPiPoint: true }))\n .then(() => {\n return ctrl.attributeChangeValue(attributes);\n })\n .catch((err: any) => {\n ctrl.error = err.message || 'Failed to issue metric query';\n return ctrl.attributeChangeValue([]);\n });\n }\n\n /**\n * Gets the webid of the current selected pi data server.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n getSelectedPIServer() {\n let webID = '';\n\n this.piServer.forEach((s) => {\n const parts = this.props.query.target!.split(';');\n if (parts.length >= 2) {\n if (parts[0] === s.text) {\n webID = s.WebId;\n return;\n }\n }\n });\n return this.piServer.length > 0 ? this.piServer[0].value?.webId : webID;\n }\n\n /**\n * Queries PI Web API for child elements and attributes when the raw query text editor is changed.\n *\n * @memberOf PIWebAPIQueryEditor\n */\n textEditorChanged() {\n const { query } = this.props;\n const splitAttributes = query.target!.split(';');\n const splitElements = splitAttributes.length > 0 ? splitAttributes[0].split('\\\\') : [];\n\n let segments: Array> = [];\n let attributes: Array> = [];\n\n if (splitElements.length > 1 || (splitElements.length === 1 && splitElements[0] !== '')) {\n // remove element hierarchy from attribute collection\n splitAttributes.splice(0, 1);\n\n each(splitElements, (item, _) => {\n segments.push({\n label: item,\n value: {\n type: item.match(/\\${\\w+}/gi) ? 'template' : undefined,\n value: item,\n expandable: true,\n },\n });\n });\n each(splitAttributes, function (item, index) {\n if (item !== '') {\n attributes.push({\n label: item,\n value: {\n value: item,\n expandable: false,\n },\n });\n }\n });\n this.getElementSegments(splitElements.length + 1, segments)\n .then((elements) => {\n if (elements.length > 0) {\n segments.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n }\n })\n .then(() => {\n this.updateArray(segments, attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n });\n } else {\n segments = this.checkAfServer();\n this.updateArray(segments, this.state.attributes, this.state.summaries, query.isPiPoint!, () => {\n this.onChange({\n ...query,\n query: undefined,\n rawQuery: false,\n attributes: this.state.attributes,\n segments: this.state.segments,\n });\n });\n }\n }\n\n /**\n * Check if the AF server and database are configured in the datasoure config.\n *\n * @returns the segments array\n *\n * @memberOf PIWebAPIQueryEditor\n */\n checkAfServer = () => {\n const { datasource } = this.props;\n const segmentsArray = [];\n if (datasource.afserver?.name) {\n segmentsArray.push({\n label: datasource.afserver.name,\n value: {\n value: datasource.afserver.name,\n expandable: true,\n },\n });\n if (datasource.afdatabase?.name) {\n segmentsArray.push({\n label: datasource.afdatabase.name,\n value: {\n value: datasource.afdatabase.name,\n expandable: true,\n },\n });\n }\n segmentsArray.push({\n label: 'Select Element',\n value: {\n value: '-Select Element-',\n },\n });\n } else {\n segmentsArray.push({\n label: '',\n });\n }\n return segmentsArray;\n };\n\n /**\n * Update the internal state of the datasource.\n *\n * @param segmentsArray the segments array to update\n * @param attributesArray the AF attributes array to update\n * @param summariesArray the summaries array to update\n * @param isPiPoint the is PI point flag\n * @param cb optional callback function\n *\n * @memberOf PIWebAPIQueryEditor\n */\n updateArray = (\n segmentsArray: Array>,\n attributesArray: Array>,\n summariesArray: Array>,\n isPiPoint: boolean,\n cb?: (() => void) | undefined\n ) => {\n this.setState(\n {\n segments: segmentsArray,\n attributes: attributesArray,\n summaries: summariesArray,\n isPiPoint,\n },\n () => {\n if (!isPiPoint) {\n this.checkAttributeSegments(attributesArray, this.state.segments).then(() => {\n if (cb) {\n cb();\n }\n });\n }\n }\n );\n };\n\n // React action when component is initialized/updated\n scopedVarsDone = false;\n componentDidMount = () => {\n this.initialLoad(false);\n };\n\n componentDidUpdate = () => {\n const { query } = this.props;\n if (this.props.data?.state === 'Done' && !!this.props.data?.request?.scopedVars && !this.scopedVarsDone) {\n this.scopedVarsDone = true;\n this.initialLoad(!query.isPiPoint);\n }\n };\n\n initialLoad = (force: boolean) => {\n const { query } = this.props;\n const metricsQuery = defaults(query, defaultQuery) as PIWebAPIQuery;\n const { segments, attributes, summary, isPiPoint } = metricsQuery;\n\n let segmentsArray: Array> = force ? [] : segments?.slice(0) ?? [];\n let attributesArray: Array> = force ? [] : attributes?.slice(0) ?? [];\n let summariesArray = summary?.types ?? [];\n\n if (!isPiPoint && segmentsArray.length === 0) {\n if (query.target && query.target.length > 0 && query.target !== ';') {\n attributesArray = [];\n // Build query from target\n this.buildFromTarget(query, segmentsArray, attributesArray)\n .then((_segmentsArray) => {\n this.updateArray(_segmentsArray, attributesArray, summariesArray, false);\n })\n .catch((e) => console.error(e));\n return;\n } else {\n segmentsArray = this.checkAfServer();\n }\n } else if (isPiPoint && segmentsArray.length > 0) {\n this.piServer = segmentsArray;\n }\n this.updateArray(segmentsArray, attributesArray, summariesArray, !!isPiPoint, () => {\n this.onChange(query);\n });\n };\n\n onChange = (query: PIWebAPIQuery) => {\n const { onChange, onRunQuery } = this.props;\n\n if (query.rawQuery) {\n query.target = query.query ?? '';\n if (!!query.query) {\n const { attributes, elementPath } = parseRawQuery(query.target);\n query.attributes = attributes;\n query.elementPath = elementPath;\n }\n } else {\n query.elementPath = this.getSegmentPathUpTo(this.state.segments, this.state.segments.length);\n query.target =\n query.elementPath +\n ';' +\n join(\n query.attributes?.map((s) => s.value?.value),\n ';'\n );\n }\n const summary = query.summary;\n if (summary) {\n summary.types = this.state.summaries;\n }\n\n onChange({...query, summary});\n\n console.log('QUERY', query.elementPath, query.attributes, query.target);\n\n if (this.isValidQuery(query)) {\n onRunQuery();\n }\n };\n\n isValidQuery = (query: PIWebAPIQuery): boolean => {\n if (query.target && query.target.length > 0 && query.target !== \";\") {\n query.target = query.target.trim();\n const targetSplit = query.target.split(\";\", 2);\n return targetSplit.length === 2 && targetSplit[0].length > 0 && targetSplit[1].length > 0;\n }\n return false;\n }\n\n stateCallback = () => {\n const query = this.props.query as PIWebAPIQuery;\n this.onChange(query);\n };\n\n onIsPiPointChange = (event: React.SyntheticEvent) => {\n const { query: queryChange } = this.props;\n const isPiPoint = !queryChange.isPiPoint;\n this.setState(\n {\n segments: isPiPoint ? [{ label: '' }] : this.checkAfServer(),\n attributes: [],\n isPiPoint,\n },\n () => {\n this.onChange({\n ...queryChange,\n expression: '',\n attributes: this.state.attributes,\n segments: this.state.segments,\n isPiPoint,\n });\n }\n );\n };\n\n render() {\n const { query: queryProps, onChange, onRunQuery } = this.props;\n const metricsQuery = defaults(queryProps, defaultQuery) as PIWebAPIQuery;\n const {\n useLastValue,\n useUnit,\n interpolate,\n query,\n rawQuery,\n digitalStates,\n enableStreaming,\n recordedValues,\n expression,\n isPiPoint,\n summary,\n display,\n regex,\n } = metricsQuery;\n\n return (\n <>\n {this.props.datasource.piPointConfig && (\n \n \n \n )}\n\n {!!rawQuery && (\n \n \n ) =>\n onChange({ ...metricsQuery, query: event.target.value })\n }\n placeholder=\"enter query\"\n />\n \n this.textEditorChanged()} />\n \n )}\n\n {!rawQuery && (\n <>\n
\n \n {this.state.segments.map((segment: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSegmentChange(item, index)}\n loadOptions={(query?: string | undefined) => {\n return this.getElementSegments(index);\n }}\n allowCustomValue\n inputMinWidth={MIN_ELEM_INPUT_WIDTH}\n />\n );\n })}\n \n {!isPiPoint && (\n {\n onChange({ ...metricsQuery, query: metricsQuery.target, rawQuery: value });\n }}\n />\n )}\n \n
\n\n \n {this.state.attributes.map((attribute: SelectableValue, index: number) => {\n if (isPiPoint) {\n return (\n }\n disabled={this.piServer.length === 0}\n onChange={(item) => this.onPiPointChange(item, index)}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n }\n return (\n }\n disabled={this.state.segments.length <= 2}\n onChange={(item) => this.onAttributeChange(item, index)}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n );\n })}\n\n {isPiPoint && (\n \n }\n disabled={this.piServer.length === 0}\n onChange={this.onAttributeAction}\n loadOptions={this.getAttributeSegmentsPI}\n reloadOptionsOnChange\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n {!isPiPoint && (\n \n }\n disabled={this.state.segments.length <= 2}\n onChange={this.onAttributeAction}\n options={this.getAttributeSegmentsAF()}\n allowCustomValue\n inputMinWidth={MIN_ATTR_INPUT_WIDTH}\n />\n )}\n \n \n )}\n\n \n \n ) =>\n onChange({ ...metricsQuery, expression: event.target.value })\n }\n placeholder=\"'.'*2\"\n />\n \n \n\n \n \n \n this.onChange({\n ...metricsQuery,\n useLastValue: { ...useLastValue, enable: !useLastValue.enable },\n })\n }\n />\n \n \n \n this.onChange({\n ...metricsQuery,\n digitalStates: { ...digitalStates, enable: !digitalStates.enable },\n })\n }\n />\n \n \n }\n onChange={this.calcNoDataValueChanged}\n options={this.getNoDataSegments()}\n allowCustomValue\n />\n \n {this.props.datasource.useUnitConfig && (\n \n \n this.onChange({\n ...metricsQuery,\n useUnit: { ...useUnit, enable: !useUnit.enable },\n })\n }\n />\n \n )}\n {this.props.datasource.useStreaming && (\n \n \n this.onChange({ ...metricsQuery, enableStreaming: { ...enableStreaming, enable: !enableStreaming.enable } })\n }\n />\n \n )}\n \n\n \n {!useLastValue.enable && (\n \n ) =>\n onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, maxNumber: parseInt(event.target.value, 10) },\n })\n }\n type=\"number\"\n placeholder=\"1000\"\n />\n \n )}\n \n \n this.onChange({\n ...metricsQuery,\n recordedValues: { ...recordedValues, enable: !recordedValues.enable },\n })\n }\n />\n \n \n\n {!useLastValue.enable && (\n \n \n ) =>\n onChange({ ...metricsQuery, interpolate: { ...interpolate, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n \n this.onChange({ ...metricsQuery, interpolate: { ...interpolate, enable: !interpolate.enable } })\n }\n />\n \n \n )}\n\n {!useLastValue.enable && (\n \n \n ) =>\n onChange({ ...metricsQuery, summary: { ...summary, interval: event.target.value } })\n }\n placeholder=\"30s\"\n />\n \n \n }\n onChange={this.calcBasisValueChanged}\n options={this.getCalcBasisSegments()}\n allowCustomValue\n />\n \n \n \n {this.state.summaries.map((s: SelectableValue, index: number) => {\n return (\n }\n onChange={(item) => this.onSummaryValueChanged(item, index)}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n );\n })}\n \n }\n onChange={this.onSummaryAction}\n options={this.getSummarySegments()}\n allowCustomValue\n />\n \n \n \n )}\n\n \n \n ) =>\n onChange({ ...metricsQuery, display: event.target.value })\n }\n placeholder=\"Display\"\n />\n \n \n {\n this.onChange({ ...metricsQuery, regex: { ...regex, enable: !regex.enable } });\n }}\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, search: event.target.value } })\n }\n placeholder=\"(.*)\"\n />\n \n \n ) =>\n onChange({ ...metricsQuery, regex: { ...regex, replace: event.target.value } })\n }\n placeholder=\"$1\"\n />\n \n \n \n );\n }\n}\n","import React, { memo, useState } from 'react';\n\nimport { AnnotationQuery, QueryEditorProps, SelectableValue } from '@grafana/data';\nimport { AsyncSelect, InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';\n\nimport { PiWebAPIDatasource } from 'datasource';\nimport { PIWebAPIDataSourceJsonData, PIWebAPIQuery, PiwebapiRsp } from 'types';\n\nconst SMALL_LABEL_WIDTH = 20;\nconst LABEL_WIDTH = 30;\nconst MIN_INPUT_WIDTH = 50;\n\ntype PiWebAPIQueryEditorProps = QueryEditorProps;\n\ntype Props = PiWebAPIQueryEditorProps & {\n annotation?: AnnotationQuery;\n onAnnotationChange?: (annotation: AnnotationQuery) => void;\n};\n\nexport const PiWebAPIAnnotationsQueryEditor = memo(function PiWebAPIAnnotationQueryEditor(props: Props) {\n const { query, datasource, annotation, onChange, onRunQuery } = props;\n\n const [afWebId, setAfWebId] = useState('');\n const [database, setDatabase] = useState(annotation?.target?.database ?? {});\n\n // this should never happen, but we want to keep typescript happy\n if (annotation === undefined) {\n return null;\n }\n\n const getEventFrames = (): Promise>> => {\n return datasource.getEventFrameTemplates(database?.WebId!).then((templ: PiwebapiRsp[]) => {\n return templ.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getDatabases = (): Promise>> => {\n return datasource.getDatabases(afWebId).then((dbs: PiwebapiRsp[]) => {\n return dbs.map((d) => ({ label: d.Name, value: d }));\n });\n };\n\n const getValue = (key: string) => {\n const query: any = annotation.target as any;\n if (!query || !query[key]) {\n return;\n }\n return { label: query[key].Name, value: query[key] };\n };\n\n datasource.getAssetServer(datasource.afserver.name).then((result) => {\n setAfWebId(result.WebId!);\n });\n\n return (\n <>\n
\n \n \n {\n setDatabase(e.value);\n onChange({ ...query, database: e.value, template: undefined });\n }}\n defaultOptions\n />\n \n \n onChange({ ...query, template: e.value })}\n defaultOptions\n />\n \n \n onChange({ ...query, showEndTime: e.currentTarget.checked })}\n />\n \n \n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, categoryName: e.currentTarget.value })}\n placeholder=\"Enter category name\"\n />\n \n \n onRunQuery()}\n onChange={(e) => onChange({ ...query, nameFilter: e.currentTarget.value })}\n placeholder=\"Enter name filter\"\n />\n \n \n \n \n \n onChange({\n ...query,\n regex: { ...query.regex, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, search: e.currentTarget.value },\n })\n }\n placeholder=\"(.*)\"\n width={MIN_INPUT_WIDTH}\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query,\n regex: { ...query.regex, replace: e.currentTarget.value },\n })\n }\n placeholder=\"$1\"\n />\n \n \n \n \n \n onChange({\n ...query!,\n attribute: { ...query.attribute, enable: e.currentTarget.checked },\n })\n }\n />\n \n \n onRunQuery()}\n onChange={(e) =>\n onChange({\n ...query!,\n attribute: { ...query.attribute, name: e.currentTarget.value },\n })\n }\n placeholder=\"Enter name\"\n />\n \n \n
\n \n );\n});\n","import { filter, map } from 'lodash';\n\nimport { Observable, of, firstValueFrom } from 'rxjs';\n\nimport {\n DataSourceInstanceSettings,\n MetricFindValue,\n AnnotationQuery,\n ScopedVars,\n AnnotationEvent,\n DataFrame,\n DataQueryRequest,\n DataQueryResponse,\n} from '@grafana/data';\nimport { BackendSrv, getBackendSrv, getTemplateSrv, TemplateSrv, DataSourceWithBackend } from '@grafana/runtime';\n\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData, PiDataServer, PiwebapiInternalRsp, PiwebapiRsp } from './types';\nimport { metricQueryTransform, parseRawQuery } from 'helper';\n\nimport { PiWebAPIAnnotationsQueryEditor } from 'query/AnnotationsQueryEditor';\n\nexport class PiWebAPIDatasource extends DataSourceWithBackend {\n piserver: PiDataServer;\n afserver: PiDataServer;\n afdatabase: PiDataServer;\n piPointConfig: boolean;\n newFormatConfig: boolean;\n useUnitConfig: boolean;\n useExperimental: boolean;\n useStreaming: boolean;\n\n constructor(\n instanceSettings: DataSourceInstanceSettings,\n readonly templateSrv: TemplateSrv = getTemplateSrv(),\n private readonly backendSrv: BackendSrv = getBackendSrv()\n ) {\n super(instanceSettings);\n\n this.piserver = { name: (instanceSettings.jsonData || {}).piserver, webid: undefined };\n this.afserver = { name: (instanceSettings.jsonData || {}).afserver, webid: undefined };\n this.afdatabase = { name: (instanceSettings.jsonData || {}).afdatabase, webid: undefined };\n this.piPointConfig = instanceSettings.jsonData.pipoint || false;\n this.newFormatConfig = instanceSettings.jsonData.newFormat || false;\n this.useUnitConfig = instanceSettings.jsonData.useUnit || false;\n this.useExperimental = instanceSettings.jsonData.useExperimental || false;\n this.useStreaming = instanceSettings.jsonData.useStreaming || false;\n\n this.annotations = {\n QueryEditor: PiWebAPIAnnotationsQueryEditor,\n prepareQuery(anno: AnnotationQuery): PIWebAPIQuery | undefined {\n if (anno.target) {\n anno.target.queryType = 'Annotation';\n anno.target.isAnnotation = true;\n }\n return anno.target;\n },\n processEvents: (\n anno: AnnotationQuery,\n data: DataFrame[]\n ): Observable => {\n return of(this.eventFrameToAnnotation(anno, data));\n },\n };\n\n Promise.all([\n this.getDataServer(this.piserver.name).then((result: PiwebapiRsp) => (this.piserver.webid = result.WebId)),\n this.getAssetServer(this.afserver.name).then((result: PiwebapiRsp) => (this.afserver.webid = result.WebId)),\n this.getDatabase(\n this.afserver.name && this.afdatabase.name ? this.afserver.name + '\\\\' + this.afdatabase.name : undefined\n ).then((result: PiwebapiRsp) => (this.afdatabase.webid = result.WebId)),\n ]);\n }\n\n /**\n * This method overrides the applyTemplateVariables() method from the DataSourceWithBackend class.\n * It is responsible for replacing the template variables in the query configuration prior\n * to sending the query to the backend. Templated variables are not able to be used for alerts\n * or public facing dashboards.\n *\n * @param {PIWebAPIQuery} query - The raw query configuration from the frontend as defined in the query editor.\n * @param {ScopedVars} scopedVars - The template variables that are defined in the query editor and dashboard.\n * @returns - PIWebAPIQuery.\n *\n * @memberOf PiWebApiDatasource\n */\n applyTemplateVariables(query: PIWebAPIQuery, scopedVars: ScopedVars) {\n return {\n ...query,\n target: query.target ? this.templateSrv.replace(query.target, scopedVars) : '',\n };\n }\n\n /**\n * This method makes the query to the backend.\n * \n * @param {DataQueryRequest} options\n *\n * @memberOf PiWebApiDatasource\n */\n query(options: DataQueryRequest): Observable { \n if (options.targets.length === 1 && !!options.targets[0].isAnnotation) {\n return super.query(options);\n }\n\n const query = this.buildQueryParameters(options);\n if (query.targets.length <= 0) {\n return of({ data: [] });\n }\n\n return super.query(query);\n }\n\n /**\n * This method does the discovery of the AF Hierarchy and populates the query user interface segments.\n *\n * @param {any} query - Parses the query configuration and builds a PI Web API query.\n * @returns - Segment information.\n *\n * @memberOf PiWebApiDatasource\n */\n metricFindQuery(query: any, queryOptions: any): Promise {\n const ds = this;\n const querydepth = ['servers', 'databases', 'databaseElements', 'elements'];\n if (typeof query === 'string') {\n query = JSON.parse(query as string);\n }\n if (queryOptions.isPiPoint) {\n query.path = this.templateSrv.replace(query.path, queryOptions);\n } else {\n if (query.path === '') {\n query.type = querydepth[0];\n } else {\n query.path = this.templateSrv.replace(query.path, queryOptions); // replace variables in the path\n query.path = query.path.split(';')[0]; // if the attribute is in the path, let's remote it\n if (query.type !== 'attributes') {\n query.type = querydepth[Math.max(0, Math.min(query.path.split('\\\\').length, querydepth.length - 1))];\n }\n }\n query.path = query.path.replace(/\\{([^\\\\])*\\}/gi, (r: string) => r.substring(1, r.length - 2).split(',')[0]);\n }\n\n query.filter = query.filter ?? '*';\n\n if (query.type === 'servers') {\n return ds.afserver?.name\n ? ds\n .getAssetServer(ds.afserver.name)\n .then((result: PiwebapiRsp) => [result])\n .then(metricQueryTransform)\n : ds.getAssetServers().then(metricQueryTransform);\n } else if (query.type === 'databases' && !!query.afServerWebId) {\n return ds.getDatabases(query.afServerWebId, {}).then(metricQueryTransform);\n } else if (query.type === 'databases') {\n return ds\n .getAssetServer(query.path)\n .then((server) => ds.getDatabases(server.WebId ?? '', {}))\n .then(metricQueryTransform);\n } else if (query.type === 'databaseElements') {\n return ds\n .getDatabase(query.path)\n .then((db) =>\n ds.getDatabaseElements(db.WebId ?? '', {\n selectedFields: 'Items.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'elements') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getElements(element.WebId ?? '', {\n selectedFields:\n 'Items.Description%3BItems.WebId%3BItems.Name%3BItems.Items%3BItems.Path%3BItems.HasChildren',\n nameFilter: query.filter,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'attributes') {\n return ds\n .getElement(query.path)\n .then((element) =>\n ds.getAttributes(element.WebId ?? '', {\n searchFullHierarchy: 'true',\n selectedFields:\n 'Items.Type%3BItems.DefaultUnitsName%3BItems.Description%3BItems.WebId%3BItems.Name%3BItems.Path',\n nameFilter: query.filter,\n })\n )\n .then(metricQueryTransform);\n } else if (query.type === 'dataserver') {\n return ds.getDataServers().then(metricQueryTransform);\n } else if (query.type === 'pipoint') {\n return ds.piPointSearch(query.webId, query.pointName).then(metricQueryTransform);\n }\n return Promise.reject('Bad type');\n }\n\n /** PRIVATE SECTION */\n\n /**\n * Builds the PIWebAPI query parameters.\n *\n * @param {any} options - Grafana query and panel options.\n * @returns - PIWebAPI query parameters.\n *\n * @memberOf PiWebApiDatasource\n */\n private buildQueryParameters(options: DataQueryRequest) {\n options.targets = filter(options.targets, (target) => {\n if (!target || !target.target || target.attributes?.length === 0 || target.target === ';' || !!target.hide) {\n return false;\n }\n return !target.target.startsWith('Select AF');\n });\n\n if (options.maxDataPoints) {\n options.maxDataPoints = options.maxDataPoints > 30000 ? 30000 : options.maxDataPoints;\n }\n options.targets = map(options.targets, (target) => {\n const tar = {\n enableStreaming: target.enableStreaming,\n target: this.templateSrv.replace(target.target, options.scopedVars),\n elementPath: this.templateSrv.replace(target.elementPath, options.scopedVars),\n attributes: map(target.attributes, (att) => {\n if (att.value) {\n this.templateSrv.replace(att.value.value, options.scopedVars)\n }\n return att;\n }),\n segments: map(target.segments, (att) => {\n if (att.value) {\n this.templateSrv.replace(att.value.value, options.scopedVars)\n }\n return att;\n }),\n isAnnotation: !!target.isAnnotation,\n display: !!target.display ? this.templateSrv.replace(target.display, options.scopedVars) : undefined,\n refId: target.refId,\n hide: target.hide,\n interpolate: target.interpolate || { enable: false },\n useLastValue: target.useLastValue || { enable: false },\n useUnit: target.useUnit || { enable: false },\n recordedValues: target.recordedValues || { enable: false },\n digitalStates: target.digitalStates || { enable: false },\n webid: target.webid ?? '',\n regex: target.regex || { enable: false },\n expression: target.expression || '',\n summary: target.summary || { types: [] },\n startTime: options.range.from,\n endTime: options.range.to,\n isPiPoint: !!target.isPiPoint,\n scopedVars: options.scopedVars,\n };\n\n if (tar.expression) {\n tar.expression = this.templateSrv.replace(tar.expression, options.scopedVars);\n }\n\n if (tar.summary.types !== undefined) {\n tar.summary.types = filter(tar.summary.types, (item) => {\n return item !== undefined && item !== null && item !== '';\n });\n }\n \n return tar;\n });\n\n return options;\n }\n\n /**\n * Localize the eventFrame dataFrame records to Grafana Annotations.\n * @param {any} annon - The annotation object.\n * @param {any} data - The dataframe recrords.\n * @returns - Grafana Annotation\n *\n * @memberOf PiWebApiDatasource\n */\n private eventFrameToAnnotation(annon: AnnotationQuery, data: DataFrame[]): AnnotationEvent[] {\n const annotationOptions = annon.target!;\n const events: AnnotationEvent[] = [];\n const currentLocale = Intl.DateTimeFormat().resolvedOptions().locale;\n\n data.forEach((d: DataFrame) => {\n let values = this.transformDataFrameToMap(d);\n for (let i = 0; i < values['time'].length; i++) {\n // replace Dataframe name using Regex\n let title = values['title'][i];\n if (annotationOptions.regex && annotationOptions.regex.enable) {\n title = title.replace(new RegExp(annotationOptions.regex.search), annotationOptions.regex.replace);\n }\n\n // test if timeEnd is negative and if so, set it to null\n if (values['timeEnd'][i] < 0) {\n values['timeEnd'][i] = null;\n }\n\n // format the text and localize the dates to browser locale\n let text = 'Tag: ' + title;\n if (annotationOptions.attribute && annotationOptions.attribute.enable) {\n text += values['attributeText'][i];\n }\n text += '
Start: ' + new Date(values['time'][i]).toLocaleString(currentLocale) + '
End: ';\n\n if (values['timeEnd'][i]) {\n text += new Date(values['timeEnd'][i]).toLocaleString(currentLocale);\n } else {\n text += 'Eventframe is open';\n }\n\n const event: AnnotationEvent = {\n time: values['time'][i],\n timeEnd: !!annotationOptions.showEndTime ? values['timeEnd'][i] : undefined,\n title: title,\n id: values['id'][i],\n text: text,\n tags: ['OSISoft PI'],\n };\n\n events.push(event);\n }\n });\n return events;\n }\n\n /**\n *\n */\n private transformDataFrameToMap(dataFrame: DataFrame): Record {\n const map: Record = {};\n\n dataFrame.fields.forEach((field) => {\n map[field.name] = field.values.toArray();\n });\n\n return map;\n }\n\n /**\n * Abstraction for calling the PI Web API REST endpoint\n *\n * @param {any} path - the path to append to the base server URL.\n * @returns - The full URL.\n *\n * @memberOf PiWebApiDatasource\n */\n private restGet(path: string): Promise {\n const observable = this.backendSrv.fetch({\n url: `/api/datasources/${this.id}/resources${path}`,\n method: 'GET',\n headers: { 'Content-Type': 'application/json' },\n });\n\n return firstValueFrom(observable).then((response: any) => {\n return response as PiwebapiInternalRsp;\n });\n }\n\n // Get a list of all data (PI) servers\n private getDataServers(): Promise {\n return this.restGet('/dataservers').then((response) => response.data.Items ?? []);\n }\n private getDataServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/dataservers?name=' + name).then((response) => response.data);\n }\n // Get a list of all asset (AF) servers\n private getAssetServers(): Promise {\n return this.restGet('/assetservers').then((response) => response.data.Items ?? []);\n }\n getAssetServer(name: string | undefined): Promise {\n if (!name) {\n return Promise.resolve({});\n }\n return this.restGet('/assetservers?path=\\\\\\\\' + name).then((response) => response.data);\n }\n getDatabase(path: string | undefined): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/assetdatabases?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getDatabases(serverId: string, options?: any): Promise {\n if (!serverId) {\n return Promise.resolve([]);\n }\n return this.restGet('/assetservers/' + serverId + '/assetdatabases').then((response) => response.data.Items ?? []);\n }\n getElement(path: string): Promise {\n if (!path) {\n return Promise.resolve({});\n }\n return this.restGet('/elements?path=\\\\\\\\' + path).then((response) => response.data);\n }\n getEventFrameTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'EventFrame');\n });\n }\n getElementTemplates(databaseId: string): Promise {\n if (!databaseId) {\n return Promise.resolve([]);\n }\n return this.restGet(\n '/assetdatabases/' + databaseId + '/elementtemplates?selectedFields=Items.InstanceType%3BItems.Name%3BItems.WebId'\n ).then((response) => {\n return filter(response.data.Items ?? [], (item) => item.InstanceType === 'Element');\n });\n }\n\n /**\n * @description\n * Get the child attributes of the current resource.\n * GET attributes/{webId}/attributes\n * @param {string} elementId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.nameFilter - The name query string used for finding attributes. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned attributes must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned attributes must be members of this template. The default is no template filter.\n * @param {string} options.valueType - Specify that returned attributes' value type must be the given value type. The default is no value type filter.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include attributes nested further than the immediate attributes of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {string} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {string} options.showExcluded - Specified if the search should include attributes with the Excluded property set. The default is 'false'.\n * @param {string} options.showHidden - Specified if the search should include attributes with the Hidden property set. The default is 'false'.\n * @param {string} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getAttributes(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/attributes' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET assetdatabases/{webId}/elements\n * @param {string} databaseId - The ID of the parent resource. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getDatabaseElements(databaseId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/assetdatabases/' + databaseId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * @description\n * Retrieve elements based on the specified conditions. By default, this method selects immediate children of the current resource.\n * Users can search for the elements based on specific search parameters. If no parameters are specified in the search, the default values for each parameter will be used and will return the elements that match the default search.\n * GET elements/{webId}/elements\n * @param {string} databaseId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {Object} options - Query Options\n * @param {string} options.webId - The ID of the resource to use as the root of the search. See WebID for more information.\n * @param {string} options.nameFilter - The name query string used for finding objects. The default is no filter. See Query String for more information.\n * @param {string} options.categoryName - Specify that returned elements must have this category. The default is no category filter.\n * @param {string} options.templateName - Specify that returned elements must have this template or a template derived from this template. The default is no template filter.\n * @param {string} options.elementType - Specify that returned elements must have this type. The default type is 'Any'. See Element Type for more information.\n * @param {string} options.searchFullHierarchy - Specifies if the search should include objects nested further than the immediate children of the searchRoot. The default is 'false'.\n * @param {string} options.sortField - The field or property of the object used to sort the returned collection. The default is 'Name'.\n * @param {string} options.sortOrder - The order that the returned collection is sorted. The default is 'Ascending'.\n * @param {number} options.startIndex - The starting index (zero based) of the items to be returned. The default is 0.\n * @param {number} options.maxCount - The maximum number of objects to be returned per call (page size). The default is 1000.\n * @param {string} options.selectedFields - List of fields to be returned in the response, separated by semicolons (;). If this parameter is not specified, all available fields will be returned. See Selected Fields for more information.\n */\n private getElements(elementId: string, options: any): Promise {\n let querystring =\n '?' +\n map(options, (value, key) => {\n return key + '=' + value;\n }).join('&');\n\n if (querystring === '?') {\n querystring = '';\n }\n\n return this.restGet('/elements/' + elementId + '/elements' + querystring).then(\n (response) => response.data.Items ?? []\n );\n }\n\n /**\n * Retrieve a list of points on a specified Data Server.\n *\n * @param {string} serverId - The ID of the server. See WebID for more information.\n * @param {string} nameFilter - A query string for filtering by point name. The default is no filter. *, ?, [ab], [!ab]\n */\n private piPointSearch(serverId: string, nameFilter: string): Promise {\n let filter1 = this.templateSrv.replace(nameFilter);\n let filter2 = `${filter1}`;\n let doFilter = false;\n if (filter1 !== nameFilter) {\n const regex = /\\{(\\w|,)+\\}/gs;\n let m;\n while ((m = regex.exec(filter1)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n if (groupIndex === 0) {\n filter1 = filter1.replace(match, match.replace('{', '(').replace('}', ')').replace(',', '|'));\n filter2 = filter2.replace(match, '*');\n doFilter = true;\n }\n });\n }\n }\n return this.restGet('/dataservers/' + serverId + '/points?maxCount=50&nameFilter=' + filter2).then((results) => {\n if (!!results && !!results.data?.Items) {\n return doFilter ? results.data.Items.filter((item) => item.Name?.match(filter1)) : results.data.Items;\n }\n return [];\n });\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { PIWebAPIConfigEditor } from './config/ConfigEditor';\nimport { PIWebAPIQueryEditor } from './query/QueryEditor';\nimport { PiWebAPIDatasource } from './datasource';\nimport { PIWebAPIQuery, PIWebAPIDataSourceJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n PiWebAPIDatasource\n)\n .setQueryEditor(PIWebAPIQueryEditor)\n .setConfigEditor(PIWebAPIConfigEditor);\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__781__","__WEBPACK_EXTERNAL_MODULE__531__","__WEBPACK_EXTERNAL_MODULE__7__","__WEBPACK_EXTERNAL_MODULE__241__","__WEBPACK_EXTERNAL_MODULE__959__","__WEBPACK_EXTERNAL_MODULE__269__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","FormField","LegacyForms","coerceOptions","options","jsonData","url","PIWebAPIConfigEditor","PureComponent","render","originalOptions","this","props","div","DataSourceHttpSettings","defaultUrl","dataSourceConfig","onChange","onHttpOptionsChange","showAccessOptions","h3","className","InlineField","label","labelWidth","InlineSwitch","pipoint","onPiPointChange","newFormat","onNewFormatChange","useUnit","onUseUnitChange","useExperimental","onUseExperimentalChange","useStreaming","onUseStreamingChange","inputWidth","onPIServerChange","piserver","placeholder","onAFServerChange","afserver","onAFDatabaseChange","afdatabase","event","onOptionsChange","target","checked","QueryField","tooltip","children","InlineFormLabel","width","QueryRowTerminator","QueryInlineField","QueryEditorRow","QueryRawInlineField","QueryRawEditorRow","defaultQuery","attributes","segments","regex","enable","summary","types","basis","interval","nodata","expression","interpolate","useLastValue","recordedValues","digitalStates","enableStreaming","isPiPoint","QueryEditorModeSwitcher","isRaw","isModalOpen","setModalOpen","useState","useEffect","Button","aria-label","icon","variant","type","onClick","ConfirmModal","isOpen","title","body","confirmText","dismissText","onConfirm","onDismiss","metricQueryTransform","response","map","item","text","Name","expandable","HasChildren","Path","split","length","Items","WebId","LABEL_WIDTH","MIN_ATTR_INPUT_WIDTH","REMOVE_LABEL","CustomLabelComponent","Icon","name","PIWebAPIQueryEditor","isValueEmpty","calcBasisValueChanged","segment","metricsQuery","query","getCalcBasisSegments","calculationBasis","calcNoDataValueChanged","getNoDataSegments","noDataReplacement","onSummaryValueChanged","index","summaries","state","slice","splice","setState","stateCallback","getSummarySegments","summaryTypes","filter","s","indexOf","unshift","removeSummary","part","onSummaryAction","selectableValue","push","summarySegment","removeAttribute","attributeChangeValue","onAttributeAction","getSegmentPathUpTo","arr","reduce","result","startsWith","checkAttributeSegments","data","datasource","ctrl","findQuery","path","metricFindQuery","assign","request","scopedVars","then","attributesResponse","validAttributes","each","attribute","substring","filteredAttributes","attrib","changedValue","templateSrv","replace","availableAttributes","catch","err","error","message","checkPiPointSegments","webId","getSelectedPIServer","pointName","webID","piServer","forEach","parts","textEditorChanged","splitAttributes","splitElements","_","match","getElementSegments","elements","updateArray","rawQuery","checkAfServer","queryProps","onRunQuery","defaults","display","piPointConfig","onIsPiPointChange","InlineFieldRow","grow","Input","onBlur","SegmentAsync","Component","onSegmentChange","loadOptions","allowCustomValue","inputMinWidth","disabled","getAttributeSegmentsPI","reloadOptionsOnChange","Segment","onAttributeChange","getAttributeSegmentsAF","attributeSegment","useUnitConfig","maxNumber","parseInt","search","constructor","super","calculationBasisSegment","noDataReplacementSegment","segmentChangeValue","Promise","resolve","remove","currentSegment","afServerWebId","items","altSegments","variables","getVariables","variable","attributeText","forOwn","val","buildFromTarget","segmentsArray","attributesArray","summariesArray","cb","scopedVarsDone","componentDidMount","initialLoad","componentDidUpdate","force","_segmentsArray","e","console","elementPath","tr","join","parseRawQuery","log","isValidQuery","trim","targetSplit","queryChange","bind","PiWebAPIAnnotationsQueryEditor","memo","annotation","afWebId","setAfWebId","database","setDatabase","getValue","getAssetServer","AsyncSelect","getDatabases","dbs","loadingMessage","template","defaultOptions","getEventFrameTemplates","templ","showEndTime","currentTarget","categoryName","nameFilter","PiWebAPIDatasource","DataSourceWithBackend","applyTemplateVariables","targets","isAnnotation","buildQueryParameters","of","queryOptions","ds","querydepth","JSON","parse","Math","max","min","getAssetServers","server","getDatabase","db","getDatabaseElements","selectedFields","getElement","element","getElements","getAttributes","searchFullHierarchy","getDataServers","piPointSearch","reject","hide","maxDataPoints","tar","att","refId","webid","startTime","range","from","endTime","to","annon","annotationOptions","events","currentLocale","Intl","DateTimeFormat","resolvedOptions","locale","values","transformDataFrameToMap","i","RegExp","Date","toLocaleString","time","timeEnd","id","tags","dataFrame","fields","field","toArray","observable","backendSrv","fetch","method","headers","firstValueFrom","restGet","getDataServer","serverId","databaseId","InstanceType","getElementTemplates","elementId","querystring","filter1","filter2","doFilter","m","exec","lastIndex","groupIndex","results","instanceSettings","getTemplateSrv","getBackendSrv","newFormatConfig","annotations","QueryEditor","prepareQuery","anno","queryType","processEvents","eventFrameToAnnotation","all","plugin","DataSourcePlugin","setQueryEditor","setConfigEditor"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/plugin.json b/dist/plugin.json index 47adfd8..afcc0b4 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -3,9 +3,12 @@ "name": "OSIsoft-PI", "type": "datasource", "id": "gridprotectionalliance-osisoftpi-datasource", + "backend": true, + "executable": "gpx_osipiwebapi", "metrics": true, "annotations": true, - "alerting": false, + "alerting": true, + "streaming": false, "info": { "description": "Datasource plugin for OSIsoft PI Web API", "author": { @@ -36,11 +39,11 @@ {"name": "Datasource Configuration", "path": "img/configuration.png"}, {"name": "Annotations Editor", "path": "img/annotations.png"} ], - "version": "4.2.0", - "updated": "2023-05-31" + "version": "5.0.0-alpha", + "updated": "2024-04-05" }, "dependencies": { - "grafanaDependency": ">=8.4.0", + "grafanaDependency": ">=10.1.0", "plugins": [] } } diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..b13857e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: '3.0' + +services: + grafana: + container_name: 'gridprotectionalliance-osisoftpi-datasource' + platform: 'linux/amd64' + build: + context: ./.config + args: + grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise} + grafana_version: ${GRAFANA_VERSION:-10.3.3} + ports: + - 3000:3000/tcp + volumes: + - ./dist:/var/lib/grafana/plugins/gridprotectionalliance-osisoftpi-datasource + - ./provisioning:/etc/grafana/provisioning diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b0bb9a5 --- /dev/null +++ b/go.mod @@ -0,0 +1,96 @@ +module github.com/GridProtectionAlliance/osisoftpi-grafana + +go 1.21 + +require ( + github.com/go-co-op/gocron v1.37.0 + github.com/google/uuid v1.6.0 + github.com/gorilla/websocket v1.5.1 + github.com/grafana/grafana-plugin-sdk-go v0.201.0 + go.opentelemetry.io/otel v1.24.0 + go.opentelemetry.io/otel/trace v1.24.0 +) + +require ( + github.com/BurntSushi/toml v1.3.2 // indirect + github.com/apache/arrow/go/v13 v13.0.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cheekybits/genny v1.0.0 // indirect + github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/getkin/kin-openapi v0.120.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/swag v0.22.4 // indirect + github.com/goccy/go-json v0.10.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/flatbuffers v23.1.21+incompatible // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/gorilla/mux v1.8.0 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect + github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 // indirect + github.com/hashicorp/go-hclog v1.6.2 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect + github.com/invopop/yaml v0.2.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.15.15 // indirect + github.com/klauspost/cpuid/v2 v2.2.3 // indirect + github.com/magefile/mage v1.15.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattetti/filebuffer v1.0.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/oklog/run v1.1.0 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/perimeterx/marshmallow v1.1.5 // indirect + github.com/pierrec/lz4/v4 v4.1.17 // indirect + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.46.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 // indirect + github.com/unknwon/com v1.0.1 // indirect + github.com/unknwon/log v0.0.0-20150304194804-e617c87089d3 // indirect + github.com/urfave/cli v1.22.14 // indirect + github.com/zeebo/xxh3 v1.0.2 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 // indirect + go.opentelemetry.io/contrib/propagators/jaeger v1.21.1 // indirect + go.opentelemetry.io/contrib/samplers/jaegerremote v0.15.1 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/sdk v1.21.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect + go.uber.org/atomic v1.9.0 // indirect + golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect + golang.org/x/mod v0.9.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.6.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/grpc v1.60.1 // indirect + google.golang.org/protobuf v1.32.0 // indirect + gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..eaf19b3 --- /dev/null +++ b/go.sum @@ -0,0 +1,389 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.110.8 h1:tyNdfIxjzaWctIiLYOTalaLKZ17SI44SKFW26QbOhME= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/apache/arrow/go/v13 v13.0.0 h1:kELrvDQuKZo8csdWYqBQfyi431x6Zs/YJTEgUuSVcWk= +github.com/apache/arrow/go/v13 v13.0.0/go.mod h1:W69eByFNO0ZR30q1/7Sr9d83zcVZmF2MiP3fFYAWJOc= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE= +github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= +github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 h1:XCdvHbz3LhewBHN7+mQPx0sg/Hxil/1USnBmxkjHcmY= +github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= +github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027 h1:1L0aalTpPz7YlMxETKpmQoWMBkeiuorElZIXoNmgiPE= +github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= +github.com/elazarl/goproxy/ext v0.0.0-20220115173737-adb46da277ac h1:9yrT5tmn9Zc0ytWPASlaPwQfQMQYnRf0RSDe1XvHw0Q= +github.com/elazarl/goproxy/ext v0.0.0-20220115173737-adb46da277ac/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/getkin/kin-openapi v0.120.0 h1:MqJcNJFrMDFNc07iwE8iFC5eT2k/NPUFDIpNeiZv8Jg= +github.com/getkin/kin-openapi v0.120.0/go.mod h1:PCWw/lfBrJY4HcdqE3jj+QFkaFK8ABoqo7PvqVhXXqw= +github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0= +github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= +github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/flatbuffers v23.1.21+incompatible h1:bUqzx/MXCDxuS0hRJL2EfjyZL3uQrPbMocUa8zGqsTA= +github.com/google/flatbuffers v23.1.21+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/grafana/grafana-plugin-sdk-go v0.201.0 h1:2ovSMQbT+wBvEggVRIJ+ExazCQVzS2nAFtx56j/yvGM= +github.com/grafana/grafana-plugin-sdk-go v0.201.0/go.mod h1:aT5g1EGl4722duptKf2sK3X/B0EIZ7Dv8PMGxFHA/vk= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 h1:dygLcbEBA+t/P7ck6a8AkXv6juQ4cK0RHBoh32jxhHM= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2/go.mod h1:Ap9RLCIJVtgQg1/BBgVEfypOAySvvlcpcVQkSzJCH4Y= +github.com/hashicorp/go-hclog v1.6.2 h1:NOtoftovWkDheyUM/8JW3QMiXyxJK3uHRK7wV04nD2I= +github.com/hashicorp/go-hclog v1.6.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= +github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= +github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= +github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU= +github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= +github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattetti/filebuffer v1.0.1 h1:gG7pyfnSIZCxdoKq+cPa8T0hhYtD9NxCdI4D7PTjRLM= +github.com/mattetti/filebuffer v1.0.1/go.mod h1:YdMURNDOttIiruleeVr6f56OrMc+MydEnTcXwtkxNVs= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= +github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= +github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= +github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= +github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY= +github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 h1:aVGB3YnaS/JNfOW3tiHIlmNmTDg618va+eT0mVomgyI= +github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8/go.mod h1:fVle4kNr08ydeohzYafr20oZzbAkhQT39gKK/pFQ5M4= +github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= +github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= +github.com/unknwon/log v0.0.0-20150304194804-e617c87089d3 h1:4EYQaWAatQokdji3zqZloVIW/Ke1RQjYw2zHULyrHJg= +github.com/unknwon/log v0.0.0-20150304194804-e617c87089d3/go.mod h1:1xEUf2abjfP92w2GZTV+GgaRxXErwRXcClbUwrNJffU= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk= +github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= +github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= +github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= +github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE= +go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 h1:gbhw/u49SS3gkPWiYweQNJGm/uJN5GkI/FrosxSHT7A= +go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1/go.mod h1:GnOaBaFQ2we3b9AGWJpsBa7v1S5RlQzlC3O7dRMxZhM= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= +go.opentelemetry.io/contrib/propagators/jaeger v1.21.1 h1:f4beMGDKiVzg9IcX7/VuWVy+oGdjx3dNJ72YehmtY5k= +go.opentelemetry.io/contrib/propagators/jaeger v1.21.1/go.mod h1:U9jhkEl8d1LL+QXY7q3kneJWJugiN3kZJV2OWz3hkBY= +go.opentelemetry.io/contrib/samplers/jaegerremote v0.15.1 h1:Qb+5A+JbIjXwO7l4HkRUhgIn4Bzz0GNS2q+qdmSx+0c= +go.opentelemetry.io/contrib/samplers/jaegerremote v0.15.1/go.mod h1:G4vNCm7fRk0kjZ6pGNLo5SpLxAUvOfSrcaegnT8TPck= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20230307190834-24139beb5833 h1:SChBja7BCQewoTAU7IgvucQKMIXrEpFxNMs0spT3/5s= +golang.org/x/exp v0.0.0-20230307190834-24139beb5833/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= +golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191020152052-9984515f0562/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +gonum.org/v1/gonum v0.12.0 h1:xKuo6hzt+gMav00meVPUlXwSdoEJP46BR+wdxQEFK2o= +gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0= +google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU= +google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify/fsnotify.v1 v1.4.7 h1:XNNYLJHt73EyYiCZi6+xjupS9CpvmiDgjPTAjrBlQbo= +gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/jest-setup.js b/jest-setup.js new file mode 100644 index 0000000..35a700b --- /dev/null +++ b/jest-setup.js @@ -0,0 +1,2 @@ +// Jest setup provided by Grafana scaffolding +import './.config/jest-setup'; diff --git a/jest.config.js b/jest.config.js index bcf17c9..79fd52a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,8 @@ -// This file is needed because it is used by vscode and other tools that -// call `jest` directly. However, unless you are doing anything special -// do not edit this file +// force timezone to UTC to allow tests to work regardless of local timezone +// generally used by snapshots, but can affect specific tests +process.env.TZ = 'UTC'; -const standard = require('@grafana/toolkit/src/config/jest.plugin.config'); - -// This process will use the same config that `yarn test` is using -module.exports = standard.jestConfig(); +module.exports = { + // Jest configuration provided by Grafana scaffolding + ...require('./.config/jest.config'), +}; diff --git a/package.json b/package.json index 3f09b79..a74ef07 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,74 @@ { "name": "grid-protection-alliance-osisoftpi-grafana", - "version": "4.2.0", + "version": "5.0.0-beta", "description": "OSISoft PI Grafana Plugin", "scripts": { - "build": "grafana-toolkit plugin:build", - "test": "grafana-toolkit plugin:test", - "dev": "grafana-toolkit plugin:dev", - "watch": "grafana-toolkit plugin:dev --watch", - "sign": "grafana-toolkit plugin:sign", - "start": "yarn watch" + "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", + "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", + "e2e": "yarn exec cypress install && yarn exec grafana-e2e run", + "e2e:update": "yarn exec cypress install && yarn exec grafana-e2e run --update-screenshots", + "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .", + "lint:fix": "yarn run lint --fix", + "server": "docker-compose up --build", + "sign": "npx --yes @grafana/sign-plugin@latest", + "start": "yarn watch", + "test": "jest --watch --onlyChanged", + "test:ci": "jest --passWithNoTests --maxWorkers 4", + "typecheck": "tsc --noEmit", + "build:backend": "mage -v build:linux && mage -v build:windows && mage -v build:darwin" }, "author": "GridProtectionAlliance", "license": "Apache-2.0", "devDependencies": { - "@grafana/data": "^9.4.7", - "@grafana/runtime": "^9.4.7", - "@grafana/toolkit": "^9.4.7", - "@grafana/ui": "^9.4.7", - "@testing-library/jest-dom": "5.4.0", - "@testing-library/react": "^10.0.2", - "@types/lodash": "latest" + "@babel/core": "^7.21.4", + "@grafana/e2e": "10.1.0", + "@grafana/e2e-selectors": "10.1.0", + "@grafana/eslint-config": "^6.0.0", + "@grafana/tsconfig": "^1.2.0-rc1", + "@swc/core": "^1.3.90", + "@swc/helpers": "^0.5.0", + "@swc/jest": "^0.2.26", + "@testing-library/jest-dom": "6.1.4", + "@testing-library/react": "14.0.0", + "@types/jest": "^29.5.0", + "@types/lodash": "^4.14.194", + "@types/node": "^20.8.7", + "@types/react-router-dom": "^5.2.0", + "@types/testing-library__jest-dom": "5.14.8", + "copy-webpack-plugin": "^11.0.0", + "css-loader": "^6.7.3", + "eslint-plugin-deprecation": "^2.0.0", + "eslint-webpack-plugin": "^4.0.1", + "fork-ts-checker-webpack-plugin": "^8.0.0", + "glob": "^10.2.7", + "identity-obj-proxy": "3.0.0", + "jest": "^29.5.0", + "jest-environment-jsdom": "^29.5.0", + "prettier": "^2.8.7", + "replace-in-file-webpack-plugin": "^1.0.6", + "sass": "1.63.2", + "sass-loader": "13.3.1", + "style-loader": "3.3.3", + "swc-loader": "^0.2.3", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "typescript": "4.8.4", + "webpack": "^5.86.0", + "webpack-cli": "^5.1.4", + "webpack-livereload-plugin": "^3.0.2" }, "engines": { - "node": ">=14" - } + "node": ">=20" + }, + "dependencies": { + "@emotion/css": "11.10.6", + "@grafana/data": "10.1.0", + "@grafana/runtime": "10.1.0", + "@grafana/schema": "10.1.0", + "@grafana/ui": "10.1.0", + "react": "18.2.0", + "react-dom": "18.2.0", + "tslib": "2.5.3" + }, + "packageManager": "yarn@1.22.21" } diff --git a/pkg/main.go b/pkg/main.go new file mode 100644 index 0000000..15ec3ac --- /dev/null +++ b/pkg/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "os" + + "github.com/GridProtectionAlliance/osisoftpi-grafana/pkg/plugin" + "github.com/grafana/grafana-plugin-sdk-go/backend/datasource" + "github.com/grafana/grafana-plugin-sdk-go/backend/log" +) + +func main() { + // Start listening to requests sent from Grafana. This call is blocking so + // it won't finish until Grafana shuts down the process or the plugin choose + // to exit by itself using os.Exit. Manage automatically manages life cycle + // of datasource instances. It accepts datasource instance factory as first + // argument. This factory will be automatically called on incoming request + // from Grafana to create different instances of SampleDatasource (per datasource + // ID). When datasource configuration changed Dispose method will be called and + // new datasource instance created using NewSampleDatasource factory. + if err := datasource.Manage("gridprotectionalliance-osisoftpi-datasource", plugin.NewPIWebAPIDatasource, datasource.ManageOpts{}); err != nil { + log.DefaultLogger.Error("Manage", "Plugin", err.Error()) + os.Exit(1) + } +} diff --git a/pkg/plugin/annotation_models.go b/pkg/plugin/annotation_models.go new file mode 100644 index 0000000..1973ebe --- /dev/null +++ b/pkg/plugin/annotation_models.go @@ -0,0 +1,203 @@ +package plugin + +import ( + "encoding/json" + "time" +) + +type PIAnnotationQuery struct { + RefID string `json:"RefID"` + QueryType string `json:"QueryType"` + MaxDataPoints int `json:"MaxDataPoints"` + Interval int64 `json:"Interval"` + TimeRange TimeRange `json:"TimeRange"` + JSON PIWebAPIAnnotationQuery `json:"JSON"` +} + +type TimeRange struct { + From time.Time `json:"From"` + To time.Time `json:"To"` +} + +type PIWebAPIAnnotationQuery struct { + CategoryName string `json:"categoryName"` + NameFilter string `json:"nameFilter"` + Attribute AnnotationAttribute `json:"attribute"` + Database AFDatabase `json:"database"` + Datasource Datasource `json:"datasource"` + DatasourceID int `json:"datasourceId"` + IsAnnotation bool `json:"isAnnotation"` + MaxDataPoints int `json:"maxDataPoints"` + QueryType string `json:"queryType"` + RefID string `json:"refId"` + Template EventFrameTemplate `json:"template"` +} + +type AnnotationAttribute struct { + Enable bool `json:"enable"` + Name string `json:"name"` +} + +type AFDatabase struct { + Description string `json:"Description"` + ExtendedProperties ExtendedProperties `json:"ExtendedProperties"` + Id string `json:"Id"` + Links Links `json:"Links"` + Name string `json:"Name"` + Path string `json:"Path"` + WebId string `json:"WebId"` +} + +type ExtendedProperties struct { + DefaultPIServer ValueContainer `json:"DefaultPIServer"` + DefaultPIServerID ValueContainer `json:"DefaultPIServerID"` +} + +type ValueContainer struct { + Value string `json:"Value"` +} + +type AssetDatabaseLinks struct { + AnalysisCategories string `json:"AnalysisCategories"` + AnalysisTemplates string `json:"AnalysisTemplates"` + AssetServer string `json:"AssetServer"` + AttributeCategories string `json:"AttributeCategories"` + ElementCategories string `json:"ElementCategories"` + ElementTemplates string `json:"ElementTemplates"` + Elements string `json:"Elements"` + EnumerationSets string `json:"EnumerationSets"` + EventFrames string `json:"EventFrames"` + Security string `json:"Security"` + SecurityEntries string `json:"SecurityEntries"` + Self string `json:"Self"` + TableCategories string `json:"TableCategories"` + Tables string `json:"Tables"` +} + +type GrafanaDatasource struct { + Type string `json:"type"` + Uid string `json:"uid"` +} + +type EventFrameTemplate struct { + InstanceType string `json:"InstanceType"` + Name string `json:"Name"` + WebId string `json:"WebId"` +} + +type PiProcessedAnnotationQuery struct { + RefID string `json:"RefID"` + TimeRange TimeRange `json:"TimeRange"` + Database AFDatabase `json:"Database"` + Template EventFrameTemplate `json:"Template"` + CategoryName string `json:"categoryName"` + NameFilter string `json:"nameFilter"` + Attributes []QueryProperties `json:"attributes"` + AttributesEnabled bool `json:"attributesEnabled"` + Error error `json:"Error"` +} + +type AnnotationBatchRequest map[string]AnnotationRequest + +type AnnotationRequest struct { + Method string `json:"Method"` + Resource string `json:"Resource,omitempty"` + RequestTemplate *AnnotationRequestTemplate `json:"RequestTemplate,omitempty"` + Parameters []string `json:"Parameters,omitempty"` + ParentIds []string `json:"ParentIds,omitempty"` +} + +type AnnotationRequestTemplate struct { + Resource string `json:"Resource"` +} + +type AnnotationBatchResponse struct { + Status int `json:"Status"` + Headers map[string]string `json:"Headers"` + Content json.RawMessage `json:"Content"` +} + +type EventFrameResponse struct { + Links struct { + First string `json:"First"` + Last string `json:"Last"` + } `json:"Links"` + Items []struct { + WebID string `json:"WebId"` + ID string `json:"Id"` + Name string `json:"Name"` + Description string `json:"Description"` + Path string `json:"Path"` + TemplateName string `json:"TemplateName"` + HasChildren bool `json:"HasChildren"` + CategoryNames []any `json:"CategoryNames"` + ExtendedProperties struct { + } `json:"ExtendedProperties"` + StartTime time.Time `json:"StartTime"` + EndTime time.Time `json:"EndTime"` + Severity string `json:"Severity"` + AcknowledgedBy string `json:"AcknowledgedBy"` + AcknowledgedDate time.Time `json:"AcknowledgedDate"` + CanBeAcknowledged bool `json:"CanBeAcknowledged"` + IsAcknowledged bool `json:"IsAcknowledged"` + IsAnnotated bool `json:"IsAnnotated"` + IsLocked bool `json:"IsLocked"` + AreValuesCaptured bool `json:"AreValuesCaptured"` + RefElementWebIds []any `json:"RefElementWebIds"` + Security struct { + CanAnnotate bool `json:"CanAnnotate"` + CanDelete bool `json:"CanDelete"` + CanExecute bool `json:"CanExecute"` + CanRead bool `json:"CanRead"` + CanReadData bool `json:"CanReadData"` + CanSubscribe bool `json:"CanSubscribe"` + CanSubscribeOthers bool `json:"CanSubscribeOthers"` + CanWrite bool `json:"CanWrite"` + CanWriteData bool `json:"CanWriteData"` + HasAdmin bool `json:"HasAdmin"` + Rights []string `json:"Rights"` + } `json:"Security"` + Links struct { + Self string `json:"Self"` + Attributes string `json:"Attributes"` + EventFrames string `json:"EventFrames"` + Database string `json:"Database"` + ReferencedElements string `json:"ReferencedElements"` + Template string `json:"Template"` + Categories string `json:"Categories"` + InterpolatedData string `json:"InterpolatedData"` + RecordedData string `json:"RecordedData"` + PlotData string `json:"PlotData"` + SummaryData string `json:"SummaryData"` + Value string `json:"Value"` + EndValue string `json:"EndValue"` + Security string `json:"Security"` + SecurityEntries string `json:"SecurityEntries"` + } `json:"Links"` + } `json:"Items"` +} + +type EventFrameAttribute struct { + Total int `json:"Total"` + Items []struct { + Status int `json:"Status"` + Headers struct { + ContentType string `json:"Content-Type"` + } `json:"Headers"` + Content struct { + Items []struct { + WebID string `json:"WebId"` + Name string `json:"Name"` + Value struct { + Timestamp time.Time `json:"Timestamp"` + Value interface{} `json:"Value"` + UnitsAbbreviation string `json:"UnitsAbbreviation"` + Good bool `json:"Good"` + Questionable bool `json:"Questionable"` + Substituted bool `json:"Substituted"` + Annotated bool `json:"Annotated"` + } `json:"Value"` + } `json:"Items"` + } `json:"Content"` + } `json:"Items"` +} diff --git a/pkg/plugin/annotation_query.go b/pkg/plugin/annotation_query.go new file mode 100644 index 0000000..ebcc520 --- /dev/null +++ b/pkg/plugin/annotation_query.go @@ -0,0 +1,253 @@ +package plugin + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "strconv" + "strings" + "time" + + "github.com/grafana/grafana-plugin-sdk-go/backend" + "github.com/grafana/grafana-plugin-sdk-go/backend/log" + "github.com/grafana/grafana-plugin-sdk-go/data" +) + +func (d *Datasource) processAnnotationQuery(ctx context.Context, query backend.DataQuery) PiProcessedAnnotationQuery { + var ProcessedQuery PiProcessedAnnotationQuery + var PiAnnotationQuery PIAnnotationQuery + + // Unmarshal the query into a PiQuery struct, and then unmarshal the PiQuery into a PiProcessedQuery + // if there are errors we'll set the error and return the PiProcessedQuery with an error set. + tempJson, err := json.Marshal(query) + if err != nil { + log.DefaultLogger.Error("Error marshalling query", "error", err) + + // create a processed query with the error set + ProcessedQuery = PiProcessedAnnotationQuery{ + Error: err, + } + return ProcessedQuery + } + + err = json.Unmarshal(tempJson, &PiAnnotationQuery) + if err != nil { + log.DefaultLogger.Error("Error unmarshalling query", "error", err) + + // create a processed query with the error set + ProcessedQuery = PiProcessedAnnotationQuery{ + Error: err, + } + return ProcessedQuery + } + + var attributes []QueryProperties + + if PiAnnotationQuery.JSON.Attribute.Name != "" && PiAnnotationQuery.JSON.Attribute.Enable { + // Splitting by comma + rawAttributes := strings.Split(PiAnnotationQuery.JSON.Attribute.Name, ",") + + // Iterating through each name, trimming the space, and then appending it to the slice + for _, name := range rawAttributes { + // strip out empty attribute names + if name == "" { + continue + } + attribute := QueryProperties{ + Label: strings.TrimSpace(name), + Value: QueryPropertiesValue{ + Value: strings.TrimSpace(name), + }, + } + attributes = append(attributes, attribute) + } + } + + //create a processed query for the annotation query + ProcessedQuery = PiProcessedAnnotationQuery{ + RefID: PiAnnotationQuery.RefID, + TimeRange: PiAnnotationQuery.TimeRange, + Database: PiAnnotationQuery.JSON.Database, + Template: PiAnnotationQuery.JSON.Template, + CategoryName: PiAnnotationQuery.JSON.CategoryName, + NameFilter: PiAnnotationQuery.JSON.NameFilter, + Attributes: attributes, + AttributesEnabled: PiAnnotationQuery.JSON.Attribute.Enable, + } + + return ProcessedQuery +} + +func (q PiProcessedAnnotationQuery) getTimeRangeURIComponent() string { + return "&startTime=" + q.TimeRange.From.UTC().Format(time.RFC3339) + "&endTime=" + q.TimeRange.To.UTC().Format(time.RFC3339) +} + +// getEventFrameQueryURL returns the URI for the event frame query +func (q PiProcessedAnnotationQuery) getEventFrameQueryURL() string { + //example uri: + //http(s):////assetdatabases//eventframes?templateName=