2018-09-25 16:28:26 +00:00
|
|
|
import { computed } from '@ember/object';
|
2018-04-03 14:16:57 +00:00
|
|
|
import DS from 'ember-data';
|
2018-06-12 21:06:37 +00:00
|
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
2018-04-03 14:16:57 +00:00
|
|
|
const { attr } = DS;
|
|
|
|
const CREATE_FIELDS = ['username', 'ip'];
|
|
|
|
|
|
|
|
const DISPLAY_FIELDS = ['username', 'ip', 'key', 'keyType', 'port'];
|
|
|
|
export default DS.Model.extend({
|
|
|
|
role: attr('object', {
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
ip: attr('string', {
|
|
|
|
label: 'IP Address',
|
|
|
|
}),
|
|
|
|
username: attr('string'),
|
|
|
|
key: attr('string'),
|
|
|
|
keyType: attr('string'),
|
|
|
|
port: attr('number'),
|
|
|
|
attrs: computed('key', function() {
|
|
|
|
let keys = this.get('key') ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0);
|
2018-06-12 21:06:37 +00:00
|
|
|
return expandAttributeMeta(this, keys);
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
|
|
|
toCreds: computed('key', function() {
|
|
|
|
// todo: would this be better copied as an SSH command?
|
|
|
|
return this.get('key');
|
|
|
|
}),
|
|
|
|
});
|