MCPcopy
hub / github.com/deepops-ai/deepops / EditPanelQuery

Function EditPanelQuery

ui/src/views/dashboard/edit-panel/Query.tsx:44–132  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

42}
43
44const EditPanelQuery = (props: Props) => {
45 const t = useStore(commonMsg)
46 const t1 = useStore(panelMsg)
47 const { panel, onChange } = props
48 const selectDatasource = (id) => {
49 onChange((panel: Panel) => {
50 panel.datasource = { ...initDatasource, id: id }
51 })
52 }
53
54 const onAddQuery = () => {
55 onChange((panel: Panel) => {
56 const ds = panel.datasource
57 if (!ds.queries) {
58 ds.queries = []
59 }
60
61 let id = 65; // from 'A' to 'Z'
62 for (const q of ds.queries) {
63 if (q.id >= id) {
64 id = q.id + 1
65 }
66 }
67
68
69 ds.queries.push({
70 id: id,
71 metrics: "",
72 legend: "",
73 visible: true,
74 data: {}
75 })
76 })
77 }
78
79 const removeQuery = id => {
80 onChange((panel: Panel) => {
81 const ds = panel.datasource
82 if (!ds.queries) {
83 ds.queries = []
84 }
85
86 ds.queries = ds.queries.filter(q => q.id != id)
87 })
88 }
89
90 const onVisibleChange = (id, visible) => {
91 onChange((panel: Panel) => {
92 const ds = panel.datasource
93 for (var i = 0; i < ds.queries.length; i++) {
94 if (ds.queries[i].id === id) {
95 ds.queries[i].visible = visible
96 break
97 }
98 }
99 })
100 }
101 const currentDatasource = getDatasource(panel.datasource.id)

Callers

nothing calls this directly

Calls 3

getDatasourceFunction · 0.90
onVisibleChangeFunction · 0.85
removeQueryFunction · 0.85

Tested by

no test coverage detected