Merge branch 'master' into clostridium
* master: Add clickable to strains chars table Sort meas table in chars Fixes #33 Manually sort strains/chars Refresh token notes Linting
This commit is contained in:
commit
13f8c5afcc
15 changed files with 80 additions and 36 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
// Note: this is here for user lockout authentication
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import JwtTokenAuthenticator from 'simple-auth-token/authenticators/jwt';
|
import JwtTokenAuthenticator from 'simple-auth-token/authenticators/jwt';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import Ember from 'ember';
|
|
||||||
|
|
||||||
export function initialize(container, application) {
|
export function initialize(container, application) {
|
||||||
application.inject('session:custom', '_store', 'service:store');
|
application.inject('session:custom', '_store', 'service:store');
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Ember from 'ember';
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
actions: {
|
actions: {
|
||||||
delete: function() {
|
delete: function() {
|
||||||
this.get('model').destroyRecord()
|
this.get('model').destroyRecord();
|
||||||
this.transitionToRoute('protected.characteristics.index');
|
this.transitionToRoute('protected.characteristics.index');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,17 +5,27 @@ export default Ember.Component.extend({
|
||||||
return this.get('model.measurements.length') > 0;
|
return this.get('model.measurements.length') > 0;
|
||||||
}.property('model.measurements'),
|
}.property('model.measurements'),
|
||||||
|
|
||||||
// TODO: this is way more complicated than it should be
|
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
|
||||||
measurementsTable: function() {
|
sortAsc: true,
|
||||||
let measurements = this.get('model.measurements');
|
paramsChanged: false,
|
||||||
let table = [];
|
sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
|
||||||
measurements.forEach((measurement) => {
|
|
||||||
let row = {};
|
actions: {
|
||||||
row['measurement'] = measurement;
|
changeSortParam: function(col) {
|
||||||
row['strain'] = this.store.peekRecord('strain', measurement.get('strain.id'));
|
let sort = this.get('sortAsc') ? 'asc' : 'desc';
|
||||||
table.push(row);
|
let sortCol = `${col}:${sort}`;
|
||||||
});
|
this.set('sortParams', [sortCol]);
|
||||||
return table;
|
this.set('paramsChanged', true);
|
||||||
}.property(),
|
this.toggleProperty('sortAsc');
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
resetSortParam: function() {
|
||||||
|
this.set('sortParams', ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName']);
|
||||||
|
this.set('paramsChanged', false);
|
||||||
|
this.set('sortAsc', true);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
{{#if measurementsPresent}}
|
{{#if measurementsPresent}}
|
||||||
|
{{#if paramsChanged}}
|
||||||
|
<button class="button-gray smaller" {{action 'resetSortParam'}}>
|
||||||
|
Reset sort
|
||||||
|
</button>
|
||||||
|
{{/if}}
|
||||||
<table class="flakes-table">
|
<table class="flakes-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Strain</th>
|
<th {{action "changeSortParam" "strain.strainName"}} class="click">Strain</th>
|
||||||
<th>Value</th>
|
<th {{action "changeSortParam" "value"}} class="click">Value</th>
|
||||||
<th>Notes</th>
|
<th {{action "changeSortParam" "notes"}} class="click">Notes</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each measurementsTable as |row|}}
|
{{#each sortedMeasurements as |row|}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{#link-to 'protected.strains.show' row.strain.id}}
|
{{#link-to 'protected.strains.show' row.strain.id}}
|
||||||
|
@ -16,10 +21,10 @@
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{row.measurement.value}}
|
{{row.value}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{row.measurement.notes}}
|
{{row.notes}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
@ -36,6 +36,10 @@ export default Ember.Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
delete: function() {
|
delete: function() {
|
||||||
|
let char = this.get('row.characteristic');
|
||||||
|
if (char.get('isNew')) {
|
||||||
|
char.destroyRecord();
|
||||||
|
}
|
||||||
this.get('row').destroyRecord();
|
this.get('row').destroyRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{{#if isEditing}}
|
{{#if isEditing}}
|
||||||
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
{{
|
{{
|
||||||
select-2
|
select-2
|
||||||
|
@ -28,6 +29,9 @@
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
<td>
|
||||||
|
{{{row.characteristic.characteristicTypeName}}}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{#link-to 'protected.characteristics.show' row.characteristic.id}}
|
{{#link-to 'protected.characteristics.show' row.characteristic.id}}
|
||||||
{{{row.characteristic.characteristicName}}}
|
{{{row.characteristic.characteristicName}}}
|
||||||
|
|
|
@ -12,6 +12,8 @@ export default Ember.Component.extend({
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
|
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
|
||||||
|
sortAsc: true,
|
||||||
|
paramsChanged: false,
|
||||||
sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
|
sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -24,6 +26,22 @@ export default Ember.Component.extend({
|
||||||
});
|
});
|
||||||
this.get('model.measurements').addObject(m);
|
this.get('model.measurements').addObject(m);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changeSortParam: function(col) {
|
||||||
|
let sort = this.get('sortAsc') ? 'asc' : 'desc';
|
||||||
|
let sortCol = `${col}:${sort}`;
|
||||||
|
this.set('sortParams', [sortCol]);
|
||||||
|
this.set('paramsChanged', true);
|
||||||
|
this.toggleProperty('sortAsc');
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
resetSortParam: function() {
|
||||||
|
this.set('sortParams', ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName']);
|
||||||
|
this.set('paramsChanged', false);
|
||||||
|
this.set('sortAsc', true);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,24 +7,32 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if measurementsPresent}}
|
{{#if measurementsPresent}}
|
||||||
|
{{#if paramsChanged}}
|
||||||
|
<button class="button-gray smaller" {{action 'resetSortParam'}}>
|
||||||
|
Reset sort
|
||||||
|
</button>
|
||||||
|
{{/if}}
|
||||||
<table class="flakes-table">
|
<table class="flakes-table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
{{#if canEdit}}
|
{{#if canEdit}}
|
||||||
<col span="1" style="width:40%">
|
<col span="1" style="width:10%">
|
||||||
|
<col span="1" style="width:30%">
|
||||||
<col span="1" style="width:20%">
|
<col span="1" style="width:20%">
|
||||||
<col span="1" style="width:20%">
|
<col span="1" style="width:20%">
|
||||||
<col span="1" style="width:20%">
|
<col span="1" style="width:20%">
|
||||||
{{else}}
|
{{else}}
|
||||||
<col span="1" style="width:40%">
|
<col span="1" style="width:10%">
|
||||||
|
<col span="1" style="width:30%">
|
||||||
<col span="1" style="width:30%">
|
<col span="1" style="width:30%">
|
||||||
<col span="1" style="width:30%">
|
<col span="1" style="width:30%">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Characteristic</th>
|
<th {{action "changeSortParam" "characteristic.characteristicTypeName"}} class="click">Type</th>
|
||||||
<th>Value</th>
|
<th {{action "changeSortParam" "characteristic.characteristicName"}} class="click">Characteristic</th>
|
||||||
<th>Notes</th>
|
<th {{action "changeSortParam" "value"}} class="click">Value</th>
|
||||||
|
<th {{action "changeSortParam" "notes"}} class="click">Notes</th>
|
||||||
{{#if canEdit}}
|
{{#if canEdit}}
|
||||||
<th>Edit</th>
|
<th>Edit</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default Ember.Route.extend({
|
||||||
let user_id = transition.params['protected.users.edit'].user_id;
|
let user_id = transition.params['protected.users.edit'].user_id;
|
||||||
|
|
||||||
this.get('session.currentUser').then((user) => {
|
this.get('session.currentUser').then((user) => {
|
||||||
if (user.get('id') !== user_id || user.get('isAdmin')) {
|
if (user.get('id') !== user_id && !user.get('isAdmin')) {
|
||||||
this.transitionTo('protected.users.index');
|
this.transitionTo('protected.users.index');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,7 @@ export default Ember.Route.extend({
|
||||||
if (!currentUser.get('isAdmin') && currentUser.get('id') !== user_id) {
|
if (!currentUser.get('isAdmin') && currentUser.get('id') !== user_id) {
|
||||||
this.transitionTo('protected.users.index');
|
this.transitionTo('protected.users.index');
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
isAdmin: Ember.computed('currentUser', function() {
|
|
||||||
return this.get('currentUser.role') == 'A';
|
|
||||||
}),
|
|
||||||
|
|
||||||
roles: Ember.String.w('A R W'),
|
roles: Ember.String.w('A R W'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<div data-row-span="1">
|
<div data-row-span="1">
|
||||||
<div data-field-span="1">
|
<div data-field-span="1">
|
||||||
<label>Role</label>
|
<label>Role</label>
|
||||||
{{#if isAdmin}}
|
{{#if session.currentUser.isAdmin}}
|
||||||
<select onchange={{action (mut user.role) value="target.value"}}>
|
<select onchange={{action (mut user.role) value="target.value"}}>
|
||||||
{{#each roles as |roleChoice|}}
|
{{#each roles as |roleChoice|}}
|
||||||
<option value={{roleChoice}} selected={{equal user.role roleChoice}}>{{roleChoice}}</option>
|
<option value={{roleChoice}} selected={{equal user.role roleChoice}}>{{roleChoice}}</option>
|
||||||
|
|
|
@ -18,7 +18,7 @@ input[type="text"] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flakes-table thead tr th span {
|
.click {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ module.exports = function(environment) {
|
||||||
authorizationPrefix: 'Bearer ',
|
authorizationPrefix: 'Bearer ',
|
||||||
authorizationHeaderName: 'Authorization',
|
authorizationHeaderName: 'Authorization',
|
||||||
refreshAccessTokens: true,
|
refreshAccessTokens: true,
|
||||||
timeFactor: 1000,
|
timeFactor: 1000, // 1000 ms/s; JWT returned in unix time seconds
|
||||||
refreshLeeway: 300,
|
refreshLeeway: 1800, // (60 s/min) * (30 min) = 1800 s
|
||||||
},
|
},
|
||||||
contentSecurityPolicy: {
|
contentSecurityPolicy: {
|
||||||
'default-src': "'none'",
|
'default-src': "'none'",
|
||||||
|
|
Reference in a new issue