diff --git a/CHANGELOG.md b/CHANGELOG.md index 9959767c087..cb4ab3ad1e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,19 @@ -# 3.0.0 (unrelased master branch) +# 3.0.0-beta2 (unreleased) + +### New Features (introduces since 3.0-beta1) +* **Preferences**: Set home dashboard on user and org level, closes [#1678](https://github.com/grafana/grafana/issues/1678) +* **Preferences**: Set timezone on user and org level, closes [#3214](https://github.com/grafana/grafana/issues/3214), [#1200](https://github.com/grafana/grafana/issues/1200) +* **Preferences**: Set theme on user and org level, closes [#3214](https://github.com/grafana/grafana/issues/3214), [#1917](https://github.com/grafana/grafana/issues/1917) + +### Bug fixes +* **Dashboard**: Fixed dashboard panel layout for mobile devices, fixes [#4529](https://github.com/grafana/grafana/issues/4529) +* **Table Panel**: Fixed issue with table panel sort, fixes [#4532](https://github.com/grafana/grafana/issues/4532) +* **Page Load Crash**: A Datasource with null jsonData would make Grafana fail to load page, fixes [#4536](https://github.com/grafana/grafana/issues/4536) +* **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4540](https://github.com/grafana/grafana/issues/4540) +* **Graph**: Fix legend in table mode with series on right-y axis, fixes [#4551](https://github.com/grafana/grafana/issues/4551), [#1145](https://github.com/grafana/grafana/issues/1145) +* **Password**: Password reset link/page did not work, fixes [#4542](https://github.com/grafana/grafana/issues/4542) + +# 3.0.0-beta1 (2016-03-31) ### New Features * **Playlists**: Playlists can now be persisted and started from urls, closes [#3655](https://github.com/grafana/grafana/issues/3655) diff --git a/Gruntfile.js b/Gruntfile.js index 70defdeaf6d..9a0c69b96f9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -18,6 +18,7 @@ module.exports = function (grunt) { } config.pkg.version = grunt.option('pkgVer') || config.pkg.version; + console.log('Version', config.pkg.version); // load plugins require('load-grunt-tasks')(grunt); diff --git a/appveyor.yml b/appveyor.yml index 83506312912..7d84bafc148 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ os: Windows Server 2012 R2 clone_folder: c:\gopath\src\github.com\grafana\grafana environment: - nodejs_version: "4" + nodejs_version: "5" GOPATH: c:\gopath install: diff --git a/build.go b/build.go index 9a945a2b07d..93b9e6db087 100644 --- a/build.go +++ b/build.go @@ -73,8 +73,7 @@ func main() { grunt("test") case "package": - //verifyGitRepoIsClean() - grunt("release") + grunt("release", fmt.Sprintf("--pkgVer=%v-%v", linuxPackageVersion, linuxPackageIteration)) createLinuxPackages() case "pkg-rpm": @@ -100,12 +99,12 @@ func main() { func makeLatestDistCopies() { rpmIteration := "-1" if linuxPackageIteration != "" { - rpmIteration = "-" + linuxPackageIteration + rpmIteration = linuxPackageIteration } - runError("cp", "dist/grafana_"+version+"_amd64.deb", "dist/grafana_latest_amd64.deb") - runError("cp", "dist/grafana-"+linuxPackageVersion+rpmIteration+".x86_64.rpm", "dist/grafana-latest-1.x86_64.rpm") - runError("cp", "dist/grafana-"+version+".linux-x64.tar.gz", "dist/grafana-latest.linux-x64.tar.gz") + runError("cp", fmt.Sprintf("dist/grafana_%v-%v_amd64.deb", linuxPackageVersion, linuxPackageIteration), "dist/grafana_latest_amd64.deb") + runError("cp", fmt.Sprintf("dist/grafana-%v-%v.x86_64.rpm", linuxPackageVersion, rpmIteration), "dist/grafana-latest-1.x86_64.rpm") + runError("cp", fmt.Sprintf("dist/grafana-%v-%v.linux-x64.tar.gz", linuxPackageVersion, linuxPackageIteration), "dist/grafana-latest.linux-x64.tar.gz") } func readVersionFromPackageJson() { @@ -133,6 +132,11 @@ func readVersionFromPackageJson() { if len(parts) > 1 { linuxPackageVersion = parts[0] linuxPackageIteration = parts[1] + if linuxPackageIteration != "" { + // add timestamp to iteration + linuxPackageIteration = fmt.Sprintf("%s%v", linuxPackageIteration, time.Now().Unix()) + } + log.Println(fmt.Sprintf("teration %v", linuxPackageIteration)) } } diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 1ecefe85c68..46b0b964b59 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -86,13 +86,12 @@ pages: - ['http_api/snapshot.md', 'API', 'Snapshot API'] - ['http_api/other.md', 'API', 'Other API'] -- ['plugins/overview.md', 'Plugins', 'Overview'] +- ['plugins/index.md', 'Plugins', 'Overview'] - ['plugins/installation.md', 'Plugins', 'Installation'] -- ['plugins/app.md', 'Plugins', 'App plugins'] -- ['plugins/datasources.md', 'Plugins', 'Datasource plugins'] -- ['plugins/panels.md', 'Plugins', 'Panel plugins'] -- ['plugins/development.md', 'Plugins', 'Plugin development'] -- ['plugins/plugin.json.md', 'Plugins', 'Plugin json'] +- ['plugins/development.md', 'Plugins', 'Development'] +- ['plugins/apps.md', 'Plugins', 'Apps'] +- ['plugins/datasources.md', 'Plugins', 'Datasources'] +- ['plugins/panels.md', 'Plugins', 'Panels'] - ['tutorials/index.md', 'Tutorials', 'Tutorials'] - ['tutorials/hubot_howto.md', 'Tutorials', 'How To integrate Hubot and Grafana'] diff --git a/docs/sources/installation/debian.md b/docs/sources/installation/debian.md index b5c72f3182c..2d24e7a9c3f 100644 --- a/docs/sources/installation/debian.md +++ b/docs/sources/installation/debian.md @@ -10,14 +10,21 @@ page_keywords: grafana, installation, debian, ubuntu, guide Description | Download ------------ | ------------- -.deb for Debian-based Linux | [grafana_2.6.0_amd64.deb](https://grafanarel.s3.amazonaws.com/builds/grafana_2.6.0_amd64.deb) +Stable .deb for Debian-based Linux | [grafana_2.6.0_amd64.deb](https://grafanarel.s3.amazonaws.com/builds/grafana_2.6.0_amd64.deb) +Beta .deb for Debian-based Linux | [grafana_3.0.0-beta11459429091_amd64.deb](https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.0-beta11459429091_amd64.deb) -## Install +## Install Stable $ wget https://grafanarel.s3.amazonaws.com/builds/grafana_2.6.0_amd64.deb $ sudo apt-get install -y adduser libfontconfig $ sudo dpkg -i grafana_2.6.0_amd64.deb +## Install 3.0 Beta + + $ wget https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.0-beta11459429091_amd64.deb + $ sudo apt-get install -y adduser libfontconfig + $ sudo dpkg -i grafana_3.0.0-beta11459429091_amd64.deb + ## APT Repository Add the following line to your `/etc/apt/sources.list` file. diff --git a/docs/sources/installation/rpm.md b/docs/sources/installation/rpm.md index ec4f648e44b..5e8e746d0f7 100644 --- a/docs/sources/installation/rpm.md +++ b/docs/sources/installation/rpm.md @@ -10,9 +10,10 @@ page_keywords: grafana, installation, centos, fedora, opensuse, redhat, guide Description | Download ------------ | ------------- -.RPM for CentOS / Fedora / OpenSuse / Redhat Linux | [grafana-2.6.0-1.x86_64.rpm](https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0-1.x86_64.rpm) +Stable .RPM for CentOS / Fedora / OpenSuse / Redhat Linux | [grafana-2.6.0-1.x86_64.rpm](https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0-1.x86_64.rpm) +Beta .RPM for CentOS / Fedor / OpenSuse / Redhat Linux | [grafana-3.0.0-beta11459429091.x86_64.rpm](https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.0-beta11459429091.x86_64.rpm) -## Install from package file +## Install Stable Release from package file You can install Grafana using Yum directly. @@ -29,6 +30,24 @@ Or install manually using `rpm`. $ sudo rpm -i --nodeps grafana-2.6.0-1.x86_64.rpm +## Install Beta Release from package file + +You can install Grafana using Yum directly. + + $ sudo yum install https://grafanarel.s3.amazonaws.com/builds/grafana-3.0.0-beta11459429091.x86_64.rpm + +Or install manually using `rpm`. + +#### On CentOS / Fedora / Redhat: + + $ sudo yum install initscripts fontconfig + $ sudo rpm -Uvh grafana-3.0.0-beta11459429091.x86_64.rpm + +#### On OpenSuse: + + $ sudo rpm -i --nodeps grafana-3.0.0-beta11459429091.x86_64.rpm + + ## Install via YUM Repository Add the following to a new file at `/etc/yum.repos.d/grafana.repo` diff --git a/docs/sources/installation/windows.md b/docs/sources/installation/windows.md index 1bc2b5a2b92..9a1ccbd0a19 100644 --- a/docs/sources/installation/windows.md +++ b/docs/sources/installation/windows.md @@ -10,7 +10,7 @@ page_keywords: grafana, installation, windows guide Description | Download ------------ | ------------- -Zip package for Windows | [grafana.2.5.0.windows-x64.zip](https://grafanarel.s3.amazonaws.com/winbuilds/dist/grafana-2.5.0.windows-x64.zip) +Stable Zip package for Windows | [grafana.2.5.0.windows-x64.zip](https://grafanarel.s3.amazonaws.com/winbuilds/dist/grafana-2.5.0.windows-x64.zip) ## Configure diff --git a/docs/sources/plugins/app.md b/docs/sources/plugins/app.md deleted file mode 100644 index 250af25c57d..00000000000 --- a/docs/sources/plugins/app.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -page_title: App plugin -page_description: App plugin for Grafana -page_keywords: grafana, plugins, documentation ---- - - > Our goal is not to have a very extensive documentation but rather have actual code that people can look at. An example implementation of an app can be found in this [example app repo](https://github.com/grafana/example-app) - -# Apps - -App plugins is a new kind of grafana plugin that can bundle datasource and panel plugins within one package. It also enable the plugin author to create custom pages within grafana. The custom pages enables the plugin author to include things like documentation, sign up forms or controlling other services using HTTP requests. - -Datasource and panel plugins will show up like normal plugins. The app pages will be available in the main menu. - - - -## Enabling app plugins -After installing an app it have to be enabled before it show up as an datasource or panel. You can do that on the app page in the config tab. - -## README.md - -The readme file in the mounted folder will show up in the overview tab on the app page. - -## Module exports -```javascript -export { - ExampleAppConfigCtrl as ConfigCtrl, - StreamPageCtrl, - LogsPageCtrl -}; -``` -The only required export is the ConfigCtrl. Both StreamPageCtrl and LogsPageCtrl are custom pages defined in plugin.json - -## Custom pages -Custom pages are defined in the plugin.json like this. -```json -"pages": [ - { "name": "Live stream", "component": "StreamPageCtrl", "role": "Editor"}, - { "name": "Log view", "component": "LogsPageCtrl", "role": "Viewer"} -] -``` -The component field have to match one of the components exported in the module.js in the root of the plugin. - -## Bundled plugins - -When Grafana starts it will scan all directories within an app plugin and load folders containing a plugin.json as an plugin. diff --git a/docs/sources/plugins/apps.md b/docs/sources/plugins/apps.md new file mode 100644 index 00000000000..74038a9feb9 --- /dev/null +++ b/docs/sources/plugins/apps.md @@ -0,0 +1,24 @@ +--- +page_title: App plugin +page_description: App plugin for Grafana +page_keywords: grafana, plugins, documentation +--- + + +# Apps + +App plugins is a new kind of grafana plugin that can bundle datasource and panel plugins within one package. It also enable the plugin author to create custom pages within grafana. The custom pages enables the plugin author to include things like documentation, sign up forms or controlling other services using HTTP requests. + +Datasource and panel plugins will show up like normal plugins. The app pages will be available in the main menu. + + + +## Enabling app plugins +After installing an app it have to be enabled before it show up as an datasource or panel. You can do that on the app page in the config tab. + +### Develop your own App + +> Our goal is not to have a very extensive documentation but rather have actual +> code that people can look at. An example implementation of an app can be found +> in this [example app repo](https://github.com/grafana/example-app) + diff --git a/docs/sources/plugins/datasources.md b/docs/sources/plugins/datasources.md index c44cd842844..3732948d527 100644 --- a/docs/sources/plugins/datasources.md +++ b/docs/sources/plugins/datasources.md @@ -4,11 +4,18 @@ page_description: Datasource plugins for Grafana page_keywords: grafana, plugins, documentation --- - > Our goal is not to have a very extensive documentation but rather have actual code that people can look at. An example implementation of a datasource can be found in this [example datasource repo](https://github.com/grafana/simple-json-datasource) # Datasources -Datasource plugins enables people to develop plugins for any database that communicates over http. Its up to the plugin to transform the data into time series data so that any grafana panel can then show it. +Datasource plugins enables people to develop plugins for any database that +communicates over http. Its up to the plugin to transform the data into +time series data so that any grafana panel can then show it. + +## Datasource development + +> Our goal is not to have a very extensive documentation but rather have actual +> code that people can look at. An example implementation of a datasource can be +> found in this [example datasource repo](https://github.com/grafana/simple-json-datasource) To interact with the rest of grafana the plugins module file can export 5 different components. @@ -19,11 +26,14 @@ To interact with the rest of grafana the plugins module file can export 5 differ - AnnotationsQueryCtrl ## Plugin json + There are two datasource specific settings for the plugin.json + ```javascript "metrics": true, "annotations": false, ``` + These settings indicates what kind of data the plugin can deliver. At least one of them have to be true ## Datasource diff --git a/docs/sources/plugins/developing_plugins.md b/docs/sources/plugins/development.md similarity index 63% rename from docs/sources/plugins/developing_plugins.md rename to docs/sources/plugins/development.md index 43a99956d55..e8b5c620732 100644 --- a/docs/sources/plugins/developing_plugins.md +++ b/docs/sources/plugins/development.md @@ -1,5 +1,5 @@ --- -page_title: Plugin development +page_title: Plugin development guide page_description: Plugin development for Grafana page_keywords: grafana, plugins, documentation, development --- @@ -11,7 +11,7 @@ From grafana 3.0 it's very easy to develop your own plugins and share them with ## Short version 1. [Setup grafana](https://github.com/grafana/grafana/blob/master/DEVELOPMENT.md) -2. Clone an example plugin into ```data/plugins``` +2. Clone an example plugin into ```/var/lib/grafana/plugins``` or `data/plugins` (relative to grafana git repo if your running development version from source dir) 3. Code away! ## What languages? @@ -26,20 +26,25 @@ All our example plugins have build scripted configured. ## module.(js|ts) -This is the entry point for every plugin. This is the place where you should export your plugin implementation. Depending on what kind of plugin you are developing you will be expected to export different things. You can find whats expected for [datasource](http://docs.grafana.org/v3.0/plugins/datasources/), [panels](http://docs.grafana.org/v3.0/plugins/panels/) and [apps](http://docs.grafana.org/v3.0/plugins/app/) -plugins in the documentation. +This is the entry point for every plugin. This is the place where you should export +your plugin implementation. Depending on what kind of plugin you are developing you +will be expected to export different things. You can find what's expected for [datasource](./datasources.md), [panels](./panels.md) +and [apps](./apps.md) plugins in the documentation. ## Start developing your plugin There are two ways that you can start developing a Grafana plugin. -1. Setup a Grafana development environment. [(described here)](https://github.com/grafana/grafana/blob/master/DEVELOPMENT.md) and place your plugin in the ```data/plugins``` folder. -2. Install Grafana and place your plugin the plugins directory which is set in your [config file](http://docs.grafana.org/installation/configuration/) + +1. Setup a Grafana development environment. [(described here)](https://github.com/grafana/grafana/blob/master/DEVELOPMENT.md) and place your plugin in the ```data/plugins``` folder. +2. Install Grafana and place your plugin in the plugins directory which is set in your [config file](../installation/configuration.md). By default this is `/var/lib/grafana/plugins` on Linux systems. +3. Place your plugin directory anywhere you like and specify it grafana.ini. We encourage people to setup the full Grafana environment so that you can get inspiration from the rest of grafana code base. -When Grafana starts it will scan the plugin folders and mount every folder that contains a plugin.json file unless the folder contains a subfolder named dist. In that case grafana will mount the dist folder instead. -This makes it possible to have both built and src content in the same plugin folder. +When Grafana starts it will scan the plugin folders and mount every folder that contains a plugin.json file unless +the folder contains a subfolder named dist. In that case grafana will mount the dist folder instead. +This makes it possible to have both built and src content in the same plugin git repo. -## Boilerplate +## Examples We currently have three different examples that you can fork/download to get started developing your grafana plugin. - [simple-json-datasource](https://github.com/grafana/simple-json-datasource) (small datasource plugin for querying json data from backends) diff --git a/docs/sources/plugins/index.md b/docs/sources/plugins/index.md new file mode 100644 index 00000000000..156262a4ec1 --- /dev/null +++ b/docs/sources/plugins/index.md @@ -0,0 +1,21 @@ +--- +page_title: Plugin overview +page_description: Plugins for Grafana +page_keywords: grafana, plugins, documentation +--- + +# Plugins + +From Grafana 3.0 not only datasource plugins are supported but also panel plugins and apps. +Having panels as plugins make it easy to create and add any kind of panel, to show your data +or improve your favorite dashboards. Apps is something new in Grafana that enables +bundling of datasources, panels, dashboards and Grafana pages into a cohesive experiance. + +Grafana already have a strong community of contributors and plugin developers. +By making it easier to develop and install plugins we hope that the community +can grow even stronger and develop new plugins that we would never think about. + +You can discover available plugins on [Grafana.net](http://grafana.net) + + + diff --git a/docs/sources/plugins/installation.md b/docs/sources/plugins/installation.md index 7c60ccca7d2..0dada8b69a7 100644 --- a/docs/sources/plugins/installation.md +++ b/docs/sources/plugins/installation.md @@ -4,14 +4,12 @@ page_description: Plugin installation for Grafana page_keywords: grafana, plugins, documentation --- -# Plugins - -## Installing plugins +# Installing plugins The easiest way to install plugins is by using the CLI tool grafana-cli which is bundled with grafana. Before any modification take place after modifying plugins, grafana-server needs to be restarted. ### Grafana plugin directory -On Linux systems the grafana-cli will assume that the grafana plugin directory is "/var/lib/grafana/plugins". It's possible to override the directory which grafana-cli will operate on by specifying the --path flag. On Windows systems this parameter have to be specified for every call. +On Linux systems the grafana-cli will assume that the grafana plugin directory is `/var/lib/grafana/plugins`. It's possible to override the directory which grafana-cli will operate on by specifying the --path flag. On Windows systems this parameter have to be specified for every call. ### Grafana-cli commands diff --git a/docs/sources/plugins/overview.md b/docs/sources/plugins/overview.md deleted file mode 100644 index 6d0864ac8f5..00000000000 --- a/docs/sources/plugins/overview.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -page_title: Plugin overview -page_description: Plugins for Grafana -page_keywords: grafana, plugins, documentation ---- - -# Plugins - -From Grafana 3.0 not only datasource plugins are supported but also panel plugins and apps. Having panels as plugins make it easy to create and add any kind of panel, to show your data or improve your favorite dashboards. Apps is something new in Grafana that enables bundling of datasources, panels that belongs together. - -Grafana already have a strong community of contributors and plugin developers. By making it easier to develop and install plugins we hope that the community can grow even stronger and develop new plugins that we would never think about. - diff --git a/docs/sources/plugins/panels.md b/docs/sources/plugins/panels.md index ad9d5db66d8..7182c3182a3 100644 --- a/docs/sources/plugins/panels.md +++ b/docs/sources/plugins/panels.md @@ -4,26 +4,15 @@ page_description: Panel plugins for Grafana page_keywords: grafana, plugins, documentation --- - > Our goal is not to have a very extensive documentation but rather have actual code that people can look at. An example implementation of a datasource can be found in the grafana repo under /examples/panel-boilerplate-es5 # Panels -To interact with the rest of grafana the panel plugin need to export a class in the module.js. -This class have to inherit from sdk.PanelCtrl or sdk.MetricsPanelCtrl and be exported as PanelCtrl. +Panels are the main bulding block of dashboards. -```javascript - return { - PanelCtrl: BoilerPlatePanelCtrl - }; -``` +## Panel development -This class will be instantiated once for every panel of its kind in a dashboard and treated as an AngularJs controller. +Examples -## MetricsPanelCtrl or PanelCtrl - -MetricsPanelCtrl inherits from PanelCtrl and adds some common features for datasource usage. So if your Panel will be working with a datasource you should inherit from MetricsPanelCtrl. If don't need to access any datasource then you should inherit from PanelCtrl instead. - -## Implementing a MetricsPanelCtrl - -If you choose to inherit from MetricsPanelCtrl you should implement a function called refreshData that will take a datasource as in parameter when its time to get new data. Its recommended that the refreshData function calls the issueQueries in the base class but its not mandatory. An examples of such implementation can be found in our [example panel](https://github.com/grafana/grafana/blob/master/examples/panel-boilerplate-es5/module.js#L27-L38) +- [clock-panel](https://github.com/grafana/clock-panel) +- [singlestat-panel](https://github.com/grafana/grafana/blob/master/public/app/plugins/panel/singlestat/module.ts) diff --git a/docs/sources/versions.html_fragment b/docs/sources/versions.html_fragment index d699cc6b6ac..0d62ee1e461 100644 --- a/docs/sources/versions.html_fragment +++ b/docs/sources/versions.html_fragment @@ -1,3 +1,4 @@ +
  • Version v3.0
  • Version v2.6
  • Version v2.5
  • Version v2.1
  • diff --git a/karma.conf.js b/karma.conf.js index 6d6d4583a0f..dc082924b11 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -8,10 +8,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'vendor/npm/es5-shim/es5-shim.js', - 'vendor/npm/es5-shim/es5-sham.js', 'vendor/npm/es6-shim/es6-shim.js', - 'vendor/npm/es6-promise/dist/es6-promise.js', 'vendor/npm/systemjs/dist/system.src.js', 'test/test-main.js', diff --git a/package.json b/package.json index 6a9edec76ae..d741bab574e 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,14 @@ "company": "Coding Instinct AB" }, "name": "grafana", - "version": "3.0.0-pre1", + "version": "3.0.0-beta2", "repository": { "type": "git", "url": "http://github.com/grafana/grafana.git" }, "devDependencies": { "angular2": "2.0.0-beta.12", + "zone.js": "^0.6.6", "autoprefixer": "^6.3.3", "es6-promise": "^3.0.2", "es6-shim": "^0.35.0", @@ -31,7 +32,7 @@ "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^0.2.1", "grunt-git-describe": "~2.3.2", - "grunt-karma": "~0.12.1", + "grunt-karma": "~0.12.2", "grunt-ng-annotate": "^1.0.1", "grunt-notify": "^0.4.3", "grunt-postcss": "^0.8.0", @@ -42,7 +43,7 @@ "grunt-typescript": "^0.8.0", "grunt-usemin": "3.0.0", "jshint-stylish": "~2.1.0", - "karma": "~0.13.15", + "karma": "0.13.22", "karma-chrome-launcher": "~0.2.2", "karma-coverage": "0.5.3", "karma-coveralls": "1.1.2", @@ -67,7 +68,6 @@ }, "license": "Apache-2.0", "dependencies": { - "es5-shim": "^4.4.1", "grunt-jscs": "~1.5.x", "grunt-sass-lint": "^0.1.0", "grunt-sync": "^0.4.1", diff --git a/packaging/publish/publish.sh b/packaging/publish/publish.sh index 1d039ae1028..58021bc6ffa 100755 --- a/packaging/publish/publish.sh +++ b/packaging/publish/publish.sh @@ -1,17 +1,22 @@ #! /usr/bin/env bash -version=2.6.0 +deb_ver=3.0.0-beta11459429091 +rpm_ver=3.0.0-beta11459429091 -wget https://grafanarel.s3.amazonaws.com/builds/grafana_${version}_amd64.deb +#rpm_ver=3.0.0-1 -package_cloud push grafana/stable/debian/jessie grafana_${version}_amd64.deb -package_cloud push grafana/stable/debian/wheezy grafana_${version}_amd64.deb -package_cloud push grafana/testing/debian/jessie grafana_${version}_amd64.deb -package_cloud push grafana/testing/debian/wheezy grafana_${version}_amd64.deb +wget https://grafanarel.s3.amazonaws.com/builds/grafana_${deb_ver}_amd64.deb -wget https://grafanarel.s3.amazonaws.com/builds/grafana-${version}-1.x86_64.rpm +# package_cloud push grafana/stable/debian/jessie grafana_${deb_ver}_amd64.deb +# package_cloud push grafana/stable/debian/wheezy grafana_${deb_ver}_amd64.deb -package_cloud push grafana/testing/el/6 grafana-${version}-1.x86_64.rpm -package_cloud push grafana/testing/el/7 grafana-${version}-1.x86_64.rpm -package_cloud push grafana/stable/el/7 grafana-${version}-1.x86_64.rpm -package_cloud push grafana/stable/el/6 grafana-${version}-1.x86_64.rpm +package_cloud push grafana/testing/debian/jessie grafana_${deb_ver}_amd64.deb +package_cloud push grafana/testing/debian/wheezy grafana_${deb_ver}_amd64.deb + +wget https://grafanarel.s3.amazonaws.com/builds/grafana-${rpm_ver}.x86_64.rpm + +package_cloud push grafana/testing/el/6 grafana-${rpm_ver}.x86_64.rpm +package_cloud push grafana/testing/el/7 grafana-${rpm_ver}.x86_64.rpm + +# package_cloud push grafana/stable/el/7 grafana-${version}-1.x86_64.rpm +# package_cloud push grafana/stable/el/6 grafana-${version}-1.x86_64.rpm diff --git a/pkg/api/api.go b/pkg/api/api.go index 23a65c6a972..85f1e2474c3 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -29,6 +29,7 @@ func Register(r *macaron.Macaron) { // authed views r.Get("/profile/", reqSignedIn, Index) + r.Get("/profile/password", reqSignedIn, Index) r.Get("/org/", reqSignedIn, Index) r.Get("/org/new", reqSignedIn, Index) r.Get("/datasources/", reqSignedIn, Index) @@ -96,10 +97,15 @@ func Register(r *macaron.Macaron) { r.Put("/", bind(m.UpdateUserCommand{}), wrap(UpdateSignedInUser)) r.Post("/using/:id", wrap(UserSetUsingOrg)) r.Get("/orgs", wrap(GetSignedInUserOrgList)) + r.Post("/stars/dashboard/:id", wrap(StarDashboard)) r.Delete("/stars/dashboard/:id", wrap(UnstarDashboard)) + r.Put("/password", bind(m.ChangeUserPasswordCommand{}), wrap(ChangeUserPassword)) r.Get("/quotas", wrap(GetUserQuotas)) + + r.Get("/preferences", wrap(GetUserPreferences)) + r.Put("/preferences", bind(dtos.UpdatePrefsCmd{}), wrap(UpdateUserPreferences)) }) // users (admin permission required) @@ -130,6 +136,9 @@ func Register(r *macaron.Macaron) { r.Post("/invites", quota("user"), bind(dtos.AddInviteForm{}), wrap(AddOrgInvite)) r.Patch("/invites/:code/revoke", wrap(RevokeInvite)) + // prefs + r.Get("/preferences", wrap(GetOrgPreferences)) + r.Put("/preferences", bind(dtos.UpdatePrefsCmd{}), wrap(UpdateOrgPreferences)) }, reqOrgAdmin) // create new org @@ -164,6 +173,11 @@ func Register(r *macaron.Macaron) { r.Delete("/:id", wrap(DeleteApiKey)) }, reqOrgAdmin) + // Preferences + r.Group("/preferences", func() { + r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard)) + }) + // Data sources r.Group("/datasources", func() { r.Get("/", GetDataSources) diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 22f9e1e22a1..b55a1377bd8 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -159,6 +159,24 @@ func canEditDashboard(role m.RoleType) bool { } func GetHomeDashboard(c *middleware.Context) { + prefsQuery := m.GetPreferencesWithDefaultsQuery{OrgId: c.OrgId, UserId: c.UserId} + if err := bus.Dispatch(&prefsQuery); err != nil { + c.JsonApiErr(500, "Failed to get preferences", err) + } + + if prefsQuery.Result.HomeDashboardId != 0 { + slugQuery := m.GetDashboardSlugByIdQuery{Id: prefsQuery.Result.HomeDashboardId} + err := bus.Dispatch(&slugQuery) + if err != nil { + c.JsonApiErr(500, "Failed to get slug from database", err) + return + } + + dashRedirect := dtos.DashboardRedirect{RedirectUri: "db/" + slugQuery.Result} + c.JSON(200, &dashRedirect) + return + } + filePath := path.Join(setting.StaticRootPath, "dashboards/home.json") file, err := os.Open(filePath) if err != nil { diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index 8c1f85c9bd1..8db36be2140 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -33,6 +33,7 @@ type CurrentUser struct { OrgRole m.RoleType `json:"orgRole"` IsGrafanaAdmin bool `json:"isGrafanaAdmin"` GravatarUrl string `json:"gravatarUrl"` + Timezone string `json:"timezone"` } type DashboardMeta struct { @@ -57,6 +58,10 @@ type DashboardFullWithMeta struct { Dashboard *simplejson.Json `json:"dashboard"` } +type DashboardRedirect struct { + RedirectUri string `json:"redirectUri"` +} + type DataSource struct { Id int64 `json:"id"` OrgId int64 `json:"orgId"` diff --git a/pkg/api/dtos/prefs.go b/pkg/api/dtos/prefs.go new file mode 100644 index 00000000000..97e20bb4011 --- /dev/null +++ b/pkg/api/dtos/prefs.go @@ -0,0 +1,13 @@ +package dtos + +type Prefs struct { + Theme string `json:"theme"` + HomeDashboardId int64 `json:"homeDashboardId"` + Timezone string `json:"timezone"` +} + +type UpdatePrefsCmd struct { + Theme string `json:"theme"` + HomeDashboardId int64 `json:"homeDashboardId"` + Timezone string `json:"timezone"` +} diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index c84d7faccff..f23f416b47a 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -59,7 +59,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro defaultDatasource = ds.Name } - if len(ds.JsonData.MustMap()) > 0 { + if ds.JsonData != nil { dsMap["jsonData"] = ds.JsonData } diff --git a/pkg/api/index.go b/pkg/api/index.go index a376f9504a4..575ea35cfaf 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -2,6 +2,7 @@ package api import ( "github.com/grafana/grafana/pkg/api/dtos" + "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/middleware" m "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/plugins" @@ -14,6 +15,12 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { return nil, err } + prefsQuery := m.GetPreferencesWithDefaultsQuery{OrgId: c.OrgId, UserId: c.UserId} + if err := bus.Dispatch(&prefsQuery); err != nil { + return nil, err + } + prefs := prefsQuery.Result + var data = dtos.IndexViewData{ User: &dtos.CurrentUser{ Id: c.UserId, @@ -21,12 +28,13 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { Login: c.Login, Email: c.Email, Name: c.Name, - LightTheme: c.Theme == "light", OrgId: c.OrgId, OrgName: c.OrgName, OrgRole: c.OrgRole, GravatarUrl: dtos.GetGravatarUrl(c.Email), IsGrafanaAdmin: c.IsGrafanaAdmin, + LightTheme: prefs.Theme == "light", + Timezone: prefs.Timezone, }, Settings: settings, AppUrl: setting.AppUrl, diff --git a/pkg/api/preferences.go b/pkg/api/preferences.go new file mode 100644 index 00000000000..795b8994470 --- /dev/null +++ b/pkg/api/preferences.go @@ -0,0 +1,73 @@ +package api + +import ( + "github.com/grafana/grafana/pkg/api/dtos" + "github.com/grafana/grafana/pkg/bus" + "github.com/grafana/grafana/pkg/middleware" + m "github.com/grafana/grafana/pkg/models" +) + +// POST /api/preferences/set-home-dash +func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Response { + + cmd.UserId = c.UserId + cmd.OrgId = c.OrgId + + if err := bus.Dispatch(&cmd); err != nil { + return ApiError(500, "Failed to set home dashboard", err) + } + + return ApiSuccess("Home dashboard set") +} + +// GET /api/user/preferences +func GetUserPreferences(c *middleware.Context) Response { + return getPreferencesFor(c.OrgId, c.UserId) +} + +func getPreferencesFor(orgId int64, userId int64) Response { + prefsQuery := m.GetPreferencesQuery{UserId: userId, OrgId: orgId} + + if err := bus.Dispatch(&prefsQuery); err != nil { + return ApiError(500, "Failed to get preferences", err) + } + + dto := dtos.Prefs{ + Theme: prefsQuery.Result.Theme, + HomeDashboardId: prefsQuery.Result.HomeDashboardId, + Timezone: prefsQuery.Result.Timezone, + } + + return Json(200, &dto) +} + +// PUT /api/user/preferences +func UpdateUserPreferences(c *middleware.Context, dtoCmd dtos.UpdatePrefsCmd) Response { + return updatePreferencesFor(c.OrgId, c.UserId, &dtoCmd) +} + +func updatePreferencesFor(orgId int64, userId int64, dtoCmd *dtos.UpdatePrefsCmd) Response { + saveCmd := m.SavePreferencesCommand{ + UserId: userId, + OrgId: orgId, + Theme: dtoCmd.Theme, + Timezone: dtoCmd.Timezone, + HomeDashboardId: dtoCmd.HomeDashboardId, + } + + if err := bus.Dispatch(&saveCmd); err != nil { + return ApiError(500, "Failed to save preferences", err) + } + + return ApiSuccess("Preferences updated") +} + +// GET /api/org/preferences +func GetOrgPreferences(c *middleware.Context) Response { + return getPreferencesFor(c.OrgId, 0) +} + +// PUT /api/org/preferences +func UpdateOrgPreferences(c *middleware.Context, dtoCmd dtos.UpdatePrefsCmd) Response { + return updatePreferencesFor(c.OrgId, 0, &dtoCmd) +} diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index 6243c729624..6b19224f934 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -148,3 +148,8 @@ type GetDashboardsQuery struct { DashboardIds []int64 Result *[]Dashboard } + +type GetDashboardSlugByIdQuery struct { + Id int64 + Result string +} diff --git a/pkg/models/preferences.go b/pkg/models/preferences.go new file mode 100644 index 00000000000..4c77bc96d4d --- /dev/null +++ b/pkg/models/preferences.go @@ -0,0 +1,53 @@ +package models + +import ( + "errors" + "time" +) + +// Typed errors +var ( + ErrPreferencesNotFound = errors.New("Preferences not found") +) + +type Preferences struct { + Id int64 + OrgId int64 + UserId int64 + Version int + HomeDashboardId int64 + Timezone string + Theme string + Created time.Time + Updated time.Time +} + +// --------------------- +// QUERIES + +type GetPreferencesQuery struct { + Id int64 + OrgId int64 + UserId int64 + + Result *Preferences +} + +type GetPreferencesWithDefaultsQuery struct { + Id int64 + OrgId int64 + UserId int64 + + Result *Preferences +} + +// --------------------- +// COMMANDS +type SavePreferencesCommand struct { + UserId int64 + OrgId int64 + + HomeDashboardId int64 `json:"homeDashboardId"` + Timezone string `json:"timezone"` + Theme string `json:"theme"` +} diff --git a/pkg/models/user.go b/pkg/models/user.go index 2842bad490d..a231156b7b0 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -136,7 +136,6 @@ type SignedInUser struct { Login string Name string Email string - Theme string ApiKeyId int64 IsGrafanaAdmin bool } diff --git a/pkg/services/sqlstore/dashboard.go b/pkg/services/sqlstore/dashboard.go index 396d507cfd2..a64094cb65e 100644 --- a/pkg/services/sqlstore/dashboard.go +++ b/pkg/services/sqlstore/dashboard.go @@ -18,6 +18,7 @@ func init() { bus.AddHandler("sql", DeleteDashboard) bus.AddHandler("sql", SearchDashboards) bus.AddHandler("sql", GetDashboardTags) + bus.AddHandler("sql", GetDashboardSlugById) } func SaveDashboard(cmd *m.SaveDashboardCommand) error { @@ -255,3 +256,23 @@ func GetDashboards(query *m.GetDashboardsQuery) error { return nil } + +type DashboardSlugDTO struct { + Slug string +} + +func GetDashboardSlugById(query *m.GetDashboardSlugByIdQuery) error { + var rawSql = `SELECT slug from dashboard WHERE Id=?` + var slug = DashboardSlugDTO{} + + exists, err := x.Sql(rawSql, query.Id).Get(&slug) + + if err != nil { + return err + } else if exists == false { + return m.ErrDashboardNotFound + } + + query.Result = slug.Slug + return nil +} diff --git a/pkg/services/sqlstore/migrations/preferences_mig.go b/pkg/services/sqlstore/migrations/preferences_mig.go index 0ce01857b75..6425c3735bb 100644 --- a/pkg/services/sqlstore/migrations/preferences_mig.go +++ b/pkg/services/sqlstore/migrations/preferences_mig.go @@ -4,17 +4,27 @@ import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" func addPreferencesMigrations(mg *Migrator) { - preferencesV1 := Table{ + mg.AddMigration("drop preferences table v2", NewDropTableMigration("preferences")) + + preferencesV2 := Table{ Name: "preferences", Columns: []*Column{ {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, - {Name: "pref_id", Type: DB_Int, Nullable: false}, - {Name: "pref_type", Type: DB_NVarchar, Length: 255, Nullable: false}, - {Name: "pref_data", Type: DB_Text, Nullable: false}, + {Name: "org_id", Type: DB_Int, Nullable: true}, + {Name: "user_id", Type: DB_NVarchar, Length: 255, Nullable: true}, + {Name: "version", Type: DB_Int, Nullable: false}, + {Name: "home_dashboard_id", Type: DB_BigInt, Nullable: true}, + {Name: "timezone", Type: DB_NVarchar, Length: 50, Nullable: true}, + {Name: "theme", Type: DB_NVarchar, Length: 20, Nullable: true}, + {Name: "created", Type: DB_DateTime, Nullable: false}, + {Name: "updated", Type: DB_DateTime, Nullable: false}, + }, + Indices: []*Index{ + {Cols: []string{"org_id"}}, + {Cols: []string{"user_id"}}, }, } // create table - mg.AddMigration("create preferences table v1", NewAddTableMigration(preferencesV1)) - + mg.AddMigration("create preferences table v2", NewAddTableMigration(preferencesV2)) } diff --git a/pkg/services/sqlstore/preferences.go b/pkg/services/sqlstore/preferences.go new file mode 100644 index 00000000000..d120c485ed3 --- /dev/null +++ b/pkg/services/sqlstore/preferences.go @@ -0,0 +1,96 @@ +package sqlstore + +import ( + "time" + + "github.com/grafana/grafana/pkg/bus" + m "github.com/grafana/grafana/pkg/models" +) + +func init() { + bus.AddHandler("sql", GetPreferences) + bus.AddHandler("sql", GetPreferencesWithDefaults) + bus.AddHandler("sql", SavePreferences) +} + +func GetPreferencesWithDefaults(query *m.GetPreferencesWithDefaultsQuery) error { + + prefs := make([]*m.Preferences, 0) + filter := "(org_id=? AND user_id=?) OR (org_id=? AND user_id=0)" + err := x.Where(filter, query.OrgId, query.UserId, query.OrgId). + OrderBy("user_id ASC"). + Find(&prefs) + + if err != nil { + return err + } + + res := &m.Preferences{ + Theme: "dark", + Timezone: "browser", + HomeDashboardId: 0, + } + + for _, p := range prefs { + if p.Theme != "" { + res.Theme = p.Theme + } + if p.Timezone != "" { + res.Timezone = p.Timezone + } + if p.HomeDashboardId != 0 { + res.HomeDashboardId = p.HomeDashboardId + } + } + + query.Result = res + return nil +} + +func GetPreferences(query *m.GetPreferencesQuery) error { + + var prefs m.Preferences + exists, err := x.Where("org_id=? AND user_id=?", query.OrgId, query.UserId).Get(&prefs) + + if err != nil { + return err + } + + if exists { + query.Result = &prefs + } else { + query.Result = new(m.Preferences) + } + + return nil +} + +func SavePreferences(cmd *m.SavePreferencesCommand) error { + return inTransaction2(func(sess *session) error { + + var prefs m.Preferences + exists, err := sess.Where("org_id=? AND user_id=?", cmd.OrgId, cmd.UserId).Get(&prefs) + + if !exists { + prefs = m.Preferences{ + UserId: cmd.UserId, + OrgId: cmd.OrgId, + HomeDashboardId: cmd.HomeDashboardId, + Timezone: cmd.Timezone, + Theme: cmd.Theme, + Created: time.Now(), + Updated: time.Now(), + } + _, err = sess.Insert(&prefs) + return err + } else { + prefs.HomeDashboardId = cmd.HomeDashboardId + prefs.Timezone = cmd.Timezone + prefs.Theme = cmd.Theme + prefs.Updated = time.Now() + prefs.Version += 1 + _, err := sess.Id(prefs.Id).AllCols().Update(&prefs) + return err + } + }) +} diff --git a/pkg/services/sqlstore/user.go b/pkg/services/sqlstore/user.go index 96b8c24b8fc..623e85ec472 100644 --- a/pkg/services/sqlstore/user.go +++ b/pkg/services/sqlstore/user.go @@ -273,7 +273,6 @@ func GetSignedInUser(query *m.GetSignedInUserQuery) error { u.email as email, u.login as login, u.name as name, - u.theme as theme, org.name as org_name, org_user.role as org_role, org.id as org_id diff --git a/public/app/core/components/dashboard_selector.ts b/public/app/core/components/dashboard_selector.ts new file mode 100644 index 00000000000..913a43911fa --- /dev/null +++ b/public/app/core/components/dashboard_selector.ts @@ -0,0 +1,44 @@ +/// + +import config from 'app/core/config'; +import _ from 'lodash'; +import $ from 'jquery'; +import coreModule from 'app/core/core_module'; + +var template = ` + +`; + +export class DashboardSelectorCtrl { + model: any; + options: any; + + /** @ngInject */ + constructor(private backendSrv) { + } + + $onInit() { + this.options = [{value: 0, text: 'Default'}]; + + return this.backendSrv.search({starred: true}).then(res => { + res.forEach(dash => { + this.options.push({value: dash.id, text: dash.title}); + }); + }); + } +} + +export function dashboardSelector() { + return { + restrict: 'E', + controller: DashboardSelectorCtrl, + bindToController: true, + controllerAs: 'ctrl', + template: template, + scope: { + model: '=' + } + }; +} + +coreModule.directive('dashboardSelector', dashboardSelector); diff --git a/public/app/core/core.ts b/public/app/core/core.ts index 279f54d4e45..abebb5ce560 100644 --- a/public/app/core/core.ts +++ b/public/app/core/core.ts @@ -32,6 +32,7 @@ import {liveSrv} from './live/live_srv'; import {Emitter} from './utils/emitter'; import {layoutSelector} from './components/layout_selector/layout_selector'; import {switchDirective} from './components/switch'; +import {dashboardSelector} from './components/dashboard_selector'; import 'app/core/controllers/all'; import 'app/core/services/all'; import 'app/core/routes/routes'; @@ -54,4 +55,5 @@ export { infoPopover, Emitter, appEvents, + dashboardSelector, }; diff --git a/public/app/core/routes/dashboard_loaders.js b/public/app/core/routes/dashboard_loaders.js index 8e2157ad84b..61cdf32c128 100644 --- a/public/app/core/routes/dashboard_loaders.js +++ b/public/app/core/routes/dashboard_loaders.js @@ -4,13 +4,17 @@ define([ function (coreModule) { "use strict"; - coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv) { + coreModule.default.controller('LoadDashboardCtrl', function($scope, $routeParams, dashboardLoaderSrv, backendSrv, $location) { if (!$routeParams.slug) { - backendSrv.get('/api/dashboards/home').then(function(result) { - var meta = result.meta; - meta.canSave = meta.canShare = meta.canStar = false; - $scope.initDashboard(result, $scope); + backendSrv.get('/api/dashboards/home').then(function(homeDash) { + if (homeDash.redirectUri) { + $location.path('dashboard/' + homeDash.redirectUri); + } else { + var meta = homeDash.meta; + meta.canSave = meta.canShare = meta.canStar = false; + $scope.initDashboard(homeDash, $scope); + } }); return; } diff --git a/public/app/core/routes/routes.ts b/public/app/core/routes/routes.ts index 92cf32448a1..1608a772e87 100644 --- a/public/app/core/routes/routes.ts +++ b/public/app/core/routes/routes.ts @@ -88,16 +88,20 @@ function setupAngularRoutes($routeProvider, $locationProvider) { resolve: loadOrgBundle, }) .when('/profile', { - templateUrl: 'public/app/features/profile/partials/profile.html', + templateUrl: 'public/app/features/org/partials/profile.html', controller : 'ProfileCtrl', + controllerAs: 'ctrl', + resolve: loadOrgBundle, }) .when('/profile/password', { - templateUrl: 'public/app/features/profile/partials/password.html', + templateUrl: 'public/app/features/org/partials/change_password.html', controller : 'ChangePasswordCtrl', + resolve: loadOrgBundle, }) .when('/profile/select-org', { - templateUrl: 'public/app/features/profile/partials/select_org.html', + templateUrl: 'public/app/features/org/partials/select_org.html', controller : 'SelectOrgCtrl', + resolve: loadOrgBundle, }) // ADMIN .when('/admin', { diff --git a/public/app/core/services/context_srv.js b/public/app/core/services/context_srv.js deleted file mode 100644 index b4a133afea3..00000000000 --- a/public/app/core/services/context_srv.js +++ /dev/null @@ -1,47 +0,0 @@ -define([ - 'angular', - 'lodash', - '../core_module', - 'app/core/store', - 'app/core/config', -], -function (angular, _, coreModule, store, config) { - 'use strict'; - - coreModule.default.service('contextSrv', function() { - - function User() { - if (config.bootData.user) { - _.extend(this, config.bootData.user); - } - } - - this.hasRole = function(role) { - return this.user.orgRole === role; - }; - - this.setPinnedState = function(val) { - this.pinned = val; - store.set('grafana.sidemenu.pinned', val); - }; - - this.toggleSideMenu = function() { - this.sidemenu = !this.sidemenu; - if (!this.sidemenu) { - this.setPinnedState(false); - } - }; - - this.pinned = store.getBool('grafana.sidemenu.pinned', false); - if (this.pinned) { - this.sidemenu = true; - } - - this.version = config.buildInfo.version; - this.lightTheme = false; - this.user = new User(); - this.isSignedIn = this.user.isSignedIn; - this.isGrafanaAdmin = this.user.isGrafanaAdmin; - this.isEditor = this.hasRole('Editor') || this.hasRole('Admin'); - }); -}); diff --git a/public/app/core/services/context_srv.ts b/public/app/core/services/context_srv.ts new file mode 100644 index 00000000000..ad670f68a32 --- /dev/null +++ b/public/app/core/services/context_srv.ts @@ -0,0 +1,73 @@ +/// + +import config from 'app/core/config'; +import _ from 'lodash'; +import coreModule from 'app/core/core_module'; +import store from 'app/core/store'; + +export class User { + isGrafanaAdmin: any; + isSignedIn: any; + orgRole: any; + + constructor() { + if (config.bootData.user) { + _.extend(this, config.bootData.user); + } + } +} + +export class ContextSrv { + pinned: any; + version: any; + user: User; + isSignedIn: any; + isGrafanaAdmin: any; + isEditor: any; + sidemenu: any; + lightTheme: any; + + constructor() { + this.pinned = store.getBool('grafana.sidemenu.pinned', false); + if (this.pinned) { + this.sidemenu = true; + } + + if (!config.buildInfo) { + config.buildInfo = {}; + } + if (!config.bootData) { + config.bootData = {user: {}, settings: {}}; + } + + this.version = config.buildInfo.version; + this.lightTheme = false; + this.user = new User(); + this.isSignedIn = this.user.isSignedIn; + this.isGrafanaAdmin = this.user.isGrafanaAdmin; + this.isEditor = this.hasRole('Editor') || this.hasRole('Admin'); + } + + hasRole(role) { + return this.user.orgRole === role; + } + + setPinnedState(val) { + this.pinned = val; + store.set('grafana.sidemenu.pinned', val); + } + + toggleSideMenu() { + this.sidemenu = !this.sidemenu; + if (!this.sidemenu) { + this.setPinnedState(false); + } + } +} + +var contextSrv = new ContextSrv(); +export {contextSrv}; + +coreModule.factory('contextSrv', function() { + return contextSrv; +}); diff --git a/public/app/features/all.js b/public/app/features/all.js index c110bcff7cd..43d9f33f190 100644 --- a/public/app/features/all.js +++ b/public/app/features/all.js @@ -7,8 +7,5 @@ define([ './playlist/all', './snapshot/all', './panel/all', - './profile/profileCtrl', - './profile/changePasswordCtrl', - './profile/selectOrgCtrl', './styleguide/styleguide', ], function () {}); diff --git a/public/app/features/dashboard/dashboardCtrl.js b/public/app/features/dashboard/dashboardCtrl.js index ea0d91019b8..b6702631155 100644 --- a/public/app/features/dashboard/dashboardCtrl.js +++ b/public/app/features/dashboard/dashboardCtrl.js @@ -134,6 +134,10 @@ function (angular, $, config, moment) { }); }; + $scope.timezoneChanged = function() { + $rootScope.$broadcast("refresh"); + }; + $scope.formatDate = function(date) { return moment(date).format('MMM Do YYYY, h:mm:ss a'); }; diff --git a/public/app/features/dashboard/dashboardSrv.js b/public/app/features/dashboard/dashboardSrv.js index 00610624867..ed119f6e23f 100644 --- a/public/app/features/dashboard/dashboardSrv.js +++ b/public/app/features/dashboard/dashboardSrv.js @@ -9,7 +9,7 @@ function (angular, $, _, moment) { var module = angular.module('grafana.services'); - module.factory('dashboardSrv', function() { + module.factory('dashboardSrv', function(contextSrv) { function DashboardModel (data, meta) { if (!data) { @@ -25,7 +25,7 @@ function (angular, $, _, moment) { this.originalTitle = this.title; this.tags = data.tags || []; this.style = data.style || "dark"; - this.timezone = data.timezone || 'browser'; + this.timezone = data.timezone || ''; this.editable = data.editable !== false; this.hideControls = data.hideControls || false; this.sharedCrosshair = data.sharedCrosshair || false; @@ -208,6 +208,14 @@ function (angular, $, _, moment) { }); }; + p.isTimezoneUtc = function() { + return this.getTimezone() === 'utc'; + }; + + p.getTimezone = function() { + return this.timezone ? this.timezone : contextSrv.user.timezone; + }; + p._updateSchema = function(old) { var i, j, k; var oldVersion = this.schemaVersion; @@ -401,11 +409,18 @@ function (angular, $, _, moment) { }); } - if (oldVersion < 11) { + if (oldVersion < 12) { // update template variables _.each(this.templating.list, function(templateVariable) { if (templateVariable.refresh) { templateVariable.refresh = 1; } if (!templateVariable.refresh) { templateVariable.refresh = 0; } + if (templateVariable.hideVariable) { + templateVariable.hide = 2; + } else if (templateVariable.hideLabel) { + templateVariable.hide = 1; + } else { + templateVariable.hide = 0; + } }); } diff --git a/public/app/features/dashboard/dashnav/dashnav.html b/public/app/features/dashboard/dashnav/dashnav.html index 19112f77a43..aec626bfe2a 100644 --- a/public/app/features/dashboard/dashnav/dashnav.html +++ b/public/app/features/dashboard/dashnav/dashnav.html @@ -48,6 +48,7 @@
  • View JSON
  • Make Editable
  • Save As...
  • +
  • Set As Home
  • Delete dashboard
  • diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 33b1a247235..2a2287613ae 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -34,7 +34,7 @@
    - +
    @@ -62,66 +62,67 @@ - -
    -
    Rows settings
    +
    -
    -
    -
    - Title - -
    - +
    +
    Rows settings
    -
    - - - -
    -
    -
    -
    +
    +
    +
    + Title + +
    + -
    - -
    +
    + + + +
    +
    +
    + -
    - -
    +
    + +
    -
    -
    Dashboard info
    -
    -
    - Last updated at: - {{formatDate(dashboardMeta.updated)}} -
    -
    - Last updated by: - {{dashboardMeta.updatedBy}}  -
    -
    - Created at: - {{formatDate(dashboardMeta.created)}}  -
    -
    - Created by: - {{dashboardMeta.createdBy}}  -
    -
    - Current version: - {{dashboardMeta.version}}  -
    -
    -
    +
    + +
    + +
    +
    Dashboard info
    +
    +
    + Last updated at: + {{formatDate(dashboardMeta.updated)}} +
    +
    + Last updated by: + {{dashboardMeta.updatedBy}}  +
    +
    + Created at: + {{formatDate(dashboardMeta.created)}}  +
    +
    + Created by: + {{dashboardMeta.createdBy}}  +
    +
    + Current version: + {{dashboardMeta.version}}  +
    +
    +
    diff --git a/public/app/features/dashboard/submenu/submenu.html b/public/app/features/dashboard/submenu/submenu.html index 21a9744b359..464d8c4cecf 100644 --- a/public/app/features/dashboard/submenu/submenu.html +++ b/public/app/features/dashboard/submenu/submenu.html @@ -1,7 +1,7 @@ +

    Address

    diff --git a/public/app/features/profile/partials/profile.html b/public/app/features/org/partials/profile.html similarity index 66% rename from public/app/features/profile/partials/profile.html rename to public/app/features/org/partials/profile.html index 042344eeac6..811891ae317 100644 --- a/public/app/features/profile/partials/profile.html +++ b/public/app/features/org/partials/profile.html @@ -6,31 +6,28 @@

    Profile

    -
    -

    Preferences

    + +

    Information

    - Name - + Name +
    - Email - + Email +
    - Username - + Username +
    -
    - UI Theme - -
    -
    - +
    + +

    Password

    Change Password @@ -47,7 +44,7 @@ - + {{org.name}} {{org.role}} diff --git a/public/app/features/profile/partials/select_org.html b/public/app/features/org/partials/select_org.html similarity index 100% rename from public/app/features/profile/partials/select_org.html rename to public/app/features/org/partials/select_org.html diff --git a/public/app/features/org/prefs_control.ts b/public/app/features/org/prefs_control.ts new file mode 100644 index 00000000000..53704d5e390 --- /dev/null +++ b/public/app/features/org/prefs_control.ts @@ -0,0 +1,98 @@ +/// + +import config from 'app/core/config'; +import _ from 'lodash'; +import coreModule from 'app/core/core_module'; + +export class PrefsControlCtrl { + prefs: any; + oldTheme: any; + prefsForm: any; + mode: string; + + timezones: any = [ + {value: '', text: 'Default'}, + {value: 'browser', text: 'Local browser time'}, + {value: 'utc', text: 'UTC'}, + ]; + themes: any = [ + {value: '', text: 'Default'}, + {value: 'dark', text: 'Dark'}, + {value: 'light', text: 'Light'}, + ]; + + /** @ngInject **/ + constructor(private backendSrv, private $location) { + } + + $onInit() { + return this.backendSrv.get(`/api/${this.mode}/preferences`).then(prefs => { + this.prefs = prefs; + this.oldTheme = prefs.theme; + }); + } + + updatePrefs() { + if (!this.prefsForm.$valid) { return; } + + var cmd = { + theme: this.prefs.theme, + timezone: this.prefs.timezone, + homeDashboardId: this.prefs.homeDashboardId + }; + + this.backendSrv.put(`/api/${this.mode}/preferences`, cmd).then(() => { + window.location.href = config.appSubUrl + this.$location.path(); + }); + } + +} + +var template = ` +
    +

    Preferences

    + +
    + UI Theme +
    + +
    +
    + +
    + Home Dashboard + + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +`; + +export function prefsControlDirective() { + return { + restrict: 'E', + controller: PrefsControlCtrl, + bindToController: true, + controllerAs: 'ctrl', + template: template, + scope: { + mode: "@" + } + }; +} + +coreModule.directive('prefsControl', prefsControlDirective); + + diff --git a/public/app/features/org/profile_ctrl.ts b/public/app/features/org/profile_ctrl.ts new file mode 100644 index 00000000000..65bff1f6c12 --- /dev/null +++ b/public/app/features/org/profile_ctrl.ts @@ -0,0 +1,51 @@ +/// + +import config from 'app/core/config'; +import {coreModule} from 'app/core/core'; +import _ from 'lodash'; + +export class ProfileCtrl { + user: any; + old_theme: any; + orgs: any; + userForm: any; + + /** @ngInject **/ + constructor(private backendSrv, private contextSrv, private $location) { + this.getUser(); + this.getUserOrgs(); + } + + getUser() { + this.backendSrv.get('/api/user').then(user => { + this.user = user; + this.user.theme = user.theme || 'dark'; + }); + } + + getUserOrgs() { + this.backendSrv.get('/api/user/orgs').then(orgs => { + this.orgs = orgs; + }); + } + + setUsingOrg(org) { + this.backendSrv.post('/api/user/using/' + org.orgId).then(() => { + window.location.href = config.appSubUrl + '/profile'; + }); + } + + update() { + if (!this.userForm.$valid) { return; } + + this.backendSrv.put('/api/user/', this.user).then(() => { + this.contextSrv.user.name = this.user.name || this.user.login; + if (this.old_theme !== this.user.theme) { + window.location.href = config.appSubUrl + this.$location.path(); + } + }); + } + +} + +coreModule.controller('ProfileCtrl', ProfileCtrl); diff --git a/public/app/features/profile/selectOrgCtrl.js b/public/app/features/org/select_org_ctrl.js similarity index 100% rename from public/app/features/profile/selectOrgCtrl.js rename to public/app/features/org/select_org_ctrl.js diff --git a/public/app/features/panel/metrics_panel_ctrl.ts b/public/app/features/panel/metrics_panel_ctrl.ts index 52e9c64981c..c1f408e9374 100644 --- a/public/app/features/panel/metrics_panel_ctrl.ts +++ b/public/app/features/panel/metrics_panel_ctrl.ts @@ -165,6 +165,7 @@ class MetricsPanelCtrl extends PanelCtrl { issueQueries(datasource) { this.updateTimeRange(); + this.datasource = datasource; if (!this.panel.targets || this.panel.targets.length === 0) { return this.$q.when([]); @@ -251,7 +252,6 @@ class MetricsPanelCtrl extends PanelCtrl { addDataQuery(datasource) { var target = { - datasource: datasource ? datasource.name : undefined }; this.panel.targets.push(target); } diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index 2821164bb10..ff2e7fde1bd 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -45,7 +45,7 @@ export class PanelCtrl { } $scope.$on("refresh", () => this.refresh()); - $scope.$on("render", () => this.calculatePanelHeight()); + $scope.$on("render", () => this.render()); } init() { @@ -149,6 +149,7 @@ export class PanelCtrl { return; } + this.calculatePanelHeight(); this.events.emit('render', payload); } diff --git a/public/app/features/plugins/import_list/import_list.ts b/public/app/features/plugins/import_list/import_list.ts index 8eb726b81c0..6c82d3faa92 100644 --- a/public/app/features/plugins/import_list/import_list.ts +++ b/public/app/features/plugins/import_list/import_list.ts @@ -10,6 +10,7 @@ export class DashImportListCtrl { plugin: any; datasource: any; + /** @ngInject */ constructor($scope, private $http, private backendSrv, private $rootScope) { this.dashboards = []; diff --git a/public/app/features/profile/profileCtrl.js b/public/app/features/profile/profileCtrl.js deleted file mode 100644 index bae85a3d0c4..00000000000 --- a/public/app/features/profile/profileCtrl.js +++ /dev/null @@ -1,51 +0,0 @@ -define([ - 'angular', - 'app/core/config', -], -function (angular, config) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('ProfileCtrl', function($scope, backendSrv, contextSrv, $location) { - - $scope.init = function() { - $scope.getUser(); - $scope.getUserOrgs(); - }; - - $scope.getUser = function() { - backendSrv.get('/api/user').then(function(user) { - $scope.user = user; - $scope.user.theme = user.theme || 'dark'; - $scope.old_theme = $scope.user.theme; - }); - }; - - $scope.getUserOrgs = function() { - backendSrv.get('/api/user/orgs').then(function(orgs) { - $scope.orgs = orgs; - }); - }; - - $scope.setUsingOrg = function(org) { - backendSrv.post('/api/user/using/' + org.orgId).then(function() { - window.location.href = config.appSubUrl + '/profile'; - }); - }; - - $scope.update = function() { - if (!$scope.userForm.$valid) { return; } - - backendSrv.put('/api/user/', $scope.user).then(function() { - contextSrv.user.name = $scope.user.name || $scope.user.login; - if ($scope.old_theme !== $scope.user.theme) { - window.location.href = config.appSubUrl + $location.path(); - } - }); - }; - - $scope.init(); - - }); -}); diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index b2916e1bcc7..291915ee99f 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -14,6 +14,7 @@ function (angular, _) { datasource: null, refresh: 0, name: '', + hide: 0, options: [], includeAll: false, multi: false, @@ -25,6 +26,12 @@ function (angular, _) { {value: 2, text: "On Time Range Change"}, ]; + $scope.hideOptions = [ + {value: 0, text: ""}, + {value: 1, text: "Label"}, + {value: 2, text: "Variable"}, + ]; + $scope.init = function() { $scope.mode = 'list'; diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 7bd1fd0940f..d1cab90ac9d 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -74,32 +74,33 @@
    Variable
    -
    +
    Name - +
    Type -
    - +
    +
    -
    +
    Data source -
    - +
    +
    -
    +
    Label - +
    Hide - - +
    + +
    @@ -176,17 +177,22 @@
    -
    +
    Selection Options
    -
    - Multi-value - - Enables multiple values to be selected at the same time -
    -
    - Include All option - -
    + + + + +
    Custom all value diff --git a/public/app/plugins/datasource/cloudwatch/README.md b/public/app/plugins/datasource/cloudwatch/README.md new file mode 100644 index 00000000000..a1b7bf5cc50 --- /dev/null +++ b/public/app/plugins/datasource/cloudwatch/README.md @@ -0,0 +1,7 @@ +# CloudWatch Datasource - Native Plugin + +Grafana ships with **built in** support for CloudWatch. You just have to add it as a data source and you will be ready to build dashboards for you CloudWatch metrics. + +Read more about it here: + +[http://docs.grafana.org/datasources/cloudwatch/](http://docs.grafana.org/datasources/cloudwatch/) \ No newline at end of file diff --git a/public/app/plugins/datasource/elasticsearch/README.md b/public/app/plugins/datasource/elasticsearch/README.md new file mode 100644 index 00000000000..21978025eeb --- /dev/null +++ b/public/app/plugins/datasource/elasticsearch/README.md @@ -0,0 +1,7 @@ +# CloudWatch Datasource - Native Plugin + +Grafana ships with **advanced support** for Elasticsearch. You can do many types of simple or complex elasticsearch queries to visualize logs or metrics stored in Elasticsearch. You can also annotate your graphs with log events stored in Elasticsearch. + +Read more about it here: + +[http://docs.grafana.org/datasources/elasticsearch/](http://docs.grafana.org/datasources/elasticsearch/) \ No newline at end of file diff --git a/public/app/plugins/datasource/elasticsearch/bucket_agg.js b/public/app/plugins/datasource/elasticsearch/bucket_agg.js index 47d88a6ea3c..18e2f3cf3b1 100644 --- a/public/app/plugins/datasource/elasticsearch/bucket_agg.js +++ b/public/app/plugins/datasource/elasticsearch/bucket_agg.js @@ -77,7 +77,7 @@ function (angular, _, queryDef) { switch($scope.agg.type) { case 'terms': { settings.order = settings.order || "asc"; - settings.size = settings.size || "0"; + settings.size = settings.size || "10"; settings.orderBy = settings.orderBy || "_term"; if (settings.size !== '0') { diff --git a/public/app/plugins/datasource/grafana/README.md b/public/app/plugins/datasource/grafana/README.md new file mode 100644 index 00000000000..a8319c8dec5 --- /dev/null +++ b/public/app/plugins/datasource/grafana/README.md @@ -0,0 +1,3 @@ +# Grafana Fake Data Datasource - Native Plugin + +This is the built in Fake Data Datasource that is used before any datasources are set up in your Grafana installation. It means you can create a graph without any data and still get an idea of what it would look like. diff --git a/public/app/plugins/datasource/graphite/README.md b/public/app/plugins/datasource/graphite/README.md new file mode 100644 index 00000000000..c27c5789bca --- /dev/null +++ b/public/app/plugins/datasource/graphite/README.md @@ -0,0 +1,9 @@ +# Graphite Datasource - Native Plugin + +Grafana ships with **built in** support for Graphite (of course!). + +Grafana has an advanced Graphite query editor that lets you quickly navigate the metric space, add functions, change function parameters and much more. The editor can handle all types of graphite queries. It can even handle complex nested queries through the use of query references. + +Read more about it here: + +[http://docs.grafana.org/datasources/graphite/](http://docs.grafana.org/datasources/graphite/) \ No newline at end of file diff --git a/public/app/plugins/datasource/influxdb/README.md b/public/app/plugins/datasource/influxdb/README.md new file mode 100644 index 00000000000..45eaa51eb0f --- /dev/null +++ b/public/app/plugins/datasource/influxdb/README.md @@ -0,0 +1,13 @@ +# InfluxDB Datasource - Native Plugin + +Grafana ships with **built in** support for InfluxDB 0.9. + +There are currently two separate datasources for InfluxDB in Grafana: InfluxDB 0.8.x and InfluxDB 0.9.x. The API and capabilities of InfluxDB 0.9.x are completely different from InfluxDB 0.8.x which is why Grafana handles them as different data sources. + +This is the plugin for InfluxDB 0.9. It is rapidly evolving and we continue to track its API. + +InfluxDB 0.8 is no longer maintained by InfluxDB Inc, but we provide support as a convenience to existing users. You can find it [here](https://www.grafana.net/plugins/grafana-influxdb-08-datasource). + +Read more about InfluxDB here: + +[http://docs.grafana.org/datasources/influxdb/](http://docs.grafana.org/datasources/influxdb/) \ No newline at end of file diff --git a/public/app/plugins/datasource/influxdb/query_ctrl.ts b/public/app/plugins/datasource/influxdb/query_ctrl.ts index d59bbbbccd5..041e3c8a882 100644 --- a/public/app/plugins/datasource/influxdb/query_ctrl.ts +++ b/public/app/plugins/datasource/influxdb/query_ctrl.ts @@ -193,7 +193,7 @@ export class InfluxQueryCtrl extends QueryCtrl { if (addTemplateVars) { for (let variable of this.templateSrv.variables) { - segments.unshift(this.uiSegmentSrv.newSegment({ type: 'template', value: '/$' + variable.name + '$/', expandable: true })); + segments.unshift(this.uiSegmentSrv.newSegment({ type: 'template', value: '/^$' + variable.name + '$/', expandable: true })); } } diff --git a/public/app/plugins/datasource/influxdb/response_parser.ts b/public/app/plugins/datasource/influxdb/response_parser.ts index ae6f2cb75a9..2e33b398a88 100644 --- a/public/app/plugins/datasource/influxdb/response_parser.ts +++ b/public/app/plugins/datasource/influxdb/response_parser.ts @@ -15,7 +15,7 @@ export default class ResponseParser { var series = influxResults.series[0]; return _.map(series.values, (value) => { if (_.isArray(value)) { - if (query.indexOf('SHOW TAG VALUES') >= 0) { + if (query.toLowerCase().indexOf('show tag values') >= 0) { return { text: (value[1] || value[0]) }; } else { return { text: value[0] }; diff --git a/public/app/plugins/datasource/mixed/README.md b/public/app/plugins/datasource/mixed/README.md new file mode 100644 index 00000000000..b69bb626c15 --- /dev/null +++ b/public/app/plugins/datasource/mixed/README.md @@ -0,0 +1,3 @@ +# Mixed Datasource - Native Plugin + +This is a **built in** datasource that allows you to mix different datasource on the same graph! You can enable this by selecting the built in -- Mixed -- data source. When selected this will allow you to specify data source on a per query basis. This will, for example, allow you to plot metrics from different Graphite servers on the same Graph or plot data from Elasticsearch alongside data from Prometheus. Mixing different data sources on the same graph works for any data source, even custom ones. \ No newline at end of file diff --git a/public/app/plugins/datasource/opentsdb/README.md b/public/app/plugins/datasource/opentsdb/README.md new file mode 100644 index 00000000000..697ecd5c4dc --- /dev/null +++ b/public/app/plugins/datasource/opentsdb/README.md @@ -0,0 +1,7 @@ +# OpenTSDB Datasource - Native Plugin + +Grafana ships with **built in** support for OpenTSDB, a scalable, distributed time series database. + +Read more about it here: + +[http://docs.grafana.org/datasources/opentsdb/](http://docs.grafana.org/datasources/opentsdb/) \ No newline at end of file diff --git a/public/app/plugins/datasource/prometheus/README.md b/public/app/plugins/datasource/prometheus/README.md new file mode 100644 index 00000000000..5b188c3393c --- /dev/null +++ b/public/app/plugins/datasource/prometheus/README.md @@ -0,0 +1,7 @@ +# Prometheus Datasource - Native Plugin + +Grafana ships with **built in** support for Prometheus, the open-source service monitoring system and time series database. + +Read more about it here: + +[http://docs.grafana.org/datasources/prometheus/](http://docs.grafana.org/datasources/prometheus/) diff --git a/public/app/plugins/panel/dashlist/README.md b/public/app/plugins/panel/dashlist/README.md new file mode 100644 index 00000000000..55996b5aff4 --- /dev/null +++ b/public/app/plugins/panel/dashlist/README.md @@ -0,0 +1,9 @@ +# Dashlist Panel - Native Plugin + +This Dashlist panel is **included** with Grafana. + +The dashboard list panel allows you to display dynamic links to other dashboards. The list can be configured to use starred dashboards, a search query and/or dashboard tags. + +Read more about it here: + +[http://docs.grafana.org/reference/dashlist/](http://docs.grafana.org/reference/dashlist/) \ No newline at end of file diff --git a/public/app/plugins/panel/dashlist/module.ts b/public/app/plugins/panel/dashlist/module.ts index e199e0cfc6e..b619b7ea7d7 100644 --- a/public/app/plugins/panel/dashlist/module.ts +++ b/public/app/plugins/panel/dashlist/module.ts @@ -25,7 +25,7 @@ class DashListCtrl extends PanelCtrl { _.defaults(this.panel, panelDefaults); if (this.panel.tag) { - this.panel.tags = [$scope.panel.tag]; + this.panel.tags = [this.panel.tag]; delete this.panel.tag; } diff --git a/public/app/plugins/panel/graph/README.md b/public/app/plugins/panel/graph/README.md new file mode 100644 index 00000000000..2dc8682f0e3 --- /dev/null +++ b/public/app/plugins/panel/graph/README.md @@ -0,0 +1,7 @@ +# Graph Panel - Native Plugin + +The Graph is the main graph panel and is **included** with Grafana. It provides a very rich set of graphing options. + +Read more about it here: + +[http://docs.grafana.org/reference/graph/](http://docs.grafana.org/reference/graph/) \ No newline at end of file diff --git a/public/app/plugins/panel/graph/graph.js b/public/app/plugins/panel/graph/graph.js index 0443a294eed..4e948bf8e5b 100755 --- a/public/app/plugins/panel/graph/graph.js +++ b/public/app/plugins/panel/graph/graph.js @@ -279,7 +279,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) { var max = _.isUndefined(ctrl.range.to) ? null : ctrl.range.to.valueOf(); options.xaxis = { - timezone: dashboard.timezone, + timezone: dashboard.getTimezone(), show: panel['x-axis'], mode: "time", min: min, diff --git a/public/app/plugins/panel/graph/legend.js b/public/app/plugins/panel/graph/legend.js index 22bbb756b59..4cad3c16844 100644 --- a/public/app/plugins/panel/graph/legend.js +++ b/public/app/plugins/panel/graph/legend.js @@ -157,7 +157,7 @@ function (angular, _, $) { } var html = '
    '; html += '
    '; diff --git a/public/app/plugins/panel/graph/specs/graph_specs.ts b/public/app/plugins/panel/graph/specs/graph_specs.ts index 1a708696680..b9c9362e5de 100644 --- a/public/app/plugins/panel/graph/specs/graph_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_specs.ts @@ -53,7 +53,9 @@ describe('grafanaGraph', function() { }, renderingCompleted: sinon.spy(), hiddenSeries: {}, - dashboard: {timezone: 'browser'}, + dashboard: { + getTimezone: sinon.stub().returns('browser') + }, range: { from: moment([2015, 1, 1, 10]), to: moment([2015, 1, 1, 22]), diff --git a/public/app/plugins/panel/graph/tab_axes.html b/public/app/plugins/panel/graph/tab_axes.html index e7e35055d5c..81ab3deeb31 100644 --- a/public/app/plugins/panel/graph/tab_axes.html +++ b/public/app/plugins/panel/graph/tab_axes.html @@ -41,30 +41,32 @@
    X-Axis
    -
    -
    -
    Thresholds
    -
    -
    - - -
    -
    - -
    - -
    -
    -
    - - -
    -
    - -
    - -
    -
    -
    +
    +
    Thresholds
    +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    diff --git a/public/app/plugins/panel/singlestat/README.md b/public/app/plugins/panel/singlestat/README.md new file mode 100644 index 00000000000..42d72825c27 --- /dev/null +++ b/public/app/plugins/panel/singlestat/README.md @@ -0,0 +1,9 @@ +# Singlestat Panel - Native Plugin + +The Singlestat Panel is **included** with Grafana. + +The Singlestat Panel allows you to show the one main summary stat of a SINGLE series. It reduces the series into a single number (by looking at the max, min, average, or sum of values in the series). Singlestat also provides thresholds to color the stat or the Panel background. It can also translate the single number into a text value, and show a sparkline summary of the series. + +Read more about it here: + +[http://docs.grafana.org/reference/singlestat/](http://docs.grafana.org/reference/singlestat/) \ No newline at end of file diff --git a/public/app/plugins/panel/table/README.md b/public/app/plugins/panel/table/README.md new file mode 100644 index 00000000000..48c4fac641b --- /dev/null +++ b/public/app/plugins/panel/table/README.md @@ -0,0 +1,9 @@ +# Table Panel - Native Plugin + +The Table Panel is **included** with Grafana. + +The table panel is very flexible, supporting both multiple modes for time series as well as for table, annotation and raw JSON data. It also provides date formatting and value formatting and coloring options. + +Check out the [Table Panel Showcase in the Grafana Playground](http://play.grafana.org/dashboard/db/table-panel-showcase) or read more about it here: + +[http://docs.grafana.org/reference/table_panel/](http://docs.grafana.org/reference/table_panel/) \ No newline at end of file diff --git a/public/app/plugins/panel/table/module.ts b/public/app/plugins/panel/table/module.ts index d5ac802a62b..295c7e0ee33 100644 --- a/public/app/plugins/panel/table/module.ts +++ b/public/app/plugins/panel/table/module.ts @@ -114,9 +114,13 @@ class TablePanelCtrl extends MetricsPanelCtrl { } } + this.render(); + } + + render() { this.table = transformDataToTable(this.dataRaw, this.panel); this.table.sort(this.panel.sort); - this.render(this.table); + return super.render(this.table); } toggleColumnSort(col, colIndex) { @@ -130,7 +134,6 @@ class TablePanelCtrl extends MetricsPanelCtrl { this.panel.sort.col = colIndex; this.panel.sort.desc = true; } - this.render(); } @@ -155,7 +158,7 @@ class TablePanelCtrl extends MetricsPanelCtrl { } function appendTableRows(tbodyElem) { - var renderer = new TableRenderer(panel, data, ctrl.dashboard.timezone); + var renderer = new TableRenderer(panel, data, ctrl.dashboard.isTimezoneUtc()); tbodyElem.empty(); tbodyElem.html(renderer.render(ctrl.pageIndex)); } diff --git a/public/app/plugins/panel/table/renderer.ts b/public/app/plugins/panel/table/renderer.ts index 0a306b103a4..c00656071be 100644 --- a/public/app/plugins/panel/table/renderer.ts +++ b/public/app/plugins/panel/table/renderer.ts @@ -8,7 +8,7 @@ export class TableRenderer { formaters: any[]; colorState: any; - constructor(private panel, private table, private timezone) { + constructor(private panel, private table, private isUtc) { this.formaters = []; this.colorState = {}; } @@ -45,7 +45,7 @@ export class TableRenderer { return v => { if (_.isArray(v)) { v = v[0]; } var date = moment(v); - if (this.timezone === 'utc') { + if (this.isUtc) { date = date.utc(); } return date.format(style.dateFormat); diff --git a/public/app/plugins/panel/text/README.md b/public/app/plugins/panel/text/README.md new file mode 100644 index 00000000000..14751842990 --- /dev/null +++ b/public/app/plugins/panel/text/README.md @@ -0,0 +1,5 @@ +# Text Panel - Native Plugin + +The Text Panel is **included** with Grafana. + +The Text Panel is a very simple panel that displays text. The source text is written in the Markdown syntax meaning you can format the text. Read [GitHub's Mastering Markdown](https://guides.github.com/features/mastering-markdown/) to learn more. \ No newline at end of file diff --git a/public/sass/_grafana.scss b/public/sass/_grafana.scss index 9da4ed0dfbc..b5aa401f0c3 100644 --- a/public/sass/_grafana.scss +++ b/public/sass/_grafana.scss @@ -17,6 +17,7 @@ @import "base/grid"; @import "base/font_awesome"; @import "base/grafana_icons"; +@import "base/code"; // UTILS @import "utils/utils"; diff --git a/public/sass/_old_responsive.scss b/public/sass/_old_responsive.scss index a7b2917277a..899a785c19b 100644 --- a/public/sass/_old_responsive.scss +++ b/public/sass/_old_responsive.scss @@ -7,8 +7,8 @@ // --------------------- @include media-breakpoint-down(sm) { div.panel { - width: 100%; - padding: 0px; + width: 100% !important; + padding: 0px !important; } .panel-margin { margin-right: 0; diff --git a/public/sass/base/_code.scss b/public/sass/base/_code.scss index db7a8cfab18..2a4057a8547 100644 --- a/public/sass/base/_code.scss +++ b/public/sass/base/_code.scss @@ -11,28 +11,28 @@ pre { background-color: $code-tag-bg; color: $text-color; border: 1px solid darken($code-tag-bg, 15%); - padding: 2px; + padding: 10px; + border-radius: 4px; } // Inline code code { - color: #d14; - background-color: #f7f7f9; - border: 1px solid #e1e1e8; + color: $text-color; + background-color: $code-tag-bg; + border: 1px solid darken($code-tag-bg, 15%); white-space: nowrap; } // Blocks of code pre { display: block; - margin: 0 0 $line-height-base / 2; - font-size: $font-size-base - 1; // 14px to 13px + margin: 0 0 $line-height-base; line-height: $line-height-base; word-break: break-all; word-wrap: break-word; white-space: pre; white-space: pre-wrap; - background-color: #f5f5f5; + background-color: $code-tag-bg; // Make prettyprint styles more spaced out for readability &.prettyprint { diff --git a/public/sass/base/_font_awesome.scss b/public/sass/base/_font_awesome.scss index 438185f3198..51d9bac987d 100644 --- a/public/sass/base/_font_awesome.scss +++ b/public/sass/base/_font_awesome.scss @@ -66,12 +66,6 @@ border: solid 0.08em #eeeeee; border-radius: .1em; } -.pull-right { - float: right; -} -.pull-left { - float: left; -} .fa.pull-left { margin-right: .3em; } diff --git a/public/sass/components/_panel_graph.scss b/public/sass/components/_panel_graph.scss index ccecbc6c9a7..9837f33a543 100644 --- a/public/sass/components/_panel_graph.scss +++ b/public/sass/components/_panel_graph.scss @@ -74,6 +74,10 @@ float: left; white-space: nowrap; padding-left: 10px; + + &--right-y { + float: right; + } } .graph-legend-value { @@ -83,14 +87,22 @@ .graph-legend-table { overflow-y: scroll; - .graph-legend-series { display: table-row; + .graph-legend-series { + display: table-row; float: none; padding-left: 0; - &.pull-right { + &--right-y { float: none; + + .graph-legend-alias:after { + content: '(right-y)'; + padding: 0 5px; + color: $text-color-weak; + } } } + td, .graph-legend-alias, .graph-legend-icon, .graph-legend-value { float: none; display: table-cell; diff --git a/public/test/specs/dashboardSrv-specs.js b/public/test/specs/dashboardSrv-specs.js index e02495c1236..6fc53f09190 100644 --- a/public/test/specs/dashboardSrv-specs.js +++ b/public/test/specs/dashboardSrv-specs.js @@ -7,6 +7,10 @@ define([ var _dashboardSrv; beforeEach(module('grafana.services')); + beforeEach(module(function($provide) { + $provide.value('contextSrv', { + }); + })); beforeEach(inject(function(dashboardSrv) { _dashboardSrv = dashboardSrv; diff --git a/public/test/specs/dynamicDashboardSrv-specs.js b/public/test/specs/dynamicDashboardSrv-specs.js index 0104081b768..b988203009a 100644 --- a/public/test/specs/dynamicDashboardSrv-specs.js +++ b/public/test/specs/dynamicDashboardSrv-specs.js @@ -12,6 +12,11 @@ define([ ctx.setup = function (setupFunc) { beforeEach(module('grafana.services')); + beforeEach(module(function($provide) { + $provide.value('contextSrv', { + user: { timezone: 'utc'} + }); + })); beforeEach(inject(function(dynamicDashboardSrv, dashboardSrv) { ctx.dynamicDashboardSrv = dynamicDashboardSrv; @@ -45,10 +50,10 @@ define([ value: ['se1', 'se2', 'se3'] }, options: [ - {text: 'se1', value: 'se1', selected: true}, - {text: 'se2', value: 'se2', selected: true}, - {text: 'se3', value: 'se3', selected: true}, - {text: 'se4', value: 'se4', selected: false} + {text: 'se1', value: 'se1', selected: true}, + {text: 'se2', value: 'se2', selected: true}, + {text: 'se3', value: 'se3', selected: true}, + {text: 'se4', value: 'se4', selected: false} ] }); }); @@ -93,7 +98,7 @@ define([ describe('After a second iteration and selected values reduced', function() { beforeEach(function() { ctx.dash.templating.list[0].options[1].selected = false; - + ctx.dynamicDashboardSrv.update(ctx.dash); }); diff --git a/public/vendor/angular/.bower.json b/public/vendor/angular/.bower.json index b7b5e0bb59f..4221ce7cb09 100644 --- a/public/vendor/angular/.bower.json +++ b/public/vendor/angular/.bower.json @@ -13,6 +13,6 @@ "commit": "5a07c5107b4d24f41744a02b07717d55bad88e70" }, "_source": "git://github.com/angular/bower-angular.git", - "_target": "1.5.3", + "_target": "~1.5.3", "_originalSource": "angular" } \ No newline at end of file diff --git a/tasks/options/concat.js b/tasks/options/concat.js index a5e0753b0cd..2ad37a52320 100644 --- a/tasks/options/concat.js +++ b/tasks/options/concat.js @@ -29,7 +29,6 @@ module.exports = function(config) { js: { src: [ - '<%= genDir %>/vendor/npm/es5-shim/es5-shim.js', '<%= genDir %>/vendor/npm/es6-shim/es6-shim.js', '<%= genDir %>/vendor/npm/es6-promise/dist/es6-promise.js', '<%= genDir %>/vendor/npm/systemjs/dist/system-polyfills.js', diff --git a/tasks/options/copy.js b/tasks/options/copy.js index 7ac115e01e9..59a36e6153a 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -25,7 +25,6 @@ module.exports = function(config) { 'angular2/manual_typings/**/*', 'systemjs/dist/*.js', 'es6-promise/**/*', - 'es5-shim/*.js', 'es6-shim/*.js', 'reflect-metadata/*.js', 'reflect-metadata/*.ts',