You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/03/18 12:08:11 UTC
[07/16] brooklyn-ui git commit: Add "Edit YAML" button if user wants
to manually edit the generated location
Add "Edit YAML" button if user wants to manually edit the generated location
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/cea004a1
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/cea004a1
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/cea004a1
Branch: refs/heads/master
Commit: cea004a1c891f64adb03c82452ab4a15fb44c676
Parents: 1785d6d
Author: Thomas Bouron <th...@cloudsoftcorp.com>
Authored: Thu Mar 17 10:56:40 2016 +0000
Committer: Thomas Bouron <th...@cloudsoftcorp.com>
Committed: Thu Mar 17 12:49:11 2016 +0000
----------------------------------------------------------------------
src/main/webapp/assets/js/view/editor.js | 2 +-
.../webapp/assets/js/view/location-wizard.js | 50 ++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cea004a1/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 c5a24f3..db10181 100644
--- a/src/main/webapp/assets/js/view/editor.js
+++ b/src/main/webapp/assets/js/view/editor.js
@@ -80,7 +80,7 @@ define([
} else if (this.options.type === MODE_CATALOG) {
this.setMode(MODE_CATALOG);
} else {
- console.log("unknown mode '"+this.option.type+"'; using '"+MODE_APP+"'");
+ console.log("unknown mode '"+this.options.type+"'; using '"+MODE_APP+"'");
this.setMode(MODE_APP);
}
this.options.catalog = new CatalogApplication.Collection();
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cea004a1/src/main/webapp/assets/js/view/location-wizard.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/view/location-wizard.js b/src/main/webapp/assets/js/view/location-wizard.js
index a6ade81..b7c6c6b 100644
--- a/src/main/webapp/assets/js/view/location-wizard.js
+++ b/src/main/webapp/assets/js/view/location-wizard.js
@@ -28,11 +28,18 @@ define([
'jquery-easy-autocomplete'
], function(_, Backbone, $, Util, Location, ModalHtml, LocationTypeHtml, LocationConfigurationHtml, LocationProvisioningHtml, LocationProvisioningEntry) {
+ var _YAML_HEADER = [
+ 'brooklyn.catalog:',
+ ' version: 0.0.1',
+ ' items:'
+ ];
+
var Wizard = Backbone.View.extend({
template: _.template(ModalHtml),
events: {
'click .location-wizard-previous': 'previousStep',
'click .location-wizard-next': 'nextStep',
+ 'click .location-wizard-edit': 'edit',
'click .location-wizard-save': 'save',
'click .location-wizard-save-and-reset': 'saveAndReset'
},
@@ -65,6 +72,10 @@ define([
this.actions = [
{
+ label: 'Edit in YAML',
+ class: 'location-wizard-edit'
+ },
+ {
label: 'Save and add another',
class: 'location-wizard-save-and-reset'
},
@@ -151,6 +162,45 @@ define([
return text && text.charAt(0).toUpperCase() + text.slice(1);
},
+ edit: function() {
+ var baseSpacing = ' ';
+
+ var content = [].concat(_YAML_HEADER);
+
+ content.push(baseSpacing + '- id: ' + this.location.get('name'));
+
+ baseSpacing += ' ';
+ content.push(baseSpacing + 'itemType: location');
+ content.push(baseSpacing + 'item:');
+
+ baseSpacing += ' ';
+ content.push(baseSpacing + 'type: ' + this.location.get('spec'));
+
+ var config = this.location.get('config');
+ if (_.keys(config).length > 0) {
+ content.push(baseSpacing + 'brooklyn.config:');
+ baseSpacing += ' ';
+
+ _.each(config, function(value, key) {
+ if (_.isArray(value)) {
+ content.push(baseSpacing + key + ':');
+ _.each(value, function(valueValue) {
+ content.push(baseSpacing + '- ' + valueValue);
+ });
+ } else if (_.isObject(value)) {
+ content.push(baseSpacing + key + ':');
+ _.each(value, function(valueValue, valueKey) {
+ content.push(baseSpacing + ' ' + valueKey + ': ' + valueValue);
+ });
+ } else {
+ content.push(baseSpacing + key + ': ' + value);
+ }
+ });
+ }
+
+ Backbone.history.navigate("/v1/editor/catalog/_/"+ encodeURIComponent(content.join("\n")), {trigger: true});
+ },
+
save: function(callback) {
var that = this;