Merge branch 'master' into export-dashboard

Conflicts:
	.floo
	.flooignore
This commit is contained in:
Torkel Ödegaard
2016-05-18 08:08:15 +02:00
42 changed files with 337 additions and 128 deletions
+1
View File
@@ -142,6 +142,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
"buildstamp": setting.BuildStamp,
"latestVersion": plugins.GrafanaLatestVersion,
"hasUpdate": plugins.GrafanaHasUpdate,
"env": setting.Env,
},
}
@@ -1,6 +1,8 @@
package commands
import (
"github.com/fatih/color"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
)
@@ -14,20 +16,17 @@ func upgradeCommand(c CommandLine) error {
return err
}
remotePlugins, err2 := s.ListAllPlugins(c.GlobalString("repo"))
v, err2 := s.GetPlugin(localPlugin.Id, c.GlobalString("repo"))
if err2 != nil {
return err2
}
for _, v := range remotePlugins.Plugins {
if localPlugin.Id == v.Id {
if ShouldUpgrade(localPlugin.Info.Version, v) {
s.RemoveInstalledPlugin(pluginsDir, pluginName)
return InstallPlugin(localPlugin.Id, "", c)
}
}
if ShouldUpgrade(localPlugin.Info.Version, v) {
s.RemoveInstalledPlugin(pluginsDir, pluginName)
return InstallPlugin(localPlugin.Id, "", c)
}
log.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id)
return nil
}
+15 -7
View File
@@ -44,7 +44,7 @@ func ReadPlugin(pluginDir, pluginName string) (m.InstalledPlugin, error) {
}
if res.Id == "" {
return m.InstalledPlugin{}, errors.New("could not read find plugin " + pluginName)
return m.InstalledPlugin{}, errors.New("could not find plugin " + pluginName + " in " + pluginDir)
}
return res, nil
@@ -69,13 +69,21 @@ func RemoveInstalledPlugin(pluginPath, id string) error {
}
func GetPlugin(pluginId, repoUrl string) (m.Plugin, error) {
resp, _ := ListAllPlugins(repoUrl)
fullUrl := repoUrl + "/repo/" + pluginId
for _, i := range resp.Plugins {
if i.Id == pluginId {
return i, nil
}
res, err := goreq.Request{Uri: fullUrl, MaxRedirects: 3}.Do()
if err != nil {
return m.Plugin{}, err
}
if res.StatusCode != 200 {
return m.Plugin{}, fmt.Errorf("Could not access %s statuscode %v", fullUrl, res.StatusCode)
}
return m.Plugin{}, errors.New("could not find plugin named \"" + pluginId + "\"")
var resp m.Plugin
err = res.Body.FromJsonTo(&resp)
if err != nil {
return m.Plugin{}, errors.New("Could not load plugin data")
}
return resp, nil
}
+10 -1
View File
@@ -24,7 +24,16 @@ func GetPluginSettings(orgId int64) (map[string]*m.PluginSettingInfoDTO, error)
}
// default to enabled true
opt := &m.PluginSettingInfoDTO{Enabled: true}
opt := &m.PluginSettingInfoDTO{
PluginId: pluginDef.Id,
OrgId: orgId,
Enabled: true,
}
// apps are disabled by default
if pluginDef.Type == PluginTypeApp {
opt.Enabled = false
}
// if it's included in app check app settings
if pluginDef.IncludedInAppId != "" {
+3 -1
View File
@@ -5,6 +5,8 @@ import (
"github.com/grafana/grafana/pkg/bus"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
)
func init() {
@@ -26,7 +28,7 @@ func GetPreferencesWithDefaults(query *m.GetPreferencesWithDefaultsQuery) error
}
res := &m.Preferences{
Theme: "dark",
Theme: setting.DefaultTheme,
Timezone: "browser",
HomeDashboardId: 0,
}
+2
View File
@@ -88,6 +88,7 @@ var (
AutoAssignOrgRole string
VerifyEmailEnabled bool
LoginHint string
DefaultTheme string
// Http auth
AdminUser string
@@ -454,6 +455,7 @@ func NewConfigContext(args *CommandLineArgs) error {
AutoAssignOrgRole = users.Key("auto_assign_org_role").In("Editor", []string{"Editor", "Admin", "Read Only Editor", "Viewer"})
VerifyEmailEnabled = users.Key("verify_email_enabled").MustBool(false)
LoginHint = users.Key("login_hint").String()
DefaultTheme = users.Key("default_theme").String()
// anonymous access
AnonymousEnabled = Cfg.Section("auth.anonymous").Key("enabled").MustBool(false)