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 2015/07/21 06:43:50 UTC

incubator-ignite git commit: IGNITE-843 Groups beta.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 a4ca8b710 -> 9499ee2eb


IGNITE-843 Groups beta.


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

Branch: refs/heads/ignite-843
Commit: 9499ee2eb74af8ad8f067c89f9ded1188f8768b8
Parents: a4ca8b7
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Jul 21 11:43:46 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Jul 21 11:43:46 2015 +0700

----------------------------------------------------------------------
 .../nodejs/controllers/caches-controller.js     |  10 ++
 .../nodejs/controllers/clusters-controller.js   |  10 ++
 .../nodejs/controllers/common-module.js         |   3 +
 .../nodejs/controllers/metadata-controller.js   | 130 ++++++++++++++++---
 .../nodejs/public/stylesheets/style.less        |   4 +
 .../nodejs/views/includes/controls.jade         |  49 +++++--
 6 files changed, 179 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9499ee2e/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 505ecc0..3cef598 100644
--- a/modules/web-control-center/nodejs/controllers/caches-controller.js
+++ b/modules/web-control-center/nodejs/controllers/caches-controller.js
@@ -201,12 +201,16 @@ controlCenterModule.controller('cachesController', ['$scope', '$http', '$common'
             });
 
         $scope.selectItem = function (item) {
+            $table.tableReset();
+
             $scope.selectedItem = item;
             $scope.backupItem = angular.copy(item);
         };
 
         // Add new cache.
         $scope.createItem = function () {
+            $table.tableReset();
+
             $scope.backupItem = {mode: 'PARTITIONED', atomicityMode: 'ATOMIC', readFromBackup: true, copyOnRead: true};
             $scope.backupItem.space = $scope.spaces[0]._id;
         };
