當前位置: 首頁>>代碼示例>>Golang>>正文


Golang IndexViewData.PluginModules方法代碼示例

本文整理匯總了Golang中github.com/grafana/grafana/pkg/api/dtos.IndexViewData.PluginModules方法的典型用法代碼示例。如果您正苦於以下問題:Golang IndexViewData.PluginModules方法的具體用法?Golang IndexViewData.PluginModules怎麽用?Golang IndexViewData.PluginModules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/grafana/grafana/pkg/api/dtos.IndexViewData的用法示例。


在下文中一共展示了IndexViewData.PluginModules方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: setIndexViewData

func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
	settings, err := getFrontendSettingsMap(c)
	if err != nil {
		return nil, err
	}

	var data = dtos.IndexViewData{
		User: &dtos.CurrentUser{
			Id:             c.UserId,
			IsSignedIn:     c.IsSignedIn,
			Login:          c.Login,
			Email:          c.Email,
			Name:           c.Name,
			LightTheme:     c.Theme == "light",
			OrgId:          c.OrgId,
			OrgName:        c.OrgName,
			OrgRole:        c.OrgRole,
			GravatarUrl:    dtos.GetGravatarUrl(c.Email),
			IsGrafanaAdmin: c.IsGrafanaAdmin,
		},
		Settings:           settings,
		AppUrl:             setting.AppUrl,
		AppSubUrl:          setting.AppSubUrl,
		GoogleAnalyticsId:  setting.GoogleAnalyticsId,
		GoogleTagManagerId: setting.GoogleTagManagerId,
	}

	if setting.DisableGravatar {
		data.User.GravatarUrl = setting.AppSubUrl + "/img/user_profile.png"
	}

	if len(data.User.Name) == 0 {
		data.User.Name = data.User.Login
	}

	themeUrlParam := c.Query("theme")
	if themeUrlParam == "light" {
		data.User.LightTheme = true
	}

	data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
		Text: "Dashboards",
		Icon: "fa fa-fw fa-th-large",
		Url:  "/",
	})

	data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
		Text: "Playlists",
		Icon: "fa fa-fw fa-list",
		Url:  "/playlists",
	})

	if c.OrgRole == m.ROLE_ADMIN {
		data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
			Text: "Data Sources",
			Icon: "fa fa-fw fa-database",
			Url:  "/datasources",
		})

		data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
			Text: "Apps",
			Icon: "fa fa-fw fa-cubes",
			Url:  "/apps",
		})
	}

	enabledPlugins, err := plugins.GetEnabledPlugins(c.OrgId)
	if err != nil {
		return nil, err
	}

	for _, plugin := range enabledPlugins.Apps {
		if plugin.Module != "" {
			data.PluginModules = append(data.PluginModules, plugin.Module)
		}

		if plugin.Css != nil {
			data.PluginCss = append(data.PluginCss, &dtos.PluginCss{Light: plugin.Css.Light, Dark: plugin.Css.Dark})
		}

		if plugin.Pinned {
			data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
				Text: plugin.Name,
				Url:  "/apps/edit/" + plugin.Id,
				Img:  plugin.Info.Logos.Small,
			})
		}
	}

	return &data, nil
}
開發者ID:naveenlj,項目名稱:grafana,代碼行數:91,代碼來源:index.go


注:本文中的github.com/grafana/grafana/pkg/api/dtos.IndexViewData.PluginModules方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。