ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [10/10] ignite git commit: IGNITE-2132 Enable test drive for sql from web.
Date Wed, 16 Dec 2015 10:28:50 GMT
IGNITE-2132 Enable test drive for sql from web.


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

Branch: refs/heads/ignite-843-rc2
Commit: 46709b002efdcbe4fb2bd08f8f41250da0195353
Parents: 0eb69c6
Author: Andrey <anovikov@gridgain.com>
Authored: Wed Dec 16 17:28:19 2015 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Wed Dec 16 17:28:19 2015 +0700

----------------------------------------------------------------------
 .../ignite/agent/handlers/RestExecutor.java     | 11 +++++++++-
 .../agent/testdrive/AgentSqlTestDrive.java      |  8 +++++--
 .../src/main/js/agents/agent-manager.js         |  8 +++++++
 .../src/main/js/controllers/common-module.js    | 22 +++++++++++++++++++-
 .../src/main/js/public/stylesheets/style.scss   |  4 ++++
 .../src/main/js/routes/agent.js                 | 16 +++++++++++++-
 .../js/views/configuration/metadata-load.jade   |  2 +-
 .../main/js/views/templates/agent-download.jade |  4 ++--
 8 files changed, 67 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
index 2d4d154..f91c14c 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
@@ -40,6 +40,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.ignite.agent.AgentConfiguration;
 import org.apache.ignite.agent.remote.Remote;
+import org.apache.ignite.agent.testdrive.AgentSqlTestDrive;
 
 import static org.apache.ignite.agent.AgentConfiguration.DFLT_NODE_PORT;
 
