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/07/23 10:40:41 UTC

[10/50] [abbrv] incubator-ignite git commit: IGNITE-843: WIP cache type metadata: added support for $confirm, $saveAs.

IGNITE-843: WIP cache type metadata: added support for $confirm, $saveAs.


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

Branch: refs/heads/ignite-1121
Commit: b34fb931bfea89c46625a945d723ab7fd8826f11
Parents: 18f554d
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Jul 21 01:03:55 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Jul 21 01:03:55 2015 +0700

----------------------------------------------------------------------
 .../nodejs/controllers/metadata-controller.js   | 74 +++++++++++++++-----
 .../nodejs/views/configuration/metadata.jade    |  1 +
 2 files changed, 56 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b34fb931/modules/web-control-center/nodejs/controllers/metadata-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/metadata-controller.js b/modules/web-control-center/nodejs/controllers/metadata-controller.js
index 9b100af..25e8156 100644
--- a/modules/web-control-center/nodejs/controllers/metadata-controller.js
+++ b/modules/web-control-center/nodejs/controllers/metadata-controller.js
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-controlCenterModule.controller('metadataController', ['$scope', '$http', '$common', '$table', function ($scope, $http, $common, $table) {
+controlCenterModule.controller('metadataController', ['$scope', '$http', '$common', '$confirm', '$saveAs', '$table', function ($scope, $http, $common, $confirm, $saveAs, $table) {
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
 
@@ -321,10 +321,13 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
             $scope.backupItem.space = $scope.spaces[0]._id;
         };
 
-        // Save metadata in db.
-        $scope.saveItem = function () {
-            var item = $scope.backupItem;
+        // Check cache type metadata logical consistency.
+        function validate(item) {
+            return true;
+        }
 
+        // Save cache type metadata into database.
+        function save(item) {
             $http.post('metadata/save', item)
                 .success(function (_id) {
                     $common.showInfo('Metadata "' + item.name + '" saved.');
@@ -343,30 +346,63 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
 
                     $scope.selectItem(item);
 
+                    $common.showInfo('Cache type metadata"' + item.name + '" saved.');
                 })
                 .error(function (errMsg) {
                     $common.showError(errMsg);
                 });
+        }
+
+        // Save cache type metadata.
+        $scope.saveItem = function () {
+            var item = $scope.backupItem;
+
+            if (validate(item))
+                save(item);
         };
 
-        $scope.removeItem = function () {
-            var _id = $scope.selectedItem._id;
+        // Save cache type metadata with new name.
+        $scope.saveItemAs = function () {
+            if (validate($scope.backupItem))
+                $saveAs.show($scope.backupItem.name).then(function (newName) {
+                    var item = angular.copy($scope.backupItem);
 
-            $http.post('metadata/remove', {_id: _id})
-                .success(function () {
-                    var i = _.findIndex($scope.metadatas, function (metadata) {
-                        return metadata._id == _id;
-                    });
+                    item._id = undefined;
+                    item.name = newName;
 
-                    if (i >= 0) {
-                        $scope.metadatas.splice(i, 1);
+                    save(item);
+                });
+        };
 
-                        $scope.selectedItem = undefined;
-                        $scope.backupItem = undefined;
-                    }
-                })
-                .error(function (errMsg) {
-                    $common.showError(errMsg);
+        $scope.removeItem = function () {
+            var selectedItem = $scope.selectedItem;
+
+            $confirm.show('Are you sure you want to remove cache type metadata: "' + selectedItem.name + '"?').then(
+                function () {
+                    var _id = selectedItem._id;
+
+                    $http.post('metadata/remove', {_id: _id})
+                        .success(function () {
+                            $common.showInfo('Cache type metadata has been removed: ' + selectedItem.name);
+
+                            var metadatas = $scope.metadatas;
+
+                            var idx = _.findIndex(metadatas, function (metadata) { return metadata._id == _id; });
+
+                            if (idx >= 0) {
+                                metadatas.splice(i, idx);
+
+                                if (metadatas.length > 0)
+                                    $scope.selectItem(metadatas[0]);
+                                else {
+                                    $scope.selectedItem = undefined;
+                                    $scope.backupItem = undefined;
+                                }
+                            }
+                        })
+                        .error(function (errMsg) {
+                            $common.showError(errMsg);
+                        });
                 });
         };
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b34fb931/modules/web-control-center/nodejs/views/configuration/metadata.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/configuration/metadata.jade b/modules/web-control-center/nodejs/views/configuration/metadata.jade
index 7eec682..bd3eb05 100644
--- a/modules/web-control-center/nodejs/views/configuration/metadata.jade
+++ b/modules/web-control-center/nodejs/views/configuration/metadata.jade
@@ -50,6 +50,7 @@ block content
                             .settings-row(ng-repeat='field in metadataManual')
                                 +form-row
                             button.btn.btn-primary(ng-disabled='manualForm.$invalid' ng-click='saveItem()') Save
+                            button.btn.btn-primary(ng-show='backupItem._id' ng-disabled='inputForm.$invalid' ng-click='saveItemAs()') Save As
                             button.btn.btn-primary.btn-second(ng-show='backupItem._id' ng-click='removeItem()') Remove
             .panel.panel-default
                 .panel-heading