Commit e174f7c2 by Leonard Gram

folders: admin for created folders

parent e294252e
......@@ -5,6 +5,7 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/services/search"
"time"
)
// FolderService service for operating on folders
......@@ -114,6 +115,45 @@ func (dr *dashboardServiceImpl) CreateFolder(cmd *models.CreateFolderCommand) er
return toFolderError(err)
}
rtEditor := models.ROLE_EDITOR
rtViewer := models.ROLE_VIEWER
items := []*models.DashboardAcl{
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
UserId: saveDashboardCmd.Result.CreatedBy,
Permission: models.PERMISSION_ADMIN,
Created: time.Now(),
Updated: time.Now(),
},
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
Role: &rtEditor,
Permission: models.PERMISSION_EDIT,
Created: time.Now(),
Updated: time.Now(),
},
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
Role: &rtViewer,
Permission: models.PERMISSION_VIEW,
Created: time.Now(),
Updated: time.Now(),
},
}
aclCmd := &models.UpdateDashboardAclCommand{
DashboardId: saveDashboardCmd.Result.Id,
Items: items,
}
if err = bus.Dispatch(aclCmd); err != nil {
return err
}
query := models.GetDashboardQuery{OrgId: dr.orgId, Id: saveDashboardCmd.Result.Id}
dashFolder, err = getFolder(query)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment