@cloudcare/guance-front-tools 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,10 +75,10 @@ const grafanaPanelTypeToGuanceChartMap = {
75
75
  };
76
76
  const GRAFANA_KEYWORKD = ['__interval'];
77
77
  function replaceVariableStr(grafanaExpr) {
78
- return grafanaExpr.replace(/\$([\d_\w]+)/g, (match, $0) => {
79
- if (GRAFANA_KEYWORKD.includes($0))
78
+ return grafanaExpr.replace(/\$\{?([\d_\w]+)\}?/g, function (match, variable) {
79
+ if (GRAFANA_KEYWORKD.includes(variable))
80
80
  return match;
81
- return `#{${$0}}`;
81
+ return `#{${variable}}`;
82
82
  });
83
83
  }
84
84
  /**
@@ -205,7 +205,7 @@ function covertPanelToGuanceChart(grafanaPanel, rowPanel) {
205
205
  h: getGuanceHByGrafanaH(pos.h),
206
206
  w: pos.w,
207
207
  },
208
- name: title || '',
208
+ name: replaceVariableStr(title || ''),
209
209
  queries: queries,
210
210
  type: chartType,
211
211
  };
@@ -334,10 +334,10 @@ const covert = (grafanaData) => {
334
334
  var _a;
335
335
  if (_panel.type === 'row') {
336
336
  const _rowPanel = _panel;
337
- guanceGroups.push({
338
- name: _rowPanel.title,
339
- });
340
337
  if (_rowPanel.title) {
338
+ guanceGroups.push({
339
+ name: _rowPanel.title,
340
+ });
341
341
  // 分组展开收起数据
342
342
  guanceExpand[_rowPanel.title] = !_rowPanel.collapsed;
343
343
  }
@@ -79,9 +79,9 @@ const grafanaPanelTypeToGuanceChartMap: { [key: string]: GuanceChartType } = {
79
79
  }
80
80
  const GRAFANA_KEYWORKD = ['__interval']
81
81
  function replaceVariableStr(grafanaExpr: string): string {
82
- return grafanaExpr.replace(/\$([\d_\w]+)/g, (match, $0) => {
83
- if (GRAFANA_KEYWORKD.includes($0)) return match
84
- return `#{${$0}}`
82
+ return grafanaExpr.replace(/\$\{?([\d_\w]+)\}?/g, function (match, variable) {
83
+ if (GRAFANA_KEYWORKD.includes(variable)) return match
84
+ return `#{${variable}}`
85
85
  })
86
86
  }
87
87
  /**
@@ -209,7 +209,7 @@ function covertPanelToGuanceChart(grafanaPanel: Panel, rowPanel: RowPanel | unde
209
209
  h: getGuanceHByGrafanaH(pos.h),
210
210
  w: pos.w,
211
211
  },
212
- name: title || '',
212
+ name: replaceVariableStr(title || ''),
213
213
  queries: queries,
214
214
  type: chartType,
215
215
  }
@@ -335,10 +335,11 @@ const covert = (grafanaData: GrafanaDashboardType): GuanceDashboardType => {
335
335
  grafanaCharts.forEach((_panel) => {
336
336
  if (_panel.type === 'row') {
337
337
  const _rowPanel = _panel as RowPanel
338
- guanceGroups.push({
339
- name: _rowPanel.title,
340
- })
338
+
341
339
  if (_rowPanel.title) {
340
+ guanceGroups.push({
341
+ name: _rowPanel.title,
342
+ })
342
343
  // 分组展开收起数据
343
344
  guanceExpand[_rowPanel.title] = !_rowPanel.collapsed
344
345
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/guance-front-tools",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },