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

Function replaceWithVariables

ui/src/utils/variable.ts:29–48  ·  view source on GitHub ↗
(s: string, extraVars?: {
    [varName:string]: string | number, 
})

Source from the content-addressed store, hash-verified

27// replace ${xxx} format with corresponding variable
28// extraVars: datav preserved variables, such as __curentValue__
29export const replaceWithVariables = (s: string, extraVars?: {
30 [varName:string]: string | number,
31}) => {
32 const vars = $variables.get()
33 const formats = parseVariableFormat(s);
34 for (const f of formats) {
35 const extrav = extraVars && extraVars[f]
36 if (extrav) {
37 s = s.replaceAll(`\${${f}}`, extrav.toString());
38 } else {
39 const v = vars.find(v => v.name ==f)
40 if (v) {
41 s = s.replaceAll(`\${${f}}`, v.selected);
42 }
43 }
44
45 }
46
47 return s
48}
49
50
51export const replaceQueryWithVariables = (q: PanelQuery, datasource: DatasourceType,interval: string) => {

Callers 12

formatUnitFunction · 0.90
getDatasourceFunction · 0.90
PanelHeaderFunction · 0.90
run_http_queryFunction · 0.90
queryHttpVariableValuesFunction · 0.90
prometheusToSeriesDataFunction · 0.90
filterAlertsFunction · 0.90
Toolbar.tsxFile · 0.90
ComplexTable.tsxFile · 0.90
Gauge.tsxFile · 0.90
onSearchFunction · 0.90
TextPanelFunction · 0.90

Calls 3

parseVariableFormatFunction · 0.90
getMethod · 0.80
findMethod · 0.80

Tested by

no test coverage detected