mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 18:26:52 +08:00
feat(): update checks starting to work
This commit is contained in:
@ -15,6 +15,9 @@ type PluginSetting struct {
|
|||||||
Dependencies *plugins.PluginDependencies `json:"dependencies"`
|
Dependencies *plugins.PluginDependencies `json:"dependencies"`
|
||||||
JsonData map[string]interface{} `json:"jsonData"`
|
JsonData map[string]interface{} `json:"jsonData"`
|
||||||
DefaultNavUrl string `json:"defaultNavUrl"`
|
DefaultNavUrl string `json:"defaultNavUrl"`
|
||||||
|
|
||||||
|
LatestVersion string `json:"latestVersion"`
|
||||||
|
HasUpdate bool `json:"hasUpdate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PluginListItem struct {
|
type PluginListItem struct {
|
||||||
@ -24,7 +27,7 @@ type PluginListItem struct {
|
|||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
Pinned bool `json:"pinned"`
|
Pinned bool `json:"pinned"`
|
||||||
Info *plugins.PluginInfo `json:"info"`
|
Info *plugins.PluginInfo `json:"info"`
|
||||||
LastesVersion string `json:"latestVersion"`
|
LatestVersion string `json:"latestVersion"`
|
||||||
HasUpdate bool `json:"hasUpdate"`
|
HasUpdate bool `json:"hasUpdate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,12 @@ func GetPluginList(c *middleware.Context) Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listItem := dtos.PluginListItem{
|
listItem := dtos.PluginListItem{
|
||||||
Id: pluginDef.Id,
|
Id: pluginDef.Id,
|
||||||
Name: pluginDef.Name,
|
Name: pluginDef.Name,
|
||||||
Type: pluginDef.Type,
|
Type: pluginDef.Type,
|
||||||
Info: &pluginDef.Info,
|
Info: &pluginDef.Info,
|
||||||
|
LatestVersion: pluginDef.GrafanaNetVersion,
|
||||||
|
HasUpdate: pluginDef.GrafanaNetHasUpdate,
|
||||||
}
|
}
|
||||||
|
|
||||||
if pluginSetting, exists := pluginSettingsMap[pluginDef.Id]; exists {
|
if pluginSetting, exists := pluginSettingsMap[pluginDef.Id]; exists {
|
||||||
@ -81,6 +83,8 @@ func GetPluginSettingById(c *middleware.Context) Response {
|
|||||||
BaseUrl: def.BaseUrl,
|
BaseUrl: def.BaseUrl,
|
||||||
Module: def.Module,
|
Module: def.Module,
|
||||||
DefaultNavUrl: def.DefaultNavUrl,
|
DefaultNavUrl: def.DefaultNavUrl,
|
||||||
|
LatestVersion: def.GrafanaNetVersion,
|
||||||
|
HasUpdate: def.GrafanaNetHasUpdate,
|
||||||
}
|
}
|
||||||
|
|
||||||
query := m.GetPluginSettingByIdQuery{PluginId: pluginId, OrgId: c.OrgId}
|
query := m.GetPluginSettingByIdQuery{PluginId: pluginId, OrgId: c.OrgId}
|
||||||
|
@ -73,7 +73,7 @@ func Init() error {
|
|||||||
app.initApp()
|
app.initApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
StartPluginUpdateChecker()
|
go StartPluginUpdateChecker()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func checkForUpdates() {
|
|||||||
log.Trace("Checking for updates")
|
log.Trace("Checking for updates")
|
||||||
|
|
||||||
client := http.Client{Timeout: time.Duration(5 * time.Second)}
|
client := http.Client{Timeout: time.Duration(5 * time.Second)}
|
||||||
resp, err := client.Get("https://grafana.net/api/plugins/repo?grafanaVersion=" + setting.BuildVersion)
|
resp, err := client.Get("https://grafana.net/api/plugins/repo")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace("Failed to get plugins repo from grafana.net, %v", err.Error())
|
log.Trace("Failed to get plugins repo from grafana.net, %v", err.Error())
|
||||||
@ -69,6 +69,7 @@ func checkForUpdates() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("GNET PLUG: %v", len(data.Plugins))
|
||||||
for _, plug := range Plugins {
|
for _, plug := range Plugins {
|
||||||
for _, gplug := range data.Plugins {
|
for _, gplug := range data.Plugins {
|
||||||
if gplug.Id == plug.Id {
|
if gplug.Id == plug.Id {
|
||||||
|
Reference in New Issue
Block a user