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,gBAAKA,UAAU,wBAAf,UACE,SAAC,EAAAlE,MAAD,CAAOG,YAAY,oBAAoBF,SAdpBN,IACvBA,EAAEuI,OAAOpK,MACXyL,EAAS7B,EAAMpB,QAAQ7G,GAASA,EAAKrB,QAAQ4L,cAAcC,SAAStK,EAAEuI,OAAOpK,MAAMkM,kBAEnFT,EAASC,WAcP,SAAC/B,EAAD,CAAeC,MAAOA,EAAO2B,cAAeS,EAAWzB,WAAYqB,KAEnE,SAAC3L,EAAD,CACEC,YAAcoG,IACZ9E,QAAQC,IAAI,MAAO6E,EAAG,KAAMsD,EAAM,IAClCiC,EAAWvF,GACX0F","sources":["webpack://grafana/./public/app/core/hooks/useNavModel.ts","webpack://grafana/./public/app/features/live/pages/AddNewRule.tsx","webpack://grafana/./public/app/features/live/pages/RuleSettingsEditor.tsx","webpack://grafana/./public/app/features/live/pages/RuleSettingsArray.tsx","webpack://grafana/./public/app/features/live/pages/RuleTest.tsx","webpack://grafana/./public/app/features/live/pages/utils.ts","webpack://grafana/./public/app/features/live/pages/RuleModal.tsx","webpack://grafana/./public/app/features/live/pages/PipelineTable.tsx","webpack://grafana/./public/app/features/live/pages/PipelineAdminPage.tsx"],"sourcesContent":["import { useSelector } from 'react-redux';\n\nimport { NavModel } from '@grafana/data';\nimport { StoreState } from 'app/types/store';\n\nimport { getNavModel } from '../selectors/navModel';\n\nexport const useNavModel = (id: string): NavModel => {\n const navIndex = useSelector((state: StoreState) => state.navIndex);\n return getNavModel(navIndex, id);\n};\n","import React, { useState } from 'react';\n\nimport { DataSourceRef, LiveChannelScope, SelectableValue } from '@grafana/data';\nimport { DataSourcePicker, getBackendSrv } from '@grafana/runtime';\nimport { Input, Field, Button, ValuePicker, HorizontalGroup } from '@grafana/ui';\nimport { useAppNotification } from 'app/core/copy/appNotification';\n\nimport { Rule } from './types';\n\ninterface Props {\n onRuleAdded: (rule: Rule) => void;\n}\n\ntype PatternType = 'ds' | 'any';\n\nconst patternTypes: Array<SelectableValue<PatternType>> = [\n {\n label: 'Data source',\n description: 'Configure a channel scoped to a data source instance',\n value: 'ds',\n },\n {\n label: 'Any',\n description: 'Enter an arbitray channel pattern',\n value: 'any',\n },\n];\n\nexport function AddNewRule({ onRuleAdded }: Props) {\n const [patternType, setPatternType] = useState<PatternType>();\n const [pattern, setPattern] = useState<string>();\n const [patternPrefix, setPatternPrefix] = useState<string>('');\n const [datasource, setDatasource] = useState<DataSourceRef>();\n const notifyApp = useAppNotification();\n\n const onSubmit = () => {\n if (!pattern) {\n notifyApp.error('Enter path');\n return;\n }\n if (patternType === 'ds' && !patternPrefix.length) {\n notifyApp.error('Select datasource');\n return;\n }\n\n getBackendSrv()\n .post(`api/live/channel-rules`, {\n pattern: patternPrefix + pattern,\n settings: {\n converter: {\n type: 'jsonAuto',\n },\n frameOutputs: [\n {\n type: 'managedStream',\n },\n ],\n },\n })\n .then((v: any) => {\n console.log('ADDED', v);\n setPattern(undefined);\n setPatternType(undefined);\n onRuleAdded(v.rule);\n })\n .catch((e) => {\n notifyApp.error('Error adding rule', e);\n e.isHandled = true;\n });\n };\n\n if (patternType) {\n return (\n <div>\n <HorizontalGroup>\n {patternType === 'any' && (\n <Field label=\"Pattern\">\n <Input\n value={pattern ?? ''}\n onChange={(e) => setPattern(e.currentTarget.value)}\n placeholder=\"scope/namespace/path\"\n />\n </Field>\n )}\n {patternType === 'ds' && (\n <>\n <Field label=\"Data source\">\n <DataSourcePicker\n current={datasource}\n onChange={(ds) => {\n setDatasource(ds);\n setPatternPrefix(`${LiveChannelScope.DataSource}/${ds.uid}/`);\n }}\n />\n </Field>\n <Field label=\"Path\">\n <Input value={pattern ?? ''} onChange={(e) => setPattern(e.currentTarget.value)} placeholder=\"path\" />\n </Field>\n </>\n )}\n\n <Field label=\"\">\n <Button onClick={onSubmit} variant={pattern?.length ? 'primary' : 'secondary'}>\n Add\n </Button>\n </Field>\n\n <Field label=\"\">\n <Button variant=\"secondary\" onClick={() => setPatternType(undefined)}>\n Cancel\n </Button>\n </Field>\n </HorizontalGroup>\n </div>\n );\n }\n\n return (\n <div>\n <ValuePicker\n label=\"Add channel rule\"\n variant=\"secondary\"\n size=\"md\"\n icon=\"plus\"\n menuPlacement=\"auto\"\n isFullWidth={false}\n options={patternTypes}\n onChange={(v) => setPatternType(v.value)}\n />\n </div>\n );\n}\n","import React from 'react';\n\nimport { CodeEditor, Select } from '@grafana/ui';\n\nimport { RuleType, RuleSetting, PipeLineEntitiesInfo } from './types';\n\ninterface Props {\n ruleType: RuleType;\n onChange: (value: RuleSetting) => void;\n value: RuleSetting;\n entitiesInfo: PipeLineEntitiesInfo;\n}\n\nexport const RuleSettingsEditor: React.FC<Props> = ({ onChange, value, ruleType, entitiesInfo }) => {\n return (\n <>\n <Select\n key={ruleType}\n options={entitiesInfo[ruleType]}\n placeholder=\"Select an option\"\n value={value?.type ?? ''}\n onChange={(value) => {\n // set the body with example\n const type = value.value;\n onChange({\n type,\n [type]: entitiesInfo.getExample(ruleType, type),\n });\n }}\n />\n <CodeEditor\n height={'50vh'}\n value={value ? JSON.stringify(value[value.type], null, '\\t') : ''}\n showLineNumbers={true}\n readOnly={false}\n language=\"json\"\n showMiniMap={false}\n onBlur={(text: string) => {\n const body = JSON.parse(text);\n onChange({\n type: value.type,\n [value.type]: body,\n });\n }}\n />\n </>\n );\n};\n","import React, { useState } from 'react';\n\nimport { Select } from '@grafana/ui';\n\nimport { SelectableValue } from '../../../../../packages/grafana-data/src';\n\nimport { RuleSettingsEditor } from './RuleSettingsEditor';\nimport { RuleType, RuleSetting, PipeLineEntitiesInfo } from './types';\n\ninterface Props {\n ruleType: RuleType;\n onChange: (value: RuleSetting[]) => void;\n value: RuleSetting[];\n entitiesInfo: PipeLineEntitiesInfo;\n}\n\nexport const RuleSettingsArray: React.FC<Props> = ({ onChange, value, ruleType, entitiesInfo }) => {\n const [index, setIndex] = useState<number>(0);\n const arr = value ?? [];\n const onRuleChange = (v: RuleSetting) => {\n if (!value) {\n onChange([v]);\n } else {\n const copy = [...value];\n copy[index] = v;\n onChange(copy);\n }\n };\n // create array of value.length + 1\n let indexArr: Array<SelectableValue<number>> = [];\n for (let i = 0; i <= arr.length; i++) {\n indexArr.push({\n label: `${ruleType}: ${i}`,\n value: i,\n });\n }\n\n return (\n <>\n <Select\n placeholder=\"Select an index\"\n options={indexArr}\n value={index}\n onChange={(index) => {\n // set index to find the correct setting\n setIndex(index.value!);\n }}\n ></Select>\n <RuleSettingsEditor onChange={onRuleChange} value={arr[index]} ruleType={ruleType} entitiesInfo={entitiesInfo} />\n </>\n );\n};\n","import { css } from '@emotion/css';\nimport React, { useState } from 'react';\n\nimport { dataFrameFromJSON, getDisplayProcessor, GrafanaTheme } from '@grafana/data';\nimport { getBackendSrv, config } from '@grafana/runtime';\nimport { Button, CodeEditor, Table, useStyles, Field } from '@grafana/ui';\n\nimport { ChannelFrame, Rule } from './types';\n\ninterface Props {\n rule: Rule;\n}\n\nexport const RuleTest: React.FC<Props> = (props) => {\n const [response, setResponse] = useState<ChannelFrame[]>();\n const [data, setData] = useState<string>();\n const styles = useStyles(getStyles);\n\n const onBlur = (text: string) => {\n setData(text);\n };\n\n const onClick = () => {\n getBackendSrv()\n .post(`api/live/pipeline-convert-test`, {\n channelRules: [props.rule],\n channel: props.rule.pattern,\n data: data,\n })\n .then((data: any) => {\n const t = data.channelFrames as any[];\n if (t) {\n setResponse(\n t.map((f) => {\n const frame = dataFrameFromJSON(f.frame);\n for (const field of frame.fields) {\n field.display = getDisplayProcessor({ field, theme: config.theme2 });\n }\n return { channel: f.channel, frame };\n })\n );\n }\n })\n .catch((e) => {\n setResponse(e);\n });\n };\n\n return (\n <div>\n <CodeEditor\n height={100}\n value=\"\"\n showLineNumbers={true}\n readOnly={false}\n language=\"json\"\n showMiniMap={false}\n onBlur={onBlur}\n />\n\n <Button onClick={onClick} className={styles.margin}>\n Test\n </Button>\n\n {response?.length &&\n response.map((r) => (\n <Field key={r.channel} label={r.channel}>\n <Table data={r.frame} width={700} height={Math.min(10 * r.frame.length + 10, 150)} showTypeIcons></Table>\n </Field>\n ))}\n </div>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme) => {\n return {\n margin: css`\n margin-bottom: 15px;\n `,\n };\n};\n","import { getBackendSrv } from '@grafana/runtime';\n\nimport { PipelineListOption, PipeLineEntitiesInfo } from './types';\n\nexport async function getPipeLineEntities(): Promise<PipeLineEntitiesInfo> {\n return await getBackendSrv()\n .get(`api/live/pipeline-entities`)\n .then((data) => {\n return {\n converter: transformLabel(data, 'converters'),\n frameProcessors: transformLabel(data, 'frameProcessors'),\n frameOutputs: transformLabel(data, 'frameOutputs'),\n getExample: (ruleType, type) => {\n return data[`${ruleType}s`]?.filter((option: PipelineListOption) => option.type === type)?.[0]?.['example'];\n },\n };\n });\n}\n\nexport function transformLabel(data: any, key: keyof typeof data) {\n if (Array.isArray(data)) {\n return data.map((d) => ({\n label: d[key],\n value: d[key],\n }));\n }\n return data[key].map((typeObj: PipelineListOption) => ({\n label: typeObj.type,\n value: typeObj.type,\n }));\n}\n","import { css } from '@emotion/css';\nimport React, { useState, useMemo } from 'react';\n\nimport { GrafanaTheme } from '@grafana/data';\nimport { getBackendSrv } from '@grafana/runtime';\nimport { Modal, TabContent, TabsBar, Tab, Button, useStyles } from '@grafana/ui';\n\nimport { RuleSettingsArray } from './RuleSettingsArray';\nimport { RuleSettingsEditor } from './RuleSettingsEditor';\nimport { RuleTest } from './RuleTest';\nimport { Rule, RuleType, PipeLineEntitiesInfo, RuleSetting } from './types';\nimport { getPipeLineEntities } from './utils';\n\ninterface Props {\n rule: Rule;\n isOpen: boolean;\n onClose: () => void;\n clickColumn: RuleType;\n}\ninterface TabInfo {\n label: string;\n type?: RuleType;\n isTest?: boolean;\n isConverter?: boolean;\n icon?: string;\n}\nconst tabs: TabInfo[] = [\n { label: 'Converter', type: 'converter', isConverter: true },\n { label: 'Processors', type: 'frameProcessors' },\n { label: 'Outputs', type: 'frameOutputs' },\n { label: 'Test', isTest: true, icon: 'flask' },\n];\n\nexport const RuleModal: React.FC<Props> = (props) => {\n const { isOpen, onClose, clickColumn } = props;\n const [rule, setRule] = useState<Rule>(props.rule);\n const [activeTab, setActiveTab] = useState<TabInfo | undefined>(tabs.find((t) => t.type === clickColumn));\n // to show color of Save button\n const [hasChange, setChange] = useState<boolean>(false);\n const [ruleSetting, setRuleSetting] = useState<any>(activeTab?.type ? rule?.settings?.[activeTab.type] : undefined);\n const [entitiesInfo, setEntitiesInfo] = useState<PipeLineEntitiesInfo>();\n const styles = useStyles(getStyles);\n\n const onRuleSettingChange = (value: RuleSetting | RuleSetting[]) => {\n setChange(true);\n if (activeTab?.type) {\n setRule({\n ...rule,\n settings: {\n ...rule.settings,\n [activeTab?.type]: value,\n },\n });\n }\n setRuleSetting(value);\n };\n\n // load pipeline entities info\n useMemo(() => {\n getPipeLineEntities().then((data) => {\n setEntitiesInfo(data);\n });\n }, []);\n\n const onSave = () => {\n getBackendSrv()\n .put(`api/live/channel-rules`, rule)\n .then(() => {\n setChange(false);\n onClose();\n })\n .catch((e) => console.error(e));\n };\n\n return (\n <Modal isOpen={isOpen} title={rule.pattern} onDismiss={onClose} closeOnEscape>\n <TabsBar>\n {tabs.map((tab, index) => {\n return (\n <Tab\n key={index}\n label={tab.label}\n active={tab === activeTab}\n icon={tab.icon as any}\n onChangeTab={() => {\n setActiveTab(tab);\n if (tab.type) {\n // to notify children of the new rule\n setRuleSetting(rule?.settings?.[tab.type]);\n }\n }}\n />\n );\n })}\n </TabsBar>\n <TabContent>\n {entitiesInfo && rule && activeTab && (\n <>\n {activeTab?.isTest && <RuleTest rule={rule} />}\n {activeTab.isConverter && (\n <RuleSettingsEditor\n onChange={onRuleSettingChange}\n value={ruleSetting}\n ruleType={'converter'}\n entitiesInfo={entitiesInfo}\n />\n )}\n {!activeTab.isConverter && activeTab.type && (\n <RuleSettingsArray\n onChange={onRuleSettingChange}\n value={ruleSetting}\n ruleType={activeTab.type}\n entitiesInfo={entitiesInfo}\n />\n )}\n </>\n )}\n <Button onClick={onSave} className={styles.save} variant={hasChange ? 'primary' : 'secondary'}>\n Save\n </Button>\n </TabContent>\n </Modal>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme) => {\n return {\n save: css`\n margin-top: 5px;\n `,\n };\n};\n","import { css } from '@emotion/css';\nimport React, { useEffect, useState } from 'react';\n\nimport { GrafanaTheme } from '@grafana/data';\nimport { getBackendSrv } from '@grafana/runtime';\nimport { Tag, useStyles, IconButton } from '@grafana/ui';\nimport { getDatasourceSrv } from 'app/features/plugins/datasource_srv';\n\nimport { RuleModal } from './RuleModal';\nimport { Rule, Output, RuleType } from './types';\n\nfunction renderOutputTags(key: string, output?: Output): React.ReactNode {\n if (!output?.type) {\n return null;\n }\n return <Tag key={key} name={output.type} />;\n}\n\ninterface Props {\n rules: Rule[];\n onRuleChanged: () => void;\n selectRule?: Rule;\n}\n\nexport const PipelineTable: React.FC<Props> = (props) => {\n const { rules } = props;\n const [isOpen, setOpen] = useState(false);\n const [selectedRule, setSelectedRule] = useState<Rule>();\n const [clickColumn, setClickColumn] = useState<RuleType>('converter');\n const styles = useStyles(getStyles);\n\n const onRowClick = (rule: Rule, event?: any) => {\n if (!rule) {\n return;\n }\n let column = event?.target?.getAttribute('data-column');\n if (!column || column === 'pattern') {\n column = 'converter';\n }\n setClickColumn(column);\n setSelectedRule(rule);\n setOpen(true);\n };\n\n // Supports selecting a rule from external config (after add rule)\n useEffect(() => {\n if (props.selectRule) {\n onRowClick(props.selectRule);\n }\n }, [props.selectRule]);\n\n const onRemoveRule = (pattern: string) => {\n getBackendSrv()\n .delete(`api/live/channel-rules`, JSON.stringify({ pattern: pattern }))\n .catch((e) => console.error(e))\n .finally(() => {\n props.onRuleChanged();\n });\n };\n\n const renderPattern = (pattern: string) => {\n if (pattern.startsWith('ds/')) {\n const idx = pattern.indexOf('/', 4);\n if (idx > 3) {\n const uid = pattern.substring(3, idx);\n const ds = getDatasourceSrv().getInstanceSettings(uid);\n if (ds) {\n return (\n <div>\n <Tag name={ds.name} colorIndex={1} /> \n <span>{pattern.substring(idx + 1)}</span>\n </div>\n );\n }\n }\n }\n return pattern;\n };\n\n return (\n <div>\n <div className=\"admin-list-table\">\n <table className=\"filter-table filter-table--hover form-inline\">\n <thead>\n <tr>\n <th>Channel</th>\n <th>Converter</th>\n <th>Processor</th>\n <th>Output</th>\n <th style={{ width: 10 }}> </th>\n </tr>\n </thead>\n <tbody>\n {rules.map((rule) => (\n <tr key={rule.pattern} onClick={(e) => onRowClick(rule, e)} className={styles.row}>\n <td data-pattern={rule.pattern} data-column=\"pattern\">\n {renderPattern(rule.pattern)}\n </td>\n <td data-pattern={rule.pattern} data-column=\"converter\">\n {rule.settings?.converter?.type}\n </td>\n <td data-pattern={rule.pattern} data-column=\"processor\">\n {rule.settings?.frameProcessors?.map((processor) => (\n <span key={rule.pattern + processor.type}>{processor.type}</span>\n ))}\n </td>\n <td data-pattern={rule.pattern} data-column=\"output\">\n {rule.settings?.frameOutputs?.map((output) => (\n <span key={rule.pattern + output.type}>{renderOutputTags('out', output)}</span>\n ))}\n </td>\n <td>\n <IconButton\n name=\"trash-alt\"\n onClick={(e) => {\n e.stopPropagation();\n onRemoveRule(rule.pattern);\n }}\n ></IconButton>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {isOpen && selectedRule && (\n <RuleModal\n rule={selectedRule}\n isOpen={isOpen}\n onClose={() => {\n setOpen(false);\n }}\n clickColumn={clickColumn}\n />\n )}\n </div>\n );\n};\n\nconst getStyles = (theme: GrafanaTheme) => {\n return {\n row: css`\n cursor: pointer;\n `,\n };\n};\n","import React, { useEffect, useState, ChangeEvent } from 'react';\n\nimport { getBackendSrv } from '@grafana/runtime';\nimport { Input } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport { useNavModel } from 'app/core/hooks/useNavModel';\n\nimport { AddNewRule } from './AddNewRule';\nimport { PipelineTable } from './PipelineTable';\nimport { Rule } from './types';\n\nexport default function PipelineAdminPage() {\n const [rules, setRules] = useState<Rule[]>([]);\n const [defaultRules, setDefaultRules] = useState<any[]>([]);\n const [newRule, setNewRule] = useState<Rule>();\n const navModel = useNavModel('live-pipeline');\n const [error, setError] = useState<string>();\n\n const loadRules = () => {\n getBackendSrv()\n .get(`api/live/channel-rules`)\n .then((data) => {\n setRules(data.rules ?? []);\n setDefaultRules(data.rules ?? []);\n })\n .catch((e) => {\n if (e.data) {\n setError(JSON.stringify(e.data, null, 2));\n }\n });\n };\n\n useEffect(() => {\n loadRules();\n }, []);\n\n const onSearchQueryChange = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.value) {\n setRules(rules.filter((rule) => rule.pattern.toLowerCase().includes(e.target.value.toLowerCase())));\n } else {\n setRules(defaultRules);\n }\n };\n\n return (\n <Page navModel={navModel}>\n <Page.Contents>\n {error && <pre>{error}</pre>}\n <div className=\"page-action-bar\">\n <div className=\"gf-form gf-form--grow\">\n <Input placeholder=\"Search pattern...\" onChange={onSearchQueryChange} />\n </div>\n </div>\n\n <PipelineTable rules={rules} onRuleChanged={loadRules} selectRule={newRule} />\n\n <AddNewRule\n onRuleAdded={(r: Rule) => {\n console.log('GOT', r, 'vs', rules[0]);\n setNewRule(r);\n loadRules();\n }}\n />\n </Page.Contents>\n </Page>\n );\n}\n"],"names":["useNavModel","id","navIndex","useSelector","state","getNavModel","patternTypes","label","description","value","AddNewRule","onRuleAdded","patternType","setPatternType","useState","pattern","setPattern","patternPrefix","setPatternPrefix","datasource","setDatasource","notifyApp","useAppNotification","onSubmit","length","getBackendSrv","post","settings","converter","type","frameOutputs","then","v","console","log","undefined","rule","catch","e","error","isHandled","HorizontalGroup","Field","Input","onChange","currentTarget","placeholder","DataSourcePicker","current","ds","LiveChannelScope","uid","Button","onClick","variant","ValuePicker","size","icon","menuPlacement","isFullWidth","options","RuleSettingsEditor","ruleType","entitiesInfo","Select","getExample","CodeEditor","height","JSON","stringify","showLineNumbers","readOnly","language","showMiniMap","onBlur","text","body","parse","RuleSettingsArray","index","setIndex","arr","indexArr","i","push","copy","RuleTest","props","response","setResponse","data","setData","styles","useStyles","getStyles","channelRules","channel","t","channelFrames","map","f","frame","dataFrameFromJSON","field","fields","display","getDisplayProcessor","theme","config","className","margin","r","Table","width","Math","min","showTypeIcons","css","transformLabel","key","Array","isArray","d","typeObj","tabs","isConverter","isTest","RuleModal","isOpen","onClose","clickColumn","setRule","activeTab","setActiveTab","find","hasChange","setChange","ruleSetting","setRuleSetting","setEntitiesInfo","onRuleSettingChange","useMemo","async","get","frameProcessors","filter","option","getPipeLineEntities","Modal","title","onDismiss","closeOnEscape","TabsBar","tab","Tab","active","onChangeTab","TabContent","put","save","renderOutputTags","output","Tag","name","PipelineTable","rules","setOpen","selectedRule","setSelectedRule","setClickColumn","onRowClick","event","column","target","getAttribute","useEffect","selectRule","renderPattern","startsWith","idx","indexOf","substring","getDatasourceSrv","getInstanceSettings","colorIndex","style","row","processor","IconButton","stopPropagation","delete","finally","onRuleChanged","PipelineAdminPage","setRules","defaultRules","setDefaultRules","newRule","setNewRule","navModel","setError","loadRules","Page","toLowerCase","includes"],"sourceRoot":""}
|