ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-2347 WIP Rework demo for load metadata.
Date Wed, 13 Jan 2016 16:43:09 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 84c5e8f7f -> 15686e9f0


IGNITE-2347 WIP Rework demo for load metadata.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/15686e9f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/15686e9f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/15686e9f

Branch: refs/heads/ignite-843-rc2
Commit: 15686e9f035af09bf599df4e0cd88106fabb78e0
Parents: 84c5e8f
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Wed Jan 13 23:42:59 2016 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Wed Jan 13 23:42:59 2016 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    | 1024 +++++++++---------
 .../main/js/controllers/metadata-controller.js  |   52 +-
 .../src/main/js/routes/metadata.js              |   31 +
 .../main/js/views/configuration/metadata.jade   |    2 +-
 4 files changed, 572 insertions(+), 537 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/15686e9f/modules/control-center-web/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/caches-controller.js b/modules/control-center-web/src/main/js/controllers/caches-controller.js
index 1f7011b..8a24167 100644
--- a/modules/control-center-web/src/main/js/controllers/caches-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js
@@ -19,502 +19,523 @@
 consoleModule.controller('cachesController', [
     '$scope', '$state', '$controller', '$filter', '$http', '$timeout', '$common', '$focus', '$confirm', '$clone', '$table', '$preview', '$loading', '$unsavedChangesGuard',
     function ($scope, $state, $controller, $filter, $http, $timeout, $common, $focus, $confirm, $clone, $table, $preview, $loading, $unsavedChangesGuard) {
-            $unsavedChangesGuard.install($scope);
+        $unsavedChangesGuard.install($scope);
 
-            // Initialize the super class and extend it.
-            angular.extend(this, $controller('save-remove', {$scope: $scope}));
+        // Initialize the super class and extend it.
+        angular.extend(this, $controller('save-remove', {$scope: $scope}));
 
-            $scope.ui = $common.formUI();
-            $scope.selectedItemWatchGuard = false;
+        $scope.ui = $common.formUI();
+        $scope.selectedItemWatchGuard = false;
 
-            $scope.joinTip = $common.joinTip;
-            $scope.getModel = $common.getModel;
-            $scope.javaBuildInClasses = $common.javaBuildInClasses;
-            $scope.compactJavaName = $common.compactJavaName;
-            $scope.widthIsSufficient = $common.widthIsSufficient;
-            $scope.saveBtnTipText = $common.saveBtnTipText;
-            $scope.panelExpanded = $common.panelExpanded;
+        $scope.joinTip = $common.joinTip;
+        $scope.getModel = $common.getModel;
+        $scope.javaBuildInClasses = $common.javaBuildInClasses;
+        $scope.compactJavaName = $common.compactJavaName;
+        $scope.widthIsSufficient = $common.widthIsSufficient;
+        $scope.saveBtnTipText = $common.saveBtnTipText;
+        $scope.panelExpanded = $common.panelExpanded;
 
-            $scope.tableVisibleRow = $table.tableVisibleRow;
+        $scope.tableVisibleRow = $table.tableVisibleRow;
 
-            $scope.tableSave = function (field, index, stopEdit) {
-                switch (field.type) {
-                    case 'table-simple':
-                        if ($table.tableSimpleSaveVisible(field, index))
-                            return $table.tableSimpleSave($scope.tableSimpleValid, $scope.backupItem, field, index, stopEdit);
+        $scope.tableSave = function (field, index, stopEdit) {
+            switch (field.type) {
+                case 'table-simple':
+                    if ($table.tableSimpleSaveVisible(field, index))
+                        return $table.tableSimpleSave($scope.tableSimpleValid, $scope.backupItem, field, index, stopEdit);
 
-                        break;
+                    break;
 
-                    case 'indexedTypes':
-                        if ($table.tablePairSaveVisible(field, index))
-                            return $table.tablePairSave($scope.tablePairValid, $scope.backupItem, field, index, stopEdit);
+                case 'indexedTypes':
+                    if ($table.tablePairSaveVisible(field, index))
+                        return $table.tablePairSave($scope.tablePairValid, $scope.backupItem, field, index, stopEdit);
 
-                        break;
-                }
+                    break;
+            }
 
-                return true;
-            };
+            return true;
+        };
 
-            $scope.tableReset = function (save) {
-                var field = $table.tableField();
+        $scope.tableReset = function (save) {
+            var field = $table.tableField();
 
-                if (!save || !$common.isDefined(field) || $scope.tableSave(field, $table.tableEditedRowIndex(), true)) {
-                    $table.tableReset();
+            if (!save || !$common.isDefined(field) || $scope.tableSave(field, $table.tableEditedRowIndex(), true)) {
+                $table.tableReset();
 
-                    return true;
-                }
+                return true;
+            }
 
-                return false;
-            };
+            return false;
+        };
 
-            $scope.tableNewItem = function (field) {
-                if ($scope.tableReset(true))
-                    $table.tableNewItem(field);
-            };
+        $scope.tableNewItem = function (field) {
+            if ($scope.tableReset(true))
+                $table.tableNewItem(field);
+        };
 
-            $scope.tableNewItemActive = $table.tableNewItemActive;
+        $scope.tableNewItemActive = $table.tableNewItemActive;
 
-            $scope.tableStartEdit = function (item, field, index) {
-                if ($scope.tableReset(true))
-                    $table.tableStartEdit(item, field, index);
-            };
+        $scope.tableStartEdit = function (item, field, index) {
+            if ($scope.tableReset(true))
+                $table.tableStartEdit(item, field, index);
+        };
 
-            $scope.tableEditing = $table.tableEditing;
+        $scope.tableEditing = $table.tableEditing;
 
-            $scope.tableRemove = function (item, field, index) {
-                if ($scope.tableReset(true))
-                    $table.tableRemove(item, field, index);
-            };
+        $scope.tableRemove = function (item, field, index) {
+            if ($scope.tableReset(true))
+                $table.tableRemove(item, field, index);
+        };
 
-            $scope.tableSimpleSave = $table.tableSimpleSave;
-            $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
+        $scope.tableSimpleSave = $table.tableSimpleSave;
+        $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
 
-            $scope.tableSimpleUp = function (item, field, index) {
-                if ($scope.tableReset(true))
-                    $table.tableSimpleUp(item, field, index);
-            };
+        $scope.tableSimpleUp = function (item, field, index) {
+            if ($scope.tableReset(true))
+                $table.tableSimpleUp(item, field, index);
+        };
 
-            $scope.tableSimpleDown = function (item, field, index) {
-                if ($scope.tableReset(true))
-                    $table.tableSimpleDown(item, field, index);
-            };
+        $scope.tableSimpleDown = function (item, field, index) {
+            if ($scope.tableReset(true))
+                $table.tableSimpleDown(item, field, index);
+        };
 
-            $scope.tableSimpleDownVisible = $table.tableSimpleDownVisible;
+        $scope.tableSimpleDownVisible = $table.tableSimpleDownVisible;
 
-            $scope.tablePairSave = $table.tablePairSave;
-            $scope.tablePairSaveVisible = $table.tablePairSaveVisible;
+        $scope.tablePairSave = $table.tablePairSave;
+        $scope.tablePairSaveVisible = $table.tablePairSaveVisible;
 
-            $scope.tableEditedRowIndex = $table.tableEditedRowIndex;
+        $scope.tableEditedRowIndex = $table.tableEditedRowIndex;
 
-            var previews = [];
+        var previews = [];
 
-            $scope.previewInit = function (preview) {
-                previews.push(preview);
+        $scope.previewInit = function (preview) {
+            previews.push(preview);
 
-                $preview.previewInit(preview);
-            };
+            $preview.previewInit(preview);
+        };
 
-            $scope.previewChanged = $preview.previewChanged;
+        $scope.previewChanged = $preview.previewChanged;
 
-            $scope.hidePopover = $common.hidePopover;
+        $scope.hidePopover = $common.hidePopover;
 
-            var showPopoverMessage = $common.showPopoverMessage;
+        var showPopoverMessage = $common.showPopoverMessage;
 
-            $scope.atomicities = $common.mkOptions(['ATOMIC', 'TRANSACTIONAL']);
+        $scope.atomicities = $common.mkOptions(['ATOMIC', 'TRANSACTIONAL']);
 
-            $scope.cacheModes = $common.mkOptions(['PARTITIONED', 'REPLICATED', 'LOCAL']);
+        $scope.cacheModes = $common.mkOptions(['PARTITIONED', 'REPLICATED', 'LOCAL']);
 
-            $scope.atomicWriteOrderModes = $common.mkOptions(['CLOCK', 'PRIMARY']);
+        $scope.atomicWriteOrderModes = $common.mkOptions(['CLOCK', 'PRIMARY']);
 
-            $scope.writeSynchronizationMode = $common.mkOptions(['FULL_SYNC', 'FULL_ASYNC', 'PRIMARY_SYNC']);
+        $scope.writeSynchronizationMode = $common.mkOptions(['FULL_SYNC', 'FULL_ASYNC', 'PRIMARY_SYNC']);
 
-            $scope.memoryModes = $common.mkOptions(['ONHEAP_TIERED', 'OFFHEAP_TIERED', 'OFFHEAP_VALUES']);
+        $scope.memoryModes = $common.mkOptions(['ONHEAP_TIERED', 'OFFHEAP_TIERED', 'OFFHEAP_VALUES']);
 
-            $scope.evictionPolicies = [
-                {value: 'LRU', label: 'LRU'},
-                {value: 'FIFO', label: 'FIFO'},
-                {value: 'SORTED', label: 'Sorted'},
-                {value: undefined, label: 'Not set'}
-            ];
+        $scope.evictionPolicies = [
+            {value: 'LRU', label: 'LRU'},
+            {value: 'FIFO', label: 'FIFO'},
+            {value: 'SORTED', label: 'Sorted'},
+            {value: undefined, label: 'Not set'}
+        ];
 
-            $scope.rebalanceModes = $common.mkOptions(['SYNC', 'ASYNC', 'NONE']);
+        $scope.rebalanceModes = $common.mkOptions(['SYNC', 'ASYNC', 'NONE']);
 
-            $scope.cacheStoreFactories = [
-                {value: 'CacheJdbcPojoStoreFactory', label: 'JDBC POJO store factory'},
-                {value: 'CacheJdbcBlobStoreFactory', label: 'JDBC BLOB store factory'},
-                {value: 'CacheHibernateBlobStoreFactory', label: 'Hibernate BLOB store factory'},
-                {value: undefined, label: 'Not set'}
-            ];
+        $scope.cacheStoreFactories = [
+            {value: 'CacheJdbcPojoStoreFactory', label: 'JDBC POJO store factory'},
+            {value: 'CacheJdbcBlobStoreFactory', label: 'JDBC BLOB store factory'},
+            {value: 'CacheHibernateBlobStoreFactory', label: 'Hibernate BLOB store factory'},
+            {value: undefined, label: 'Not set'}
+        ];
 
-            $scope.jdbcBlobStoreConnections = [
-                {value: 'URL', label: 'URL'},
-                {value: 'DataSource', label: 'Data source'}
-            ];
+        $scope.jdbcBlobStoreConnections = [
+            {value: 'URL', label: 'URL'},
+            {value: 'DataSource', label: 'Data source'}
+        ];
 
-            $scope.cacheStoreJdbcDialects = [
-                {value: 'Generic', label: 'Generic JDBC'},
-                {value: 'Oracle', label: 'Oracle'},
-                {value: 'DB2', label: 'IBM DB2'},
-                {value: 'SQLServer', label: 'Microsoft SQL Server'},
-                {value: 'MySQL', label: 'MySQL'},
-                {value: 'PostgreSQL', label: 'PostgreSQL'},
-                {value: 'H2', label: 'H2 database'}
-            ];
+        $scope.cacheStoreJdbcDialects = [
+            {value: 'Generic', label: 'Generic JDBC'},
+            {value: 'Oracle', label: 'Oracle'},
+            {value: 'DB2', label: 'IBM DB2'},
+            {value: 'SQLServer', label: 'Microsoft SQL Server'},
+            {value: 'MySQL', label: 'MySQL'},
+            {value: 'PostgreSQL', label: 'PostgreSQL'},
+            {value: 'H2', label: 'H2 database'}
+        ];
 
-            $scope.toggleExpanded = function () {
-                $scope.ui.expanded = !$scope.ui.expanded;
+        $scope.toggleExpanded = function () {
+            $scope.ui.expanded = !$scope.ui.expanded;
 
-                $common.hidePopover();
-            };
+            $common.hidePopover();
+        };
 
-            $scope.panels = {activePanels: [0]};
-
-            $scope.general = [];
-            $scope.advanced = [];
-            $scope.caches = [];
-            $scope.metadatas = [];
-
-            $scope.preview = {
-                general: {xml: '', java: '', allDefaults: true},
-                memory: {xml: '', java: '', allDefaults: true},
-                query: {xml: '', java: '', allDefaults: true},
-                store: {xml: '', java: '', allDefaults: true},
-                concurrency: {xml: '', java: '', allDefaults: true},
-                rebalance: {xml: '', java: '', allDefaults: true},
-                serverNearCache: {xml: '', java: '', allDefaults: true},
-                statistics: {xml: '', java: '', allDefaults: true}
-            };
+        $scope.panels = {activePanels: [0]};
 
-            function _cacheLbl () {
-                return this.name + ', ' + _.result(_.find($scope.cacheModes, {value: this.cacheMode}), 'label') + ', ' + _.result(_.find($scope.atomicities, {value: this.atomicityMode}), 'label');
-            }
+        $scope.general = [];
+        $scope.advanced = [];
+        $scope.caches = [];
+        $scope.metadatas = [];
 
-            $scope.required = function (field) {
-                var backupItem = $scope.backupItem;
+        $scope.preview = {
+            general: {xml: '', java: '', allDefaults: true},
+            memory: {xml: '', java: '', allDefaults: true},
+            query: {xml: '', java: '', allDefaults: true},
+            store: {xml: '', java: '', allDefaults: true},
+            concurrency: {xml: '', java: '', allDefaults: true},
+            rebalance: {xml: '', java: '', allDefaults: true},
+            serverNearCache: {xml: '', java: '', allDefaults: true},
+            statistics: {xml: '', java: '', allDefaults: true}
+        };
 
-                if (backupItem) {
-                    var model = $common.isDefined(field.path) ? field.path + '.' + field.model : field.model;
+        function _cacheLbl() {
+            return this.name + ', ' + _.result(_.find($scope.cacheModes, {value: this.cacheMode}), 'label') + ', ' + _.result(_.find($scope.atomicities, {value: this.atomicityMode}), 'label');
+        }
 
-                    var memoryMode = backupItem.memoryMode;
+        $scope.required = function (field) {
+            var backupItem = $scope.backupItem;
 
-                    var onHeapTired = memoryMode === 'ONHEAP_TIERED';
-                    var offHeapTired = memoryMode === 'OFFHEAP_TIERED';
+            if (backupItem) {
+                var model = $common.isDefined(field.path) ? field.path + '.' + field.model : field.model;
 
-                    var offHeapMaxMemory = backupItem.offHeapMaxMemory;
+                var memoryMode = backupItem.memoryMode;
 
-                    if (model === 'offHeapMaxMemory' && offHeapTired)
-                        return true;
+                var onHeapTired = memoryMode === 'ONHEAP_TIERED';
+                var offHeapTired = memoryMode === 'OFFHEAP_TIERED';
 
-                    if (model === 'evictionPolicy.kind' && onHeapTired)
-                        return backupItem.swapEnabled || ($common.isDefined(offHeapMaxMemory) && offHeapMaxMemory >= 0);
-                }
+                var offHeapMaxMemory = backupItem.offHeapMaxMemory;
 
-                return false;
-            };
+                if (model === 'offHeapMaxMemory' && offHeapTired)
+                    return true;
 
-            $scope.tableSimpleValid = function (item, field, fx, index) {
-                var model;
+                if (model === 'evictionPolicy.kind' && onHeapTired)
+                    return backupItem.swapEnabled || ($common.isDefined(offHeapMaxMemory) && offHeapMaxMemory >= 0);
+            }
 
-                switch (field.model) {
-                    case 'hibernateProperties':
-                        if (fx.indexOf('=') < 0)
-                            return showPopoverMessage(null, null, $table.tableFieldId(index, 'HibProp'), 'Property should be present in format key=value!');
+            return false;
+        };
 
-                        model = item.cacheStoreFactory.CacheHibernateBlobStoreFactory[field.model];
+        $scope.tableSimpleValid = function (item, field, fx, index) {
+            var model;
 
-                        var key = fx.split('=')[0];
+            switch (field.model) {
+                case 'hibernateProperties':
+                    if (fx.indexOf('=') < 0)
+                        return showPopoverMessage(null, null, $table.tableFieldId(index, 'HibProp'), 'Property should be present in format key=value!');
 
-                        var exist = false;
+                    model = item.cacheStoreFactory.CacheHibernateBlobStoreFactory[field.model];
 
-                        if ($common.isDefined(model)) {
-                            model.forEach(function (val, ix) {
-                                if (ix !== index && val.split('=')[0] === key)
-                                    exist = true;
-                            });
-                        }
+                    var key = fx.split('=')[0];
 
-                        if (exist)
-                            return showPopoverMessage(null, null, $table.tableFieldId(index, 'HibProp'), 'Property with such name already exists!');
+                    var exist = false;
 
-                        break;
+                    if ($common.isDefined(model)) {
+                        model.forEach(function (val, ix) {
+                            if (ix !== index && val.split('=')[0] === key)
+                                exist = true;
+                        });
+                    }
 
-                    case 'sqlFunctionClasses':
-                        if (!$common.isValidJavaClass('SQL function', fx, false, $table.tableFieldId(index, 'SqlFx')))
-                            return $table.tableFocusInvalidField(index, 'SqlFx');
+                    if (exist)
+                        return showPopoverMessage(null, null, $table.tableFieldId(index, 'HibProp'), 'Property with such name already exists!');
 
-                        model = item[field.model];
+                    break;
 
-                        if ($common.isDefined(model)) {
-                            var idx = _.indexOf(model, fx);
+                case 'sqlFunctionClasses':
+                    if (!$common.isValidJavaClass('SQL function', fx, false, $table.tableFieldId(index, 'SqlFx')))
+                        return $table.tableFocusInvalidField(index, 'SqlFx');
 
-                            // Found duplicate.
-                            if (idx >= 0 && idx !== index)
-                                return showPopoverMessage(null, null, $table.tableFieldId(index, 'SqlFx'), 'SQL function with such class name already exists!');
-                        }
-                }
+                    model = item[field.model];
 
-                return true;
-            };
+                    if ($common.isDefined(model)) {
+                        var idx = _.indexOf(model, fx);
 
-            $scope.tablePairValid = function (item, field, index) {
-                var pairValue = $table.tablePairValue(field, index);
+                        // Found duplicate.
+                        if (idx >= 0 && idx !== index)
+                            return showPopoverMessage(null, null, $table.tableFieldId(index, 'SqlFx'), 'SQL function with such class name already exists!');
+                    }
+            }
 
-                if (!$common.isValidJavaClass('Indexed type key', pairValue.key, true, $table.tableFieldId(index, 'KeyIndexedType')))
-                    return $table.tableFocusInvalidField(index, 'KeyIndexedType');
+            return true;
+        };
 
-                if (!$common.isValidJavaClass('Indexed type value', pairValue.value, true, $table.tableFieldId(index, 'ValueIndexedType')))
-                    return $table.tableFocusInvalidField(index, 'ValueIndexedType');
+        $scope.tablePairValid = function (item, field, index) {
+            var pairValue = $table.tablePairValue(field, index);
 
-                var model = item[field.model];
+            if (!$common.isValidJavaClass('Indexed type key', pairValue.key, true, $table.tableFieldId(index, 'KeyIndexedType')))
+                return $table.tableFocusInvalidField(index, 'KeyIndexedType');
 
-                if ($common.isDefined(model)) {
-                    var idx = _.findIndex(model, function (pair) {
-                        return pair.keyClass === pairValue.key && pair.valueClass === pairValue.value;
-                    });
+            if (!$common.isValidJavaClass('Indexed type value', pairValue.value, true, $table.tableFieldId(index, 'ValueIndexedType')))
+                return $table.tableFocusInvalidField(index, 'ValueIndexedType');
 
-                    // Found duplicate.
-                    if (idx >= 0 && idx !== index)
-                        return showPopoverMessage(null, null, $table.tableFieldId(index, 'ValueIndexedType'), 'Indexed type with such key and value classes already exists!');
-                }
+            var model = item[field.model];
 
-                return true;
-            };
+            if ($common.isDefined(model)) {
+                var idx = _.findIndex(model, function (pair) {
+                    return pair.keyClass === pairValue.key && pair.valueClass === pairValue.value;
+                });
 
-            function selectFirstItem() {
-                if ($scope.caches.length > 0)
-                    $scope.selectItem($scope.caches[0]);
+                // Found duplicate.
+                if (idx >= 0 && idx !== index)
+                    return showPopoverMessage(null, null, $table.tableFieldId(index, 'ValueIndexedType'), 'Indexed type with such key and value classes already exists!');
             }
 
-            function cacheMetadatas(item) {
-                return _.reduce($scope.metadatas, function (memo, meta) {
-                    if (item && _.contains(item.metadatas, meta.value)) {
-                        memo.push(meta.meta);
-                    }
+            return true;
+        };
 
-                    return memo;
-                }, []);
-            }
+        function selectFirstItem() {
+            if ($scope.caches.length > 0)
+                $scope.selectItem($scope.caches[0]);
+        }
 
-            $loading.start('loadingCachesScreen');
+        function cacheMetadatas(item) {
+            return _.reduce($scope.metadatas, function (memo, meta) {
+                if (item && _.contains(item.metadatas, meta.value)) {
+                    memo.push(meta.meta);
+                }
 
-            // When landing on the page, get caches and show them.
-            $http.post('/api/v1/configuration/caches/list')
-                .success(function (data) {
-                    var validFilter = $filter('metadatasValidation');
+                return memo;
+            }, []);
+        }
 
-                    $scope.spaces = data.spaces;
+        $loading.start('loadingCachesScreen');
 
-                    data.caches.forEach(function (cache) {
-                        Object.defineProperty(cache, 'label', {
-                            get: _cacheLbl
-                        });
+        // When landing on the page, get caches and show them.
+        $http.post('/api/v1/configuration/caches/list')
+            .success(function (data) {
+                var validFilter = $filter('metadatasValidation');
+
+                $scope.spaces = data.spaces;
+
+                data.caches.forEach(function (cache) {
+                    Object.defineProperty(cache, 'label', {
+                        get: _cacheLbl
                     });
+                });
 
-                    $scope.caches = data.caches;
-                    $scope.clusters = data.clusters;
-                    $scope.metadatas = _.sortBy(_.map(validFilter(data.metadatas, true, false), function (meta) {
-                        return {value: meta._id, label: meta.valueType, kind: meta.kind, meta: meta};
-                    }), 'label');
+                $scope.caches = data.caches;
+                $scope.clusters = data.clusters;
+                $scope.metadatas = _.sortBy(_.map(validFilter(data.metadatas, true, false), function (meta) {
+                    return {value: meta._id, label: meta.valueType, kind: meta.kind, meta: meta};
+                }), 'label');
 
-                    // Load page descriptor.
-                    $http.get('/models/caches.json')
-                        .success(function (data) {
-                            $scope.screenTip = data.screenTip;
-                            $scope.moreInfo = data.moreInfo;
-                            $scope.general = data.general;
-                            $scope.advanced = data.advanced;
+                // Load page descriptor.
+                $http.get('/models/caches.json')
+                    .success(function (data) {
+                        $scope.screenTip = data.screenTip;
+                        $scope.moreInfo = data.moreInfo;
+                        $scope.general = data.general;
+                        $scope.advanced = data.advanced;
 
-                            $scope.ui.addGroups(data.general, data.advanced);
+                        $scope.ui.addGroups(data.general, data.advanced);
 
-                            if ($common.getQueryVariable('new'))
-                                $scope.createItem($common.getQueryVariable('id'));
-                            else {
-                                var lastSelectedCache = angular.fromJson(sessionStorage.lastSelectedCache);
+                        if ($common.getQueryVariable('new'))
+                            $scope.createItem($common.getQueryVariable('id'));
+                        else {
+                            var lastSelectedCache = angular.fromJson(sessionStorage.lastSelectedCache);
 
-                                if (lastSelectedCache) {
-                                    var idx = _.findIndex($scope.caches, function (cache) {
-                                        return cache._id === lastSelectedCache;
-                                    });
+                            if (lastSelectedCache) {
+                                var idx = _.findIndex($scope.caches, function (cache) {
+                                    return cache._id === lastSelectedCache;
+                                });
 
-                                    if (idx >= 0)
-                                        $scope.selectItem($scope.caches[idx]);
-                                    else {
-                                        sessionStorage.removeItem('lastSelectedCache');
+                                if (idx >= 0)
+                                    $scope.selectItem($scope.caches[idx]);
+                                else {
+                                    sessionStorage.removeItem('lastSelectedCache');
 
-                                        selectFirstItem();
-                                    }
-                                }
-                                else
                                     selectFirstItem();
+                                }
                             }
+                            else
+                                selectFirstItem();
+                        }
 
-                            $scope.$watch('backupItem', function (val) {
-                                if (val) {
-                                    var srcItem = $scope.selectedItem ? $scope.selectedItem : prepareNewItem();
-
-                                    $scope.ui.checkDirty(val, srcItem);
+                        $scope.$watch('backupItem', function (val) {
+                            if (val) {
+                                var srcItem = $scope.selectedItem ? $scope.selectedItem : prepareNewItem();
 
-                                    var metas = cacheMetadatas(val);
-                                    var varName = $commonUtils.toJavaName('cache', val.name);
+                                $scope.ui.checkDirty(val, srcItem);
 
-                                    $scope.preview.general.xml = $generatorXml.cacheMetadatas(metas, $generatorXml.cacheGeneral(val)).asString();
-                                    $scope.preview.general.java = $generatorJava.cacheMetadatas(metas, varName, $generatorJava.cacheGeneral(val, varName)).asString();
-                                    $scope.preview.general.allDefaults = $common.isEmptyString($scope.preview.general.xml);
+                                var metas = cacheMetadatas(val);
+                                var varName = $commonUtils.toJavaName('cache', val.name);
 
-                                    $scope.preview.memory.xml = $generatorXml.cacheMemory(val).asString();
-                                    $scope.preview.memory.java = $generatorJava.cacheMemory(val, varName).asString();
-                                    $scope.preview.memory.allDefaults = $common.isEmptyString($scope.preview.memory.xml);
+                                $scope.preview.general.xml = $generatorXml.cacheMetadatas(metas, $generatorXml.cacheGeneral(val)).asString();
+                                $scope.preview.general.java = $generatorJava.cacheMetadatas(metas, varName, $generatorJava.cacheGeneral(val, varName)).asString();
+                                $scope.preview.general.allDefaults = $common.isEmptyString($scope.preview.general.xml);
 
-                                    $scope.preview.query.xml = $generatorXml.cacheQuery(val).asString();
-                                    $scope.preview.query.java = $generatorJava.cacheQuery(val, varName).asString();
-                                    $scope.preview.query.allDefaults = $common.isEmptyString($scope.preview.query.xml);
+                                $scope.preview.memory.xml = $generatorXml.cacheMemory(val).asString();
+                                $scope.preview.memory.java = $generatorJava.cacheMemory(val, varName).asString();
+                                $scope.preview.memory.allDefaults = $common.isEmptyString($scope.preview.memory.xml);
 
-                                    var storeFactory = $generatorXml.cacheStore(val, metas);
+                                $scope.preview.query.xml = $generatorXml.cacheQuery(val).asString();
+                                $scope.preview.query.java = $generatorJava.cacheQuery(val, varName).asString();
+                                $scope.preview.query.allDefaults = $common.isEmptyString($scope.preview.query.xml);
 
-                                    $scope.preview.store.xml = $generatorXml.generateDataSources(storeFactory.datasources).asString() + storeFactory.asString();
-                                    $scope.preview.store.java = $generatorJava.cacheStore(val, metas, varName).asString();
-                                    $scope.preview.store.allDefaults = $common.isEmptyString($scope.preview.store.xml);
+                                var storeFactory = $generatorXml.cacheStore(val, metas);
 
-                                    $scope.preview.concurrency.xml = $generatorXml.cacheConcurrency(val).asString();
-                                    $scope.preview.concurrency.java = $generatorJava.cacheConcurrency(val, varName).asString();
-                                    $scope.preview.concurrency.allDefaults = $common.isEmptyString($scope.preview.concurrency.xml);
+                                $scope.preview.store.xml = $generatorXml.generateDataSources(storeFactory.datasources).asString() + storeFactory.asString();
+                                $scope.preview.store.java = $generatorJava.cacheStore(val, metas, varName).asString();
+                                $scope.preview.store.allDefaults = $common.isEmptyString($scope.preview.store.xml);
 
-                                    $scope.preview.rebalance.xml = $generatorXml.cacheRebalance(val).asString();
-                                    $scope.preview.rebalance.java = $generatorJava.cacheRebalance(val, varName).asString();
-                                    $scope.preview.rebalance.allDefaults = $common.isEmptyString($scope.preview.rebalance.xml);
+                                $scope.preview.concurrency.xml = $generatorXml.cacheConcurrency(val).asString();
+                                $scope.preview.concurrency.java = $generatorJava.cacheConcurrency(val, varName).asString();
+                                $scope.preview.concurrency.allDefaults = $common.isEmptyString($scope.preview.concurrency.xml);
 
-                                    $scope.preview.serverNearCache.xml = $generatorXml.cacheServerNearCache(val).asString();
-                                    $scope.preview.serverNearCache.java = $generatorJava.cacheServerNearCache(val, varName).asString();
-                                    $scope.preview.serverNearCache.allDefaults = $common.isEmptyString($scope.preview.serverNearCache.xml);
+                                $scope.preview.rebalance.xml = $generatorXml.cacheRebalance(val).asString();
+                                $scope.preview.rebalance.java = $generatorJava.cacheRebalance(val, varName).asString();
+                                $scope.preview.rebalance.allDefaults = $common.isEmptyString($scope.preview.rebalance.xml);
 
-                                    $scope.preview.statistics.xml = $generatorXml.cacheStatistics(val).asString();
-                                    $scope.preview.statistics.java = $generatorJava.cacheStatistics(val, varName).asString();
-                                    $scope.preview.statistics.allDefaults = $common.isEmptyString($scope.preview.statistics.xml);
-                                }
-                            }, true);
+                                $scope.preview.serverNearCache.xml = $generatorXml.cacheServerNearCache(val).asString();
+                                $scope.preview.serverNearCache.java = $generatorJava.cacheServerNearCache(val, varName).asString();
+                                $scope.preview.serverNearCache.allDefaults = $common.isEmptyString($scope.preview.serverNearCache.xml);
 
-                            $scope.$watchCollection('backupItem.metadatas', function (val) {
-                                if ($scope.selectedItemWatchGuard)
-                                    $scope.selectedItemWatchGuard = false;
-                                else {
-                                    var item = $scope.backupItem;
+                                $scope.preview.statistics.xml = $generatorXml.cacheStatistics(val).asString();
+                                $scope.preview.statistics.java = $generatorJava.cacheStatistics(val, varName).asString();
+                                $scope.preview.statistics.allDefaults = $common.isEmptyString($scope.preview.statistics.xml);
+                            }
+                        }, true);
 
-                                    var cacheStoreFactory = $common.isDefined(item) &&
-                                        $common.isDefined(item.cacheStoreFactory) &&
-                                        $common.isDefined(item.cacheStoreFactory.kind);
+                        $scope.$watchCollection('backupItem.metadatas', function (val) {
+                            if ($scope.selectedItemWatchGuard)
+                                $scope.selectedItemWatchGuard = false;
+                            else {
+                                var item = $scope.backupItem;
 
-                                    if (val && !cacheStoreFactory) {
-                                        if (_.findIndex(cacheMetadatas(item), $common.metadataForStoreConfigured) >= 0) {
-                                            item.cacheStoreFactory.kind = 'CacheJdbcPojoStoreFactory';
+                                var cacheStoreFactory = $common.isDefined(item) &&
+                                    $common.isDefined(item.cacheStoreFactory) &&
+                                    $common.isDefined(item.cacheStoreFactory.kind);
 
-                                            if (!item.readThrough && !item.writeThrough) {
-                                                item.readThrough = true;
-                                                item.writeThrough = true;
-                                            }
+                                if (val && !cacheStoreFactory) {
+                                    if (_.findIndex(cacheMetadatas(item), $common.metadataForStoreConfigured) >= 0) {
+                                        item.cacheStoreFactory.kind = 'CacheJdbcPojoStoreFactory';
 
-                                            $timeout(function () {
-                                                $common.ensureActivePanel($scope.panels, 'store');
-                                            });
+                                        if (!item.readThrough && !item.writeThrough) {
+                                            item.readThrough = true;
+                                            item.writeThrough = true;
                                         }
+
+                                        $timeout(function () {
+                                            $common.ensureActivePanel($scope.panels, 'store');
+                                        });
                                     }
                                 }
-                            });
-                        })
-                        .error(function (errMsg) {
-                            $common.showError(errMsg);
+                            }
                         });
-                })
-                .error(function (errMsg) {
-                    $common.showError(errMsg);
-                })
-                .finally(function () {
-                    $scope.ui.ready = true;
-                    $loading.finish('loadingCachesScreen');
-                });
-
-            $scope.selectItem = function (item, backup) {
-                function selectItem() {
-                    $table.tableReset();
-
-                    $scope.selectedItemWatchGuard = true;
-                    $scope.selectedItem = angular.copy(item);
-
-                    try {
-                        if (item)
-                            sessionStorage.lastSelectedCache = angular.toJson(item._id);
-                        else
-                            sessionStorage.removeItem('lastSelectedCache');
-                    }
-                    catch (error) { }
-
-                    _.forEach(previews, function(preview) {
-                        preview.attractAttention = false;
+                    })
+                    .error(function (errMsg) {
+                        $common.showError(errMsg);
                     });
+            })
+            .error(function (errMsg) {
+                $common.showError(errMsg);
+            })
+            .finally(function () {
+                $scope.ui.ready = true;
+                $loading.finish('loadingCachesScreen');
+            });
+
+        $scope.selectItem = function (item, backup) {
+            function selectItem() {
+                $table.tableReset();
 
-                    if (backup)
-                        $scope.backupItem = backup;
-                    else if (item)
-                        $scope.backupItem = angular.copy(item);
-                    else
-                        $scope.backupItem = undefined;
+                $scope.selectedItemWatchGuard = true;
+                $scope.selectedItem = angular.copy(item);
 
-                    if ($common.getQueryVariable('new'))
-                        $state.go('base.configuration.caches');
+                try {
+                    if (item)
+                        sessionStorage.lastSelectedCache = angular.toJson(item._id);
+                    else
+                        sessionStorage.removeItem('lastSelectedCache');
                 }
+                catch (error) { }
+
+                _.forEach(previews, function (preview) {
+                    preview.attractAttention = false;
+                });
 
-                $common.confirmUnsavedChanges($scope.ui.isDirty(), selectItem);
+                if (backup)
+                    $scope.backupItem = backup;
+                else if (item)
+                    $scope.backupItem = angular.copy(item);
+                else
+                    $scope.backupItem = undefined;
+
+                if ($common.getQueryVariable('new'))
+                    $state.go('base.configuration.caches');
+            }
 
-                $scope.ui.formTitle = $common.isDefined($scope.backupItem) && $scope.backupItem._id ?
-                    'Selected cache: ' + $scope.backupItem.name : 'New cache';
+            $common.confirmUnsavedChanges($scope.ui.isDirty(), selectItem);
+
+            $scope.ui.formTitle = $common.isDefined($scope.backupItem) && $scope.backupItem._id ?
+                'Selected cache: ' + $scope.backupItem.name : 'New cache';
+        };
+
+        function prepareNewItem(id) {
+            return {
+                space: $scope.spaces[0]._id,
+                cacheMode: 'PARTITIONED',
+                atomicityMode: 'ATOMIC',
+                readFromBackup: true,
+                copyOnRead: true,
+                clusters: id && _.find($scope.clusters, {value: id})
+                    ? [id]
+                    : _.map($scope.clusters, function (cluster) { return cluster.value; }),
+                metadatas: id && _.find($scope.metadatas, {value: id}) ? [id] : [],
+                cacheStoreFactory: {CacheJdbcBlobStoreFactory: {connectVia: 'DataSource'}},
+                get label() { return angular.bind(this, _cacheLbl)(); }
             };
+        }
 
-            function prepareNewItem(id) {
-                return {
-                    space: $scope.spaces[0]._id,
-                    cacheMode: 'PARTITIONED',
-                    atomicityMode: 'ATOMIC',
-                    readFromBackup: true,
-                    copyOnRead: true,
-                    clusters: id && _.find($scope.clusters, {value: id})
-                        ? [id]
-                        : _.map($scope.clusters, function(cluster) { return cluster.value; }),
-                    metadatas: id && _.find($scope.metadatas, {value: id}) ? [id] : [],
-                    cacheStoreFactory: {CacheJdbcBlobStoreFactory: {connectVia: 'DataSource'}},
-                    get label() { return angular.bind(this, _cacheLbl)(); }
-                };
+        // Add new cache.
+        $scope.createItem = function (id) {
+            if ($scope.tableReset(true)) {
+                $timeout(function () {
+                    $common.ensureActivePanel($scope.panels, 'general', 'cacheName');
+                });
+
+                $scope.selectItem(undefined, prepareNewItem(id));
             }
+        };
 
-            // Add new cache.
-            $scope.createItem = function (id) {
-                if ($scope.tableReset(true)) {
-                    $timeout(function () {
-                        $common.ensureActivePanel($scope.panels, 'general', 'cacheName');
-                    });
+        // Check cache logical consistency.
+        function validate(item) {
+            if ($common.isEmptyString(item.name))
+                return showPopoverMessage($scope.panels, 'general', 'cacheName', 'Name should not be empty');
 
-                    $scope.selectItem(undefined, prepareNewItem(id));
-                }
-            };
+            if (item.memoryMode === 'OFFHEAP_TIERED' && !$common.isDefined(item.offHeapMaxMemory))
+                return showPopoverMessage($scope.panels, 'memory', 'offHeapMaxMemory',
+                    'Off-heap max memory should be specified');
 
-            // Check cache logical consistency.
-            function validate(item) {
-                if ($common.isEmptyString(item.name))
-                    return showPopoverMessage($scope.panels, 'general', 'cacheName', 'Name should not be empty');
+            if (item.memoryMode === 'ONHEAP_TIERED' && item.offHeapMaxMemory > 0 && !$common.isDefined(item.evictionPolicy.kind))
+                return showPopoverMessage($scope.panels, 'memory', 'evictionPolicy', 'Eviction policy should not be configured');
 
-                if (item.memoryMode === 'OFFHEAP_TIERED' && !$common.isDefined(item.offHeapMaxMemory))
-                    return showPopoverMessage($scope.panels, 'memory', 'offHeapMaxMemory',
-                        'Off-heap max memory should be specified');
+            var cacheStoreFactorySelected = item.cacheStoreFactory && item.cacheStoreFactory.kind;
 
-                if (item.memoryMode === 'ONHEAP_TIERED' && item.offHeapMaxMemory > 0 &&
-                        !$common.isDefined(item.evictionPolicy.kind)) {
-                    return showPopoverMessage($scope.panels, 'memory', 'evictionPolicy', 'Eviction policy should not be configured');
-                }
+            if (cacheStoreFactorySelected) {
+                var storeFactory = item.cacheStoreFactory[item.cacheStoreFactory.kind];
+
+                if (item.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory') {
+                    if ($common.isEmptyString(storeFactory.dataSourceBean))
+                        return showPopoverMessage($scope.panels, 'store', 'dataSourceBean',
+                            'Data source bean name should not be empty');
 
-                var cacheStoreFactorySelected = item.cacheStoreFactory && item.cacheStoreFactory.kind;
+                    if (!$common.isValidJavaIdentifier('Data source bean', storeFactory.dataSourceBean, 'dataSourceBean', $scope.panels, 'store'))
+                        return false;
 
-                if (cacheStoreFactorySelected) {
-                    var storeFactory = item.cacheStoreFactory[item.cacheStoreFactory.kind];
+                    if (!storeFactory.dialect)
+                        return showPopoverMessage($scope.panels, 'store', 'dialect',
+                            'Dialect should not be empty');
+                }
 
-                    if (item.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory') {
+                if (item.cacheStoreFactory.kind === 'CacheJdbcBlobStoreFactory') {
+                    if (storeFactory.connectVia === 'URL') {
+                        if ($common.isEmptyString(storeFactory.connectionUrl))
+                            return showPopoverMessage($scope.panels, 'store', 'connectionUrl',
+                                'Connection URL should not be empty');
+
+                        if ($common.isEmptyString(storeFactory.user))
+                            return showPopoverMessage($scope.panels, 'store', 'user',
+                                'User should not be empty');
+                    }
+                    else {
                         if ($common.isEmptyString(storeFactory.dataSourceBean))
                             return showPopoverMessage($scope.panels, 'store', 'dataSourceBean',
                                 'Data source bean name should not be empty');
@@ -522,187 +543,164 @@ consoleModule.controller('cachesController', [
                         if (!$common.isValidJavaIdentifier('Data source bean', storeFactory.dataSourceBean, 'dataSourceBean', $scope.panels, 'store'))
                             return false;
 
-                        if (!storeFactory.dialect)
-                            return showPopoverMessage($scope.panels, 'store', 'dialect',
-                                'Dialect should not be empty');
+                        if (!storeFactory.database)
+                            return showPopoverMessage($scope.panels, 'store', 'database',
+                                'Database should not be empty');
                     }
+                }
+            }
 
-                    if (item.cacheStoreFactory.kind === 'CacheJdbcBlobStoreFactory') {
-                        if (storeFactory.connectVia === 'URL') {
-                            if ($common.isEmptyString(storeFactory.connectionUrl))
-                                return showPopoverMessage($scope.panels, 'store', 'connectionUrl',
-                                    'Connection URL should not be empty');
+            if ((item.readThrough || item.writeThrough) && !cacheStoreFactorySelected)
+                return showPopoverMessage($scope.panels, 'store', 'cacheStoreFactory',
+                    (item.readThrough ? 'Read' : 'Write') + ' through are enabled but store is not configured!');
 
-                            if ($common.isEmptyString(storeFactory.user))
-                                return showPopoverMessage($scope.panels, 'store', 'user',
-                                    'User should not be empty');
-                        }
-                        else {
-                            if ($common.isEmptyString(storeFactory.dataSourceBean))
-                                return showPopoverMessage($scope.panels, 'store', 'dataSourceBean',
-                                    'Data source bean name should not be empty');
+            if (item.writeBehindEnabled && !cacheStoreFactorySelected)
+                return showPopoverMessage($scope.panels, 'store', 'cacheStoreFactory',
+                    'Write behind enabled but store is not configured!');
 
-                            if (!$common.isValidJavaIdentifier('Data source bean', storeFactory.dataSourceBean, 'dataSourceBean', $scope.panels, 'store'))
-                                return false;
+            if (cacheStoreFactorySelected) {
+                if (!item.readThrough && !item.writeThrough)
+                    return showPopoverMessage($scope.panels, 'store', 'readThrough',
+                        'Store is configured but read/write through are not enabled!');
 
-                            if (!storeFactory.database)
-                                return showPopoverMessage($scope.panels, 'store', 'database',
-                                    'Database should not be empty');
-                        }
+                if (item.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory') {
+                    if ($common.isDefined(item.metadatas)) {
+                        var metadatas = cacheMetadatas($scope.backupItem);
+
+                        if (_.findIndex(metadatas, $common.metadataForStoreConfigured) < 0)
+                            return showPopoverMessage($scope.panels, 'general', 'metadata',
+                                'Cache with configured JDBC POJO store factory should contain at least one metadata with store configuration');
                     }
                 }
+            }
 
-                if ((item.readThrough || item.writeThrough) && !cacheStoreFactorySelected)
-                    return showPopoverMessage($scope.panels, 'store', 'cacheStoreFactory',
-                        (item.readThrough ? 'Read' : 'Write') + ' through are enabled but store is not configured!');
-
-                if (item.writeBehindEnabled && !cacheStoreFactorySelected)
-                    return showPopoverMessage($scope.panels, 'store', 'cacheStoreFactory',
-                        'Write behind enabled but store is not configured!');
+            return true;
+        }
 
-                if (cacheStoreFactorySelected) {
-                    if (!item.readThrough && !item.writeThrough)
-                        return showPopoverMessage($scope.panels, 'store', 'readThrough',
-                            'Store is configured but read/write through are not enabled!');
+        // Save cache into database.
+        function save(item) {
+            $http.post('/api/v1/configuration/caches/save', item)
+                .success(function (_id) {
+                    $scope.ui.markPristine();
 
-                    if (item.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory') {
-                        if ($common.isDefined(item.metadatas)) {
-                            var metadatas = cacheMetadatas($scope.backupItem);
+                    var idx = _.findIndex($scope.caches, function (cache) {
+                        return cache._id === _id;
+                    });
 
-                            if (_.findIndex(metadatas, $common.metadataForStoreConfigured) < 0)
-                                return showPopoverMessage($scope.panels, 'general', 'metadata',
-                                    'Cache with configured JDBC POJO store factory should contain at least one metadata with store configuration');
-                        }
+                    if (idx >= 0)
+                        angular.extend($scope.caches[idx], item);
+                    else {
+                        item._id = _id;
+                        $scope.caches.push(item);
                     }
-                }
 
-                return true;
-            }
+                    $scope.selectItem(item);
 
-            // Save cache into database.
-            function save(item) {
-                $http.post('/api/v1/configuration/caches/save', item)
-                    .success(function (_id) {
-                        $scope.ui.markPristine();
-
-                        var idx = _.findIndex($scope.caches, function (cache) {
-                            return cache._id === _id;
-                        });
+                    $common.showInfo('Cache "' + item.name + '" saved.');
+                })
+                .error(function (errMsg) {
+                    $common.showError(errMsg);
+                });
+        }
 
-                        if (idx >= 0)
-                            angular.extend($scope.caches[idx], item);
-                        else {
-                            item._id = _id;
-                            $scope.caches.push(item);
-                        }
+        // Save cache.
+        $scope.saveItem = function () {
+            if ($scope.tableReset(true)) {
 
-                        $scope.selectItem(item);
+                var item = $scope.backupItem;
 
-                        $common.showInfo('Cache "' + item.name + '" saved.');
-                    })
-                    .error(function (errMsg) {
-                        $common.showError(errMsg);
-                    });
+                if (validate(item))
+                    save(item);
             }
+        };
 
-            // Save cache.
-            $scope.saveItem = function () {
-                if ($scope.tableReset(true)) {
+        // Save cache with new name.
+        $scope.cloneItem = function () {
+            if ($scope.tableReset(true)) {
+                if (validate($scope.backupItem))
+                    $clone.confirm($scope.backupItem.name).then(function (newName) {
+                        var item = angular.copy($scope.backupItem);
 
-                    var item = $scope.backupItem;
+                        item._id = undefined;
+                        item.name = newName;
 
-                    if (validate(item))
                         save(item);
-                }
-            };
-
-            // Save cache with new name.
-            $scope.cloneItem = function () {
-                if ($scope.tableReset(true)) {
-                    if (validate($scope.backupItem))
-                        $clone.confirm($scope.backupItem.name).then(function (newName) {
-                            var item = angular.copy($scope.backupItem);
-
-                            item._id = undefined;
-                            item.name = newName;
-
-                            save(item);
-                        });
-                }
-            };
+                    });
+            }
+        };
 
-            // Remove cache from db.
-            $scope.removeItem = function () {
-                $table.tableReset();
+        // Remove cache from db.
+        $scope.removeItem = function () {
+            $table.tableReset();
 
-                var selectedItem = $scope.selectedItem;
+            var selectedItem = $scope.selectedItem;
 
-                $confirm.confirm('Are you sure you want to remove cache: "' + selectedItem.name + '"?')
-                    .then(function () {
-                            var _id = selectedItem._id;
+            $confirm.confirm('Are you sure you want to remove cache: "' + selectedItem.name + '"?')
+                .then(function () {
+                    var _id = selectedItem._id;
 
-                            $http.post('/api/v1/configuration/caches/remove', {_id: _id})
-                                .success(function () {
-                                    $common.showInfo('Cache has been removed: ' + selectedItem.name);
+                    $http.post('/api/v1/configuration/caches/remove', {_id: _id})
+                        .success(function () {
+                            $common.showInfo('Cache has been removed: ' + selectedItem.name);
 
-                                    var caches = $scope.caches;
+                            var caches = $scope.caches;
 
-                                    var idx = _.findIndex(caches, function (cache) {
-                                        return cache._id === _id;
-                                    });
+                            var idx = _.findIndex(caches, function (cache) {
+                                return cache._id === _id;
+                            });
 
-                                    if (idx >= 0) {
-                                        caches.splice(idx, 1);
+                            if (idx >= 0) {
+                                caches.splice(idx, 1);
 
-                                        if (caches.length > 0)
-                                            $scope.selectItem(caches[0]);
-                                        else
-                                            $scope.selectItem(undefined, undefined);
-                                    }
-                                })
-                                .error(function (errMsg) {
-                                    $common.showError(errMsg);
-                                });
-                    });
-            };
+                                if (caches.length > 0)
+                                    $scope.selectItem(caches[0]);
+                                else
+                                    $scope.selectItem(undefined, undefined);
+                            }
+                        })
+                        .error(function (errMsg) {
+                            $common.showError(errMsg);
+                        });
+                });
+        };
 
-            // Remove all caches from db.
-            $scope.removeAllItems = function () {
-                $table.tableReset();
+        // Remove all caches from db.
+        $scope.removeAllItems = function () {
+            $table.tableReset();
 
-                $confirm.confirm('Are you sure you want to remove all caches?')
-                    .then(function () {
-                            $http.post('/api/v1/configuration/caches/remove/all')
-                                .success(function () {
-                                    $common.showInfo('All caches have been removed');
+            $confirm.confirm('Are you sure you want to remove all caches?')
+                .then(function () {
+                    $http.post('/api/v1/configuration/caches/remove/all')
+                        .success(function () {
+                            $common.showInfo('All caches have been removed');
 
-                                    $scope.caches = [];
+                            $scope.caches = [];
 
-                                    $scope.selectItem(undefined, undefined);
-                                })
-                                .error(function (errMsg) {
-                                    $common.showError(errMsg);
-                                });
-                    });
-            };
+                            $scope.selectItem(undefined, undefined);
+                        })
+                        .error(function (errMsg) {
+                            $common.showError(errMsg);
+                        });
+                });
+        };
 
-            $scope.resetItem = function (group) {
-                var resetTo = $scope.selectedItem;
+        $scope.resetItem = function (group) {
+            var resetTo = $scope.selectedItem;
 
-                if (!$common.isDefined(resetTo))
-                    resetTo = prepareNewItem();
+            if (!$common.isDefined(resetTo))
+                resetTo = prepareNewItem();
 
-                $common.resetItem($scope.backupItem, resetTo, $scope.general, group);
-                $common.resetItem($scope.backupItem, resetTo, $scope.advanced, group);
-            };
+            $common.resetItem($scope.backupItem, resetTo, $scope.general, group);
+            $common.resetItem($scope.backupItem, resetTo, $scope.advanced, group);
+        };
 
-            $scope.resetAll = function() {
-                $table.tableReset();
+        $scope.resetAll = function () {
+            $table.tableReset();
 
-                $confirm.confirm('Are you sure you want to undo all changes for current cache?')
-                    .then(function() {
-                        $scope.backupItem = $scope.selectedItem ? angular.copy($scope.selectedItem) : prepareNewItem();
-                    });
-            };
-        }]
+            $confirm.confirm('Are you sure you want to undo all changes for current cache?')
+                .then(function () {
+                    $scope.backupItem = $scope.selectedItem ? angular.copy($scope.selectedItem) : prepareNewItem();
+                });
+        };
+    }]
 );

http://git-wip-us.apache.org/repos/asf/ignite/blob/15686e9f/modules/control-center-web/src/main/js/controllers/metadata-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/metadata-controller.js b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
index 306cec3..70bd388 100644
--- a/modules/control-center-web/src/main/js/controllers/metadata-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
@@ -32,12 +32,32 @@ consoleModule.controller('metadataController', function ($filter, $http, $timeou
         $scope.ui.generateCaches = true;
         $scope.ui.generatedCachesClusters = [];
 
-        $scope.removeDemoDropdown = [{ 'text': 'Remove Demo data', 'click': 'removeDemoItems()'}];
+        $scope.removeDemoDropdown = [{ 'text': 'Remove generated demo metadata', 'click': 'removeDemoItems()'}];
+
+        function restoreSelection() {
+            var lastSelectedMetadata = angular.fromJson(sessionStorage.lastSelectedMetadata);
+
+            if (lastSelectedMetadata) {
+                var idx = _.findIndex($scope.metadatas, function (metadata) {
+                    return metadata._id === lastSelectedMetadata;
+                });
+
+                if (idx >= 0)
+                    $scope.selectItem($scope.metadatas[idx]);
+                else {
+                    sessionStorage.removeItem('lastSelectedMetadata');
+
+                    selectFirstItem();
+                }
+            }
+            else
+                selectFirstItem();
+        }
 
         $scope.removeDemoItems = function () {
             $table.tableReset();
 
-            $confirm.confirm('Are you sure you want to remove all demo metadata and caches?')
+            $confirm.confirm('Are you sure you want to remove all generated demo metadata and caches?')
                 .then(function () {
                     $http.post('/api/v1/configuration/metadata/remove/demo')
                         .success(function () {
@@ -57,7 +77,7 @@ consoleModule.controller('metadataController', function ($filter, $http, $timeou
                                     });
                                 });
 
-                            $scope.selectItem(undefined, undefined);
+                            restoreSelection();
                         })
                         .error(function (errMsg) {
                             $common.showError(errMsg);
@@ -65,6 +85,12 @@ consoleModule.controller('metadataController', function ($filter, $http, $timeou
                 });
         };
 
+        $scope.hasDemoItems =  function () {
+            return _.findIndex($scope.metadatas, function (meta) {
+                    return meta.demo;
+                }) >= 0;
+        };
+
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
         $scope.javaBuildInClasses = $common.javaBuildInClasses;
@@ -908,26 +934,6 @@ consoleModule.controller('metadataController', function ($filter, $http, $timeou
         // When landing on the page, get metadatas and show them.
         $loading.start('loadingMetadataScreen');
 
-        function restoreSelection() {
-            var lastSelectedMetadata = angular.fromJson(sessionStorage.lastSelectedMetadata);
-
-            if (lastSelectedMetadata) {
-                var idx = _.findIndex($scope.metadatas, function (metadata) {
-                    return metadata._id === lastSelectedMetadata;
-                });
-
-                if (idx >= 0)
-                    $scope.selectItem($scope.metadatas[idx]);
-                else {
-                    sessionStorage.removeItem('lastSelectedMetadata');
-
-                    selectFirstItem();
-                }
-            }
-            else
-                selectFirstItem();
-        }
-
         $http.post('/api/v1/configuration/metadata/list')
             .success(function (data) {
                 $scope.spaces = data.spaces;

http://git-wip-us.apache.org/repos/asf/ignite/blob/15686e9f/modules/control-center-web/src/main/js/routes/metadata.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/metadata.js b/modules/control-center-web/src/main/js/routes/metadata.js
index 0d11d8d..3caf3b5 100644
--- a/modules/control-center-web/src/main/js/routes/metadata.js
+++ b/modules/control-center-web/src/main/js/routes/metadata.js
@@ -231,4 +231,35 @@ router.post('/remove/all', function (req, res) {
     });
 });
 
+/**
+ * Remove all generated demo metadata and caches.
+ */
+router.post('/remove/demo', function (req, res) {
+    var user_id = req.currentUserId();
+
+    // Get owned space and all accessed space.
+    db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function (err, spaces) {
+        if (db.processed(err, res)) {
+            var space_ids = spaces.map(function (value) {
+                return value._id;
+            });
+
+            // Remove all demo metadata.
+            db.CacheTypeMetadata.remove({$and: [{space: {$in: space_ids}}, {demo: true}]}, function (err) {
+                if (err)
+                    return res.status(500).send(err.message);
+
+                // Remove all demo caches.
+                db.Cache.remove({$and: [{space: {$in: space_ids}}, {demo: true}]}, function (err) {
+                    if (err)
+                        return res.status(500).send(err.message);
+
+                    res.sendStatus(200);
+                });
+            });
+        }
+    });
+});
+
+
 module.exports = router;

http://git-wip-us.apache.org/repos/asf/ignite/blob/15686e9f/modules/control-center-web/src/main/js/views/configuration/metadata.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/configuration/metadata.jade b/modules/control-center-web/src/main/js/views/configuration/metadata.jade
index 1c9b7ed..b518f52 100644
--- a/modules/control-center-web/src/main/js/views/configuration/metadata.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/metadata.jade
@@ -69,7 +69,7 @@ include ../includes/controls
                     button.btn.btn-primary(ng-click='showLoadMetadataModal(false)') Load from database
                 .btn-group.panel-tip-container(bs-tooltip='' data-title='Load metadata from demo database' data-placement='bottom')
                     button.btn.btn-info(ng-click='showLoadMetadataModal(true)') Load from demo database
-                        button.btn.dropdown-toggle.btn-info(id='remove-demo-dropdown' data-toggle='dropdown' data-container='body' bs-dropdown='removeDemoDropdown' data-placement='bottom-right')
+                        button.btn.dropdown-toggle.btn-info(id='remove-demo-dropdown' ng-if='hasDemoItems()' data-toggle='dropdown' data-container='body' bs-dropdown='removeDemoDropdown' data-placement='bottom-right')
                             span.caret
                 +save-remove-buttons('metadata')
                 hr


Mime
View raw message