ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [1/2] incubator-ignite git commit: # ignite-843 Cleanup summary.
Date Fri, 03 Jul 2015 06:32:30 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 f2f288e8a -> 1e8bfdffa


# ignite-843 Cleanup summary.


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

Branch: refs/heads/ignite-843
Commit: 370d8fe59191d8cd6d7516c659a8de297be805fe
Parents: f3a402e
Author: Andrey <anovikov@gridgain.com>
Authored: Fri Jul 3 13:32:18 2015 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Fri Jul 3 13:32:18 2015 +0700

----------------------------------------------------------------------
 .../public/javascripts/controllers/summary.js   | 61 +++++++++++++++-----
 .../nodejs/routes/configGenerator.js            | 48 ++++++---------
 .../nodejs/utils/generatorJava.js               |  5 +-
 .../nodejs/utils/generatorUtils.js              |  2 +-
 .../nodejs/views/summary.jade                   | 43 +++++++-------
 .../nodejs/views/templates/select.jade          |  2 +-
 6 files changed, 90 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/370d8fe5/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js b/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
index 40db236..9454f21 100644
--- a/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
+++ b/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
@@ -16,6 +16,17 @@
  */
 
 configuratorModule.controller('summaryController', ['$scope', '$http', function ($scope,
$http) {
+    $scope.generateJavaItems = [
+        { label: 'factory class',value: true},
+        { label: 'snippet',value: false}
+    ];
+
+    $scope.generateJavaClass = false;
+
+    $scope.javaData = undefined;
+    $scope.xmlData = undefined;
+    $scope.dockerData = undefined;
+
     $http.get('/rest/clusters').success(function (data) {
         $scope.caches = data.caches;
         $scope.spaces = data.spaces;
@@ -31,8 +42,11 @@ configuratorModule.controller('summaryController', ['$scope', '$http',
function
     $scope.generateConfig = function() {
         var lang = $scope.cfgLang;
 
-        if (lang == 'docker')
+        if (lang == 'docker') {
+            $("<pre class='brush:plain' />").text($scope.dockerFile()).appendTo($('#dockerResultDiv').empty());
+
             return;
+        }
 
         var cluster = $scope.selectedItem;
         
@@ -42,13 +56,17 @@ configuratorModule.controller('summaryController', ['$scope', '$http',
function
         $scope.loading = true;
 
         $http.get('/rest/configGenerator', {params: 
-        {name: cluster.name, lang: lang, generateJavaClass: $scope.generateJavaClass}})
+        {_id: cluster._id, lang: lang, generateJavaClass: $scope.generateJavaClass}})
             .success(
             function (data) {
                 if (lang == 'java') {
+                    $scope.javaData = data;
+
                     $("<pre class='brush:java' />").text(data).appendTo($('#javaResultDiv').empty());
                 }
                 else if (lang == 'xml') {
+                    $scope.xmlData = data;
+
                     $("<pre class='brush:xml' />").text(data).appendTo($('#xmlResultDiv').empty());
                 }
 
@@ -68,23 +86,30 @@ configuratorModule.controller('summaryController', ['$scope', '$http',
function
     $scope.$watch('generateJavaClass', $scope.generateConfig);
 
     $scope.dockerArg = {};
-    
-    $scope.downloadDocker = function() {
-        var dockerText = $scope.dockerFile();
-        
-        if (dockerText.length == 0)
+
+    $scope.download = function(text, fileName) {
+        if (text.length == 0)
             return;
         
-        var pom = document.createElement('a');
-        pom.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(dockerText));
-        pom.setAttribute('download', 'Dockerfile');
+        var file = document.createElement('a');
+        file.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(text));
+        file.setAttribute('download', fileName);
+
+        file.style.display = 'none';
+        document.body.appendChild(file);
 
-        pom.style.display = 'none';
-        document.body.appendChild(pom);
+        file.click();
 
-        pom.click();
+        document.body.removeChild(file);
+    };
+
+    $scope.downloadJava = function() {
+        $scope.download($scope.javaData,
+            $scope.generateJavaClass ? 'ConfigurationFactory.java' : $scope.selectedItem.name
+ '.snipplet.txt');
+    };
 
-        document.body.removeChild(pom);
+    $scope.downloadDocker = function() {
+        download($scope.dockerFile(), 'Dockerfile');
     };
 
     $scope.oss = ['debian:8', 'ubuntu:14.10'];
@@ -98,7 +123,7 @@ configuratorModule.controller('summaryController', ['$scope', '$http',
function
         if (!os) {
             os = 'debian:8'
         }
-        
+
         return "" +
             "# Start from a Debian image.\n"+
             "FROM " + os + "\n"+
@@ -110,7 +135,7 @@ configuratorModule.controller('summaryController', ['$scope', '$http',
function
             "  maven \\\n"+
             "  git\n"+
             "\n"+
-            "# Intasll Oracle JDK.\n"+
+            "# Install Oracle JDK.\n"+
             "RUN mkdir /opt/jdk\n"+
             "\n"+
             "RUN wget --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\n"+
@@ -136,4 +161,8 @@ configuratorModule.controller('summaryController', ['$scope', '$http',
function
             "\n"+
             "RUN mv /tmp/*.xml /home/$(ls)/config";
     };
+
+    $scope.$watch('dockerArg.os', function() {
+        $("<pre class='brush:plain' />").text($scope.dockerFile()).appendTo($('#dockerResultDiv').empty());
+    });
 }]);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/370d8fe5/modules/web-control-center/nodejs/routes/configGenerator.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/configGenerator.js b/modules/web-control-center/nodejs/routes/configGenerator.js
index 407514a..f43817a 100644
--- a/modules/web-control-center/nodejs/routes/configGenerator.js
+++ b/modules/web-control-center/nodejs/routes/configGenerator.js
@@ -24,45 +24,31 @@ var generatorJava = require('./../utils/generatorJava');
 
 router.get('/', function(req, res) {
     var lang = req.query.lang;
-    var name = req.query.name;
 
-    var user_id = req.user._id;
-    
-    db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]},
function (err, spaces) {
+    // Get cluster.
+    db.Cluster.findById(req.query._id).populate('caches').exec(function (err, cluster) {
         if (err)
             return res.status(500).send(err.message);
 
-        var space_ids = spaces.map(function(value) {
-            return value._id;
-        });
+        if (!cluster) {
+            res.sendStatus(404);
 
-        // Get all clusters for spaces.
-        db.Cluster.find({name: name, space: {$in: space_ids}}).populate('caches').exec(function
(err, clusters) {
-            if (err)
-                return res.status(500).send(err.message);
+            return
+        }
 
-            if (clusters.length == 0) {
-                res.sendStatus(404);
+        switch (lang) {
+            case 'xml':
+                res.send(generatorXml.generateClusterConfiguration(cluster));
+                break;
 
-                return
-            }
+            case 'java':
+                res.send(generatorJava.generateClusterConfiguration(cluster, req.query.generateJavaClass
=== 'true'));
+                break;
 
-            var cluster = clusters[0];
-
-            switch (lang) {
-                case 'xml':
-                    res.send(generatorXml.generateClusterConfiguration(cluster));
-                    break;
-
-                case 'java':
-                    res.send(generatorJava.generateClusterConfiguration(cluster, req.query.generateJavaClass
== 'true'));
-                    break;
-
-                default:
-                    res.status(404).send("Unknown language: " + lang);
-                    break;
-            }
-        });
+            default:
+                res.status(404).send("Unknown language: " + lang);
+                break;
+        }
     });
 });
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/370d8fe5/modules/web-control-center/nodejs/utils/generatorJava.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/utils/generatorJava.js b/modules/web-control-center/nodejs/utils/generatorJava.js
index 223f85f..88d969d 100644
--- a/modules/web-control-center/nodejs/utils/generatorJava.js
+++ b/modules/web-control-center/nodejs/utils/generatorJava.js
@@ -25,7 +25,9 @@ exports.generateClusterConfiguration = function(cluster, generateJavaClass)
{
         res.line(' * ' + generatorUtils.mainComment());
         res.line(' */');
         res.startBlock('public class ConfigurationFactory {');
-        res.line();
+        res.line('/**');
+        res.line(' * Configure grid.');
+        res.line(' */');
         res.startBlock('public IgniteConfiguration createConfiguration() {');
     }
     
@@ -273,6 +275,7 @@ exports.generateClusterConfiguration = function(cluster, generateJavaClass)
{
     addProperty(res, cluster, 'cfg', 'utilityCachePoolSize');
 
     if (generateJavaClass) {
+        res.line();
         res.line('return cfg;');
         res.endBlock('}');
         res.endBlock('}');

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/370d8fe5/modules/web-control-center/nodejs/utils/generatorUtils.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/utils/generatorUtils.js b/modules/web-control-center/nodejs/utils/generatorUtils.js
index 82df5bb..abae387 100644
--- a/modules/web-control-center/nodejs/utils/generatorUtils.js
+++ b/modules/web-control-center/nodejs/utils/generatorUtils.js
@@ -16,7 +16,7 @@
  */
 
 exports.mainComment = function() {
-    return 'This configuration was generated by automatically by Ignite (' 
+    return 'This configuration was generated by Ignite Control Center ('
         + formatDate(new Date()) + ')';
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/370d8fe5/modules/web-control-center/nodejs/views/summary.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/summary.jade b/modules/web-control-center/nodejs/views/summary.jade
index daa6709..71f91da 100644
--- a/modules/web-control-center/nodejs/views/summary.jade
+++ b/modules/web-control-center/nodejs/views/summary.jade
@@ -21,6 +21,7 @@ append scripts
     script(src='//cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.min.js')
   
     script(src='//cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushXml.js')
   
     script(src='//cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushJava.js')
+    script(src='//cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushPlain.js')
     script(src="//cdn.jsdelivr.net/angularjs/1.3.15/angular-animate.min.js")
     script(src="//cdn.jsdelivr.net/angularjs/1.3.15/angular-sanitize.min.js")
 
@@ -61,34 +62,34 @@ block content
                             img(src='images/docker.png', width='16px' height='16px')
                             |  Dockerfile
 
-                div(style='padding-top: 10px')        
+                .settings-row
                     #xmlResult(ng-show="cfgLang == 'xml'")
+                        label
+                        button.btn.btn-primary.pull-right(style='margin-right: 0px;' ng-click='$scope.download($scope.xmlData,
$scope.selectedItem.name + ".xml")') Download
+
                         #xmlResultDiv
-                
                     #javaResult(ng-show="cfgLang == 'java'")
-                        label
-                            input(type='checkbox', ng-model="generateJavaClass")
-                            | generate java class.
+                        .col-sm-1
+                            label Generate:
+                        .col-sm-3
+                            button.form-control(ng-model='generateJavaClass' bs-select data-placeholder='{{detail.placeholder}}'
bs-options='item.value as item.label for item in generateJavaItems')
+
+                        button.btn.btn-primary.pull-right(style='margin-right: 0px;' ng-click='downloadJava()')
Download
 
                         #javaResultDiv
-                    
                     #dockerResult(ng-show="cfgLang == 'docker'")
                         p
                             a(href='https://docs.docker.com/reference/builder') Dockerfile
-                            | is a text file with instructions to create Docker image. To
build image you have to
-                            | store following Docker file with your xml ignite configurations
to the same directory. 
-                        
-                        form.form-horizontal
-                            .form-group
-                                label.control-label.col-sm-3(for='os') Operation System
-                                .col-sm-6
-                                    input#os.form-control(type='text', ng-model='dockerArg.os',
placeholder='debian:8' data-min-length="0" data-html="1" data-auto-select="true" data-animation="am-flip-x"
bs-typeahead bs-options='os for os in oss')
-                                
-                            .form-group
-                                | Download as 
-                                a(href, ng-click='downloadDocker()') file
-                                
-                                textarea.form-control(rows=30, readonly=true)
-                                    | {{ dockerFile() }}
+                            | &nbspis a text file with instructions to create Docker
image. To build image you have to
+                            | store following Docker file with your xml ignite configurations
to the same directory.
+
+                        .col-sm-2
+                            label(for='os') Operation System:
+                        .col-sm-4
+                            input#os.form-control(type='text', ng-model='dockerArg.os' placeholder='debian:8'
data-min-length="0" data-html="1" data-auto-select="true" data-animation="am-flip-x" bs-typeahead
bs-options='os for os in oss')
+
+                        button.btn.btn-primary.pull-right(style='margin-right: 0px;' ng-click='downloadDocker()')
Download
+
+                        .settings-row#dockerResultDiv(style='margin-top: 15px')
 
                 div(ng-show='generateError') {{generateError}}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/370d8fe5/modules/web-control-center/nodejs/views/templates/select.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/templates/select.jade b/modules/web-control-center/nodejs/views/templates/select.jade
index 4a39795..83a1731 100644
--- a/modules/web-control-center/nodejs/views/templates/select.jade
+++ b/modules/web-control-center/nodejs/views/templates/select.jade
@@ -16,7 +16,7 @@
 
 ul.select.dropdown-menu(tabindex='-1', ng-show='$isVisible()', role='select')
     li(role='presentation', ng-repeat='match in $matches')
-        hr(ng-if='!match.value' style='margin: 5px 0')
+        hr(ng-if='match.value == undefined' style='margin: 5px 0')
         a(style='cursor: default;', role='menuitem', tabindex='-1', ng-class='{active: $isActive($index)}'
ng-click='$select($index, $event)')
             i.pull-right(class='{{$iconCheckmark}}', ng-if='$isMultiple && $isActive($index)'
ng-class='{active: $isActive($index)}' style='margin-left: 15px')
             span(ng-bind='match.label')


Mime
View raw message