open-vault/ui/app/models/ssh-otp-credential.js
Matthew Irish 924d1b4ddc
UI - code cleanup (#4699)
* use lazyCapabilities macro in models

* use expandAttributeMeta and fieldToAttrs everywhere

* add angle bracket component polyfill

* use PageHeader component throughout
2018-06-12 16:06:37 -05:00

29 lines
832 B
JavaScript

import DS from 'ember-data';
import Ember from 'ember';
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
const { attr } = DS;
const { computed } = Ember;
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);
return expandAttributeMeta(this, keys);
}),
toCreds: computed('key', function() {
// todo: would this be better copied as an SSH command?
return this.get('key');
}),
});