Merge branch 'develop' into add-target-type
This commit is contained in:
49 files changed
+312
-217
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import ApplicationAdapter from './application';
|
||||
|
||||
export default class HostCatalogAdapter extends ApplicationAdapter {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Host catalogs use the new, unprefixed pathing style.
|
||||
* @override
|
||||
*/
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -7,32 +7,12 @@ export default class HostSetAdapter extends ApplicationAdapter {
|
||||
|
||||
@service store;
|
||||
|
||||
// =methods
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Append a host catalog URL ahead of the host sets path if `hostCatalogID` is
|
||||
* passed via adapter options. Otherwise, generate the prefix as normal.
|
||||
*
|
||||
* TODO: generalize the interface to resource-prefixed URLs by accepting
|
||||
* a modelName and an ID, rather than looking for a known key.
|
||||
*
|
||||
* Host sets use the new, unprefixed pathing style.
|
||||
* @override
|
||||
* @param {string} path
|
||||
* @param {string} parentURL
|
||||
* @param {string} modelName
|
||||
* @param {string} id
|
||||
* @param {object} snapshot
|
||||
* @return {string} urlPrefix
|
||||
*/
|
||||
urlPrefix(path, parentURL, modelName, id, snapshot) {
|
||||
const hostCatalogID = snapshot?.adapterOptions?.hostCatalogID;
|
||||
if (hostCatalogID) {
|
||||
const hostCatalogAdapter = this.store.adapterFor('host-catalog');
|
||||
return hostCatalogAdapter
|
||||
._buildPrefixedURL('host-catalog', hostCatalogID, snapshot);
|
||||
} else {
|
||||
return super.urlPrefix(...arguments);
|
||||
}
|
||||
}
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -7,32 +7,12 @@ export default class HostAdapter extends ApplicationAdapter {
|
||||
|
||||
@service store;
|
||||
|
||||
// =methods
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Append a host catalog URL ahead of the host path if `hostCatalogID` is
|
||||
* passed via adapter options. Otherwise, generate the prefix as normal.
|
||||
*
|
||||
* TODO: generalize the interface to resource-prefixed URLs by accepting
|
||||
* a modelName and an ID, rather than looking for a known key.
|
||||
*
|
||||
* Hosts use the new, unprefixed pathing style.
|
||||
* @override
|
||||
* @param {string} path
|
||||
* @param {string} parentURL
|
||||
* @param {string} modelName
|
||||
* @param {string} id
|
||||
* @param {object} snapshot
|
||||
* @return {string} urlPrefix
|
||||
*/
|
||||
urlPrefix(path, parentURL, modelName, id, snapshot) {
|
||||
const hostCatalogID = snapshot?.adapterOptions?.hostCatalogID;
|
||||
if (hostCatalogID) {
|
||||
const hostCatalogAdapter = this.store.adapterFor('host-catalog');
|
||||
return hostCatalogAdapter
|
||||
._buildPrefixedURL('host-catalog', hostCatalogID, snapshot);
|
||||
} else {
|
||||
return super.urlPrefix(...arguments);
|
||||
}
|
||||
}
|
||||
hasScopePrefix = false;
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@ export default class GeneratedHostSetModel extends BaseModel {
|
||||
|
||||
@attr('string', {
|
||||
description: 'The owning host catalog ID.',
|
||||
readOnly: true
|
||||
}) host_catalog_id;
|
||||
|
||||
@attr('string', {
|
||||
|
||||
@@ -12,6 +12,10 @@ export default class GeneratedHostModel extends BaseModel {
|
||||
description: 'The type of the resource, to help differentiate schemas'
|
||||
}) type;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The owning host catalog ID.',
|
||||
}) host_catalog_id;
|
||||
|
||||
@attr('string', {
|
||||
description: 'Optional name for identification purposes'
|
||||
}) name;
|
||||
@@ -35,8 +39,4 @@ export default class GeneratedHostModel extends BaseModel {
|
||||
})
|
||||
version;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The address (DNS or IP name) used to reach the host'
|
||||
}) address;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import GeneratedHostSetModel from '../generated/models/host-set';
|
||||
import { fragmentArray } from 'ember-data-model-fragments/attributes';
|
||||
//import { computed } from '@ember/object';
|
||||
|
||||
export default class HostSetModel extends GeneratedHostSetModel {
|
||||
|
||||
@@ -12,18 +11,6 @@ export default class HostSetModel extends GeneratedHostSetModel {
|
||||
*/
|
||||
@fragmentArray('fragment-string', {readOnly: true}) host_ids;
|
||||
|
||||
// TODO this is here in case we want it in the future,
|
||||
// especially for the target / add host sets workflow
|
||||
/**
|
||||
* Returns the host catalog instance associated with this host set if
|
||||
* it is already loaded into the store.
|
||||
* @type {?HostCatalogModel}
|
||||
*/
|
||||
// @computed('host_catalog_id')
|
||||
// get hostCatalog() {
|
||||
// return this.store.peekRecord('host-catalog', this.host_catalog_id);
|
||||
// }
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class HostCatalogSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,14 @@ import ApplicationSerializer from './application';
|
||||
|
||||
export default class HostSetSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class HostSerializer extends ApplicationSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Serialized the scope ID into the `scope_id` field.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = true;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user