From d056b1f1e11f6a9acbe1650130e878e399707d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 31 Jul 2014 09:17:37 +0200 Subject: [PATCH] Search: max_results config.js option & scroll in search results (To show more or all dashboards), Closes #631 --- CHANGELOG.md | 1 + src/app/components/settings.js | 3 ++- src/app/partials/search.html | 2 ++ .../services/elasticsearch/es-datasource.js | 5 +++-- src/config.sample.js | 22 ++++++++++++------- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d9e6593f0..1adad34d820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - [Issue #266](https://github.com/grafana/grafana/issues/266). Graphite: New option cacheTimeout to override graphite default memcache timeout - [Issue #606](https://github.com/grafana/grafana/issues/606). General: New global option in config.js to specify admin password (useful to hinder users from accidentally make changes) - [Issue #201](https://github.com/grafana/grafana/issues/201). Annotations: Elasticsearch datasource support for events +- [Issue #631](https://github.com/grafana/grafana/issues/631). Search: max_results config.js option & scroll in search results (To show more or all dashboards) **Changes** - [Issue #536](https://github.com/grafana/grafana/issues/536). Graphite: Use unix epoch for Graphite from/to for absolute time ranges diff --git a/src/app/components/settings.js b/src/app/components/settings.js index f8d84fbe3de..29121dcaded 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -19,7 +19,8 @@ function (_, crypto) { default_route : '/dashboard/file/default.json', playlist_timespan : "1m", unsaved_changes_warning : true, - admin: {} + search : { max_results: 20 }, + admin : {} }; // This initializes a new hash on purpose, to avoid adding parameters to diff --git a/src/app/partials/search.html b/src/app/partials/search.html index a3eaba3a6dc..f61b8a4d3cc 100644 --- a/src/app/partials/search.html +++ b/src/app/partials/search.html @@ -60,6 +60,7 @@ + @@ -88,6 +89,7 @@ +
diff --git a/src/app/services/elasticsearch/es-datasource.js b/src/app/services/elasticsearch/es-datasource.js index ffc7d394277..8752850a8c8 100644 --- a/src/app/services/elasticsearch/es-datasource.js +++ b/src/app/services/elasticsearch/es-datasource.js @@ -23,6 +23,7 @@ function (angular, _, $, config, kbn, moment) { this.index = datasource.index; this.grafanaDB = datasource.grafanaDB; this.annotationEditorSrc = 'app/partials/elasticsearch/annotation_editor.html'; + this.searchMaxResults = config.search.max_results || 20; } ElasticDatasource.prototype._request = function(method, url, index, data) { @@ -198,7 +199,7 @@ function (angular, _, $, config, kbn, moment) { var query = { query: { query_string: { query: queryString } }, facets: { tags: { terms: { field: "tags", order: "term", size: 50 } } }, - size: 20, + size: this.searchMaxResults, sort: ["_uid"] }; @@ -208,7 +209,7 @@ function (angular, _, $, config, kbn, moment) { return { dashboards: [], tags: [] }; } - return { dashboards: results.hits.hits, tags: results.facets.terms }; + return { dashboards: results.hits.hits, tags: results.facets.terms || [] }; }); }; diff --git a/src/config.sample.js b/src/config.sample.js index 6d421855e5b..25940fbce5e 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -9,7 +9,9 @@ function (Settings) { return new Settings({ - // datasources, you can add multiple + // datasources + // Delete the ones you do not want + // grafanaDB: true marks the datasource for use as dashboard storage datasources: { graphite: { type: 'graphite', @@ -22,19 +24,23 @@ function (Settings) { username: 'admin', password: 'admin' }, + // elasticsearch, used for storing and loading dashboards, annotations + // For Basic authentication use: http://username:password@domain.com:9200 + elasticsearch: { + type: 'elasticsearch', + url: "http://"+window.location.hostname+":9200" + index: 'grafana-dash', // index for storing dashboards + grafanaDB: true, + } }, - // elasticsearch url - // used for storing and loading dashboards, optional - // For Basic authentication use: http://username:password@domain.com:9200 - elasticsearch: "http://"+window.location.hostname+":9200", + search: { + max_results: 20 + }, // default start dashboard default_route: '/dashboard/file/default.json', - // Elasticsearch index for storing dashboards - grafana_index: "grafana-dash", - // set to false to disable unsaved changes warning unsaved_changes_warning: true,