diff --git a/app/components/form-key-value/component.js b/app/components/form-key-value/component.js
index be4e6123e..423b95bed 100644
--- a/app/components/form-key-value/component.js
+++ b/app/components/form-key-value/component.js
@@ -1,5 +1,7 @@
import Ember from 'ember';
+// @@TODO@@ - Dec 8, 2015 - need to add callback to this service.
+
export default Ember.Component.extend({
// Inputs
initialMap: null,
@@ -10,6 +12,7 @@ export default Ember.Component.extend({
valuePlaceholder: 'Value',
ary: null,
+ asMap: null,
actions: {
add() {
@@ -92,14 +95,15 @@ export default Ember.Component.extend({
this.set('ary', ary);
},
- asMap: function() {
+ asMapObserver: function() {
+
var out = {};
this.get('ary').forEach((row) => {
- out[row.get('key')] = row.get('value');
+ out[row.get('key').trim()] = row.get('value').trim();
});
- return out;
- }.property('ary.@each.{key,value}'),
+ this.set('asMap', out);
+ }.observes('ary.@each.{key,value}'),
changed: function() {
this.sendAction('changed', this.get('asMap'));
diff --git a/app/components/host-settings/component.js b/app/components/host-settings/component.js
new file mode 100644
index 000000000..e5863d4c2
--- /dev/null
+++ b/app/components/host-settings/component.js
@@ -0,0 +1,112 @@
+import Ember from 'ember';
+
+function isPublic(name) {
+ if ( (name||'').trim().replace(/^https?:\/\//,'').match(/^(localhost|192\.168\.|172\.1[6789]\.|172\.2[0123456789]\.|172\.3[01]\.|10\.)/) )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+export default Ember.Component.extend({
+ endpoint: Ember.inject.service(),
+
+ customRadio: null,
+ customValue: '',
+
+ thisPage: null,
+
+ actions: {
+ sendActiveValue: function(value) {
+ this.sendAction('sendActiveValue', value);
+ }
+ },
+
+ didInitAttrs: function() {
+ var thisPage = window.location.origin;
+ var endpoint = this.get('endpoint.origin');
+ var isDifferent = endpoint !== thisPage;
+
+ this.set('thisPage', thisPage);
+
+ if ( endpoint !== thisPage )
+ {
+ this.set('customValue', endpoint);
+ }
+
+ var value = this.get('host');
+
+ if ( value )
+ {
+ if ( value === thisPage )
+ {
+ this.set('customValue', '');
+ this.set('customRadio', 'no');
+ }
+ else
+ {
+ this.set('customValue', value);
+ this.set('customRadio', 'yes');
+ }
+ }
+ else if ( isDifferent )
+ {
+ // for some reason the activeValueObserver doesnt recognize setting this value unless
+ // we run with ember.run.next
+ Ember.run.next(() => {
+ this.set('customValue', endpoint);
+ this.set('customRadio', 'yes');
+ });
+ }
+ else
+ {
+ this.set('customValue', '');
+ this.set('customRadio', 'no');
+ }
+ },
+
+
+ looksPublic: function() {
+ return isPublic(this.get('activeValue'));
+ }.property('activeValue'),
+
+ parseActiveValue: function(value) {
+ var out;
+ if ( this.get('customRadio') === 'yes' )
+ {
+ out = value.trim();
+ }
+ else
+ {
+ out = this.get('thisPage');
+ }
+ return out;
+ },
+
+ activeValueObserver: function() {
+ this.send('sendActiveValue', this.parseActiveValue(this.get('customValue')));
+ }.observes('customRadio','customValue','thisPage'),
+
+
+ activeValue: function() {
+ return this.parseActiveValue(this.get('customValue'));
+ }.property('customRadio','customValue','thisPage'),
+
+ customValueDidChange: function() {
+ var val = this.get('customValue')||''.trim();
+ var idx = val.indexOf('/', 8); // 8 is enough for "https://"
+ if ( idx !== -1 )
+ {
+ // Trim paths off of the URL
+ this.set('customValue', val.substr(0,idx));
+ return; // We'll be back...
+ }
+
+ if ( val )
+ {
+ this.set('customRadio','yes');
+ }
+ }.observes('customValue'),
+
+});
diff --git a/app/components/host-settings/template.hbs b/app/components/host-settings/template.hbs
new file mode 100644
index 000000000..968fb7f49
--- /dev/null
+++ b/app/components/host-settings/template.hbs
@@ -0,0 +1,23 @@
+
Host
+
+
We need to know a little about how your environment is set up before you can register hosts. What base URL should hosts use to connect to the Rancher API?