Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// We don't need to go deeper than 100, prevents circular substitution
var i = 0;
while(i < 100 && !doSubsitutePossible(vars)) {
i++;
}
}
var templateVariables = config.get('gen-dashboard.variable');
substituteVariables(templateVariables);
function getTarget(path) {
return strformat(config.get('gen-dashboard.template.' + path),
templateVariables);
}
var dashboard = new grafana.Dashboard({
title: config.get('gen-dashboard.dashboard-title')
});
function lineGraph(opts) {
var graph = new grafana.Panels.Graph(opts);
graph.state.fill = 0;
return graph;
}
function createSystemRow() {
var row = new grafana.Row();
row.state.title = 'SYSTEM';
row.state.showTitle = true;
row.addPanel(lineGraph({
export function createDashboard(dbdata: GrafanaDBData) {
const rows = dbdata.rows.map(conf => {
const row = new Grafana.Row({title: conf.title});
conf.panels.forEach(panel => row.addPanel(newPanel(panel)));
return row;
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: dbdata.title,
templating: dbdata.templates,
description: dbdata.description,
rows,
});
db.state.editable = false;
// Necessary to make custom templates display "all" option
for (const template of db.state?.templating?.list) {
if (template.type === 'custom' && template.includeAll) {
template.options.unshift({selected: true, text: 'All', value: '$__all'});
}
template.current = template.options[0];
}
return db;
export function AccessPointDashboard() {
const row = new Grafana.Row({title: ''});
APNPanels.forEach(conf => {
row.addPanel(newPanel(conf));
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'CWF - Access Points',
templating: [apnTemplate()],
rows: [row],
editable: false,
});
db.state.editable = false;
db.state.description =
'Do not edit: edits will be overwritten. Save this dashboard under another name to copy and edit.';
return db;
}
export function SubscribersDashboard() {
const row = new Grafana.Row({title: ''});
SubscribersPanels.forEach(conf => {
row.addPanel(newPanel(conf));
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'CWF - Subscribers',
templating: [imsiTemplate()],
rows: [row],
editable: false,
});
db.state.editable = false;
db.state.description =
'Do not edit: edits will be overwritten. Save this dashboard under another name to copy and edit.';
return db;
}
export function InternalDashboard() {
const row = new Grafana.Row({title: ''});
InternalPanels.forEach(conf => {
row.addPanel(newPanel(conf));
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'Internal',
templating: [networkTemplate(), gatewayTemplate()],
rows: [row],
});
db.state.editable = false;
db.state.description =
'Metrics relevant to the internals of gateways. Do not edit: edits will be overwritten. Save this dashboard under another name to copy and edit.';
return db;
}
export function CWFNetworkDashboard() {
const row = new Grafana.Row({title: ''});
NetworkPanels.forEach(conf => {
row.addPanel(newPanel(conf));
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'CWF - Network',
templating: [networkTemplate()],
rows: [row],
editable: false,
});
db.state.editable = false;
db.state.description =
'Do not edit: edits will be overwritten. Save this dashboard under another name to copy and edit.';
return db;
}
export function TemplateDashboard() {
const row = new Grafana.Row({title: ''});
row.addPanel(
newPanel({
title: 'Variable Demo',
targets: [
{expr: `cpu_percent{networkID=~"$networkID",gatewayID=~"$gatewayID"}`},
],
}),
);
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'Template',
templating: [networkTemplate(), gatewayTemplate()],
rows: [row],
});
db.state.editable = true;
db.state.description =
'Template dashboard with network and gateway variables preconfigured. Copy from this template to create a new dashboard which includes the networkID and gatewayID variables.';
return db;
}
export function GatewaysDashboard() {
const row = new Grafana.Row({title: ''});
GatewayPanels.forEach(conf => {
row.addPanel(newPanel(conf));
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'Gateways',
templating: [networkTemplate(), gatewayTemplate()],
rows: [row],
editable: false,
});
db.state.editable = false;
db.state.description =
'Metrics relevant to the gateways. Do not edit: edits will be overwritten. Save this dashboard under another name to copy and edit.';
return db;
}
export function NetworksDashboard() {
const row = new Grafana.Row({title: ''});
NetworkPanels.forEach(conf => {
row.addPanel(newPanel(conf));
});
const db = new Grafana.Dashboard({
schemaVersion: 6,
title: 'Networks',
templating: [networkTemplate()],
rows: [row],
editable: false,
});
db.state.editable = false;
db.state.description =
'Metrics relevant to the whole network. Do not edit: edits will be overwritten. Save this dashboard under another name to copy and edit.';
return db;
}