2018-06-27 20:39:57 +00:00
|
|
|
import Controller from '@ember/controller';
|
2017-12-15 21:39:18 +00:00
|
|
|
import { computed } from '@ember/object';
|
2019-10-15 18:32:58 +00:00
|
|
|
import { computed as overridable } from 'ember-overridable-computed';
|
2018-03-13 21:59:03 +00:00
|
|
|
import { alias } from '@ember/object/computed';
|
2019-05-20 22:36:15 +00:00
|
|
|
import { task } from 'ember-concurrency';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2017-10-31 04:02:40 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
export default class IndexController extends Controller {
|
|
|
|
@computed('model.task.taskGroup.tasks.@each.name')
|
|
|
|
get otherTaskStates() {
|
2020-04-30 13:15:19 +00:00
|
|
|
const taskName = this.model.task.name;
|
|
|
|
return this.model.allocation.states.rejectBy('name', taskName);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-04-30 13:15:19 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('otherTaskStates.@each.lifecycle')
|
|
|
|
get prestartTaskStates() {
|
2020-04-30 13:15:19 +00:00
|
|
|
return this.otherTaskStates.filterBy('task.lifecycle');
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-04-30 13:15:19 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@alias('model.resources.networks.firstObject') network;
|
|
|
|
|
|
|
|
@computed('network.{reservedPorts.[],dynamicPorts.[]}')
|
|
|
|
get ports() {
|
2017-11-14 18:50:09 +00:00
|
|
|
return (this.get('network.reservedPorts') || [])
|
2017-10-31 04:02:40 +00:00
|
|
|
.map(port => ({
|
|
|
|
name: port.Label,
|
|
|
|
port: port.Value,
|
|
|
|
isDynamic: false,
|
|
|
|
}))
|
|
|
|
.concat(
|
2017-11-14 18:50:09 +00:00
|
|
|
(this.get('network.dynamicPorts') || []).map(port => ({
|
2017-10-31 04:02:40 +00:00
|
|
|
name: port.Label,
|
|
|
|
port: port.Value,
|
|
|
|
isDynamic: true,
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
.sortBy('name');
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2019-05-20 22:36:15 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@overridable(() => {
|
2019-05-20 22:36:15 +00:00
|
|
|
// { title, description }
|
|
|
|
return null;
|
2020-06-10 13:49:16 +00:00
|
|
|
})
|
|
|
|
error;
|
2019-05-20 22:36:15 +00:00
|
|
|
|
|
|
|
onDismiss() {
|
|
|
|
this.set('error', null);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2019-05-20 22:36:15 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@task(function*() {
|
2019-05-20 22:36:15 +00:00
|
|
|
try {
|
|
|
|
yield this.model.restart();
|
|
|
|
} catch (err) {
|
|
|
|
this.set('error', {
|
|
|
|
title: 'Could Not Restart Task',
|
2019-05-21 00:19:24 +00:00
|
|
|
description: 'Your ACL token does not grant allocation lifecycle permissions.',
|
2019-05-20 22:36:15 +00:00
|
|
|
});
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
})
|
|
|
|
restartTask;
|
|
|
|
}
|