diff --git a/CHANGELOG.md b/CHANGELOG.md index 72c3ef67443..1819e658ef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ IMPROVEMENTS: * agent: add `-dev=connect` parameter to support running in dev mode with Consul Connect [[GH-6126](https://github.com/hashicorp/nomad/issues/6126)] * api: add follow parameter to file streaming endpoint to support older browsers [[GH-6049](https://github.com/hashicorp/nomad/issues/6049)] * metrics: Add job status (pending, running, dead) metrics [[GH-6003](https://github.com/hashicorp/nomad/issues/6003)] + * ui: Add creation time to evaluations table [[GH-6050](https://github.com/hashicorp/nomad/pull/6050)] BUG FIXES: diff --git a/ui/app/models/evaluation.js b/ui/app/models/evaluation.js index 5cd407bbfee..2b7b0f2e0aa 100644 --- a/ui/app/models/evaluation.js +++ b/ui/app/models/evaluation.js @@ -20,6 +20,10 @@ export default Model.extend({ job: belongsTo('job'), modifyIndex: attr('number'), + modifyTime: attr('date'), + + createIndex: attr('number'), + createTime: attr('date'), waitUntil: attr('date'), }); diff --git a/ui/app/serializers/evaluation.js b/ui/app/serializers/evaluation.js index b81c257ace2..18e08271e36 100644 --- a/ui/app/serializers/evaluation.js +++ b/ui/app/serializers/evaluation.js @@ -21,6 +21,12 @@ export default ApplicationSerializer.extend({ 'default'; hash.JobID = JSON.stringify([hash.JobID, hash.Namespace]); + hash.ModifyTimeNanos = hash.ModifyTime % 1000000; + hash.ModifyTime = Math.floor(hash.ModifyTime / 1000000); + + hash.CreateTimeNanos = hash.CreateTime % 1000000; + hash.CreateTime = Math.floor(hash.CreateTime / 1000000); + return this._super(typeHash, hash); }, }); diff --git a/ui/app/templates/jobs/job/evaluations.hbs b/ui/app/templates/jobs/job/evaluations.hbs index ee2bdd0ff50..2c160f10a34 100644 --- a/ui/app/templates/jobs/job/evaluations.hbs +++ b/ui/app/templates/jobs/job/evaluations.hbs @@ -9,6 +9,7 @@ {{#t.head}} ID {{#t.sort-by prop="priority"}}Priority{{/t.sort-by}} + {{#t.sort-by prop="createTime"}}Created{{/t.sort-by}} {{#t.sort-by prop="triggeredBy"}}Triggered By{{/t.sort-by}} {{#t.sort-by prop="status"}}Status{{/t.sort-by}} {{#t.sort-by prop="hasPlacementFailures"}}Placement Failures{{/t.sort-by}} @@ -17,6 +18,7 @@ {{row.model.shortId}} {{row.model.priority}} + {{format-month-ts row.model.createTime}} {{row.model.triggeredBy}} {{row.model.status}} diff --git a/ui/mirage/factories/evaluation.js b/ui/mirage/factories/evaluation.js index 0dbfa25dc4c..941f85e5574 100644 --- a/ui/mirage/factories/evaluation.js +++ b/ui/mirage/factories/evaluation.js @@ -16,6 +16,7 @@ const EVAL_TRIGGERED_BY = [ 'failed-follow-up', 'max-plan-attempts', ]; +const REF_TIME = new Date(); const generateCountMap = (keysCount, list) => () => { const sample = Array(keysCount) @@ -53,6 +54,12 @@ export default Factory.extend({ failedTGAllocs: null, modifyIndex: () => faker.random.number({ min: 10, max: 2000 }), + modifyTime: () => faker.date.past(2 / 365, REF_TIME) * 1000000, + + createIndex: () => faker.random.number({ min: 10, max: 2000 }), + createTime() { + return faker.date.past(2 / 365, new Date(this.modifyTime / 1000000)) * 1000000; + }, waitUntil: null, diff --git a/ui/tests/unit/serializers/evaluation-test.js b/ui/tests/unit/serializers/evaluation-test.js index a31209b4da0..053828acddd 100644 --- a/ui/tests/unit/serializers/evaluation-test.js +++ b/ui/tests/unit/serializers/evaluation-test.js @@ -9,11 +9,14 @@ module('Unit | Serializer | Evaluation', function(hooks) { this.subject = () => this.store.serializerFor('evaluation'); }); + const sampleDate = new Date('2018-12-12T00:00:00'); const normalizationTestCases = [ { name: 'Normal', in: { ID: 'test-eval', + CreateTime: +sampleDate * 1000000, + ModifyTime: +sampleDate * 1000000, FailedTGAllocs: { taskGroup: { NodesAvailable: 10, @@ -29,6 +32,8 @@ module('Unit | Serializer | Evaluation', function(hooks) { id: 'test-eval', type: 'evaluation', attributes: { + createTime: sampleDate, + modifyTime: sampleDate, failedTGAllocs: [ { name: 'taskGroup', @@ -52,6 +57,8 @@ module('Unit | Serializer | Evaluation', function(hooks) { name: 'Dots in task group names', in: { ID: 'test-eval', + CreateTime: +sampleDate * 1000000, + ModifyTime: +sampleDate * 1000000, FailedTGAllocs: { 'one.two': { NodesAvailable: 10, @@ -70,6 +77,8 @@ module('Unit | Serializer | Evaluation', function(hooks) { id: 'test-eval', type: 'evaluation', attributes: { + modifyTime: sampleDate, + createTime: sampleDate, failedTGAllocs: [ { name: 'one.two',