web/admin: better show metadata download for saml provider

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-12-19 10:54:51 +01:00
parent 3b973e12a4
commit 39e0ed2962
1 changed files with 48 additions and 21 deletions

View File

@ -75,32 +75,59 @@ export class SAMLProviderViewPage extends AKElement {
} }
async renderRelatedObjects(): Promise<TemplateResult> { async renderRelatedObjects(): Promise<TemplateResult> {
if (!this.provider?.signingKp) { const relatedObjects = [];
return Promise.resolve(html``); if (this.provider?.assignedApplicationName) {
relatedObjects.push(html`<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text">${t`Metadata`}</span>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
<a
class="pf-c-button pf-m-primary"
target="_blank"
href=${ifDefined(this.provider?.urlDownloadMetadata)}
>
${t`Download`}
</a>
<ak-action-button
class="pf-m-secondary"
.apiRequest=${() => {
return navigator.clipboard.writeText(
this.provider?.urlDownloadMetadata || "",
);
}}
>
${t`Copy download URL`}
</ak-action-button>
</div>
</dd>
</div>`);
}
if (this.provider?.signingKp) {
const kp = await new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsRetrieve({
kpUuid: this.provider.signingKp,
});
relatedObjects.push(html`<div class="pf-c-description-list__group">
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text"
>${t`Download signing certificate`}</span
>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
<a class="pf-c-button pf-m-primary" href=${kp.certificateDownloadUrl}
>${t`Download`}</a
>
</div>
</dd>
</div>`);
} }
const kp = await new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsRetrieve({
kpUuid: this.provider.signingKp,
});
return html` <div class="pf-c-card pf-l-grid__item pf-m-12-col"> return html` <div class="pf-c-card pf-l-grid__item pf-m-12-col">
<div class="pf-c-card__title">${t`Related objects`}</div> <div class="pf-c-card__title">${t`Related objects`}</div>
<div class="pf-c-card__body"> <div class="pf-c-card__body">
<dl class="pf-c-description-list pf-m-2-col"> <dl class="pf-c-description-list pf-m-2-col">
<div class="pf-c-description-list__group"> ${relatedObjects.length > 0 ? relatedObjects : html`-`}
<dt class="pf-c-description-list__term">
<span class="pf-c-description-list__text"
>${t`Download signing certificate`}</span
>
</dt>
<dd class="pf-c-description-list__description">
<div class="pf-c-description-list__text">
<a
class="pf-c-button pf-m-primary"
href=${kp.certificateDownloadUrl}
>${t`Download`}</a
>
</div>
</dd>
</div>
</dl> </dl>
</div> </div>
</div>`; </div>`;