diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go
index ce81df0fc44..0364c0ab681 100644
--- a/pkg/api/dashboard.go
+++ b/pkg/api/dashboard.go
@@ -40,8 +40,8 @@ func GetDashboard(c *middleware.Context) Response {
slug := strings.ToLower(c.Params(":slug"))
query := m.GetDashboardQuery{Slug: slug, OrgId: c.OrgId}
- err := bus.Dispatch(&query)
- if err != nil {
+
+ if err := bus.Dispatch(&query); err != nil {
return ApiError(404, "Dashboard not found", err)
}
@@ -70,27 +70,39 @@ func GetDashboard(c *middleware.Context) Response {
creator = getUserLogin(dash.CreatedBy)
}
+ meta := dtos.DashboardMeta{
+ IsStarred: isStarred,
+ Slug: slug,
+ Type: m.DashTypeDB,
+ CanStar: c.IsSignedIn,
+ CanSave: canSave,
+ CanEdit: canEdit,
+ Created: dash.Created,
+ Updated: dash.Updated,
+ UpdatedBy: updater,
+ CreatedBy: creator,
+ Version: dash.Version,
+ HasAcl: dash.HasAcl,
+ IsFolder: dash.IsFolder,
+ FolderId: dash.ParentId,
+ FolderTitle: "Root",
+ }
+
+ // lookup folder title
+ if dash.ParentId > 0 {
+ query := m.GetDashboardQuery{Id: dash.ParentId, OrgId: c.OrgId}
+ if err := bus.Dispatch(&query); err != nil {
+ return ApiError(500, "Dashboard folder could not be read", err)
+ }
+ meta.FolderTitle = query.Result.Title
+ }
+
// make sure db version is in sync with json model version
dash.Data.Set("version", dash.Version)
dto := dtos.DashboardFullWithMeta{
Dashboard: dash.Data,
- Meta: dtos.DashboardMeta{
- IsStarred: isStarred,
- Slug: slug,
- Type: m.DashTypeDB,
- CanStar: c.IsSignedIn,
- CanSave: canSave,
- CanEdit: canEdit,
- Created: dash.Created,
- Updated: dash.Updated,
- UpdatedBy: updater,
- CreatedBy: creator,
- Version: dash.Version,
- HasAcl: dash.HasAcl,
- IsFolder: dash.IsFolder,
- ParentId: dash.ParentId,
- },
+ Meta: meta,
}
c.TimeRequest(metrics.M_Api_Dashboard_Get)
diff --git a/pkg/api/dtos/dashboard.go b/pkg/api/dtos/dashboard.go
index 5fbba1c9844..8e6407d770c 100644
--- a/pkg/api/dtos/dashboard.go
+++ b/pkg/api/dtos/dashboard.go
@@ -7,23 +7,24 @@ import (
)
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"`
- Version int `json:"version"`
- HasAcl bool `json:"hasAcl"`
- IsFolder bool `json:"isFolder"`
- ParentId int64 `json:"parentId"`
+ 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"`
+ HasAcl bool `json:"hasAcl"`
+ IsFolder bool `json:"isFolder"`
+ FolderId int64 `json:"folderId"`
+ FolderTitle string `json:"folderTitle"`
}
type DashboardFullWithMeta struct {
diff --git a/public/app/core/nav_model_srv.ts b/public/app/core/nav_model_srv.ts
index a8184a40505..058247b7fd8 100644
--- a/public/app/core/nav_model_srv.ts
+++ b/public/app/core/nav_model_srv.ts
@@ -197,7 +197,7 @@ export class NavModelSrv {
clickHandler: () => dashNavCtrl.showHelpModal()
});
- if (this.contextSrv.isEditor) {
+ if (this.contextSrv.isEditor && !dashboard.meta.isFolder) {
menu.push({
title: 'Save As ...',
icon: 'fa fa-fw fa-save',
diff --git a/public/app/features/dashboard/dashboard_ctrl.ts b/public/app/features/dashboard/dashboard_ctrl.ts
index 61778120506..4a23905be8c 100644
--- a/public/app/features/dashboard/dashboard_ctrl.ts
+++ b/public/app/features/dashboard/dashboard_ctrl.ts
@@ -128,8 +128,10 @@ export class DashboardCtrl {
$rootScope.$broadcast("refresh");
};
- $scope.onFolderChange = function(parentId) {
- $scope.dashboard.parentId = parentId;
+ $scope.onFolderChange = function(folder) {
+ $scope.dashboard.parentId = folder.id;
+ $scope.dashboard.meta.folderId = folder.id;
+ $scope.dashboard.meta.folderTitle= folder.title;
};
}
diff --git a/public/app/features/dashboard/dashboard_srv.ts b/public/app/features/dashboard/dashboard_srv.ts
index 1269ed571dc..6d799a907f9 100644
--- a/public/app/features/dashboard/dashboard_srv.ts
+++ b/public/app/features/dashboard/dashboard_srv.ts
@@ -113,17 +113,8 @@ export class DashboardSrv {
}
showSaveAsModal() {
- var newScope = this.$rootScope.$new();
- newScope.clone = this.dash.getSaveModelClone();
- newScope.clone.editable = true;
- newScope.clone.hideControls = false;
- newScope.clone.meta = {};
- newScope.clone.meta.parentId = this.dash.meta.parentId;
- newScope.clone.meta.isFolder = this.dash.meta.isFolder;
-
this.$rootScope.appEvent('show-modal', {
templateHtml: '