Przeglądaj źródła

Search: max_results config.js option & scroll in search results (To show more or all dashboards), Closes #631

Torkel Ödegaard 11 lat temu
rodzic
commit
d056b1f1e1

+ 1 - 0
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

+ 2 - 1
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

+ 2 - 0
src/app/partials/search.html

@@ -60,6 +60,7 @@
         </table>
 
         <table class="table table-condensed table-striped" ng-if="!tagsOnly">
+					<tbody style="max-height: 570px; overflow: auto; display: block">
           <tr bindonce ng-repeat="row in results.metrics"
               class="grafana-search-metric-result"
               ng-class="{'selected': $index === selectedIndex }">
@@ -88,6 +89,7 @@
             </td>
             <td><a><i class="icon-share" ng-click="shareDashboard(row._id, row._id)" config-modal="app/partials/dashLoaderShare.html"></i></a></td>
           </tr>
+					</tbody>
         </table>
       </div>
     </li>

+ 3 - 2
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 || [] };
         });
     };
 

+ 14 - 8
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,