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AaoC,qBAAf,QAAgC,IAC7CC,YAAarC,EAAaqC,eAqDpBC,gBAjDetC,IACvBH,EAAS,OAAD,UAAMD,EAAN,CAAaI,aAAAA,WAmDjB,iBAAKiB,MAAO,CAAEsB,QAAS,OAAQC,IAAK,OAApC,WACE,SAAC,EAAAC,OAAD,CAAQC,QAAS,IAAM7B,EAAU8B,QAAQ,gBAAiB,4BAA6BC,QAAQ,UAA/F,sBAGA,SAAC,EAAAH,OAAD,CACEC,QAAS,IAAM7B,EAAUgC,QAAQ,gBAAiB,2BAA4B,qBAC9ED,QAAQ,YAFV,sBAMA,SAAC,EAAAH,OAAD,CACEC,QAAS,IAAM7B,EAAUiC,MAAM,cAAe,2BAA4B,0BAC1EF,QAAQ,cAFV,4BAYH,SAAS7C,IACd,MAAMuB,EAAqC,CACzCC,YAAa,CACXC,SAAU,CACRuB,MAAO,CACLC,KAAMC,EAAAA,iBAAAA,iBAGVxB,UAAW,IAEbyB,iBAAmBC,GAAcA,EACjCC,MAAOC,EAAAA,GAAAA,QAGHC,EAAa,CACjBC,mBAAoB,IAAM,GAC1BC,wBAAyB,IAAMlC,EAC/BmC,eAAgB,KAAM,CAAGC,aAAa,EAAOC,aAAa,KAG5D,MAAO,CACL1D,YAAa,IAAI2D,EAAAA,EAAiBN,GAClCtD,aAAc,CACZnE,QAAS,GACTwB,WAAY,CACVwG,KAAM,iBAERzB,cAAe,MAKrB,W,2DC7IA,QARA,SAAuB0B,EAAaC,GAChC,IAAIC,GAAK,IAAAlE,UAASiE,GAAeE,EAAQD,EAAG,GAAIpH,EAASoH,EAAG,GAK5D,OAJA,QAA0B,WACtB,IAAIE,EAAIJ,EAAYK,UAAUvH,GAC9B,OAAO,WAAc,OAAOsH,EAAEE,iBAC/B,CAACN,IACGG","sources":["webpack://grafana/./public/app/features/query/components/QueryEditorRows.tsx","webpack://grafana/./public/app/features/sandbox/TestStuffPage.tsx","webpack://grafana/./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/useObservable.js"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport { DragDropContext, DragStart, Droppable, DropResult } from 'react-beautiful-dnd';\n\nimport {\n CoreApp,\n DataQuery,\n DataSourceInstanceSettings,\n DataSourceRef,\n EventBusExtended,\n HistoryItem,\n PanelData,\n} from '@grafana/data';\nimport { getDataSourceSrv, reportInteraction } from '@grafana/runtime';\n\nimport { QueryEditorRow } from './QueryEditorRow';\n\ninterface Props {\n // The query configuration\n queries: DataQuery[];\n dsSettings: DataSourceInstanceSettings;\n\n // Query editing\n onQueriesChange: (queries: DataQuery[]) => void;\n onAddQuery: (query: DataQuery) => void;\n onRunQueries: () => void;\n\n // Query Response Data\n data: PanelData;\n\n // Misc\n app?: CoreApp;\n history?: Array>;\n eventBus?: EventBusExtended;\n}\n\nexport class QueryEditorRows extends PureComponent {\n onRemoveQuery = (query: DataQuery) => {\n this.props.onQueriesChange(this.props.queries.filter((item) => item !== query));\n };\n\n onChangeQuery(query: DataQuery, index: number) {\n const { queries, onQueriesChange } = this.props;\n\n // update query in array\n onQueriesChange(\n queries.map((item, itemIndex) => {\n if (itemIndex === index) {\n return query;\n }\n return item;\n })\n );\n }\n\n onDataSourceChange(dataSource: DataSourceInstanceSettings, index: number) {\n const { queries, onQueriesChange } = this.props;\n\n onQueriesChange(\n queries.map((item, itemIndex) => {\n if (itemIndex !== index) {\n return item;\n }\n\n const dataSourceRef: DataSourceRef = {\n type: dataSource.type,\n uid: dataSource.uid,\n };\n\n if (item.datasource) {\n const previous = getDataSourceSrv().getInstanceSettings(item.datasource);\n\n if (previous?.type === dataSource.type) {\n return {\n ...item,\n datasource: dataSourceRef,\n };\n }\n }\n\n return {\n refId: item.refId,\n hide: item.hide,\n datasource: dataSourceRef,\n };\n })\n );\n }\n\n onDragStart = (result: DragStart) => {\n const { queries, dsSettings } = this.props;\n\n reportInteraction('query_row_reorder_started', {\n startIndex: result.source.index,\n numberOfQueries: queries.length,\n datasourceType: dsSettings.type,\n });\n };\n\n onDragEnd = (result: DropResult) => {\n const { queries, onQueriesChange, dsSettings } = this.props;\n\n if (!result || !result.destination) {\n return;\n }\n\n const startIndex = result.source.index;\n const endIndex = result.destination.index;\n if (startIndex === endIndex) {\n reportInteraction('query_row_reorder_canceled', {\n startIndex,\n endIndex,\n numberOfQueries: queries.length,\n datasourceType: dsSettings.type,\n });\n return;\n }\n\n const update = Array.from(queries);\n const [removed] = update.splice(startIndex, 1);\n update.splice(endIndex, 0, removed);\n onQueriesChange(update);\n\n reportInteraction('query_row_reorder_ended', {\n startIndex,\n endIndex,\n numberOfQueries: queries.length,\n datasourceType: dsSettings.type,\n });\n };\n\n render() {\n const { dsSettings, data, queries, app, history, eventBus } = this.props;\n\n return (\n \n \n {(provided) => {\n return (\n
\n {queries.map((query, index) => {\n const dataSourceSettings = getDataSourceSettings(query, dsSettings);\n const onChangeDataSourceSettings = dsSettings.meta.mixed\n ? (settings: DataSourceInstanceSettings) => this.onDataSourceChange(settings, index)\n : undefined;\n\n return (\n this.onChangeQuery(query, index)}\n onRemoveQuery={this.onRemoveQuery}\n onAddQuery={this.props.onAddQuery}\n onRunQuery={this.props.onRunQueries}\n queries={queries}\n app={app}\n history={history}\n eventBus={eventBus}\n />\n );\n })}\n {provided.placeholder}\n
\n );\n }}\n
\n
\n );\n }\n}\n\nconst getDataSourceSettings = (\n query: DataQuery,\n groupSettings: DataSourceInstanceSettings\n): DataSourceInstanceSettings => {\n if (!query.datasource) {\n return groupSettings;\n }\n const querySettings = getDataSourceSrv().getInstanceSettings(query.datasource);\n return querySettings || groupSettings;\n};\n","import React, { FC, useMemo, useState } from 'react';\nimport { useObservable } from 'react-use';\nimport AutoSizer from 'react-virtualized-auto-sizer';\n\nimport {\n ApplyFieldOverrideOptions,\n DataTransformerConfig,\n dateMath,\n FieldColorModeId,\n NavModelItem,\n PanelData,\n} from '@grafana/data';\nimport { Button, Table } from '@grafana/ui';\nimport { config } from 'app/core/config';\nimport { useAppNotification } from 'app/core/copy/appNotification';\nimport { QueryGroupOptions } from 'app/types';\n\nimport Page from '../../core/components/Page/Page';\nimport { PanelRenderer } from '../panel/components/PanelRenderer';\nimport { QueryGroup } from '../query/components/QueryGroup';\nimport { PanelQueryRunner } from '../query/state/PanelQueryRunner';\n\ninterface State {\n queryRunner: PanelQueryRunner;\n queryOptions: QueryGroupOptions;\n data?: PanelData;\n}\n\nexport const TestStuffPage: FC = () => {\n const [state, setState] = useState(getDefaultState());\n const { queryOptions, queryRunner } = state;\n\n const onRunQueries = () => {\n const timeRange = { from: 'now-1h', to: 'now' };\n\n queryRunner.run({\n queries: queryOptions.queries,\n datasource: queryOptions.dataSource,\n timezone: 'browser',\n timeRange: { from: dateMath.parse(timeRange.from)!, to: dateMath.parse(timeRange.to)!, raw: timeRange },\n maxDataPoints: queryOptions.maxDataPoints ?? 100,\n minInterval: queryOptions.minInterval,\n });\n };\n\n const onOptionsChange = (queryOptions: QueryGroupOptions) => {\n setState({ ...state, queryOptions });\n };\n\n /**\n * Subscribe to data\n */\n const observable = useMemo(() => queryRunner.getData({ withFieldConfig: true, withTransforms: true }), [queryRunner]);\n const data = useObservable(observable);\n\n const node: NavModelItem = {\n id: 'test-page',\n text: 'Test page',\n icon: 'dashboard',\n subTitle: 'FOR TESTING!',\n url: 'sandbox/test',\n };\n\n const notifyApp = useAppNotification();\n\n return (\n \n \n {data && (\n \n {({ width }) => {\n return (\n
\n \n \n \n );\n }}\n \n )}\n
\n \n
\n
\n \n notifyApp.warning('Warning toast', 'some more text goes here', 'bogus-trace-99999')}\n variant=\"secondary\"\n >\n Warning\n \n notifyApp.error('Error toast', 'some more text goes here', 'bogus-trace-fdsfdfsfds')}\n variant=\"destructive\"\n >\n Error\n \n
\n \n \n );\n};\n\nexport function getDefaultState(): State {\n const options: ApplyFieldOverrideOptions = {\n fieldConfig: {\n defaults: {\n color: {\n mode: FieldColorModeId.PaletteClassic,\n },\n },\n overrides: [],\n },\n replaceVariables: (v: string) => v,\n theme: config.theme2,\n };\n\n const dataConfig = {\n getTransformations: () => [] as DataTransformerConfig[],\n getFieldOverrideOptions: () => options,\n getDataSupport: () => ({ annotations: false, alertStates: false }),\n };\n\n return {\n queryRunner: new PanelQueryRunner(dataConfig),\n queryOptions: {\n queries: [],\n dataSource: {\n name: 'gdev-testdata',\n },\n maxDataPoints: 100,\n },\n };\n}\n\nexport default TestStuffPage;\n","import { useState } from 'react';\nimport useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';\nfunction useObservable(observable$, initialValue) {\n var _a = useState(initialValue), value = _a[0], update = _a[1];\n useIsomorphicLayoutEffect(function () {\n var s = observable$.subscribe(update);\n return function () { return s.unsubscribe(); };\n }, [observable$]);\n return value;\n}\nexport default useObservable;\n"],"names":["QueryEditorRows","PureComponent","query","this","props","onQueriesChange","queries","filter","item","result","dsSettings","reportInteraction","startIndex","source","index","numberOfQueries","length","datasourceType","type","destination","endIndex","update","Array","from","removed","splice","onChangeQuery","map","itemIndex","onDataSourceChange","dataSource","dataSourceRef","uid","datasource","previous","getDataSourceSrv","getInstanceSettings","refId","hide","render","data","app","history","eventBus","onDragStart","onDragEnd","droppableId","direction","provided","ref","innerRef","droppableProps","dataSourceSettings","getDataSourceSettings","onChangeDataSourceSettings","meta","mixed","settings","undefined","id","onChangeDataSource","onChange","onRemoveQuery","onAddQuery","onRunQuery","onRunQueries","placeholder","groupSettings","TestStuffPage","state","setState","useState","getDefaultState","queryOptions","queryRunner","observable","useMemo","getData","withFieldConfig","withTransforms","useObservable","node","text","icon","subTitle","url","notifyApp","useAppNotification","navModel","main","style","width","height","title","pluginId","options","fieldConfig","defaults","overrides","timeZone","Table","series","marginTop","timeRange","to","run","timezone","dateMath","raw","maxDataPoints","minInterval","onOptionsChange","display","gap","Button","onClick","success","variant","warning","error","color","mode","FieldColorModeId","replaceVariables","v","theme","config","dataConfig","getTransformations","getFieldOverrideOptions","getDataSupport","annotations","alertStates","PanelQueryRunner","name","observable$","initialValue","_a","value","s","subscribe","unsubscribe"],"sourceRoot":""}