mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
Get the latest deployment for a job by using the appropriate API
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { alias } from '@ember/object/computed';
|
||||
import { alias, equal } from '@ember/object/computed';
|
||||
import { computed } from '@ember/object';
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
@@ -10,7 +10,7 @@ import sumAggregation from '../utils/properties/sum-aggregation';
|
||||
export default Model.extend({
|
||||
shortId: shortUUIDProperty('id'),
|
||||
|
||||
job: belongsTo('job'),
|
||||
job: belongsTo('job', { inverse: 'deployments' }),
|
||||
versionNumber: attr('number'),
|
||||
|
||||
// If any task group is not promoted yet requires promotion and the deployment
|
||||
@@ -26,6 +26,9 @@ export default Model.extend({
|
||||
|
||||
status: attr('string'),
|
||||
statusDescription: attr('string'),
|
||||
|
||||
isRunning: equal('status', 'running'),
|
||||
|
||||
taskGroupSummaries: fragmentArray('task-group-deployment-summary'),
|
||||
allocations: hasMany('allocations'),
|
||||
|
||||
|
||||
@@ -172,8 +172,11 @@ export default Model.extend({
|
||||
|
||||
supportsDeployments: equal('type', 'service'),
|
||||
|
||||
runningDeployment: computed('deployments.@each.status', function() {
|
||||
return this.get('deployments').findBy('status', 'running');
|
||||
latestDeployment: belongsTo('deployment', { inverse: null }),
|
||||
|
||||
runningDeployment: computed('latestDeployment.isRunning', function() {
|
||||
const latest = this.get('latestDeployment');
|
||||
if (latest.get('isRunning')) return latest;
|
||||
}),
|
||||
|
||||
fetchRawDefinition() {
|
||||
|
||||
@@ -12,7 +12,8 @@ export default Route.extend(WithWatchers, {
|
||||
model: this.get('watch').perform(model),
|
||||
summary: this.get('watchSummary').perform(model.get('summary')),
|
||||
evaluations: this.get('watchEvaluations').perform(model),
|
||||
deployments: model.get('supportsDeployments') && this.get('watchDeployments').perform(model),
|
||||
latestDeployment:
|
||||
model.get('supportsDeployments') && this.get('watchLatestDeployment').perform(model),
|
||||
list: model.get('hasChildren') && this.get('watchAll').perform(),
|
||||
});
|
||||
},
|
||||
@@ -21,7 +22,13 @@ export default Route.extend(WithWatchers, {
|
||||
watchAll: watchAll('job'),
|
||||
watchSummary: watchRecord('job-summary'),
|
||||
watchEvaluations: watchRelationship('evaluations'),
|
||||
watchDeployments: watchRelationship('deployments'),
|
||||
watchLatestDeployment: watchRelationship('latestDeployment'),
|
||||
|
||||
watchers: collect('watch', 'watchAll', 'watchSummary', 'watchEvaluations', 'watchDeployments'),
|
||||
watchers: collect(
|
||||
'watch',
|
||||
'watchAll',
|
||||
'watchSummary',
|
||||
'watchEvaluations',
|
||||
'watchLatestDeployment'
|
||||
),
|
||||
});
|
||||
|
||||
@@ -61,22 +61,27 @@ export default ApplicationSerializer.extend({
|
||||
return assign(this._super(...arguments), {
|
||||
allocations: {
|
||||
links: {
|
||||
related: buildURL(`${jobURL}/allocations`, { namespace: namespace }),
|
||||
related: buildURL(`${jobURL}/allocations`, { namespace }),
|
||||
},
|
||||
},
|
||||
versions: {
|
||||
links: {
|
||||
related: buildURL(`${jobURL}/versions`, { namespace: namespace, diffs: true }),
|
||||
related: buildURL(`${jobURL}/versions`, { namespace, diffs: true }),
|
||||
},
|
||||
},
|
||||
deployments: {
|
||||
links: {
|
||||
related: buildURL(`${jobURL}/deployments`, { namespace: namespace }),
|
||||
related: buildURL(`${jobURL}/deployments`, { namespace }),
|
||||
},
|
||||
},
|
||||
latestDeployment: {
|
||||
links: {
|
||||
related: buildURL(`${jobURL}/deployment`, { namespace }),
|
||||
},
|
||||
},
|
||||
evaluations: {
|
||||
links: {
|
||||
related: buildURL(`${jobURL}/evaluations`, { namespace: namespace }),
|
||||
related: buildURL(`${jobURL}/evaluations`, { namespace }),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user