Просмотр исходного кода

moved back to to load icon, and reinstated load dashboard from file

Torkel Ödegaard 12 лет назад
Родитель
Сommit
5f8358e5c2

+ 13 - 2
src/app/controllers/search.js

@@ -43,14 +43,24 @@ function (angular, _, config, $) {
       });
     };
 
+    $scope.toggleImport = function ($event) {
+      $event.stopPropagation();
+
+      $scope.showImport = !$scope.showImport;
+    };
+
     $scope.elasticsearch_dblist = function(queryStr) {
+      $scope.showImport = false;
+
       queryStr = queryStr.toLowerCase();
 
-      if (queryStr.indexOf('d:') === 0) {
-        $scope.elasticsearch_dashboards(queryStr.substring(2, queryStr.length));
+      if (queryStr.indexOf('m:') !== 0) {
+        $scope.elasticsearch_dashboards(queryStr);
         return;
       }
 
+      queryStr = queryStr.substring(2, queryStr.length);
+
       var words = queryStr.split(' ');
       var query = $scope.ejs.BoolQuery();
       var terms = _.map(words, function(word) {
@@ -78,6 +88,7 @@ function (angular, _, config, $) {
 
     $scope.openSearch = function () {
       $scope.giveSearchFocus = $scope.giveSearchFocus + 1;
+      $scope.elasticsearch_dblist("");
     };
 
     $scope.addMetricToCurrentDashboard = function (metricId) {

+ 0 - 2
src/app/panels/graphite/module.js

@@ -432,11 +432,9 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
     $scope.toggleSeries = function(info) {
       if ($scope.hiddenSeries[info.alias]) {
         delete $scope.hiddenSeries[info.alias];
-        info.hidden = false;
       }
       else {
         $scope.hiddenSeries[info.alias] = true;
-        info.hidden = true;
       }
 
       $scope.$emit('toggleLegend', info.alias);

+ 8 - 1
src/app/partials/dashLoader.html

@@ -5,7 +5,9 @@
 </style>
 
 <li>
-  <a class='small' ng-controller="ZoomCtrl" ng-click='zoom(2)'><i class='icon-zoom-out'></i> Zoom Out</a>
+  <a class='small' ng-controller="ZoomCtrl" ng-click='zoom(2)'>
+    Zoom Out
+  </a>
 </li>
 
 <li ng-repeat="pulldown in dashboard.current.nav" ng-controller="PulldownCtrl" ng-show="pulldown.enable"><kibana-simple-panel type="pulldown.type" ng-cloak></kibana-simple-panel></li>
@@ -51,6 +53,11 @@
   </ul>
 </li>
 
+<li class="dropdown" ng-show="showDropdown('load')" ng-controller="SearchCtrl" ng-init="init()" ng-include="'app/partials/search.html'">
+
+</li>
+
+
 <li><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/dashboard'><i class='icon-home'></i></a></li>
 
 <li ng-show="showDropdown('share')"><a bs-tooltip="'Share'" data-placement="bottom" ng-click="elasticsearch_save('temp',dashboard.current.loader.save_temp_ttl)" bs-modal="'app/partials/dashLoaderShare.html'"><i class='icon-share'></i></a></li>

+ 43 - 9
src/app/partials/search.html

@@ -1,5 +1,5 @@
   <style>
-    .grafana-search {
+    #grafana-search {
       position: fixed;
       right: 0;
       left: 0;
@@ -12,15 +12,19 @@
     }
   </style>
 
- <li class="dropdown">
   <a href="#" bs-tooltip="'Search'" data-placement="bottom" ng-click="openSearch()" class="dropdown-toggle" data-toggle="dropdown">
-    <i class='icon-search'></i>
+    <i class='icon-folder-open'></i>
   </a>
-  <ul class="dropdown-menu grafana-search">
-    <li>
-      <div class="grafana-search-panel">
-        <input type="text" placeholder="search dashboards, metrics, or graphs" xng-focus="giveSearchFocus" ng-keydown="keyDown($event)" ng-model="elasticsearch.query" ng-change="elasticsearch_dblist(elasticsearch.query)" />
 
+  <ul class="dropdown-menu" id="grafana-search">
+    <li ng-if="!showImport">
+      <div class="grafana-search-panel">
+        <input  type="text"
+                placeholder="search dashboards, metrics, or graphs"
+                xng-focus="giveSearchFocus"
+                ng-keydown="keyDown($event)"
+                ng-model="elasticsearch.query"
+                ng-change="elasticsearch_dblist(elasticsearch.query)" />
         <h6 ng-hide="search_results.dashboards.length || search_results.metrics.length">No dashboards or metrics matching your query found</h6>
         <table class="table table-condensed table-striped">
           <tr bindonce ng-repeat="row in search_results.metrics" class="grafana-search-metric-result">
@@ -43,5 +47,35 @@
         </table>
       </div>
     </li>
-  </ul>
-</li>
+
+    <li class="pull-right" style="margin: 5px;">
+      <a ng-click="toggleImport($event)">Import</a>
+    </li>
+    <!-- ng-show="dashboard.current.loader.load_gist || dashboard.current.loader.load_local" -->
+    <li ng-if="showImport" style="margin: 20px;">
+      <div class="editor-row">
+        <div class="section">
+          <div class="editor-option">
+            <h5>Local File <tip>Load dashboard JSON layout from file</tip></h5>
+            <form>
+              <input type="file" id="dashupload" dash-upload /><br>
+            </form>
+          </div>
+        </div>
+      </div>
+
+      <div class="editor-row" ng-show='dashboard.current.loader.load_gist'>
+        <h5>Gist <tip>Enter a gist number or url</tip></h5>
+        <form>
+          <input type="text" ng-model="gist.url" placeholder="Gist number or URL"><br>
+          <button class="btn" ng-click="gist_dblist(dashboard.gist_id(gist.url))" ng-show="dashboard.is_gist(gist.url)"><i class="icon-github-alt"></i> Get gist:{{gist.url | gistid}}</button>
+          <h6 ng-show="gist.files.length">Dashboards in gist:{{gist.url | gistid}} <small>click to load</small></h6>
+          <h6 ng-hide="gist.files.length || !gist.url.length">No gist dashboards found</h6>
+          <table class="table table-condensed table-striped">
+            <tr ng-repeat="file in gist.files">
+              <td><a ng-click="dashboard.dash_load(file)">{{file.title}}</a></td>
+            </tr>
+          </table>
+        </form>
+      </div>
+    </li>

+ 2 - 0
src/app/services/dashboard.js

@@ -70,6 +70,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
     // Store a reference to this
     var self = this;
     var filterSrv;
+    var graphiteSrv;
 
     this.current = _.clone(_dash);
     this.last = {};
@@ -160,6 +161,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
       $timeout(function() {
         // Ok, now that we've setup the current dashboard, we can inject our services
         filterSrv = $injector.get('filterSrv');
+        graphiteSrv = $injector.get('graphiteSrv');
         filterSrv.init();
 
       },0).then(function() {

+ 0 - 4
src/index.html

@@ -34,10 +34,6 @@
       <div class="navbar-inner">
         <div class="container-fluid">
           <span class="brand"><img src="img/small.png" bs-tooltip="'Kibana 3 milestone pre-5'" data-placement="bottom"> {{dashboard.current.title}}</span>
-
-          <ul class="nav pull-left" ng-controller="SearchCtrl" ng-init="init()" ng-include="'app/partials/search.html'">
-          </ul>
-
           <ul class="nav pull-right" ng-controller='dashLoader' ng-init="init()" ng-include="'app/partials/dashLoader.html'">
           </ul>
         </div>