diff --git a/ui/app/adapters/job.js b/ui/app/adapters/job.js index f6992cb13..dad4b37aa 100644 --- a/ui/app/adapters/job.js +++ b/ui/app/adapters/job.js @@ -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', + }, + }, + }); + } } diff --git a/ui/app/models/job.js b/ui/app/models/job.js index e179cd4b4..154fc07b1 100644 --- a/ui/app/models/job.js +++ b/ui/app/models/job.js @@ -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; diff --git a/ui/app/models/task-group.js b/ui/app/models/task-group.js index 8647eccc5..4926f0aff 100644 --- a/ui/app/models/task-group.js +++ b/ui/app/models/task-group.js @@ -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); + } }