protected route
This commit is contained in:
parent
72c957f8dc
commit
eb1a8bb6e3
41 changed files with 56 additions and 43 deletions
50
app/pods/protected/measurements/controller.js
Normal file
50
app/pods/protected/measurements/controller.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import Ember from 'ember';
|
||||
import ColumnDefinition from 'ember-table/models/column-definition';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
measurements: [],
|
||||
|
||||
measurementsEmpty: function() {
|
||||
return this.get('measurements').length === 0;
|
||||
}.property('measurements'),
|
||||
|
||||
tableColumns: Ember.computed(function() {
|
||||
let strainCol = ColumnDefinition.create({
|
||||
savedWidth: 200,
|
||||
textAlign: 'text-align-left',
|
||||
headerCellName: 'Strain',
|
||||
contentPath: 'strain.fullNameMU',
|
||||
});
|
||||
|
||||
let charCol = ColumnDefinition.create({
|
||||
savedWidth: 200,
|
||||
textAlign: 'text-align-left',
|
||||
headerCellName: 'Characteristic',
|
||||
contentPath: 'characteristic.characteristicName',
|
||||
});
|
||||
|
||||
let valCol = ColumnDefinition.create({
|
||||
savedWidth: 150,
|
||||
textAlign: 'text-align-left',
|
||||
headerCellName: 'Value',
|
||||
contentPath: 'value',
|
||||
});
|
||||
|
||||
return [strainCol, charCol, valCol];
|
||||
}),
|
||||
|
||||
tableContent: Ember.computed('measurements', function() {
|
||||
return this.get('measurements');
|
||||
}),
|
||||
|
||||
actions: {
|
||||
search: function(selectedStrains, selectedCharacteristics) {
|
||||
this.store.find('measurement', {
|
||||
strain: selectedStrains,
|
||||
characteristic: selectedCharacteristics,
|
||||
}).then((measurements)=>{
|
||||
this.set('measurements', measurements);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
8
app/pods/protected/measurements/route.js
Normal file
8
app/pods/protected/measurements/route.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function() {
|
||||
return this.store.findAll('measurement');
|
||||
},
|
||||
});
|
21
app/pods/protected/measurements/template.hbs
Normal file
21
app/pods/protected/measurements/template.hbs
Normal file
|
@ -0,0 +1,21 @@
|
|||
<h2>{{genus-name}} Measurements</h2>
|
||||
|
||||
{{measurement-search-panel search='search' strainLabel='All strains' charLabel='All characteristics'}}
|
||||
|
||||
<div class="grid-12 gutter-50">
|
||||
<div class="span-12">
|
||||
<h3>Total matching measurements: {{measurements.length}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if measurementsEmpty}}
|
||||
<span>No results</span>
|
||||
{{else}}
|
||||
{{
|
||||
ember-table
|
||||
columns=tableColumns
|
||||
content=tableContent
|
||||
columnMode='fluid'
|
||||
hasFooter=false
|
||||
}}
|
||||
{{/if}}
|
Reference in a new issue