@@ -98,7 +99,7 @@ public class RestExecutor {
 
         if (path != null) {
             if (!path.startsWith("/") && !cfg.nodeUri().endsWith("/"))
-                path = '/' +  path;
+                path = '/' + path;
 
             builder.setPath(path);
         }
@@ -166,6 +167,14 @@ public class RestExecutor {
     }
 
     /**
+     * Enable test-drive SQL.
+     */
+    @Remote
+    public boolean enableTestDriveSQL() {
+        return AgentSqlTestDrive.testDrive(cfg);
+    }
+
+    /**
      * Request result.
      */
     public static class RestResult {

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
index d9fe0d2..221b586 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/testdrive/AgentSqlTestDrive.java
@@ -458,7 +458,7 @@ public class AgentSqlTestDrive {
     /**
      * Start ignite node with cacheEmployee and populate it with data.
      */
-    public static void testDrive(AgentConfiguration acfg) {
+    public static boolean testDrive(AgentConfiguration acfg) {
         if (initLatch.compareAndSet(false, true)) {
             log.log(Level.INFO, "TEST-DRIVE-SQL: Starting embedded node for sql test-drive...");
 
@@ -496,7 +496,7 @@ public class AgentSqlTestDrive {
                 if (F.isEmpty(host) || port == null) {
                     log.log(Level.SEVERE, "TEST-DRIVE-SQL: Failed to start embedded node
with rest!");
 
-                    return;
+                    return false;
                 }
 
                 acfg.nodeUri(String.format("http://%s:%d", "0.0.0.0".equals(host) ? "127.0.0.1"
: host, port));
@@ -507,7 +507,11 @@ public class AgentSqlTestDrive {
             }
             catch (Exception e) {
                 log.log(Level.SEVERE, "TEST-DRIVE-SQL: Failed to start embedded node for
sql test-drive!", e);
+
+                return false;
             }
         }
+
+        return true;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/modules/control-center-web/src/main/js/agents/agent-manager.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/agents/agent-manager.js b/modules/control-center-web/src/main/js/agents/agent-manager.js
index cd6b084..c75f4ca 100644
--- a/modules/control-center-web/src/main/js/agents/agent-manager.js
+++ b/modules/control-center-web/src/main/js/agents/agent-manager.js
@@ -194,6 +194,14 @@ Client.prototype.availableDrivers = function(cb) {
     this._invokeRmtMethod('availableDrivers', arguments)
 };
 
+/**
+ * @param {Function} cb Callback. Take two arguments: {Object} exception, {Object} result.
+ * @return {Boolean} If test-drive SQL was enabled.
+ */
+Client.prototype.enableTestDriveSQL = function(cb) {
+    this._invokeRmtMethod('enableTestDriveSQL', arguments)
+};
+
 Client.prototype._invokeRmtMethod = function(methodName, args) {
     var cb = null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/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 7545d6d..2357a02 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
@@ -1936,7 +1936,10 @@ consoleModule.controller('auth', [
 
 // Download agent controller.
 consoleModule.controller('agent-download', [
-    '$http', '$common', '$scope', '$interval', '$modal', '$state', function ($http, $common,
$scope, $interval, $modal, $state) {
+    '$http', '$common', '$scope', '$interval', '$modal', '$loading', '$state',
+        function ($http, $common, $scope, $interval, $modal, $loading, $state) {
+        $scope.loadingAgentOptions = { text: 'Enabling test-drive SQL...' };
+
         // Pre-fetch modal dialogs.
         var _agentDownloadModal = $modal({scope: $scope, templateUrl: '/templates/agent-download.html',
show: false, backdrop: 'static'});
 
@@ -1977,6 +1980,21 @@ consoleModule.controller('agent-download', [
             document.body.removeChild(lnk);
         };
 
+        $scope.enableTestDriveSQL = function () {
+            $loading.start('loadingAgent');
+
+            $http.post('/api/v1/agent/testdrive/sql')
+                .success(function (result) {
+                    if (!result)
+                        $common.showError('Failed to start test-drive sql', 'top-right',
'body', true);
+                })
+                .error(function (errMsg, status) {
+                    $loading.finish('loadingAgent');
+
+                    _handleException(errMsg, status);
+                });
+        };
+
         /**
          * Base handler of exceptions on agent interaction
          *
@@ -2034,6 +2052,8 @@ consoleModule.controller('agent-download', [
                     if (_agentDownloadModal.awaitFirstSuccess)
                         _stopInterval();
 
+                    $loading.finish('loadingAgent');
+
                     _agentDownloadModal.checkFn(result, _agentDownloadModal.hide, _handleException);
                 })
                 .error(function (errMsg, status) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/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 1f217f9..c3c5fa3 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
@@ -1628,6 +1628,10 @@ a {
     .dw-loading.dw-loading-overlay {
         z-index: 9999;
     }
+
+    .dw-loading-body {
+        left: 10%;
+    }
 }
 
 .panel-tip-container {

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/modules/control-center-web/src/main/js/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/agent.js b/modules/control-center-web/src/main/js/routes/agent.js
index 1d40dba..f915df2 100644
--- a/modules/control-center-web/src/main/js/routes/agent.js
+++ b/modules/control-center-web/src/main/js/routes/agent.js
@@ -45,7 +45,7 @@ router.get('/download/zip', function (req, res) {
     var JSZip = require('jszip');
     var config = require('../helpers/configuration-loader.js');
 
-    var agentFld = 'ignite-web-agent-1.5.0-SNAPSHOT';
+    var agentFld = 'ignite-web-agent-1.5.0-b2-SNAPSHOT';
     var agentZip = agentFld + '.zip';
 
     // Read a zip file.
@@ -280,6 +280,20 @@ router.post('/ping', function (req, res) {
         res.sendStatus(200);
 });
 
+/* Enable test-drive for sql. */
+router.post('/testdrive/sql', function (req, res) {
+    var client = _client(req, res);
+
+    if (client) {
+        client.enableTestDriveSQL(function (err, drivers) {
+            if (err)
+                return res.status(500).send(err);
+
+            res.sendStatus(200);
+        });
+    }
+});
+
 /* Get JDBC drivers list. */
 router.post('/drivers', function (req, res) {
     var client = _client(req, res);

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/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 b8c85ac..a6800d0 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
@@ -20,7 +20,7 @@ mixin chk(mdl, change, tip)
     input(type='checkbox' ng-model=mdl ng-change=change bs-tooltip='' data-title=tip data-placement='bottom')
 
 .modal.center(role='dialog')
-    .modal-dialog(ng-cloak)
+    .modal-dialog
         .modal-content(dw-loading='loadingMetadataFromDb' dw-loading-options='loadMeta.loadingOptions')
             #errors-container.modal-header.header
                 button.close(ng-click='$hide()' aria-hidden='true') &times;

http://git-wip-us.apache.org/repos/asf/ignite/blob/46709b00/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 05a73e6..aef3ae7 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
@@ -14,7 +14,7 @@
 
 .modal.center(tabindex='-1' role='dialog')
     .modal-dialog
-        .modal-content
+        .modal-content(dw-loading='loadingAgent' dw-loading-options='loadingAgentOptions')
             #errors-container.modal-header.header
                 h4.modal-title(ng-if='!nodeFailedConnection') Connection to Ignite Web Agent
is not established
                 h4.modal-title(ng-if='nodeFailedConnection') Connection to Ignite Node is
not established
@@ -53,5 +53,5 @@
                         | &nbsp; in agent folder for more information
             .modal-footer
                 button.btn.btn-default(ng-click='goBack()') Back to {{::agentDownloadBackTo}}
-                button.btn.btn-primary(ng-if='nodeFailedConnection' ng-click='downloadAgent()')
Start test-drive
+                button.btn.btn-primary(ng-if='nodeFailedConnection' ng-click='enableTestDriveSQL()')
Start test-drive sql
                 button.btn.btn-primary(ng-if='!nodeFailedConnection' ng-click='downloadAgent()')
Download zip


Mime
View raw message