mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Excluded total calculations from backend
This commit is contained in:
parent
c5377fb429
commit
00a6efa15e
@ -58,26 +58,20 @@ func GetDashboard(c *middleware.Context) {
|
|||||||
creator = getUserLogin(dash.CreatedBy)
|
creator = getUserLogin(dash.CreatedBy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finding total panels and queries on the dashboard
|
|
||||||
totalRows, totalPanels, totalQueries := getTotalRowsPanelsAndQueries(dash.Data)
|
|
||||||
|
|
||||||
dto := dtos.DashboardFullWithMeta{
|
dto := dtos.DashboardFullWithMeta{
|
||||||
Dashboard: dash.Data,
|
Dashboard: dash.Data,
|
||||||
Meta: dtos.DashboardMeta{
|
Meta: dtos.DashboardMeta{
|
||||||
IsStarred: isStarred,
|
IsStarred: isStarred,
|
||||||
Slug: slug,
|
Slug: slug,
|
||||||
Type: m.DashTypeDB,
|
Type: m.DashTypeDB,
|
||||||
CanStar: c.IsSignedIn,
|
CanStar: c.IsSignedIn,
|
||||||
CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
|
CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
|
||||||
CanEdit: canEditDashboard(c.OrgRole),
|
CanEdit: canEditDashboard(c.OrgRole),
|
||||||
Created: dash.Created,
|
Created: dash.Created,
|
||||||
Updated: dash.Updated,
|
Updated: dash.Updated,
|
||||||
UpdatedBy: updater,
|
UpdatedBy: updater,
|
||||||
CreatedBy: creator,
|
CreatedBy: creator,
|
||||||
TotalRows: totalRows,
|
Version: dash.Version,
|
||||||
TotalPanels: totalPanels,
|
|
||||||
TotalQueries: totalQueries,
|
|
||||||
Version: dash.Version,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,26 +89,6 @@ func getUserLogin(userId int64) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTotalRowsPanelsAndQueries(data map[string]interface{}) (int, int, int) {
|
|
||||||
totalRows, totalPanels, totalQueries := 0, 0, 0
|
|
||||||
if rows, rowsOk := data["rows"]; rowsOk {
|
|
||||||
totalRows = len(rows.([]interface{}))
|
|
||||||
if totalRows > 0 {
|
|
||||||
for _, rowElement := range rows.([]interface{}) {
|
|
||||||
if panels, panelsOk := rowElement.(map[string]interface{})["panels"]; panelsOk {
|
|
||||||
totalPanels += len(panels.([]interface{}))
|
|
||||||
for _, panelElement := range panels.([]interface{}) {
|
|
||||||
if targets, targetsOk := panelElement.(map[string]interface{})["targets"]; targetsOk {
|
|
||||||
totalQueries += len(targets.([]interface{}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return totalRows, totalPanels, totalQueries
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteDashboard(c *middleware.Context) {
|
func DeleteDashboard(c *middleware.Context) {
|
||||||
slug := c.Params(":slug")
|
slug := c.Params(":slug")
|
||||||
|
|
||||||
|
@ -30,23 +30,20 @@ type CurrentUser struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DashboardMeta struct {
|
type DashboardMeta struct {
|
||||||
IsStarred bool `json:"isStarred,omitempty"`
|
IsStarred bool `json:"isStarred,omitempty"`
|
||||||
IsHome bool `json:"isHome,omitempty"`
|
IsHome bool `json:"isHome,omitempty"`
|
||||||
IsSnapshot bool `json:"isSnapshot,omitempty"`
|
IsSnapshot bool `json:"isSnapshot,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
CanSave bool `json:"canSave"`
|
CanSave bool `json:"canSave"`
|
||||||
CanEdit bool `json:"canEdit"`
|
CanEdit bool `json:"canEdit"`
|
||||||
CanStar bool `json:"canStar"`
|
CanStar bool `json:"canStar"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
Expires time.Time `json:"expires"`
|
Expires time.Time `json:"expires"`
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
Updated time.Time `json:"updated"`
|
Updated time.Time `json:"updated"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
TotalRows int `json:"totalRows"`
|
Version int `json:"version"`
|
||||||
TotalPanels int `json:"totalPanels"`
|
|
||||||
TotalQueries int `json:"totalQueries"`
|
|
||||||
Version int `json:"version"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DashboardFullWithMeta struct {
|
type DashboardFullWithMeta struct {
|
||||||
|
@ -167,40 +167,7 @@
|
|||||||
<div class="tight-form">
|
<div class="tight-form">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item" style="width: 120px">
|
<li class="tight-form-item" style="width: 120px">
|
||||||
Total rows:
|
Current version:
|
||||||
</li>
|
|
||||||
<li class="tight-form-item" style="width: 180px">
|
|
||||||
{{dashboardMeta.totalRows}}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
<div class="tight-form">
|
|
||||||
<ul class="tight-form-list">
|
|
||||||
<li class="tight-form-item" style="width: 120px">
|
|
||||||
Total panels:
|
|
||||||
</li>
|
|
||||||
<li class="tight-form-item" style="width: 180px">
|
|
||||||
{{dashboardMeta.totalPanels}}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
<div class="tight-form">
|
|
||||||
<ul class="tight-form-list">
|
|
||||||
<li class="tight-form-item" style="width: 120px">
|
|
||||||
Total queries:
|
|
||||||
</li>
|
|
||||||
<li class="tight-form-item" style="width: 180px">
|
|
||||||
{{dashboardMeta.totalQueries}}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
<div class="tight-form">
|
|
||||||
<ul class="tight-form-list">
|
|
||||||
<li class="tight-form-item" style="width: 120px">
|
|
||||||
Version:
|
|
||||||
</li>
|
</li>
|
||||||
<li class="tight-form-item" style="width: 180px">
|
<li class="tight-form-item" style="width: 180px">
|
||||||
{{dashboardMeta.version}}
|
{{dashboardMeta.version}}
|
||||||
|
Loading…
Reference in New Issue
Block a user