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 Implemented table for db fields metadata.
Date Mon, 20 Jul 2015 10:34:41 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 75d817581 -> d298fd8d4


IGNITE-843 Implemented table for db fields metadata.


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

Branch: refs/heads/ignite-843
Commit: d298fd8d4013d200de506766b09592187fe1e475
Parents: 75d8175
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Jul 20 17:34:38 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Jul 20 17:34:38 2015 +0700

----------------------------------------------------------------------
 .../nodejs/controllers/common-module.js         | 11 ++-
 .../nodejs/controllers/metadata-controller.js   | 88 ++++++++++++++++++++
 .../nodejs/controllers/models/metadata.json     | 10 +--
 modules/web-control-center/nodejs/db.js         |  4 +-
 .../nodejs/public/stylesheets/style.less        | 20 +++++
 .../nodejs/views/includes/controls.jade         | 45 +++++++++-
 6 files changed, 165 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d298fd8d/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 a94d23c..f0667c2 100644
--- a/modules/web-control-center/nodejs/controllers/common-module.js
+++ b/modules/web-control-center/nodejs/controllers/common-module.js
@@ -110,6 +110,9 @@ controlCenterModule.service('$common', ['$alert', function ($alert) {
             return lines.join("");
         },
         isDefined: isDefined,
+        isNonEmpty: function (s) {
+            return isDefined(s) && s.trim().length > 0;
+        },
         errorMessage: errorMessage,
         showError: function (msg) {
             if (msgModal)
@@ -214,6 +217,9 @@ controlCenterModule.service('$table', ['$common', function ($common) {
     }
 
     return {
+        tableReset: function () {
+            _tableReset();
+        },
         tableNewItem: function (field) {
             _tableState(field.model, -1);
         },
@@ -248,7 +254,7 @@ controlCenterModule.service('$table', ['$common', function ($common) {
             }
         },
         tableSimpleSaveVisible: function(newValue) {
-            return $common.isDefined(newValue) && newValue.trim().length > 0;
+            return $common.isNonEmpty(newValue);
         },
         tableSimpleUp: function (item, field, index) {
             _tableReset();
@@ -287,8 +293,7 @@ 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;
+            return $common.isNonEmpty(newKey) && $common.isNonEmpty(newValue);
         }
     }
 }]);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d298fd8d/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 017b316..b56b94e 100644
--- a/modules/web-control-center/nodejs/controllers/metadata-controller.js
+++ b/modules/web-control-center/nodejs/controllers/metadata-controller.js
@@ -57,6 +57,51 @@ controlCenterModule.controller('metadataController', ['$scope', '$http',
'$commo
             {value: 'h2', label: 'H2 database'}
         ];
 
+        $scope.jdbcTypes = [
+            {value: 'BIT', label: 'BIT'},
+            {value: 'BOOLEAN', label: 'BOOLEAN'},
+            {value: 'TINYINT', label: 'TINYINT'},
+            {value: 'SMALLINT', label: 'SMALLINT'},
+            {value: 'INTEGER', label: 'INTEGER'},
+            {value: 'BIGINT', label: 'BIGINT'},
+            {value: 'REAL', label: 'REAL'},
+            {value: 'FLOAT', label: 'FLOAT'},
+            {value: 'DOUBLE', label: 'DOUBLE'},
+            {value: 'NUMERIC', label: 'NUMERIC'},
+            {value: 'DECIMAL', label: 'DECIMAL'},
+            {value: 'CHAR', label: 'CHAR'},
+            {value: 'VARCHAR', label: 'VARCHAR'},
+            {value: 'LONGVARCHAR', label: 'LONGVARCHAR'},
+            {value: 'NCHAR', label: 'NCHAR'},
+            {value: 'NVARCHAR', label: 'NVARCHAR'},
+            {value: 'LONGNVARCHAR', label: 'LONGNVARCHAR'},
+            {value: 'DATE', label: 'DATE'},
+            {value: 'TIME', label: 'TIME'},
+            {value: 'TIMESTAMP', label: 'TIMESTAMP'}
+        ];
+
+        $scope.javaTypes = [
+            {value: 'boolean', label: 'boolean'},
+            {value: 'Boolean', label: 'Boolean'},
+            {value: 'byte', label: 'byte'},
+            {value: 'Byte', label: 'Byte'},
+            {value: 'short', label: 'short'},
+            {value: 'Short', label: 'Short'},
+            {value: 'int', label: 'int'},
+            {value: 'Integer', label: 'Integer'},
+            {value: 'long', label: 'long'},
+            {value: 'Long', label: 'Long'},
+            {value: 'float', label: 'float'},
+            {value: 'Float', label: 'Float'},
+            {value: 'double', label: 'double'},
+            {value: 'Double', label: 'Double'},
+            {value: 'BigDecimal', label: 'BigDecimal'},
+            {value: 'String', label: 'String'},
+            {value: 'Date', label: 'Date'},
+            {value: 'Time', label: 'Time'},
+            {value: 'Timestamp', label: 'Timestamp'}
+        ];
+
         $scope.data = {
             curTableIdx: 0,
             curFieldIdx: 0,
@@ -352,6 +397,49 @@ controlCenterModule.controller('metadataController', ['$scope', '$http',
'$commo
             return true;
         };
 
+        $scope.tableDbFieldSaveVisible = function(dbName, dbType, javaName, javaType){
+            return $common.isNonEmpty(dbName) && $common.isDefined(dbType) &&
+                $common.isNonEmpty(javaName) && $common.isDefined(javaType);
+        };
+
+        $scope.tableDbFieldSave = function(field, newDbName, newDbType, newJavaName, newJavaType,
index) {
+            var item = $scope.backupItem;
+
+            var model = item[field.model];
+
+            var newItem = {dbName: newDbName, dbType: newDbType, javaName: newJavaName, javaType:
newJavaType};
+
+            if ($common.isDefined(model)) {
+                var idx = _.findIndex(model, function (dbMeta) {return dbMeta.dbName == newDbName});
+
+                // Found duplicate.
+                if (idx >= 0 && index != idx) {
+                    $common.showError('DB field with such name already exists!');
+
+                    return;
+                }
+
+                if (index < 0) {
+                    if (model)
+                        model.push(newItem);
+                    else
+                        item[field.model] = [newItem];
+                }
+                else {
+                    var dbField = model[index];
+
+                    dbField.dbName = newDbName;
+                    dbField.dbType = newDbType;
+                    dbField.javaName = newJavaName;
+                    dbField.javaType = newJavaType;
+                }
+            }
+            else
+                item[field.model] = [newItem];
+
+            $table.tableReset();
+        };
+
         $scope.selectSchema = function (idx) {
             var data = $scope.data;
             var tables = data.tables;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d298fd8d/modules/web-control-center/nodejs/controllers/models/metadata.json
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/models/metadata.json b/modules/web-control-center/nodejs/controllers/models/metadata.json
index cff787f..a3c0c75 100644
--- a/modules/web-control-center/nodejs/controllers/models/metadata.json
+++ b/modules/web-control-center/nodejs/controllers/models/metadata.json
@@ -61,7 +61,7 @@
     },
     {
       "label": "Key fields",
-      "type": "fieldsMetadata",
+      "type": "dbFields",
       "model": "keyFields",
       "keyName": "name",
       "valueName": "className",
@@ -70,7 +70,7 @@
     },
     {
       "label": "Value fields",
-      "type": "fieldsMetadata",
+      "type": "dbFields",
       "model": "valueFields",
       "keyName": "name",
       "valueName": "className",
@@ -79,7 +79,7 @@
     },
     {
       "label": "Query fields",
-      "type": "fieldsMetadata",
+      "type": "queryFields",
       "model": "queryFields",
       "keyName": "name",
       "valueName": "className",
@@ -88,7 +88,7 @@
     },
     {
       "label": "Ascending fields",
-      "type": "fieldsMetadata",
+      "type": "queryFields",
       "model": "ascendingFields",
       "keyName": "name",
       "valueName": "className",
@@ -97,7 +97,7 @@
     },
     {
       "label": "Descending fields",
-      "type": "fieldsMetadata",
+      "type": "queryFields",
       "model": "descendingFields",
       "keyName": "name",
       "valueName": "className",

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d298fd8d/modules/web-control-center/nodejs/db.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/db.js b/modules/web-control-center/nodejs/db.js
index b8034a3..ae34573 100644
--- a/modules/web-control-center/nodejs/db.js
+++ b/modules/web-control-center/nodejs/db.js
@@ -70,8 +70,8 @@ var CacheTypeMetadataSchema = new Schema({
     databaseTable: String,
     keyType: String,
     valueType: String,
-    keyFields: [{dbName: String, dbType: Number, javaName: String, javaType: String}],
-    valueFields: [{dbName: String, dbType: Number, javaName: String, javaType: String}],
+    keyFields: [{dbName: String, dbType: String, javaName: String, javaType: String}],
+    valueFields: [{dbName: String, dbType: String, javaName: String, javaType: String}],
     queryFields: [{name: String, className: String}],
     ascendingFields: [{name: String, className: String}],
     descendingFields:  [{name: String, className: String}],

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d298fd8d/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 2323b9f..80bbbdb 100644
--- a/modules/web-control-center/nodejs/public/stylesheets/style.less
+++ b/modules/web-control-center/nodejs/public/stylesheets/style.less
@@ -871,6 +871,18 @@ label {
   cursor: pointer;
 }
 
+.fa-floppy-o {
+  cursor: pointer;
+}
+
+.fa-arrow-up {
+  cursor: pointer;
+}
+
+.fa-arrow-down {
+  cursor: pointer;
+}
+
 label.required:after {
   color: @ignite-red;
   content: ' *';
@@ -1062,12 +1074,20 @@ a {
   list-style: none;
   margin: 0;
   padding: 0;
+
+  label {
+    line-height: @input-height;
+  }
 }
 
 .grid-cell {
   flex-basis: 50%;
 }
 
+.grid-cell-4 {
+  flex-basis: 25%;
+}
+
 .grid-fixed-cell {
   flex-basis: 10px;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d298fd8d/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 9da9d49..aedee2c 100644
--- a/modules/web-control-center/nodejs/views/includes/controls.jade
+++ b/modules/web-control-center/nodejs/views/includes/controls.jade
@@ -137,6 +137,23 @@ mixin details-row
                 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 table-db-field-edit(dbName, dbType, javaName, javaType)
+    .grid
+        .grid-cell-4
+            input.form-control(type='text' ng-model=dbName placeholder='DB name')
+        div
+            label &nbsp;/&nbsp;
+        .grid-cell-4
+            button.form-control(ng-model=dbType bs-select data-placeholder='JDBC type' bs-options='item.value
as item.label for item in {{jdbcTypes}}')
+        div
+            label &nbsp;/&nbsp;
+        .grid-cell-4
+            input.form-control(type='text' ng-model=javaName placeholder='Java name')
+        div
+            label &nbsp;/&nbsp;
+        .grid-cell-4
+            button.form-control(ng-model=javaType bs-select data-placeholder='Java type'
bs-options='item.value as item.label for item in {{javaTypes}}')
+
 mixin form-row
     +form-row-custom(['col-sm-2'], ['col-sm-4'])
 
@@ -224,9 +241,31 @@ mixin form-row-custom(lblClasses, fieldClasses)
                     +btn-save('tableSimpleSaveVisible(newValue)', 'tableSimpleSave(tableSimpleValid,
backupItem, field, newValue, -1)')
                     .input-tip
                         input.form-control(type='text' ng-model='newValue' placeholder='{{field.placeholder}}')
-        div(ng-switch-when='fieldsMetadata' ng-hide=fieldHide)
+        div(ng-switch-when='indexedTypes')
+            +table-pair('Index key-value type pairs', fieldMdl, 'keyClass', 'valueClass',
'Key class full name', 'Value class full name')
+        div(ng-switch-when='queryFields' ng-hide=fieldHide)
             +table-pair('{{field.label}}', fieldMdl, 'name', 'className', 'Field name', 'Field
class full name')
+        div(ng-switch-when='dbFields' ng-hide=fieldHide)
+            .col-sm-6
+                label.table-header {{field.label}}:
+                +tipLabel('field.tip')
+                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}')
+                        td.col-sm-6
+                            div(ng-show='!tableEditing(field, $index)')
+                                a(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}}
+                                +btn-remove('tableRemove(backupItem, field, $index)')
+                            div(ng-if='tableEditing(field, $index)')
+                                label.labelField {{$index + 1}})
+                                +btn-save('tableDbFieldSaveVisible(curDbName, curDbType,
curJavaName, curJavaType)', 'tableDbFieldSave(field, curDbName, curDbType, curJavaName, curJavaType,
$index)')
+                                .input-tip
+                                    +table-db-field-edit('curDbName', 'curDbType', 'curJavaName',
'curJavaType')
+            .settings-row(ng-show='tableNewItemActive(field)')
+                .col-sm-6
+                    +btn-save('tableDbFieldSaveVisible(newDbName, newDbType, newJavaName,
newJavaType)', 'tableDbFieldSave(field, newDbName, newDbType, newJavaName, newJavaType, -1)')
+                    .input-tip
+                        +table-db-field-edit('newDbName', 'newDbType', 'newJavaName', 'newJavaType')
         div(ng-switch-when='groupsMetadata' ng-hide=fieldHide)&attributes(fieldCommon)
             label.table-header {{field.label}}:
-        div(ng-switch-when='indexedTypes')
-            +table-pair('Index key-value type pairs', fieldMdl, 'keyClass', 'valueClass',
'Key class full name', 'Value class full name')


Mime
View raw message