Commit 05772b30 by Torkel Ödegaard

feat(ux): completed work on getting started panel, #6466

parent dee6b7d1
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana/pkg/api/dtos" "github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/metrics" "github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware" "github.com/grafana/grafana/pkg/middleware"
...@@ -216,9 +217,28 @@ func GetHomeDashboard(c *middleware.Context) Response { ...@@ -216,9 +217,28 @@ func GetHomeDashboard(c *middleware.Context) Response {
return ApiError(500, "Failed to load home dashboard", err) return ApiError(500, "Failed to load home dashboard", err)
} }
if c.HasUserRole(m.ROLE_ADMIN) && !c.HasHelpFlag(m.HelpFlagGettingStartedPanelDismissed) {
addGettingStartedPanelToHomeDashboard(dash.Dashboard)
}
return Json(200, &dash) return Json(200, &dash)
} }
func addGettingStartedPanelToHomeDashboard(dash *simplejson.Json) {
rows := dash.Get("rows").MustArray()
row := simplejson.NewFromAny(rows[0])
newpanel := simplejson.NewFromAny(map[string]interface{}{
"type": "gettingstarted",
"id": 123123,
"span": 12,
})
panels := row.Get("panels").MustArray()
panels = append(panels, newpanel)
row.Set("panels", panels)
}
func GetDashboardFromJsonFile(c *middleware.Context) { func GetDashboardFromJsonFile(c *middleware.Context) {
file := c.Params(":file") file := c.Params(":file")
......
...@@ -122,12 +122,13 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro ...@@ -122,12 +122,13 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
panels := map[string]interface{}{} panels := map[string]interface{}{}
for _, panel := range enabledPlugins.Panels { for _, panel := range enabledPlugins.Panels {
panels[panel.Id] = map[string]interface{}{ panels[panel.Id] = map[string]interface{}{
"module": panel.Module, "module": panel.Module,
"baseUrl": panel.BaseUrl, "baseUrl": panel.BaseUrl,
"name": panel.Name, "name": panel.Name,
"id": panel.Id, "id": panel.Id,
"info": panel.Info, "info": panel.Info,
"sort": getPanelSort(panel.Id), "hideFromList": panel.HideFromList,
"sort": getPanelSort(panel.Id),
} }
} }
......
...@@ -229,6 +229,10 @@ func (ctx *Context) HasUserRole(role m.RoleType) bool { ...@@ -229,6 +229,10 @@ func (ctx *Context) HasUserRole(role m.RoleType) bool {
return ctx.OrgRole.Includes(role) return ctx.OrgRole.Includes(role)
} }
func (ctx *Context) HasHelpFlag(flag m.HelpFlags1) bool {
return ctx.HelpFlags1.HasFlag(flag)
}
func (ctx *Context) TimeRequest(timer metrics.Timer) { func (ctx *Context) TimeRequest(timer metrics.Timer) {
ctx.Data["perfmon.timer"] = timer ctx.Data["perfmon.timer"] = timer
} }
...@@ -38,6 +38,7 @@ type PluginBase struct { ...@@ -38,6 +38,7 @@ type PluginBase struct {
Includes []*PluginInclude `json:"includes"` Includes []*PluginInclude `json:"includes"`
Module string `json:"module"` Module string `json:"module"`
BaseUrl string `json:"baseUrl"` BaseUrl string `json:"baseUrl"`
HideFromList bool `json:"hideFromList"`
IncludedInAppId string `json:"-"` IncludedInAppId string `json:"-"`
PluginDir string `json:"-"` PluginDir string `json:"-"`
......
...@@ -18,9 +18,15 @@ export class AddPanelCtrl { ...@@ -18,9 +18,15 @@ export class AddPanelCtrl {
constructor(private $scope, private $timeout, private $rootScope) { constructor(private $scope, private $timeout, private $rootScope) {
this.row = this.rowCtrl.row; this.row = this.rowCtrl.row;
this.dashboard = this.rowCtrl.dashboard; this.dashboard = this.rowCtrl.dashboard;
this.allPanels = _.orderBy(_.map(config.panels, item => item), 'sort');
this.panelHits = this.allPanels;
this.activeIndex = 0; this.activeIndex = 0;
this.allPanels = _.chain(config.panels)
.filter({hideFromList: false})
.map(item => item)
.orderBy('sort')
.value();
this.panelHits = this.allPanels;
} }
keyDown(evt) { keyDown(evt) {
......
...@@ -14,44 +14,9 @@ class GettingStartedPanelCtrl extends PanelCtrl { ...@@ -14,44 +14,9 @@ class GettingStartedPanelCtrl extends PanelCtrl {
constructor($scope, $injector, private backendSrv, private datasourceSrv, private $q) { constructor($scope, $injector, private backendSrv, private datasourceSrv, private $q) {
super($scope, $injector); super($scope, $injector);
/* tslint:disable */
if (contextSrv.user.helpFlags1 & 1) {
this.row.removePanel(this.panel, false);
return;
}
/* tslint:enable */
this.stepIndex = 0; this.stepIndex = 0;
this.steps = []; this.steps = [];
if (!contextSrv.hasRole('Admin')) {
this.steps.push({
cta: 'Basic Concepts Guide',
icon: 'fa fa-file-text-o',
href: 'http://docs.grafana.org/guides/basic_concepts/',
check: () => $q.when(false),
cssClass: 'active',
});
this.steps.push({
cta: 'Getting Started Guide',
icon: 'fa fa-file-text-o',
href: 'http://docs.grafana.org/guides/getting_started/',
check: () => $q.when(false),
cssClass: 'active',
});
this.steps.push({
cta: 'Building a dashboard',
icon: 'fa fa-film',
href: 'http://docs.grafana.org/tutorials/screencasts/',
check: () => $q.when(false),
cssClass: 'active',
});
return;
}
this.steps.push({ this.steps.push({
title: 'Install Grafana', title: 'Install Grafana',
icon: 'icon-gf icon-gf-check', icon: 'icon-gf icon-gf-check',
...@@ -114,7 +79,6 @@ class GettingStartedPanelCtrl extends PanelCtrl { ...@@ -114,7 +79,6 @@ class GettingStartedPanelCtrl extends PanelCtrl {
this.stepIndex = -1; this.stepIndex = -1;
return this.nextStep().then(res => { return this.nextStep().then(res => {
this.checksDone = true; this.checksDone = true;
console.log(this.steps);
}); });
} }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
"name": "Getting Started", "name": "Getting Started",
"id": "gettingstarted", "id": "gettingstarted",
"hideFromList": true,
"info": { "info": {
"author": { "author": {
"name": "Grafana Project", "name": "Grafana Project",
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"sharedCrosshair": false, "sharedCrosshair": false,
"rows": [ "rows": [
{ {
"title": "Row title", "title": "Home Dashboard",
"collapse": false, "collapse": false,
"editable": true, "editable": true,
"height": "25px", "height": "25px",
...@@ -25,14 +25,6 @@ ...@@ -25,14 +25,6 @@
"title": "", "title": "",
"transparent": true, "transparent": true,
"type": "text" "type": "text"
},
{
"id": 8,
"links": [],
"span": 12,
"title": "",
"transparent": false,
"type": "gettingstarted"
} }
] ]
}, },
......
...@@ -90,7 +90,6 @@ $path-position: $marker-size-half - ($path-height / 2); ...@@ -90,7 +90,6 @@ $path-position: $marker-size-half - ($path-height / 2);
.progress-text { .progress-text {
display: none; display: none;
} }
.progress-marker { .progress-marker {
.icon-gf { .icon-gf {
color: $brand-primary; color: $brand-primary;
...@@ -113,9 +112,6 @@ $path-position: $marker-size-half - ($path-height / 2); ...@@ -113,9 +112,6 @@ $path-position: $marker-size-half - ($path-height / 2);
} }
.progress-text { .progress-text {
text-decoration: line-through; text-decoration: line-through;
&:hover {
color: $text-color-weak;
}
} }
&::after { &::after {
background: $progress-color-grey-light; background: $progress-color-grey-light;
......
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