Merge branch 'updatecheck' into pluginlist

This commit is contained in:
Torkel Ödegaard 2016-04-11 13:43:29 -04:00
commit c518fdc155
23 changed files with 230 additions and 62 deletions

View File

@ -12,7 +12,7 @@
* **Graph Panel**: Fixed issue with axis labels overlapping Y-axis, fixes [#4626](https://github.com/grafana/grafana/issues/4626) * **Graph Panel**: Fixed issue with axis labels overlapping Y-axis, fixes [#4626](https://github.com/grafana/grafana/issues/4626)
* **InfluxDB**: Fixed issue with templating query containing template variable, fixes [#4602](https://github.com/grafana/grafana/issues/4602) * **InfluxDB**: Fixed issue with templating query containing template variable, fixes [#4602](https://github.com/grafana/grafana/issues/4602)
* **Graph Panel**: Fixed issue with hiding series and stacking, fixes [#4557](https://github.com/grafana/grafana/issues/4557) * **Graph Panel**: Fixed issue with hiding series and stacking, fixes [#4557](https://github.com/grafana/grafana/issues/4557)
* **Mixed Datasources**: Fixed issue with mixing many datasources in same graph, fixes [#4604](https://github.com/grafana/grafana/issues/4604) * **Graph Panel**: Fixed issue with legend height in table mode with few series, affected iframe embedding as well, fixes [#4640](https://github.com/grafana/grafana/issues/4640)
# 3.0.0-beta2 (2016-04-04) # 3.0.0-beta2 (2016-04-04)

View File

@ -111,6 +111,13 @@ gc_interval_time = 86400
# Change this option to false to disable reporting. # Change this option to false to disable reporting.
reporting_enabled = true reporting_enabled = true
# Set to false to disable all checks to https://grafana.net
# for new vesions (grafana itself and plugins), check is used
# in some UI views to notify that grafana or plugin update exists
# This option does not cause any auto updates, nor send any information
# only a GET request to http://grafana.net to get latest versions
check_for_updates = true
# Google Analytics universal tracking code, only enabled if you specify an id here # Google Analytics universal tracking code, only enabled if you specify an id here
google_analytics_ua_id = google_analytics_ua_id =

View File

@ -100,6 +100,13 @@
# Change this option to false to disable reporting. # Change this option to false to disable reporting.
;reporting_enabled = true ;reporting_enabled = true
# Set to false to disable all checks to https://grafana.net
# for new vesions (grafana itself and plugins), check is used
# in some UI views to notify that grafana or plugin update exists
# This option does not cause any auto updates, nor send any information
# only a GET request to http://grafana.net to get latest versions
check_for_updates = true
# Google Analytics universal tracking code, only enabled if you specify an id here # Google Analytics universal tracking code, only enabled if you specify an id here
;google_analytics_ua_id = ;google_analytics_ua_id =

View File

@ -1,3 +1,4 @@
{ {
"version": "2.1.1" "stable": "2.6.0",
"testing": "3.0.0-beta1"
} }

View File

@ -15,15 +15,20 @@ 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 {
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
Id string `json:"id"` Id string `json:"id"`
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"`
LatestVersion string `json:"latestVersion"`
HasUpdate bool `json:"hasUpdate"`
} }
type PluginList []PluginListItem type PluginList []PluginListItem

View File

@ -137,9 +137,11 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
"allowOrgCreate": (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin, "allowOrgCreate": (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin,
"authProxyEnabled": setting.AuthProxyEnabled, "authProxyEnabled": setting.AuthProxyEnabled,
"buildInfo": map[string]interface{}{ "buildInfo": map[string]interface{}{
"version": setting.BuildVersion, "version": setting.BuildVersion,
"commit": setting.BuildCommit, "commit": setting.BuildCommit,
"buildstamp": setting.BuildStamp, "buildstamp": setting.BuildStamp,
"latestVersion": plugins.GrafanaLatestVersion,
"hasUpdate": plugins.GrafanaHasUpdate,
}, },
} }

View File

@ -40,10 +40,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 {
@ -87,6 +89,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}

View File

@ -10,6 +10,7 @@ import (
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models" m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
) )
@ -56,6 +57,9 @@ func sendUsageStats() {
metrics["stats.users.count"] = statsQuery.Result.UserCount metrics["stats.users.count"] = statsQuery.Result.UserCount
metrics["stats.orgs.count"] = statsQuery.Result.OrgCount metrics["stats.orgs.count"] = statsQuery.Result.OrgCount
metrics["stats.playlist.count"] = statsQuery.Result.PlaylistCount metrics["stats.playlist.count"] = statsQuery.Result.PlaylistCount
metrics["stats.plugins.apps.count"] = len(plugins.Apps)
metrics["stats.plugins.panels.count"] = len(plugins.Panels)
metrics["stats.plugins.datasources.count"] = len(plugins.DataSources)
dsStats := m.GetDataSourceStatsQuery{} dsStats := m.GetDataSourceStatsQuery{}
if err := bus.Dispatch(&dsStats); err != nil { if err := bus.Dispatch(&dsStats); err != nil {

View File

@ -45,6 +45,9 @@ type PluginBase struct {
DefaultNavUrl string `json:"-"` DefaultNavUrl string `json:"-"`
IsCorePlugin bool `json:"-"` IsCorePlugin bool `json:"-"`
GrafanaNetVersion string `json:"-"`
GrafanaNetHasUpdate bool `json:"-"`
// cache for readme file contents // cache for readme file contents
Readme []byte `json:"-"` Readme []byte `json:"-"`
} }

View File

@ -22,6 +22,9 @@ var (
Apps map[string]*AppPlugin Apps map[string]*AppPlugin
Plugins map[string]*PluginBase Plugins map[string]*PluginBase
PluginTypes map[string]interface{} PluginTypes map[string]interface{}
GrafanaLatestVersion string
GrafanaHasUpdate bool
) )
type PluginScanner struct { type PluginScanner struct {
@ -70,6 +73,7 @@ func Init() error {
app.initApp() app.initApp()
} }
go StartPluginUpdateChecker()
return nil return nil
} }

View File

@ -0,0 +1,110 @@
package plugins
import (
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/setting"
)
type GrafanaNetPlugins struct {
Plugins []GrafanaNetPlugin `json:"plugins"`
}
type GrafanaNetPlugin struct {
Id string `json:"id"`
Versions []GrafanaNetPluginVersion `json:"versions"`
}
type GrafanaNetPluginVersion struct {
Version string `json:"version"`
}
type GithubLatest struct {
Stable string `json:"stable"`
Testing string `json:"testing"`
}
func StartPluginUpdateChecker() {
if !setting.CheckForUpdates {
return
}
ticker := time.NewTicker(time.Second * 24)
for {
select {
case <-ticker.C:
checkForUpdates()
}
}
}
func checkForUpdates() {
log.Trace("Checking for updates")
client := http.Client{Timeout: time.Duration(5 * time.Second)}
resp, err := client.Get("https://grafana.net/api/plugins/repo")
if err != nil {
log.Trace("Failed to get plugins repo from grafana.net, %v", err.Error())
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Trace("Update check failed, reading response from grafana.net, %v", err.Error())
return
}
var data GrafanaNetPlugins
err = json.Unmarshal(body, &data)
if err != nil {
log.Trace("Failed to unmarshal plugin repo, reading response from grafana.net, %v", err.Error())
return
}
for _, plug := range Plugins {
for _, gplug := range data.Plugins {
if gplug.Id == plug.Id {
if len(gplug.Versions) > 0 {
plug.GrafanaNetVersion = gplug.Versions[0].Version
plug.GrafanaNetHasUpdate = plug.Info.Version != plug.GrafanaNetVersion
}
}
}
}
resp2, err := client.Get("https://raw.githubusercontent.com/grafana/grafana/master/latest.json")
if err != nil {
log.Trace("Failed to get lates.json repo from github: %v", err.Error())
return
}
defer resp2.Body.Close()
body, err = ioutil.ReadAll(resp2.Body)
if err != nil {
log.Trace("Update check failed, reading response from github.net, %v", err.Error())
return
}
var githubLatest GithubLatest
err = json.Unmarshal(body, &githubLatest)
if err != nil {
log.Trace("Failed to unmarshal github latest, reading response from github: %v", err.Error())
return
}
if strings.Contains(setting.BuildVersion, "-") {
GrafanaLatestVersion = githubLatest.Testing
GrafanaHasUpdate = githubLatest.Testing != setting.BuildVersion
} else {
GrafanaLatestVersion = githubLatest.Stable
GrafanaHasUpdate = githubLatest.Stable != setting.BuildVersion
}
}

View File

@ -124,6 +124,7 @@ var (
appliedEnvOverrides []string appliedEnvOverrides []string
ReportingEnabled bool ReportingEnabled bool
CheckForUpdates bool
GoogleAnalyticsId string GoogleAnalyticsId string
GoogleTagManagerId string GoogleTagManagerId string
@ -475,6 +476,7 @@ func NewConfigContext(args *CommandLineArgs) error {
analytics := Cfg.Section("analytics") analytics := Cfg.Section("analytics")
ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true) ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true)
CheckForUpdates = analytics.Key("check_for_updates").MustBool(true)
GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String() GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String()
GoogleTagManagerId = analytics.Key("google_tag_manager_id").String() GoogleTagManagerId = analytics.Key("google_tag_manager_id").String()

View File

@ -21,14 +21,14 @@ export class SwitchCtrl {
id: any; id: any;
/** @ngInject */ /** @ngInject */
constructor($scope) { constructor($scope, private $timeout) {
this.show = true; this.show = true;
this.id = $scope.$id; this.id = $scope.$id;
} }
internalOnChange() { internalOnChange() {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { this.$timeout(() => {
this.onChange(); this.onChange();
resolve(); resolve();
}); });

View File

@ -39,7 +39,9 @@ function (angular, coreModule, config) {
$scope.buildInfo = { $scope.buildInfo = {
version: config.buildInfo.version, version: config.buildInfo.version,
commit: config.buildInfo.commit, commit: config.buildInfo.commit,
buildstamp: new Date(config.buildInfo.buildstamp * 1000) buildstamp: new Date(config.buildInfo.buildstamp * 1000),
latestVersion: config.buildInfo.latestVersion,
hasUpdate: config.buildInfo.hasUpdate,
}; };
$scope.submit = function() { $scope.submit = function() {

View File

@ -38,31 +38,26 @@
<div ng-include src="'shareLinkOptions.html'"></div> <div ng-include src="'shareLinkOptions.html'"></div>
<div class="gf-form-group position-center"> <div class="gf-form-group section">
<div class="gf-form width-30" > <div class="gf-form width-30">
<textarea rows="5" data-share-panel-url class="gf-form-input width-30" ng-model='iframeHtml'></textarea> <textarea rows="5" data-share-panel-url class="gf-form-input width-30" ng-model='iframeHtml'></textarea>
</div> </div>
</div> </div>
<div class="gf-form-group">
<div class="gf-form position-center">
<button class="btn btn-inverse" data-clipboard-text="{{iframeHtml}}" clipboard-button><i class="fa fa-clipboard"></i> Copy</button>
</div>
</div>
</script> </script>
<script type="text/ng-template" id="shareLinkOptions.html"> <script type="text/ng-template" id="shareLinkOptions.html">
<div class="gf-form-group position-center"> <div class="gf-form-group section">
<gf-form-switch class="gf-form"
label="Current time range" label-class="width-12" switch-class="max-width-6"
checked="options.forCurrent" on-change="buildUrl()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label="Template variables" label-class="width-12" switch-class="max-width-6"
checked="options.includeTemplateVars" on-change="buildUrl()">
</gf-form-switch>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-5">Include</span> <span class="gf-form-label width-12">Theme</span>
<editor-checkbox text="Current time range" model="options.forCurrent" change="buildUrl()"></editor-checkbox> <div class="gf-form-select-wrapper width-6">
</div>
<div class="gf-form">
<span class="gf-form-label width-5">Include</span>
<editor-checkbox text="Template variables" model="options.includeTemplateVars" change="buildUrl()"></editor-checkbox>
</div>
<div class="gf-form">
<span class="gf-form-label width-5">Theme</span>
<div class="gf-form-select-wrapper max-width-10">
<select class="gf-form-input" ng-model="options.theme" ng-options="f as f for f in ['current', 'dark', 'light']" ng-change="buildUrl()"></select> <select class="gf-form-input" ng-model="options.theme" ng-options="f as f for f in ['current', 'dark', 'light']" ng-change="buildUrl()"></select>
</div> </div>
</div> </div>
@ -75,18 +70,19 @@
</div> </div>
<div ng-include src="'shareLinkOptions.html'"></div> <div ng-include src="'shareLinkOptions.html'"></div>
<div class="gf-form-group position-center"> <div>
<div class="gf-form-inline"> <div class="gf-form-group section">
<div class="gf-form-inline">
<div class="gf-form width-30"> <div class="gf-form width-30">
<input type="text" data-share-panel-url class="gf-form-input" ng-model="shareUrl"></input> <input type="text" data-share-panel-url class="gf-form-input" ng-model="shareUrl"></input>
</div> </div>
<div class="gf-form pull-right"> <div class="gf-form pull-right">
<button class="btn btn-inverse pull-right" data-clipboard-text="{{shareUrl}}" clipboard-button><i class="fa fa-clipboard"></i> Copy</button> <button class="btn btn-inverse pull-right" data-clipboard-text="{{shareUrl}}" clipboard-button><i class="fa fa-clipboard"></i> Copy</button>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="gf-form position-center" ng-show="modeSharePanel"> <div class="gf-form section" ng-show="modeSharePanel">
<a href="{{imageUrl}}" target="_blank"><i class="fa fa-camera"></i> Direct link rendered image</a> <a href="{{imageUrl}}" target="_blank"><i class="fa fa-camera"></i> Direct link rendered image</a>
</div> </div>
</script> </script>
@ -117,7 +113,7 @@
</p> </p>
</div> </div>
<div class="gf-form-group share-modal-options position-center"> <div class="gf-form-group share-modal-options">
<div class="gf-form" ng-if="step === 1"> <div class="gf-form" ng-if="step === 1">
<span class="gf-form-label width-12">Snapshot name</span> <span class="gf-form-label width-12">Snapshot name</span>
<input type="text" ng-model="snapshot.name" class="gf-form-input max-width-15" > <input type="text" ng-model="snapshot.name" class="gf-form-input max-width-15" >

View File

@ -20,8 +20,9 @@
<li class="card-item-wrapper" ng-repeat="ds in ctrl.datasources"> <li class="card-item-wrapper" ng-repeat="ds in ctrl.datasources">
<a class="card-item" href="datasources/edit/{{ds.id}}/"> <a class="card-item" href="datasources/edit/{{ds.id}}/">
<div class="card-item-header"> <div class="card-item-header">
<i class="icon-gf icon-gf-{{ds.type}}"></i> <div class="card-item-type">
{{ds.type}} {{ds.type}}
</div>
</div> </div>
<div class="card-item-body"> <div class="card-item-body">
<figure class="card-item-figure"> <figure class="card-item-figure">

View File

@ -33,8 +33,13 @@
<li class="card-item-wrapper" ng-repeat="plugin in ctrl.plugins"> <li class="card-item-wrapper" ng-repeat="plugin in ctrl.plugins">
<a class="card-item" href="plugins/{{plugin.id}}/edit"> <a class="card-item" href="plugins/{{plugin.id}}/edit">
<div class="card-item-header"> <div class="card-item-header">
<i class="icon-gf icon-gf-{{plugin.type}}"></i> <div class="card-item-type">
{{plugin.type}} <i class="icon-gf icon-gf-{{plugin.type}}"></i>
{{plugin.type}}
</div>
<div class="card-item-notice" ng-show="plugin.hasUpdate">
<span bs-tooltip="plugin.latestVersion">Update available!</span>
</div>
</div> </div>
<div class="card-item-body"> <div class="card-item-body">
<figure class="card-item-figure"> <figure class="card-item-figure">

View File

@ -78,9 +78,9 @@
Grafana version: {{buildInfo.version}}, commit: {{buildInfo.commit}}, Grafana version: {{buildInfo.version}}, commit: {{buildInfo.commit}},
build date: {{buildInfo.buildstamp | date: 'yyyy-MM-dd HH:mm:ss' }} build date: {{buildInfo.buildstamp | date: 'yyyy-MM-dd HH:mm:ss' }}
</div> </div>
<div class="version-footer text-center small" ng-show="buildInfo.hasUpdate">
<a class="external-link" target="_blank" href="http://grafana.org/download">New Grafana Version Available ({{buildInfo.latestVersion}})</a>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -16,7 +16,7 @@ export class OpenTsConfigCtrl {
tsdbVersions = [ tsdbVersions = [
{name: '<=2.1', value: 1}, {name: '<=2.1', value: 1},
{name: '2.2', value: 2}, {name: '>=2.2', value: 2},
]; ];
tsdbResolutions = [ tsdbResolutions = [

View File

@ -194,9 +194,9 @@ function (angular, _, $) {
} }
var topPadding = 6; var topPadding = 6;
$container.css("height", maxHeight - topPadding); $container.css("max-height", maxHeight - topPadding);
} else { } else {
$container.css("height", ""); $container.css("max-height", "");
} }
} }
} }

View File

@ -218,6 +218,7 @@ class TablePanelCtrl extends MetricsPanelCtrl {
if (data) { if (data) {
renderPanel(); renderPanel();
} }
ctrl.renderingCompleted();
}); });
} }
} }

