Allocation methods for stopping and restarting
This commit is contained in:
parent
d3e919a2c8
commit
a00bc8befc
|
@ -1,3 +1,22 @@
|
|||
import Watchable from './watchable';
|
||||
import addToPath from 'nomad-ui/utils/add-to-path';
|
||||
|
||||
export default Watchable.extend();
|
||||
export default Watchable.extend({
|
||||
stop: adapterAction('/stop'),
|
||||
restart: adapterAction((adapter, allocation) => {
|
||||
const prefix = `${adapter.host || '/'}${adapter.urlPrefix()}`;
|
||||
return `${prefix}/client/allocation/${allocation.id}/restart`;
|
||||
}, 'PUT'),
|
||||
});
|
||||
|
||||
function adapterAction(path, verb = 'POST') {
|
||||
return function(allocation) {
|
||||
let url;
|
||||
if (typeof path === 'function') {
|
||||
url = path(this, allocation);
|
||||
} else {
|
||||
url = addToPath(this.urlForFindRecord(allocation.id, 'allocation'), path);
|
||||
}
|
||||
return this.ajax(url, verb);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -99,4 +99,12 @@ export default Model.extend({
|
|||
);
|
||||
}
|
||||
),
|
||||
|
||||
stop() {
|
||||
return this.store.adapterFor('allocation').stop(this);
|
||||
},
|
||||
|
||||
restart() {
|
||||
return this.store.adapterFor('allocation').restart(this);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue