ui/lib/shared/addon/components/schema/input-host/component.js

37 lines
1015 B
JavaScript

import { inject as service } from '@ember/service';
import Component from '@ember/component';
import layout from './template';
export default Component.extend({
layout,
modalService: service('modal'),
hostConfig: null,
hostName: null,
value: null,
actions: {
launchHost() {
// we should reall not kill the previous driver if they edit, fix this in the future
if (this.get('hostConfig')) {
this.setProperties({
hostConfig: null,
hostName: null
});
}
this.get('modalService').toggleModal('modal-catalog-host', {
callee: this,
});
},
completed(value){
this.setProperties({
hostConfig: value, // probably use this when we are sending it back up on edit
value: JSON.stringify(value)
});
Object.keys(value).forEach((key) => {
if (key.indexOf('Config') >= 0) {
this.set('hostName', key.slice(0, key.indexOf('Config')).capitalize());
}
});
}
}
});