2018-10-04 04:32:55 +00:00
|
|
|
/* eslint-disable */
|
2018-09-25 16:28:26 +00:00
|
|
|
import { isEmpty } from '@ember/utils';
|
2018-10-04 04:32:55 +00:00
|
|
|
import ApplicationAdapter from './application';
|
2018-04-20 02:26:25 +00:00
|
|
|
|
2018-10-04 04:32:55 +00:00
|
|
|
export default ApplicationAdapter.extend({
|
|
|
|
namespace: 'v1',
|
|
|
|
_url(backend, id) {
|
|
|
|
let url = `${this.buildURL()}/${backend}/metadata/`;
|
2018-09-25 16:28:26 +00:00
|
|
|
if (!isEmpty(id)) {
|
2018-04-20 02:26:25 +00:00
|
|
|
url = url + id;
|
|
|
|
}
|
|
|
|
return url;
|
|
|
|
},
|
|
|
|
|
2018-10-04 04:32:55 +00:00
|
|
|
// we override query here because the query object has a bunch of client-side
|
|
|
|
// concerns and we only want to send "list" to the server
|
|
|
|
query(store, type, query) {
|
|
|
|
let { backend, id } = query;
|
2018-10-06 03:02:23 +00:00
|
|
|
return this.ajax(this._url(backend, id), 'GET', { data: { list: true } }).then(resp => {
|
|
|
|
resp.id = id;
|
2018-10-18 04:06:52 +00:00
|
|
|
resp.backend = backend;
|
2018-10-06 03:02:23 +00:00
|
|
|
return resp;
|
|
|
|
});
|
2018-10-04 04:32:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
urlForQueryRecord(query) {
|
2018-04-20 02:26:25 +00:00
|
|
|
let { id, backend } = query;
|
2018-10-06 03:02:23 +00:00
|
|
|
return this._url(backend, id);
|
2018-10-04 04:32:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
queryRecord(store, type, query) {
|
|
|
|
let { backend, id } = query;
|
2018-10-06 03:02:23 +00:00
|
|
|
return this.ajax(this._url(backend, id), 'GET').then(resp => {
|
2018-04-20 02:26:25 +00:00
|
|
|
resp.id = id;
|
2018-10-04 04:32:55 +00:00
|
|
|
resp.backend = backend;
|
2018-04-20 02:26:25 +00:00
|
|
|
return resp;
|
|
|
|
});
|
|
|
|
},
|
2018-10-04 04:32:55 +00:00
|
|
|
|
2018-10-17 02:42:29 +00:00
|
|
|
detailURL(snapshot) {
|
2018-10-18 04:06:52 +00:00
|
|
|
let backend = snapshot.belongsTo('engine', { id: true }) || snapshot.attr('engineId');
|
2018-10-06 03:02:23 +00:00
|
|
|
let { id } = snapshot;
|
|
|
|
return this._url(backend, id);
|
|
|
|
},
|
|
|
|
|
2018-10-17 02:42:29 +00:00
|
|
|
urlForUpdateRecord(store, type, snapshot) {
|
|
|
|
return this.detailURL(snapshot);
|
|
|
|
},
|
|
|
|
urlForCreateRecord(modelName, snapshot) {
|
|
|
|
return this.detailURL(snapshot);
|
|
|
|
},
|
2018-10-04 04:32:55 +00:00
|
|
|
urlForDeleteRecord(store, type, snapshot) {
|
2018-10-17 02:42:29 +00:00
|
|
|
return this.detailURL(snapshot);
|
2018-10-04 04:32:55 +00:00
|
|
|
},
|
2018-04-20 02:26:25 +00:00
|
|
|
});
|