|
|
|
@ -2,22 +2,12 @@ import Serializer from './application';
|
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/nspace';
|
|
|
|
|
|
|
|
|
|
export default class NspaceSerializer extends Serializer {
|
|
|
|
|
primaryKey = PRIMARY_KEY;
|
|
|
|
|
slugKey = SLUG_KEY;
|
|
|
|
|
|
|
|
|
|
respondForQuery(respond, query, data, modelClass) {
|
|
|
|
|
return super.respondForQuery(
|
|
|
|
|
cb =>
|
|
|
|
|
respond((headers, body) =>
|
|
|
|
|
cb(
|
|
|
|
|
headers,
|
|
|
|
|
body.map(function(item) {
|
|
|
|
|
item.Namespace = '*';
|
|
|
|
|
item.Datacenter = query.dc;
|
|
|
|
|
const normalizeACLs = item => {
|
|
|
|
|
if (get(item, 'ACLs.PolicyDefaults')) {
|
|
|
|
|
item.ACLs.PolicyDefaults = item.ACLs.PolicyDefaults.map(function(item) {
|
|
|
|
|
if (typeof item.template === 'undefined') {
|
|
|
|
|
item.template = '';
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -33,6 +23,22 @@ export default class NspaceSerializer extends Serializer {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return item;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default class NspaceSerializer extends Serializer {
|
|
|
|
|
primaryKey = PRIMARY_KEY;
|
|
|
|
|
slugKey = SLUG_KEY;
|
|
|
|
|
|
|
|
|
|
respondForQuery(respond, query, data, modelClass) {
|
|
|
|
|
return super.respondForQuery(
|
|
|
|
|
cb =>
|
|
|
|
|
respond((headers, body) =>
|
|
|
|
|
cb(
|
|
|
|
|
headers,
|
|
|
|
|
body.map(function(item) {
|
|
|
|
|
item.Namespace = '*';
|
|
|
|
|
item.Datacenter = query.dc;
|
|
|
|
|
return normalizeACLs(item);
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
@ -46,7 +52,7 @@ export default class NspaceSerializer extends Serializer {
|
|
|
|
|
respond((headers, body) => {
|
|
|
|
|
body.Datacenter = serialized.dc;
|
|
|
|
|
body.Namespace = '*';
|
|
|
|
|
return cb(headers, body);
|
|
|
|
|
return cb(headers, normalizeACLs(body));
|
|
|
|
|
}),
|
|
|
|
|
serialized,
|
|
|
|
|
data
|
|
|
|
@ -59,7 +65,7 @@ export default class NspaceSerializer extends Serializer {
|
|
|
|
|
respond((headers, body) => {
|
|
|
|
|
body.Datacenter = serialized.dc;
|
|
|
|
|
body.Namespace = '*';
|
|
|
|
|
return cb(headers, body);
|
|
|
|
|
return cb(headers, normalizeACLs(body));
|
|
|
|
|
}),
|
|
|
|
|
serialized,
|
|
|
|
|
data
|
|
|
|
@ -68,7 +74,7 @@ export default class NspaceSerializer extends Serializer {
|
|
|
|
|
|
|
|
|
|
respondForUpdateRecord(respond, serialized, data) {
|
|
|
|
|
return respond((headers, body) => {
|
|
|
|
|
return body;
|
|
|
|
|
return normalizeACLs(body);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|