diff --git a/mod/dashboard/app/scripts/common/services/etcd.js b/mod/dashboard/app/scripts/common/services/etcd.js index 5a303bac8..aaad9ed41 100644 --- a/mod/dashboard/app/scripts/common/services/etcd.js +++ b/mod/dashboard/app/scripts/common/services/etcd.js @@ -2,10 +2,10 @@ angular.module('etcd', []) -.factory('EtcdV1', ['$http', function($http) { - var keyPrefix = '/v1/keys/' - var statsPrefix = '/v1/stats/' - var baseURL = '/v1/' +.factory('EtcdV2', ['$http', function($http) { + var keyPrefix = '/v2/keys/' + var statsPrefix = '/v2/stats/' + var baseURL = '/v2/' delete $http.defaults.headers.common['X-Requested-With']; @@ -15,7 +15,8 @@ angular.module('etcd', []) return ''; } parts = parts.filter(function(v){return v!=='';}); - return parts.join('/'); + parts = parts.join('/'); + return parts } function newKey(keyName) { @@ -32,7 +33,11 @@ angular.module('etcd', []) }; self.path = function() { - return '/' + cleanupPath(keyPrefix + self.name); + var path = '/' + cleanupPath(keyPrefix + self.name); + if (path === keyPrefix.substring(0, keyPrefix.length - 1)) { + return keyPrefix + } + return path }; self.get = function() { @@ -43,7 +48,7 @@ angular.module('etcd', []) return $http({ url: self.path(), data: $.param({value: keyValue}), - method: 'POST', + method: 'PUT', headers: {'Content-Type': 'application/x-www-form-urlencoded'} }); }; diff --git a/mod/dashboard/app/scripts/controllers/browser.js b/mod/dashboard/app/scripts/controllers/browser.js index 42018f2ff..72ca269ea 100644 --- a/mod/dashboard/app/scripts/controllers/browser.js +++ b/mod/dashboard/app/scripts/controllers/browser.js @@ -2,7 +2,7 @@ angular.module('etcdBrowser', ['ngRoute', 'etcd', 'timeRelative']) -.constant('keyPrefix', '/v1/keys') +.constant('keyPrefix', '/v2/keys/') .config(['$routeProvider', 'keyPrefix', function ($routeProvider, keyPrefix) { //read localstorage @@ -18,7 +18,7 @@ angular.module('etcdBrowser', ['ngRoute', 'etcd', 'timeRelative']) }); }]) -.controller('MainCtrl', ['$scope', '$location', 'EtcdV1', 'keyPrefix', function ($scope, $location, EtcdV1, keyPrefix) { +.controller('MainCtrl', ['$scope', '$location', 'EtcdV2', 'keyPrefix', function ($scope, $location, EtcdV2, keyPrefix) { $scope.save = 'etcd-save-hide'; $scope.preview = 'etcd-preview-hide'; $scope.enableBack = true; @@ -43,12 +43,12 @@ angular.module('etcdBrowser', ['ngRoute', 'etcd', 'timeRelative']) // Notify everyone of the update localStorage.setItem('etcdPath', $scope.etcdPath); $scope.enableBack = true; - //disable back button if at root (/v1/keys/) - if($scope.etcdPath === '/v1/keys') { + //disable back button if at root (/v2/keys/) + if($scope.etcdPath === keyPrefix) { $scope.enableBack = false; } - $scope.key = EtcdV1.getKey(etcdPathKey($scope.etcdPath)); + $scope.key = EtcdV2.getKey(etcdPathKey($scope.etcdPath)); }); $scope.$watch('key', function() { @@ -59,14 +59,14 @@ angular.module('etcdBrowser', ['ngRoute', 'etcd', 'timeRelative']) //hide any errors $('#etcd-browse-error').hide(); // Looking at a directory if we got an array - if (data.length) { - $scope.list = data; + if (data.dir === true) { + $scope.list = data.kvs; $scope.preview = 'etcd-preview-hide'; } else { $scope.singleValue = data.value; $scope.preview = 'etcd-preview-reveal'; $scope.key.getParent().get().success(function(data) { - $scope.list = data; + $scope.list = data.kvs; }); } $scope.previewMessage = 'No key selected.'; diff --git a/mod/dashboard/app/views/browser.html b/mod/dashboard/app/views/browser.html index b59f94636..b40dc38dc 100644 --- a/mod/dashboard/app/views/browser.html +++ b/mod/dashboard/app/views/browser.html @@ -56,7 +56,7 @@ - {{key.key}} + {{key.key}}