ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: GNITE-2347 WIP Rework demo for load metadata.
Date Tue, 12 Jan 2016 11:12:57 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 65f74f5fb -> 941491116


GNITE-2347 WIP Rework demo for load metadata.


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

Branch: refs/heads/ignite-843-rc2
Commit: 94149111655086d9b32fd3cfae4675d7ec85bf75
Parents: 65f74f5
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Tue Jan 12 18:13:07 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Tue Jan 12 18:13:07 2016 +0700

----------------------------------------------------------------------
 .../main/js/controllers/metadata-controller.js  | 138 ++++++++++---------
 .../main/js/controllers/models/metadata.json    |  70 ----------
 .../src/main/js/public/stylesheets/style.scss   |   4 +-
 .../js/views/configuration/metadata-load.jade   |  54 ++++++--
 4 files changed, 117 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/94149111/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 5b24d12..69bf110 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
@@ -202,7 +202,6 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
 
                     if (preset) {
                         preset.jdbcUrl = restoredPreset.jdbcUrl;
-
                         preset.user = restoredPreset.user;
                     }
                 });
@@ -230,55 +229,54 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
             }
         }
 
-        $scope.preset = {
+        $scope.ui.selectedJdbcDriverJar = {};
+
+        $scope.$watch('ui.selectedJdbcDriverJar', function (val) {
+            if (val)
+                $scope.updateSelectedPreset(val);
+        }, true);
+
+        $scope.selectedPreset = {
             db: 'unknown',
-            jdbcDriverClass: '',
             jdbcDriverJar: '',
+            jdbcDriverClass: '',
             jdbcUrl: 'jdbc:[database]',
             user: 'sa',
+            password: '',
             tablesOnly: true
         };
 
-        $scope.selectedPreset = {};
-
         $scope.ui.showValid = true;
 
-        function _findPreset(idx) {
-            var selected = $scope.jdbcDriverJars[idx];
-
-            idx = _.findIndex(_dbPresets, function (preset) {
-                return preset.jdbcDriverClass === selected.jdbcDriverClass;
+        function _findPreset(selectedJdbcJar) {
+            var result = _.find(_dbPresets, function (preset) {
+                return preset.jdbcDriverClass === selectedJdbcJar.jdbcDriverClass;
             });
 
-            if (idx >= 0)
-                return _dbPresets[idx];
-
-            return {
-                db: 'unknown',
-                jdbcDriverClass: selected.jdbcDriverClass,
-                jdbcDriverJar: selected.jdbcDriverJar,
-                jdbcUrl: 'jdbc:[database]',
-                user: 'admin'
-            };
-        }
-
-        $scope.$watch('preset.drvIdx', function (drvIdx) {
-            if (_.isNumber(drvIdx)) {
-                var preset = $scope.jdbcDriverJars[drvIdx];
+            if (!result)
+                result = {
+                    db: 'unknown',
+                    jdbcUrl: 'jdbc:[database]',
+                    user: 'admin'
+                };
 
-                var jdbcDriverJar = preset.jdbcDriverJar;
+            result.jdbcDriverJar = selectedJdbcJar.jdbcDriverJar;
+            result.jdbcDriverClass = selectedJdbcJar.jdbcDriverClass;
 
-                preset = _findPreset(drvIdx);
+            return result;
+        }
 
-                var newPreset = angular.copy(preset);
+        $scope.updateSelectedPreset = function (selectedJdbcDriverJar) {
+            var foundPreset = _findPreset(selectedJdbcDriverJar);
 
-                newPreset.jdbcDriverJar = jdbcDriverJar;
-                newPreset.drvIdx = drvIdx;
-                newPreset.tablesOnly = $scope.preset.tablesOnly;
+            var selectedPreset = $scope.selectedPreset;
 
-                $scope.preset = newPreset;
-            }
-        }, true);
+            selectedPreset.db = foundPreset.db;
+            selectedPreset.jdbcDriverJar = foundPreset.jdbcDriverJar;
+            selectedPreset.jdbcDriverClass = foundPreset.jdbcDriverClass;
+            selectedPreset.jdbcUrl = foundPreset.jdbcUrl;
+            selectedPreset.user = foundPreset.user;
+        };
 
         $scope.supportedJdbcTypes = $common.mkOptions($common.SUPPORTED_JDBC_TYPES);
 
@@ -289,7 +287,7 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
             {value: false, label: 'DESC'}
         ];
 
-        $scope.panels = {activePanels: [0, 1]};
+        $scope.panels = { activePanels: [0, 1] };
 
         $scope.metadatas = [];
 
@@ -377,38 +375,45 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
                     if ($scope.loadMeta.action === 'drivers') {
                         $loading.start('loadingMetadataFromDb');
 
+                        $scope.jdbcDriverJars = [];
+                        $scope.ui.selectedJdbcDriverJar = {};
+
                         $http.post('/api/v1/agent/drivers')
                             .success(function (drivers) {
                                 onSuccess();
 
                                 if (drivers && drivers.length > 0) {
-                                    $scope.jdbcDriverJars = [];
+                                    drivers = _.sortBy(drivers, 'jdbcDriverJar');
 
-                                    var _h2DrvJar = _.find(drivers, function (drv) {
-                                        return drv.jdbcDriverJar.startsWith('h2');
-                                    });
+                                    if ($scope.loadMeta.demo) {
+                                        var _h2DrvJar = _.find(drivers, function (drv) {
+                                            return drv.jdbcDriverJar.startsWith('h2');
+                                        });
 
-                                    if (_h2DrvJar) {
-                                        $scope.demoConnection = {
-                                            jdbcDriverJar: _h2DrvJar.jdbcDriverJar,
-                                            jdbcDriverClass: 'org.h2.Driver',
-                                            jdbcUrl: 'jdbc:h2:mem:demo-db',
-                                            user: 'sa',
-                                            password: '',
-                                            tablesOnly: true
-                                        };
+                                        if (_h2DrvJar) {
+                                            $scope.selectedPreset = {
+                                                jdbcDriverJar: _h2DrvJar.jdbcDriverJar,
+                                                jdbcDriverClass: 'org.h2.Driver',
+                                                jdbcUrl: 'jdbc:h2:mem:demo-db',
+                                                user: 'sa',
+                                                password: '',
+                                                tablesOnly: true
+                                            };
+                                        }
                                     }
-
-                                    drivers.forEach(function (driver) {
-                                        $scope.jdbcDriverJars.push({
-                                            label: driver.jdbcDriverJar,
-                                            value: $scope.jdbcDriverJars.length,
-                                            jdbcDriverJar: driver.jdbcDriverJar,
-                                            jdbcDriverClass: driver.jdbcDriverClass
+                                    else {
+                                        drivers.forEach(function (driver) {
+                                            $scope.jdbcDriverJars.push({
+                                                label: driver.jdbcDriverJar,
+                                                value: {
+                                                    jdbcDriverJar: driver.jdbcDriverJar,
+                                                    jdbcDriverClass: driver.jdbcDriverClass
+                                                }
+                                            });
                                         });
-                                    });
 
-                                    $scope.preset.drvIdx = 0;
+                                        $scope.ui.selectedJdbcDriverJar = $scope.jdbcDriverJars[0].value;
+                                    }
 
                                     $common.confirmUnsavedChanges($scope.ui.isDirty(), function
() {
                                         loadMetaModal.$promise.then(function () {
@@ -445,13 +450,15 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
         function _loadSchemas() {
             $loading.start('loadingMetadataFromDb');
 
-            $scope.selectedPreset = $scope.loadMeta.demo ? angular.copy($scope.demoConnection)
: angular.copy($scope.preset);
+            if (!$scope.loadMeta.demo)
+                _savePreset($scope.selectedPreset);
 
             $http.post('/api/v1/agent/schemas', $scope.selectedPreset)
                 .success(function (schemas) {
                     $scope.loadMeta.schemas = _.map(schemas, function (schema) {
                         return {use: false, name: schema};
                     });
+
                     $scope.loadMeta.action = 'schemas';
 
                     if ($scope.loadMeta.schemas.length === 0)
@@ -460,14 +467,14 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
                         _.forEach($scope.loadMeta.schemas, function (sch) {
                             sch.use = true;
                         });
+
+                    $scope.loadMeta.info = INFO_SELECT_SCHEMAS;
+                    $scope.loadMeta.loadingOptions = LOADING_TABLES;
                 })
                 .error(function (errMsg) {
                     $common.showError(errMsg);
                 })
                 .finally(function() {
-                    $scope.loadMeta.info = INFO_SELECT_SCHEMAS;
-                    $scope.loadMeta.loadingOptions = LOADING_TABLES;
-
                     $loading.finish('loadingMetadataFromDb');
                 });
         }
@@ -500,16 +507,15 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
                         }));
                     });
 
-                    $scope.loadMeta.tables = tables;
                     $scope.loadMeta.action = 'tables';
+                    $scope.loadMeta.tables = tables;
+                    $scope.loadMeta.info = INFO_SELECT_TABLES;
+                    $scope.loadMeta.loadingOptions = LOADING_METADATA;
                 })
                 .error(function (errMsg) {
                     $common.showError(errMsg);
                 })
                 .finally(function() {
-                    $scope.loadMeta.info = INFO_SELECT_TABLES;
-                    $scope.loadMeta.loadingOptions = LOADING_METADATA;
-
                     $loading.finish('loadingMetadataFromDb');
                 });
         }
@@ -615,8 +621,6 @@ consoleModule.controller('metadataController', function ($filter, $http,
$timeou
             if (!$common.isValidJavaClass('Package', $scope.ui.packageName, false, 'metadataLoadPackage',
true))
                 return false;
 
-            _savePreset($scope.preset);
-
             var batch = [];
             var tables = [];
             var dupCnt = 0;

http://git-wip-us.apache.org/repos/asf/ignite/blob/94149111/modules/control-center-web/src/main/js/controllers/models/metadata.json
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/models/metadata.json b/modules/control-center-web/src/main/js/controllers/models/metadata.json
index 39bcb7b..752c434 100644
--- a/modules/control-center-web/src/main/js/controllers/models/metadata.json
+++ b/modules/control-center-web/src/main/js/controllers/models/metadata.json
@@ -160,75 +160,5 @@
         }
       ]
     }
-  ],
-  "metadataDb": [
-    {
-      "label": "Driver JAR",
-      "id": "jdbcDriverJar",
-      "type": "dropdown",
-      "container": "false",
-      "model": "drvIdx",
-      "items": "jdbcDriverJars",
-      "tip": [
-        "Select appropriate JAR with JDBC driver",
-        "To add another driver you need to place it into '/jdbc-drivers' folder of Ignite
Web Agent",
-        "Refer to Ignite Web Agent README.txt for for more information"
-      ]
-    },
-    {
-      "label": "JDBC Driver",
-      "id": "jdbcDriverClass",
-      "type": "text",
-      "disabled": "jdbcDriverJars[preset.drvIdx].demo",
-      "model": "jdbcDriverClass",
-      "placeholder": "Full class name of JDBC driver",
-      "tip": [
-        "Full class name of JDBC driver that will be used to connect to database"
-      ]
-    },
-    {
-      "label": "JDBC URL",
-      "id": "jdbcUrl",
-      "type": "text",
-      "disabled": "jdbcDriverJars[preset.drvIdx].demo",
-      "model": "jdbcUrl",
-      "placeholder": "JDBC URL",
-      "tip": [
-        "JDBC URL for connecting to database",
-        "Refer to your database documentation for details"
-      ]
-    },
-    {
-      "label": "User",
-      "id": "user",
-      "type": "text",
-      "disabled": "jdbcDriverJars[preset.drvIdx].demo",
-      "model": "user",
-      "tip": [
-        "User name for connecting to database"
-      ]
-    },
-    {
-      "label": "Password",
-      "id": "password",
-      "type": "password",
-      "disabled": "jdbcDriverJars[preset.drvIdx].demo",
-      "model": "password",
-      "onEnter": "loadMetadataNext()",
-      "tip": [
-        "Password for connecting to database",
-        "Note, password would not be saved in preferences for security reasons"
-      ]
-    },
-    {
-      "label": "Tables only",
-      "id": "tablesOnly",
-      "type": "check",
-      "model": "tablesOnly",
-      "tip": [
-        "If selected, then only tables metadata will be parsed",
-        "Otherwise table and view metadata will be parsed"
-      ]
-    }
   ]
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/94149111/modules/control-center-web/src/main/js/public/stylesheets/style.scss
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/public/stylesheets/style.scss b/modules/control-center-web/src/main/js/public/stylesheets/style.scss
index 2750954..36827cb 100644
--- a/modules/control-center-web/src/main/js/public/stylesheets/style.scss
+++ b/modules/control-center-web/src/main/js/public/stylesheets/style.scss
@@ -831,7 +831,7 @@ button.form-control {
 }
 
 .metadata-content {
-    margin: 15px 30px;
+    margin: 20px;
 }
 
 .scrollable-y {
@@ -1811,7 +1811,7 @@ treecontrol.tree-classic {
     }
 
     a {
-        font-family: normal;
+        font-weight: normal;
         padding-left: 20px;
         float: none;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/94149111/modules/control-center-web/src/main/js/views/configuration/metadata-load.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/configuration/metadata-load.jade
b/modules/control-center-web/src/main/js/views/configuration/metadata-load.jade
index 3c21d7c..9bf060d 100644
--- a/modules/control-center-web/src/main/js/views/configuration/metadata-load.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/metadata-load.jade
@@ -26,7 +26,7 @@ mixin chk(mdl, change, tip)
                 button.close(ng-click='$hide()' aria-hidden='true') &times;
                 h4.modal-title Load metadata from database
             .metadata-content(ng-show='loadMeta.action == "drivers"')
-            .metadata-content(ng-show='loadMeta.action == "connect" && loadMeta.demo')
+            .metadata-content(ng-show='loadMeta.action == "connect" && loadMeta.demo'
style='margin-bottom: 141px')
                 label Demo description:
                 ul
                     li In-memory H2 database server will be started inside agent
@@ -35,9 +35,43 @@ mixin chk(mdl, change, tip)
                     li Click "Next" to continue
             .metadata-content(ng-show='loadMeta.action == "connect" && !loadMeta.demo')
                 form.form-horizontal(name='connectForm' novalidate)
-                    .settings-row(ng-repeat='field in metadataDb')
-                        +form-row-custom(['col-xs-4 col-sm-3 col-md-3'], ['col-xs-8 col-sm-9
col-md-9'], 'selectedPreset')
-            .metadata-content(ng-show='loadMeta.action == "schemas"' style='margin-bottom:
50px')
+                    .settings-row
+                        label.col-xs-4.col-sm-2.col-md-2 Driver JAR:
+                        .col-xs-8.col-sm-10.col-md-10
+                            i.tipField.fa.fa-question-circle(bs-tooltip='' data-title='Select
appropriate JAR with JDBC driver<br> To add another driver you need to place it into
"/jdbc-drivers" folder of Ignite Web Agent<br> Refer to Ignite Web Agent README.txt
for for more information')
+                            .input-tip
+                                button.select-toggle.form-control(id='jdbcDriverJar' bs-select
ng-model='ui.selectedJdbcDriverJar' ng-class='{placeholder: !(jdbcDriverJars && jdbcDriverJars.length
> 0)}' data-container='false' placeholder='Choose JDBC driver' bs-options='item.value as
item.label for item in jdbcDriverJars')
+                    .settings-row
+                        label.col-xs-4.col-sm-2.col-md-2 JDBC Driver:
+                        .col-xs-8.col-sm-10.col-md-10
+                            i.tipField.fa.fa-question-circle(bs-tooltip='' data-title='Fully
qualified class name of JDBC driver that will be used to connect to database')
+                            .input-tip
+                                input.form-control(id='jdbcDriverClass' type='text' ng-model='selectedPreset.jdbcDriverClass'
placeholder='JDBC driver fully qualified class name' required=true)
+                    .settings-row
+                        label.col-xs-4.col-sm-2.col-md-2 JDBC URL:
+                        .col-xs-8.col-sm-10.col-md-10
+                            i.tipField.fa.fa-question-circle(bs-tooltip='' data-title='JDBC
URL for connecting to database<br>Refer to your database documentation for details')
+                            .input-tip
+                                input.form-control(id='jdbcUrl' type='text' ng-model='selectedPreset.jdbcUrl'
placeholder='JDBC URL' required=true)
+                    .settings-row
+                        label.col-xs-4.col-sm-2.col-md-2 User:
+                        .col-xs-8.col-sm-10.col-md-10
+                            i.tipField.fa.fa-question-circle(bs-tooltip='' data-title='User
name for connecting to database')
+                            .input-tip
+                                input.form-control(id='user' type='text' ng-model='selectedPreset.user')
+                    .settings-row
+                        label.col-xs-4.col-sm-2.col-md-2 Password:
+                        .col-xs-8.col-sm-10.col-md-10
+                            i.tipField.fa.fa-question-circle(bs-tooltip='' data-title='Password
for connecting to database<br>Note, password would not be saved in preferences for security
reasons')
+                            .input-tip
+                                input.form-control(id='password' type='password' ng-model='selectedPreset.password'
on-enter='loadMetadataNext()')
+                    .settings-row
+                        .checkbox
+                            label
+                                input(id='tablesOnly' type='checkbox' ng-model='selectedPreset.tablesOnly')
+                                | Tables only
+                            i.tipLabel.fa.fa-question-circle(bs-tooltip='' data-title='If
selected, then only tables metadata will be parsed<br>Otherwise table and view metadata
will be parsed')
+            .metadata-content(ng-show='loadMeta.action == "schemas"')
                 table.table.metadata(st-table='loadMeta.displayedSchemas' st-safe-src='loadMeta.schemas')
                     thead
                         tr
@@ -52,7 +86,7 @@ mixin chk(mdl, change, tip)
                         tbody
                             tr
                                 td(colspan='2')
-                                    .scrollable-y(style='height: 184px')
+                                    .scrollable-y(style='height: 137px')
                                         table.table-modal-striped(id='metadataSchemaData')
                                             tbody
                                                 tr(ng-repeat='schema in loadMeta.displayedSchemas')
@@ -60,7 +94,7 @@ mixin chk(mdl, change, tip)
                                                         input(type='checkbox' ng-model='schema.use'
ng-change='selectSchema()')
                                                     td
                                                         label {{::schema.name}}
-            .metadata-content(ng-show='loadMeta.action == "tables"' style='margin-bottom:
50px')
+            .metadata-content(ng-show='loadMeta.action == "tables"')
                 table.table.metadata(st-table='loadMeta.displayedTables' st-safe-src='loadMeta.tables')
                     thead
                         tr
@@ -70,14 +104,14 @@ mixin chk(mdl, change, tip)
                         tr
                             th(width='50px')
                                 +chk('loadMeta.allTablesSelected',  'selectAllTables()',
'Select all tables')
-                            th(width='200px')
+                            th(width='117px')
                                 label Schema
                             th
                                 label Table name
                     tbody
                         tr
                             td(colspan='3')
-                                .scrollable-y(style='height: 184px')
+                                .scrollable-y(style='height: 137px')
                                     table.table-modal-striped(id='metadataTableData')
                                         tbody
                                             tr(ng-repeat='table in loadMeta.displayedTables')
@@ -87,7 +121,7 @@ mixin chk(mdl, change, tip)
                                                     label {{::table.schema}}
                                                 td
                                                     label {{::table.tbl}}
-            .metadata-content(ng-show='loadMeta.action == "options"' style='margin-bottom:
152px')
+            .metadata-content(ng-show='loadMeta.action == "options"' style='margin-bottom:
75px')
                 form.form-horizontal(name='optionsForm' novalidate)
                     .settings-row
                         .col-xs-3.col-sm-2.col-md-2.required
@@ -122,6 +156,6 @@ mixin chk(mdl, change, tip)
                             .input-tip
                                 button.select-toggle.form-control(id='metadataGeneratedCachesCluster'
bs-select ng-model='ui.generatedCachesClusters' ng-disabled='!ui.generateCaches' ng-class='{placeholder:
!(ui.generatedCachesClusters && ui.generatedCachesClusters.length > 0)}' data-container='false'
data-multiple='1' placeholder='Choose clusters for generated caches' bs-options='item.value
as item.label for item in clusters')
             .modal-footer
-                label.labelField {{loadMeta.info}}
+                label(ng-hide='loadMeta.action == "connect" && loadMeta.demo').labelField
{{loadMeta.info}}
                 button.btn.btn-primary(ng-show='loadMeta.action != "connect"' ng-click='loadMetadataPrev()')
Prev
                 a.btn.btn-primary(ng-click='loadMetadataNext()' ng-disabled='!nextAvailable()'
bs-tooltip='' data-title='{{nextTooltipText()}}' data-placement='bottom') {{loadMeta.button}}


Mime
View raw message