From 753fd164d77030c57372ed7de60f3dfc3d3d3945 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 27 Jan 2016 16:33:32 -0800 Subject: [PATCH 1/8] Added createdBy in metadata ui and dashboard table --- pkg/api/dtos/models.go | 1 + pkg/models/dashboards.go | 14 +++++++++----- pkg/services/sqlstore/migrations/dashboard_mig.go | 5 +++++ .../app/features/dashboard/partials/settings.html | 11 +++++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index a5e8e74fb46..b93d36c0aee 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -42,6 +42,7 @@ type DashboardMeta struct { Created time.Time `json:"created"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` } type DashboardFullWithMeta struct { diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index ddf5dd244f5..c9718dda295 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -34,6 +34,7 @@ type Dashboard struct { Updated time.Time UpdatedBy int64 + CreatedBy int64 Title string Data map[string]interface{} @@ -66,7 +67,7 @@ func (dash *Dashboard) GetTags() []string { return b } -func NewDashboardFromJson(data map[string]interface{}) *Dashboard { +func NewDashboardFromJson(data map[string]interface {}) *Dashboard { dash := &Dashboard{} dash.Data = data dash.Title = dash.Data["title"].(string) @@ -91,8 +92,11 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard { // GetDashboardModel turns the command into the savable model func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard { dash := NewDashboardFromJson(cmd.Dashboard) - dash.OrgId = cmd.OrgId - dash.UpdatedBy = cmd.UpdatedBy + if dash.Data["version"] == 0 { + dash.CreatedBy = cmd.UserId + } + dash.UpdatedBy = cmd.UserId + dash.OrgId = cmd.OrgId dash.UpdateSlug() return dash } @@ -114,9 +118,9 @@ func (dash *Dashboard) UpdateSlug() { type SaveDashboardCommand struct { Dashboard map[string]interface{} `json:"dashboard" binding:"Required"` - Overwrite bool `json:"overwrite"` + UserId int64 `json:"userId"` OrgId int64 `json:"-"` - UpdatedBy int64 `json:"-"` + Overwrite bool `json:"overwrite"` Result *Dashboard } diff --git a/pkg/services/sqlstore/migrations/dashboard_mig.go b/pkg/services/sqlstore/migrations/dashboard_mig.go index b94f1a7d6ac..43fb8e36cb2 100644 --- a/pkg/services/sqlstore/migrations/dashboard_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_mig.go @@ -97,4 +97,9 @@ func addDashboardMigration(mg *Migrator) { mg.AddMigration("Add column updated_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{ Name: "updated_by", Type: DB_Int, Nullable: true, })) + + // add column to store creator of a dashboard + mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{ + Name: "created_by", Type: DB_Int, Nullable: true, + })) } diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 730d2cadeb8..d1a02924f0b 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -151,6 +151,17 @@
+
+ +
+
From 6a1192172dd75c9442070439ca48f2e185d2d9e6 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 27 Jan 2016 21:55:54 -0800 Subject: [PATCH 2/8] Api stores dashboard creator --- pkg/api/dashboard.go | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 79485fa8cca..5effc1d06d7 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -49,18 +49,14 @@ func GetDashboard(c *middleware.Context) { dash := query.Result - // Finding the last updater of the dashboard - updater := "Anonymous" - if dash.UpdatedBy != 0 { - userQuery := m.GetUserByIdQuery{Id: dash.UpdatedBy} - userErr := bus.Dispatch(&userQuery) - if userErr != nil { - updater = "Unknown" - } else { - user := userQuery.Result - updater = user.Login - } - } + // Finding the last creator and updater of the dashboard + updater, creator := "Anonymous", "Anonymous" + if dash.UpdatedBy > 0 { + updater = getUserLogin(dash.UpdatedBy) + } + if dash.CreatedBy > 0 { + creator = getUserLogin(dash.CreatedBy) + } dto := dtos.DashboardFullWithMeta{ Dashboard: dash.Data, @@ -74,12 +70,24 @@ func GetDashboard(c *middleware.Context) { Created: dash.Created, Updated: dash.Updated, UpdatedBy: updater, + CreatedBy: creator, }, } c.JSON(200, dto) } +func getUserLogin(userId int64) string { + query := m.GetUserByIdQuery{Id: userId} + err := bus.Dispatch(&query) + if err != nil { + return "Anonymous" + } else { + user := query.Result + return user.Login + } +} + func DeleteDashboard(c *middleware.Context) { slug := c.Params(":slug") @@ -104,10 +112,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) { cmd.OrgId = c.OrgId if !c.IsSignedIn { - cmd.UpdatedBy = 0 + cmd.UserId = -1 } else { - cmd.UpdatedBy = c.UserId - } + cmd.UserId = c.UserId + } dash := cmd.GetDashboardModel() if dash.Id == 0 { From 58121d89fc876f43041e1d200ff68f19d6ee1528 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 27 Jan 2016 22:00:24 -0800 Subject: [PATCH 3/8] Updated http_api docs --- docs/sources/reference/http_api.md | 6 ++-- pkg/api/dashboard.go | 32 +++++++++---------- pkg/api/dtos/models.go | 2 +- pkg/models/dashboards.go | 16 +++++----- .../sqlstore/migrations/dashboard_mig.go | 8 ++--- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/docs/sources/reference/http_api.md b/docs/sources/reference/http_api.md index 4b0dff6c4b6..5ffd03c4111 100644 --- a/docs/sources/reference/http_api.md +++ b/docs/sources/reference/http_api.md @@ -70,13 +70,15 @@ Creates a new dashboard or updates an existing dashboard. "schemaVersion": 6, "version": 0 }, - "overwrite": false + "overwrite": false, + "userId:": 3 } JSON Body schema: -- **dashboard** – The complete dashboard model, id = null to create a new dashboard +- **dashboard** – The complete dashboard model, id = null to create a new dashboard. - **overwrite** – Set to true if you want to overwrite existing dashboard with newer version or with same dashboard title. +- **userId** - Set userId if you want to record who created or updated a dashboard. **Example Response**: diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 5effc1d06d7..8bcb7fc6b74 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -52,11 +52,11 @@ func GetDashboard(c *middleware.Context) { // Finding the last creator and updater of the dashboard updater, creator := "Anonymous", "Anonymous" if dash.UpdatedBy > 0 { - updater = getUserLogin(dash.UpdatedBy) - } - if dash.CreatedBy > 0 { - creator = getUserLogin(dash.CreatedBy) - } + updater = getUserLogin(dash.UpdatedBy) + } + if dash.CreatedBy > 0 { + creator = getUserLogin(dash.CreatedBy) + } dto := dtos.DashboardFullWithMeta{ Dashboard: dash.Data, @@ -70,7 +70,7 @@ func GetDashboard(c *middleware.Context) { Created: dash.Created, Updated: dash.Updated, UpdatedBy: updater, - CreatedBy: creator, + CreatedBy: creator, }, } @@ -78,14 +78,14 @@ func GetDashboard(c *middleware.Context) { } func getUserLogin(userId int64) string { - query := m.GetUserByIdQuery{Id: userId} - err := bus.Dispatch(&query) - if err != nil { - return "Anonymous" - } else { - user := query.Result - return user.Login - } + query := m.GetUserByIdQuery{Id: userId} + err := bus.Dispatch(&query) + if err != nil { + return "Anonymous" + } else { + user := query.Result + return user.Login + } } func DeleteDashboard(c *middleware.Context) { @@ -114,8 +114,8 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) { if !c.IsSignedIn { cmd.UserId = -1 } else { - cmd.UserId = c.UserId - } + cmd.UserId = c.UserId + } dash := cmd.GetDashboardModel() if dash.Id == 0 { diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index b93d36c0aee..b35b5c472b6 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -42,7 +42,7 @@ type DashboardMeta struct { Created time.Time `json:"created"` Updated time.Time `json:"updated"` UpdatedBy string `json:"updatedBy"` - CreatedBy string `json:"createdBy"` + CreatedBy string `json:"createdBy"` } type DashboardFullWithMeta struct { diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index c9718dda295..a85e98a8b91 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -34,7 +34,7 @@ type Dashboard struct { Updated time.Time UpdatedBy int64 - CreatedBy int64 + CreatedBy int64 Title string Data map[string]interface{} @@ -67,7 +67,7 @@ func (dash *Dashboard) GetTags() []string { return b } -func NewDashboardFromJson(data map[string]interface {}) *Dashboard { +func NewDashboardFromJson(data map[string]interface{}) *Dashboard { dash := &Dashboard{} dash.Data = data dash.Title = dash.Data["title"].(string) @@ -93,10 +93,10 @@ func NewDashboardFromJson(data map[string]interface {}) *Dashboard { func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard { dash := NewDashboardFromJson(cmd.Dashboard) if dash.Data["version"] == 0 { - dash.CreatedBy = cmd.UserId - } - dash.UpdatedBy = cmd.UserId - dash.OrgId = cmd.OrgId + dash.CreatedBy = cmd.UserId + } + dash.UpdatedBy = cmd.UserId + dash.OrgId = cmd.OrgId dash.UpdateSlug() return dash } @@ -118,9 +118,9 @@ func (dash *Dashboard) UpdateSlug() { type SaveDashboardCommand struct { Dashboard map[string]interface{} `json:"dashboard" binding:"Required"` - UserId int64 `json:"userId"` + UserId int64 `json:"userId"` OrgId int64 `json:"-"` - Overwrite bool `json:"overwrite"` + Overwrite bool `json:"overwrite"` Result *Dashboard } diff --git a/pkg/services/sqlstore/migrations/dashboard_mig.go b/pkg/services/sqlstore/migrations/dashboard_mig.go index 43fb8e36cb2..a4a8629b331 100644 --- a/pkg/services/sqlstore/migrations/dashboard_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_mig.go @@ -98,8 +98,8 @@ func addDashboardMigration(mg *Migrator) { Name: "updated_by", Type: DB_Int, Nullable: true, })) - // add column to store creator of a dashboard - mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{ - Name: "created_by", Type: DB_Int, Nullable: true, - })) + // add column to store creator of a dashboard + mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{ + Name: "created_by", Type: DB_Int, Nullable: true, + })) } From b30dcce4bc6c4557ee8702902b702674d1666c17 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 28 Jan 2016 00:52:52 -0800 Subject: [PATCH 4/8] Added dtos and UI for more metadata --- pkg/api/dtos/models.go | 30 ++++---- .../features/dashboard/partials/settings.html | 76 +++++++++++++++---- 2 files changed, 78 insertions(+), 28 deletions(-) diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index b35b5c472b6..4617f89d3c9 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -30,19 +30,23 @@ type CurrentUser struct { } type DashboardMeta struct { - IsStarred bool `json:"isStarred,omitempty"` - IsHome bool `json:"isHome,omitempty"` - IsSnapshot bool `json:"isSnapshot,omitempty"` - Type string `json:"type,omitempty"` - CanSave bool `json:"canSave"` - CanEdit bool `json:"canEdit"` - CanStar bool `json:"canStar"` - Slug string `json:"slug"` - Expires time.Time `json:"expires"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - UpdatedBy string `json:"updatedBy"` - CreatedBy string `json:"createdBy"` + IsStarred bool `json:"isStarred,omitempty"` + IsHome bool `json:"isHome,omitempty"` + IsSnapshot bool `json:"isSnapshot,omitempty"` + Type string `json:"type,omitempty"` + CanSave bool `json:"canSave"` + CanEdit bool `json:"canEdit"` + CanStar bool `json:"canStar"` + Slug string `json:"slug"` + Expires time.Time `json:"expires"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` + TotalRows int64 `json:"totalRows"` + TotalPanels int64 `json:"totalPanels"` + TotalQueries int64 `json:"totalQueries"` + Version int `json:"version"` } type DashboardFullWithMeta struct { diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index d1a02924f0b..579f3717ebc 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -115,9 +115,9 @@
-
-
-
Dashboard info
+
+
Dashboard info
+
  • @@ -130,17 +130,6 @@
-
    -
  • - Created at: -
  • -
  • - {{formatDate(dashboardMeta.created)}} -
  • -
-
-
-
  • Last updated by: @@ -150,6 +139,17 @@
+
+
+
    +
  • + Created at: +
  • +
  • + {{formatDate(dashboardMeta.created)}} +
  • +
+
    @@ -158,7 +158,53 @@
  • {{dashboardMeta.createdBy}} -
  • + +
+
+
+
+
+
+
    +
  • + Total rows: +
  • +
  • + {{dashboardMeta.totalRows}} +
  • +
+
+
+
+
    +
  • + Total panels: +
  • +
  • + {{dashboardMeta.totalPanels}} +
  • +
+
+
+
+
    +
  • + Total queries: +
  • +
  • + {{dashboardMeta.totalQueries}} +
  • +
+
+
+
+
    +
  • + Version: +
  • +
  • + {{dashboardMeta.version}} +
From 972ac99b7cccc56540597b5ada8524dabe284765 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 28 Jan 2016 09:53:19 -0800 Subject: [PATCH 5/8] Added more metadata --- docs/sources/reference/http_api.md | 4 +-- pkg/api/dashboard.go | 49 +++++++++++++++++++++++------- pkg/api/dtos/models.go | 8 ++--- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/docs/sources/reference/http_api.md b/docs/sources/reference/http_api.md index 5ffd03c4111..70431565741 100644 --- a/docs/sources/reference/http_api.md +++ b/docs/sources/reference/http_api.md @@ -70,15 +70,13 @@ Creates a new dashboard or updates an existing dashboard. "schemaVersion": 6, "version": 0 }, - "overwrite": false, - "userId:": 3 + "overwrite": false } JSON Body schema: - **dashboard** – The complete dashboard model, id = null to create a new dashboard. - **overwrite** – Set to true if you want to overwrite existing dashboard with newer version or with same dashboard title. -- **userId** - Set userId if you want to record who created or updated a dashboard. **Example Response**: diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 8bcb7fc6b74..cc635a108e3 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -49,7 +49,7 @@ func GetDashboard(c *middleware.Context) { dash := query.Result - // Finding the last creator and updater of the dashboard + // Finding creator and last updater of the dashboard updater, creator := "Anonymous", "Anonymous" if dash.UpdatedBy > 0 { updater = getUserLogin(dash.UpdatedBy) @@ -58,19 +58,26 @@ func GetDashboard(c *middleware.Context) { creator = getUserLogin(dash.CreatedBy) } + // Finding total panels and queries on the dashboard + totalRows, totalPanels, totalQueries := getTotalRowsPanelsAndQueries(dash.Data) + dto := dtos.DashboardFullWithMeta{ Dashboard: dash.Data, Meta: dtos.DashboardMeta{ - IsStarred: isStarred, - Slug: slug, - Type: m.DashTypeDB, - CanStar: c.IsSignedIn, - CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR, - CanEdit: canEditDashboard(c.OrgRole), - Created: dash.Created, - Updated: dash.Updated, - UpdatedBy: updater, - CreatedBy: creator, + IsStarred: isStarred, + Slug: slug, + Type: m.DashTypeDB, + CanStar: c.IsSignedIn, + CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR, + CanEdit: canEditDashboard(c.OrgRole), + Created: dash.Created, + Updated: dash.Updated, + UpdatedBy: updater, + CreatedBy: creator, + TotalRows: totalRows, + TotalPanels: totalPanels, + TotalQueries: totalQueries, + Version: dash.Version, }, } @@ -88,6 +95,26 @@ 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) { slug := c.Params(":slug") diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index 4617f89d3c9..5fe23b4a53e 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -43,10 +43,10 @@ type DashboardMeta struct { Updated time.Time `json:"updated"` UpdatedBy string `json:"updatedBy"` CreatedBy string `json:"createdBy"` - TotalRows int64 `json:"totalRows"` - TotalPanels int64 `json:"totalPanels"` - TotalQueries int64 `json:"totalQueries"` - Version int `json:"version"` + TotalRows int `json:"totalRows"` + TotalPanels int `json:"totalPanels"` + TotalQueries int `json:"totalQueries"` + Version int `json:"version"` } type DashboardFullWithMeta struct { From 00a6efa15eb73f4fe5679506e830ebbdf70147a7 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Mon, 1 Feb 2016 23:26:11 -0800 Subject: [PATCH 6/8] Excluded total calculations from backend --- pkg/api/dashboard.go | 48 +++++-------------- pkg/api/dtos/models.go | 31 ++++++------ .../features/dashboard/partials/settings.html | 35 +------------- 3 files changed, 26 insertions(+), 88 deletions(-) diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index cc635a108e3..c0c7cd0e4f5 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -58,26 +58,20 @@ func GetDashboard(c *middleware.Context) { creator = getUserLogin(dash.CreatedBy) } - // Finding total panels and queries on the dashboard - totalRows, totalPanels, totalQueries := getTotalRowsPanelsAndQueries(dash.Data) - dto := dtos.DashboardFullWithMeta{ Dashboard: dash.Data, Meta: dtos.DashboardMeta{ - IsStarred: isStarred, - Slug: slug, - Type: m.DashTypeDB, - CanStar: c.IsSignedIn, - CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR, - CanEdit: canEditDashboard(c.OrgRole), - Created: dash.Created, - Updated: dash.Updated, - UpdatedBy: updater, - CreatedBy: creator, - TotalRows: totalRows, - TotalPanels: totalPanels, - TotalQueries: totalQueries, - Version: dash.Version, + IsStarred: isStarred, + Slug: slug, + Type: m.DashTypeDB, + CanStar: c.IsSignedIn, + CanSave: c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR, + CanEdit: canEditDashboard(c.OrgRole), + Created: dash.Created, + Updated: dash.Updated, + UpdatedBy: updater, + CreatedBy: creator, + 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) { slug := c.Params(":slug") diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index 5fe23b4a53e..83176e836e5 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -30,23 +30,20 @@ type CurrentUser struct { } type DashboardMeta struct { - IsStarred bool `json:"isStarred,omitempty"` - IsHome bool `json:"isHome,omitempty"` - IsSnapshot bool `json:"isSnapshot,omitempty"` - Type string `json:"type,omitempty"` - CanSave bool `json:"canSave"` - CanEdit bool `json:"canEdit"` - CanStar bool `json:"canStar"` - Slug string `json:"slug"` - Expires time.Time `json:"expires"` - Created time.Time `json:"created"` - Updated time.Time `json:"updated"` - UpdatedBy string `json:"updatedBy"` - CreatedBy string `json:"createdBy"` - TotalRows int `json:"totalRows"` - TotalPanels int `json:"totalPanels"` - TotalQueries int `json:"totalQueries"` - Version int `json:"version"` + IsStarred bool `json:"isStarred,omitempty"` + IsHome bool `json:"isHome,omitempty"` + IsSnapshot bool `json:"isSnapshot,omitempty"` + Type string `json:"type,omitempty"` + CanSave bool `json:"canSave"` + CanEdit bool `json:"canEdit"` + CanStar bool `json:"canStar"` + Slug string `json:"slug"` + Expires time.Time `json:"expires"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` + UpdatedBy string `json:"updatedBy"` + CreatedBy string `json:"createdBy"` + Version int `json:"version"` } type DashboardFullWithMeta struct { diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index e5b42bbdfdd..939a23a2d1e 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -167,40 +167,7 @@
  • - Total rows: -
  • -
  • - {{dashboardMeta.totalRows}} -
  • -
-
-
-
-
    -
  • - Total panels: -
  • -
  • - {{dashboardMeta.totalPanels}} -
  • -
-
-
-
-
    -
  • - Total queries: -
  • -
  • - {{dashboardMeta.totalQueries}} -
  • -
-
-
-
-
    -
  • - Version: + Current version:
  • {{dashboardMeta.version}} From c6ab63ec479cd263d59d03b4b646e8019d5516cb Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 2 Feb 2016 11:50:01 -0800 Subject: [PATCH 7/8] Calculated total stats in frontend --- .../app/features/dashboard/dashboardCtrl.js | 20 +++++++++++ .../features/dashboard/partials/settings.html | 33 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/public/app/features/dashboard/dashboardCtrl.js b/public/app/features/dashboard/dashboardCtrl.js index ea0d91019b8..cc305e4aed4 100644 --- a/public/app/features/dashboard/dashboardCtrl.js +++ b/public/app/features/dashboard/dashboardCtrl.js @@ -57,6 +57,7 @@ function (angular, $, config, moment) { dashboardKeybindings.shortcuts($scope); + $scope.evaluateTotalStats(); $scope.updateSubmenuVisibility(); $scope.setWindowTitleAndTheme(); @@ -67,6 +68,25 @@ function (angular, $, config, moment) { }); }; + $scope.evaluateTotalStats = function() { + $scope.dashboard.totalRows = 0; + $scope.dashboard.totalPanels = 0; + $scope.dashboard.totalQueries = 0; + if ($scope.dashboard.rows) { + $scope.dashboard.totalRows = $scope.dashboard.rows.length; + for (var i=0; i<$scope.dashboard.rows.length; i++) { + if ($scope.dashboard.rows[i].panels) { + $scope.dashboard.totalPanels += $scope.dashboard.rows[i].panels.length; + for (var j=0; j<$scope.dashboard.rows[i].panels.length; j++) { + if ($scope.dashboard.rows[i].panels[j].targets) { + $scope.dashboard.totalQueries += $scope.dashboard.rows[i].panels[j].targets.length; + } + } + } + } + } + }; + $scope.updateSubmenuVisibility = function() { $scope.submenuEnabled = $scope.dashboard.isSubmenuFeaturesEnabled(); }; diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 939a23a2d1e..d27d3322692 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -164,6 +164,39 @@
+
+
    +
  • + Total Rows: +
  • +
  • + {{dashboard.totalRows}} +
  • +
+
+
+
+
    +
  • + Total Panels: +
  • +
  • + {{dashboard.totalPanels}} +
  • +
+
+
+
+
    +
  • + Total Queries: +
  • +
  • + {{dashboard.totalQueries}} +
  • +
+
+
  • From b5a5b7b912e6052485e6ba3a437dc20f94b324b5 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 4 Feb 2016 13:34:23 -0800 Subject: [PATCH 8/8] Removed totalStats from PR --- .../app/features/dashboard/dashboardCtrl.js | 20 ----------- .../features/dashboard/partials/settings.html | 35 ------------------- 2 files changed, 55 deletions(-) diff --git a/public/app/features/dashboard/dashboardCtrl.js b/public/app/features/dashboard/dashboardCtrl.js index cc305e4aed4..ea0d91019b8 100644 --- a/public/app/features/dashboard/dashboardCtrl.js +++ b/public/app/features/dashboard/dashboardCtrl.js @@ -57,7 +57,6 @@ function (angular, $, config, moment) { dashboardKeybindings.shortcuts($scope); - $scope.evaluateTotalStats(); $scope.updateSubmenuVisibility(); $scope.setWindowTitleAndTheme(); @@ -68,25 +67,6 @@ function (angular, $, config, moment) { }); }; - $scope.evaluateTotalStats = function() { - $scope.dashboard.totalRows = 0; - $scope.dashboard.totalPanels = 0; - $scope.dashboard.totalQueries = 0; - if ($scope.dashboard.rows) { - $scope.dashboard.totalRows = $scope.dashboard.rows.length; - for (var i=0; i<$scope.dashboard.rows.length; i++) { - if ($scope.dashboard.rows[i].panels) { - $scope.dashboard.totalPanels += $scope.dashboard.rows[i].panels.length; - for (var j=0; j<$scope.dashboard.rows[i].panels.length; j++) { - if ($scope.dashboard.rows[i].panels[j].targets) { - $scope.dashboard.totalQueries += $scope.dashboard.rows[i].panels[j].targets.length; - } - } - } - } - } - }; - $scope.updateSubmenuVisibility = function() { $scope.submenuEnabled = $scope.dashboard.isSubmenuFeaturesEnabled(); }; diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index d27d3322692..7af2abfe076 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -162,41 +162,6 @@
-
-
-
-
    -
  • - Total Rows: -
  • -
  • - {{dashboard.totalRows}} -
  • -
-
-
-
-
    -
  • - Total Panels: -
  • -
  • - {{dashboard.totalPanels}} -
  • -
-
-
-
-
    -
  • - Total Queries: -
  • -
  • - {{dashboard.totalQueries}} -
  • -
-
-