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