brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [01/10] incubator-brooklyn git commit: JS gui is smart about going to wizard page or yaml page after selecting item from template
Date Wed, 08 Apr 2015 09:40:07 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 3c6ffc483 -> e9179eb0b


JS gui is smart about going to wizard page or yaml page after selecting item from template


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

Branch: refs/heads/master
Commit: 565db3ac554546a439c736ed8ebb9b0b2d4ffcf8
Parents: 592f3ef
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Mar 27 18:44:57 2015 -0500
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Sat Mar 28 10:02:49 2015 -0500

----------------------------------------------------------------------
 .../assets/js/model/catalog-item-summary.js     | 11 ++++--
 .../assets/js/view/application-add-wizard.js    | 40 ++++++++++++--------
 2 files changed, 31 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/565db3ac/usage/jsgui/src/main/webapp/assets/js/model/catalog-item-summary.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/model/catalog-item-summary.js b/usage/jsgui/src/main/webapp/assets/js/model/catalog-item-summary.js
index 8e4d3c4..2d8da58 100644
--- a/usage/jsgui/src/main/webapp/assets/js/model/catalog-item-summary.js
+++ b/usage/jsgui/src/main/webapp/assets/js/model/catalog-item-summary.js
@@ -18,7 +18,10 @@
 */
 define(["underscore", "backbone"], function (_, Backbone) {
 
-    // not used currently
+    // NB: THIS IS NOT USED CURRENTLY
+    // the logic in application-add-wizard.js simply loads and manipulates json
+    // TODO change that so that it uses this backbone model + collection 
+    // allowing a way to specify on creation what we are looking up in the catalog -- apps
or entities or policies
     
     var CatalogItem = {}
 
@@ -29,15 +32,15 @@ define(["underscore", "backbone"], function (_, Backbone) {
                 name:"",
                 type:"",
                 description:"",
-                iconUrl:"", 
-                planYaml:""
+                planYaml:"",
+                iconUrl:""
             }
         }
     })
 
     CatalogItem.Collection = Backbone.Collection.extend({
         model:CatalogItem.Model,
-        url:'/v1/catalog'  // not used?
+        url:'/v1/catalog'  // TODO is this application or entities or policies?
     })
 
     return CatalogItem

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/565db3ac/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
index a936a0c..bc5ae07 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -248,18 +248,21 @@ define([
             this.renderCurrentStep()
         },
         nextStep:function () {
-        	  
             if (this.currentStep < 2) {
-//                if (this.currentView.validate()) {
-//                    this.currentStep += 1
-//                    this.renderCurrentStep()
-//                } else {
-//                    // call to validate should showFailure
-//                }
-           	 $("ul#app-add-wizard-create-tab").find("a[href='#yamlTab']").tab('show')
-                $("#yaml_code").focus()
-              
-
+                if (this.currentView.validate()) {
+                    var isYaml = (this.currentView && this.currentView.selectedTemplate
&& this.currentView.selectedTemplate.yaml);
+                    if (isYaml) {
+                        // it's a yaml catalog template, show the yaml tab
+           	            $("ul#app-add-wizard-create-tab").find("a[href='#yamlTab']").tab('show');
+                        $("#yaml_code").focus()
+                    } else {
+                        // it's a java catalog template, go to wizard for location + config
+                        this.currentStep += 1
+                        this.renderCurrentStep()
+                    }
+                } else {
+                    // the call to validate will have done the showFailure
+                }
             } else {
                 this.finishStep()
             }
@@ -318,6 +321,7 @@ define([
                 self.catalogEntityIds = _.map(result, function(item) { return item.id })
                 self.$(".entity-type-input").typeahead().data('typeahead').source = self.catalogEntityIds
             })
+            // TODO use catalog-item-summary.js instead of raw json; see comments in that
file
             $.get('/v1/catalog/applications', {}, function (result) {
                 self.catalogApplicationItems = result
                 self.catalogApplicationIds = _.map(result, function(item) { return item.id
})
@@ -402,12 +406,11 @@ define([
         addTemplateLozenge: function(that, item) {
             var $tempel = _.template(CreateStepTemplateEntryHtml, {
                 id: item.id,
-                name: item.name,
+                name: item.name || item.id,
                 description: item.description,
                 planYaml:  item.planYaml,
-                iconUrl: item.iconUrTeml
+                iconUrl: item.iconUr
             })
-            //alert("yaml:"+item.planYaml)
             $("#create-step-template-entries", that.$el).append($tempel)
         },
         templateClick: function(event) {
@@ -418,9 +421,14 @@ define([
                 $tl.addClass("selected")
                 this.selectedTemplate = {
                     type: $tl.attr('id'),
-                    name: $tl.data("name")
+                    name: $tl.data("name"),
+                    yaml: $tl.data("yaml")
                 };
-                $("textarea#yaml_code").val($tl.data("yaml"));
+                if (this.selectedTemplate.yaml) {
+                    $("textarea#yaml_code").val(this.selectedTemplate.yaml);
+                } else {
+                    $("textarea#yaml_code").val("services:\n- type: "+this.selectedTemplate.type);
+                }
             } else {
                 this.selectedTemplate = null;
             }


Mime
View raw message