brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [03/27] brooklyn-ui git commit: composer is aware whether it is catalog or blueprint mode
Date Thu, 18 Feb 2016 10:36:55 GMT
composer is aware whether it is catalog or blueprint mode


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/61201998
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/61201998
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/61201998

Branch: refs/heads/master
Commit: 61201998b3b8177d62461e433052c94208adbcac
Parents: 0554b07
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Feb 11 14:09:18 2016 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Feb 11 17:44:11 2016 +0000

----------------------------------------------------------------------
 src/main/webapp/assets/js/view/editor.js    | 24 +++++++++++++++++++++++-
 src/main/webapp/assets/tpl/editor/page.html |  9 +++++----
 2 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/61201998/src/main/webapp/assets/js/view/editor.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/view/editor.js b/src/main/webapp/assets/js/view/editor.js
index baf534f..fa893fc 100644
--- a/src/main/webapp/assets/js/view/editor.js
+++ b/src/main/webapp/assets/js/view/editor.js
@@ -49,6 +49,10 @@ define([
         '      services:\n'+
         '      - type: <your service here>\n'+
         '      location: <your cloud here>\n';
+        
+    // is the user working on an app blueprint or a catalog item
+    var MODE_APP = "app";
+    var MODE_CATALOG = "catalog";
 
     var EditorView = Backbone.View.extend({
         tagName:"div",
@@ -63,6 +67,14 @@ define([
 
         initialize:function () {
             var vm = this;
+            if (!this.options.type || this.options.type === MODE_APP) {
+                this.setMode(MODE_APP);
+            } else if (this.options.type === MODE_CATALOG) {
+                this.setMode(MODE_CATALOG);
+            } else {
+                console.log("unknown mode '"+this.option.type+"'; using '"+MODE_APP+"'");
+                this.setMode(MODE_APP);
+            }
             this.options.catalog = new CatalogApplication.Collection();
             this.options.catalog.fetch({
                 data: $.param({allVersions: true}),
@@ -71,11 +83,21 @@ define([
                 }
             });
         },
+        setMode: function(mode) {
+            if (this.mode === mode) return;
+            this.mode = mode;
+            this.refresh();
+        },
         render:function (eventName) {
             this.$el.html(_.template(EditorHtml, {}));
             this.loadEditor();
+            this.refresh();
             return this;
         },
+        refresh: function() {
+            $("#button-run", this.$el).html(this.mode==MODE_CATALOG ? "Add to Catalog" :
"Deploy");
+            $("#button-delete", this.$el).html("Clear");
+        },
         refreshEditor: function() {
             var cm = this.editor;
             if (typeof(cm) !== "undefined") {
@@ -138,7 +160,7 @@ define([
         },
         runBlueprint: function() {
             if (this.validate()){
-                if(this.editor.getValue().slice(0,16) === 'brooklyn.catalog'){
+                if (this.mode === MODE_CATALOG) {
                     this.submitCatalog();
                 }else{
                     this.submitApplication();

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/61201998/src/main/webapp/assets/tpl/editor/page.html
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/tpl/editor/page.html b/src/main/webapp/assets/tpl/editor/page.html
index 9a37fe0..727b4d4 100644
--- a/src/main/webapp/assets/tpl/editor/page.html
+++ b/src/main/webapp/assets/tpl/editor/page.html
@@ -20,10 +20,11 @@ under the License.
     <div class="row row-fluid">
         <div class="span12 composer" id="composer">
             <div class="navbar_top">
-                <h3>YAML Composer</h3>
-                <div class="apps-tree-toolbar">
-                    <button id="button-run" class="btn btn-success btn-sm">Create</button>
-                    <button id="button-delete" class="btn btn-danger btn-sm">Reset</button>
+                <h3 style="margin-top: 6px;">Blueprint Composer</h3>
+                <div class="apps-tree-toolbar" style="margin-top: -24px !important;">
+                    <!-- will be renamed -->
+                    <button id="button-run" class="btn btn-success btn-sm">Run</button>
+                    <button id="button-delete" class="btn btn-danger btn-sm">Clear</button>
                 </div>
             </div>
             <div class="navbar_main_wrapper">


Mime
View raw message