New scale action for jobs (and a convenience task group method)

This commit is contained in:
Michael Lange 2020-06-17 01:48:10 -07:00
parent 57f4e9a62e
commit aebc896ff6
3 changed files with 24 additions and 0 deletions

View file

@ -68,4 +68,20 @@ export default class JobAdapter extends WatchableNamespaceIDs {
},
});
}
scale(job, group, count, reason) {
const url = addToPath(this.urlForFindRecord(job.get('id'), 'job'), '/scale');
return this.ajax(url, 'POST', {
data: {
Count: count,
Reason: reason,
Target: {
Group: group,
},
Meta: {
Source: 'nomad-ui',
},
},
});
}
}

View file

@ -245,6 +245,10 @@ export default class Job extends Model {
return promise;
}
scale(group, count, reason = 'Manual scaling event from the Nomad UI') {
return this.store.adapterFor('job').scale(this, group, count, reason);
}
setIdByPayload(payload) {
const namespace = payload.Namespace || 'default';
const id = payload.Name;

View file

@ -53,4 +53,8 @@ export default class TaskGroup extends Fragment {
get summary() {
return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.name);
}
scale(count, reason) {
return this.job.scale(this.name, count, reason);
}
}