diff --git a/' b/'
new file mode 100644
index 00000000000..86791d43fde
--- /dev/null
+++ b/'
@@ -0,0 +1,84 @@
+/* global _ */
+
+/*
+ * Complex scripted dashboard
+ * This script generates a dashboard object that Grafana can load. It also takes a number of user
+ * supplied URL parameters (int ARGS variable)
+ *
+ * Return a dashboard object, or a function
+ *
+ * For async scripts, return a function, this function must take a single callback function as argument,
+ * call this callback function with the dashboard object (look at scripted_async.js for an example)
+ */
+
+'use strict';
+
+// accessable variables in this scope
+var window, document, ARGS, $, jQuery, moment, kbn, services, _;
+
+// default datasource
+var datasource = services.datasourceSrv.default;
+// get datasource used for saving dashboards
+var dashboardDB = services.datasourceSrv.getGrafanaDB();
+
+var targets = [];
+
+function getTargets(path) {
+ return datasource.metricFindQuery(path + '.*').then(function(result) {
+ if (!result) {
+ return null;
+ }
+
+ if (targets.length === 10) {
+ return null;
+ }
+
+ var promises = _.map(result, function(metric) {
+ if (metric.expandable) {
+ return getTargets(path + "." + metric.text);
+ }
+ else {
+ targets.push(path + '.' + metric.text);
+ }
+ return null;
+ });
+
+ return services.$q.when(promises);
+ });
+}
+
+function createDashboard(target, index) {
+ // Intialize a skeleton with nothing but a rows array and service object
+ var dashboard = { rows : [] };
+ dashboard.title = 'Scripted dash ' + index;
+ dashboard.time = {
+ from: "now-6h",
+ to: "now"
+ };
+
+ dashboard.rows.push({
+ title: 'Chart',
+ height: '300px',
+ panels: [
+ {
+ title: 'Events',
+ type: 'graph',
+ span: 12,
+ targets: [ {target: target} ]
+ }
+ ]
+ });
+
+}
+
+return function(callback) {
+
+ getTargets('apps').then(function(results) {
+ console.log('targets: ', targets);
+ _.each(targets, function(target, index) {
+ var dashboard = createDashboard(target);
+ });
+ });
+
+};
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd27a6a6667..24772741c14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,10 +11,15 @@
**Misc**
- [Issue #938](https://github.com/grafana/grafana/issues/938). Panel: Plugin panels now reside outside of app/panels directory
- [Issue #952](https://github.com/grafana/grafana/issues/952). Help: Shortcut "?" to open help modal with list of all shortcuts
+- [Issue #991](https://github.com/grafana/grafana/issues/991). ScriptedDashboard: datasource services are now available in scripted dashboards, you can query datasource for metric keys, generate dashboards, and even save them in a scripted dashboard (see scripted_gen_and_save.js for example)
+
+**OpenTSDB**
+- [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc
**Fixes**
- [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other)
- [Issue #505](https://github.com/grafana/grafana/issues/505). Graph: fix for second y axis tick unit labels wrapping on the next line
+- [Issue #987](https://github.com/grafana/grafana/issues/987). Dashboard: Collapsed rows became invisible when hide controls was enabled
=======
# 1.8.1 (2014-09-30)
diff --git a/src/app/components/require.config.js b/src/app/components/require.config.js
index 5d8da32846f..882583083c6 100644
--- a/src/app/components/require.config.js
+++ b/src/app/components/require.config.js
@@ -3,6 +3,7 @@
*/
require.config({
baseUrl: 'app',
+ urlArgs: 'bust=' + (new Date().getTime()),
paths: {
config: ['../config', '../config.sample'],
diff --git a/src/app/dashboards/scripted_gen_and_save.js b/src/app/dashboards/scripted_gen_and_save.js
new file mode 100644
index 00000000000..d874b3fc28e
--- /dev/null
+++ b/src/app/dashboards/scripted_gen_and_save.js
@@ -0,0 +1,95 @@
+/* global _ */
+
+/*
+ * Complex scripted dashboard
+ * This script generates a dashboard object that Grafana can load. It also takes a number of user
+ * supplied URL parameters (int ARGS variable)
+ *
+ * Return a dashboard object, or a function
+ *
+ * For async scripts, return a function, this function must take a single callback function as argument,
+ * call this callback function with the dashboard object (look at scripted_async.js for an example)
+ */
+
+'use strict';
+
+// accessable variables in this scope
+var window, document, ARGS, $, jQuery, moment, kbn, services, _;
+
+// default datasource
+var datasource = services.datasourceSrv.default;
+// get datasource used for saving dashboards
+var dashboardDB = services.datasourceSrv.getGrafanaDB();
+
+var targets = [];
+
+function getTargets(path) {
+ return datasource.metricFindQuery(path + '.*').then(function(result) {
+ if (!result) {
+ return null;
+ }
+
+ if (targets.length === 10) {
+ return null;
+ }
+
+ var promises = _.map(result, function(metric) {
+ if (metric.expandable) {
+ return getTargets(path + "." + metric.text);
+ }
+ else {
+ targets.push(path + '.' + metric.text);
+ }
+ return null;
+ });
+
+ return services.$q.all(promises);
+ });
+}
+
+function createDashboard(target, index) {
+ // Intialize a skeleton with nothing but a rows array and service object
+ var dashboard = { rows : [] };
+ dashboard.title = 'Scripted dash ' + index;
+ dashboard.time = {
+ from: "now-6h",
+ to: "now"
+ };
+
+ dashboard.rows.push({
+ title: 'Chart',
+ height: '300px',
+ panels: [
+ {
+ title: 'Events',
+ type: 'graph',
+ span: 12,
+ targets: [ {target: target} ]
+ }
+ ]
+ });
+
+ return dashboard;
+}
+
+function saveDashboard(dashboard) {
+ var model = services.dashboardSrv.create(dashboard);
+ dashboardDB.saveDashboard(model);
+}
+
+return function(callback) {
+
+ getTargets('apps').then(function() {
+ console.log('targets: ', targets);
+ _.each(targets, function(target, index) {
+ var dashboard = createDashboard(target, index);
+ saveDashboard(dashboard);
+
+ if (index === targets.length - 1) {
+ callback(dashboard);
+ }
+ });
+ });
+
+};
+
diff --git a/src/app/directives/grafanaGraph.tooltip.js b/src/app/directives/grafanaGraph.tooltip.js
index 3a4a9b1ac2a..e0fede2f62d 100644
--- a/src/app/directives/grafanaGraph.tooltip.js
+++ b/src/app/directives/grafanaGraph.tooltip.js
@@ -144,8 +144,9 @@ function ($) {
hoverInfo = seriesHoverInfo[i];
value = series.formatValue(hoverInfo.value);
- group = ' ' + series.label;
- seriesHtml = group + ': ' + value + ' ' + seriesHtml;
+ seriesHtml += '
';
+ seriesHtml += ' ' + series.label + ':
';
+ seriesHtml += '
' + value + '
';
plot.highlight(i, hoverInfo.hoverIndex);
}
@@ -154,7 +155,8 @@ function ($) {
// single series tooltip
else if (item) {
series = seriesList[item.seriesIndex];
- group = ' ' + series.label;
+ group = '
';
+ group += ' ' + series.label + ':
';
if (scope.panel.stack && scope.panel.tooltip.value_type === 'individual') {
value = item.datapoint[1] - item.datapoint[2];
@@ -165,7 +167,7 @@ function ($) {
value = series.formatValue(value);
timestamp = dashboard.formatDate(item.datapoint[0]);
- group += ': ' + value + ' ';
+ group += '