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 Confirm override for metadata load.
Date Thu, 10 Sep 2015 09:24:04 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 5780f96d0 -> c8e5855bb


IGNITE-843 Confirm override for metadata load.


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

Branch: refs/heads/ignite-843
Commit: c8e5855bb31c9145541bddfbfa0e7b9a9744deaa
Parents: 5780f96
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Thu Sep 10 16:24:41 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Thu Sep 10 16:24:41 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/common-module.js    | 100 +++++++++++++++++--
 .../main/js/controllers/metadata-controller.js  |  84 ++++++++--------
 2 files changed, 138 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c8e5855b/modules/control-center-web/src/main/js/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js
index ca63419..c8e676b 100644
--- a/modules/control-center-web/src/main/js/controllers/common-module.js
+++ b/modules/control-center-web/src/main/js/controllers/common-module.js
@@ -728,24 +728,110 @@ controlCenterModule.service('$confirm', function ($modal, $rootScope,
$q) {
         confirmModal.hide();
     };
 
+    var confirmModal = $modal({templateUrl: '/confirm', scope: scope, placement: 'center',
show: false});
+
+    var parentShow = confirmModal.show;
+
+    confirmModal.show = function (content) {
+        scope.content = content || 'Confirm deletion?';
+
+        deferred = $q.defer();
+
+        parentShow();
+
+        return deferred.promise;
+    };
+
+    return confirmModal;
+});
+
+// Confirm by step popup service.
+controlCenterModule.service('$stepConfirm', function ($timeout, $modal, $rootScope, $q) {
+    var scope = $rootScope.$new();
+
+    var deferred;
+
+    scope.ui = {forAll: false};
+
+    var contentGenerator = function () {};
+
+    var stepProcessor = function () {};
+
+    var modelArray;
+
+    var curIx = -1;
+
+    function nextElement() {
+        curIx += 1;
+
+        if (curIx < modelArray.length) {
+            scope.content = contentGenerator(modelArray[curIx]);
+
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * Generate reject event on cancel for special event processing.
      */
     scope.cancel = function () {
         deferred.reject('cancelled');
 
-        confirmModal.hide();
+        stepConfirmModal.hide();
     };
 
-    var confirmModal = $modal({templateUrl: '/confirm', scope: scope, placement: 'center',
show: false});
+    scope.skip = function () {
+        if (scope.ui.forAll || !nextElement()) {
+            deferred.resolve();
 
-    var parentShow = confirmModal.show;
+            stepConfirmModal.hide();
+        }
+    };
 
-    confirmModal.show = function (content, cancelTitle) {
-        scope.content = content || 'Confirm deletion?';
+    scope.continue = function () {
+        stepProcessor(modelArray[curIx]);
 
+        if (scope.ui.forAll) {
+            while(nextElement())
+                stepProcessor(modelArray[curIx]);
+        }
         scope.cancelTitle = cancelTitle || dfltCancelTitle;
 
+        if (!nextElement()) {
+            deferred.resolve();
+
+            stepConfirmModal.hide();
+        }
+    };
+
+    var stepConfirmModal = $modal({templateUrl: 'metadata/metadata-load-confirm', scope:
scope, placement: 'center', show: false});
+
+    var parentShow = stepConfirmModal.show;
+
+    /**
+     * Show confirm by steps dialog.
+     *
+     * @param generator Function to generate a confirm message. first argument is a confirmed
element.
+     * @param processor Function to compute a confirmed element.
+     * @param model Array of element to process by confirm.
+     */
+    stepConfirmModal.show = function (generator, processor, model) {
+        $timeout(function () {
+            scope.content = contentGenerator(model[0]);
+        });
+
+        contentGenerator = generator;
+
+        stepProcessor = processor;
+
+        modelArray = model;
+
+        curIx = 0;
+
+        scope.ui.forAll = false;
+
         deferred = $q.defer();
 
         parentShow();
@@ -753,7 +839,7 @@ controlCenterModule.service('$confirm', function ($modal, $rootScope,
$q) {
         return deferred.promise;
     };
 
-    return confirmModal;
+    return stepConfirmModal;
 });
 
 // 'Save as' popup service.
@@ -1554,7 +1640,7 @@ controlCenterModule.controller('agent-download', [
         $scope.showDownloadAgent = function () {
             _agentDownloadModal.$promise.then(_agentDownloadModal.show);
         };
-}]);
+    }]);
 
 // Navigation bar controller.
 controlCenterModule.controller('notebooks', ['$scope', '$modal', '$window', '$http', '$common',

http://git-wip-us.apache.org/repos/asf/ignite/blob/c8e5855b/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 158e642..eb8ae29 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
@@ -17,8 +17,8 @@
 
 // Controller for Metadata screen.
 controlCenterModule.controller('metadataController', [
-        '$scope', '$controller', '$http', '$modal', '$common', '$timeout', '$focus', '$confirm',
'$copy', '$table', '$preview',
-        function ($scope, $controller, $http, $modal, $common, $timeout, $focus, $confirm,
$copy, $table, $preview) {
+        '$scope', '$controller', '$http', '$modal', '$common', '$timeout', '$focus', '$confirm',
'$copy', '$table', '$preview', '$stepConfirm',
+        function ($scope, $controller, $http, $modal, $common, $timeout, $focus, $confirm,
$copy, $table, $preview, $stepConfirm) {
             // Initialize the super class and extend it.
             angular.extend(this, $controller('save-remove', {$scope: $scope}));
 
@@ -134,7 +134,7 @@ controlCenterModule.controller('metadataController', [
 
             function _findPreset(jdbcDriverJar) {
                 var idx = _.findIndex(jdbcDrivers, function (jdbcDriver) {
-                   return  jdbcDriver.jdbcDriverJar == jdbcDriverJar;
+                    return  jdbcDriver.jdbcDriverJar == jdbcDriverJar;
                 });
 
                 if (idx >= 0) {
@@ -296,8 +296,8 @@ controlCenterModule.controller('metadataController', [
                 $scope.preset.schemas = [];
 
                 _.forEach($scope.loadMeta.schemas, function (schema) {
-                   if (schema.use)
-                       $scope.preset.schemas.push(schema.name);
+                    if (schema.use)
+                        $scope.preset.schemas.push(schema.name);
                 });
 
                 $http.post('/agent/metadata', $scope.preset)
@@ -376,38 +376,39 @@ controlCenterModule.controller('metadataController', [
                     var delayed = [];
 
                     /**
-                     * Save the tied metadata by one on confirm variant selected only.
+                     * Save exist metadata function.
                      *
-                     * @param ix Index of deleayed metadata to select.
+                     * @param metadata Object to save. 0 index for exist element, 1 index
for changed element.
                      */
-                    function saveDelayed(ix) {
-                        if (ix < delayed.length) {
-                            var existMeta = delayed[ix][0];
-                            var meta = delayed[ix][1];
-
-                            $confirm.show(
-                                '<span>' +
-                                'Metadata with name &quot;' + meta.databaseTable + '&quot;
already exist.<br/><br/>' +
-                                'Are you sure you want to overwrite it?' +
-                                '</span>', 'Skip').then(function () {
-                                    existMeta.databaseSchema = meta.databaseSchema;
-                                    existMeta.databaseTable = meta.databaseTable;
-                                    existMeta.keyType = meta.keyType;
-                                    existMeta.valueType = meta.valueType;
-                                    existMeta.queryFields = meta.queryFields;
-                                    existMeta.ascendingFields = meta.ascendingFields;
-                                    existMeta.descendingFields = meta.descendingFields;
-                                    existMeta.groups = meta.groups;
-                                    existMeta.keyFields = meta.keyFields;
-                                    existMeta.valueFields = meta.valueFields;
-
-                                    save(existMeta, true);
-
-                                    saveDelayed(ix + 1);
-                                }, function () {
-                                    saveDelayed(ix + 1);
-                                })
-                        }
+                    function saveDelayed(metadata) {
+                        var existMeta = metadata[0];
+                        var meta = metadata[1];
+
+                        existMeta.databaseSchema = meta.databaseSchema;
+                        existMeta.databaseTable = meta.databaseTable;
+                        existMeta.keyType = meta.keyType;
+                        existMeta.valueType = meta.valueType;
+                        existMeta.queryFields = meta.queryFields;
+                        existMeta.ascendingFields = meta.ascendingFields;
+                        existMeta.descendingFields = meta.descendingFields;
+                        existMeta.groups = meta.groups;
+                        existMeta.keyFields = meta.keyFields;
+                        existMeta.valueFields = meta.valueFields;
+
+                        save(existMeta, true);
+                    }
+
+                    /**
+                     * Generate message to show on confirm dialog.
+                     *
+                     * @param metadata Object to confirm. 0 index for exist element, 1 index
for changed element.
+                     * @returns {string} Generated message.
+                     */
+                    function overwriteMessage(metadata) {
+                        return '<span>' +
+                            'Metadata with name &quot;' + metadata[1].databaseTable +
'&quot; already exist.<br/><br/>' +
+                            'Are you sure you want to overwrite it?' +
+                            '</span>'
                     }
 
                     _.forEach($scope.loadMeta.tables, function (table) {
@@ -514,9 +515,14 @@ controlCenterModule.controller('metadataController', [
                     });
 
                     // Process delayed metadata.
-                    saveDelayed(0);
-
-                    $common.showInfo('Cache type metadata loaded from database.');
+                    if (delayed.length > 0)
+                        $stepConfirm.show(overwriteMessage, saveDelayed, delayed).then(function
() {
+                            $common.showInfo('Cache type metadata loaded from database.');
+                        }, function () {
+                            $common.showError('Cache type metadata loading interrupted by
user.');
+                        });
+                    else
+                        $common.showInfo('Cache type metadata loaded from database.');
                 }
 
                 if (isIntersections)
@@ -980,7 +986,7 @@ controlCenterModule.controller('metadataController', [
                             return showPopoverMessage(null, null, $table.tableFieldId(index,
'JavaName' + dbFieldTable.id), 'Field with such java name already exists!');
 
                         if (index < 0) {
-                                model.push(dbFieldValue);
+                            model.push(dbFieldValue);
                         }
                         else {
                             var dbField = model[index];


Mime
View raw message