2020-01-21 17:52:40 +00:00
|
|
|
import { env } from 'consul-ui/env';
|
2019-02-21 10:36:15 +00:00
|
|
|
|
|
|
|
export function initialize(container) {
|
2019-04-17 08:25:08 +00:00
|
|
|
if (env('CONSUL_UI_DISABLE_REALTIME')) {
|
2019-02-21 10:36:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-01-29 16:22:31 +00:00
|
|
|
['node', 'coordinate', 'session', 'service', 'proxy', 'discovery-chain', 'intention']
|
2020-01-21 17:52:40 +00:00
|
|
|
.concat(env('CONSUL_NSPACES_ENABLED') ? ['nspace/enabled'] : [])
|
2019-02-21 10:36:15 +00:00
|
|
|
.map(function(item) {
|
|
|
|
// create repositories that return a promise resolving to an EventSource
|
|
|
|
return {
|
|
|
|
service: `repository/${item}/event-source`,
|
|
|
|
extend: 'repository/type/event-source',
|
|
|
|
// Inject our original respository that is used by this class
|
|
|
|
// within the callable of the EventSource
|
|
|
|
services: {
|
|
|
|
content: `repository/${item}`,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
})
|
2019-05-01 18:09:29 +00:00
|
|
|
.concat(
|
|
|
|
['dc', 'policy', 'role'].map(function(item) {
|
|
|
|
// create repositories that return a promise resolving to an EventSource
|
|
|
|
return {
|
|
|
|
service: `repository/${item}/component`,
|
|
|
|
extend: 'repository/type/component',
|
|
|
|
// Inject our original respository that is used by this class
|
|
|
|
// within the callable of the EventSource
|
|
|
|
services: {
|
|
|
|
content: `repository/${item}`,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
})
|
|
|
|
)
|
2019-02-21 10:36:15 +00:00
|
|
|
.concat([
|
|
|
|
// These are the routes where we overwrite the 'default'
|
2019-03-22 17:24:40 +00:00
|
|
|
// repo service. Default repos are repos that return a promise resolving to
|
2019-02-21 10:36:15 +00:00
|
|
|
// an ember-data record or recordset
|
|
|
|
{
|
|
|
|
route: 'dc/nodes/index',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/node/event-source',
|
|
|
|
},
|
|
|
|
},
|
2019-03-22 17:24:40 +00:00
|
|
|
{
|
|
|
|
route: 'dc/nodes/show',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/node/event-source',
|
|
|
|
coordinateRepo: 'repository/coordinate/event-source',
|
|
|
|
sessionRepo: 'repository/session/event-source',
|
|
|
|
},
|
|
|
|
},
|
2019-02-21 10:36:15 +00:00
|
|
|
{
|
|
|
|
route: 'dc/services/index',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/service/event-source',
|
|
|
|
},
|
|
|
|
},
|
2019-03-22 17:10:33 +00:00
|
|
|
{
|
|
|
|
route: 'dc/services/show',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/service/event-source',
|
2019-12-17 19:27:28 +00:00
|
|
|
chainRepo: 'repository/discovery-chain/event-source',
|
2019-03-22 17:10:33 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-22 17:24:40 +00:00
|
|
|
{
|
|
|
|
route: 'dc/services/instance',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/service/event-source',
|
|
|
|
proxyRepo: 'repository/proxy/event-source',
|
|
|
|
},
|
|
|
|
},
|
2020-01-29 16:22:31 +00:00
|
|
|
{
|
|
|
|
route: 'dc/intentions/index',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/intention/event-source',
|
|
|
|
},
|
|
|
|
},
|
2019-05-01 18:09:29 +00:00
|
|
|
{
|
|
|
|
service: 'form',
|
|
|
|
services: {
|
|
|
|
role: 'repository/role/component',
|
|
|
|
policy: 'repository/policy/component',
|
|
|
|
},
|
|
|
|
},
|
2019-02-21 10:36:15 +00:00
|
|
|
])
|
2019-12-17 18:47:37 +00:00
|
|
|
.concat(
|
2020-01-21 17:52:40 +00:00
|
|
|
env('CONSUL_NSPACES_ENABLED')
|
2019-12-17 18:47:37 +00:00
|
|
|
? [
|
|
|
|
{
|
|
|
|
route: 'dc/nspaces/index',
|
|
|
|
services: {
|
|
|
|
repo: 'repository/nspace/enabled/event-source',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []
|
|
|
|
)
|
2019-02-21 10:36:15 +00:00
|
|
|
.forEach(function(definition) {
|
|
|
|
if (typeof definition.extend !== 'undefined') {
|
|
|
|
// Create the class instances that we need
|
|
|
|
container.register(
|
|
|
|
`service:${definition.service}`,
|
|
|
|
container.resolveRegistration(`service:${definition.extend}`).extend({})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Object.keys(definition.services).forEach(function(name) {
|
|
|
|
const servicePath = definition.services[name];
|
|
|
|
// inject its dependencies, this could probably detect the type
|
|
|
|
// but hardcode this for the moment
|
|
|
|
if (typeof definition.route !== 'undefined') {
|
|
|
|
container.inject(`route:${definition.route}`, name, `service:${servicePath}`);
|
2020-01-21 17:52:40 +00:00
|
|
|
if (env('CONSUL_NSPACES_ENABLED') && definition.route.startsWith('dc/')) {
|
2019-12-17 18:47:37 +00:00
|
|
|
container.inject(`route:nspace/${definition.route}`, name, `service:${servicePath}`);
|
|
|
|
}
|
2019-02-21 10:36:15 +00:00
|
|
|
} else {
|
|
|
|
container.inject(`service:${definition.service}`, name, `service:${servicePath}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
initialize,
|
|
|
|
};
|