Permalink
Browse files

Updated manager app to Ember CLI 0.2.

  • Loading branch information...
heycarsten committed Mar 19, 2015
1 parent 542bc7a commit a0a7a3cbc8d9529df20ac2e6ad5a5b1c0327fd6e
@@ -1,31 +1,28 @@
import Em from 'ember';

export default Em.Controller.extend({
year: function() {
year: Em.computed(function() {
return new Date().getFullYear();
}.property(),
}),

actions: {
toggleAccountMenu: function() {
var controller = this;

toggleAccountMenu() {
if (this.get('showAccountMenu')) {
return;
}

this.set('showAccountMenu', true);

Em.run.next(function() {
Em.$(document).one('click', function() {
controller.set('showAccountMenu', false);
Em.run.next(() => {
Em.$(document).one('click', () => {
this.set('showAccountMenu', false);
return true;
});
});
}
},

currentRouteClass: function() {
var path = this.get('currentPath');
return path.dasherize().replace(/\./g, '-');
}.property('currentPath'),
currentRouteClass: Em.computed(function() {
return this.get('currentPath').dasherize().replace(/\./g, '-');
}).property('currentPath')
});
@@ -1,9 +1,9 @@
import Em from 'ember';

export default Em.Controller.extend({
needs: 'application',
application: Em.inject.controller(),

currentPath: Em.computed.oneWay('controllers.application.currentPath'),
currentPath: Em.computed.reads('application.currentPath'),

inKeys: Em.computed.match('currentPath', /^dashboard\.keys/),
inAccount: Em.computed.match('currentPath', /^dashboard\.account/)
@@ -20,5 +20,4 @@ import Em from 'ember';
// return ret;
// }.property('cycleRequests')

export default Em.ObjectController.extend({
});
export default Em.Controller.extend();
@@ -6,17 +6,15 @@ var KINDS = [
{ id: 'native_client', label: 'Desktop / Mobile \u2014 Apple iOS / Cocoa, Android, Blackberry, etc.' }
];

export default Em.ObjectController.extend({
export default Em.Controller.extend({
kindOptions: KINDS,
isWebClient: Em.computed.equal('kind', 'web_client'),
isClient: Em.computed.match('kind', /_client$/),
isWebClient: Em.computed.equal('model.kind', 'web_client'),
isClient: Em.computed.match('model.kind', /_client$/),

actions: {
createKey: function(model) {
var controller = this;

model.save().then(function() {
controller.transitionTo('dashboard.keys');
createKey(model) {
model.save().then(() => {
this.transitionTo('dashboard.keys');
}, Em.K);
}
}
@@ -1,17 +1,17 @@
import Em from 'ember';

export default Em.ObjectController.extend({
isWeb: Em.computed.equal('kind', 'web_client'),
isServer: Em.computed.equal('kind', 'private_server'),
isClient: Em.computed.equal('kind', 'native_client'),
export default Em.Controller.extend({
isWeb: Em.computed.equal('model.kind', 'web_client'),
isServer: Em.computed.equal('model.kind', 'private_server'),
isClient: Em.computed.equal('model.kind', 'native_client'),

currentMonth: function() {
currentMonth: Em.computed(function() {
return moment().format('MMMM');
}.property(),
}),

actions: {
deleteKey: function() {
if (this.get('totalCycleRequests') > 0) {
deleteKey() {
if (this.get('model.totalCycleRequests') > 0) {
if (!confirm('Are you sure you want to delete this Access Key? Any integrations that are using it will stop working.')) {
return;
}
@@ -1,27 +1,25 @@
import Ember from 'ember';
import Em from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';

export default Ember.Controller.extend(LoginControllerMixin, {
export default Em.Controller.extend(LoginControllerMixin, {
authenticator: 'authenticator:un-auth',

actions: {
// display an error when authentication fails
authenticate: function() {
var controller = this;

this.send('loading');

this._super().then(null, function(xhr) {
this._super().catch(xhr => {
var msg;

if (xhr.status === 422) {
msg = xhr.responseJSON.error.detail;
} else {
msg = 'an HTTP ' + xhr.status + ' error occurred on the server, try again';
msg = `an HTTP ${xhr.status} error occurred on the server, try again`;
}

controller.send('loaded');
controller.set('errorMessage', msg.capitalize() + '.');
this.send('loaded');
this.set('errorMessage', msg.capitalize() + '.');
});
}
}
@@ -2,47 +2,40 @@ import Em from 'ember';

export default Em.Controller.extend({
actions: {
submit: function() {
var controller = this;

submit() {
this.send('loading');

Em.$.ajax({
url: '/manager/passwords/' + this.get('token'),
type: 'PUT',
data: { password: this.get('password') }
}).then(
function(data) {
Em.run(function() {
controller.session.authenticate('authenticator:un-auth', data).then(function() {
controller.transitionToRoute('dashboard.keys');
});
}).then(data => {
Em.run(function() {
this.session.authenticate('authenticator:un-auth', data).then(() => {
this.transitionToRoute('dashboard.keys');
});
},

function(xhr) {
Em.run(function() {
// MEGAHAX :-/
var err = Em.Object.create({
remove: function(prop) {
var val = this.get(prop);

if (val) {
val.clear();
}
});
}).catch(xhr => {
Em.run(() => {
// MEGAHAX :-/
var err = Em.Object.create({
remove: function(prop) {
var val = this.get(prop);

if (val) {
val.clear();
}
});

xhr.responseJSON.errors.forEach(function(e) {
err[e.path.camelize()] = [{ message: e.detail }];
});
}
});

controller.set('errors', err);
controller.send('loaded');
xhr.responseJSON.errors.forEach(e => {
err[e.path.camelize()] = [{ message: e.detail }];
});
}
);

this.set('errors', err);
this.send('loaded');
});
});
}
}
});
@@ -5,25 +5,23 @@ export default Em.Controller.extend({

subTemplate: 'password/recover/form',

reset: function() {
reset() {
this.set('email', null);
this.set('subTemplate', 'password/recover/form');
},

actions: {
submit: function() {
var controller = this;

submit() {
this.send('loading');

Em.$.ajax({
url: '/manager/passwords',
type: 'POST',
data: { email: this.get('email') }
}).always(function() {
Em.run(function() {
controller.set('subTemplate', 'password/recover/done');
controller.send('loaded');
}).always(() => {
Em.run(() => {
this.set('subTemplate', 'password/recover/done');
this.send('loaded');
});
});
}
@@ -1,33 +1,27 @@
import Em from 'ember';

export default Em.ObjectController.extend({
export default Em.Controller.extend({
disabled: false,
currentTemplate: 'signup/form',

reset: function() {
reset() {
this.setProperties({
name: null,
email: null,
name: null,
email: null,
password: null
});
},

actions: {
createAccount: function(model) {
var controller = this;

createAccount(model) {
this.send('loading');

model.save().then(
function() {
controller.send('loaded');
controller.set('currentTemplate', 'signup/done');
},

function() {
controller.send('loaded');
}
);
model.save().then(() => {
this.send('loaded');
this.set('currentTemplate', 'signup/done');
}).catch(() => {
this.send('loaded');
});
}
}
});
@@ -1,7 +1,7 @@
<h1>Activity</h1>

<h2>Total requests this month: {{totalCycleRequests}}</h2>
<h2>Total requests this month: {{model.totalCycleRequests}}</h2>

{{line-area-chart
height=240
data=cycleRequests}}
data=model.cycleRequests}}
@@ -11,7 +11,7 @@
</tr>
</thead>
<tbody>
{{#each key in this}}
{{#each key in model}}
{{#link-to "dashboard.keys.show" key tagName="tr"}}
<td>{{key.label}}</td>
<td>{{key.humanKind}}</td>
@@ -1,44 +1,40 @@
<h1>{{label}}</h1>

{{#if totalCycleRequests}}
{{#if model.totalCycleRequests}}
<section class="activity-detail">
<header>
<h1>{{currentMonth}}</h1>
<h2>Daily Activity</h2>
</header>
{{line-area-chart height=150 data=cycleRequests}}
{{line-area-chart height=150 data=model.cycleRequests}}
</section>
{{/if}}

<div class='key-and-usage-wrapper'>
<section class="key-detail">
<h1>API Key</h1>

<code class='key-payload'>{{unbound token}}</code>
<code class='key-payload'>{{unbound model.token}}</code>

<ul class='meta'>
{{#if isServer}}
{{#if model.isServer}}
<li>
<h2>Type</h2>
<p>Private / Server</p>
</li>
{{/if}}

{{#if isClient}}
{{else if model.isClient}}
<li>
<h2>Type</h2>
<p>Mobile / Desktop</p>
</li>
{{/if}}

{{#if isWeb}}
{{else if model.isWeb}}
<li>
<h2>Type</h2>
<p>Web Browser</p>
</li>
<li title="You can make requests from this domain with CORS or JSONP.">
<h2>Domain</h2>
<p>{{domain}}</p>
<p>{{model.domain}}</p>
</li>
<li title="Individual clients are limited to 1200 requests per hour.">
<h2>Rate Limit</h2>
@@ -21,7 +21,7 @@
"devDependencies": {
"broccoli-asset-rev": "^2.0.0",
"broccoli-sass": "^0.4.0",
"ember-cli": "0.2.0-beta.1",
"ember-cli": "0.2.0",
"ember-cli-app-version": "0.3.1",
"ember-cli-babel": "^4.0.0",
"ember-cli-bourbon": "0.0.5",

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<base href="/manager/" />
<meta name="manager/config/environment" content="%7B%22modulePrefix%22%3A%22manager%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/manager/%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22manager%22%2C%22version%22%3A%220.0.0.c32657b6%22%7D%2C%22simple-auth%22%3A%7B%22session%22%3A%22session%3Aun-auth%22%2C%22authorizer%22%3A%22authorizer%3Aun-auth%22%2C%22authenticator%22%3A%22authenticator%3Aun-auth%22%2C%22routeAfterAuthentication%22%3A%22dashboard.keys%22%2C%22routeIfAlreadyAuthenticated%22%3A%22dashboard.keys%22%7D%2C%22exportApplicationGlobal%22%3Afalse%7D" />
<meta name="manager/config/environment" content="%7B%22modulePrefix%22%3A%22manager%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/manager/%22%2C%22locationType%22%3A%22auto%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22manager%22%2C%22version%22%3A%220.0.0.dc45090e%22%7D%2C%22simple-auth%22%3A%7B%22session%22%3A%22session%3Aun-auth%22%2C%22authorizer%22%3A%22authorizer%3Aun-auth%22%2C%22authenticator%22%3A%22authenticator%3Aun-auth%22%2C%22routeAfterAuthentication%22%3A%22dashboard.keys%22%2C%22routeIfAlreadyAuthenticated%22%3A%22dashboard.keys%22%7D%2C%22exportApplicationGlobal%22%3Afalse%7D" />

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:500,900,400italic,400,300,300italic,700,700italic' rel='stylesheet' type='text/css'>
@@ -21,8 +21,8 @@
<body>


<script src="assets/vendor-982512408faa3112b39469ff46126f87.js"></script>
<script src="assets/manager-7de8e4fa3f997a503d4cc4c8ac786c37.js"></script>
<script src="assets/vendor-9c0369f3f4db079b809e8e53d5b7d2b5.js"></script>
<script src="assets/manager-870aa2ae56d0e923000bb8591e292f60.js"></script>


</body>

0 comments on commit a0a7a3c

Please sign in to comment.