Prettify dc.services.show template

pull/14947/head
Michael Klein 2022-10-12 14:52:03 +02:00
parent a33feb2b41
commit e548bbb4ff
1 changed files with 141 additions and 123 deletions

View File

@ -1,36 +1,32 @@
<Route <Route @name={{routeName}} as |route|>
@name={{routeName}}
as |route|>
<DataLoader <DataLoader
@src={{uri '/${partition}/${nspace}/${dc}/service-instance/${id}/${node}/${name}/${peer}' @src={{uri
(hash '/${partition}/${nspace}/${dc}/service-instance/${id}/${node}/${name}/${peer}'
partition=route.params.partition (hash
nspace=route.params.nspace partition=route.params.partition
dc=route.params.dc nspace=route.params.nspace
id=route.params.id dc=route.params.dc
node=route.params.node id=route.params.id
name=route.params.name node=route.params.node
peer=route.params.peer name=route.params.name
) peer=route.params.peer
}} )
as |loader|> }}
as |loader|
>
<BlockSlot @name="error"> <BlockSlot @name='error'>
<AppError <AppError @error={{loader.error}} @login={{route.model.app.login.open}} />
@error={{loader.error}}
@login={{route.model.app.login.open}}
/>
</BlockSlot> </BlockSlot>
<BlockSlot @name="disconnected" as |after|> <BlockSlot @name='disconnected' as |after|>
{{#if (eq loader.error.status "404")}} {{#if (eq loader.error.status '404')}}
<Notice <Notice
{{notification {{notification sticky=true}}
sticky=true class='notification-update'
}} @type='warning'
class="notification-update" as |notice|
@type="warning" >
as |notice|>
<notice.Header> <notice.Header>
<strong>Warning!</strong> <strong>Warning!</strong>
</notice.Header> </notice.Header>
@ -40,14 +36,8 @@ as |route|>
</p> </p>
</notice.Body> </notice.Body>
</Notice> </Notice>
{{else if (eq loader.error.status "403")}} {{else if (eq loader.error.status '403')}}
<Notice <Notice {{notification sticky=true}} class='notification-update' @type='error' as |notice|>
{{notification
sticky=true
}}
class="notification-update"
@type="error"
as |notice|>
<notice.Header> <notice.Header>
<strong>Error!</strong> <strong>Error!</strong>
</notice.Header> </notice.Header>
@ -58,13 +48,7 @@ as |route|>
</notice.Body> </notice.Body>
</Notice> </Notice>
{{else}} {{else}}
<Notice <Notice {{notification sticky=true}} class='notification-update' @type='error' as |notice|>
{{notification
sticky=true
}}
class="notification-update"
@type="error"
as |notice|>
<notice.Header> <notice.Header>
<strong>Warning!</strong> <strong>Warning!</strong>
</notice.Header> </notice.Header>
@ -77,64 +61,67 @@ as |route|>
{{/if}} {{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="loaded"> <BlockSlot @name='loaded'>
{{#let {{#let loader.data as |item|}}
{{#if item.IsOrigin}}
loader.data <DataSource
@src={{uri
as |item|}} '/${partition}/${nspace}/${dc}/proxy-instance/${id}/${node}/${name}'
{{#if item.IsOrigin}} (hash
<DataSource partition=route.params.partition
@src={{uri '/${partition}/${nspace}/${dc}/proxy-instance/${id}/${node}/${name}' nspace=route.params.nspace
(hash dc=route.params.dc
partition=route.params.partition id=route.params.id
nspace=route.params.nspace node=route.params.node
dc=route.params.dc name=route.params.name
id=route.params.id )
node=route.params.node }}
name=route.params.name @onchange={{action (mut meta) value='data'}}
) as |meta|
}} >
@onchange={{action (mut meta) value="data"}} {{! We only really need meta to get the correct ServiceID }}
as |meta|> {{! but we may as well use the NodeName and ServiceName }}
{{! We only really need meta to get the correct ServiceID }} {{! from meta also, but they should be the same as the instance }}
{{! but we may as well use the NodeName and ServiceName }} {{! so if we can ever get ServiceID from elsewhere we could save }}
{{! from meta also, but they should be the same as the instance }} {{! a HTTP request/long poll here }}
{{! so if we can ever get ServiceID from elsewhere we could save }} {{#if meta.data.ServiceID}}
{{! a HTTP request/long poll here }} {{! if we have a proxy then get the additional instance information }}
{{#if meta.data.ServiceID}} {{! for the proxy itself so if the service is called `backend` }}
{{! if we have a proxy then get the additional instance information }} {{! its likely to have a proxy service called `backend-sidecar-proxy` }}
{{! for the proxy itself so if the service is called `backend` }} {{! and this second request get the info for that instance and saves }}
{{! its likely to have a proxy service called `backend-sidecar-proxy` }} {{! it into the `proxy` variable }}
{{! and this second request get the info for that instance and saves }} <DataSource
{{! it into the `proxy` variable }} @src={{uri
<DataSource '/${partition}/${nspace}/${dc}/service-instance/${id}/${node}/${name}/${peer}'
@src={{uri '/${partition}/${nspace}/${dc}/service-instance/${id}/${node}/${name}/${peer}' (hash
(hash partition=route.params.partition
partition=route.params.partition nspace=route.params.nspace
nspace=route.params.nspace dc=route.params.dc
dc=route.params.dc id=meta.data.ServiceID
id=meta.data.ServiceID node=meta.data.NodeName
node=meta.data.NodeName name=meta.data.ServiceName
name=meta.data.ServiceName peer=route.params.peer
peer=route.params.peer )
) }}
}} @onchange={{action (mut proxy) value='data'}}
@onchange={{action (mut proxy) value="data"}} />
/> {{/if}}
{{/if}} </DataSource>
</DataSource> {{/if}}
{{/if}} <AppView>
<AppView> <BlockSlot @name='breadcrumbs'>
<BlockSlot @name="breadcrumbs"> <ol>
<ol> <li><a href={{href-to 'dc.services' params=(hash peer=undefined)}}>All Services</a></li>
<li><a href={{href-to 'dc.services' params=(hash peer=undefined)}}>All Services</a></li> <li><a
<li><a {{tooltip (concat "Service (" item.Service.Service ")")}} data-test-back href={{href-to 'dc.services.show'}}> {{tooltip (concat 'Service (' item.Service.Service ')')}}
Service ({{item.Service.Service}}) data-test-back
</a></li> href={{href-to 'dc.services.show'}}
</ol> >
Service ({{item.Service.Service}})
</a></li>
</ol>
</BlockSlot> </BlockSlot>
<BlockSlot @name="header"> <BlockSlot @name='header'>
<h1> <h1>
<route.Title @title={{item.Service.ID}} /> <route.Title @title={{item.Service.ID}} />
</h1> </h1>
@ -146,15 +133,20 @@ as |item|}}
<Consul::TransparentProxy /> <Consul::TransparentProxy />
{{/if}} {{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="nav"> <BlockSlot @name='nav'>
<dl> <dl>
<dt>Service Name</dt> <dt>Service Name</dt>
<dd><a href="{{href-to 'dc.services.show' item.Service.Service}}">{{item.Service.Service}}</a></dd> <dd><a
href='{{href-to "dc.services.show" item.Service.Service}}'
>{{item.Service.Service}}</a></dd>
</dl> </dl>
{{#unless item.Node.Meta.synthetic-node}} {{#unless item.Node.Meta.synthetic-node}}
<dl> <dl>
<dt>Node Name</dt> <dt>Node Name</dt>
<dd><a data-test-service-instance-node-name href="{{href-to 'dc.nodes.show' item.Node.Node}}">{{item.Node.Node}}</a></dd> <dd><a
data-test-service-instance-node-name
href='{{href-to "dc.nodes.show" item.Node.Node}}'
>{{item.Node.Node}}</a></dd>
</dl> </dl>
{{/unless}} {{/unless}}
{{#if item.Service.PeerName}} {{#if item.Service.PeerName}}
@ -164,36 +156,62 @@ as |item|}}
</dl> </dl>
{{/if}} {{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions"> <BlockSlot @name='actions'>
{{#let (or item.Service.Address item.Node.Address) as |address|}} {{#let (or item.Service.Address item.Node.Address) as |address|}}
<CopyButton @value={{address}} @name="Address">{{address}}</CopyButton> <CopyButton @value={{address}} @name='Address'>{{address}}</CopyButton>
{{/let}} {{/let}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="content"> <BlockSlot @name='content'>
<TabNav @items={{ <TabNav
compact @items={{compact
(array (array
(hash label="Health Checks" href=(href-to "dc.services.instance.healthchecks") selected=(is-href "dc.services.instance.healthchecks")) (hash
(if (eq item.Service.Kind 'mesh-gateway') (hash label="Addresses" href=(href-to "dc.services.instance.addresses") selected=(is-href "dc.services.instance.addresses"))) label='Health Checks'
(if proxy (hash label="Upstreams" href=(href-to "dc.services.instance.upstreams") selected=(is-href "dc.services.instance.upstreams"))) href=(href-to 'dc.services.instance.healthchecks')
(if proxy (hash label="Exposed Paths" href=(href-to "dc.services.instance.exposedpaths") selected=(is-href "dc.services.instance.exposedpaths"))) selected=(is-href 'dc.services.instance.healthchecks')
(hash label="Tags & Meta" href=(href-to "dc.services.instance.metadata") selected=(is-href "dc.services.instance.metadata"))
) )
(if
(eq item.Service.Kind 'mesh-gateway')
(hash
label='Addresses'
href=(href-to 'dc.services.instance.addresses')
selected=(is-href 'dc.services.instance.addresses')
)
)
(if
proxy
(hash
label='Upstreams'
href=(href-to 'dc.services.instance.upstreams')
selected=(is-href 'dc.services.instance.upstreams')
)
)
(if
proxy
(hash
label='Exposed Paths'
href=(href-to 'dc.services.instance.exposedpaths')
selected=(is-href 'dc.services.instance.exposedpaths')
)
)
(hash
label='Tags & Meta'
href=(href-to 'dc.services.instance.metadata')
selected=(is-href 'dc.services.instance.metadata')
)
)
}} }}
/> />
<Outlet <Outlet
@name={{routeName}} @name={{routeName}}
@model={{assign (hash @model={{assign (hash proxy=proxy meta=meta item=item) route.model}}
proxy=proxy as |o|
meta=meta >
item=item
) route.model}}
as |o|>
{{outlet}} {{outlet}}
</Outlet> </Outlet>
</BlockSlot> </BlockSlot>
</AppView> </AppView>
{{/let}} {{/let}}
</BlockSlot> </BlockSlot>
</DataLoader> </DataLoader>
</Route> </Route>