View File

@ -76,13 +76,20 @@
} }
.card-item-header { .card-item-header {
margin-bottom: $spacer;
}
.card-item-type {
color: $text-color-weak; color: $text-color-weak;
text-transform: uppercase; text-transform: uppercase;
margin-bottom: $spacer;
font-size: $font-size-sm; font-size: $font-size-sm;
font-weight: bold; font-weight: bold;
} }
.card-item-notice {
font-size: $font-size-sm;
}
.card-item-name { .card-item-name {
color: $headings-color; color: $headings-color;
overflow: hidden; overflow: hidden;
@ -107,6 +114,16 @@
.card-list-layout-grid { .card-list-layout-grid {
.card-item-type {
display: inline-block;
}
.card-item-notice {
font-size: $font-size-sm;
display: inline-block;
margin-left: $spacer;
}
.card-item-header-action { .card-item-header-action {
float: right; float: right;
} }
@ -173,6 +190,7 @@
.card-item-header { .card-item-header {
float: right; float: right;
text-align: right;
} }
.card-item-figure { .card-item-figure {

View File

@ -127,6 +127,7 @@
.share-modal-options { .share-modal-options {
margin: 11px 20px 33px 20px; margin: 11px 20px 33px 20px;
display: inline-block;
} }
.share-modal-big-icon { .share-modal-big-icon {
@ -162,8 +163,3 @@
} }
} }
.modal-body {
.position-center {
display: inline-block;
}
}