From f7b4f331f3a16edc1d89eeb2ac59fc0216ca5e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 27 Mar 2015 14:23:23 +0100 Subject: [PATCH 01/18] Updating docs --- docs/sources/reference/annotations.md | 41 +++++++++++---------------- docs/sources/reference/singlestat.md | 6 ++++ pkg/api/frontendsettings.go | 6 ++-- src/css/less/variables.dark.less | 4 +-- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/docs/sources/reference/annotations.md b/docs/sources/reference/annotations.md index 37bf84cb891..41d7bf411a3 100644 --- a/docs/sources/reference/annotations.md +++ b/docs/sources/reference/annotations.md @@ -10,38 +10,31 @@ page_keywords: grafana, annotations, guide, documentation Annotations provide a way to mark points on the graph with rich events. When you hover over an annotation you can get title, tags, and text information for the event. -To enable annotations open dashboard settings and the controls tab. -Under feature toggles you will find the checkbox for annotations. +To add an annotation query click dashboard settings icon in top menu and select `Annotations` from the +dropdown. This will open the `Annotations` edit view. Click the `Add` tab to add a new annotation query. -When enabled they will appear in the sub menu controls area. -![](/img/v1/annotations_submenu1.png) +### Graphite annotations -Click the cog wheel to open the dialog where you can add & edit annotations. -![](/img/v1/annotations_dialog1.png) +Graphite supports two ways to query annotations. -## Datasources -Grafana supports many data sources for annotation. +- A regular metric query, use the `Graphite target expression` text input for this +- Graphite events query, use the `Graphite event tags` text input, especify an tag or wildcard (leave empty should also work) -- Graphite metrics -- Graphite events -- InfluxDB query -- Elasticsearch query +## Elasticsearch annoations +![](/img/v2/annotations_es.png) + +Grafana can query any Elasticsearch index for annotation events. The index name can be the name of an alias or an index wildcard pattern. +You can leave the search query blank or specify a lucene query. + +If your elasticsearch document has a timestamp field other than `@timestamp` you will need to specify that. As well +as the name for the fields that should be used for the annotation title, tags and text. Tags and text are optional. + +> **Note** The annotation timestamp field in elasticsearch need to be in UTC format. ## InfluxDB Annotations -![](/img/influxdb/influxdb_annotation.png) +![](/img/v2/annotations_influxdb.png) For InfluxDB you need to enter a query like in the above screenshot. You need to have the ```where $timeFilter``` part. If you only select one column you will not need to enter anything in the column mapping fields. If you have multiple columns you need to specify which column should be treated as title, tags and text column. -## Elasticsearch Annotations -![](/img/v1/elasticsearch_annotations_edit.png) - -You can use the same data source as you specified in config.js for storing grafana dashboards or you can specify another one. -The annotation definition contains an index name that will override the index name specified in config.js. The index name can -be the name of an alias or an index wildcard pattern. You can leave the search query blank or specify a lucene query. - -If your elasticsearch document has a timestamp field other than ```@timestamp``` you will need to specify that. As well -as the name for the fields that should be used for the annotation title, tags and text. Tags and text are optional. - -**The annotation timestamp field in elasticsearch need to be in UTC format** diff --git a/docs/sources/reference/singlestat.md b/docs/sources/reference/singlestat.md index 54085c907bb..8ca68dd82b6 100644 --- a/docs/sources/reference/singlestat.md +++ b/docs/sources/reference/singlestat.md @@ -6,4 +6,10 @@ page_keywords: grafana, singlestat, panel, documentation # Singlestat Panel +![](/img/v1/singlestat_panel2.png) +The singlestat panel allows you to show the one main summery stat of a single series (like max, min, avg, sum). It also +provides thresholds to color that singlestat metric or the panel background. + +## Options +- TODO diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index e42a2deedf2..3af191a7af7 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -1,11 +1,10 @@ package api import ( - "errors" - "fmt" "strconv" "github.com/grafana/grafana/pkg/bus" + "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/middleware" m "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/plugins" @@ -45,7 +44,8 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro meta, exists := plugins.DataSources[ds.Type] if !exists { - return nil, errors.New(fmt.Sprintf("Could not find plugin definition for data source: %v", ds.Type)) + log.Error(3, "Could not find plugin definition for data source: %v", ds.Type) + continue } dsMap["meta"] = meta diff --git a/src/css/less/variables.dark.less b/src/css/less/variables.dark.less index 9a7613ff311..9a0180added 100644 --- a/src/css/less/variables.dark.less +++ b/src/css/less/variables.dark.less @@ -161,8 +161,8 @@ @dropdownLinkColorHover: @white; @dropdownLinkColorActive: @white; -@dropdownLinkBackgroundActive: @blue; -@dropdownLinkBackgroundHover: @blue; +@dropdownLinkBackgroundActive: @blueDark; +@dropdownLinkBackgroundHover: @blueDark; From 6bd273611600ddd54f8028cf93fc9987ad8446e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 27 Mar 2015 14:39:03 +0100 Subject: [PATCH 02/18] added transparent panel option --- src/app/features/panel/partials/panel.html | 2 +- src/app/partials/panelgeneral.html | 1 + src/css/less/panel.less | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/features/panel/partials/panel.html b/src/app/features/panel/partials/panel.html index d8b91bbeb85..2f393ae9a6b 100644 --- a/src/app/features/panel/partials/panel.html +++ b/src/app/features/panel/partials/panel.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/partials/panelgeneral.html b/src/app/partials/panelgeneral.html index 21fbf68c68f..f5a73bc0851 100644 --- a/src/app/partials/panelgeneral.html +++ b/src/app/partials/panelgeneral.html @@ -10,6 +10,7 @@
+
diff --git a/src/css/less/panel.less b/src/css/less/panel.less index 20164acfb9e..a0f8fb29b0f 100644 --- a/src/css/less/panel.less +++ b/src/css/less/panel.less @@ -11,7 +11,7 @@ } .panel-container { - background: @grafanaPanelBackground; + background-color: @grafanaPanelBackground; position: relative; border: @grafanaPanelBorder; &:hover { @@ -19,6 +19,11 @@ display: block; } } + + &.panel-transparent { + background-color: transparent; + border: none; + } } .panel-content { From 80c771c9454435c5d213fe3377ed745699e89ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 27 Mar 2015 17:13:44 +0100 Subject: [PATCH 03/18] Added googla analytics id setting --- conf/defaults.ini | 18 +++++++++++------- conf/sample.ini | 15 +++++++++------ pkg/api/index.go | 4 ++++ pkg/setting/setting.go | 7 +++++-- src/app/services/all.js | 1 + src/app/services/analytics.js | 28 ++++++++++++++++++++++++++++ src/views/index.html | 14 ++++++++++++++ 7 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 src/app/services/analytics.js diff --git a/conf/defaults.ini b/conf/defaults.ini index 8d724c737d8..d372c825f53 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -1,12 +1,6 @@ app_name = Grafana app_mode = production -# Report anonymous usage counters to stats.grafana.org (https). -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -reporting-enabled = true - [server] ; protocol (http or https) protocol = http @@ -21,11 +15,21 @@ root_url = %(protocol)s://%(domain)s:%(http_port)s/ router_logging = false ; the path relative to the binary where the static (html/js/css) files are placed static_root_path = public +; enable gzip enable_gzip = false -; if https protocol +; https certs & key file cert_file = cert_key = +[analytics] +# Server reporting, sends usage counters to stats.grafana.org (https). +# No ip addresses are being tracked, only simple counters to track +# running instances, dashboard and error counts. It is very helpful to us. +# Change this option to false to disable reporting. +reporting_enabled = true +; Google Analytics universal tracking code, only enabled if you specify an id here +google_analytics_ua_id = + [database] ; Either "mysql", "postgres" or "sqlite3", it's your choice type = sqlite3 diff --git a/conf/sample.ini b/conf/sample.ini index 1e91418826a..3d4f6cf8e57 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -5,12 +5,6 @@ app_mode = production -# Report anonymous usage counters to stats.grafana.org (https). -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -reporting-enabled = true - [server] ; protocol (http or https) protocol = http @@ -27,6 +21,15 @@ router_logging = false static_root_path = public enable_gzip = false +[analytics] +# Server reporting, sends usage counters to stats.grafana.org (https). +# No ip addresses are being tracked, only simple counters to track +# running instances, dashboard and error counts. It is very helpful to us. +# Change this option to false to disable reporting. +reporting_enabled = true +; Google Analytics universal tracking code, only enabled if you specify an id here +google_analytics_ua_id = + [database] ; Either "mysql", "postgres" or "sqlite3", it's your choice type = sqlite3 diff --git a/pkg/api/index.go b/pkg/api/index.go index 4af66f18133..ceafc37b7c1 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -33,6 +33,10 @@ func setIndexViewData(c *middleware.Context) error { c.Data["AppUrl"] = setting.AppUrl c.Data["AppSubUrl"] = setting.AppSubUrl + if setting.GoogleAnalyticsId != "" { + c.Data["GoogleAnalyticsId"] = setting.GoogleAnalyticsId + } + return nil } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index defa8311e8c..87d943cdd5c 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -97,7 +97,8 @@ var ( configFiles []string - ReportingEnabled bool + ReportingEnabled bool + GoogleAnalyticsId string ) func init() { @@ -235,7 +236,9 @@ func NewConfigContext(config string) { ImagesDir = "data/png" PhantomDir = "vendor/phantomjs" - ReportingEnabled = Cfg.Section("").Key("reporting-enabled").MustBool(true) + analytics := Cfg.Section("analytics") + ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true) + GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String() readSessionConfig() } diff --git a/src/app/services/all.js b/src/app/services/all.js index 70b363d074d..da1dfebd06a 100644 --- a/src/app/services/all.js +++ b/src/app/services/all.js @@ -5,6 +5,7 @@ define([ './contextSrv', './timer', './keyboardManager', + './analytics', './popoverSrv', './backendSrv', ], diff --git a/src/app/services/analytics.js b/src/app/services/analytics.js new file mode 100644 index 00000000000..4bb7f0c79db --- /dev/null +++ b/src/app/services/analytics.js @@ -0,0 +1,28 @@ +define([ + 'angular', +], +function(angular) { + 'use strict'; + + var module = angular.module('grafana.services'); + module.service('googleAnalyticsSrv', function($rootScope, $location) { + + var first = true; + + this.init = function() { + $rootScope.$on('$viewContentLoaded', function() { + // skip first + if (first) { + first = false; + return; + } + window.ga('send', 'pageview', { page: $location.url() }); + }); + }; + + }).run(function(googleAnalyticsSrv) { + if (window.ga) { + googleAnalyticsSrv.init(); + } + }); +}); diff --git a/src/views/index.html b/src/views/index.html index fd92bccd0d5..29a31d1eda3 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -59,5 +59,19 @@ require(['app'], function (app) { app.boot(); }) + + + [[if .GoogleAnalyticsId]] + + [[end]] + From 45419195aaf7bfec824c4bb59893d314e5db532a Mon Sep 17 00:00:00 2001 From: nopzor1200 Date: Sat, 28 Mar 2015 00:30:39 -0400 Subject: [PATCH 04/18] Update migrating_to2.md some suggested updates --- docs/sources/installation/migrating_to2.md | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/sources/installation/migrating_to2.md b/docs/sources/installation/migrating_to2.md index f2ac8f8bc64..ce59cdace48 100644 --- a/docs/sources/installation/migrating_to2.md +++ b/docs/sources/installation/migrating_to2.md @@ -6,42 +6,50 @@ page_keywords: grafana, installation, migration, documentation # Migrating from v1.x to v2.x -Grafana 2.x is pretty different from v1.x in that Grafana 2.x has its own backend and its own -database to store dashboards and users in. +Grafana 2.0 represents a major update to Grafana. It brings new capabilities, many of which are enabled by its new backend and integrated database. + +The new backend lays a foundation for many new capabilities that we hope to deliver on over the coming months. For Grafana 2.0, we've focused on user and organization management and server-side sharing and rendering. + +We've attempted to provide a smooth migration path for V1.9 users to migrate to Grafana 2.0. Details are below: ## Adding Data sources -Data sources in Grafana v2.0 are no longer configured via the `config.js` file. That config file is no more. -You add data sources via UI or via the [HTTP API](../reference/http_api.md). Go the `Data Sources` view via the side menu. -The side menu can be toggled via the Grafana icon in the top header (to the right). +The 'config.js' file has been deprecated. Data sources are now managed via the UI or [HTTP API](../reference/http_api.md). Go the `Data Sources` view via the side menu (which can be toggled via the Grafana icon in the upper left of your browser. + +Add any Graphite, InfluxDB, elasticsearch, and OpenTSDB datasources that you were using with Grafana 1.x. Grafana 2.0 can be configured to communicate with your datasource using a backend mode which can eliminate many CORS-related issues, as well as provide more secure authentication to your datasources. ## Importing dashboards +Grafana 2.0 now has integrated dashboard storage engine that can be configured to use an internal sqllite database, MySQL, or Postgres. This eliminates the need to use Elasticsearch for dashboard storage for Graphite users. Grafana 2.0 no longer supports storing dashboards in InfluxDB. + ### From Elasticsearch -Start by going to the `Data Sources` view and add your elasticsearch datasource. Specify the elasticsearch -index name where your Grafana v1.x dashboards are stored, default is `grafana-dash`. + +Start by going to the `Data Sources` view (via the side menu), and add your elasticsearch datasource. Specify the elasticsearch index name where your Grafana v1.x dashboards are stored (default is `grafana-dash`). ![](/img/v2/datasource_edit_elastic.jpg) - ### From InfluxDB -Start by going to the `Data Sources` view and add your influxdb datasource. Specify the database +Start by going to the `Data Sources` view (via the side menu), and add your influxdb datasource. Specify the database name where your Grafana v1.x dashboards are stored, default is `grafana`. - ### Go to Import dashboards view -Go to the `Dashboards` view and click on the dashboards search dropdown. At the bottom of the search dropdown -you find the `Import` button. +Go to the `Dashboards` view and click on the dashboards search dropdown. Click the `Import` button at the bottom of the search dropdown. ![](/img/v2/dashboard_import.jpg) - ### Import view -In the Import view you find the section `Migrate dashboards`. Pick the datasource you added (Elasticsearch or InfluxDB) +In the Import view you find the section `Migrate dashboards`. Pick the datasource you added (from elasticsearch or InfluxDB), and click the `Import` button. ![](/img/v2/migrate_dashboards.jpg) +Your dashboards should be automatically imported into the Grafana 2.0 backend. Dashboards will no longer be stored in your previous elasticsearch or InfluxDB databases. + +### Invite your team + +Explain users and orgs. + +### Enjoy the new features From f969fce4d42c7f123bcd2d16462cedc0739931e9 Mon Sep 17 00:00:00 2001 From: nopzor1200 Date: Sat, 28 Mar 2015 00:39:13 -0400 Subject: [PATCH 05/18] Update migrating_to2.md minor tweaks --- docs/sources/installation/migrating_to2.md | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/sources/installation/migrating_to2.md b/docs/sources/installation/migrating_to2.md index ce59cdace48..68ffb65b8ee 100644 --- a/docs/sources/installation/migrating_to2.md +++ b/docs/sources/installation/migrating_to2.md @@ -6,32 +6,31 @@ page_keywords: grafana, installation, migration, documentation # Migrating from v1.x to v2.x -Grafana 2.0 represents a major update to Grafana. It brings new capabilities, many of which are enabled by its new backend and integrated database. +Grafana 2.0 represents a major update to Grafana. It brings new capabilities, many of which are enabled by its new backend server and integrated database. -The new backend lays a foundation for many new capabilities that we hope to deliver on over the coming months. For Grafana 2.0, we've focused on user and organization management and server-side sharing and rendering. +The new backend lays a foundation for many new capabilities that we hope to deliver over the coming months. For the 2.0 release, we've focused on user and organization management and server-side sharing and rendering. -We've attempted to provide a smooth migration path for V1.9 users to migrate to Grafana 2.0. Details are below: +We've attempted to provide a smooth migration path for V1.9 users to migrate to Grafana 2.0. ## Adding Data sources -The 'config.js' file has been deprecated. Data sources are now managed via the UI or [HTTP API](../reference/http_api.md). Go the `Data Sources` view via the side menu (which can be toggled via the Grafana icon in the upper left of your browser. +The 'config.js' file has been deprecated. Data sources are now managed via the UI or [HTTP API](../reference/http_api.md). Manage your organizations data sources by clicking on the `Data Sources` menu on the side menu (which can be toggled via the Grafana icon in the upper left of your browser). -Add any Graphite, InfluxDB, elasticsearch, and OpenTSDB datasources that you were using with Grafana 1.x. Grafana 2.0 can be configured to communicate with your datasource using a backend mode which can eliminate many CORS-related issues, as well as provide more secure authentication to your datasources. +From here, you can add any Graphite, InfluxDB, elasticsearch, and OpenTSDB datasources that you were using with Grafana 1.x. Grafana 2.0 can be configured to communicate with your datasource using a backend mode which can eliminate many CORS-related issues, as well as provide more secure authentication to your datasources. -## Importing dashboards +## Importing your existing dashboards -Grafana 2.0 now has integrated dashboard storage engine that can be configured to use an internal sqllite database, MySQL, or Postgres. This eliminates the need to use Elasticsearch for dashboard storage for Graphite users. Grafana 2.0 no longer supports storing dashboards in InfluxDB. +Grafana 2.0 now has integrated dashboard storage engine that can be configured to use an internal sqllite database, MySQL, or Postgres. This eliminates the need to use Elasticsearch for dashboard storage for Graphite users. Grafana 2.0 no longer supports storing dashboards in InfluxDB. You can seamlessly import your existing dashboards. -### From Elasticsearch +### dashboards from Elasticsearch -Start by going to the `Data Sources` view (via the side menu), and add your elasticsearch datasource. Specify the elasticsearch index name where your Grafana v1.x dashboards are stored (default is `grafana-dash`). +Start by going to the `Data Sources` view (via the side menu), and make sure your elasticsearch datasource is added. Specify the elasticsearch index name where your existing Grafana v1.x dashboards are stored (default is `grafana-dash`). ![](/img/v2/datasource_edit_elastic.jpg) -### From InfluxDB +### dashboards from InfluxDB -Start by going to the `Data Sources` view (via the side menu), and add your influxdb datasource. Specify the database -name where your Grafana v1.x dashboards are stored, default is `grafana`. +Start by going to the `Data Sources` view (via the side menu), and make sure your InfluxDB datasource is added. Specify the database name where your Grafana v1.x dashboards are stored, default is `grafana`. ### Go to Import dashboards view @@ -46,7 +45,9 @@ and click the `Import` button. ![](/img/v2/migrate_dashboards.jpg) -Your dashboards should be automatically imported into the Grafana 2.0 backend. Dashboards will no longer be stored in your previous elasticsearch or InfluxDB databases. +Your dashboards should be automatically imported into the Grafana 2.0 backend. + +Dashboards will no longer be stored in your previous elasticsearch or InfluxDB databases. ### Invite your team From 1200dd4b755aa29f1f1f52652920b95b8abd64ba Mon Sep 17 00:00:00 2001 From: nopzor1200 Date: Sat, 28 Mar 2015 11:57:00 -0400 Subject: [PATCH 06/18] Update migrating_to2.md --- docs/sources/installation/migrating_to2.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/sources/installation/migrating_to2.md b/docs/sources/installation/migrating_to2.md index 68ffb65b8ee..b90037e0cba 100644 --- a/docs/sources/installation/migrating_to2.md +++ b/docs/sources/installation/migrating_to2.md @@ -8,19 +8,21 @@ page_keywords: grafana, installation, migration, documentation Grafana 2.0 represents a major update to Grafana. It brings new capabilities, many of which are enabled by its new backend server and integrated database. -The new backend lays a foundation for many new capabilities that we hope to deliver over the coming months. For the 2.0 release, we've focused on user and organization management and server-side sharing and rendering. +The new backend lays a solid foundation that we hope to build on over the coming months. For the 2.0 release, it enables authentication as well as server-side sharing and rendering. We've attempted to provide a smooth migration path for V1.9 users to migrate to Grafana 2.0. ## Adding Data sources -The 'config.js' file has been deprecated. Data sources are now managed via the UI or [HTTP API](../reference/http_api.md). Manage your organizations data sources by clicking on the `Data Sources` menu on the side menu (which can be toggled via the Grafana icon in the upper left of your browser). +The config.js file has been deprecated. Data sources are now managed via the UI or [HTTP API](../reference/http_api.md). Manage your organizations data sources by clicking on the `Data Sources` menu on the side menu (which can be toggled via the Grafana icon in the upper left of your browser). From here, you can add any Graphite, InfluxDB, elasticsearch, and OpenTSDB datasources that you were using with Grafana 1.x. Grafana 2.0 can be configured to communicate with your datasource using a backend mode which can eliminate many CORS-related issues, as well as provide more secure authentication to your datasources. ## Importing your existing dashboards -Grafana 2.0 now has integrated dashboard storage engine that can be configured to use an internal sqllite database, MySQL, or Postgres. This eliminates the need to use Elasticsearch for dashboard storage for Graphite users. Grafana 2.0 no longer supports storing dashboards in InfluxDB. You can seamlessly import your existing dashboards. +Grafana 2.0 now has integrated dashboard storage engine that can be configured to use an internal sqllite database, MySQL, or Postgres. This eliminates the need to use Elasticsearch for dashboard storage for Graphite users. Grafana 2.0 does not support storing dashboards in InfluxDB. + +You can seamlessly import your existing dashboards. ### dashboards from Elasticsearch From 8e9a0eddf5c35390d93376ef09331fdd294637b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 28 Mar 2015 17:53:52 +0100 Subject: [PATCH 07/18] Custom snapshot topnav header, new custom dashboard snapshot icon, #1623 --- pkg/api/dashboard_snapshot.go | 6 +++- pkg/api/dtos/models.go | 11 ++++--- src/app/directives/topnav.js | 2 +- src/app/features/dashboard/all.js | 1 + src/app/features/dashboard/dashboardCtrl.js | 6 ++-- .../features/dashboard/dashboardNavCtrl.js | 30 ++---------------- .../dashboard/partials/dashboardTopNav.html} | 0 .../dashboard/partials/shareDashboard.html | 8 +++-- .../dashboard/partials/snapshotTopNav.html | 31 +++++++++++++++++++ .../features/dashboard/snapshotTopNavCtrl.js | 22 +++++++++++++ src/app/panels/timepicker/module.js | 25 +++++++++++++++ src/app/partials/dashboard.html | 4 +-- src/css/less/fonts.less | 22 +++++++++++++ src/css/less/grafana.less | 19 ++++++------ src/css/less/navbar.less | 26 +++++++++++++--- src/vendor/css/font-awesome.min.css | 1 + 16 files changed, 157 insertions(+), 57 deletions(-) rename src/app/{partials/dashboard_topnav.html => features/dashboard/partials/dashboardTopNav.html} (100%) create mode 100644 src/app/features/dashboard/partials/snapshotTopNav.html create mode 100644 src/app/features/dashboard/snapshotTopNavCtrl.js create mode 100644 src/css/less/fonts.less diff --git a/pkg/api/dashboard_snapshot.go b/pkg/api/dashboard_snapshot.go index 8de96ec9f21..fe628d580b1 100644 --- a/pkg/api/dashboard_snapshot.go +++ b/pkg/api/dashboard_snapshot.go @@ -65,7 +65,11 @@ func GetDashboardSnapshot(c *middleware.Context) { dto := dtos.Dashboard{ Model: snapshot.Dashboard, - Meta: dtos.DashboardMeta{IsSnapshot: true}, + Meta: dtos.DashboardMeta{ + IsSnapshot: true, + Created: snapshot.Created, + Expires: snapshot.Expires, + }, } metrics.M_Api_Dashboard_Snapshot_Get.Inc(1) diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index 2cb9da0189f..53519631d22 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -4,6 +4,7 @@ import ( "crypto/md5" "fmt" "strings" + "time" m "github.com/grafana/grafana/pkg/models" ) @@ -27,10 +28,12 @@ type CurrentUser struct { } type DashboardMeta struct { - IsStarred bool `json:"isStarred"` - IsHome bool `json:"isHome"` - IsSnapshot bool `json:"isSnapshot"` - Slug string `json:"slug"` + IsStarred bool `json:"isStarred"` + IsHome bool `json:"isHome"` + IsSnapshot bool `json:"isSnapshot"` + Slug string `json:"slug"` + Expires time.Time `json:"expires"` + Created time.Time `json:"created"` } type Dashboard struct { diff --git a/src/app/directives/topnav.js b/src/app/directives/topnav.js index c871dd085cb..88b98d55984 100644 --- a/src/app/directives/topnav.js +++ b/src/app/directives/topnav.js @@ -25,7 +25,7 @@ function (angular) { '' + '' + - '' + + '' + '' + '' + diff --git a/src/app/features/dashboard/all.js b/src/app/features/dashboard/all.js index d297ce502a8..1380034dd19 100644 --- a/src/app/features/dashboard/all.js +++ b/src/app/features/dashboard/all.js @@ -1,6 +1,7 @@ define([ './dashboardCtrl', './dashboardNavCtrl', + './snapshotTopNavCtrl', './saveDashboardAsCtrl', './playlistCtrl', './rowCtrl', diff --git a/src/app/features/dashboard/dashboardCtrl.js b/src/app/features/dashboard/dashboardCtrl.js index a8e0a2e595b..649fc14ede0 100644 --- a/src/app/features/dashboard/dashboardCtrl.js +++ b/src/app/features/dashboard/dashboardCtrl.js @@ -21,6 +21,7 @@ function (angular, $, config) { $timeout) { $scope.editor = { index: 0 }; + $scope.topNavPartial = 'app/features/dashboard/partials/dashboardTopNav.html'; $scope.panels = config.panels; var resizeEventTimeout; @@ -76,10 +77,7 @@ function (angular, $, config) { } if (dashboard.snapshot) { - meta.canEdit = false; - meta.canSave = false; - meta.canStar = false; - meta.canShare = false; + $scope.topNavPartial = 'app/features/dashboard/partials/snapshotTopNav.html'; } $scope.dashboardMeta = meta; diff --git a/src/app/features/dashboard/dashboardNavCtrl.js b/src/app/features/dashboard/dashboardNavCtrl.js index 17bdfb5efc7..6c017ae856e 100644 --- a/src/app/features/dashboard/dashboardNavCtrl.js +++ b/src/app/features/dashboard/dashboardNavCtrl.js @@ -1,25 +1,20 @@ define([ 'angular', 'lodash', - 'moment', 'config', 'store', 'filesaver' ], -function (angular, _, moment) { +function (angular, _) { 'use strict'; var module = angular.module('grafana.controllers'); - module.controller('DashboardNavCtrl', function($scope, $rootScope, alertSrv, $location, playlistSrv, backendSrv, timeSrv, $timeout) { + module.controller('DashboardNavCtrl', function($scope, $rootScope, alertSrv, $location, playlistSrv, backendSrv, $timeout) { $scope.init = function() { $scope.onAppEvent('save-dashboard', $scope.saveDashboard); $scope.onAppEvent('delete-dashboard', $scope.deleteDashboard); - - $scope.onAppEvent('zoom-out', function() { - $scope.zoom(2); - }); }; $scope.openEditView = function(editview) { @@ -136,27 +131,6 @@ function (angular, _, moment) { window.saveAs(blob, $scope.dashboard.title + '-' + new Date().getTime()); }; - $scope.zoom = function(factor) { - var range = timeSrv.timeRange(); - - var timespan = (range.to.valueOf() - range.from.valueOf()); - var center = range.to.valueOf() - timespan/2; - - var to = (center + (timespan*factor)/2); - var from = (center - (timespan*factor)/2); - - if(to > Date.now() && range.to <= Date.now()) { - var offset = to - Date.now(); - from = from - offset; - to = Date.now(); - } - - timeSrv.setTime({ - from: moment.utc(from).toDate(), - to: moment.utc(to).toDate(), - }); - }; - $scope.snapshot = function() { $scope.dashboard.snapshot = true; $rootScope.$broadcast('refresh'); diff --git a/src/app/partials/dashboard_topnav.html b/src/app/features/dashboard/partials/dashboardTopNav.html similarity index 100% rename from src/app/partials/dashboard_topnav.html rename to src/app/features/dashboard/partials/dashboardTopNav.html diff --git a/src/app/features/dashboard/partials/shareDashboard.html b/src/app/features/dashboard/partials/shareDashboard.html index fefca5a9100..d00f95355ea 100644 --- a/src/app/features/dashboard/partials/shareDashboard.html +++ b/src/app/features/dashboard/partials/shareDashboard.html @@ -47,8 +47,12 @@