You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/01/28 17:11:48 UTC

ignite git commit: IGNITE-2490 Fixed wrong unsaved changes confirmation + cleanup legacy code.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 b2e0f3d94 -> 5c3f43590


IGNITE-2490 Fixed wrong unsaved changes confirmation + cleanup legacy code.


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

Branch: refs/heads/ignite-843-rc2
Commit: 5c3f4359055a4a7ba8b898b79000aaf5cc31da14
Parents: b2e0f3d
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Jan 28 23:11:55 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Jan 28 23:11:55 2016 +0700

----------------------------------------------------------------------
 .../main/js/controllers/clusters-controller.js  | 152 ++-----------------
 .../src/main/js/controllers/common-module.js    |   2 +-
 .../main/js/views/configuration/clusters.jade   |   4 +-
 3 files changed, 19 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5c3f4359/modules/control-center-web/src/main/js/controllers/clusters-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/clusters-controller.js b/modules/control-center-web/src/main/js/controllers/clusters-controller.js
index 6e4c2a6..c38f74e 100644
--- a/modules/control-center-web/src/main/js/controllers/clusters-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/clusters-controller.js
@@ -17,7 +17,7 @@
 
 // Controller for Clusters screen.
 consoleModule.controller('clustersController', function ($http, $timeout, $scope, $state, $controller,
-    $common, $focus, $confirm, $clone, $table, $preview, $loading, $unsavedChangesGuard, igniteIncludeEventGroups) {
+    $common, $focus, $confirm, $clone, $preview, $loading, $unsavedChangesGuard, igniteIncludeEventGroups) {
         $unsavedChangesGuard.install($scope);
 
         var __original_value;
@@ -38,6 +38,7 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
         angular.extend(this, $controller('save-remove', {$scope: $scope}));
 
         $scope.ui = $common.formUI();
+        $scope.ui.angularWay = true; // TODO We need to distinguish refactored UI from legacy UI.
 
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
@@ -46,82 +47,6 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
         $scope.saveBtnTipText = $common.saveBtnTipText;
         $scope.panelExpanded = $common.panelExpanded;
 
-        $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);
-
-                    break;
-            }
-
-            return true;
-        };
-
-        $scope.tableReset = function (save) {
-            var field = $table.tableField();
-
-            if (!save || !$common.isDefined(field) || $scope.tableSave(field, $table.tableEditedRowIndex(), true)) {
-                $table.tableReset();
-
-                return true;
-            }
-
-            return false;
-        };
-
-        $scope.tableNewItem = function (field) {
-            if ($scope.tableReset(true)) {
-                if (field.type === 'typeConfigurations') {
-                    var binary = $scope.backupItem.binaryConfiguration;
-
-                    if (!binary)
-                        $scope.backupItem.binaryConfiguration = {typeConfigurations: [{}]};
-                    else if (!$common.isDefined(binary.typeConfigurations))
-                        binary.typeConfigurations = [{}];
-                    else
-                        binary.typeConfigurations.push({});
-                }
-                else
-                    $table.tableNewItem(field);
-            }
-        };
-        $scope.tableNewItemActive = $table.tableNewItemActive;
-
-        $scope.tableStartEdit = function (item, field, index) {
-            if ($scope.tableReset(true))
-                $table.tableStartEdit(item, field, index);
-        };
-        $scope.tableEditing = $table.tableEditing;
-
-        $scope.tableRemove = function (item, field, index) {
-            if ($scope.tableReset(true)) {
-                if (field.type === 'typeConfigurations')
-                    $scope.backupItem.binaryConfiguration.typeConfigurations.splice(index, 1);
-                else
-                    $table.tableRemove(item, field, index);
-            }
-        };
-
-        $scope.tableSimpleSave = $table.tableSimpleSave;
-        $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
-
-        $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.tableSimpleDownVisible = $table.tableSimpleDownVisible;
-
-        $scope.tableEditedRowIndex = $table.tableEditedRowIndex;
-
         var previews = [];
 
         $scope.previewInit = function (preview) {
@@ -203,38 +128,6 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
 
         $scope.panels = {activePanels: [0]};
 
-        var simpleTables = {
-            addresses: {msg: 'Such IP address already exists!', id: 'IpAddress'},
-            regions: {msg: 'Such region already exists!', id: 'Region'},
-            zones: {msg: 'Such zone already exists!', id: 'Zone'},
-            peerClassLoadingLocalClassPathExclude: {msg: 'Such package already exists!', id: 'PeerClsPathExclude'},
-            trustManagers: {msg: 'Such trust manager already exists!', id: 'trustManagers'}
-        };
-
-        $scope.tableSimpleValid = function (item, field, val, index) {
-            var model = $common.getModel(item, field)[field.model];
-
-            if (field.model === 'trustManagers' && !$common.isValidJavaClass('Trust manager', val, false,  $table.tableFieldId(index, 'trustManagers'), false))
-                return false;
-
-            if ($common.isDefined(model)) {
-                var idx = _.indexOf(model, val);
-
-                // Found duplicate.
-                if (idx >= 0 && idx !== index) {
-                    var simpleTable = simpleTables[field.model];
-
-                    if (simpleTable) {
-                        $common.showPopoverMessage(null, null, $table.tableFieldId(index, simpleTable.id), simpleTable.msg);
-
-                        return $table.tableFocusInvalidField(index, simpleTable.id);
-                    }
-                }
-            }
-
-            return true;
-        };
-
         $scope.clusters = [];
 
         function _clusterLbl (cluster) {
@@ -390,8 +283,6 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
 
         $scope.selectItem = function (item, backup) {
             function selectItem() {
-                $table.tableReset();
-
                 $scope.selectedItem = angular.copy(item);
 
                 try {
@@ -444,13 +335,11 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
 
         // Add new cluster.
         $scope.createItem = function(id) {
-            if ($scope.tableReset(true)) {
-                $timeout(function () {
-                    $common.ensureActivePanel($scope.panels, "general", 'clusterName');
-                });
+            $timeout(function () {
+                $common.ensureActivePanel($scope.panels, "general", 'clusterName');
+            });
 
-                $scope.selectItem(undefined, prepareNewItem(id));
-            }
+            $scope.selectItem(undefined, prepareNewItem(id));
         };
 
         $scope.indexOfCache = function (cacheId) {
@@ -710,12 +599,10 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
 
         // Save cluster.
         $scope.saveItem = function () {
-            if ($scope.tableReset(true)) {
-                var item = $scope.backupItem;
+            var item = $scope.backupItem;
 
-                if (validate(item))
-                    save(item);
-            }
+            if (validate(item))
+                save(item);
         };
 
         function _clusterNames() {
@@ -727,16 +614,15 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
         // Copy cluster with new name.
         $scope.cloneItem = function () {
             function cloneItem() {
-                if ($scope.tableReset(true)) {
-                    if (validate($scope.backupItem))
-                        $clone.confirm($scope.backupItem.name, _clusterNames()).then(function (newName) {
-                            var item = angular.copy($scope.backupItem);
+                if (validate($scope.backupItem)) {
+                    $clone.confirm($scope.backupItem.name, _clusterNames()).then(function (newName) {
+                        var item = angular.copy($scope.backupItem);
 
-                            delete item._id;
-                            item.name = newName;
+                        delete item._id;
+                        item.name = newName;
 
-                            save(item);
-                        });
+                        save(item);
+                    });
                 }
             }
 
@@ -745,8 +631,6 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
 
         // Remove cluster from db.
         $scope.removeItem = function () {
-            $table.tableReset();
-
             var selectedItem = $scope.selectedItem;
 
             $confirm.confirm('Are you sure you want to remove cluster: "' + selectedItem.name + '"?')
@@ -780,8 +664,6 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
 
         // Remove all clusters from db.
         $scope.removeAllItems = function () {
-            $table.tableReset();
-
             $confirm.confirm('Are you sure you want to remove all clusters?')
                 .then(function () {
                         $http.post('/api/v1/configuration/clusters/remove/all')
@@ -809,8 +691,6 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope
         };
 
         $scope.resetAll = function() {
-            $table.tableReset();
-
             $confirm.confirm('Are you sure you want to undo all changes for current cluster?')
                 .then(function() {
                     $scope.backupItem = $scope.selectedItem ? angular.copy($scope.selectedItem) : prepareNewItem();

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c3f4359/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 8903632..fad1290 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
@@ -1144,7 +1144,7 @@ consoleModule.service('$unsavedChangesGuard', function ($rootScope) {
             });
 
             var unbind = $rootScope.$on('$stateChangeStart', function(event) {
-                if ($scope.ui && ($scope.ui.isDirty() || ($scope.ui.inputForm && $scope.ui.inputForm.$dirty))) {
+                if ($scope.ui && ($scope.ui.isDirty() || ($scope.ui.angularWay && $scope.ui.inputForm && $scope.ui.inputForm.$dirty))) {
                     if (!confirm('You have unsaved changes.\n\nAre you sure you want to discard them?')) {
                         event.preventDefault();
                     } else {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5c3f4359/modules/control-center-web/src/main/js/views/configuration/clusters.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/configuration/clusters.jade b/modules/control-center-web/src/main/js/views/configuration/clusters.jade
index da7968f..28fc273 100644
--- a/modules/control-center-web/src/main/js/views/configuration/clusters.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/clusters.jade
@@ -37,7 +37,7 @@ include ../includes/controls
                 -var cloneTip = '"Clone current ' + objectName + '"'
                 -var undoTip = '"Undo all changes for current ' + objectName + '"'
 
-                div(ng-show='tableVisibleRow(displayedRows, selectedItem)' style='display: inline-block;')
+                div(ng-show='backupItem' style='display: inline-block;')
                     .panel-tip-container(ng-hide='!backupItem || backupItem._id')
                         a.btn.btn-primary(ng-disabled='!ui.inputForm.$dirty' ng-click='ui.inputForm.$dirty && saveItem()' bs-tooltip='' data-title='{{saveBtnTipText(ui.inputForm.$dirty, "#{objectName}")}}' data-placement='bottom' data-trigger='hover') Save
                     .panel-tip-container(ng-show='backupItem._id')
@@ -52,7 +52,7 @@ include ../includes/controls
                         i.btn.btn-primary.fa.fa-undo(id='undo-item' ng-disabled='!ui.inputForm.$dirty' ng-click='ui.inputForm.$dirty && resetAll()' bs-tooltip=undoTip data-placement='bottom' data-trigger='hover')
             hr
             div(bs-collapse='' data-allow-multiple='true' ng-model='__.groups')
-                form.form-horizontal(name='ui.inputForm' ng-show='backupItem && tableVisibleRow(displayedRows, selectedItem)' novalidate)
+                form.form-horizontal(name='ui.inputForm' ng-show='backupItem' novalidate)
                     .panel-group(ng-click='triggerDigest = true')
                         ignite-configuration-clusters-general
                         .advanced-options