You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/06/10 17:16:30 UTC
incubator-ignite git commit: # IGNITE-843 Wip on cache indexed types.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-843 80ba59c0d -> 577dbad67
# IGNITE-843 Wip on cache indexed types.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/577dbad6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/577dbad6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/577dbad6
Branch: refs/heads/ignite-843
Commit: 577dbad679261c93a5e294a9756134f5cca8fa5d
Parents: 80ba59c
Author: AKuznetsov <ak...@gridgain.com>
Authored: Wed Jun 10 22:16:23 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Wed Jun 10 22:16:23 2015 +0700
----------------------------------------------------------------------
.../public/javascripts/controllers/caches.js | 77 +++++++++++++++-----
.../nodejs/views/includes/controls.jade | 4 +-
.../webconfig/nodejs/views/indexedTypes.jade | 6 +-
3 files changed, 63 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/577dbad6/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/public/javascripts/controllers/caches.js b/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
index fd28c1f..1984336 100644
--- a/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
+++ b/modules/webconfig/nodejs/public/javascripts/controllers/caches.js
@@ -15,10 +15,17 @@
* limitations under the License.
*/
-configuratorModule.controller('cachesController', ['$scope', '$modal', '$http', function($scope, $modal, $http) {
+configuratorModule.controller('cachesController', ['$scope', '$modal', '$http', function ($scope, $modal, $http) {
$scope.templates = [
- {value: {mode: 'PARTITIONED', atomicityMode: 'ATOMIC',
- indexedTypes: [{keyClass: 'org.some.KeyClass', valueClass: 'org.some.ValueClass'},{keyClass: 'org.some.KeyClass2', valueClass: 'org.some.ValueClass2'}]}, label: 'Partitioned'},
+ {
+ value: {
+ mode: 'PARTITIONED', atomicityMode: 'ATOMIC',
+ indexedTypes: [{
+ keyClass: 'org.some.KeyClass',
+ valueClass: 'org.some.ValueClass'
+ }, {keyClass: 'org.some.KeyClass2', valueClass: 'org.some.ValueClass2'}]
+ }, label: 'Partitioned'
+ },
{value: {mode: 'REPLICATED', atomicityMode: 'ATOMIC'}, label: 'Replicated'},
{value: {mode: 'LOCAL', atomicityMode: 'ATOMIC'}, label: 'Local'}
];
@@ -43,7 +50,7 @@ configuratorModule.controller('cachesController', ['$scope', '$modal', '$http',
{value: 'ONHEAP_TIERED', label: 'ONHEAP_TIERED'},
{value: 'OFFHEAP_TIERED', label: 'OFFHEAP_TIERED'},
{value: 'OFFHEAP_VALUES', label: 'OFFHEAP_VALUES'}
- ];
+ ];
$scope.evictionPolicies = [
{value: 'LRU', label: 'Least Recently Used'},
@@ -62,7 +69,7 @@ configuratorModule.controller('cachesController', ['$scope', '$modal', '$http',
$scope.advanced = [];
$http.get('/form-models/caches.json')
- .success(function(data) {
+ .success(function (data) {
$scope.general = data.general;
$scope.advanced = data.advanced;
});
@@ -71,51 +78,83 @@ configuratorModule.controller('cachesController', ['$scope', '$modal', '$http',
// Create popup for indexedTypes.
var indexedTypesModal = $modal({scope: $scope, template: '/indexedTypes', show: false});
- $scope.editIndexedTypes = function(cache) {
+ $scope.editIndexedTypes = function (idx) {
+ $scope.indexedTypeIdx = idx;
+
+ console.log('Index: ' + idx);
+
+ if (idx < 0) {
+ $scope.currKeyCls = '';
+ $scope.currValCls = '';
+ }
+ else {
+ var idxType = $scope.backupItem.indexedTypes[idx];
+
+ $scope.currKeyCls = idxType.keyClass;
+ $scope.currValCls = idxType.valueClass;
+ }
+
indexedTypesModal.$promise.then(indexedTypesModal.show);
};
+ $scope.saveIndexedType = function () {
+ var idxTypes = $scope.backupItem.indexedTypes;
+
+ var idx = $scope.indexedTypeIdx;
+
+ if (idx < 0)
+ idxTypes.push({keyClass: $scope.currKeyCls, valueClass: $scope.currValCls});
+ else {
+ var idxType = idxTypes[idx];
+
+ idxType.keyClass = $scope.currKeyCls;
+ idxType.valueClass = $scope.currValCls;
+ }
+
+ indexedTypesModal.hide();
+ };
+
$scope.caches = [];
// When landing on the page, get caches and show them.
$http.get('/rest/caches')
- .success(function(data) {
+ .success(function (data) {
$scope.spaces = data.spaces;
$scope.caches = data.caches;
});
- $scope.selectItem = function(item) {
+ $scope.selectItem = function (item) {
$scope.selectedItem = item;
$scope.backupItem = angular.copy(item);
};
// Add new cache.
- $scope.createItem = function() {
+ $scope.createItem = function () {
var item = angular.copy($scope.create.template);
item.name = 'Cache ' + ($scope.caches.length + 1);
item.space = $scope.spaces[0]._id;
$http.post('/rest/caches/save', item)
- .success(function(_id) {
+ .success(function (_id) {
item._id = _id;
$scope.caches.push(item);
$scope.selectItem(item);
})
- .error(function(errorMessage) {
+ .error(function (errorMessage) {
console.log('Error: ' + errorMessage);
});
};
- $scope.removeItem = function() {
+ $scope.removeItem = function () {
var _id = $scope.selectedItem._id;
$http.post('/rest/caches/remove', {_id: _id})
- .success(function() {
- var i = _.findIndex($scope.caches, function(cache) {
+ .success(function () {
+ var i = _.findIndex($scope.caches, function (cache) {
return cache._id == _id;
});
@@ -126,18 +165,18 @@ configuratorModule.controller('cachesController', ['$scope', '$modal', '$http',
$scope.backupItem = undefined;
}
})
- .error(function(errorMessage) {
+ .error(function (errorMessage) {
console.log('Error: ' + errorMessage);
});
};
// Save cache in db.
- $scope.saveItem = function() {
+ $scope.saveItem = function () {
var item = $scope.backupItem;
$http.post('/rest/caches/save', item)
- .success(function() {
- var i = _.findIndex($scope.caches, function(cache) {
+ .success(function () {
+ var i = _.findIndex($scope.caches, function (cache) {
return cache._id == item._id;
});
@@ -146,7 +185,7 @@ configuratorModule.controller('cachesController', ['$scope', '$modal', '$http',
$scope.selectItem(item);
})
- .error(function(errorMessage) {
+ .error(function (errorMessage) {
console.log('Error: ' + errorMessage);
});
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/577dbad6/modules/webconfig/nodejs/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/views/includes/controls.jade b/modules/webconfig/nodejs/views/includes/controls.jade
index 9f76751..cdc0ca7 100644
--- a/modules/webconfig/nodejs/views/includes/controls.jade
+++ b/modules/webconfig/nodejs/views/includes/controls.jade
@@ -103,7 +103,7 @@ mixin form-row
div(ng-switch-when='indexedTypes')
div
label Indexed types: {{backupItem.indexedTypes.length}}
- button.btn.btn-primary(style='margin-left: 10px' ng-click='editIndexedTypes()') Add indexed type
+ button.btn.btn-primary(style='margin-left: 10px' ng-click='editIndexedTypes(-1)') Add indexed type
+tip
.col-sm-10.links(style='margin-left: 18px')
-var idxTypes = 'backupItem.indexedTypes'
@@ -111,6 +111,6 @@ mixin form-row
tbody
tr(ng-repeat='idxType in #{idxTypes}')
td
- a {{$index + 1}}. {{idxType.keyClass}}, {{idxType.valueClass}}
+ a(ng-click='editIndexedTypes($index)') {{$index + 1}}. {{idxType.keyClass}}, {{idxType.valueClass}}
label.fa.fa-remove(style='margin-left: 10px')
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/577dbad6/modules/webconfig/nodejs/views/indexedTypes.jade
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/views/indexedTypes.jade b/modules/webconfig/nodejs/views/indexedTypes.jade
index a968ebc..d785588 100644
--- a/modules/webconfig/nodejs/views/indexedTypes.jade
+++ b/modules/webconfig/nodejs/views/indexedTypes.jade
@@ -23,11 +23,11 @@
.form-group
label.col-sm-3.control-label Key Class:
.controls.col-sm-9
- input.form-control(type='text' required)
+ input.form-control(type='text' ng-model='currKeyCls' required)
.form-group
label.col-sm-3.control-label Value Class:
.controls.col-sm-9
- input.form-control(type='text' required)
+ input.form-control(type='text' ng-model='currValCls' required)
.modal-footer
- button.btn.btn-primary(ng-click='saveIndexedType(key, val)' ng-disabled='indexedTypeForm.$invalid') Save
+ button.btn.btn-primary(ng-click='saveIndexedType()' ng-disabled='indexedTypeForm.$invalid') Save
button.btn.btn-primary(ng-click='$hide()') Cancel