mirror of https://github.com/rancher/ui.git
Merge pull request #89 from vincent99/master
Hosts Setup to set api.host setting
This commit is contained in:
commit
c023d55b6f
|
|
@ -11,10 +11,12 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
var store = this.get('store');
|
||||
var session = this.get('session');
|
||||
|
||||
// Load schemas
|
||||
return store.find('schema', null, {url: 'schemas'}).then((/*schemas*/) => {
|
||||
var isAdmin = session.get(C.USER_TYPE_SESSION_KEY) === C.USER_TYPE_ADMIN;
|
||||
// Save whether the user is an admin or not.
|
||||
// For cattle >= v0.6 the token response will have userType: admin/user, for older look for a schema
|
||||
this.set('app.isAuthenticationAdmin', session.get(C.USER_TYPE_SESSION_KEY) === C.USER_TYPE_ADMIN || store.hasRecordFor('schema','githubconfig'));
|
||||
this.set('app.isAuthenticationAdmin', isAdmin || store.hasRecordFor('schema','githubconfig'));
|
||||
|
||||
// Load all the projects
|
||||
var supportsProjects = this.get('app.authenticationEnabled') && store.hasRecordFor('schema','project');
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export default Ember.View.extend({
|
|||
|
||||
// Cap add/drop multiselects
|
||||
this.initMultiselect();
|
||||
|
||||
this.$('INPUT')[0].focus();
|
||||
},
|
||||
|
||||
willDestroyElement: function() {
|
||||
|
|
|
|||
|
|
@ -86,14 +86,15 @@ var HostController = Cattle.TransitioningResourceController.extend({
|
|||
}.property('physicalHostId'),
|
||||
|
||||
osBlurb: function() {
|
||||
if ( this.get('info.osInfo') )
|
||||
// @TODO this always sends back Ubuntu
|
||||
if ( false && this.get('info.osInfo') )
|
||||
{
|
||||
return this.get('info.osInfo.distribution') + ' ' + this.get('info.osInfo.version');
|
||||
}
|
||||
}.property('info.osInfo.{distribution,version}'),
|
||||
|
||||
cpuBlurb: function() {
|
||||
if ( this.get('info.cpuInfo') )
|
||||
if ( this.get('info.cpuInfo.count') )
|
||||
{
|
||||
var ghz = Math.round(this.get('info.cpuInfo.mhz')/10)/100;
|
||||
|
||||
|
|
@ -118,10 +119,10 @@ var HostController = Cattle.TransitioningResourceController.extend({
|
|||
}.property('info.memoryInfo.memTotal'),
|
||||
|
||||
diskBlurb: function() {
|
||||
if ( this.get('info.diskInfo') )
|
||||
if ( this.get('info.diskInfo.mountPoints') )
|
||||
{
|
||||
var totalMb = 0;
|
||||
var mounts = this.get('info.diskInfo.mountPoints');
|
||||
var mounts = this.get('info.diskInfo.mountPoints')||[];
|
||||
Object.keys(mounts).forEach((mountPoint) => {
|
||||
totalMb += mounts[mountPoint].total;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,26 @@
|
|||
import OverlayRoute from 'ui/pods/overlay/route';
|
||||
import C from 'ui/utils/constants';
|
||||
import Ember from 'ember';
|
||||
|
||||
export default OverlayRoute.extend({
|
||||
model: function() {
|
||||
var userType = this.get('session').get(C.USER_TYPE_SESSION_KEY);
|
||||
var isAdmin = userType === undefined || userType === C.USER_TYPE_ADMIN;
|
||||
if ( isAdmin )
|
||||
{
|
||||
return this.get('store').find('setting', C.SETTING_API_HOST).then((setting) => {
|
||||
if ( setting.get('value') )
|
||||
{
|
||||
return Ember.RSVP.resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.transitionTo('hosts.setup');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
cancel: function() {
|
||||
// @TODO don't remember switches between tabs as previous routes
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@
|
|||
{{#each driver in drivers}}
|
||||
{{#if driver.available}}
|
||||
{{#link-to driver.route tagName="li" href=false}}
|
||||
<a {{bind-attr href=view.href}}>{{driver.label}}</a>
|
||||
<a>{{driver.label}}</a>
|
||||
{{/link-to}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#link-to "hosts.setup" tagName="li" href=false class="pull-right"}}
|
||||
<a>Setup</a>
|
||||
{{/link-to}}
|
||||
</ul>
|
||||
|
||||
<section>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
var hostname = window.location.hostname;
|
||||
var looksPublic = true;
|
||||
if ( hostname.match(/^(localhost|192\.168\.|172\.1{6789}\.|172\.2{0123456789}\.|172\.3{01}\.|10\.)/) )
|
||||
{
|
||||
looksPublic = false;
|
||||
}
|
||||
|
||||
export default Ember.ObjectController.extend({
|
||||
error: null,
|
||||
customRadio: (looksPublic ? 'no' : 'yes'),
|
||||
custom: Ember.computed.equal('customRadio', 'yes'),
|
||||
looksPublic: looksPublic,
|
||||
editing: true,
|
||||
saving: false,
|
||||
thisPage: window.location.host,
|
||||
customValue: '',
|
||||
|
||||
actions: {
|
||||
save: function() {
|
||||
var model = this.get('model');
|
||||
if ( this.get('custom') )
|
||||
{
|
||||
var value = this.get('customValue').trim();
|
||||
if ( !value )
|
||||
{
|
||||
this.set('error', 'Please provide a DNS name or IP address');
|
||||
return;
|
||||
}
|
||||
|
||||
model.set('value', value);
|
||||
}
|
||||
else
|
||||
{
|
||||
model.set('value', this.get('thisPage'));
|
||||
}
|
||||
|
||||
this.set('saving', true);
|
||||
model.save().then(() => {
|
||||
this.transitionTo('hosts.new');
|
||||
}).catch((err) => {
|
||||
this.set('error', err);
|
||||
}).finally(() => {
|
||||
this.set('saving', false);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
this.send('goToPrevious');
|
||||
}
|
||||
},
|
||||
|
||||
customValueDidChange: function() {
|
||||
if ( this.get('customValue') )
|
||||
{
|
||||
this.set('customRadio','yes');
|
||||
}
|
||||
}.observes('customValue'),
|
||||
});
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import OverlayRoute from 'ui/pods/overlay/route';
|
||||
import C from 'ui/utils/constants';
|
||||
|
||||
export default OverlayRoute.extend({
|
||||
model: function() {
|
||||
return this.get('store').find('setting', C.SETTING_API_HOST);
|
||||
},
|
||||
|
||||
renderTemplate: function() {
|
||||
this.render({into: 'application', outlet: 'overlay'});
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<h2>Host Setup</h2>
|
||||
<h4>We need to know a little about how your environment is set up before you can register hosts.</h4>
|
||||
|
||||
{{#if error}}
|
||||
<div class="alert alert-danger" style="margin-top: 15px;">
|
||||
<p>{{error}}</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<h5 style="margin-top: 30px;">What DNS name or IP address and port should hosts use to connect to the Rancher API?</h5>
|
||||
|
||||
<div style="margin-top: 15px;">
|
||||
<label>{{radio-button selection=customRadio value="no"}} This site's address:</label>
|
||||
<code class="form-control-static">{{thisPage}}</code>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>{{radio-button selection=customRadio value="yes"}} Something else:</label>
|
||||
{{input type="text" class="form-control" value=customValue placeholder="e.g. rancher.mydomain.com"}}
|
||||
</div>
|
||||
|
||||
{{#unless looksPublic}}
|
||||
{{#unless custom}}
|
||||
<div class="alert alert-info" style="margin-top: 30px;">
|
||||
<i class="ss-info" style="font-size: 35px; float: left;"></i>
|
||||
<p style="margin-left: 50px;">
|
||||
Are you sure all hosts you create will be able to reach <code>{{thisPage}}</code>?<br/>It looks like a private IP or local network.
|
||||
</p>
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
|
||||
<div class="footer-actions">
|
||||
{{partial "save-cancel"}}
|
||||
</div>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import Overlay from 'ui/pods/overlay/view';
|
||||
|
||||
export default Overlay.extend({
|
||||
actions: {
|
||||
overlayEnter: function() {
|
||||
this.get('controller').send('save');
|
||||
},
|
||||
|
||||
overlayClose: function() {
|
||||
this.get('controller').send('cancel');
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -26,6 +26,7 @@ Router.map(function() {
|
|||
});
|
||||
|
||||
this.resource('hosts', { path: '/hosts'}, function() {
|
||||
this.route('setup', {path: '/setup'});
|
||||
this.route('new', {path: '/new'}, function() {
|
||||
this.route('digitalocean');
|
||||
this.route('openstack');
|
||||
|
|
|
|||
|
|
@ -415,12 +415,16 @@ TABLE.graphs {
|
|||
}
|
||||
|
||||
.btn-circle {
|
||||
@extend .btn;
|
||||
display: inline-block;
|
||||
line-height: $line-height-base;
|
||||
vertical-align: middle;
|
||||
touch-action: manipulation;
|
||||
background-color: transparent;
|
||||
background-repeat: no-repeat;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<div class="col-sm-12 col-md-8">
|
||||
<div class="form-control-static">
|
||||
<button class="btn btn-circle" {{action "addVolume" target="view"}}><i class="ss-plus"></i></button>
|
||||
<button class="btn-circle-plus" {{action "addVolume" target="view"}}></button>
|
||||
</div>
|
||||
{{#if volumesArray.length}}
|
||||
<table class="table fixed no-lines no-top-padding tight">
|
||||
|
|
@ -15,9 +15,7 @@
|
|||
{{input type="text" class="form-control volume-path input-sm" value=vol.value placeholder="e.g. [/path/on/host]:/path/in/container[:ro]"}}
|
||||
</td>
|
||||
<td width="30" class="text-right">
|
||||
<button {{action "removeVolume" vol}} class="btn btn-circle" type="button" tabindex="-1">
|
||||
<i class="ss-delete"></i>
|
||||
</button>
|
||||
<button {{action "removeVolume" vol}} class="btn-circle-x" type="button" tabindex="-1"></button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
@ -35,7 +33,7 @@
|
|||
<div class="form-control-static">
|
||||
{{#if hostId}}
|
||||
{{#if hostContainerChoices.length}}
|
||||
<button class="btn btn-circle" {{action "addVolumeFrom" target="view"}}><i class="ss-plus"></i></button>
|
||||
<button class="btn btn-circle-plus" {{action "addVolumeFrom" target="view"}}></button>
|
||||
{{else}}
|
||||
<span class="text-muted">This host has no containers to use the volumes from.</span>
|
||||
{{/if}}
|
||||
|
|
@ -59,9 +57,7 @@
|
|||
}}
|
||||
</td>
|
||||
<td width="30" class="text-right">
|
||||
<button {{action "removeVolumeFrom" vol}} class="btn btn-circle" type="button" tabindex="-1">
|
||||
<i class="ss-delete"></i>
|
||||
</button>
|
||||
<button {{action "removeVolumeFrom" vol}} class="btn-circle-x" type="button" tabindex="-1"></button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ export default {
|
|||
|
||||
NO_CHALLENGE_HEADER: 'x-api-no-challenge',
|
||||
NO_CHALLENGE_VALUE: 'true',
|
||||
|
||||
SETTING_API_HOST: 'api.host',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default Ember.ArrayProxy.extend({
|
|||
|
||||
sourceContentChanged: function() {
|
||||
var x = this.get('sourceContent').filter(function(item) {
|
||||
return item.get('state').toLowerCase() !== 'purged';
|
||||
return (item.get('state')||'').toLowerCase() !== 'purged';
|
||||
});
|
||||
this.set('content', x);
|
||||
}.observes('sourceContent.@each.state').on('init'),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ui",
|
||||
"version": "0.10.0",
|
||||
"version": "0.10.1",
|
||||
"private": true,
|
||||
"directories": {
|
||||
"doc": "doc",
|
||||
|
|
|
|||
Loading…
Reference in New Issue