mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
dashboard: fixes for panels without rows
This commit is contained in:
parent
5e8f253ff8
commit
0f6270098b
@ -235,42 +235,54 @@ export class BackendSrv {
|
|||||||
|
|
||||||
createDashboardFolder(name) {
|
createDashboardFolder(name) {
|
||||||
const dash = {
|
const dash = {
|
||||||
|
schemaVersion: 16,
|
||||||
title: name,
|
title: name,
|
||||||
editable: true,
|
editable: true,
|
||||||
hideControls: true,
|
hideControls: true,
|
||||||
rows: [
|
panels: [
|
||||||
{
|
{
|
||||||
panels: [
|
id: 1,
|
||||||
{
|
folderId: 0,
|
||||||
folderId: 0,
|
headings: false,
|
||||||
headings: false,
|
limit: 1000,
|
||||||
limit: 1000,
|
links: [],
|
||||||
links: [],
|
query: '',
|
||||||
query: '',
|
recent: false,
|
||||||
recent: false,
|
search: true,
|
||||||
search: true,
|
starred: false,
|
||||||
span: 4,
|
tags: [],
|
||||||
starred: false,
|
title: 'Dashboards in this folder',
|
||||||
tags: [],
|
type: 'dashlist',
|
||||||
title: 'Dashboards in this folder',
|
gridPos: {
|
||||||
type: 'dashlist'
|
x: 0,
|
||||||
},
|
y: 0,
|
||||||
{
|
w: 4,
|
||||||
onlyAlertsOnDashboard: true,
|
h: 10
|
||||||
span: 4,
|
}
|
||||||
title: 'Alerts in this folder',
|
},
|
||||||
type: 'alertlist'
|
{
|
||||||
},
|
id: 2,
|
||||||
{
|
onlyAlertsOnDashboard: true,
|
||||||
span: 4,
|
title: 'Alerts in this folder',
|
||||||
title: 'Permissions for this folder',
|
type: 'alertlist',
|
||||||
type: 'permissionlist',
|
gridPos: {
|
||||||
folderId: 0
|
x: 4,
|
||||||
}
|
y: 0,
|
||||||
],
|
w: 4,
|
||||||
showTitle: true,
|
h: 10
|
||||||
title: name,
|
}
|
||||||
titleSize: 'h1'
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
title: 'Permissions for this folder',
|
||||||
|
type: 'permissionlist',
|
||||||
|
folderId: 0,
|
||||||
|
gridPos: {
|
||||||
|
x: 8,
|
||||||
|
y: 0,
|
||||||
|
w: 4,
|
||||||
|
h: 10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@ -280,8 +292,8 @@ export class BackendSrv {
|
|||||||
return this.getDashboard('db', res.slug);
|
return this.getDashboard('db', res.slug);
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
res.dashboard.rows[0].panels[0].folderId = res.dashboard.id;
|
res.dashboard.panels[0].folderId = res.dashboard.id;
|
||||||
res.dashboard.rows[0].panels[2].folderId = res.dashboard.id;
|
res.dashboard.panels[2].folderId = res.dashboard.id;
|
||||||
return this.saveDashboard(res.dashboard, {overwrite: false});
|
return this.saveDashboard(res.dashboard, {overwrite: false});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ export class PanelModel {
|
|||||||
gridPos: GridPos;
|
gridPos: GridPos;
|
||||||
type: string;
|
type: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
alert?: any;
|
||||||
|
|
||||||
// non persisted
|
// non persisted
|
||||||
fullscreen: boolean;
|
fullscreen: boolean;
|
||||||
|
@ -92,16 +92,16 @@ export class DashNavCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteDashboard() {
|
deleteDashboard() {
|
||||||
var confirmText = "";
|
var confirmText = '';
|
||||||
var text2 = this.dashboard.title;
|
var text2 = this.dashboard.title;
|
||||||
var alerts = this.dashboard.rows.reduce((memo, row) => {
|
|
||||||
memo += row.panels.filter(panel => panel.alert).length;
|
const alerts = _.sumBy(this.dashboard.panels, panel => {
|
||||||
return memo;
|
return panel.alert ? 1 : 0;
|
||||||
}, 0);
|
});
|
||||||
|
|
||||||
if (alerts > 0) {
|
if (alerts > 0) {
|
||||||
confirmText = 'DELETE';
|
confirmText = 'DELETE';
|
||||||
text2 = `This dashboard contains ${alerts} alerts. Deleting this dashboad will also delete those alerts`;
|
text2 = `This dashboard contains ${alerts} alerts. Deleting this dashboard will also delete those alerts`;
|
||||||
}
|
}
|
||||||
|
|
||||||
appEvents.emit('confirm-modal', {
|
appEvents.emit('confirm-modal', {
|
||||||
|
Loading…
Reference in New Issue
Block a user