@@ -263,6 +267,8 @@ controlCenterModule.controller('cachesController', ['$scope', '$http', '$common'
 
         // Save cache.
         $scope.saveItem = function () {
+            $table.tableReset();
+
             var item = $scope.backupItem;
 
             if (validate(item))
@@ -271,6 +277,8 @@ controlCenterModule.controller('cachesController', ['$scope', '$http', '$common'
 
         // Save cache with new name.
         $scope.saveItemAs = function () {
+            $table.tableReset();
+
             if (validate($scope.backupItem))
                 $saveAs.show($scope.backupItem.name).then(function (newName) {
                     var item = angular.copy($scope.backupItem);
@@ -284,6 +292,8 @@ controlCenterModule.controller('cachesController', ['$scope', '$http', '$common'
 
         // Remove cache from db.
         $scope.removeItem = function () {
+            $table.tableReset();
+
             var selectedItem = $scope.selectedItem;
 
             $confirm.show('Are you sure you want to remove cache: "' + selectedItem.name + '"?').then(

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9499ee2e/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 36f783a..996e2a3 100644
--- a/modules/web-control-center/nodejs/controllers/clusters-controller.js
+++ b/modules/web-control-center/nodejs/controllers/clusters-controller.js
@@ -177,12 +177,16 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo
             });
 
         $scope.selectItem = function (item) {
+            $table.tableReset();
+
             $scope.selectedItem = item;
             $scope.backupItem = angular.copy(item);
         };
 
         // Add new cluster.
         $scope.createItem = function () {
+            $table.tableReset();
+
             $scope.backupItem = angular.copy($scope.create.template);
             $scope.backupItem.space = $scope.spaces[0]._id;
         };
@@ -241,6 +245,8 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo
 
         // Save cluster.
         $scope.saveItem = function () {
+            $table.tableReset();
+
             var item = $scope.backupItem;
 
             if (validate(item))
@@ -249,6 +255,8 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo
 
         // Save cluster with new name.
         $scope.saveItemAs = function () {
+            $table.tableReset();
+
             if (validate($scope.backupItem))
                 $saveAs.show($scope.backupItem.name).then(function (newName) {
                     var item = angular.copy($scope.backupItem);
@@ -262,6 +270,8 @@ controlCenterModule.controller('clustersController', ['$scope', '$http', '$commo
 
         // Remove cluster from db.
         $scope.removeItem = function () {
+            $table.tableReset();
+
             var selectedItem = $scope.selectedItem;
 
             $confirm.show('Are you sure you want to remove cluster: "' + selectedItem.name + '"?').then(

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9499ee2e/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 f0667c2..f011a59 100644
--- a/modules/web-control-center/nodejs/controllers/common-module.js
+++ b/modules/web-control-center/nodejs/controllers/common-module.js
@@ -217,6 +217,9 @@ controlCenterModule.service('$table', ['$common', function ($common) {
     }
 
     return {
+        tableState: function (name, editIndex) {
+            _tableState(name, editIndex);
+        },
         tableReset: function () {
             _tableReset();
         },

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9499ee2e/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 25e8156..1064f3a 100644
--- a/modules/web-control-center/nodejs/controllers/metadata-controller.js
+++ b/modules/web-control-center/nodejs/controllers/metadata-controller.js
@@ -102,6 +102,11 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
             {value: 'Timestamp', label: 'Timestamp'}
         ];
 
+        $scope.sortDirections = [
+            {value: 'ASC', label: 'ASC'},
+            {value: 'DESC', label: 'DESC'}
+        ];
+
         $scope.data = {
             curTableIdx: 0,
             curFieldIdx: 0,
@@ -296,28 +301,17 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
             });
 
         $scope.selectItem = function (item) {
+            $table.tableReset();
+
             $scope.selectedItem = item;
             $scope.backupItem = angular.copy(item);
         };
 
         // Add new metadata.
         $scope.createItem = function () {
-            $scope.backupItem = angular.copy($scope.template);
-
-            $scope.backupItem.groups = [{
-                name: "index1",
-                fields: [
-                    {name: "fld1", className: "Integer", direction: "ASC"},
-                    {name: "fld2", className: "String", direction: "DESC"}]
-            },
-                {
-                    name: "index2",
-                    fields: [
-                        {name: "fld3", className: "Integer", direction: "ASC"},
-                        {name: "fld4", className: "Data", direction: "DESC"}]
-                }
-            ];
+            $table.tableReset();
 
+            $scope.backupItem = angular.copy($scope.template);
             $scope.backupItem.space = $scope.spaces[0]._id;
         };
 
@@ -355,6 +349,8 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
 
         // Save cache type metadata.
         $scope.saveItem = function () {
+            $table.tableReset();
+
             var item = $scope.backupItem;
 
             if (validate(item))
@@ -363,6 +359,8 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
 
         // Save cache type metadata with new name.
         $scope.saveItemAs = function () {
+            $table.tableReset();
+
             if (validate($scope.backupItem))
                 $saveAs.show($scope.backupItem.name).then(function (newName) {
                     var item = angular.copy($scope.backupItem);
@@ -375,6 +373,8 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
         };
 
         $scope.removeItem = function () {
+            $table.tableReset();
+
             var selectedItem = $scope.selectedItem;
 
             $confirm.show('Are you sure you want to remove cache type metadata: "' + selectedItem.name + '"?').then(
@@ -495,9 +495,105 @@ controlCenterModule.controller('metadataController', ['$scope', '$http', '$commo
             return $common.isNonEmpty(group);
         };
 
+        function tableGroupValid(groupName, index) {
+            var groups = $scope.backupItem.groups;
+
+            if ($common.isDefined(groups)) {
+                var idx = _.findIndex(groups, function (group) {return group.name == groupName});
+
+                // Found itself.
+                if (index >= 0 && index == idx)
+                    return true;
+
+                // Found duplicate.
+                if (idx >= 0) {
+                    $common.showError('Group with such name already exists!');
+
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        $scope.tableGroupSave = function(groupName, index) {
+            if (tableGroupValid(groupName, index)) {
+                $table.tableReset();
+
+                var item = $scope.backupItem;
+
+                if (index < 0) {
+                    var newGroup = {name: groupName};
+
+                    if (item.groups)
+                        item.groups.push(newGroup);
+                    else
+                        item.groups = [newGroup];
+                }
+                else
+                    item.groups[index].name = groupName;
+            }
+        };
+
+        $scope.tableGroupNewItem = function(groupIndex) {
+            var groupName = $scope.backupItem.groups[groupIndex].name;
+
+            return $table.tableNewItem({model: groupName});
+        };
+
+        $scope.tableGroupNewItemActive = function(groupIndex) {
+            var groupName = $scope.backupItem.groups[groupIndex].name;
+
+            return $table.tableNewItemActive({model: groupName});
+        };
+
+        $scope.tableGroupItemEditing = function (groupIndex, index) {
+            var groups = $scope.backupItem.groups;
+
+            if (groups)
+                return $table.tableEditing({model: groups[groupIndex].name}, index);
+
+            return false;
+        };
+
+        $scope.tableGroupItemStartEdit = function(groupIndex, index) {
+            var groups = $scope.backupItem.groups;
+
+            $table.tableState(groups[groupIndex].name, index);
+
+            return groups[groupIndex].fields[index];
+        };
+
+        $scope.tableGroupItemSaveVisible = function(fieldName, className) {
+            return $common.isNonEmpty(fieldName) && $common.isNonEmpty(className);
+        };
+
+        $scope.tableGroupItemSave = function(fieldName, className, direction, groupIndex, index) {
+            $table.tableReset();
+
+            var group = $scope.backupItem.groups[groupIndex];
+
+            if (index < 0) {
+                var newGroupItem = {name: fieldName, className: className, direction: direction};
+
+                if (group.fields)
+                    group.fields.push(newGroupItem);
+                else
+                    group.fields = [newGroupItem];
+            }
+            else {
+                var groupItem = group.fields[index];
+
+                groupItem.name = fieldName;
+                groupItem.className = className;
+                groupItem.direction = direction;
+            }
+        };
+
         $scope.tableRemoveGroupItem = function(group, index) {
-            console.log("group: " + group.name);
-            console.log("index: " + index);
+            $table.tableReset();
+
+            group.fields.splice(index, 1);
         };
 
         $scope.selectSchema = function (idx) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9499ee2e/modules/web-control-center/nodejs/public/stylesheets/style.less
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/public/stylesheets/style.less b/modules/web-control-center/nodejs/public/stylesheets/style.less
index e4369e4..a16318d 100644
--- a/modules/web-control-center/nodejs/public/stylesheets/style.less
+++ b/modules/web-control-center/nodejs/public/stylesheets/style.less
@@ -872,6 +872,10 @@ label {
   margin-right: 0;
 }
 
+.fa-plus {
+  cursor: pointer;
+}
+
 .fa-remove {
   color: @ignite-red;
   cursor: pointer;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9499ee2e/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 6c81489..f45b60e 100644
--- a/modules/web-control-center/nodejs/views/includes/controls.jade
+++ b/modules/web-control-center/nodejs/views/includes/controls.jade
@@ -28,6 +28,9 @@ mixin ico-exclamation(mdl, err, msg)
 mixin btn-save(show, click)
     i.tipField.fa.fa-floppy-o(ng-show=show ng-click=click)
 
+mixin btn-add(click)
+    i.tipField.fa.fa-plus(ng-click=click)
+
 mixin btn-remove(click)
     i.tipField.fa.fa-remove(ng-click=click)
 
@@ -145,6 +148,16 @@ mixin table-db-field-edit(dbName, dbType, javaName, javaType)
     .input-tip
         input.form-control(type='text' ng-model=dbName placeholder='DB name')
 
+mixin table-group-item-edit(fieldName, className, direction)
+    div(style='width: 15%; float: right')
+        button.form-control(ng-model=direction bs-select data-placeholder='Sort' bs-options='item.value as item.label for item in {{sortDirections}}')
+    label.fieldSep /
+    div(style='width: 38%; float: right')
+        input.form-control(type='text' ng-model=className placeholder='Class name')
+    label.fieldSep /
+    .input-tip
+        input.form-control(type='text' ng-model=fieldName placeholder='Field name')
+
 mixin form-row
     +form-row-custom(['col-sm-2'], ['col-sm-4'])
 
@@ -246,7 +259,7 @@ mixin form-row-custom(lblClasses, fieldClasses)
                     tr.col-sm-12(ng-repeat='item in #{fieldMdl}')
                         td.col-sm-6
                             div(ng-show='!tableEditing(field, $index)')
-                                a.labelFormField(ng-click='curValue = tableStartEdit(backupItem, field, $index)') {{$index + 1}}) {{item | compact}}(ng-click='curDbFldMeta = tableStartEdit(backupItem, field, $index); curDbName = curDbFldMeta.dbName; curDbType = curDbFldMeta.dbType; curJavaName = curDbFldMeta.javaName; curJavaType = curDbFldMeta.javaType') {{$index + 1}}) {{item.dbName}} / {{item.dbType}} / {{item.javaName}} / {{item.javaType}}
+                                a.labelFormField(ng-click='curField = tableStartEdit(backupItem, field, $index); curDbName = curField.dbName; curDbType = curField.dbType; curJavaName = curField.javaName; curJavaType = curField.javaType') {{$index + 1}}) {{item.dbName}} / {{item.dbType}} / {{item.javaName}} / {{item.javaType}}
                                 +btn-remove('tableRemove(backupItem, field, $index)')
                             div(ng-if='tableEditing(field, $index)')
                                 label.labelField {{$index + 1}})
@@ -266,18 +279,34 @@ mixin form-row-custom(lblClasses, fieldClasses)
                     tr.col-sm-12(ng-repeat='group in #{fieldMdl}')
                         td.col-sm-6
                             div
-                                div(ng-show='!tableEditing(field, $index)')
-                                    a.labelFormField(ng-click='curGroup = tableStartEdit(backupItem, field, $index); curName = curGroup.name; curFields = curGroup.fields') {{$index + 1}}) {{group.name}}
+                                .col-sm-12(ng-show='!tableEditing(field, $index)')
+                                    a.labelFormField(ng-click='curGroup = tableStartEdit(backupItem, field, $index); curGroupName = curGroup.name; curFields = curGroup.fields') {{$index + 1}}) {{group.name}}
                                     +btn-remove('tableRemove(backupItem, field, $index)')
+                                    +btn-add('tableGroupNewItem($index); newDirection = "ASC"')
                                 div(ng-show='tableEditing(field, $index)')
                                     label.labelField {{$index + 1}})
-                                    +btn-save('tableGroupSaveVisible(curName)', 'tableGroupSave(field, curDbName, curDbType, curJavaName, curJavaType, $index)')
+                                    +btn-save('tableGroupSaveVisible(curGroupName)', 'tableGroupSave(curGroupName, $index)')
                                     .input-tip
-                                        input.form-control(type='text' ng-model='curName' placeholder='Index name')
-                                table.links-edit.col-sm-12(st-table='group.fields' ng-show='group.fields.length > 0')
-                                    tr(ng-repeat='groupItem in group.fields')
-                                        td
-                                            a.labelFormField('') {{$index + 1}}) {{groupItem.name}} / {{groupItem.className}} / {{groupItem.direction}}
-                                            +btn-remove('tableRemoveGroupItem(group, $index)')
+                                        input.form-control(type='text' ng-model='curGroupName' placeholder='Index name')
+                                div
+                                    table.links-edit.col-sm-12(st-table='group.fields' ng-show='group.fields.length > 0' ng-init='groupIndex = $index')
+                                        tr(ng-repeat='groupItem in group.fields')
+                                            td
+                                                div(ng-show='!tableGroupItemEditing(groupIndex, $index)')
+                                                    a.labelFormField(ng-click='curGroupItem = tableGroupItemStartEdit(groupIndex, $index); curFieldName = curGroupItem.name; curClassName = curGroupItem.className; curDirection = curGroupItem.direction') {{$index + 1}}) {{groupItem.name}} / {{groupItem.className}} / {{groupItem.direction}}
+                                                    +btn-remove('tableRemoveGroupItem(group, $index)')
+                                                div(ng-show='tableGroupItemEditing(groupIndex, $index)')
+                                                    label.labelField {{$index + 1}})
+                                                    +btn-save('tableGroupItemSaveVisible(curFieldName, curClassName)', 'tableGroupItemSave(curFieldName, curClassName, curDirection, groupIndex, $index)')
+                                                    +table-group-item-edit('curFieldName', 'curClassName', 'curDirection')
+                                    .settings-row(style='padding-left: 18px' ng-show='tableGroupNewItemActive(groupIndex)')
+                                        +btn-save('tableGroupItemSaveVisible(newFieldName, newClassName)', 'tableGroupItemSave(newFieldName, newClassName, newDirection, groupIndex, -1)')
+                                        +table-group-item-edit('newFieldName', 'newClassName', 'newDirection')
+            .settings-row(ng-show='tableNewItemActive(field)')
+                .col-sm-6
+                    +btn-save('tableGroupSaveVisible(newGroupName)', 'tableGroupSave(newGroupName, -1)')
+                    .input-tip
+                        input.form-control(type='text' ng-model='newGroupName' placeholder='Group name')
+