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 / skip on load metadata.
Date Thu, 10 Sep 2015 03:26:14 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 7162dc3f9 -> 13ba99a48


IGNITE-843 Confirm / skip on load metadata.


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

Branch: refs/heads/ignite-843
Commit: 13ba99a48dcba5ff1708edcb12fdab8624393c6d
Parents: 7162dc3
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Thu Sep 10 10:26:37 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Thu Sep 10 10:26:37 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/common-module.js    | 18 +++++-
 .../main/js/controllers/metadata-controller.js  | 60 ++++++++++++++------
 .../js/routes/generator/generator-common.js     | 11 +---
 .../src/main/js/views/includes/controls.jade    |  2 +-
 .../src/main/js/views/templates/confirm.jade    |  2 +-
 5 files changed, 66 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/13ba99a4/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 119eb20..ccd61ef 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
@@ -717,19 +717,35 @@ controlCenterModule.service('$confirm', function ($modal, $rootScope,
$q) {
 
     var deferred;
 
+    var dfltCancelTitle = 'Cancel';
+
+    // Configure title of cancel button.
+    scope.cancelTitle = dfltCancelTitle;
+
     scope.ok = function () {
         deferred.resolve();
 
         confirmModal.hide();
     };
 
+    /**
+     * Generate reject event on cancel for special event processing.
+     */
+    scope.cancel = function () {
+        deferred.reject('cancelled');
+
+        confirmModal.hide();
+    };
+
     var confirmModal = $modal({templateUrl: '/confirm', scope: scope, placement: 'center',
show: false});
 
     var parentShow = confirmModal.show;
 
-    confirmModal.show = function (content) {
+    confirmModal.show = function (content, cancelTitle) {
         scope.content = content || 'Confirm deletion?';
 
+        scope.cancelTitle = cancelTitle || dfltCancelTitle;
+
         deferred = $q.defer();
 
         parentShow();

http://git-wip-us.apache.org/repos/asf/ignite/blob/13ba99a4/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 db3497a..48e7838 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
@@ -373,6 +373,43 @@ controlCenterModule.controller('metadataController', [
                 function saveImported() {
                     loadMetaModal.hide();
 
+                    var delayed = [];
+
+                    /**
+                     * Save the tied metadata by one on confirm variant selected only.
+                     *
+                     * @param ix Index of deleayed metadata to select.
+                     */
+                    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);
+                                })
+                        }
+                    }
+
                     _.forEach($scope.loadMeta.tables, function (table) {
                         if (table.use) {
                             if (tables.indexOf(table.tbl) == -1) {
@@ -449,12 +486,11 @@ controlCenterModule.controller('metadataController', [
 
                                 var metaName = toProperCase(tableName);
 
-                                var meta = _.find($scope.metadatas, function (meta) {
+                                var metaFound = _.find($scope.metadatas, function (meta)
{
                                     return meta.name == metaName;
                                 });
 
-                                if (!meta)
-                                    meta = {space: $scope.spaces[0], name: metaName};
+                                var meta = {space: $scope.spaces[0], name: metaName};
 
                                 meta.databaseSchema = table.schema;
                                 meta.databaseTable = tableName;
@@ -467,19 +503,8 @@ controlCenterModule.controller('metadataController', [
                                 meta.keyFields = keyFields;
                                 meta.valueFields = valFields;
 
-                                var idx = _.findIndex($scope.metadatas, function (metadata)
{
-                                    return metadata.databaseTable == tableName;
-                                });
-
-                                if (idx >= 0) {
-                                    $confirm.show(
-                                        '<span>' +
-                                        'Metadata with name &quot;' + tableName + '&quot;
already exist.<br/><br/>' +
-                                        'Are you sure you want to overwrite it?' +
-                                        '</span>').then(function () {
-                                            save(meta, true);
-                                        })
-                                }
+                                if ($common.isDefined(metaFound))
+                                    delayed.push([metaFound, meta]);
                                 else
                                     save(meta, true);
 
@@ -488,6 +513,9 @@ controlCenterModule.controller('metadataController', [
                         }
                     });
 
+                    // Process delayed metadata.
+                    saveDelayed(0);
+
                     $common.showInfo('Cache type metadata loaded from database.');
                 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/13ba99a4/modules/control-center-web/src/main/js/routes/generator/generator-common.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-common.js b/modules/control-center-web/src/main/js/routes/generator/generator-common.js
index 5789506..5503c37 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-common.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-common.js
@@ -17,6 +17,8 @@
 
 // For server side we should load required libraries.
 if (typeof window === 'undefined') {
+    _ = require('lodash');
+
     $dataStructures = require('../../helpers/data-structures');
 }
 
@@ -61,14 +63,7 @@ $generatorCommon.builder = function () {
     res.datasources = [];
 
     res.append = function (s) {
-        if (this.lineStart) {
-            for (var i = 0; i < this.deep; i++)
-                this.push('    ');
-
-            this.lineStart = false;
-        }
-
-        this.push(s);
+        this.push((this.lineStart ? _.repeat('    ', this.deep) : '') + s);
 
         return this;
     };

http://git-wip-us.apache.org/repos/asf/ignite/blob/13ba99a4/modules/control-center-web/src/main/js/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/includes/controls.jade b/modules/control-center-web/src/main/js/views/includes/controls.jade
index 4070fe6..d3335d2 100644
--- a/modules/control-center-web/src/main/js/views/includes/controls.jade
+++ b/modules/control-center-web/src/main/js/views/includes/controls.jade
@@ -480,7 +480,7 @@ mixin preview(preview, id)
 mixin save-remove-buttons(objectName)
     -var removeTip = '"Remove current ' + objectName + '"'
 
-    .panel-tip-container(ng-hide='backupItem._id')
+    .panel-tip-container(ng-hide='!backupItem || backupItem._id')
         a.btn.btn-primary(ng-disabled='!formChanged(ui.inputForm)' ng-click='formChanged(ui.inputForm)
? saveItem() : ""' bs-tooltip data-title='{{saveBtnTipText(ui.inputForm, "#{objectName}")}}'
data-placement='bottom' data-trigger='hover') Save
     .btn-group.panel-tip-container(ng-show='backupItem._id')
         a.btn.btn-primary(id='save-item' ng-disabled='!formChanged(ui.inputForm)' ng-click='formChanged(ui.inputForm)
? saveItem() : ""' bs-tooltip data-title='{{saveBtnTipText(ui.inputForm, "#{objectName}")}}'
data-placement='bottom' data-trigger='hover') Save

http://git-wip-us.apache.org/repos/asf/ignite/blob/13ba99a4/modules/control-center-web/src/main/js/views/templates/confirm.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/templates/confirm.jade b/modules/control-center-web/src/main/js/views/templates/confirm.jade
index 21e125b..c2ead41 100644
--- a/modules/control-center-web/src/main/js/views/templates/confirm.jade
+++ b/modules/control-center-web/src/main/js/views/templates/confirm.jade
@@ -23,5 +23,5 @@
             .modal-body(ng-show='content')
                 p(ng-bind-html='content' style='text-align: center;')
             .modal-footer
-                button.btn.btn-default(id='confirm-btn-cancel' type='button' ng-click='$hide()')
Cancel
+                button.btn.btn-default(id='confirm-btn-cancel' type='button' ng-click='cancel()')
{{cancelTitle}}
                 button.btn.btn-primary(id='confirm-btn-confirm' type='button' ng-click='ok()')
Confirm


Mime
View raw message