x-api-bearer auth, project detail

This commit is contained in:
Vincent Fiduccia 2015-04-22 00:54:00 -07:00
parent 29a71af7b7
commit 4c4ebefba2
13 changed files with 128 additions and 30 deletions

View File

@ -1,7 +1,8 @@
import Cattle from 'ui/utils/cattle';
import C from 'ui/utils/constants';
export default Cattle.CollectionController.extend({
needs: ['application'],
needs: ['application','authenticated'],
itemController: 'apikey',
endpoint: function() {
// Strip trailing slash off of the absoluteEndpoint
@ -13,5 +14,18 @@ export default Cattle.CollectionController.extend({
url += this.get('app.apiEndpoint').replace(/^\/+/,'');
return url;
}.property('controllers.application.absoluteEndpoint','app.apiEndpoint')
}.property('controllers.application.absoluteEndpoint','app.apiEndpoint'),
endpointWithAuth: function() {
var session = this.get('session');
var endpoint = this.get('endpoint');
var pos = endpoint.indexOf('//');
endpoint = endpoint.substr(0,pos+2) +
'x-api-bearer=' + session.get(C.SESSION.PROJECT) +
':' + session.get(C.SESSION.TOKEN) +
'@' + endpoint.substr(pos+2);
return endpoint;
}.property('endpoint', 'session.'+C.SESSION.TOKEN,'session.'+C.SESSION.PROJECT)
});

View File

@ -3,7 +3,7 @@
<div class="col-md-6">
<label>Endpoint</label>
<div class="well">
<a href="{{unbound endpoint}}" target="_blank">{{unbound endpoint}}</a>
<a {{bind-attr href=endpointWithAuth}} target="_blank">{{endpoint}}</a>
</div>
</div>
@ -19,7 +19,7 @@
<section class="grid-header">
<div class="row">
<div class="col-sm-6">
<h3>All API Keys ({{length}})</h3>
<h3>API Keys for project: &quot;{{#with controllers.authenticated.project as p controller="project"}}{{p.displayName}}{{/with}}&quot; ({{length}})</h3>
</div>
<div class="col-sm-6 text-right">
<button {{action "newApikey"}} class="btn btn-primary"><i class="ss-plus"></i> Create an API key</button>

View File

@ -5,6 +5,11 @@ export default Ember.Route.extend({
cancel: function() {
this.goToPrevious();
},
didTransition: function() {
this._super();
this.send('setPageLayout', {label: 'Back', backToPrevious: true});
},
},
model: function(/*params, transition*/) {
@ -30,8 +35,4 @@ export default Ember.Route.extend({
controller.set('model', neu);
controller.initFields();
},
renderTemplate: function() {
this.render('projects/new', {controller: 'project/edit'});
},
});

View File

@ -1 +0,0 @@
{{outlet}}

View File

@ -1,3 +1,16 @@
import New from 'ui/project/new/view';
import Ember from 'ember';
export default New.extend();
export default Ember.View.extend({
templateName: 'projects/new',
didInsertElement: function() {
$('BODY').addClass('white');
this.$('INPUT')[0].focus();
this._super();
},
willDestroyElement: function() {
$('BODY').removeClass('white');
this._super();
},
});

View File

@ -0,0 +1,21 @@
import Ember from 'ember';
export default Ember.Route.extend({
model: function(/*params , transition*/) {
var project = this.modelFor('project');
return project.importLink('projectMembers').then(() => {
return project;
});
},
renderTemplate: function() {
this.render({controller: 'project'});
},
actions: {
didTransition: function() {
this._super();
this.send('setPageLayout', {label: 'All Projects', backRoute: 'projects'});
},
},
});

View File

@ -0,0 +1,65 @@
{{partial "transitioning-progress"}}
<section>
<div class="row">
<div class="col-sm-6">
<h3>
{{displayName}}
{{resource-actions-menu model=this choices=availableActions style="display: inline"}}
</h3>
</div>
<div class="col-sm-6 text-right">
<h3 {{bind-attr class=":instance-status stateColor"}}>
<i {{bind-attr class="stateIcon"}}></i> {{displayState}}
</h3>
<div {{bind-attr class=":force-wrap isError:text-danger:text-muted showTransitioningMessage::hide"}}>
{{transitioningMessage}}
</div>
</div>
</div>
</section>
{{#if description}}
<section>
<div class="well">
<label>Description</label>
{{description}}
</div>
</section>
{{/if}}
<section>
<div class="well">
<label>Mounts</label>
<table class="grid fixed">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Role</th>
</tr>
</thead>
<tbody>
{{#each member in projectMembers itemController="projectmember"}}
<tr>
<td>
{{#if member.isRancher}}
{{#if member.isMyRancher}}
My Rancher Account
{{else}}
Rancher Account: {{member.name}} ({{member.externalId}})
{{/if}}
{{else}}
{{github-block type=member.githubType login=member.externalId fallback=member.name}}
{{/if}}
</td>
<td>{{member.displayType}}</td>
<td>
{{uc-first member.role}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</section>

View File

@ -1 +0,0 @@
{{outlet}}

View File

@ -28,7 +28,7 @@
<i {{bind-attr class="p.stateIcon"}}></i> {{p.displayState}}
</td>
<td>
{{p.displayName}}
{{#link-to "project" p.id}}{{p.displayName}}{{/link-to}}
</td>
<td>
{{#if p.description}}{{p.description}}{{else}}<span class="text-italic">No description</span>{{/if}}

View File

@ -21,6 +21,7 @@ Router.map(function() {
this.route('index', {path: '/'});
this.resource("project", { path: '/:project_id' }, function() {
this.route('index', {path: '/'});
this.route("edit");
});
});

View File

@ -15,6 +15,7 @@ test('it renders', function(assert) {
// creates the component instance
var component = this.subject({
projects: [],
store: Ember.Object.create({
hasRecordFor: function() {}
}),

View File

@ -1,16 +0,0 @@
import {
moduleFor,
test
} from 'ember-qunit';
import {
ucFirst
} from 'ui/helpers/uc-first';
moduleFor('helper:uc-first');
// Replace this with your real tests.
test('it works', function(assert) {
var result = ucFirst("things and stuff");
assert.ok(result === "Things and stuff");
});

View File

@ -4,7 +4,7 @@ import {
} from 'ember-qunit';
moduleFor('controller:apikeys', 'ApikeysController', {
needs: ['controller:application']
needs: ['controller:application','controller:authenticated']
});
// Replace this with your real tests.