diff --git a/addons/api/addon/generated/models/host.js b/addons/api/addon/generated/models/host.js index 0d9e0dd2d..8713b9b89 100644 --- a/addons/api/addon/generated/models/host.js +++ b/addons/api/addon/generated/models/host.js @@ -35,8 +35,4 @@ export default class GeneratedHostModel extends BaseModel { }) version; - @attr('string', { - description: 'The address (DNS or IP name) used to reach the host' - }) address; - } diff --git a/addons/api/addon/models/fragment-host-attributes.js b/addons/api/addon/models/fragment-host-attributes.js new file mode 100644 index 000000000..114da4bca --- /dev/null +++ b/addons/api/addon/models/fragment-host-attributes.js @@ -0,0 +1,9 @@ +import Fragment from 'ember-data-model-fragments/fragment'; +import { attr } from '@ember-data/model'; + +export default class FragmentHostAttributesModel extends Fragment { + + @attr('string', { + description: 'The address (DNS or IP name) used to reach the host' + }) address; +} diff --git a/addons/api/addon/models/host.js b/addons/api/addon/models/host.js index 451097080..a2e855084 100644 --- a/addons/api/addon/models/host.js +++ b/addons/api/addon/models/host.js @@ -1,3 +1,12 @@ import GeneratedHostModel from '../generated/models/host'; +import { fragment } from 'ember-data-model-fragments/attributes'; -export default class HostModel extends GeneratedHostModel {} +export default class HostModel extends GeneratedHostModel { + + /** + * Attributes of this resource, if any, represented as a JSON fragment. + * @type {FragmentHostAttributesModel} + */ + @fragment('fragment-host-attributes', { defaultValue: {} }) attributes; + +} diff --git a/addons/api/app/models/fragment-host-attributes.js b/addons/api/app/models/fragment-host-attributes.js new file mode 100644 index 000000000..201efcb7a --- /dev/null +++ b/addons/api/app/models/fragment-host-attributes.js @@ -0,0 +1 @@ +export { default } from 'api/models/fragment-host-attributes'; diff --git a/addons/api/tests/unit/models/host-test.js b/addons/api/tests/unit/models/host-test.js index d19d98fc3..3cc0a3ad9 100644 --- a/addons/api/tests/unit/models/host-test.js +++ b/addons/api/tests/unit/models/host-test.js @@ -10,4 +10,15 @@ module('Unit | Model | host', function(hooks) { let model = store.createRecord('host', {}); assert.ok(model); }); + + test('it contains attributes', function(assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('host', { + type: 'static', + attributes: { + address: '127.0.0.1' + } + }); + assert.equal(model.attributes.address, '127.0.0.1'); + }); }); diff --git a/ui/core/app/components/form/host-set/hosts/index.hbs b/ui/core/app/components/form/host-set/hosts/index.hbs index 1943e26aa..088270a0b 100644 --- a/ui/core/app/components/form/host-set/hosts/index.hbs +++ b/ui/core/app/components/form/host-set/hosts/index.hbs @@ -41,7 +41,7 @@ onChange={{fn @toggleHost option.host}} /> {{option.host.name}} - {{option.host.address}} + {{option.host.attributes.address}} {{/each}} diff --git a/ui/core/app/components/form/host/index.hbs b/ui/core/app/components/form/host/index.hbs index 9152b0ba0..2168b7285 100644 --- a/ui/core/app/components/form/host/index.hbs +++ b/ui/core/app/components/form/host/index.hbs @@ -47,6 +47,24 @@ {{/if}} + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + {{t "form.label.name"}} {{t "form.label.type"}} {{t "form.label.id"}} + {{t "form.label.address"}} @@ -26,6 +27,9 @@ {{host.id}} + + {{host.attributes.address}} + {{/each}} diff --git a/ui/core/mirage/generated/factories/host.js b/ui/core/mirage/generated/factories/host.js index 2d6925e82..e6fccf602 100644 --- a/ui/core/mirage/generated/factories/host.js +++ b/ui/core/mirage/generated/factories/host.js @@ -12,6 +12,6 @@ export default Factory.extend({ created_time: () => date.recent(), updated_time: () => date.recent(), version: () => random.number(), - address: () => internet.ipv6(), + attributes: () => { return { address: internet.ipv6() } }, });