diff --git a/app/pods/login/controller.js b/app/pods/login/controller.js
index 70eca2b..2b2a42a 100644
--- a/app/pods/login/controller.js
+++ b/app/pods/login/controller.js
@@ -7,12 +7,12 @@ export default Ember.Controller.extend({
let session = this.get('session');
let authenticator = 'simple-auth-authenticator:token';
- this.set('loading', true);
// Manually clean up because there might not be a transition
this.get('flashMessages').clearMessages();
- session.authenticate(authenticator, credentials).then(null, (error)=> {
- this.set('loading', false);
- this.get('flashMessages').error(error.error);
+ this.transitionTo('loading').then(() => {
+ session.authenticate(authenticator, credentials).then(null, (error)=> {
+ this.get('flashMessages').error(error.error);
+ });
});
}
}
diff --git a/app/pods/login/template.hbs b/app/pods/login/template.hbs
index 7d3f5ac..c56ca42 100644
--- a/app/pods/login/template.hbs
+++ b/app/pods/login/template.hbs
@@ -1,16 +1,12 @@
{{#x-application invalidateSession="invalidateSession"}}
- {{#if loading}}
- {{loading-panel}}
- {{else}}
-
-
-
- Forget your password? {{link-to 'Request a lockout email.' 'users.requestlockouthelp'}}
-
- {{/if}}
+
+
+
+ Forget your password? {{link-to 'Request a lockout email.' 'users.requestlockouthelp'}}
+
{{/x-application}}
diff --git a/app/pods/protected/compare/results/controller.js b/app/pods/protected/compare/results/controller.js
index c8fafc1..391985a 100644
--- a/app/pods/protected/compare/results/controller.js
+++ b/app/pods/protected/compare/results/controller.js
@@ -3,6 +3,13 @@ import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['strain_ids', 'characteristic_ids'],
+ csvLink: function() {
+ let token = encodeURIComponent(this.get('session.secure.token'));
+ return `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/` +
+ `compare?token=${token}&strain_ids=${this.get('strain_ids')}&` +
+ `characteristic_ids=${this.get('characteristic_ids')}&mimeType=csv`;
+ }.property('strain_ids', 'characteristic_ids').readOnly(),
+
strains: function() {
let strains = [];
let strain_ids = this.get('strain_ids').split(',');
@@ -21,30 +28,4 @@ export default Ember.Controller.extend({
return characteristics;
}.property('characteristic_ids'),
- // Set up data table matrix
- data: function() {
- let characteristics = this.get('characteristics');
- let strains = this.get('strains');
- let measurements = this.get('model');
- let data = Ember.A();
-
- characteristics.forEach((characteristic) => {
- let row = {
- characteristic: characteristic.get('characteristicName'),
- };
-
- strains.forEach((strain) => {
- let meas = measurements.filterBy('strain.id', strain.get('id'))
- .filterBy('characteristic.id', characteristic.get('id'));
- if (!Ember.isEmpty(meas)) {
- row[strain.get('id')] = meas[0].get('value');
- } else {
- row[strain.get('id')] = '';
- }
- });
- data.pushObject(row);
- });
- return data;
- }.property('characteristics', 'strains').readOnly(),
-
});
diff --git a/app/pods/protected/compare/results/route.js b/app/pods/protected/compare/results/route.js
index ef097f3..e37da66 100644
--- a/app/pods/protected/compare/results/route.js
+++ b/app/pods/protected/compare/results/route.js
@@ -1,4 +1,5 @@
import Ember from 'ember';
+import ajaxRequest from '../../../../utils/ajax-request';
export default Ember.Route.extend({
queryParams: {
@@ -12,16 +13,35 @@ export default Ember.Route.extend({
beforeModel: function(transition) {
this._super(transition);
- if (Ember.$.isEmptyObject(transition.queryParams)) {
+ if (Ember.$.isEmptyObject(transition.queryParams.strain_ids) ||
+ Ember.$.isEmptyObject(transition.queryParams.characteristic_ids)) {
this.transitionTo('protected.compare');
}
},
model: function(params) {
+ if (params.strain_ids === '' || params.characteristic_ids === '') {
+ this.transitionTo('protected.compare');
+ }
+
let compare = this.controllerFor('protected.compare');
compare.set('selectedStrains', params.strain_ids);
compare.set('selectedCharacteristics', params.characteristic_ids);
- return this.store.query('measurement', params);
+
+ let url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/compare`;
+ let options = {
+ method: 'GET',
+ data: params,
+ };
+ return ajaxRequest(url, options);
+ },
+
+ setupController: function(controller, model) {
+ model.forEach((m, i) => {
+ let c = this.store.peekRecord('characteristic', m[0]);
+ model[i][0] = c.get('characteristicName');
+ });
+ controller.set('model', model);
},
});
diff --git a/app/pods/protected/compare/results/template.hbs b/app/pods/protected/compare/results/template.hbs
index dbed78d..e7384f8 100644
--- a/app/pods/protected/compare/results/template.hbs
+++ b/app/pods/protected/compare/results/template.hbs
@@ -13,14 +13,15 @@
- {{#each data as |row|}}
+ {{#each model as |row|}}
- {{row.characteristic}} |
- {{#each strains as |strain|}}
- {{get-property row strain.id}} |
+ {{#each row key="@index" as |col|}}
+ {{col}} |
{{/each}}
{{/each}}
+
+ Download as CSV
diff --git a/app/pods/protected/loading/template.hbs b/app/pods/protected/loading/template.hbs
new file mode 100644
index 0000000..e5a3e05
--- /dev/null
+++ b/app/pods/protected/loading/template.hbs
@@ -0,0 +1 @@
+{{loading-panel}}
diff --git a/app/pods/users/new/new-user-form/component.js b/app/pods/users/new/controller.js
similarity index 76%
rename from app/pods/users/new/new-user-form/component.js
rename to app/pods/users/new/controller.js
index 4d8b815..fcc00d7 100644
--- a/app/pods/users/new/new-user-form/component.js
+++ b/app/pods/users/new/controller.js
@@ -1,7 +1,6 @@
import Ember from 'ember';
-export default Ember.Component.extend({
- classNames: ['grid-1'],
+export default Ember.Controller.extend({
passwordConfirm: null,
actions: {
@@ -17,7 +16,10 @@ export default Ember.Component.extend({
if (user.get('hasDirtyAttributes')) {
user.save().then(() => {
- this.sendAction();
+ this.transitionTo('login').then(() => {
+ this.get('flashMessages').information(`You have successfully signed up.
+ Please check your email for further instructions.`);
+ });
}).catch(() => {
// Manually clean up messages because there is no transition
this.get('flashMessages').clearMessages();
diff --git a/app/pods/users/new/new-user-form/template.hbs b/app/pods/users/new/new-user-form/template.hbs
deleted file mode 100644
index e1f70de..0000000
--- a/app/pods/users/new/new-user-form/template.hbs
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
diff --git a/app/pods/users/new/route.js b/app/pods/users/new/route.js
index 5557316..8d7010b 100644
--- a/app/pods/users/new/route.js
+++ b/app/pods/users/new/route.js
@@ -12,12 +12,4 @@ export default Ember.Route.extend(UnauthenticatedRouteMixin, {
controller.setProperties(model);
},
- actions: {
- success: function() {
- this.transitionTo('login').then(() => {
- this.get('flashMessages').information(`You have successfully signed up.
- Please check your email for further instructions.`);
- });
- }
- },
});
diff --git a/app/pods/users/new/template.hbs b/app/pods/users/new/template.hbs
index 075ede5..d6e81c5 100644
--- a/app/pods/users/new/template.hbs
+++ b/app/pods/users/new/template.hbs
@@ -1 +1,32 @@
-{{users/new/new-user-form user=user action="success"}}
+
+
+
+
+