mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
39a4ba4396
* add stats and licensing under admin -> general when topnav is enabled * add ldap to users and access * use ID instead of Id * add enterprise licensing node
82 lines
1.8 KiB
Go
82 lines
1.8 KiB
Go
package licensing
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/api/dtos"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/hooks"
|
|
"github.com/grafana/grafana/pkg/services/navtree"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
const (
|
|
openSource = "Open Source"
|
|
)
|
|
|
|
type OSSLicensingService struct {
|
|
Cfg *setting.Cfg
|
|
HooksService *hooks.HooksService
|
|
}
|
|
|
|
func (*OSSLicensingService) Expiry() int64 {
|
|
return 0
|
|
}
|
|
|
|
func (*OSSLicensingService) Edition() string {
|
|
return openSource
|
|
}
|
|
|
|
func (*OSSLicensingService) StateInfo() string {
|
|
return ""
|
|
}
|
|
|
|
func (*OSSLicensingService) ContentDeliveryPrefix() string {
|
|
return "grafana-oss"
|
|
}
|
|
|
|
func (l *OSSLicensingService) LicenseURL(showAdminLicensingPage bool) string {
|
|
if showAdminLicensingPage {
|
|
return l.Cfg.AppSubURL + "/admin/upgrading"
|
|
}
|
|
|
|
return "https://grafana.com/oss/grafana?utm_source=grafana_footer"
|
|
}
|
|
|
|
func (*OSSLicensingService) EnabledFeatures() map[string]bool {
|
|
return map[string]bool{}
|
|
}
|
|
|
|
func (*OSSLicensingService) FeatureEnabled(feature string) bool {
|
|
return false
|
|
}
|
|
|
|
func ProvideService(cfg *setting.Cfg, hooksService *hooks.HooksService) *OSSLicensingService {
|
|
l := &OSSLicensingService{
|
|
Cfg: cfg,
|
|
HooksService: hooksService,
|
|
}
|
|
l.HooksService.AddIndexDataHook(func(indexData *dtos.IndexViewData, req *models.ReqContext) {
|
|
if !req.IsGrafanaAdmin {
|
|
return
|
|
}
|
|
|
|
var adminNodeID string
|
|
|
|
if cfg.IsFeatureToggleEnabled("topnav") {
|
|
adminNodeID = navtree.NavIDCfg
|
|
} else {
|
|
adminNodeID = navtree.NavIDAdmin
|
|
}
|
|
|
|
if adminNode := indexData.NavTree.FindById(adminNodeID); adminNode != nil {
|
|
adminNode.Children = append(adminNode.Children, &navtree.NavLink{
|
|
Text: "Stats and license",
|
|
Id: "upgrading",
|
|
Url: l.LicenseURL(req.IsGrafanaAdmin),
|
|
Icon: "unlock",
|
|
})
|
|
}
|
|
})
|
|
|
|
return l
|
|
}
|