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,8 +1,7 @@
<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
'/${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
@ -13,24 +12,21 @@ as |route|>
peer=route.params.peer 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,15 +61,12 @@ as |route|>
{{/if}} {{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="loaded"> <BlockSlot @name='loaded'>
{{#let {{#let loader.data as |item|}}
loader.data
as |item|}}
{{#if item.IsOrigin}} {{#if item.IsOrigin}}
<DataSource <DataSource
@src={{uri '/${partition}/${nspace}/${dc}/proxy-instance/${id}/${node}/${name}' @src={{uri
'/${partition}/${nspace}/${dc}/proxy-instance/${id}/${node}/${name}'
(hash (hash
partition=route.params.partition partition=route.params.partition
nspace=route.params.nspace nspace=route.params.nspace
@ -95,8 +76,9 @@ as |item|}}
name=route.params.name name=route.params.name
) )
}} }}
@onchange={{action (mut meta) value="data"}} @onchange={{action (mut meta) value='data'}}
as |meta|> as |meta|
>
{{! We only really need meta to get the correct ServiceID }} {{! We only really need meta to get the correct ServiceID }}
{{! but we may as well use the NodeName and ServiceName }} {{! but we may as well use the NodeName and ServiceName }}
{{! from meta also, but they should be the same as the instance }} {{! from meta also, but they should be the same as the instance }}
@ -109,7 +91,8 @@ as |item|}}
{{! and this second request get the info for that instance and saves }} {{! and this second request get the info for that instance and saves }}
{{! it into the `proxy` variable }} {{! it into the `proxy` variable }}
<DataSource <DataSource
@src={{uri '/${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
@ -120,21 +103,25 @@ as |item|}}
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 {{tooltip (concat "Service (" item.Service.Service ")")}} data-test-back href={{href-to 'dc.services.show'}}> <li><a
{{tooltip (concat 'Service (' item.Service.Service ')')}}
data-test-back
href={{href-to 'dc.services.show'}}
>
Service ({{item.Service.Service}}) Service ({{item.Service.Service}})
</a></li> </a></li>
</ol> </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>