diff --git a/app/helpers/.gitkeep b/app/helpers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/initializers/custom-session.js b/app/initializers/custom-session.js deleted file mode 100644 index 45b2a27..0000000 --- a/app/initializers/custom-session.js +++ /dev/null @@ -1,34 +0,0 @@ -import Ember from "ember"; -import DS from 'ember-data'; -import Session from "simple-auth/session"; - -// This is pulled straight from ember-cli-simple-auth-token -function getTokenData(token) { - var tokenData = atob(token.split('.')[1]); - try { - return JSON.parse(tokenData); - } catch (e) { - return tokenData; - } -} - -var CustomSession = Session.extend({ - currentUser: function() { - let token = this.get('secure.token'); - if (!Ember.isEmpty(token)) { - let t = getTokenData(token); - return DS.PromiseObject.create({ - promise: this.container.lookup('store:main').find('user', t['sub']) - }); - } - return null; - }.property('token') -}); - -export default { - name: "custom-session", - before: "simple-auth", - initialize: function(container, application) { - application.register('session:custom', CustomSession); - } -}; diff --git a/app/models/.gitkeep b/app/models/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/models/characteristic-type.js b/app/models/characteristic-type.js index 31f793a..284486e 100644 --- a/app/models/characteristic-type.js +++ b/app/models/characteristic-type.js @@ -8,5 +8,6 @@ export default DS.Model.extend({ deletedAt: DS.attr('date'), createdBy: DS.attr('number'), updatedBy: DS.attr('number'), - deletedBy: DS.attr('number') + deletedBy: DS.attr('number'), + sortOrder: DS.attr('number'), }); diff --git a/app/models/characteristic.js b/app/models/characteristic.js index eeeafe4..9f33d7b 100644 --- a/app/models/characteristic.js +++ b/app/models/characteristic.js @@ -10,5 +10,6 @@ export default DS.Model.extend({ deletedAt : DS.attr('date'), createdBy : DS.attr('number'), updatedBy : DS.attr('number'), - deletedBy : DS.attr('number') + deletedBy : DS.attr('number'), + sortOrder : DS.attr('number'), }); diff --git a/app/models/species.js b/app/models/species.js index 8c679ee..b6d509a 100644 --- a/app/models/species.js +++ b/app/models/species.js @@ -7,7 +7,7 @@ export default DS.Model.extend({ typeSpecies : DS.attr('boolean'), etymology : DS.attr('string'), genusName : DS.attr('string', { defaultValue: config.APP.genus }), - strains : DS.hasMany('strain', { async: true }), + strains : DS.hasMany('strain', { async: false }), totalStrains: DS.attr('number'), createdAt : DS.attr('date'), updatedAt : DS.attr('date'), @@ -15,6 +15,7 @@ export default DS.Model.extend({ createdBy : DS.attr('number'), updatedBy : DS.attr('number'), deletedBy : DS.attr('number'), + sortOrder : DS.attr('number'), speciesNameMU: function() { return Ember.String.htmlSafe(`${this.get('speciesName')}`); diff --git a/app/models/strain.js b/app/models/strain.js index 09983a5..49344cf 100644 --- a/app/models/strain.js +++ b/app/models/strain.js @@ -2,21 +2,23 @@ import DS from 'ember-data'; import Ember from 'ember'; export default DS.Model.extend({ - measurements : DS.hasMany('measurements', { async: true }), - species : DS.belongsTo('species', { async: true }), - strainName : DS.attr('string'), - typeStrain : DS.attr('boolean'), - accessionNumbers : DS.attr('string'), - genbank : DS.attr('string'), - isolatedFrom : DS.attr('string'), - notes : DS.attr('string'), - createdAt : DS.attr('date'), - updatedAt : DS.attr('date'), - deletedAt : DS.attr('date'), - createdBy : DS.attr('number'), - updatedBy : DS.attr('number'), - deletedBy : DS.attr('number'), - totalMeasurements: DS.attr('number'), + measurements : DS.hasMany('measurements', { async: true }), + species : DS.belongsTo('species', { async: false }), + strainName : DS.attr('string'), + typeStrain : DS.attr('boolean'), + accessionNumbers : DS.attr('string'), + genbank : DS.attr('string'), + wholeGenomeSequence: DS.attr('string'), + isolatedFrom : DS.attr('string'), + notes : DS.attr('string'), + createdAt : DS.attr('date'), + updatedAt : DS.attr('date'), + deletedAt : DS.attr('date'), + createdBy : DS.attr('number'), + updatedBy : DS.attr('number'), + deletedBy : DS.attr('number'), + totalMeasurements : DS.attr('number'), + sortOrder : DS.attr('number'), strainNameMU: function() { let type = this.get('typeStrain') ? 'T' : ''; diff --git a/app/models/user.js b/app/models/user.js index 67efa88..ae851d0 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -2,6 +2,7 @@ import DS from 'ember-data'; export default DS.Model.extend({ email : DS.attr('string'), + password : DS.attr('string'), name : DS.attr('string'), role : DS.attr('string'), createdAt: DS.attr('date'), diff --git a/app/pods/application/adapter.js b/app/pods/application/adapter.js index e979dec..bb89c25 100644 --- a/app/pods/application/adapter.js +++ b/app/pods/application/adapter.js @@ -5,10 +5,13 @@ export default DS.RESTAdapter.extend({ namespace: function() { return 'api/' + this.get('globals.genus'); }.property(), + host: function() { return this.get('globals.apiURL'); }.property(), + coalesceFindRequests: true, + ajaxError: function(jqXHR) { // http://stackoverflow.com/a/24027443 var error = this._super(jqXHR); @@ -25,5 +28,5 @@ export default DS.RESTAdapter.extend({ } else { return error; } - } + }, }); diff --git a/app/pods/application/route.js b/app/pods/application/route.js index 2f1869b..e3173ee 100644 --- a/app/pods/application/route.js +++ b/app/pods/application/route.js @@ -4,7 +4,16 @@ import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin'; export default Ember.Route.extend(ApplicationRouteMixin, { actions: { invalidateSession: function() { - this.get('session').invalidate(); + this.get('session').invalidate().then(() => { + // Wait until promise is resolved + return true; + }); }, + + didTransition: function() { + this.get('flashMessages').clearMessages(); + return true; + }, + } }); diff --git a/app/pods/application/template.hbs b/app/pods/application/template.hbs index 729e634..6e52a50 100644 --- a/app/pods/application/template.hbs +++ b/app/pods/application/template.hbs @@ -1,7 +1,5 @@
- {{#link-to 'index' class='logo'}} - {{globals.genus}}.info - {{/link-to}} + {{site-logo}} {{#if session.isAuthenticated}}
- - {{globals.genus}}.info - + {{site-logo}}
+ {{#each flashMessages.queue as |flash|}} + {{custom-flash-message flash=flash}} + {{/each}} {{outlet}}
diff --git a/app/pods/characteristics/controller.js b/app/pods/characteristics/controller.js new file mode 100644 index 0000000..ae686a9 --- /dev/null +++ b/app/pods/characteristics/controller.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + sortParams: ['characteristicType.characteristicTypeName', 'characteristicName'], + sortedCharacteristics: Ember.computed.sort('characteristics', 'sortParams'), +}); diff --git a/app/pods/characteristics/route.js b/app/pods/characteristics/route.js index bde4ffa..6fc0c60 100644 --- a/app/pods/characteristics/route.js +++ b/app/pods/characteristics/route.js @@ -8,14 +8,8 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { characteristics: this.store.findAll('characteristic'), }); }, + setupController: function(controller, models) { - var tableAttrs = [ - { name: 'Name', attr: 'characteristicName' }, - { name: 'Type', attr: 'characteristicType.characteristicTypeName' } - ]; - controller.set('model', models.characteristics); - controller.set('tableAttrs', tableAttrs); - controller.set('row', 'characteristic-index-row'); - controller.set('sort', ['characteristicName']); + controller.setProperties(models); }, }); diff --git a/app/pods/characteristics/template.hbs b/app/pods/characteristics/template.hbs index d9e559a..63f40a4 100644 --- a/app/pods/characteristics/template.hbs +++ b/app/pods/characteristics/template.hbs @@ -1,10 +1,19 @@

{{genus-name}} Characteristics

-

Total characteristics: {{model.length}}

+

Total characteristics: {{characteristics.length}}

