Skip to content

Commit

Permalink
Merge pull request #3607 from hashicorp/f-ui-modify-time-over-modify-…
Browse files Browse the repository at this point in the history
…index

UI Use ModifyTime instead of ModifyIndex in allocation lists
  • Loading branch information
DingoEatingFuzz authored Dec 7, 2017
2 parents dfb95fd + e982951 commit a78a2e3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions ui/app/models/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default Model.extend({
taskGroupName: attr('string'),
resources: fragment('resources'),
modifyIndex: attr('number'),
modifyTime: attr('date'),
jobVersion: attr('number'),

// TEMPORARY: https://github.com/emberjs/data/issues/5209
Expand Down
3 changes: 3 additions & 0 deletions ui/app/serializers/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default ApplicationSerializer.extend({
// TEMPORARY: https://github.com/emberjs/data/issues/5209
hash.OriginalJobId = hash.JobID;

hash.ModifyTimeNanos = hash.ModifyTime % 1000000;
hash.ModifyTime = Math.floor(hash.ModifyTime / 1000000);

return this._super(typeHash, hash);
},
});
2 changes: 1 addition & 1 deletion ui/app/serializers/task-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default ApplicationSerializer.extend({
// only understand time to the millisecond precision. So store
// the time (precise to ms) as a date, and store the remaining ns
// as a number to deal with when it comes up.
hash.Time = Math.floor(hash.Time / 1000000);
hash.TimeNanos = hash.Time % 1000000;
hash.Time = Math.floor(hash.Time / 1000000);

return this._super(typeHash, hash);
},
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/allocation-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{allocation.shortId}}
{{/link-to}}
</td>
<td>{{allocation.modifyIndex}}</td>
<td>{{moment-format allocation.modifyTime "MM/DD HH:mm:ss"}}</td>
<td>{{allocation.name}}</td>
<td>
<span class="color-swatch {{allocation.clientStatus}}" /> {{allocation.clientStatus}}
Expand Down
3 changes: 3 additions & 0 deletions ui/mirage/factories/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { provide, pickOne } from '../utils';
const UUIDS = provide(100, faker.random.uuid.bind(faker.random));
const CLIENT_STATUSES = ['pending', 'running', 'complete', 'failed', 'lost'];
const DESIRED_STATUSES = ['run', 'stop', 'evict'];
const REF_TIME = new Date();

export default Factory.extend({
id: i => (i >= 100 ? `${UUIDS[i % 100]}-${i}` : UUIDS[i]),

modifyIndex: () => faker.random.number({ min: 10, max: 2000 }),
jobVersion: () => faker.random.number(10),

modifyTime: () => faker.date.past(2 / 365, REF_TIME) * 1000000,

clientStatus: faker.list.random(...CLIENT_STATUSES),
desiredStatus: faker.list.random(...DESIRED_STATUSES),

Expand Down
5 changes: 3 additions & 2 deletions ui/tests/acceptance/client-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { click, find, findAll, currentURL, visit } from 'ember-native-dom-helper
import { test } from 'qunit';
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import moment from 'moment';

const { $ } = Ember;

Expand Down Expand Up @@ -127,8 +128,8 @@ test('each allocation should have high-level details for the allocation', functi
.find('td:eq(1)')
.text()
.trim(),
allocation.modifyIndex,
'Allocation modify index'
moment(allocation.modifyTime / 1000000).format('MM/DD HH:mm:ss'),
'Allocation modify time'
);
assert.equal(
allocationRow
Expand Down
5 changes: 3 additions & 2 deletions ui/tests/acceptance/task-group-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { click, find, findAll, fillIn, currentURL, visit } from 'ember-native-do
import { test } from 'qunit';
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import moment from 'moment';

const { $ } = Ember;

Expand Down Expand Up @@ -157,8 +158,8 @@ test('each allocation should show basic information about the allocation', funct
.find('td:eq(1)')
.text()
.trim(),
allocation.modifyIndex,
'Allocation modify index'
moment(allocation.modifyTime / 1000000).format('MM/DD HH:mm:ss'),
'Allocation modify time'
);
assert.equal(
allocationRow
Expand Down

0 comments on commit a78a2e3

Please sign in to comment.