Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit 9cfb9f0

Browse files
authored
dashboard info by domain (#439)
* get merged config from dashboard_info, based on domain provided (node|room) * get info and colors by domain * 2.28.0 * update dashboard_info.js * 2.28.1 * update dashboard_info.js * 2.28.2 * update dashboard_info.js * 2.28.3 * update dashboard_info.js (from https://github.com/netdata/netdata/blob/00daf1c806b5b405209706cdd699c598f452a9b7/web/gui/dashboard_info.js) * 2.28.4 * 2.28.5
1 parent 866f06b commit 9cfb9f0

File tree

7 files changed

+182
-107
lines changed

7 files changed

+182
-107
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/dashboard",
3-
"version": "2.27.1",
3+
"version": "2.28.5",
44
"homepage": ".",
55
"main": "./lib/src/index-npm.js",
66
"files": [

src/dashboard_info.js

Lines changed: 149 additions & 89 deletions
Large diffs are not rendered by default.

src/domains/chart/chart-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface ChartMetadata {
7070
dimensions: {
7171
[key: string]: Dimension
7272
}
73+
domain?: string
7374
chartLabels?: {
7475
[key: string]: string[]
7576
}

src/domains/charts/getMenuChartAttributes.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const getChartCommon = ({ family, context, units }, type) =>
77
: `${family}/${context}/${units}`
88

99
export default chart => {
10-
const { context, id } = chart
10+
const { context, domain, id } = chart
1111
const commonMin = getChartCommon(chart, "commonMin")
1212
const commonMax = getChartCommon(chart, "commonMax")
1313

@@ -19,11 +19,17 @@ export default chart => {
1919
chartLibrary: "dygraph",
2020
width: "100%",
2121
forceTimeWindow: true,
22-
info: netdataDashboard.contextInfo(context),
22+
info: netdataDashboard.contextInfo(context, domain),
2323
height: netdataDashboard.contextHeight(context, options.chartsHeight),
2424
dygraphValueRange: netdataDashboard.contextValueRange(context),
2525
heightId: `${name2id(`${options.hostname}/${id}`)}`,
26-
colors: `${netdataDashboard.anyAttribute(netdataDashboard.context, "colors", context, "")}`,
26+
colors: `${netdataDashboard.anyAttribute(
27+
netdataDashboard.context,
28+
"colors",
29+
context,
30+
"",
31+
domain
32+
)}`,
2733
decimalDigits: netdataDashboard.contextDecimalDigits(context, -1),
2834
dygraphTitle: "",
2935
dygraphTitleHeight: 0,

src/domains/dashboard/components/node-view/generate-head-charts.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ export const generateHeadCharts = (type: string, chart: ChartMetadata, duration:
1010
// return '';
1111
// }
1212

13-
const hcharts = netdataDashboard.anyAttribute(netdataDashboard.context, type, chart.context, [])
14-
return hcharts.map((hChart: HeadDescription) => (typeof hChart === "function"
15-
? hChart(netdataDashboard.os, chart.id)
16-
.replace(/CHART_DURATION/g, duration.toString())
17-
.replace(/CHART_UNIQUE_ID/g, chart.id)
18-
: hChart.replace(/CHART_DURATION/g, duration.toString())
19-
.replace(/CHART_UNIQUE_ID/g, chart.id)
20-
))
13+
const hcharts = netdataDashboard.anyAttribute(
14+
netdataDashboard.context,
15+
type,
16+
chart.context,
17+
[],
18+
chart.domain
19+
)
20+
return hcharts.map((hChart: HeadDescription) =>
21+
typeof hChart === "function"
22+
? hChart(netdataDashboard.os, chart.id)
23+
.replace(/CHART_DURATION/g, duration.toString())
24+
.replace(/CHART_UNIQUE_ID/g, chart.id)
25+
: hChart.replace(/CHART_DURATION/g, duration.toString()).replace(/CHART_UNIQUE_ID/g, chart.id)
26+
)
2127
}

src/domains/dashboard/utils/netdata-dashboard.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ export const netdataDashboard = {
127127
+ " role=\"application\"></div>"
128128
},
129129

130-
anyAttribute(obj: AnyStringKeyT, attr: string, key: string, def: unknown) {
130+
anyAttribute(obj: AnyStringKeyT, attr: string, key: string, def: unknown, domain?: string) {
131131
if (typeof (obj[key]) !== "undefined") {
132-
const x = obj[key][attr]
132+
const config = obj[key]
133+
const configWithDomain = domain ? {...config, ...config[domain]} : config
134+
const x = configWithDomain[attr]
133135

134-
if (typeof (x) === "undefined") {
136+
if (x === undefined) {
135137
return def
136138
}
137139

@@ -209,8 +211,8 @@ export const netdataDashboard = {
209211
return this.anyAttribute(this.submenu, "height", key, 1.0) * relative
210212
},
211213

212-
contextInfo(id: string) {
213-
const x = this.anyAttribute(this.context, "info", id, null)
214+
contextInfo(id: string, domain?: string) {
215+
const x = this.anyAttribute(this.context, "info", id, null, domain)
214216

215217
if (x !== null) {
216218
return `<div class="shorten dashboard-context-info"

0 commit comments

Comments
 (0)