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

Commit

Permalink
dashboard info by domain (#439)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jacekkolasa authored Aug 22, 2022
1 parent 866f06b commit 9cfb9f0
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 107 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netdata/dashboard",
"version": "2.27.1",
"version": "2.28.5",
"homepage": ".",
"main": "./lib/src/index-npm.js",
"files": [
Expand Down
238 changes: 149 additions & 89 deletions src/dashboard_info.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/domains/chart/chart-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface ChartMetadata {
dimensions: {
[key: string]: Dimension
}
domain?: string
chartLabels?: {
[key: string]: string[]
}
Expand Down
12 changes: 9 additions & 3 deletions src/domains/charts/getMenuChartAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getChartCommon = ({ family, context, units }, type) =>
: `${family}/${context}/${units}`

export default chart => {
const { context, id } = chart
const { context, domain, id } = chart
const commonMin = getChartCommon(chart, "commonMin")
const commonMax = getChartCommon(chart, "commonMax")

Expand All @@ -19,11 +19,17 @@ export default chart => {
chartLibrary: "dygraph",
width: "100%",
forceTimeWindow: true,
info: netdataDashboard.contextInfo(context),
info: netdataDashboard.contextInfo(context, domain),
height: netdataDashboard.contextHeight(context, options.chartsHeight),
dygraphValueRange: netdataDashboard.contextValueRange(context),
heightId: `${name2id(`${options.hostname}/${id}`)}`,
colors: `${netdataDashboard.anyAttribute(netdataDashboard.context, "colors", context, "")}`,
colors: `${netdataDashboard.anyAttribute(
netdataDashboard.context,
"colors",
context,
"",
domain
)}`,
decimalDigits: netdataDashboard.contextDecimalDigits(context, -1),
dygraphTitle: "",
dygraphTitleHeight: 0,
Expand Down
22 changes: 14 additions & 8 deletions src/domains/dashboard/components/node-view/generate-head-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ export const generateHeadCharts = (type: string, chart: ChartMetadata, duration:
// return '';
// }

const hcharts = netdataDashboard.anyAttribute(netdataDashboard.context, type, chart.context, [])
return hcharts.map((hChart: HeadDescription) => (typeof hChart === "function"
? hChart(netdataDashboard.os, chart.id)
.replace(/CHART_DURATION/g, duration.toString())
.replace(/CHART_UNIQUE_ID/g, chart.id)
: hChart.replace(/CHART_DURATION/g, duration.toString())
.replace(/CHART_UNIQUE_ID/g, chart.id)
))
const hcharts = netdataDashboard.anyAttribute(
netdataDashboard.context,
type,
chart.context,
[],
chart.domain
)
return hcharts.map((hChart: HeadDescription) =>
typeof hChart === "function"
? hChart(netdataDashboard.os, chart.id)
.replace(/CHART_DURATION/g, duration.toString())
.replace(/CHART_UNIQUE_ID/g, chart.id)
: hChart.replace(/CHART_DURATION/g, duration.toString()).replace(/CHART_UNIQUE_ID/g, chart.id)
)
}
12 changes: 7 additions & 5 deletions src/domains/dashboard/utils/netdata-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ export const netdataDashboard = {
+ " role=\"application\"></div>"
},

anyAttribute(obj: AnyStringKeyT, attr: string, key: string, def: unknown) {
anyAttribute(obj: AnyStringKeyT, attr: string, key: string, def: unknown, domain?: string) {
if (typeof (obj[key]) !== "undefined") {
const x = obj[key][attr]
const config = obj[key]
const configWithDomain = domain ? {...config, ...config[domain]} : config
const x = configWithDomain[attr]

if (typeof (x) === "undefined") {
if (x === undefined) {
return def
}

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

contextInfo(id: string) {
const x = this.anyAttribute(this.context, "info", id, null)
contextInfo(id: string, domain?: string) {
const x = this.anyAttribute(this.context, "info", id, null, domain)

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

0 comments on commit 9cfb9f0

Please sign in to comment.