Repository: ignite Updated Branches: refs/heads/ignite-843 db2c79ed4 -> 86fe3afa1
ignite-843 await agent connect. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/86fe3afa Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/86fe3afa Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/86fe3afa Branch: refs/heads/ignite-843 Commit: 86fe3afa1958cc86a0c5899f4d051212f9fc7ef6 Parents: db2c79e Author: Vasiliy Sisko <[email protected]> Authored: Wed Oct 7 09:32:06 2015 +0700 Committer: Andrey <[email protected]> Committed: Wed Oct 7 09:32:06 2015 +0700 ---------------------------------------------------------------------- .../src/main/js/controllers/common-module.js | 51 ++++++++++++++---- .../main/js/controllers/metadata-controller.js | 57 ++++++++++---------- .../src/main/js/controllers/sql-controller.js | 24 +++++---- .../main/js/views/configuration/metadata.jade | 2 +- .../main/js/views/templates/agent-download.jade | 3 +- 5 files changed, 87 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/86fe3afa/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 de22df4..cc0ddab 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 @@ -561,10 +561,7 @@ consoleModule.service('$common', [ var isCur = isDefined(curValue); var isSrc = isDefined(srcValue); - if ((isCur && !isSrc) || (!isCur && isSrc) || (isCur && isSrc && !angular.equals(curValue, srcValue))) - return true; - - return false; + return !!((isCur && !isSrc) || (!isCur && isSrc) || (isCur && isSrc && !angular.equals(curValue, srcValue))); } function _compareFields(fields) { @@ -1350,7 +1347,7 @@ consoleModule.service('$preview', ['$timeout', '$interval', function ($timeout, var newContent = content.lines; - if (content.action == 'remove') + if (content.checkFn == 'remove') prevContent = content.lines; else if (prevContent.length > 0 && newContent.length > 0 && editor.attractAttention) { if (clearPromise) { @@ -1828,7 +1825,7 @@ consoleModule.controller('activeLink', [ consoleModule.controller('auth', [ '$scope', '$modal', '$http', '$window', '$common', '$focus', function ($scope, $modal, $http, $window, $common, $focus) { - $scope.action = 'login'; + $scope.checkFn = 'login'; $scope.userDropdown = [{text: 'Profile', href: '/profile'}]; @@ -1846,7 +1843,7 @@ consoleModule.controller('auth', [ // Try to authorize user with provided credentials. $scope.auth = function (action, user_info) { - $http.post('/' + action, user_info) + $http.post('/' + checkFn, user_info) .success(function () { $window.location = '/configuration/clusters'; }) @@ -1881,10 +1878,25 @@ consoleModule.controller('auth', [ // Download agent controller. consoleModule.controller('agent-download', [ - '$scope', '$modal', function ($scope, $modal) { + '$common', '$scope', '$timeout', '$modal', '$window', function ($common, $scope, $timeout, $modal, $window) { // Pre-fetch modal dialogs. var _agentDownloadModal = $modal({scope: $scope, templateUrl: '/agent/download', show: false}); + var _agentDownloadHide = _agentDownloadModal.hide; + + _agentDownloadModal.hide = function () { + $timeout.cancel(_agentDownloadModal.checker); + + _agentDownloadHide(); + }; + + $scope.goBackAndHide = function () { + if ($scope.backLink) + $window.location = $scope.backLink; + + _agentDownloadModal.hide() + }; + $scope.downloadAgent = function () { var lnk = document.createElement('a'); @@ -1898,9 +1910,28 @@ consoleModule.controller('agent-download', [ document.body.removeChild(lnk); }; - $scope.showDownloadAgent = function () { - _agentDownloadModal.$promise.then(_agentDownloadModal.show); + var _handleException = function (errMsg, status) { + if (status == 503) { + if (!_agentDownloadModal.$isShown) + _agentDownloadModal.$promise.then(_agentDownloadModal.show); + + _agentDownloadModal.checker = $timeout(function () { + _agentDownloadModal.checkFn(_agentDownloadModal.hide, _handleException); + }, 3000); + } + else + $common.showError(errMsg); }; + + $scope.awaitAgent = function (checkFn, backLink) { + _agentDownloadModal.checkFn = checkFn; + + $scope.backLink = backLink; + + _agentDownloadModal.$options.backdrop = $common.isDefined(backLink) ? 'static' : true; + + checkFn(_agentDownloadModal.hide, _handleException); + } }]); // Navigation bar controller. http://git-wip-us.apache.org/repos/asf/ignite/blob/86fe3afa/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 4ebc894..abf642f 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 @@ -232,40 +232,43 @@ consoleModule.controller('metadataController', [ info: 'Configure connection to database' }; - // Get available JDBC drivers via agent. - $http.post('/agent/drivers') - .success(function (drivers) { - if (drivers && drivers.length > 0) { - $scope.jdbcDriverJars = _.map(drivers, function (driver) { - return {value: driver.jdbcDriverJar, label: driver.jdbcDriverJar}; - }); + function getDrivers(onSuccess, onException) { + // Get available JDBC drivers via agent. + $http.post('/agent/drivers') + .success(function (drivers) { + onSuccess(); + + if (drivers && drivers.length > 0) { + $scope.jdbcDriverJars = _.map(drivers, function (driver) { + return {value: driver.jdbcDriverJar, label: driver.jdbcDriverJar}; + }); - jdbcDrivers = drivers; + jdbcDrivers = drivers; - $scope.preset.jdbcDriverJar = drivers[0].jdbcDriverJar; + $scope.preset.jdbcDriverJar = drivers[0].jdbcDriverJar; - function openLoadMetadataModal() { - loadMetaModal.$promise.then(function () { - $scope.loadMeta.action = 'connect'; - $scope.loadMeta.tables = []; + function openLoadMetadataModal() { + loadMetaModal.$promise.then(function () { + $scope.loadMeta.action = 'connect'; + $scope.loadMeta.tables = []; - loadMetaModal.show(); + loadMetaModal.show(); - $focus('jdbcUrl'); - }); + $focus('jdbcUrl'); + }); + } + + $common.confirmUnsavedChanges($scope.ui.isDirty(), openLoadMetadataModal); } + else + $common.showError('JDBC drivers not found!'); + }) + .error(function (errMsg, status) { + onException(errMsg, status); + }); + } - $common.confirmUnsavedChanges($scope.ui.isDirty(), openLoadMetadataModal); - } - else - $common.showError('JDBC drivers not found!'); - }) - .error(function (errMsg, status) { - if (status == 503) - $scope.showDownloadAgent(); - else - $common.showError(errMsg); - }); + $scope.awaitAgent(getDrivers); }; function _loadSchemas() { http://git-wip-us.apache.org/repos/asf/ignite/blob/86fe3afa/modules/control-center-web/src/main/js/controllers/sql-controller.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/sql-controller.js b/modules/control-center-web/src/main/js/controllers/sql-controller.js index 2e9c0e5..b9ad846 100644 --- a/modules/control-center-web/src/main/js/controllers/sql-controller.js +++ b/modules/control-center-web/src/main/js/controllers/sql-controller.js @@ -333,19 +333,21 @@ consoleModule.controller('sqlController', }); }; - $http.post('/agent/topology') - .success(function (caches) { - $scope.caches = _.sortBy(caches, 'name'); + function getTopology(onSuccess, onException) { + $http.post('/agent/topology') + .success(function (caches) { + onSuccess(); - _setActiveCache(); - }) - .error(function (err, status) { - if (status == 503) - $scope.showDownloadAgent(); - else - $common.showError('Receive agent error: ' + err); - }); + $scope.caches = _.sortBy(caches, 'name'); + + _setActiveCache(); + }) + .error(function (err, status) { + onException(err, status); + }); + } + $scope.awaitAgent(getTopology, '/'); var _columnFilter = function(paragraph) { return paragraph.disabledSystemColumns || paragraph.systemColumns ? _allColumn : _hideColumn; http://git-wip-us.apache.org/repos/asf/ignite/blob/86fe3afa/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 aec80af..7e051bf 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 @@ -50,7 +50,7 @@ block content 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}}' + 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/86fe3afa/modules/control-center-web/src/main/js/views/templates/agent-download.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/templates/agent-download.jade b/modules/control-center-web/src/main/js/views/templates/agent-download.jade index cfd404b..7246238 100644 --- a/modules/control-center-web/src/main/js/views/templates/agent-download.jade +++ b/modules/control-center-web/src/main/js/views/templates/agent-download.jade @@ -16,7 +16,7 @@ .modal-dialog .modal-content #errors-container.modal-header.header - button.close(ng-click='$hide()') × + button.close(ng-if='!backLink' ng-click='$hide()') × h4.modal-title Connection to Ignite Web Agent is not established .agent-download p Please download and run @@ -45,4 +45,5 @@ i.tipLabel.fa.fa-clipboard(ng-click-copy='{{user.token}}' bs-tooltip='' data-title='Copy security token to clipboard') i.tipLabel.fa.fa-question-circle(ng-if=lines bs-tooltip='' data-title='The security token is used for authorization of web agent') .modal-footer + button.btn.btn-default(ng-if='backLink' ng-click='goBackAndHide()') Home button.btn.btn-primary(ng-click='downloadAgent()') Download zip
