158 lines
4.3 KiB
TypeScript
158 lines
4.3 KiB
TypeScript
import {
|
|
DeesElement,
|
|
customElement,
|
|
html,
|
|
css,
|
|
cssManager,
|
|
property,
|
|
type TemplateResult,
|
|
} from '@design.estate/dees-element';
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'sz-certificates-card': SzCertificatesCard;
|
|
}
|
|
}
|
|
|
|
@customElement('sz-certificates-card')
|
|
export class SzCertificatesCard extends DeesElement {
|
|
public static demo = () => html`
|
|
<div style="padding: 24px; display: flex; gap: 16px; flex-wrap: wrap;">
|
|
<sz-certificates-card validCount="2"></sz-certificates-card>
|
|
<sz-certificates-card validCount="5" expiringCount="2"></sz-certificates-card>
|
|
<sz-certificates-card validCount="0" expiredCount="1"></sz-certificates-card>
|
|
</div>
|
|
`;
|
|
|
|
public static demoGroups = ['Network'];
|
|
|
|
@property({ type: Number })
|
|
public accessor validCount: number = 0;
|
|
|
|
@property({ type: Number })
|
|
public accessor expiringCount: number = 0;
|
|
|
|
@property({ type: Number })
|
|
public accessor expiredCount: number = 0;
|
|
|
|
public static styles = [
|
|
cssManager.defaultStyles,
|
|
css`
|
|
:host {
|
|
display: block;
|
|
min-width: 200px;
|
|
height: 100%;
|
|
}
|
|
|
|
.card {
|
|
background: ${cssManager.bdTheme('#ffffff', '#09090b')};
|
|
border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
height: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.header {
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.title {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
color: ${cssManager.bdTheme('#18181b', '#fafafa')};
|
|
}
|
|
|
|
.subtitle {
|
|
font-size: 13px;
|
|
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.status-icon {
|
|
width: 20px;
|
|
height: 20px;
|
|
}
|
|
|
|
.status-icon.valid {
|
|
color: ${cssManager.bdTheme('#22c55e', '#22c55e')};
|
|
}
|
|
|
|
.status-icon.warning {
|
|
color: ${cssManager.bdTheme('#facc15', '#facc15')};
|
|
}
|
|
|
|
.status-icon.error {
|
|
color: ${cssManager.bdTheme('#ef4444', '#ef4444')};
|
|
}
|
|
|
|
.status-text {
|
|
font-size: 14px;
|
|
color: ${cssManager.bdTheme('#18181b', '#fafafa')};
|
|
}
|
|
|
|
.status-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
`,
|
|
];
|
|
|
|
public render(): TemplateResult {
|
|
return html`
|
|
<div class="card">
|
|
<div class="header">
|
|
<div class="title">Certificates</div>
|
|
<div class="subtitle">SSL/TLS certificate status</div>
|
|
</div>
|
|
|
|
<div class="status-list">
|
|
${this.validCount > 0 ? html`
|
|
<div class="status">
|
|
<svg class="status-icon valid" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<polyline points="20 6 9 17 4 12"></polyline>
|
|
</svg>
|
|
<span class="status-text">${this.validCount} valid</span>
|
|
</div>
|
|
` : ''}
|
|
|
|
${this.expiringCount > 0 ? html`
|
|
<div class="status">
|
|
<svg class="status-icon warning" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
|
|
<line x1="12" y1="9" x2="12" y2="13"></line>
|
|
<line x1="12" y1="17" x2="12.01" y2="17"></line>
|
|
</svg>
|
|
<span class="status-text">${this.expiringCount} expiring soon</span>
|
|
</div>
|
|
` : ''}
|
|
|
|
${this.expiredCount > 0 ? html`
|
|
<div class="status">
|
|
<svg class="status-icon error" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<circle cx="12" cy="12" r="10"></circle>
|
|
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
</svg>
|
|
<span class="status-text">${this.expiredCount} expired</span>
|
|
</div>
|
|
` : ''}
|
|
|
|
${this.validCount === 0 && this.expiringCount === 0 && this.expiredCount === 0 ? html`
|
|
<div class="status">
|
|
<span class="status-text">No certificates</span>
|
|
</div>
|
|
` : ''}
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|