ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843: Refactored common functions.
Date Mon, 20 Jul 2015 00:57:27 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 f92109a91 -> 69889db21


IGNITE-843: Refactored common functions.


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

Branch: refs/heads/ignite-843
Commit: 69889db216feea32615212f8e68193578ffaec96
Parents: f92109a
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Jul 20 07:57:19 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Jul 20 07:57:19 2015 +0700

----------------------------------------------------------------------
 .../nodejs/controllers/caches-controller.js     | 16 ++--
 .../nodejs/controllers/clusters-controller.js   | 11 ++-
 .../nodejs/controllers/common-module.js         | 98 ++++++--------------
 .../nodejs/controllers/metadata-controller.js   | 16 ++--
 .../nodejs/views/includes/controls.jade         | 34 +++----
 5 files changed, 62 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/69889db2/modules/web-control-center/nodejs/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/caches-controller.js b/modules/web-control-center/nodejs/controllers/caches-controller.js
index c7ba8de..9a7a11b 100644
--- a/modules/web-control-center/nodejs/controllers/caches-controller.js
+++ b/modules/web-control-center/nodejs/controllers/caches-controller.js
@@ -19,24 +19,20 @@ controlCenterModule.controller('cachesController', ['$scope', '$http',
'$common'
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
 
-        $scope.tableSimpleNewItem = $table.tableSimpleNewItem;
-        $scope.tableSimpleNewItemActive = $table.tableSimpleNewItemActive;
+        $scope.tableNewItem = $table.tableNewItem;
+        $scope.tableNewItemActive = $table.tableNewItemActive;
+        $scope.tableEditing = $table.tableEditing;
+        $scope.tableStartEdit = $table.tableStartEdit;
+        $scope.tableRemove = $table.tableRemove;
+
         $scope.tableSimpleSave = $table.tableSimpleSave;
         $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
-        $scope.tableSimpleStartEdit = $table.tableSimpleStartEdit;
-        $scope.tableSimpleEditing = $table.tableSimpleEditing;
-        $scope.tableSimpleRemove = $table.tableSimpleRemove;
         $scope.tableSimpleUp = $table.tableSimpleUp;
         $scope.tableSimpleDown = $table.tableSimpleDown;
         $scope.tableSimpleDownVisible = $table.tableSimpleDownVisible;
 
-        $scope.tablePairNewItem = $table.tablePairNewItem;
-        $scope.tablePairNewItemActive = $table.tablePairNewItemActive;
         $scope.tablePairSave = $table.tablePairSave;
         $scope.tablePairSaveVisible = $table.tablePairSaveVisible;
-        $scope.tablePairStartEdit = $table.tablePairStartEdit;
-        $scope.tablePairEditing = $table.tablePairEditing;
-        $scope.tablePairRemove = $table.tablePairRemove;
 
         $scope.atomicities = [
             {value: 'ATOMIC', label: 'ATOMIC'},

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/69889db2/modules/web-control-center/nodejs/controllers/clusters-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/clusters-controller.js b/modules/web-control-center/nodejs/controllers/clusters-controller.js
index 5ac470d..8a5dc45 100644
--- a/modules/web-control-center/nodejs/controllers/clusters-controller.js
+++ b/modules/web-control-center/nodejs/controllers/clusters-controller.js
@@ -19,13 +19,14 @@ controlCenterModule.controller('clustersController', ['$scope', '$http',
'$commo
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
 
-        $scope.tableSimpleNewItem = $table.tableSimpleNewItem;
-        $scope.tableSimpleNewItemActive = $table.tableSimpleNewItemActive;
+        $scope.tableNewItem = $table.tableNewItem;
+        $scope.tableNewItemActive = $table.tableNewItemActive;
+        $scope.tableEditing = $table.tableEditing;
+        $scope.tableStartEdit = $table.tableStartEdit;
+        $scope.tableRemove = $table.tableRemove;
+
         $scope.tableSimpleSave = $table.tableSimpleSave;
         $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
-        $scope.tableSimpleStartEdit = $table.tableSimpleStartEdit;
-        $scope.tableSimpleEditing = $table.tableSimpleEditing;
-        $scope.tableSimpleRemove = $table.tableSimpleRemove;
         $scope.tableSimpleUp = $table.tableSimpleUp;
         $scope.tableSimpleDown = $table.tableSimpleDown;
         $scope.tableSimpleDownVisible = $table.tableSimpleDownVisible;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/69889db2/modules/web-control-center/nodejs/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/common-module.js b/modules/web-control-center/nodejs/controllers/common-module.js
index e6bb10f..2205203 100644
--- a/modules/web-control-center/nodejs/controllers/common-module.js
+++ b/modules/web-control-center/nodejs/controllers/common-module.js
@@ -190,9 +190,6 @@ controlCenterModule.service('$saveAs', function ($modal, $rootScope, $q)
{
 
 // Tables support service.
 controlCenterModule.service('$table', ['$common', function ($common) {
-    var tableSimple = {name: 'none', editIndex: -1};
-    var tablePair = {name: 'none', editIndex: -1};
-
     function swapSimpleItems(a, ix1, ix2) {
         var tmp = a[ix1];
 
@@ -204,44 +201,41 @@ controlCenterModule.service('$table', ['$common', function ($common)
{
         return $common.getModel(item, field);
     }
 
-    function tableSimpleReset() {
-        tableSimple.name = 'none';
-        tableSimple.editIndex = -1;
-    }
+    var table = {name: 'none', editIndex: -1};
 
-    function tablePairReset() {
-        tablePair.name = 'none';
-        tablePair.editIndex = -1;
+    function tableReset() {
+        table.name = 'none';
+        table.editIndex = -1;
     }
 
-    function tableSimpleState(name, editIndex) {
-        tableSimple.name = name;
-        tableSimple.editIndex = editIndex;
-
-        tablePairReset();
-    }
-
-    function tablePairState(name, editIndex) {
-        tablePair.name = name;
-        tablePair.editIndex = editIndex;
-
-        tableSimpleReset();
+    function tableState(name, editIndex) {
+        table.name = name;
+        table.editIndex = editIndex;
     }
 
     return {
-        tableSimpleNewItem: function (field) {
-            tableSimpleState(field.model, -1);
+        tableNewItem: function (field) {
+            tableState(field.model, -1);
+        },
+        tableNewItemActive: function (field) {
+            return table.name == field.model && table.editIndex < 0;
         },
-        tableSimpleNewItemActive: function (field) {
-            return tableSimple.name == field.model && tableSimple.editIndex <
0;
+        tableEditing: function (field, index) {
+            return table.name == field.model && table.editIndex == index;
         },
-        tableSimpleValid: function(item, field, newValue, index) {
-            return $common.isDefined(item) && $common.isDefined(field) &&
$common.isDefined(newValue);
+        tableStartEdit: function (item, field, index) {
+            tableState(field.model, index);
+
+            return model(item, field)[field.model][index];
+        },
+        tableRemove: function (item, field, index) {
+            tableReset();
+
+            model(item, field)[field.model].splice(index, 1);
         },
         tableSimpleSave: function (valueValid, item, field, newValue, index) {
             if (valueValid(item, field, newValue, index)) {
-                tableSimpleReset();
-                tablePairReset();
+                tableReset();
 
                 if (index < 0) {
                     if (model(item, field)[field.model])
@@ -256,46 +250,22 @@ controlCenterModule.service('$table', ['$common', function ($common)
{
         tableSimpleSaveVisible: function(newValue) {
             return $common.isDefined(newValue) && newValue.trim().length > 0;
         },
-        tableSimpleStartEdit: function (item, field, index) {
-            tableSimpleState(field.model, index);
-
-            return model(item, field)[field.model][index];
-        },
-        tableSimpleEditing: function (field, index) {
-            return tableSimple.name == field.model && tableSimple.editIndex == index;
-        },
-        tableSimpleRemove: function (item, field, index) {
-            tableSimpleReset();
-            tablePairReset();
-
-            model(item, field)[field.model].splice(index, 1);
-        },
         tableSimpleUp: function (item, field, index) {
-            tableSimpleReset();
+            tableReset();
 
             swapSimpleItems(model(item, field)[field.model], index, index - 1);
         },
         tableSimpleDown: function (item, field, index) {
-            tableSimpleReset();
+            tableReset();
 
             swapSimpleItems(model(item, field)[field.model], index, index + 1);
         },
         tableSimpleDownVisible: function (item, field, index) {
             return index < model(item, field)[field.model].length - 1;
         },
-        tablePairNewItem: function (field) {
-            tablePairState(field.model, -1);
-        },
-        tablePairNewItemActive: function (field) {
-            return tablePair.name == field.model && tablePair.editIndex < 0;
-        },
-        tablePairValid: function(item, field, newKey, newValue, index) {
-            return $common.isDefined(item) && $common.isDefined(newKey) &&
$common.isDefined(newValue);
-        },
         tablePairSave: function (pairValid, item, field, newKey, newValue, index) {
             if (pairValid(item, field, newKey, newValue, index)) {
-                tableSimpleReset();
-                tablePairReset();
+                tableReset();
 
                 var pair = {};
 
@@ -319,20 +289,6 @@ controlCenterModule.service('$table', ['$common', function ($common)
{
         tablePairSaveVisible: function(newKey, newValue) {
             return $common.isDefined(newKey) && $common.isDefined(newValue) &&
                 newKey.trim().length > 0 &&  newValue.trim().length > 0;
-        },
-        tablePairStartEdit: function (item, field, index) {
-            tablePairState(field.model, index);
-
-            return item[field.model][index];
-        },
-        tablePairEditing: function (field, index) {
-            return tablePair.name == field.model && tablePair.editIndex == index;
-        },
-        tablePairRemove: function (item, field, index) {
-            tableSimpleReset();
-            tablePairReset();
-
-            item[field.model].splice(index, 1);
         }
     }
 }]);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/69889db2/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 9f10f49..3fae5c0 100644
--- a/modules/web-control-center/nodejs/controllers/metadata-controller.js
+++ b/modules/web-control-center/nodejs/controllers/metadata-controller.js
@@ -19,24 +19,20 @@ controlCenterModule.controller('metadataController', ['$scope', '$http',
'$commo
         $scope.joinTip = $common.joinTip;
         $scope.getModel = $common.getModel;
 
-        $scope.tableSimpleNewItem = $table.tableSimpleNewItem;
-        $scope.tableSimpleNewItemActive = $table.tableSimpleNewItemActive;
+        $scope.tableNewItem = $table.tableNewItem;
+        $scope.tableNewItemActive = $table.tableNewItemActive;
+        $scope.tableEditing = $table.tableEditing;
+        $scope.tableStartEdit = $table.tableStartEdit;
+        $scope.tableRemove = $table.tableRemove;
+
         $scope.tableSimpleSave = $table.tableSimpleSave;
         $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
-        $scope.tableSimpleStartEdit = $table.tableSimpleStartEdit;
-        $scope.tableSimpleEditing = $table.tableSimpleEditing;
-        $scope.tableSimpleRemove = $table.tableSimpleRemove;
         $scope.tableSimpleUp = $table.tableSimpleUp;
         $scope.tableSimpleDown = $table.tableSimpleDown;
         $scope.tableSimpleDownVisible = $table.tableSimpleDownVisible;
 
-        $scope.tablePairNewItem = $table.tablePairNewItem;
-        $scope.tablePairNewItemActive = $table.tablePairNewItemActive;
         $scope.tablePairSave = $table.tablePairSave;
         $scope.tablePairSaveVisible = $table.tablePairSaveVisible;
-        $scope.tablePairStartEdit = $table.tablePairStartEdit;
-        $scope.tablePairEditing = $table.tablePairEditing;
-        $scope.tablePairRemove = $table.tablePairRemove;
 
         $scope.templates = [
             {value: {kind: 'query'}, label: 'query'},

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/69889db2/modules/web-control-center/nodejs/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/includes/controls.jade b/modules/web-control-center/nodejs/views/includes/controls.jade
index 546c4bf..4685fb4 100644
--- a/modules/web-control-center/nodejs/views/includes/controls.jade
+++ b/modules/web-control-center/nodejs/views/includes/controls.jade
@@ -41,15 +41,15 @@ mixin table-pair(header, tblMdl, keyFld, valFld, keyPlaceholder, valPlaceholder)
     .col-sm-6
         label.table-header #{header}:
         +tipLabel('field.tip')
-        button.btn.btn-primary.fieldButton(ng-click='tablePairNewItem(field)') Add
+        button.btn.btn-primary.fieldButton(ng-click='tableNewItem(field)') Add
     table.links-edit.col-sm-12(st-table=tblMdl ng-show='#{tblMdl}.length > 0')
         tbody
             tr.col-sm-12(ng-repeat='item in #{tblMdl}')
                 td.col-sm-6
-                    div(ng-show='!tablePairEditing(field, $index)')
-                        a(ng-click='curPair = tablePairStartEdit(backupItem, field, $index);
curKey = curPair.#{keyFld}; curValue = curPair.#{valFld}') {{$index + 1}}) {{item.#{keyFld}}}
/ {{item.#{valFld}}}
-                        +btn-remove('tablePairRemove(backupItem, field, $index)')
-                    div(ng-show='tablePairEditing(field, $index)')
+                    div(ng-show='!tableEditing(field, $index)')
+                        a(ng-click='curPair = tableStartEdit(backupItem, field, $index);
curKey = curPair.#{keyFld}; curValue = curPair.#{valFld}') {{$index + 1}}) {{item.#{keyFld}}}
/ {{item.#{valFld}}}
+                        +btn-remove('tableRemove(backupItem, field, $index)')
+                    div(ng-show='tableEditing(field, $index)')
                         label.labelField {{$index + 1}})
                         +btn-save('tablePairSaveVisible(curKey, curValue)', 'tablePairSave(tablePairValid,
backupItem, field, curKey, curValue, $index)')
                         .input-tip
@@ -57,7 +57,7 @@ mixin table-pair(header, tblMdl, keyFld, valFld, keyPlaceholder, valPlaceholder)
                                 input.form-control.table-form-control(type='text' ng-model='curKey'
placeholder=keyPlaceholder)
                                 label &nbsp;/&nbsp;
                                 input.form-control.table-form-control(type='text' ng-model='curValue'
placeholder=valPlaceholder)
-    .settings-row(ng-show='tablePairNewItemActive(field)')
+    .settings-row(ng-show='tableNewItemActive(field)')
         .col-sm-6
             +btn-save('tablePairSaveVisible(newKey, newValue)', 'tablePairSave(tablePairValid,
backupItem, field, newKey, newValue, -1)')
             .input-tip
@@ -116,13 +116,13 @@ mixin details-row
                 tbody
                     tr(ng-repeat='item in #{detailMdl} track by $index')
                         td
-                            div(ng-show='!tableSimpleEditing(detail, $index)')
-                                +btn-remove('tableSimpleRemove(backupItem, detail, $index)')
+                            div(ng-show='!tableEditing(detail, $index)')
+                                +btn-remove('tableRemove(backupItem, detail, $index)')
                                 +btn-down('detail.reordering && tableSimpleDownVisible(backupItem,
detail, $index)', 'tableSimpleDown(backupItem, detail, $index)')
                                 +btn-up('detail.reordering && $index > 0', 'tableSimpleUp(backupItem,
detail, $index)')
                                 .input-tip
-                                    a(ng-click='curValue = tableSimpleStartEdit(backupItem,
detail, $index)') {{$index + 1}}) {{item}}
-                            div(ng-show='tableSimpleEditing(detail, $index)')
+                                    a(ng-click='curValue = tableStartEdit(backupItem, detail,
$index)') {{$index + 1}}) {{item}}
+                            div(ng-show='tableEditing(detail, $index)')
                                 label.labelField {{$index + 1}})
                                 +btn-save('tableSimpleSaveVisible(curValue)', 'tableSimpleSave(tableSimpleValid,
backupItem, detail, curValue, $index)')
                                 .input-tip.form-group.has-feedback
@@ -131,7 +131,7 @@ mixin details-row
             button.btn.btn-primary.fieldButton(ng-disabled='!newValue' ng-click='tableSimpleSave(tableSimpleValid,
backupItem, detail, newValue, -1)') Add
             +tipField('detail.tip')
             .input-tip.form-group.has-feedback
-                input.form-control(name='{{detail.model}}' type='text' ng-model='newValue'
ng-focus='tableSimpleNewItem(detail)' placeholder='{{detail.placeholder}}')&attributes(customValidators)
+                input.form-control(name='{{detail.model}}' type='text' ng-model='newValue'
ng-focus='tableNewItem(detail)' placeholder='{{detail.placeholder}}')&attributes(customValidators)
                 +ico-exclamation('{{detail.model}}', 'ipaddress', 'Invalid address, see help
for format description.')
 
 mixin form-row
@@ -201,22 +201,22 @@ mixin form-row-custom(lblClasses, fieldClasses)
             .col-sm-6
                 label.table-header {{field.label}}:
                 +tipLabel('field.tableTip')
-                button.btn.btn-primary.fieldButton(ng-click='tableSimpleNewItem(field)')
Add
+                button.btn.btn-primary.fieldButton(ng-click='tableNewItem(field)') Add
             table.links-edit.col-sm-12(st-table='#{fieldMdl}' ng-show='#{fieldMdl}.length
> 0')
                 tbody
                     tr.col-sm-12(ng-repeat='item in #{fieldMdl} track by $index')
                         td.col-sm-6
-                            div(ng-show='!tableSimpleEditing(field, $index)')
-                                a(ng-click='curValue = tableSimpleStartEdit(backupItem, field,
$index)') {{$index + 1}}) {{item | compact}}
-                                +btn-remove('tableSimpleRemove(backupItem, field, $index)')
+                            div(ng-show='!tableEditing(field, $index)')
+                                a(ng-click='curValue = tableStartEdit(backupItem, field,
$index)') {{$index + 1}}) {{item | compact}}
+                                +btn-remove('tableRemove(backupItem, field, $index)')
                                 +btn-down('field.reordering && tableSimpleDownVisible(backupItem,
field, $index)', 'tableSimpleDown(backupItem, field, $index)')
                                 +btn-up('field.reordering && $index > 0', 'tableSimpleUp(backupItem,
field, $index)')
-                            div(ng-show='tableSimpleEditing(field, $index)')
+                            div(ng-show='tableEditing(field, $index)')
                                 label.labelField {{$index + 1}})
                                 +btn-save('tableSimpleSaveVisible(curValue)', 'tableSimpleSave(tableSimpleValid,
backupItem, field, curValue, $index)')
                                 .input-tip
                                     input.form-control(type='text' ng-model='curValue' placeholder='{{field.placeholder}}')
-            .settings-row(ng-show='tableSimpleNewItemActive(field)')
+            .settings-row(ng-show='tableNewItemActive(field)')
                 .col-sm-6
                     +btn-save('tableSimpleSaveVisible(newValue)', 'tableSimpleSave(tableSimpleValid,
backupItem, field, newValue, -1)')
                     .input-tip


Mime
View raw message