diff --git a/app/controllers/characteristics/index.js b/app/controllers/characteristics/index.js new file mode 100644 index 0000000..f94b49b --- /dev/null +++ b/app/controllers/characteristics/index.js @@ -0,0 +1,5 @@ +import SortableController from '../sortable'; + +export default SortableController.extend({ + sortBy: 'characteristicName', +}); diff --git a/app/models/characteristic.js b/app/models/characteristic.js new file mode 100644 index 0000000..9eb46ce --- /dev/null +++ b/app/models/characteristic.js @@ -0,0 +1,11 @@ +import DS from 'ember-data'; + +export default DS.Model.extend({ + characteristicName: DS.attr('string'), + characteristicType: DS.attr('string'), + strains: DS.hasMany('strain'), + measurements: DS.hasMany('measurements'), + createdAt: DS.attr('date'), + updatedAt: DS.attr('date'), + deletedAt: DS.attr('date') +}); diff --git a/app/router.js b/app/router.js index 9a11680..332bd1e 100644 --- a/app/router.js +++ b/app/router.js @@ -13,6 +13,7 @@ Router.map(function() { this.resource('measurements', function() {}); }); }); + this.resource('characteristics', function() {}); }); export default Router; diff --git a/app/routes/characteristics.js b/app/routes/characteristics.js new file mode 100644 index 0000000..5b14286 --- /dev/null +++ b/app/routes/characteristics.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/routes/characteristics/index.js b/app/routes/characteristics/index.js new file mode 100644 index 0000000..348187c --- /dev/null +++ b/app/routes/characteristics/index.js @@ -0,0 +1,7 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + model: function() { + return this.store.findAll('characteristic'); + } +}); diff --git a/app/templates/application.hbs b/app/templates/application.hbs index 37e6b90..5c84d01 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -6,6 +6,9 @@ {{#link-to 'strains' tagName='li' href=false}} {{#link-to 'strains'}}Strains{{/link-to}} {{/link-to}} + {{#link-to 'characteristics' tagName='li' href=false}} + {{#link-to 'characteristics'}}Characteristics{{/link-to}} + {{/link-to}} {{#link-to 'about' tagName='li' href=false}} {{#link-to 'about'}}About{{/link-to}} {{/link-to}} diff --git a/app/templates/characteristics.hbs b/app/templates/characteristics.hbs new file mode 100644 index 0000000..c24cd68 --- /dev/null +++ b/app/templates/characteristics.hbs @@ -0,0 +1 @@ +{{outlet}} diff --git a/app/templates/characteristics/index.hbs b/app/templates/characteristics/index.hbs new file mode 100644 index 0000000..b882ae1 --- /dev/null +++ b/app/templates/characteristics/index.hbs @@ -0,0 +1,19 @@ +

Hymenobacter Characteristics

+

Total characteristics: {{controller.length}}

+ + + + + + + + + + {{#each characteristic in controller}} + + + + + {{/each}} + +
NameType
{{characteristic.characteristicName}}{{characteristic.characteristicType}}
diff --git a/server/mocks/characteristics.js b/server/mocks/characteristics.js new file mode 100644 index 0000000..d6e3813 --- /dev/null +++ b/server/mocks/characteristics.js @@ -0,0 +1,78 @@ +module.exports = function(app) { + var express = require('express'); + var characteristicsRouter = express.Router(); + + var CHARACTERISTICS = [ + { + id: 1, + characteristicName: 'α-fucosidase (API ZYM)', + characteristicType: 'Type 1', + strains: [1], + measurements: [1], + createdAt: "0001-01-01T00:00:00Z", + updatedAt: "0001-01-01T00:00:00Z", + deletedAt: null + }, + { + id: 2, + characteristicName: 'α-glucosidase', + characteristicType: 'Type 2', + strains: [1], + measurements: [2], + createdAt: "0001-01-01T00:00:00Z", + updatedAt: "0001-01-01T00:00:00Z", + deletedAt: null + }, + { + id: 3, + characteristicName: 'Chloramphenicol', + characteristicType: 'Type 3', + strains: [1], + measurements: [3], + createdAt: "0001-01-01T00:00:00Z", + updatedAt: "0001-01-01T00:00:00Z", + deletedAt: 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/hymenobacter/characteristics', characteristicsRouter); +}; diff --git a/tests/unit/controllers/characteristics/index-test.js b/tests/unit/controllers/characteristics/index-test.js new file mode 100644 index 0000000..d538d93 --- /dev/null +++ b/tests/unit/controllers/characteristics/index-test.js @@ -0,0 +1,15 @@ +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/models/characteristic-test.js b/tests/unit/models/characteristic-test.js new file mode 100644 index 0000000..6445fbb --- /dev/null +++ b/tests/unit/models/characteristic-test.js @@ -0,0 +1,15 @@ +import { + moduleForModel, + test +} from 'ember-qunit'; + +moduleForModel('characteristic', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('it exists', function(assert) { + var model = this.subject(); + // var store = this.store(); + assert.ok(!!model); +}); diff --git a/tests/unit/routes/characteristics-test.js b/tests/unit/routes/characteristics-test.js new file mode 100644 index 0000000..954cf6d --- /dev/null +++ b/tests/unit/routes/characteristics-test.js @@ -0,0 +1,14 @@ +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 new file mode 100644 index 0000000..5d4da1e --- /dev/null +++ b/tests/unit/routes/characteristics/index-test.js @@ -0,0 +1,14 @@ +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); +});