-{{ - sortable-table - content=model - tableAttrs=tableAttrs - row=row - sortProperties=sort -}} + + + + + + + + + {{#each sortedCharacteristics as |row|}} + + + + + {{/each}} + +
NameType
{{row.characteristicName}}{{row.characteristicType.characteristicTypeName}}
diff --git a/app/pods/compare/route.js b/app/pods/compare/route.js index 5b14286..b53f980 100644 --- a/app/pods/compare/route.js +++ b/app/pods/compare/route.js @@ -1,4 +1,12 @@ import Ember from 'ember'; import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'; -export default Ember.Route.extend(AuthenticatedRouteMixin); +export default Ember.Route.extend(AuthenticatedRouteMixin, { + resetController: function(controller, isExiting /*, transition*/) { + if (isExiting) { + controller.set('data', null); + controller.set('strains', null); + controller.set('dataEmpty', true); + } + } +}); diff --git a/app/pods/compare/template.hbs b/app/pods/compare/template.hbs index 8cf1faa..a4466f4 100644 --- a/app/pods/compare/template.hbs +++ b/app/pods/compare/template.hbs @@ -1,19 +1,28 @@

{{genus-name}} - Compare Strains

-{{measurement-search-panel search='search'}} +{{ + measurement-search-panel + search='search' + strainLabel='Select one or more strains' + charLabel='Select one or more characteristics' +}} {{#if dataEmpty}}
Please select one or more strains and one or more characteristics.
{{else}} -
+
{{#each strains as |strain|}} - + {{/each}} diff --git a/app/pods/components/add-button/component.js b/app/pods/components/add-button/component.js deleted file mode 100644 index 857bde3..0000000 --- a/app/pods/components/add-button/component.js +++ /dev/null @@ -1,8 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - canAdd: function() { - let role = this.get('session.currentUser.role'); - return (role === 'W') || (role === 'A'); - }.property('session.currentUser.role') -}); diff --git a/app/pods/components/characteristic-index-row/component.js b/app/pods/components/characteristic-index-row/component.js deleted file mode 100644 index f48ea57..0000000 --- a/app/pods/components/characteristic-index-row/component.js +++ /dev/null @@ -1,5 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', -}); diff --git a/app/pods/components/characteristic-index-row/template.hbs b/app/pods/components/characteristic-index-row/template.hbs deleted file mode 100644 index c829365..0000000 --- a/app/pods/components/characteristic-index-row/template.hbs +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/app/pods/components/custom-flash-message/component.js b/app/pods/components/custom-flash-message/component.js new file mode 100644 index 0000000..f89312c --- /dev/null +++ b/app/pods/components/custom-flash-message/component.js @@ -0,0 +1,7 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + classNames: ['flakes-message'], + classNameBindings: ['type'], + type: Ember.computed.readOnly('flash.type'), +}); diff --git a/app/pods/components/custom-flash-message/template.hbs b/app/pods/components/custom-flash-message/template.hbs new file mode 100644 index 0000000..2197d70 --- /dev/null +++ b/app/pods/components/custom-flash-message/template.hbs @@ -0,0 +1 @@ +{{flash.message}} diff --git a/app/pods/components/display-errors/template.hbs b/app/pods/components/display-errors/template.hbs index 8d95c0d..6a74209 100644 --- a/app/pods/components/display-errors/template.hbs +++ b/app/pods/components/display-errors/template.hbs @@ -1,3 +1,3 @@ -{{#each error in a}} +{{#each a as |error|}}
{{error.message}}
{{/each}} diff --git a/app/pods/components/forms/species-form/component.js b/app/pods/components/forms/species-form/component.js new file mode 100644 index 0000000..0e5912c --- /dev/null +++ b/app/pods/components/forms/species-form/component.js @@ -0,0 +1,12 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + actions: { + save: function() { + this.sendAction('save'); + }, + cancel: function() { + this.sendAction('cancel'); + }, + } +}); diff --git a/app/pods/components/forms/species-form/template.hbs b/app/pods/components/forms/species-form/template.hbs new file mode 100644 index 0000000..fda54bc --- /dev/null +++ b/app/pods/components/forms/species-form/template.hbs @@ -0,0 +1,42 @@ + +
+ {{species.speciesName}} +
+
+ + {{input value=species.speciesName}} +
+
+ + {{input type="checkbox" checked=species.typeSpecies}} {{if species.typeSpecies 'Yes' 'No'}} +
+
+
+
+ + {{#each species.strains as |strain index|}} + {{if index ","}} + {{#link-to 'strains.show' strain.id}} + {{{strain.strainNameMU}}} + {{/link-to}} + {{/each}} + {{add-button label="Add Strain" link="strains.new"}} +
+
+
+
+ + {{textarea value=species.etymology cols="70" rows="5"}} +
+
+
+ +
+{{#if species.isDirty}} + + Save + +{{/if}} + + Cancel + diff --git a/app/pods/components/measurement-search-panel/component.js b/app/pods/components/measurement-search-panel/component.js index e56e6e9..b9e9749 100644 --- a/app/pods/components/measurement-search-panel/component.js +++ b/app/pods/components/measurement-search-panel/component.js @@ -23,10 +23,10 @@ export default Ember.Component.extend({ models[item.model] = models[item.model].filter((i) => { if (!Ember.isEmpty(i.get(item.children))) { return true; } }); - models[item.model] = models[item.model].sortBy(item.text); + models[item.model] = models[item.model].sortBy('sortOrder'); let temp = models[item.model].map((data) => { let temp_children = []; - let sorted_children = data.get(item.children).sortBy(item.ctext); + let sorted_children = data.get(item.children).sortBy('sortOrder'); sorted_children.forEach((child) => { temp_children.push({id: child.get(item.cid), text: child.get(item.ctext)}); }); diff --git a/app/pods/components/measurement-search-panel/template.hbs b/app/pods/components/measurement-search-panel/template.hbs index ae9dc36..0376f8a 100644 --- a/app/pods/components/measurement-search-panel/template.hbs +++ b/app/pods/components/measurement-search-panel/template.hbs @@ -10,7 +10,7 @@ content=species value=selectedStrains optionValuePath="id" - placeholder="All strains" + placeholder=strainLabel }}
  • @@ -21,7 +21,7 @@ content=characteristicTypes value=selectedCharacteristics optionValuePath="id" - placeholder="All characteristics" + placeholder=charLabel }}
  • diff --git a/app/pods/components/site-logo/template.hbs b/app/pods/components/site-logo/template.hbs new file mode 100644 index 0000000..4219c12 --- /dev/null +++ b/app/pods/components/site-logo/template.hbs @@ -0,0 +1,3 @@ +{{#link-to 'index' class='logo'}} +

    {{globals.genus}}.info

    +{{/link-to}} diff --git a/app/pods/components/sortable-table-header/component.js b/app/pods/components/sortable-table-header/component.js deleted file mode 100644 index 638b078..0000000 --- a/app/pods/components/sortable-table-header/component.js +++ /dev/null @@ -1,13 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'th', - upArrow: '▲', - downArrow: '▼', - - actions: { - sortBy: function(sortProperty, ascending) { - this.sendAction('action', sortProperty, ascending); - } - }, -}); diff --git a/app/pods/components/sortable-table-header/template.hbs b/app/pods/components/sortable-table-header/template.hbs deleted file mode 100644 index 7710080..0000000 --- a/app/pods/components/sortable-table-header/template.hbs +++ /dev/null @@ -1,3 +0,0 @@ -{{title}} -{{{upArrow}}} -{{{downArrow}}} diff --git a/app/pods/components/sortable-table/component.js b/app/pods/components/sortable-table/component.js deleted file mode 100644 index acef098..0000000 --- a/app/pods/components/sortable-table/component.js +++ /dev/null @@ -1,14 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend(Ember.SortableMixin, { - tagName: 'table', - classNames: ['flakes-table'], - sortProperties: [], - - actions: { - sortBy: function(property, ascending) { - this.set('sortAscending', ascending); - this.set('sortProperties', [property]); - } - }, -}); diff --git a/app/pods/components/sortable-table/template.hbs b/app/pods/components/sortable-table/template.hbs deleted file mode 100644 index 0874743..0000000 --- a/app/pods/components/sortable-table/template.hbs +++ /dev/null @@ -1,13 +0,0 @@ -
  • - - {{#each a in tableAttrs}} - {{sortable-table-header title=a.name sortProperty=a.attr action="sortBy"}} - {{/each}} - - - - - {{#each item in arrangedContent}} - {{component row data=item}} - {{/each}} - diff --git a/app/pods/components/species-details/component.js b/app/pods/components/species-details/component.js deleted file mode 100644 index 2950361..0000000 --- a/app/pods/components/species-details/component.js +++ /dev/null @@ -1,22 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - classNames: ['grid-1'], - isEditing: false, - - canEdit: function() { - let role = this.get('session.currentUser.role'); - let id = this.get('session.currentUser.id'); - let author = this.get('species.createdBy'); - return (role === 'W' && (+id === author)) || (role === 'A'); - }.property('session.currentUser.role', 'session.currentUser.id', 'species.createdBy'), - - actions: { - save: function() { - this.sendAction('save'); - }, - cancel: function() { - this.sendAction('cancel'); - }, - } -}); diff --git a/app/pods/components/species-details/template.hbs b/app/pods/components/species-details/template.hbs deleted file mode 100644 index 813ada2..0000000 --- a/app/pods/components/species-details/template.hbs +++ /dev/null @@ -1,89 +0,0 @@ -
    -
    - - Species - {{#if isEditing}} - {{input value=species.speciesName}} - {{else}} - {{species.speciesName}} - {{/if}} - {{display-errors a=species.errors.speciesName}} - - - {{! ROW 1 }} -
    -
    -
    Strains
    -
    - {{#each species.strains as |strain index|}} - {{if index ","}} - {{#link-to 'strains.show' strain.id}} - {{{strain.strainNameMU}}} - {{/link-to}} - {{/each}} - {{#unless species.isNew}} - {{add-button label="Add Strain" link="strains.new"}} - {{/unless}} -
    -
    -
    -
    Type Species?
    -
    - {{#if isEditing}} - {{input type="checkbox" checked=species.typeSpecies}} - {{/if}} - {{if species.typeSpecies 'Yes' 'No'}} - {{display-errors a=species.errors.typeSpecies}} -
    -
    -
    - - {{! ROW 2 }} -
    -
    -
    Etymology
    -
    - {{#if isEditing}} - {{textarea value=species.etymology cols="70" rows="3"}} - {{else}} - {{species.etymology}} - {{/if}} - {{display-errors a=species.errors.etymology}} -
    -
    -
    - - {{! ROW 3 }} -
    -
    -
    Record Created
    -
    {{null-time species.createdAt 'LL'}}
    -
    -
    -
    Record Updated
    -
    {{null-time species.updatedAt 'LL'}}
    -
    -
    -
    Record Deleted
    -
    {{null-time species.deletedAt 'LL'}}
    -
    -
    -
    - - {{! ROW 4 }} - {{#if canEdit}} -
    - -
    - {{/if}} -
    -
    diff --git a/app/pods/components/species-index-row/component.js b/app/pods/components/species-index-row/component.js deleted file mode 100644 index f48ea57..0000000 --- a/app/pods/components/species-index-row/component.js +++ /dev/null @@ -1,5 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', -}); diff --git a/app/pods/components/species-index-row/template.hbs b/app/pods/components/species-index-row/template.hbs deleted file mode 100644 index e86113a..0000000 --- a/app/pods/components/species-index-row/template.hbs +++ /dev/null @@ -1,15 +0,0 @@ - - diff --git a/app/pods/components/strain-details/component.js b/app/pods/components/strain-details/component.js index 87949ee..b483565 100644 --- a/app/pods/components/strain-details/component.js +++ b/app/pods/components/strain-details/component.js @@ -1,15 +1,13 @@ import Ember from 'ember'; +import userCanEdit from '../../../utils/user-can-edit'; export default Ember.Component.extend({ classNames: ['grid-1'], isEditing: false, canEdit: function() { - let role = this.get('session.currentUser.role'); - let id = this.get('session.currentUser.id'); - let author = this.get('strain.createdBy'); - return (role === 'W' && (+id === author)) || (role === 'A'); - }.property('session.currentUser.role', 'session.currentUser.id', 'strain.createdBy'), + return userCanEdit(this.get('session.currentUser'), this.get('strain.createdBy')); + }.property('session.currentUser', 'strain.createdBy').readOnly(), actions: { save: function() { diff --git a/app/pods/components/strain-details/template.hbs b/app/pods/components/strain-details/template.hbs index f2d648f..4f98ea7 100644 --- a/app/pods/components/strain-details/template.hbs +++ b/app/pods/components/strain-details/template.hbs @@ -5,23 +5,22 @@ {{#if isEditing}} {{input value=strain.strainName}} {{else}} - {{strain.strainName}} + {{strain.strainNameMU}} {{/if}} {{display-errors a=strain.errors.strainName}} {{! ROW 1 }} -
    +
    Species
    {{#if isEditing}} {{ - view "select" + select-2 content=species - optionValuePath="content.id" - optionLabelPath="content.speciesName" - selection=strain.species + optionLabelPath="speciesName" + value=strain.species }} {{else}} {{#link-to 'species.show' strain.species}} @@ -43,7 +42,7 @@
    {{! ROW 2 }} -
    +
    Accession Numbers
    @@ -66,6 +65,17 @@ {{display-errors a=strain.errors.genbank}}
    +
    +
    Whole Genome Sequence
    +
    + {{#if isEditing}} + {{input value=strain.wholeGenomeSequence}} + {{else}} + {{strain.wholeGenomeSequence}} + {{/if}} + {{display-errors a=strain.errors.wholeGenomeSequence}} +
    +
    {{! ROW 3 }} diff --git a/app/pods/components/strain-index-row/component.js b/app/pods/components/strain-index-row/component.js deleted file mode 100644 index f48ea57..0000000 --- a/app/pods/components/strain-index-row/component.js +++ /dev/null @@ -1,5 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', -}); diff --git a/app/pods/components/strain-index-row/template.hbs b/app/pods/components/strain-index-row/template.hbs deleted file mode 100644 index f512924..0000000 --- a/app/pods/components/strain-index-row/template.hbs +++ /dev/null @@ -1,8 +0,0 @@ -
    - diff --git a/app/pods/login/controller.js b/app/pods/login/controller.js index d055e8f..c622ec8 100644 --- a/app/pods/login/controller.js +++ b/app/pods/login/controller.js @@ -1,18 +1,25 @@ import Ember from 'ember'; +import parseBase64 from '../../utils/parse-base64'; export default Ember.Controller.extend({ actions: { authenticate: function() { - this.set('errorMessage', null); let credentials = this.getProperties('identification', 'password'); + let session = this.get('session'); let authenticator = 'simple-auth-authenticator:token'; this.set('loading', true); - this.get('session').authenticate(authenticator, credentials).then(()=>{ + // Manually clean up because there might not be a transition + this.get('flashMessages').clearMessages(); + session.authenticate(authenticator, credentials).then(()=>{ this.set('loading', false); + let t = parseBase64(session.get('secure.token')); + this.store.find('user', t['sub']).then((user) => { + session.set('currentUser', user); + }); }, (error)=> { this.set('loading', false); - this.set('errorMessage', error.error); + this.get('flashMessages').error(error.error); }); } } diff --git a/app/pods/login/route.js b/app/pods/login/route.js index 596bf30..457fe0c 100644 --- a/app/pods/login/route.js +++ b/app/pods/login/route.js @@ -1,8 +1,4 @@ import Ember from 'ember'; import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin'; -export default Ember.Route.extend(UnauthenticatedRouteMixin, { - setupController: function(controller) { - controller.set('errorMessage', null); - } -}); +export default Ember.Route.extend(UnauthenticatedRouteMixin, {}); diff --git a/app/pods/login/template.hbs b/app/pods/login/template.hbs index 18d24ef..c851114 100644 --- a/app/pods/login/template.hbs +++ b/app/pods/login/template.hbs @@ -2,10 +2,7 @@

    You are already logged in!

    {{else}} {{#if loading}} -
    -
    -
    -
    + {{loading-panel}} {{else}}

    Log In

    @@ -14,7 +11,4 @@ {{input class="button-gray" type="submit" value="Log In"}} {{/if}} - {{#if errorMessage}} -
    {{errorMessage}}
    - {{/if}} {{/if}} diff --git a/app/pods/measurements/template.hbs b/app/pods/measurements/template.hbs index 63a47e0..6ddf84e 100644 --- a/app/pods/measurements/template.hbs +++ b/app/pods/measurements/template.hbs @@ -1,6 +1,6 @@

    {{genus-name}} Measurements

    -{{measurement-search-panel search='search'}} +{{measurement-search-panel search='search' strainLabel='All strains' charLabel='All characteristics'}}
    diff --git a/app/pods/species/edit/controller.js b/app/pods/species/edit/controller.js new file mode 100644 index 0000000..463392e --- /dev/null +++ b/app/pods/species/edit/controller.js @@ -0,0 +1,29 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + actions: { + save: function() { + let species = this.get('model'); + + if (species.get('isDirty')) { + species.save().then((species) => { + this.transitionToRoute('species.show', species.get('id')); + }, (err) => { + this.get('flashMessages').error(err.responseJSON.error); + }); + } else { + this.transitionToRoute('species.show', species.get('id')); + } + }, + + cancel: function() { + let species = this.get('model'); + + species.get('errors').clear(); + species.rollback(); + + this.transitionToRoute('species.show', species.get('id')); + }, + + }, +}); diff --git a/app/pods/species/edit/route.js b/app/pods/species/edit/route.js new file mode 100644 index 0000000..b3f843f --- /dev/null +++ b/app/pods/species/edit/route.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; +import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'; + +export default Ember.Route.extend(AuthenticatedRouteMixin, {}); diff --git a/app/pods/species/edit/template.hbs b/app/pods/species/edit/template.hbs new file mode 100644 index 0000000..5c6c82f --- /dev/null +++ b/app/pods/species/edit/template.hbs @@ -0,0 +1,6 @@ +{{ + forms/species-form + species=model + save="save" + cancel="cancel" +}} diff --git a/app/pods/species/index/controller.js b/app/pods/species/index/controller.js new file mode 100644 index 0000000..2714e73 --- /dev/null +++ b/app/pods/species/index/controller.js @@ -0,0 +1,11 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + sortParams: ['speciesName', 'strainCount'], + sortedSpecies: Ember.computed.sort('model', 'sortParams'), + + metaData: function() { + return this.store.metadataFor('species'); + }.property('model.isLoaded').readOnly(), + +}); diff --git a/app/pods/species/index/route.js b/app/pods/species/index/route.js index 6ef9dd3..6b02e0e 100644 --- a/app/pods/species/index/route.js +++ b/app/pods/species/index/route.js @@ -4,15 +4,5 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi export default Ember.Route.extend(AuthenticatedRouteMixin, { model: function() { return this.store.findAll('species'); - }, - setupController: function(controller, model) { - var tableAttrs = [ - { name: 'Name', attr: 'speciesName' }, - { name: 'Strains', attr: 'totalStrains' } - ]; - controller.set('model', model); - controller.set('tableAttrs', tableAttrs); - controller.set('row', 'species-index-row'); - controller.set('sort', ['speciesName']); - }, + } }); diff --git a/app/pods/species/index/template.hbs b/app/pods/species/index/template.hbs index b73fee7..6fc2993 100644 --- a/app/pods/species/index/template.hbs +++ b/app/pods/species/index/template.hbs @@ -1,12 +1,34 @@

    {{genus-name}} Species

    -

    Total species: {{controller.length}}

    +

    Total species: {{model.length}}

    -{{add-button label="Add Species" link="species.new"}} +{{add-button label="Add Species" link="species.new" canAdd=metaData.canAdd}} -{{ - sortable-table - content=model - tableAttrs=tableAttrs - row=row - sortProperties=sort -}} +
    Characteristic{{strain.fullNameMU}} + {{#link-to 'strains.show' strain.id classBinding="data.typeStrain:type-strain"}} + {{strain.fullNameMU}} + {{/link-to}} +
    - {{data.characteristicName}} - - {{data.characteristicType.characteristicTypeName}} -
    - - {{#link-to 'species.show' data}} - {{data.speciesName}} - {{/link-to}} - - - {{#each data.strains as |strain index|}} - {{if index ","}} - {{#link-to 'strains.show' strain.id}} - {{{strain.strainNameMU}}} - {{/link-to}} - {{/each}} - - {{#link-to 'strains.show' data.id classBinding="data.typeStrain:type-strain"}} - {{{data.fullNameMU}}} - {{/link-to}} - - {{data.totalMeasurements}} -
    + + + + + + + + {{#each sortedSpecies as |species|}} + + + + + {{/each}} + +
    NameStrains
    + + {{#link-to 'species.show' species}} + {{species.speciesName}} + {{/link-to}} + + + {{#each species.strains as |strain index|}} + {{if index ","}} + {{#link-to 'strains.show' strain.id}} + {{{strain.strainNameMU}}} + {{/link-to}} + {{/each}} +
    diff --git a/app/pods/species/new/controller.js b/app/pods/species/new/controller.js index a289976..568648f 100644 --- a/app/pods/species/new/controller.js +++ b/app/pods/species/new/controller.js @@ -1,21 +1,30 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - isEditing: true, actions: { save: function() { - var species = this.get('model'); + let species = this.get('model'); + if (species.get('isDirty')) { - species.save(); + species.save().then((species) => { + this.transitionToRoute('species.show', species.get('id')); + }, (err) => { + this.get('flashMessages').error(err.responseJSON.error); + }); + } else { + this.transitionToRoute('species.index'); } - this.transitionToRoute('species.index'); }, + cancel: function() { - var species = this.get('model'); + let species = this.get('model'); + if (species.get('isNew')) { species.deleteRecord(); } + this.transitionToRoute('species.index'); - } - } + }, + + }, }); diff --git a/app/pods/species/new/route.js b/app/pods/species/new/route.js index b9f79eb..98741c6 100644 --- a/app/pods/species/new/route.js +++ b/app/pods/species/new/route.js @@ -5,9 +5,5 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { model: function() { return this.store.createRecord('species'); }, - actions: { - cancelSpecies: function() { - this.transitionTo('species.index'); - } - } + }); diff --git a/app/pods/species/new/template.hbs b/app/pods/species/new/template.hbs index f38417f..5c6c82f 100644 --- a/app/pods/species/new/template.hbs +++ b/app/pods/species/new/template.hbs @@ -1,7 +1,6 @@ {{ - species-details + forms/species-form species=model - isEditing=true save="save" cancel="cancel" }} diff --git a/app/pods/species/show/controller.js b/app/pods/species/show/controller.js index 2d5a523..d9625f4 100644 --- a/app/pods/species/show/controller.js +++ b/app/pods/species/show/controller.js @@ -1,22 +1,14 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - isEditing: false, - actions: { - save: function() { - var species = this.get('model'); - if (species.get('isDirty')) { - species.save(); - } - this.toggleProperty('isEditing'); - }, - cancel: function() { - if (this.get('isEditing')) { - var species = this.get('model'); - species.get('errors').clear(); - species.rollback(); - } - this.toggleProperty('isEditing'); + userCanEdit: function() { + let meta = this.store.metadataFor('species'); + let id = this.get('model.id'); + + if (meta.canEdit.indexOf( +id ) === -1) { + return false } - } + return true; + }.property('model.isLoaded').readOnly(), + }); diff --git a/app/pods/species/show/template.hbs b/app/pods/species/show/template.hbs index b242fc5..e892234 100644 --- a/app/pods/species/show/template.hbs +++ b/app/pods/species/show/template.hbs @@ -1,7 +1,63 @@ -{{ - species-details - species=model - isEditing=isEditing - save="save" - cancel="cancel" -}} +
    +
    +
    + + Species {{model.speciesName}} + + + {{! ROW 1 }} +
    +
    +
    Strains
    +
    + {{#each model.strains as |strain index|}} + {{if index ","}} + {{#link-to 'strains.show' strain.id}} + {{{strain.strainNameMU}}} + {{/link-to}} + {{/each}} +
    +
    +
    +
    Type Species?
    +
    + {{if model.typeSpecies 'Yes' 'No'}} +
    +
    +
    + + {{! ROW 2 }} +
    +
    +
    Etymology
    +
    + {{model.etymology}} +
    +
    +
    + + {{! ROW 3 }} +
    +
    +
    Record Created
    +
    {{null-time model.createdAt 'LL'}}
    +
    +
    +
    Record Updated
    +
    {{null-time model.updatedAt 'LL'}}
    +
    +
    +
    Record Deleted
    +
    {{null-time model.deletedAt 'LL'}}
    +
    +
    +
    +
    +
    +
    +{{#if userCanEdit}} +
    + {{#link-to 'species.edit' model class="button-gray smaller"}} + Edit + {{/link-to}} +{{/if}} diff --git a/app/pods/strains/index/controller.js b/app/pods/strains/index/controller.js new file mode 100644 index 0000000..25e4db1 --- /dev/null +++ b/app/pods/strains/index/controller.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + sortParams: ['fullNameMU', 'totalMeasurements'], + sortedStrains: Ember.computed.sort('strains', 'sortParams'), +}); diff --git a/app/pods/strains/index/route.js b/app/pods/strains/index/route.js index 81bcc2b..034c403 100644 --- a/app/pods/strains/index/route.js +++ b/app/pods/strains/index/route.js @@ -3,16 +3,12 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi export default Ember.Route.extend(AuthenticatedRouteMixin, { model: function() { - return this.store.findAll('strain'); + return Ember.RSVP.hash({ + strains: this.store.findAll('strain'), + }); }, + setupController: function(controller, model) { - var tableAttrs = [ - { name: 'Name', attr: 'fullNameMU' }, - { name: 'Total Measurements', attr: 'totalMeasurements' } - ]; - controller.set('model', model); - controller.set('tableAttrs', tableAttrs); - controller.set('row', 'strain-index-row'); - controller.set('sort', ['fullNameMU']); + controller.setProperties(model); }, }); diff --git a/app/pods/strains/index/template.hbs b/app/pods/strains/index/template.hbs index 3d91f2a..9ac0600 100644 --- a/app/pods/strains/index/template.hbs +++ b/app/pods/strains/index/template.hbs @@ -1,12 +1,27 @@

    {{genus-name}} Strains

    -

    Total strains: {{model.length}}

    +

    Total strains: {{strains.length}}

    {{add-button label="Add Strain" link="strains.new"}} -{{ - sortable-table - content=model - tableAttrs=tableAttrs - row=row - sortProperties=sort -}} + + + + + + + + + {{#each sortedStrains as |row|}} + + + + + {{/each}} + +
    SpeciesTotal Measurements
    + {{#link-to 'strains.show' row.id classBinding="data.typeStrain:type-strain"}} + {{row.fullNameMU}} + {{/link-to}} + + {{row.totalMeasurements}} +
    diff --git a/app/pods/user/adapter.js b/app/pods/user/adapter.js deleted file mode 100644 index 9e430e9..0000000 --- a/app/pods/user/adapter.js +++ /dev/null @@ -1,9 +0,0 @@ -import DS from 'ember-data'; - -export default DS.RESTAdapter.extend({ - namespace: 'api', - host: function() { - return this.get('globals.apiURL'); - }.property(), - coalesceFindRequests: true, -}); diff --git a/app/pods/users/route.js b/app/pods/users/index/route.js similarity index 100% rename from app/pods/users/route.js rename to app/pods/users/index/route.js diff --git a/app/pods/users/template.hbs b/app/pods/users/index/template.hbs similarity index 54% rename from app/pods/users/template.hbs rename to app/pods/users/index/template.hbs index 005836e..f3239cb 100644 --- a/app/pods/users/template.hbs +++ b/app/pods/users/index/template.hbs @@ -1,3 +1,3 @@ -{{#each user in model}} +{{#each model as |user|}} {{user.email}}
    {{/each}} diff --git a/app/pods/users/new/fail/route.js b/app/pods/users/new/fail/route.js new file mode 100644 index 0000000..26d9f31 --- /dev/null +++ b/app/pods/users/new/fail/route.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ +}); diff --git a/app/pods/users/new/fail/template.hbs b/app/pods/users/new/fail/template.hbs new file mode 100644 index 0000000..534f7e0 --- /dev/null +++ b/app/pods/users/new/fail/template.hbs @@ -0,0 +1 @@ +

    Failure

    diff --git a/app/pods/users/new/new-user-form/component.js b/app/pods/users/new/new-user-form/component.js new file mode 100644 index 0000000..dd41ea0 --- /dev/null +++ b/app/pods/users/new/new-user-form/component.js @@ -0,0 +1,31 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + classNames: ['grid-1'], + passwordConfirm: null, + + actions: { + save: function() { + let user = this.get('user'); + + // All validation is server-side, except for password verification matching + if (user.get('password') !== this.get('passwordConfirm')) { + this.get('flashMessages').clearMessages(); + this.get('flashMessages').error("Password fields don't match"); + return; + } + + if (user.get('isDirty')) { + user.save().then(() => { + this.sendAction(); + }).catch(() => { + // Manually clean up messages because there is no transition + this.get('flashMessages').clearMessages(); + user.get('errors').forEach((error) => { + this.get('flashMessages').error(`${error.attribute.capitalize()} - ${error.message}`); + }); + }); + } + }, + }, +}); diff --git a/app/pods/users/new/new-user-form/template.hbs b/app/pods/users/new/new-user-form/template.hbs new file mode 100644 index 0000000..da73395 --- /dev/null +++ b/app/pods/users/new/new-user-form/template.hbs @@ -0,0 +1,30 @@ +
    +
    + New User Signup +
    +
      +
    • + + {{input value=user.name}} +
    • +
    • + + {{input value=user.email}} +
    • +
    • + + {{input type="password" value=user.password}} +
    • +
    • + + {{input type="password" value=passwordConfirm}} +
    • +
    • + + Submit + +
    • +
    +
    +
    +
    diff --git a/app/pods/users/new/route.js b/app/pods/users/new/route.js new file mode 100644 index 0000000..5557316 --- /dev/null +++ b/app/pods/users/new/route.js @@ -0,0 +1,23 @@ +import Ember from 'ember'; +import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin'; + +export default Ember.Route.extend(UnauthenticatedRouteMixin, { + model: function() { + return Ember.RSVP.hash({ + user: this.store.createRecord('user'), + }); + }, + + setupController: function(controller, model) { + 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/success/route.js b/app/pods/users/new/success/route.js new file mode 100644 index 0000000..26d9f31 --- /dev/null +++ b/app/pods/users/new/success/route.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ +}); diff --git a/app/pods/users/new/success/template.hbs b/app/pods/users/new/success/template.hbs new file mode 100644 index 0000000..f5fbd3c --- /dev/null +++ b/app/pods/users/new/success/template.hbs @@ -0,0 +1 @@ +

    Success

    diff --git a/app/pods/users/new/template.hbs b/app/pods/users/new/template.hbs new file mode 100644 index 0000000..075ede5 --- /dev/null +++ b/app/pods/users/new/template.hbs @@ -0,0 +1 @@ +{{users/new/new-user-form user=user action="success"}} diff --git a/app/pods/users/new/verify/route.js b/app/pods/users/new/verify/route.js new file mode 100644 index 0000000..26d9f31 --- /dev/null +++ b/app/pods/users/new/verify/route.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ +}); diff --git a/app/pods/users/new/verify/template.hbs b/app/pods/users/new/verify/template.hbs new file mode 100644 index 0000000..c24cd68 --- /dev/null +++ b/app/pods/users/new/verify/template.hbs @@ -0,0 +1 @@ +{{outlet}} diff --git a/app/router.js b/app/router.js index 03f3b68..6f43b21 100644 --- a/app/router.js +++ b/app/router.js @@ -9,18 +9,25 @@ Router.map(function() { this.route('login'); this.route('about'); this.route('characteristics'); - this.route('users'); this.route('measurements'); this.route('compare'); this.route('species', function() { this.route('new'); this.route('show', { path: ':species_id' }); + this.route('edit', { path: ':species_id/edit' }); }); this.route('strains', function() { this.route('new'); this.route('show', { path: ':strain_id' }); }); + this.route('users', function() { + this.route('new', function() { + this.route('fail'); + this.route('success'); + this.route('verify', { path: ':nonce' }); + }); + }); }); export default Router; diff --git a/app/styles/app.css b/app/styles/app.css index ff245dd..2a02ea6 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -1,3 +1,8 @@ +.overflow-div { + white-space: nowrap; + overflow: auto; +} + .measurements-container { padding: 2em 0em 0em 0em; } diff --git a/app/utils/parse-base64.js b/app/utils/parse-base64.js new file mode 100644 index 0000000..deb8f8c --- /dev/null +++ b/app/utils/parse-base64.js @@ -0,0 +1,8 @@ +export default function parseBase64(token) { + let tokenData = atob(token.split('.')[1]); + try { + return JSON.parse(tokenData); + } catch (e) { + return tokenData; + } +} diff --git a/app/utils/user-can-add.js b/app/utils/user-can-add.js new file mode 100644 index 0000000..68a135b --- /dev/null +++ b/app/utils/user-can-add.js @@ -0,0 +1,3 @@ +export default function userCanAdd(role) { + return (role === 'W') || (role === 'A'); +} diff --git a/app/utils/user-can-edit.js b/app/utils/user-can-edit.js new file mode 100644 index 0000000..20146d5 --- /dev/null +++ b/app/utils/user-can-edit.js @@ -0,0 +1,5 @@ +export default function userCanEdit(currentUser, author) { + let id = currentUser.id; + let role = currentUser.role; + return (role === 'W' && (+id === author)) || (role === 'A'); +} diff --git a/bower.json b/bower.json index 7eac921..f163a83 100644 --- a/bower.json +++ b/bower.json @@ -13,7 +13,7 @@ "loader.js": "ember-cli/loader.js#3.2.0", "qunit": "~1.17.1", "flakes": "~1.0.0", - "ember-simple-auth": "~0.8.0-beta.3", + "ember-simple-auth": "~0.8.0", "moment": "~2.9.0", "select2": "3.5.2", "antiscroll": "git://github.com/azirbel/antiscroll.git#90391fb371c7be769bc32e7287c5271981428356", diff --git a/config/environment.js b/config/environment.js index 78196ba..21b348a 100644 --- a/config/environment.js +++ b/config/environment.js @@ -16,8 +16,8 @@ module.exports = function(environment) { }, podModulePrefix: 'clostridiumdotinfo/pods', 'simple-auth': { - session: 'session:custom', authorizer: 'simple-auth-authorizer:token', + store: 'simple-auth-session-store:local-storage', }, 'simple-auth-token': { identificationField: 'email', @@ -34,32 +34,33 @@ module.exports = function(environment) { 'style-src': "'self' 'unsafe-inline'", 'media-src': "'self'" }, + flashMessageDefaults: { + sticky: true, + type: 'error', + types: ['error', 'warning', 'success', 'information', 'tip', 'message'], + }, }; + var apiURL; + if (environment === 'development') { - ENV['simple-auth']['crossOriginWhitelist'] = ['http://127.0.0.1:4200']; - ENV['simple-auth-token']['serverTokenEndpoint'] = '/api/authenticate'; - ENV.apiURL = 'http://127.0.0.1:4200'; - ENV.contentSecurityPolicy['connect-src'] = "'self' http://127.0.0.1:4200"; + apiURL = 'http://127.0.0.1:8901'; } if (environment === 'test') { - ENV['simple-auth']['crossOriginWhitelist'] = ['https://bactdb-test.herokuapp.com']; - ENV['simple-auth-token']['serverTokenEndpoint'] = 'https://bactdb-test.herokuapp.com/api/authenticate'; - ENV.apiURL = 'https://bactdb-test.herokuapp.com'; - ENV.contentSecurityPolicy['connect-src'] = "'self' https://bactdb-test.herokuapp.com"; - - // keep test console output quieter + apiURL = 'https://bactdb-test.herokuapp.com'; ENV.APP.LOG_ACTIVE_GENERATION = false; ENV.APP.LOG_VIEW_LOOKUPS = false; } if (environment === 'production') { - ENV['simple-auth']['crossOriginWhitelist'] = ['https://bactdb.herokuapp.com']; - ENV['simple-auth-token']['serverTokenEndpoint'] = 'https://bactdb.herokuapp.com/api/authenticate'; - ENV.apiURL = 'https://bactdb.herokuapp.com'; - ENV.contentSecurityPolicy['connect-src'] = "'self' https://bactdb.herokuapp.com"; + apiURL = 'https://bactdb.herokuapp.com'; } + ENV['simple-auth']['crossOriginWhitelist'] = [apiURL]; + ENV['simple-auth-token']['serverTokenEndpoint'] = apiURL + '/api/authenticate'; + ENV.apiURL = apiURL; + ENV.contentSecurityPolicy['connect-src'] = "'self' " + apiURL; + return ENV; }; diff --git a/package.json b/package.json index edb726a..dd728ff 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "author": "", "license": "MIT", "devDependencies": { - "body-parser": "^1.12.2", "broccoli-asset-rev": "^2.0.2", "ember-cli": "0.2.7", "ember-cli-app-version": "0.3.3", @@ -27,11 +26,12 @@ "ember-cli-content-security-policy": "0.4.0", "ember-cli-dependency-checker": "^1.0.0", "ember-cli-divshot": "^0.1.7", + "ember-cli-flash": "1.1.4", "ember-cli-htmlbars": "0.7.6", "ember-cli-ic-ajax": "0.1.1", "ember-cli-inject-live-reload": "^1.3.0", "ember-cli-qunit": "0.3.13", - "ember-cli-simple-auth": "^0.8.0-beta.3", + "ember-cli-simple-auth": "^0.8.0", "ember-cli-simple-auth-token": "^0.7.2", "ember-cli-uglify": "^1.0.1", "ember-data": "1.0.0-beta.18", @@ -39,9 +39,6 @@ "ember-export-application-global": "^1.0.2", "ember-select-2": "1.3.0", "ember-table": "0.5.0", - "express": "^4.12.4", - "glob": "^4.5.3", - "jsonwebtoken": "^5.0.0", - "morgan": "^1.6.0" + "glob": "^4.5.3" } } diff --git a/server/.jshintrc b/server/.jshintrc deleted file mode 100644 index c1f2978..0000000 --- a/server/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "node": true -} diff --git a/server/index.js b/server/index.js deleted file mode 100644 index 4bdb85a..0000000 --- a/server/index.js +++ /dev/null @@ -1,42 +0,0 @@ -// To use it create some files under `mocks/` -// e.g. `server/mocks/ember-hamsters.js` -// -// module.exports = function(app) { -// app.get('/ember-hamsters', function(req, res) { -// res.send('hello'); -// }); -// }; - -// http://stackoverflow.com/q/11001817 -var allowCrossDomain = function(req, res, next) { - res.header('Access-Control-Allow-Origin', '*'); - res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); - res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With'); - - // intercept OPTIONS method - if ('OPTIONS' == req.method) { - res.sendStatus(200); - } - else { - next(); - } -}; - -module.exports = function(app) { - var globSync = require('glob').sync; - var mocks = globSync('./mocks/**/*.js', { cwd: __dirname }).map(require); - var proxies = globSync('./proxies/**/*.js', { cwd: __dirname }).map(require); - - // Log proxy requests - var morgan = require('morgan'); - app.use(morgan('dev')); - app.use(allowCrossDomain); - - // Parse json - var bodyParser = require('body-parser'); - app.use(bodyParser.json()); - - mocks.forEach(function(route) { route(app); }); - proxies.forEach(function(route) { route(app); }); - -}; diff --git a/server/mocks/authenticate.js b/server/mocks/authenticate.js deleted file mode 100644 index 0a6a8b8..0000000 --- a/server/mocks/authenticate.js +++ /dev/null @@ -1,66 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var jwt = require('jsonwebtoken'); - var authenticateRouter = express.Router(); - - var USERS = [ - { - id: 1, - email: 'testA', - name: 'Test Admin User', - role: 'A', - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null - }, - { - id: 2, - email: 'testR', - name: 'Test Read User', - role: 'R', - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null - }, - { - id: 3, - email: 'testW', - name: 'Test Write User', - role: 'W', - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null - } - ] - - authenticateRouter.post('/', function(req, res) { - // wait for a bit to simulate cold boot of heroku api - var ms = 3000 + new Date().getTime(); - while (new Date() < ms){} - - if ((req.body.email === 'testA' || req.body.email === 'testR' || req.body.email === 'testW' ) - && req.body.password === 'test') { - var user = USERS.filter(function(u) { - if (u.email == req.body.email) { - return u; - } - })[0]; - var token = jwt.sign({ - 'name': user.name, - 'role': user.role - }, 'secret', - { - expiresInMinutes: 60, - issuer: 'bactdb', - subject: user.id, - }); - res.send({ - 'token': token - }); - } else { - res.status(401).send({'error':'Invalid username or password'}); - } - }); - - app.use('/api/authenticate', authenticateRouter); -}; diff --git a/server/mocks/characteristic-types.js b/server/mocks/characteristic-types.js deleted file mode 100644 index 15405ef..0000000 --- a/server/mocks/characteristic-types.js +++ /dev/null @@ -1,81 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var characteristicTypesRouter = express.Router(); - - var CHARACTERISTIC_TYPES = [ - { - id: 1, - characteristicTypeName: 'Type 1', - characteristics: [1,4], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - { - id: 2, - characteristicTypeName: 'Type 2', - characteristics: [2,5], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - { - id: 3, - characteristicTypeName: 'Type 3', - characteristics: [3], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - ] - - characteristicTypesRouter.get('/', function(req, res) { - var characteristics; - if (req.query.ids) { - characteristic_types = CHARACTERISTIC_TYPES.filter(function(c) { - return req.query.ids.indexOf(c.id.toString()) > -1; - }); - } else { - characteristic_types = CHARACTERISTIC_TYPES; - } - res.send({ - 'characteristicTypes': characteristic_types - }); - }); - - characteristicTypesRouter.post('/', function(req, res) { - res.status(201).end(); - }); - - characteristicTypesRouter.get('/:id', function(req, res) { - var characteristic_type = CHARACTERISTIC_TYPES.filter(function(c) { - return c.id == req.params.id; - }); - res.send({ - 'characteristicType': characteristic_type - }); - }); - - characteristicTypesRouter.put('/:id', function(req, res) { - res.send({ - 'characteristicTypes': { - id: req.params.id - } - }); - }); - - characteristicTypesRouter.delete('/:id', function(req, res) { - res.status(204).end(); - }); - - app.use('/api/clostridium/characteristicTypes', characteristicTypesRouter); -}; diff --git a/server/mocks/characteristics.js b/server/mocks/characteristics.js deleted file mode 100644 index 170e6b9..0000000 --- a/server/mocks/characteristics.js +++ /dev/null @@ -1,113 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var characteristicsRouter = express.Router(); - - var CHARACTERISTICS = [ - { - id: 1, - characteristicName: 'α-fucosidase (API ZYM)', - characteristicType: 1, - strains: [1,2], - measurements: [1,6], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - { - id: 2, - characteristicName: 'α-glucosidase', - characteristicType: 2, - strains: [1,2], - measurements: [2,7], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - { - id: 3, - characteristicName: 'Chloramphenicol', - characteristicType: 3, - strains: [1,2], - measurements: [3,8], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - { - id: 4, - characteristicName: 'Bacitracin', - characteristicType: 1, - strains: [1,2], - measurements: [4,9], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - }, - { - id: 5, - characteristicName: 'Indole', - characteristicType: 2, - strains: [1,2], - measurements: [5,10], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null - } - ] - - characteristicsRouter.get('/', function(req, res) { - var characteristics; - if (req.query.ids) { - characteristics = CHARACTERISTICS.filter(function(c) { - return req.query.ids.indexOf(c.id.toString()) > -1; - }); - } else { - characteristics = CHARACTERISTICS; - } - res.send({ - 'characteristics': characteristics - }); - }); - - characteristicsRouter.post('/', function(req, res) { - res.status(201).end(); - }); - - characteristicsRouter.get('/:id', function(req, res) { - var characteristic = CHARACTERISTICS.filter(function(c) { - return c.id == req.params.id; - }); - res.send({ - 'characteristic': characteristic - }); - }); - - characteristicsRouter.put('/:id', function(req, res) { - res.send({ - 'characteristics': { - id: req.params.id - } - }); - }); - - characteristicsRouter.delete('/:id', function(req, res) { - res.status(204).end(); - }); - - app.use('/api/clostridium/characteristics', characteristicsRouter); -}; diff --git a/server/mocks/measurements.js b/server/mocks/measurements.js deleted file mode 100644 index 64d4428..0000000 --- a/server/mocks/measurements.js +++ /dev/null @@ -1,209 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var measurementsRouter = express.Router(); - - var MEASUREMENTS = [ - { - id: 1, - strain: 1, - characteristic: 1, - textMeasurementType: 'Meas. Type 1', - txtValue: null, - numValue: null, - confidenceInterval: null, - unitType: null, - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 2, - strain: 1, - characteristic: 2, - textMeasurementType: 'Meas. Type 1', - txtValue: null, - numValue: null, - confidenceInterval: null, - unitType: null, - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 3, - strain: 1, - characteristic: 3, - textMeasurementType: null, - txtValue: "text value", - numValue: null, - confidenceInterval: null, - unitType: null, - notes: "some notes", - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 4, - strain: 1, - characteristic: 4, - textMeasurementType: null, - txtValue: null, - numValue: 123.4, - confidenceInterval: null, - unitType: 'Unit 1', - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 5, - strain: 1, - characteristic: 5, - textMeasurementType: null, - txtValue: null, - numValue: 567.8, - confidenceInterval: 0.2, - unitType: 'Unit 1', - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 6, - strain: 2, - characteristic: 1, - textMeasurementType: 'Meas. Type 1', - txtValue: null, - numValue: null, - confidenceInterval: null, - unitType: null, - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 7, - strain: 2, - characteristic: 2, - textMeasurementType: 'Meas. Type 1', - txtValue: null, - numValue: null, - confidenceInterval: null, - unitType: null, - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 8, - strain: 2, - characteristic: 3, - textMeasurementType: null, - txtValue: "text value", - numValue: null, - confidenceInterval: null, - unitType: null, - notes: "some notes", - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 9, - strain: 2, - characteristic: 4, - textMeasurementType: null, - txtValue: null, - numValue: 123.4, - confidenceInterval: null, - unitType: 'Unit 1', - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - }, - { - id: 10, - strain: 2, - characteristic: 5, - textMeasurementType: null, - txtValue: null, - numValue: 567.8, - confidenceInterval: 0.2, - unitType: 'Unit 1', - notes: null, - testMethod: null, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - createdBy: 1, - updatedBy: 1 - } - ] - - measurementsRouter.get('/', function(req, res) { - var measurements; - if (req.query.ids) { - measurements = MEASUREMENTS.filter(function(m) { - return req.query.ids.indexOf(m.id.toString()) > -1; - }); - } else { - measurements = MEASUREMENTS; - } - res.send({ - 'measurements': measurements - }); - }); - - measurementsRouter.post('/', function(req, res) { - res.status(201).end(); - }); - - measurementsRouter.get('/:id', function(req, res) { - var measurements = MEASUREMENTS.filter(function(m) { - return m.id == req.params.id; - }); - res.send({ - 'measurement': measurements - }); - }); - - measurementsRouter.put('/:id', function(req, res) { - var measurements = MEASUREMENTS.filter(function(m) { - return m.id == req.params.id; - }); - res.send({ - 'measurement': measurements[0] - }); - }); - - measurementsRouter.delete('/:id', function(req, res) { - res.status(204).end(); - }); - - app.use('/api/clostridium/measurements', measurementsRouter); -}; diff --git a/server/mocks/species.js b/server/mocks/species.js deleted file mode 100644 index 59ff57b..0000000 --- a/server/mocks/species.js +++ /dev/null @@ -1,105 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var speciesRouter = express.Router(); - - var SPECIES = [ - { - id: 1, - genusName: "Clostridium", - speciesName: "One", - typeSpecies: true, - etymology: "Test Etymology", - strains: [1,2], - totalStrains: 1, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null, - }, - { - id: 2, - genusName: "Clostridium", - speciesName: "Two", - typeSpecies: true, - etymology: "Test Etymology", - strains: [3], - totalStrains: 1, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null, - }, - { - id: 3, - genusName: "Clostridium", - speciesName: "Three", - typeSpecies: true, - etymology: "Test Etymology", - strains: [4], - totalStrains: 1, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null, - }, - { - id: 4, - genusName: "Clostridium", - speciesName: "Four", - typeSpecies: true, - etymology: "Test Etymology", - strains: [4], - totalStrains: 1, - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null, - } - ]; - - speciesRouter.get('/', function(req, res) { - var species; - if (req.query.ids) { - species = SPECIES.filter(function(s) { - return req.query.ids.indexOf(s.id.toString()) > -1; - }); - } else { - species = SPECIES; - } - res.send({ - 'species': species - }); - }); - - speciesRouter.post('/', function(req, res) { - req.body.species.id = Math.max.apply(Math, SPECIES.map(function(o){return o.id;})) + 1; - res.status(201).send(req.body); - }); - - speciesRouter.get('/:id', function(req, res) { - var species = SPECIES.filter(function(s) { - return s.id == req.params.id; - }); - res.send({ - 'species': species[0] - }); - }); - - speciesRouter.put('/:id', function(req, res) { - res.send(req.body); - }); - - speciesRouter.delete('/:id', function(req, res) { - res.status(204).end(); - }); - - app.use('/api/clostridium/species', speciesRouter); -}; diff --git a/server/mocks/strains.js b/server/mocks/strains.js deleted file mode 100644 index 0349cc3..0000000 --- a/server/mocks/strains.js +++ /dev/null @@ -1,130 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var strainsRouter = express.Router(); - - var STRAINS = [ - { - id: 1, - species: 1, - strainName: "ABC", - typeStrain: true, - accessionNumbers: "Test Accession", - genbank: "Test Genbank", - isolatedFrom: "Location 1", - measurements: [1,2,3,4,5], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null, - totalMeasurements: 5, - notes: "Test notes", - }, - { - id: 2, - species: 1, - strainName: "XYZ", - typeStrain: false, - accessionNumbers: "Test Accession", - genbank: "Test Genbank", - isolatedFrom: "Location 2", - measurements: [6,7,8,9,10], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 3, - updatedBy: 3, - deletedBy: null, - totalMeasurements: 5, - notes: "Test notes", - }, - { - id: 3, - species: 2, - strainName: "QRS", - typeStrain: true, - accessionNumbers: "Test Accession", - genbank: "Test Genbank", - isolatedFrom: "Location 1", - measurements: [], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 1, - updatedBy: 1, - deletedBy: null, - totalMeasurements: 0, - notes: "Test notes", - }, - { - id: 4, - species: 3, - strainName: "LMN", - typeStrain: true, - accessionNumbers: "Test Accession", - genbank: "Test Genbank", - isolatedFrom: "Location 2", - measurements: [], - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null, - createdBy: 3, - updatedBy: 3, - deletedBy: null, - totalMeasurements: 0, - notes: "Test notes", - } - ]; - - strainsRouter.get('/', function(req, res) { - var strains; - if (req.query.ids) { - strains = STRAINS.filter(function(s) { - return req.query.ids.indexOf(s.id.toString()) > -1; - }); - } else { - strains = STRAINS; - } - res.send({ - 'strains': strains - }); - }); - - strainsRouter.post('/', function(req, res) { - req.body.strain.id = Math.max.apply(Math, STRAINS.map(function(o){return o.id;})) + 1; - res.status(201).send(req.body); - }); - - strainsRouter.get('/:id', function(req, res) { - var strains = STRAINS.filter(function(s) { - return s.id == req.params.id; - }); - res.send({ - 'strain': strains[0] - }); - }); - - strainsRouter.put('/:id', function(req, res) { - var strains = STRAINS.filter(function(s) { - return s.id == req.params.id; - }); - if (strains.length === 0) { - res.status(422).send({ - 'errors':{ - "strainName": ["error1"], - "typeStrain": ["error2", "error3"], - "isolatedFrom": ["error4"] - } - }).end(); - } else { - res.status(204).end(); - } - }); - - strainsRouter.delete('/:id', function(req, res) { - res.status(204).end(); - }); - - app.use('/api/clostridium/strains', strainsRouter); -}; diff --git a/server/mocks/users.js b/server/mocks/users.js deleted file mode 100644 index a01f5a8..0000000 --- a/server/mocks/users.js +++ /dev/null @@ -1,75 +0,0 @@ -module.exports = function(app) { - var express = require('express'); - var usersRouter = express.Router(); - - var USERS = [ - { - id: 1, - email: 'testA', - name: 'Test Admin User', - role: 'A', - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null - }, - { - id: 2, - email: 'testR', - name: 'Test Read User', - role: 'R', - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null - }, - { - id: 3, - email: 'testW', - name: 'Test Write User', - role: 'W', - createdAt: "0001-01-01T00:00:00Z", - updatedAt: "0001-01-01T00:00:00Z", - deletedAt: null - } - ] - - usersRouter.get('/', function(req, res) { - var users; - if (req.query.ids) { - users = USERS.filter(function(u) { - return req.query.ids.indexOf(u.id.toString()) > -1; - }); - } else { - users = USERS; - } - res.send({ - 'users': users - }); - }); - - usersRouter.post('/', function(req, res) { - res.status(201).end(); - }); - - usersRouter.get('/:id', function(req, res) { - var user = USERS.filter(function(u) { - return u.id == req.params.id; - }); - res.send({ - 'user': user - }); - }); - - usersRouter.put('/:id', function(req, res) { - res.send({ - 'users': { - id: req.params.id - } - }); - }); - - usersRouter.delete('/:id', function(req, res) { - res.status(204).end(); - }); - - app.use('/api/users', usersRouter); -}; diff --git a/tests/helpers/flash-message.js b/tests/helpers/flash-message.js new file mode 100644 index 0000000..1acf2cf --- /dev/null +++ b/tests/helpers/flash-message.js @@ -0,0 +1,3 @@ +import FlashObject from 'ember-cli-flash/flash/object'; + +FlashObject.reopen({ _destroyLater: null }); diff --git a/tests/test-helper.js b/tests/test-helper.js index e6cfb70..0b009b7 100644 --- a/tests/test-helper.js +++ b/tests/test-helper.js @@ -1,4 +1,6 @@ import resolver from './helpers/resolver'; +import flashMessageHelper from './helpers/flash-message'; + import { setResolver } from 'ember-qunit'; diff --git a/tests/unit/controllers/characteristics/index-test.js b/tests/unit/controllers/characteristics/index-test.js deleted file mode 100644 index d538d93..0000000 --- a/tests/unit/controllers/characteristics/index-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:characteristics/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -}); diff --git a/tests/unit/controllers/measurements/index-test.js b/tests/unit/controllers/measurements/index-test.js deleted file mode 100644 index a5ea689..0000000 --- a/tests/unit/controllers/measurements/index-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:measurements/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -}); diff --git a/tests/unit/controllers/sortable-test.js b/tests/unit/controllers/sortable-test.js deleted file mode 100644 index 92e3747..0000000 --- a/tests/unit/controllers/sortable-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:sortable', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -}); diff --git a/tests/unit/controllers/strains/index-test.js b/tests/unit/controllers/strains/index-test.js deleted file mode 100644 index 59cba90..0000000 --- a/tests/unit/controllers/strains/index-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:strains/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -}); diff --git a/tests/unit/pods/compare/controller-test.js b/tests/unit/pods/compare/controller-test.js deleted file mode 100644 index c34abc7..0000000 --- a/tests/unit/pods/compare/controller-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:compare', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -}); diff --git a/tests/unit/pods/compare/route-test.js b/tests/unit/pods/compare/route-test.js deleted file mode 100644 index c940264..0000000 --- a/tests/unit/pods/compare/route-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('route:compare', 'Unit | Route | compare', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/pods/components/add-button/component-test.js b/tests/unit/pods/components/add-button/component-test.js deleted file mode 100644 index 2cfd8fc..0000000 --- a/tests/unit/pods/components/add-button/component-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('add-button', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/characteristic-index-row/component-test.js b/tests/unit/pods/components/characteristic-index-row/component-test.js deleted file mode 100644 index 0964cf7..0000000 --- a/tests/unit/pods/components/characteristic-index-row/component-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('characteristic-index-row', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/genbank-url/component-test.js b/tests/unit/pods/components/genbank-url/component-test.js deleted file mode 100644 index 753b583..0000000 --- a/tests/unit/pods/components/genbank-url/component-test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; - -moduleForComponent('genbank-url', 'Unit | Component | genbank url', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'], - unit: true -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/loading-panel/component-test.js b/tests/unit/pods/components/loading-panel/component-test.js deleted file mode 100644 index 6be90f0..0000000 --- a/tests/unit/pods/components/loading-panel/component-test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; - -moduleForComponent('loading-panel', 'Unit | Component | loading panel', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'], - unit: true -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/measurement-search-panel/component-test.js b/tests/unit/pods/components/measurement-search-panel/component-test.js deleted file mode 100644 index 88b1a89..0000000 --- a/tests/unit/pods/components/measurement-search-panel/component-test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; - -moduleForComponent('measurement-search-panel', 'Unit | Component | measurement search panel', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'], - unit: true -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/search-button/component-test.js b/tests/unit/pods/components/search-button/component-test.js deleted file mode 100644 index 6381186..0000000 --- a/tests/unit/pods/components/search-button/component-test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; - -moduleForComponent('search-button', 'Unit | Component | search button', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'], - unit: true -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/site-name/component-test.js b/tests/unit/pods/components/site-name/component-test.js deleted file mode 100644 index 2c5861f..0000000 --- a/tests/unit/pods/components/site-name/component-test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { moduleForComponent, test } from 'ember-qunit'; - -moduleForComponent('site-name', 'Unit | Component | site name', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'], - unit: true -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/sortable-table-header/component-test.js b/tests/unit/pods/components/sortable-table-header/component-test.js deleted file mode 100644 index adb3489..0000000 --- a/tests/unit/pods/components/sortable-table-header/component-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('sortable-table-header', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/sortable-table/component-test.js b/tests/unit/pods/components/sortable-table/component-test.js deleted file mode 100644 index 2d888ff..0000000 --- a/tests/unit/pods/components/sortable-table/component-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('sortable-table', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/species-index-row/component-test.js b/tests/unit/pods/components/species-index-row/component-test.js deleted file mode 100644 index 2b6b389..0000000 --- a/tests/unit/pods/components/species-index-row/component-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('species-index-row', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/components/strain-index-row/component-test.js b/tests/unit/pods/components/strain-index-row/component-test.js deleted file mode 100644 index 819c0e9..0000000 --- a/tests/unit/pods/components/strain-index-row/component-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { - moduleForComponent, - test -} from 'ember-qunit'; - -moduleForComponent('strain-index-row', { - // Specify the other units that are required for this test - // needs: ['component:foo', 'helper:bar'] -}); - -test('it renders', function(assert) { - assert.expect(2); - - // Creates the component instance - var component = this.subject(); - assert.equal(component._state, 'preRender'); - - // Renders the component to the page - this.render(); - assert.equal(component._state, 'inDOM'); -}); diff --git a/tests/unit/pods/loading/route-test.js b/tests/unit/pods/loading/route-test.js deleted file mode 100644 index e81a0d4..0000000 --- a/tests/unit/pods/loading/route-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('route:loading', 'Unit | Route | loading', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/pods/measurements/controller-test.js b/tests/unit/pods/measurements/controller-test.js deleted file mode 100644 index f20328f..0000000 --- a/tests/unit/pods/measurements/controller-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:measurements', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -}); diff --git a/tests/unit/pods/measurements/route-test.js b/tests/unit/pods/measurements/route-test.js deleted file mode 100644 index 74e119e..0000000 --- a/tests/unit/pods/measurements/route-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('route:measurements', 'Unit | Route | measurements', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/characteristics-test.js b/tests/unit/routes/characteristics-test.js deleted file mode 100644 index 954cf6d..0000000 --- a/tests/unit/routes/characteristics-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:characteristics', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/characteristics/index-test.js b/tests/unit/routes/characteristics/index-test.js deleted file mode 100644 index 5d4da1e..0000000 --- a/tests/unit/routes/characteristics/index-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:characteristics/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/measurements-test.js b/tests/unit/routes/measurements-test.js deleted file mode 100644 index 53395b7..0000000 --- a/tests/unit/routes/measurements-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:measurements', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/measurements/index-test.js b/tests/unit/routes/measurements/index-test.js deleted file mode 100644 index ce045c0..0000000 --- a/tests/unit/routes/measurements/index-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:measurements/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/species-test.js b/tests/unit/routes/species-test.js deleted file mode 100644 index ed7e7ba..0000000 --- a/tests/unit/routes/species-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:species', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/species/index-test.js b/tests/unit/routes/species/index-test.js deleted file mode 100644 index 4e751cd..0000000 --- a/tests/unit/routes/species/index-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:species/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/species/new-test.js b/tests/unit/routes/species/new-test.js deleted file mode 100644 index 1c7fab4..0000000 --- a/tests/unit/routes/species/new-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:species/new', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/species/show-test.js b/tests/unit/routes/species/show-test.js deleted file mode 100644 index d6ad3b2..0000000 --- a/tests/unit/routes/species/show-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:species/show', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/strains-test.js b/tests/unit/routes/strains-test.js deleted file mode 100644 index 76f9e94..0000000 --- a/tests/unit/routes/strains-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:strains', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/strains/index-test.js b/tests/unit/routes/strains/index-test.js deleted file mode 100644 index f32db19..0000000 --- a/tests/unit/routes/strains/index-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:strains/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/strains/new-test.js b/tests/unit/routes/strains/new-test.js deleted file mode 100644 index d865650..0000000 --- a/tests/unit/routes/strains/new-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:strains/new', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/strains/show-test.js b/tests/unit/routes/strains/show-test.js deleted file mode 100644 index 9407c3a..0000000 --- a/tests/unit/routes/strains/show-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:strains/show', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/users-test.js b/tests/unit/routes/users-test.js deleted file mode 100644 index 843f9ae..0000000 --- a/tests/unit/routes/users-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:users', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/routes/users/index-test.js b/tests/unit/routes/users/index-test.js deleted file mode 100644 index 86efdaf..0000000 --- a/tests/unit/routes/users/index-test.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('route:users/index', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -test('it exists', function(assert) { - var route = this.subject(); - assert.ok(route); -}); diff --git a/tests/unit/helpers/get-property-test.js b/tests/unit/utils/parse-base64-test.js similarity index 51% rename from tests/unit/helpers/get-property-test.js rename to tests/unit/utils/parse-base64-test.js index 25955ae..c0387b4 100644 --- a/tests/unit/helpers/get-property-test.js +++ b/tests/unit/utils/parse-base64-test.js @@ -1,10 +1,10 @@ -import { getProperty } from '../../../helpers/get-property'; +import parseBase64 from '../../../utils/parse-base64'; import { module, test } from 'qunit'; -module('Unit | Helper | get property'); +module('Unit | Utility | parse base64'); // Replace this with your real tests. test('it works', function(assert) { - var result = getProperty(42); + var result = parseBase64(); assert.ok(result); }); diff --git a/tests/unit/utils/user-can-add-test.js b/tests/unit/utils/user-can-add-test.js new file mode 100644 index 0000000..d94174e --- /dev/null +++ b/tests/unit/utils/user-can-add-test.js @@ -0,0 +1,10 @@ +import userCanAdd from '../../../utils/user-can-add'; +import { module, test } from 'qunit'; + +module('Unit | Utility | user can add'); + +// Replace this with your real tests. +test('it works', function(assert) { + var result = userCanAdd(); + assert.ok(result); +}); diff --git a/tests/unit/utils/user-can-edit-test.js b/tests/unit/utils/user-can-edit-test.js new file mode 100644 index 0000000..a14b4da --- /dev/null +++ b/tests/unit/utils/user-can-edit-test.js @@ -0,0 +1,10 @@ +import userCanEdit from '../../../utils/user-can-edit'; +import { module, test } from 'qunit'; + +module('Unit | Utility | user can edit'); + +// Replace this with your real tests. +test('it works', function(assert) { + var result = userCanEdit(); + assert.ok(result); +}); diff --git a/tests/unit/views/application-test.js b/tests/unit/views/application-test.js deleted file mode 100644 index 87a9a92..0000000 --- a/tests/unit/views/application-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('view:application'); - -// Replace this with your real tests. -test('it exists', function(assert) { - var view = this.subject(); - assert.ok(view); -});