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-843 WIP linked Caches with Metadata.
Date Wed, 09 Sep 2015 03:29:00 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 211b86527 -> c53103bfc


IGNITE-843 WIP linked Caches with Metadata.


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

Branch: refs/heads/ignite-843
Commit: c53103bfceb0b60c78b4ed5356505b4fbe6affd7
Parents: 211b865
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Sep 9 10:29:18 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Sep 9 10:29:18 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    | 21 ++++-
 .../main/js/controllers/metadata-controller.js  | 90 +++++++++++++-------
 .../src/main/js/routes/caches.js                |  1 -
 3 files changed, 78 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c53103bf/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 4d5fb1c..6543f9c 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
@@ -305,8 +305,8 @@ controlCenterModule.controller('cachesController', [
                                 if (restoredSelectedItem && _.isEqual(restoredItem.clusters,
restoredSelectedItem.clusters)) {
                                     restoredItem.clusters = [];
 
-                                    _.forEach(cache.clusters, function (cache) {
-                                        restoredItem.clusters.push(cache)
+                                    _.forEach(cache.clusters, function (cluster) {
+                                        restoredItem.clusters.push(cluster)
                                     });
                                 }
                                 else {
@@ -318,6 +318,23 @@ controlCenterModule.controller('cachesController', [
                                     });
                                 }
 
+                                // Metadatas not changed by user. We should take metadatas
from server as they could be changed on Metadata screen.
+                                if (restoredSelectedItem && _.isEqual(restoredItem.metadatas,
restoredSelectedItem.metadatas)) {
+                                    restoredItem.metadatas = [];
+
+                                    _.forEach(cache.metadatas, function (meta) {
+                                        restoredItem.metadatas.push(meta)
+                                    });
+                                }
+                                else {
+                                    // Metadatas changed by user. We need to remove deleted
metadatas (if any).
+                                    restoredItem.metadatas = _.filter(restoredItem.metadatas,
function (metaId) {
+                                        return _.findIndex($scope.metadatas, function (scopeMeta)
{
+                                                return scopeMeta.value == metaId;
+                                            }) >= 0;
+                                    });
+                                }
+
                                 $scope.selectItem(cache, restoredItem, sessionStorage.cacheBackupItemChanged);
                             }
                             else

http://git-wip-us.apache.org/repos/asf/ignite/blob/c53103bf/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 2620f81..7cc3b1c 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
@@ -202,32 +202,6 @@ controlCenterModule.controller('metadataController', [
                     $scope.selectItem($scope.metadatas[0]);
             }
 
-            function setSelectedAndBackupItem(sel, backup, changed) {
-                function setSelectedAndBackupItem() {
-                    $table.tableReset();
-
-                    $scope.selectedItem = sel;
-
-                    _.forEach(previews, function(preview) {
-                        preview.attractAttention = false;
-                    });
-
-                    $scope.backupItem = backup;
-
-                    $timeout(function () {
-                        if (changed)
-                            $common.markChanged($scope.ui.inputForm, 'metadataBackupItemChanged');
-                        else
-                            $common.markPristine($scope.ui.inputForm, 'metadataBackupItemChanged');
-                    }, 50);
-                }
-
-                $common.confirmUnsavedChanges($confirm, $scope.ui.inputForm, setSelectedAndBackupItem);
-
-                $scope.ui.formTitle = $common.isDefined($scope.backupItem) && $scope.backupItem._id
?
-                    'Selected metadata: ' + $scope.backupItem.name : 'New metadata';
-            }
-
             $scope.selectAllSchemas = function () {
                 var allSelected = $scope.loadMeta.allSchemasSelected;
 
@@ -589,7 +563,28 @@ controlCenterModule.controller('metadataController', [
                             });
 
                             if (idx >= 0) {
-                                setSelectedAndBackupItem($scope.metadatas[idx], restoredItem,
sessionStorage.metadataBackupItemChanged);
+                                var meta = $scope.metadatas[idx];
+
+                                var restoredSelectedItem = angular.fromJson(sessionStorage.metadataSelectedItem);
+
+                                // Caches not changed by user. We should take caches from
server as they could be changed on Caches screen.
+                                if (restoredSelectedItem && _.isEqual(restoredItem.caches,
restoredSelectedItem.caches)) {
+                                    restoredItem.caches = [];
+
+                                    _.forEach(meta.caches, function (cache) {
+                                        restoredItem.caches.push(cache)
+                                    });
+                                }
+                                else {
+                                    // Caches changed by user. We need to remove deleted
caches (if any).
+                                    restoredItem.caches = _.filter(restoredItem.caches, function
(cacheId) {
+                                        return _.findIndex($scope.caches, function (scopeCache)
{
+                                                return scopeCache.value == cacheId;
+                                            }) >= 0;
+                                    });
+                                }
+
+                                $scope.selectItem(meta, restoredItem, sessionStorage.metadataBackupItemChanged);
                             }
                             else {
                                 sessionStorage.removeItem('metadataBackupItem');
@@ -598,7 +593,7 @@ controlCenterModule.controller('metadataController', [
                             }
                         }
                         else
-                            setSelectedAndBackupItem(undefined, restoredItem, sessionStorage.metadataBackupItemChanged);
+                            $scope.selectItem(undefined, restoredItem, sessionStorage.metadataBackupItemChanged);
                     }
                     else
                         selectFirstItem();
@@ -638,8 +633,41 @@ controlCenterModule.controller('metadataController', [
                     $common.showError(errMsg);
                 });
 
-            $scope.selectItem = function (item) {
-                setSelectedAndBackupItem(item, angular.copy(item));
+            $scope.selectItem = function (item, backup, changed) {
+                function selectItem() {
+                    $table.tableReset();
+
+                    $scope.selectedItem = item;
+
+                    if (item)
+                        sessionStorage.metadataSelectedItem = angular.toJson(item);
+                    else
+                        sessionStorage.removeItem('metadataSelectedItem');
+
+                    _.forEach(previews, function(preview) {
+                        preview.attractAttention = false;
+                    });
+
+                    if (backup)
+                        $scope.backupItem = backup;
+                    else if (item)
+                        $scope.backupItem = angular.copy(item);
+                    else
+                        $scope.backupItem = undefined;
+
+                    $timeout(function () {
+                        if (changed)
+                            $common.markChanged($scope.ui.inputForm, 'metadataBackupItemChanged');
+                        else
+                            $common.markPristine($scope.ui.inputForm, 'metadataBackupItemChanged');
+                    }, 50);
+                }
+
+                $common.confirmUnsavedChanges($confirm, $scope.ui.inputForm, selectItem);
+
+                $scope.ui.formTitle = $common.isDefined($scope.backupItem) && $scope.backupItem._id
+                    ? 'Selected metadata: ' + $scope.backupItem.name
+                    : 'New metadata';
             };
 
             // Add new metadata.
@@ -650,7 +678,7 @@ controlCenterModule.controller('metadataController', [
                     $common.ensureActivePanel($scope.panels, 'metadata', 'metadataName');
                 });
 
-                setSelectedAndBackupItem(undefined, {space: $scope.spaces[0]._id, caches:
[]});
+                $scope.selectItem(undefined, {space: $scope.spaces[0]._id, caches: []});
             };
 
             function queryConfigured(item) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/c53103bf/modules/control-center-web/src/main/js/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/caches.js b/modules/control-center-web/src/main/js/routes/caches.js
index e9f7a44..0875be5 100644
--- a/modules/control-center-web/src/main/js/routes/caches.js
+++ b/modules/control-center-web/src/main/js/routes/caches.js
@@ -49,7 +49,6 @@ router.post('/list', function (req, res) {
                             // Get all caches for spaces.
                             db.Cache.find({space: {$in: space_ids}}).sort('name').exec(function
(err, caches) {
                                 if (db.processed(err, res)) {
-
                                     _.forEach(caches, function (cache) {
                                         // Remove deleted clusters.
                                         cache.clusters = _.filter(cache.clusters, function
(clusterId) {


Mime
View raw message