ui: Defer requesting gateway related services until the tab is visible (#8803)

* ui: Defer requesting gateway related services until the tab is visible

* Extend one route with the other as they are the same thing dsatawise
This commit is contained in:
John Cowen 2020-10-05 14:48:26 +01:00 committed by GitHub
parent 63ceb4f15e
commit f00e6e78f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 43 deletions

View File

@ -6,7 +6,7 @@ import { get } from '@ember/object';
export default Route.extend({
data: service('data-source/service'),
settings: service('settings'),
model: function(params, transition = {}) {
model: function(params, transition) {
const dc = this.modelFor('dc').dc.Name;
const nspace = this.modelFor('nspace').nspace.substr(1);
return hash({
@ -19,32 +19,19 @@ export default Route.extend({
urls: this.settings.findBySlug('urls'),
chain: null,
proxies: [],
})
.then(model => {
return ['connect-proxy', 'mesh-gateway', 'ingress-gateway', 'terminating-gateway'].includes(
get(model, 'items.firstObject.Service.Kind')
)
? model
: hash({
...model,
chain: this.data.source(uri => uri`/${nspace}/${dc}/discovery-chain/${params.name}`),
proxies: this.data.source(
uri => uri`/${nspace}/${dc}/proxies/for-service/${params.name}`
),
});
})
.then(model => {
return ['ingress-gateway', 'terminating-gateway'].includes(
get(model, 'items.firstObject.Service.Kind')
)
? hash({
...model,
gatewayServices: this.data.source(
uri => uri`/${nspace}/${dc}/gateways/for-service/${params.name}`
),
})
: model;
});
}).then(model => {
return ['connect-proxy', 'mesh-gateway', 'ingress-gateway', 'terminating-gateway'].includes(
get(model, 'items.firstObject.Service.Kind')
)
? model
: hash({
...model,
chain: this.data.source(uri => uri`/${nspace}/${dc}/discovery-chain/${params.name}`),
proxies: this.data.source(
uri => uri`/${nspace}/${dc}/proxies/for-service/${params.name}`
),
});
});
},
setupController: function(controller, model) {
this._super(...arguments);

View File

@ -1,12 +1,22 @@
import Route from 'consul-ui/routing/route';
import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
export default Route.extend({
data: service('data-source/service'),
model: function() {
const dc = this.modelFor('dc').dc.Name;
const nspace = this.modelFor('nspace').nspace.substr(1);
const parent = this.routeName
.split('.')
.slice(0, -1)
.join('.');
return this.modelFor(parent);
const name = this.modelFor(parent).name;
return hash({
dc: dc,
nspace: nspace,
gatewayServices: this.data.source(uri => uri`/${nspace}/${dc}/gateways/for-service/${name}`),
});
},
setupController: function(controller, model) {
this._super(...arguments);

View File

@ -1,15 +1,5 @@
import Route from 'consul-ui/routing/route';
import Route from './services';
export default Route.extend({
model: function() {
const parent = this.routeName
.split('.')
.slice(0, -1)
.join('.');
return this.modelFor(parent);
},
setupController: function(controller, model) {
this._super(...arguments);
controller.setProperties(model);
},
templateName: 'dc/services/show/upstreams',
});

View File

@ -2,7 +2,6 @@
<EventSource @src={{chain}} />
<EventSource @src={{intentions}} />
<EventSource @src={{proxies}} />
<EventSource @src={{gatewayServices}} />
{{title item.Service.Service}}
<AppView>
<BlockSlot @name="notification" as |status type|>

View File

@ -1,4 +1,5 @@
<div id="services" class="tab-section">
<EventSource @src={{gatewayServices}} />
<div class="tab-section">
<div role="tabpanel">
{{#let (hash
instances=(if instance (split instance ',') undefined)

View File

@ -1,4 +1,5 @@
<div id="upstreams" class="tab-section">
<EventSource @src={{gatewayServices}} />
<div class="tab-section">
<div role="tabpanel">
{{#let (hash
instances=(if instance (split instance ',') undefined)