瀏覽代碼

Elasticsearch: fix for issue when saving dashboard with title equal to slugified url, would cause the backward compatible fix to delete it, Closes #828

Torkel Ödegaard 11 年之前
父節點
當前提交
a97bcc3ca7
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 1 0
      CHANGELOG.md
  2. 3 2
      src/app/services/elasticsearch/es-datasource.js

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 - [Issue #802](https://github.com/grafana/grafana/issues/802). Annotations: Fix when using InfluxDB datasource
 - [Issue #802](https://github.com/grafana/grafana/issues/802). Annotations: Fix when using InfluxDB datasource
 - [Issue #795](https://github.com/grafana/grafana/issues/795). Chrome: Fix for display issue in chrome beta & chrome canary when entering edit mode
 - [Issue #795](https://github.com/grafana/grafana/issues/795). Chrome: Fix for display issue in chrome beta & chrome canary when entering edit mode
 - [Issue #818](https://github.com/grafana/grafana/issues/818). Graph: Added percent y-axis format
 - [Issue #818](https://github.com/grafana/grafana/issues/818). Graph: Added percent y-axis format
+- [Issue #828](https://github.com/grafana/grafana/issues/828). Elasticsearch: saving new dashboard with title equal to slugified url would cause it to deleted.
 
 
 # 1.8.0-RC1 (2014-09-12)
 # 1.8.0-RC1 (2014-09-12)
 
 

+ 3 - 2
src/app/services/elasticsearch/es-datasource.js

@@ -169,7 +169,7 @@ function (angular, _, config, kbn, moment) {
 
 
         return this._request('PUT', '/dashboard/' + id, this.index, data)
         return this._request('PUT', '/dashboard/' + id, this.index, data)
           .then(function(results) {
           .then(function(results) {
-            self._removeUnslugifiedDashboard(results, title);
+            self._removeUnslugifiedDashboard(results, title, id);
             return { title: title, url: '/dashboard/db/' + id };
             return { title: title, url: '/dashboard/db/' + id };
           }, function() {
           }, function() {
             throw 'Failed to save to elasticsearch';
             throw 'Failed to save to elasticsearch';
@@ -177,8 +177,9 @@ function (angular, _, config, kbn, moment) {
       }
       }
     };
     };
 
 
-    ElasticDatasource.prototype._removeUnslugifiedDashboard = function(saveResult, title) {
+    ElasticDatasource.prototype._removeUnslugifiedDashboard = function(saveResult, title, id) {
       if (saveResult.statusText !== 'Created') { return; }
       if (saveResult.statusText !== 'Created') { return; }
+      if (title === id) { return; }
 
 
       var self = this;
       var self = this;
       this._get('/dashboard/' + title).then(function() {
       this._get('/dashboard/' + title).then(function() {