You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2015/05/27 10:38:21 UTC
incubator-ignite git commit: # 843 Fixed cluster edit.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-843 17c6f30bb -> 9ba409484
# 843 Fixed cluster edit.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9ba40948
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9ba40948
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9ba40948
Branch: refs/heads/ignite-843
Commit: 9ba4094845eb3a6d698a03d4c0c0747288535d77
Parents: 17c6f30
Author: Andrey <an...@gridgain.com>
Authored: Wed May 27 15:38:15 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Wed May 27 15:38:15 2015 +0700
----------------------------------------------------------------------
.../public/javascripts/controllers/clusters.js | 97 ++++++++++----------
modules/webconfig/nodejs/views/clusters.jade | 26 +++---
2 files changed, 62 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ba40948/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js b/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
index 0884109..0cdd5c4 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/clusters.js
@@ -1,7 +1,9 @@
configuratorModule.controller('clustersController', [ '$scope', '$modal', '$http', '$filter', 'ngTableParams',
- function ($scope, $modal, $http, $filter, ngTableParams) {
- $scope.edit = {};
+ function($scope, $modal, $http, $filter, ngTableParams) {
+ $scope.editColumn = {};
+
$scope.editRow = {};
+
$scope.editIdx = false;
$scope.discoveries = [
@@ -9,7 +11,7 @@ configuratorModule.controller('clustersController', [ '$scope', '$modal', '$http
{value: 'TcpDiscoveryMulticastIpFinder', label: 'Multicast'}
];
- $scope.discoveryAsString = function (value) {
+ $scope.discoveryAsString = function(value) {
for (var i in $scope.discoveries) {
if ($scope.discoveries[i].value == value)
return $scope.discoveries[i].label;
@@ -20,7 +22,7 @@ configuratorModule.controller('clustersController', [ '$scope', '$modal', '$http
// When landing on the page, get clusters and show them.
$http.get('/rest/clusters')
- .success(function (data) {
+ .success(function(data) {
$scope.spaces = data.spaces;
$scope.clusters = data.clusters;
@@ -31,7 +33,7 @@ configuratorModule.controller('clustersController', [ '$scope', '$modal', '$http
}, {
total: $scope.clusters.length, // Length of data.
counts: [],
- getData: function ($defer, params) {
+ getData: function($defer, params) {
// Use build-in angular filter.
var orderedData = params.sorting() ?
$filter('orderBy')($scope.clusters, params.orderBy()) :
@@ -48,15 +50,44 @@ configuratorModule.controller('clustersController', [ '$scope', '$modal', '$http
// Create popup for discovery advanced settings.
var discoveryModal = $modal({scope: $scope, template: '/discovery', show: false});
- $scope.editDiscovery = function (cluster) {
+ $scope.editDiscovery = function(cluster) {
discoveryModal.$promise.then(discoveryModal.show);
};
- $scope.submit = function () {
- if ($scope.editIdx !== false) {
- console.log($scope.$data);
+ // Add new cluster.
+ $scope.add = function() {
+ $scope.clusters.push({space: $scope.spaces[0]._id});
+
+ $scope.clustersTable.reload();
+ };
+
+ $scope.beginEdit = function(name, cluster) {
+ $scope.revert();
+
+ $scope.currentRow = cluster;
+
+ $scope.editColumn = name;
+
+ $scope.editRow = angular.copy(cluster);
+
+ $scope.editIdx = $scope.clusters.indexOf(cluster);
+ };
+
+ $scope.revert = function() {
+ if ($scope.editColumn && $scope.currentRow) {
+ $scope.clusters[$scope.clusters.indexOf($scope.currentRow)] = $scope.editRow;
+
+ $scope.currentRow = undefined;
+
+ $scope.editColumn = undefined;
+
+ $scope.clustersTable.reload();
+ }
+ };
- var cluster = $scope.clusters[$scope.editIdx];
+ $scope.submit = function() {
+ if ($scope.editColumn && $scope.currentRow) {
+ var cluster = $scope.currentRow;
var data = {
_id: cluster._id,
@@ -66,62 +97,32 @@ configuratorModule.controller('clustersController', [ '$scope', '$modal', '$http
addresses: ['127.0.0.1', '192.168.1.1']
};
- $scope.editIdx = false;
+ $scope.currentRow = undefined;
- $http.post('/rest/clusters/save', data)
- .success(function (data) {
- myOtherModal.hide();
+ $scope.editColumn = undefined;
+ $http.post('/rest/clusters/save', data)
+ .success(function(data) {
$scope.spaces = data.spaces;
$scope.clusters = data.clusters;
$scope.clustersTable.reload();
})
- .error(function (errorMessage) {
+ .error(function(errorMessage) {
console.log('Error: ' + errorMessage);
});
}
};
- // Add new cluster.
- $scope.add = function () {
- // $scope.clusters.push({name: 'Cluster', discovery: 'TcpDiscoveryVmIpFinder'});
- $scope.clusters.push({space: $scope.spaces[0]._id});
-
- $scope.clustersTable.reload();
- };
-
- $scope.beginEdit = function (cluster) {
- $scope.editIdx = $scope.clusters.indexOf(cluster);
-
- $scope.editRow = angular.copy(cluster);
-
- //// Show when some event occurs (use $promise property to ensure the template has been loaded)
- //myOtherModal.$promise.then(myOtherModal.show);
- };
-
- $scope.revert = function () {
- if ($scope.editIdx !== false) {
- $scope.clusters[$scope.editIdx] = $scope.editRow;
-
- $scope.editIdx = false;
-
- $scope.clustersTable.reload();
- }
-
- //// Show when some event occurs (use $promise property to ensure the template has been loaded)
- //myOtherModal.$promise.then(myOtherModal.show);
- };
-
- $scope.delete = function (cluster) {
+ $scope.delete = function(cluster) {
$http.post('/rest/clusters/remove', {_id: cluster._id})
- .success(function (data) {
+ .success(function(data) {
$scope.spaces = data.spaces;
$scope.clusters = data.clusters;
$scope.clustersTable.reload();
})
- .error(function (errorMessage) {
+ .error(function(errorMessage) {
console.log('Error: ' + errorMessage);
});
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ba40948/modules/webconfig/nodejs/views/clusters.jade
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/views/clusters.jade b/modules/webconfig/nodejs/views/clusters.jade
index 0960624..dc74713 100644
--- a/modules/webconfig/nodejs/views/clusters.jade
+++ b/modules/webconfig/nodejs/views/clusters.jade
@@ -19,29 +19,29 @@ block content
table(ng-table="clustersTable" class=['table', 'table-bordered', 'table-hover'])
tr(ng-repeat="cluster in $data")
td(data-title="'#'" class=['text-center', 'vcenter'] style='width: 50px') {{$index + 1}}
- td(data-title="'Name'" sortable="'name'" class=['text-center', 'col-sm-4'])
- div(ng-if='!(edit.name && editIdx == $index)')
+ td(data-title="'Name'" sortable="'name'" class=['text-center', 'col-sm-7'])
+ div(ng-if='!(editColumn == "name" && currentRow == cluster)')
span(ng-if='cluster.name') {{cluster.name}}
- span.pull-right(type='button' ng-click='beginEdit(cluster); edit.name = true' data-animation="am-fade-and-scale")
+ span.pull-right(type='button' ng-click='beginEdit("name", cluster);')
i(class=['fa', 'fa-pencil'])
- div.input-group(ng-if='edit.name && editIdx == $index')
+ div.input-group(ng-if='editColumn == "name" && currentRow == cluster')
input.form-control(type='text' ng-model='cluster.name')
span.input-group-addon
- i(class=['fa', 'fa-repeat'] ng-click='revert(); edit.name = false')
- i(class=['fa', 'fa-save'] ng-click='submit(); edit.name = false' style='margin-left: 10px;')
+ i(class=['fa', 'fa-repeat'] ng-click='revert();')
+ i(class=['fa', 'fa-save'] ng-click='submit();' style='margin-left: 10px;')
td.text-center(data-title="'Discovery'" sortable="'discovery'")
- div(ng-if='!(edit.discovery && editIdx == $index)')
+ div(ng-if='!(editColumn == "discovery" && currentRow == cluster)')
span(ng-if='cluster.discovery') {{discoveryAsString(cluster.discovery)}}
span.pull-right(type='button')
- i(class=['fa', 'fa-caret-square-o-down'] ng-click='editDiscovery(cluster); edit.discovery = false')
- i(class=['fa', 'fa-pencil'] ng-click='beginEdit(cluster); edit.discovery = true' style='margin-left: 10px;')
- div.input-group(ng-if='edit.discovery && editIdx == $index')
+ i(class=['fa', 'fa-caret-square-o-down'] ng-click='editDiscovery(cluster);')
+ i(class=['fa', 'fa-pencil'] ng-click='beginEdit("discovery", cluster);' style='margin-left: 10px;')
+ div.input-group(ng-if='editColumn == "discovery" && currentRow == cluster')
button(class=['btn', 'btn-default', 'form-control', 'pull-right'] style='width: 85%' data-placement='bottom-center' ng-model='cluster.discovery' data-template='/select' data-placeholder='Choose discovery' bs-options='discovery.value as discovery.label for discovery in discoveries' bs-select)
span.caret
span.input-group-addon
- i(class=['fa', 'fa-repeat'] ng-click='revert(); edit.discovery = false')
- i(class=['fa', 'fa-save'] ng-click='submit(); edit.discovery = false' style='margin-left: 10px;')
- td(data-title="'Delete'" class=['col-sm-1'])
+ i(class=['fa', 'fa-repeat'] ng-click='revert();')
+ i(class=['fa', 'fa-save'] ng-click='submit();' style='margin-left: 10px;')
+ td.col-sm-1(data-title="'Delete'")
center
span(type='button' ng-click='delete(cluster)')
i(class=['fa', 'fa-remove'])
\ No newline at end of file