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 Refactor summary page.
Date Thu, 09 Jul 2015 09:02:01 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 92d6209f8 -> 77caa7526


# ignite-843 Refactor summary page.


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

Branch: refs/heads/ignite-843
Commit: 43b72fc1b15ab663ca08674869d419c06db02051
Parents: e9758ac
Author: Andrey <anovikov@gridgain.com>
Authored: Thu Jul 9 16:02:07 2015 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Thu Jul 9 16:02:07 2015 +0700

----------------------------------------------------------------------
 .../nodejs/controllers/summary-controller.js    | 143 ++++---------------
 .../nodejs/routes/generator/docker.js           |  58 ++++++++
 .../nodejs/routes/generator/java.js             |   6 +-
 .../web-control-center/nodejs/routes/summary.js |  29 ++--
 .../nodejs/views/summary.jade                   |  12 +-
 5 files changed, 105 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/43b72fc1/modules/web-control-center/nodejs/controllers/summary-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/summary-controller.js b/modules/web-control-center/nodejs/controllers/summary-controller.js
index f979dac..9e11f8d 100644
--- a/modules/web-control-center/nodejs/controllers/summary-controller.js
+++ b/modules/web-control-center/nodejs/controllers/summary-controller.js
@@ -16,66 +16,50 @@
  */
 
 controlCenterModule.controller('summaryController', ['$scope', '$http', function ($scope,
$http) {
-    $scope.generateJavaItems = [
+    $scope.javaClassItems = [
         { label: 'snippet',value: false},
         { label: 'factory class',value: true}
     ];
 
-    $scope.generateJavaClass = false;
+    $scope.oss = ['debian:8', 'ubuntu:14.10'];
+
+    $scope.cfgLang = 'xml';
+
+    $scope.javaClass = false;
+    $scope.os = undefined;
 
-    $scope.javaData = undefined;
-    $scope.xmlData = undefined;
-    $scope.dockerData = undefined;
+    $scope.generated = undefined;
 
     $http.post('/configuration/clusters/list').success(function (data) {
         $scope.clusters = data.clusters;
     });
 
-    $scope.selectItem = function (item) {
-        $scope.selectedItem = item;
-
-        $scope.generate()
-    };
-
-    $scope.cfgLang = 'xml';
-
-    $scope.generate = function() {
-        var cluster = $scope.selectedItem;
-        
-        if (!cluster)
-            return;
-
-        var lang = $scope.cfgLang;
-        
-        $scope.loading = true;
-
-        $http.post('/configuration/summary/generator', {_id: cluster._id, lang: lang, generateJavaClass:
$scope.generateJavaClass})
-            .success(
-            function (data) {
-                switch (lang) {
-                    case 'java':
-                        $scope.javaData = data;
+    $scope.reload = function() {
+        $("<pre class='brush:java' />").text($scope.javaClass ? $scope.generated.javaClass
: $scope.generated.javaSnippet).appendTo($('#javaResultDiv').empty());
 
-                        $("<pre class='brush:java' />").text(data).appendTo($('#javaResultDiv').empty());
+        $("<pre class='brush:xml' />").text($scope.generated.xml).appendTo($('#xmlResultDiv').empty());
 
-                        break;
+        var os = $scope.os ? $scope.os : $scope.oss[0];
 
-                    case 'xml':
-                        $scope.xmlData = data;
+        $("<pre class='brush:plain' />").text($scope.generated.docker.replace(new RegExp('\%OS\%',
'g'), os)).appendTo($('#dockerResultDiv').empty());
 
-                        $("<pre class='brush:xml' />").text(data).appendTo($('#xmlResultDiv').empty());
+        SyntaxHighlighter.highlight();
+    };
 
-                        break;
+    $scope.generate = function(item) {
+        if (!item)
+            return;
 
-                    case 'docker':
-                        $scope.dockerData = data;
+        $scope.selectedItem = item;
 
-                        $("<pre class='brush:plain' />").text($scope.dockerFile()).appendTo($('#dockerResultDiv').empty());
+        $scope.loading = true;
 
-                        break;
-                }
+        $http.post('/configuration/summary/generator', {_id: $scope.selectedItem._id})
+            .success(function (data) {
+                $scope.generated = data;
 
-                SyntaxHighlighter.highlight();
+                $scope.$watch('javaClass', $scope.reload);
+                $scope.$watch('os', $scope.reload);
 
                 $scope.loading = false;
             }).error(function (data) {
@@ -85,87 +69,18 @@ controlCenterModule.controller('summaryController', ['$scope', '$http',
function
             });
     };
 
-    $scope.$watch('cfgLang', $scope.generate);
-    $scope.$watch('generateJavaClass', $scope.generate);
-
-    $scope.dockerArg = {};
-
-    $scope.download = function(text, fileName) {
-        if (text.length == 0)
-            return;
-        
+    $scope.download = function() {
         var file = document.createElement('a');
+
         file.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(text));
-        file.setAttribute('download', fileName);
+        file.setAttribute('download', $scope.selectedItem.name + '-configuration.zip');
 
         file.style.display = 'none';
+
         document.body.appendChild(file);
 
         file.click();
 
         document.body.removeChild(file);
     };
-
-    $scope.downloadJava = function() {
-        $scope.download($scope.javaData,
-            $scope.generateJavaClass ? 'ConfigurationFactory.java' : $scope.selectedItem.name
+ '.snipplet.txt');
-    };
-
-    $scope.downloadDocker = function() {
-        $scope.download($scope.dockerFile(), 'Dockerfile');
-    };
-
-    $scope.oss = ['debian:8', 'ubuntu:14.10'];
-    
-    $scope.dockerFile = function() {
-        if (!$scope.selectedItem || !$scope.dockerArg) {
-            return '';
-        }
-        
-        var os = $scope.dockerArg.os;
-
-        if (!os)
-            os = 'debian:8';
-
-        return "" +
-            "# Start from a Debian image.\n"+
-            "FROM " + os + "\n"+
-            "\n"+
-            "# Install tools.\n"+
-            "RUN apt-get update && apt-get install -y --fix-missing \\\n"+
-            "  wget \\\n"+
-            "  dstat \\\n"+
-            "  maven \\\n"+
-            "  git\n"+
-            "\n"+
-            "# Install Oracle JDK.\n"+
-            "RUN mkdir /opt/jdk\n"+
-            "\n"+
-            "RUN wget --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\n"+
-            "  http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz\n"+
-            "\n"+
-            "RUN tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/jdk\n"+
-            "\n"+
-            "RUN rm jdk-7u79-linux-x64.tar.gz\n"+
-            "\n"+
-            "RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.7.0_79/bin/java
100\n"+
-            "\n"+
-            "RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.7.0_79/bin/javac
100\n"+
-            "\n"+
-            "# Sets java variables.\n"+
-            "ENV JAVA_HOME /opt/jdk/jdk1.7.0_79/\n"+
-            "\n"+
-            "# Create working directory\n"+
-            "WORKDIR /home\n"+
-            "\n"+
-            "RUN wget -O ignite.zip http://tiny.cc/updater/download_ignite.php &&
unzip ignite.zip && rm ignite.zip\n"+
-            "\n"+
-            "COPY *.xml /tmp/\n"+
-            "\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/43b72fc1/modules/web-control-center/nodejs/routes/generator/docker.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/generator/docker.js b/modules/web-control-center/nodejs/routes/generator/docker.js
new file mode 100644
index 0000000..9ea917d
--- /dev/null
+++ b/modules/web-control-center/nodejs/routes/generator/docker.js
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+exports.generateClusterConfiguration = function(cluster, os) {
+    if (!os)
+        os = 'debian:8';
+
+    return "" +
+        "# Start from a Debian image.\n"+
+        "FROM " + os + "\n"+
+        "\n"+
+        "# Install tools.\n"+
+        "RUN apt-get update && apt-get install -y --fix-missing \\\n"+
+        "  wget \\\n"+
+        "  dstat \\\n"+
+        "  maven \\\n"+
+        "  git\n"+
+        "\n"+
+        "# Install Oracle JDK.\n"+
+        "RUN mkdir /opt/jdk\n"+
+        "\n"+
+        "RUN wget --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\n"+
+        "  http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz\n"+
+        "\n"+
+        "RUN tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/jdk\n"+
+        "\n"+
+        "RUN rm jdk-7u79-linux-x64.tar.gz\n"+
+        "\n"+
+        "RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.7.0_79/bin/java
100\n"+
+        "\n"+
+        "RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.7.0_79/bin/javac
100\n"+
+        "\n"+
+        "# Sets java variables.\n"+
+        "ENV JAVA_HOME /opt/jdk/jdk1.7.0_79/\n"+
+        "\n"+
+        "# Create working directory\n"+
+        "WORKDIR /home\n"+
+        "\n"+
+        "RUN wget -O ignite.zip http://tiny.cc/updater/download_ignite.php && unzip
ignite.zip && rm ignite.zip\n"+
+        "\n"+
+        "COPY *.xml /tmp/\n"+
+        "\n"+
+        "RUN mv /tmp/*.xml /home/$(ls)/config";
+};

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/43b72fc1/modules/web-control-center/nodejs/routes/generator/java.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/generator/java.js b/modules/web-control-center/nodejs/routes/generator/java.js
index ad0fbaf..1b54150 100644
--- a/modules/web-control-center/nodejs/routes/generator/java.js
+++ b/modules/web-control-center/nodejs/routes/generator/java.js
@@ -19,12 +19,12 @@ var _ = require('lodash');
 
 var generatorUtils = require("./common");
 
-exports.generateClusterConfiguration = function(cluster, generateJavaClass) {
+exports.generateClusterConfiguration = function(cluster, javaClass) {
     var res = generatorUtils.builder();
 
     res.datasourceBeans = [];
 
-    if (generateJavaClass) {
+    if (javaClass) {
         res.line('/**');
         res.line(' * ' + generatorUtils.mainComment());
         res.line(' */');
@@ -291,7 +291,7 @@ exports.generateClusterConfiguration = function(cluster, generateJavaClass)
{
     addProperty(res, cluster, 'cfg', 'utilityCacheKeepAliveTime');
     addProperty(res, cluster, 'cfg', 'utilityCachePoolSize');
 
-    if (generateJavaClass) {
+    if (javaClass) {
         res.line();
         res.line('return cfg;');
         res.endBlock('}');

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/43b72fc1/modules/web-control-center/nodejs/routes/summary.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/summary.js b/modules/web-control-center/nodejs/routes/summary.js
index 71c9489..9724708 100644
--- a/modules/web-control-center/nodejs/routes/summary.js
+++ b/modules/web-control-center/nodejs/routes/summary.js
@@ -21,6 +21,7 @@ var router = require('express').Router();
 
 var generatorXml = require('./generator/xml');
 var generatorJava = require('./generator/java');
+var generatorDocker = require('./generator/docker');
 
 /* GET summary page. */
 router.get('/', function(req, res) {
@@ -28,32 +29,20 @@ router.get('/', function(req, res) {
 });
 
 router.post('/generator', function(req, res) {
-    var lang = req.body.lang;
-
     // Get cluster.
     db.Cluster.findById(req.body._id).populate('caches').exec(function (err, cluster) {
         if (err)
             return res.status(500).send(err.message);
 
-        if (!cluster) {
-            res.sendStatus(404);
-
-            return
-        }
-
-        switch (lang) {
-            case 'xml':
-                res.send(generatorXml.generateClusterConfiguration(cluster));
-                break;
-
-            case 'java':
-                res.send(generatorJava.generateClusterConfiguration(cluster, req.body.generateJavaClass));
-                break;
+        if (!cluster)
+            return res.sendStatus(404);
 
-            default:
-                res.status(404).send("Unknown language: " + lang);
-                break;
-        }
+        return res.send({
+            xml: generatorXml.generateClusterConfiguration(cluster),
+            javaSnippet: generatorJava.generateClusterConfiguration(cluster, false),
+            javaClass: generatorJava.generateClusterConfiguration(cluster, true),
+            docker: generatorDocker.generateClusterConfiguration(cluster, '%OS%')
+        });
     });
 });
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/43b72fc1/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 3762822..54d8395 100644
--- a/modules/web-control-center/nodejs/views/summary.jade
+++ b/modules/web-control-center/nodejs/views/summary.jade
@@ -36,18 +36,18 @@ block content
         p Configurations summary.
         hr
     .docs-body(ng-controller='summaryController')
-        div(ng-hide='clusters.length > 0')
+        div(ng-show='clusters.length == 0')
             | No cluster configured. You can&nbsp;
             a(href='clusters') configure
-            |  it.
-        div(ng-hide='clusters.length == 0')
+            | &nbsp;it.
+        div(ng-show='clusters.length > 0')
             p Following cluster configurations were created, you can download them as XML,
java code or as docker file.
             .links
                 table.col-sm-12(st-table='clusters')
                     tbody
                         tr(ng-repeat='row in clusters track by row._id')
                             td.col-sm-6(ng-class='{active: row._id == selectedItem._id}')
-                                a(ng-click='selectItem(row)') {{$index + 1}}) {{row.name}}
+                                a(ng-click='generate(row)') {{$index + 1}}) {{row.name}}
             #cfgResult.configBox(ng-show='selectedItem && !generateError &&
!loading', style='margin-top: 20px')
                 ul.nav.nav-tabs
                     li(ng-class='{active: cfgLang == "xml"}')
@@ -70,7 +70,7 @@ block content
                         .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' data-sort='false')
+                            button.form-control(ng-model='javaClass' bs-select data-placeholder='{{detail.placeholder}}'
bs-options='item.value as item.label for item in javaClassItems' data-sort='false')
                         button.btn.btn-primary.pull-right(style='margin-right: 0px;margin-top:
-40px' ng-click='downloadJava()') Download
                         #javaResultDiv
                     #dockerResult(ng-show="cfgLang == 'docker'")
@@ -87,6 +87,6 @@ block content
                         .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')
+                            input#os.form-control(type='text', ng-model='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')
                         .settings-row#dockerResultDiv(style='margin-top: 15px')
                 div(ng-show='generateError') {{generateError}}


Mime
View raw message