ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject ignite git commit: ignite-1485 Metadata loading fixes
Date Tue, 06 Oct 2015 04:09:26 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 3d9ac74aa -> 068e31342


ignite-1485 Metadata loading fixes


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

Branch: refs/heads/ignite-843
Commit: 068e313427095908a73518a21358502686902eac
Parents: 3d9ac74
Author: Vasiliy Sisko <vsisko@gridgain.com>
Authored: Tue Oct 6 11:09:16 2015 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Tue Oct 6 11:09:16 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    |  8 ++--
 .../src/main/js/controllers/common-module.js    | 27 +++++++++---
 .../main/js/controllers/metadata-controller.js  | 46 ++++++++++++++++----
 .../src/main/js/public/stylesheets/style.scss   | 13 ++++++
 .../main/js/views/configuration/metadata.jade   | 23 +++++++++-
 .../src/main/js/views/includes/controls.jade    |  2 +-
 6 files changed, 98 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/068e3134/modules/control-center-web/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/caches-controller.js b/modules/control-center-web/src/main/js/controllers/caches-controller.js
index 9171774..5e657a4 100644
--- a/modules/control-center-web/src/main/js/controllers/caches-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js
@@ -17,8 +17,8 @@
 
 // Controller for Caches screen.
 consoleModule.controller('cachesController', [
-    '$scope', '$controller', '$http', '$timeout', '$common', '$focus', '$confirm', '$message',
'$clone', '$table', '$preview', '$loading', '$unsavedChangesGuard',
-    function ($scope, $controller, $http, $timeout, $common, $focus, $confirm, $message,
$clone, $table, $preview, $loading, $unsavedChangesGuard) {
+    '$scope', '$controller', '$filter', '$http', '$timeout', '$common', '$focus', '$confirm',
'$message', '$clone', '$table', '$preview', '$loading', '$unsavedChangesGuard',
+    function ($scope, $controller, $filter, $http, $timeout, $common, $focus, $confirm, $message,
$clone, $table, $preview, $loading, $unsavedChangesGuard) {
             $unsavedChangesGuard.install($scope);
 
             // Initialize the super class and extend it.
@@ -233,10 +233,12 @@ consoleModule.controller('cachesController', [
             // When landing on the page, get caches and show them.
             $http.post('caches/list')
                 .success(function (data) {
+                    var validFilter = $filter('metadatasValidation');
+
                     $scope.spaces = data.spaces;
                     $scope.caches = data.caches;
                     $scope.clusters = data.clusters;
-                    $scope.metadatas = _.sortBy(_.map(data.metadatas, function (meta) {
+                    $scope.metadatas = _.sortBy(_.map(validFilter(data.metadatas, true, false),
function (meta) {
                         return {value: meta._id, label: meta.valueType, kind: meta.kind,
meta: meta}
                     }), 'label');
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/068e3134/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 3024f36..07c8378 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
@@ -865,19 +865,13 @@ consoleModule.service('$confirm', function ($modal, $rootScope, $q)
{
     var confirmModal = $modal({templateUrl: '/confirm', scope: scope, placement: 'center',
show: false});
 
     scope.confirmOk = function () {
-        deferred.reject('cancelled');
-
-        confirmModal.hide();
-    };
-
-    scope.confirmOk = function () {
         deferred.resolve(true);
 
         confirmModal.hide();
     };
 
     scope.confirmCancel = function () {
-        deferred.resolve(false);
+        deferred.reject('cancelled');
 
         confirmModal.hide();
     };
@@ -1607,6 +1601,25 @@ consoleModule.filter('metadatasSearch', function() {
     }
 });
 
+// Filter metadata with key fields configuration.
+consoleModule.filter('metadatasValidation', ['$common', function ($common) {
+    return function(metadatas, valid, invalid) {
+        if (valid && invalid)
+            return metadatas;
+
+        var out = [];
+
+        _.forEach(metadatas, function (meta) {
+            var _valid = !$common.metadataForStoreConfigured(meta) || $common.isJavaBuildInClass(meta.keyType)
|| !$common.isEmptyArray(meta.keyFields);
+
+            if (valid && _valid || invalid && !_valid)
+                out.push(meta);
+        });
+
+        return out;
+    }
+}]);
+
 // Directive to enable validation for IP addresses.
 consoleModule.directive('ipaddress', function () {
     const ip = '(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])';

http://git-wip-us.apache.org/repos/asf/ignite/blob/068e3134/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 8a8f085..4ebc894 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
@@ -131,6 +131,8 @@ consoleModule.controller('metadataController', [
                 tablesOnly: true
             };
 
+            $scope.ui.showValid = true;
+
             var jdbcDrivers = [];
 
             function _findPreset(jdbcDriverJar) {
@@ -300,6 +302,12 @@ consoleModule.controller('metadataController', [
                         $scope.loadMeta.tables = tables;
                         $scope.loadMeta.action = 'tables';
                         $scope.loadMeta.button = 'Save';
+
+                        _.forEach(tables, function (tbl) {
+                            tbl.use = $common.isDefined(_.find(tbl.cols, function (col) {
+                                return col.key;
+                            }));
+                        })
                     })
                     .error(function (errMsg) {
                         $common.showError(errMsg);
@@ -410,6 +418,8 @@ consoleModule.controller('metadataController', [
                 var tables = [];
                 var dupCnt = 0;
 
+                var containKey = true;
+
                 _.forEach($scope.loadMeta.tables, function (table) {
                     if (table.use) {
                         var qryFields = [];
@@ -448,6 +458,8 @@ consoleModule.controller('metadataController', [
                             return 'Unknown';
                         }
 
+                        var _containKey = false;
+
                         _.forEach(table.cols, function (col) {
                             var colName = col.name;
                             var jdbcType = $common.findJdbcType(col.type);
@@ -461,12 +473,17 @@ consoleModule.controller('metadataController', [
                             if (_.includes(table.descCols, colName))
                                 descFields.push(queryField(colName, jdbcType));
 
-                            if (col.key)
+                            if (col.key) {
                                 keyFields.push(dbField(colName, jdbcType));
+
+                                _containKey = true;
+                            }
                             else
                                 valFields.push(dbField(colName, jdbcType));
                         });
 
+                        containKey &= _containKey;
+
                         var idxs = table.idxs;
 
                         if (table.idxs) {
@@ -554,15 +571,26 @@ consoleModule.controller('metadataController', [
 
                 var itemsToConfirm = _.filter(batch, function (item) { return item.confirm;
});
 
-                if (itemsToConfirm.length > 0)
-                    $confirmBatch.confirm(overwriteMessage, itemsToConfirm)
-                        .then(function () {
-                            _saveBatch(_.filter(batch, function (item) {return !item.skip}));
-                        }, function () {
-                            $common.showError('Cache type metadata loading interrupted by
user.');
-                        });
+                function checkOverwrite() {
+                    if (itemsToConfirm.length > 0)
+                        $confirmBatch.confirm(overwriteMessage, itemsToConfirm)
+                            .then(function () {
+                                _saveBatch(_.filter(batch, function (item) {
+                                    return !item.skip
+                                }));
+                            }, function () {
+                                $common.showError('Cache type metadata loading interrupted
by user.');
+                            });
+                    else
+                        _saveBatch(batch);
+                }
+
+                if (containKey)
+                    checkOverwrite();
                 else
-                    _saveBatch(batch);
+                    $confirm.confirm('Imported tables contain tables without primary key.<br/>'
+
+                        'You should manually configure key type and key fields for these
metadata types.')
+                        .then(function () { checkOverwrite(); })
             }
 
             $scope.loadMetadataNext = function () {

http://git-wip-us.apache.org/repos/asf/ignite/blob/068e3134/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 deb6008..1cf871e 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
@@ -1831,3 +1831,16 @@ treecontrol.tree-classic {
         min-height: 450px;
     }
 }
+
+.additional-filter {
+    input[type="checkbox"] {
+        position: absolute;
+        margin-top: 8px;
+    }
+
+    a {
+        font-family: normal;
+        padding-left: 20px;
+        float: none;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/068e3134/modules/control-center-web/src/main/js/views/configuration/metadata.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/configuration/metadata.jade b/modules/control-center-web/src/main/js/views/configuration/metadata.jade
index 43b2ec5..aec80af 100644
--- a/modules/control-center-web/src/main/js/views/configuration/metadata.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/metadata.jade
@@ -29,7 +29,28 @@ block content
             div(ng-show='ui.ready')
                 +block-callout('{{screenTip.workflowTitle}}', 'screenTip.workflowContent',
'{{screenTip.whatsNextTitle}}', 'screenTip.whatsNextContent')
                 hr
-                +main-table('Types metadata:', 'metadatas', 'metadataName', 'selectItem(row)',
'{{$index + 1}}) {{row.valueType}}')
+                .padding-bottom-dflt(ng-show='metadatas && metadatas.length >
0')
+                    table.links(st-set-filter='metadatasSearch' st-table='displayedRows'
st-safe-src='metadatas')
+                        thead
+                            tr
+                                th
+                                    lable.labelHeader.labelFormField Types metadata:
+                                    .col-sm-8.pull-right(style='padding: 0')
+                                        .col-sm-6
+                                            .pull-right.labelLogin.additional-filter(ng-if='(displayedRows
| metadatasValidation:false:true).length > 0')
+                                                a.labelFormField(ng-if='ui.showValid' ng-click='ui.showValid
= !ui.showValid') Key fields should be configured: {{(displayedRows | metadatasValidation:false:true).length}}&nbsp
+                                                a.labelFormField(ng-if='!ui.showValid' ng-click='ui.showValid
= !ui.showValid') Show all metadata: {{displayedRows.length}}&nbsp
+                                        .col-sm-6
+                                            input.form-control.pull-right(type='text' st-search=''
placeholder='Filter metadatas...')
+                            tbody
+                                tr
+                                    td
+                                        .scrollable-y(style='max-height: 200px')
+                                            table
+                                                tbody
+                                                    tr(ng-repeat='row in (displayedRows |
metadatasValidation:ui.showValid:true) track by row._id')
+                                                        td
+                                                            a(ng-class='{active: row._id
== selectedItem._id}' ng-click='selectItem(row)') '{{$index + 1}}) {{row.valueType}}'
                 .padding-top-dflt(bs-affix)
                     .panel-tip-container(data-placement='bottom' bs-tooltip data-title='Create
new metadata')
                         button.btn.btn-primary(id='new-item' ng-click='createItem()') Add
metadata

http://git-wip-us.apache.org/repos/asf/ignite/blob/068e3134/modules/control-center-web/src/main/js/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/includes/controls.jade b/modules/control-center-web/src/main/js/views/includes/controls.jade
index 642cb5b..1fda142 100644
--- a/modules/control-center-web/src/main/js/views/includes/controls.jade
+++ b/modules/control-center-web/src/main/js/views/includes/controls.jade
@@ -442,7 +442,7 @@ mixin form-row-custom(lblClasses, fieldClasses, dataSource)
                                     .input-tip
                                         input#newGroupName.form-control(type='text' ng-model='field.newGroupName'
placeholder='Group name' on-enter='tableGroupSaveVisible(field, -1) && tableGroupSave(field,
-1)' on-escape='tableReset()')
 
-mixin main-table(title,  rows, focusId, click, rowTemplate)
+mixin main-table(title, rows, focusId, click, rowTemplate)
     .padding-bottom-dflt(ng-show='#{rows} && #{rows}.length > 0')
         table.links(st-set-filter='#{rows}Search' st-table='displayedRows' st-safe-src='#{rows}')
             thead


Mime
View raw message