2025-06-30 00:17:43 +00:00
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
property,
|
|
|
|
|
html,
|
|
|
|
|
customElement,
|
|
|
|
|
type TemplateResult,
|
|
|
|
|
css,
|
|
|
|
|
cssManager,
|
|
|
|
|
unsafeCSS,
|
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
import * as domtools from '@design.estate/dees-domtools';
|
2025-12-23 09:26:37 +00:00
|
|
|
import * as sharedStyles from '../styles/shared.styles.js';
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
import './internal/uplinternal-miniheading.js';
|
|
|
|
|
import { demoFunc } from './upl-statuspage-statsgrid.demo.js';
|
|
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
|
'upl-statuspage-statsgrid': UplStatuspageStatsgrid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@customElement('upl-statuspage-statsgrid')
|
|
|
|
|
export class UplStatuspageStatsgrid extends DeesElement {
|
|
|
|
|
public static demo = demoFunc;
|
|
|
|
|
|
|
|
|
|
@property({ type: Number })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor uptime: number = 99.99;
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: Number })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor avgResponseTime: number = 125;
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: Number })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor totalIncidents: number = 0;
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: Number })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor affectedServices: number = 0;
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: Number })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor totalServices: number = 0;
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: String })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor currentStatus: string = 'operational';
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: Boolean })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor loading: boolean = false;
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
@property({ type: String })
|
2025-12-23 09:26:37 +00:00
|
|
|
accessor timePeriod: string = '90 days';
|
2025-06-30 00:17:43 +00:00
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
|
domtools.elementBasic.staticStyles,
|
2025-12-23 09:26:37 +00:00
|
|
|
sharedStyles.commonStyles,
|
2025-06-30 00:17:43 +00:00
|
|
|
css`
|
|
|
|
|
:host {
|
|
|
|
|
display: block;
|
|
|
|
|
background: transparent;
|
2025-12-23 09:26:37 +00:00
|
|
|
font-family: ${unsafeCSS(sharedStyles.fonts.base)};
|
|
|
|
|
color: ${sharedStyles.colors.text.primary};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.container {
|
|
|
|
|
max-width: 1200px;
|
|
|
|
|
margin: 0 auto;
|
2025-12-23 09:26:37 +00:00
|
|
|
padding: 0 ${unsafeCSS(sharedStyles.spacing.lg)} ${unsafeCSS(sharedStyles.spacing.lg)} ${unsafeCSS(sharedStyles.spacing.lg)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stats-grid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
2025-12-23 09:26:37 +00:00
|
|
|
gap: ${unsafeCSS(sharedStyles.spacing.md)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-card {
|
|
|
|
|
background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
|
|
|
|
|
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
2025-12-23 09:26:37 +00:00
|
|
|
border-radius: ${unsafeCSS(sharedStyles.borderRadius.base)};
|
|
|
|
|
padding: ${unsafeCSS(sharedStyles.spacing.lg)};
|
2025-06-30 00:17:43 +00:00
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-card:hover {
|
|
|
|
|
border-color: ${cssManager.bdTheme('#d1d5db', '#3f3f46')};
|
|
|
|
|
box-shadow: ${cssManager.bdTheme(
|
|
|
|
|
'0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
|
|
|
|
'0 0 0 1px rgba(255, 255, 255, 0.1)'
|
|
|
|
|
)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-label {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: ${cssManager.bdTheme('#6b7280', '#a1a1aa')};
|
|
|
|
|
text-transform: uppercase;
|
|
|
|
|
letter-spacing: 0.05em;
|
|
|
|
|
font-weight: 500;
|
2025-12-23 09:26:37 +00:00
|
|
|
margin-bottom: ${unsafeCSS(sharedStyles.spacing.sm)};
|
2025-06-30 00:17:43 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2025-12-23 09:26:37 +00:00
|
|
|
gap: ${unsafeCSS(sharedStyles.spacing.xs)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-value {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: ${cssManager.bdTheme('#0a0a0a', '#fafafa')};
|
|
|
|
|
font-variant-numeric: tabular-nums;
|
|
|
|
|
line-height: 1.2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-unit {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: ${cssManager.bdTheme('#6b7280', '#a1a1aa')};
|
|
|
|
|
margin-left: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-change {
|
|
|
|
|
font-size: 12px;
|
2025-12-23 09:26:37 +00:00
|
|
|
margin-top: ${unsafeCSS(sharedStyles.spacing.xs)};
|
2025-06-30 00:17:43 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-change.positive {
|
|
|
|
|
color: ${cssManager.bdTheme('#10b981', '#10b981')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-change.negative {
|
|
|
|
|
color: ${cssManager.bdTheme('#ef4444', '#ef4444')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-change.neutral {
|
|
|
|
|
color: ${cssManager.bdTheme('#6b7280', '#a1a1aa')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.loading-skeleton {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
2025-12-23 09:26:37 +00:00
|
|
|
gap: ${unsafeCSS(sharedStyles.spacing.md)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.skeleton-card {
|
|
|
|
|
background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')};
|
|
|
|
|
border: 1px solid ${cssManager.bdTheme('#e5e7eb', '#27272a')};
|
2025-12-23 09:26:37 +00:00
|
|
|
border-radius: ${unsafeCSS(sharedStyles.borderRadius.base)};
|
|
|
|
|
padding: ${unsafeCSS(sharedStyles.spacing.lg)};
|
2025-06-30 00:17:43 +00:00
|
|
|
height: 100px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.skeleton-label {
|
|
|
|
|
height: 14px;
|
|
|
|
|
width: 80px;
|
|
|
|
|
background: ${cssManager.bdTheme('#f3f4f6', '#27272a')};
|
|
|
|
|
border-radius: 4px;
|
2025-12-23 09:26:37 +00:00
|
|
|
margin-bottom: ${unsafeCSS(sharedStyles.spacing.sm)};
|
2025-06-30 00:17:43 +00:00
|
|
|
animation: pulse 2s infinite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.skeleton-value {
|
|
|
|
|
height: 28px;
|
|
|
|
|
width: 120px;
|
|
|
|
|
background: ${cssManager.bdTheme('#f3f4f6', '#27272a')};
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
animation: pulse 2s infinite;
|
|
|
|
|
animation-delay: 0.1s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes pulse {
|
|
|
|
|
0%, 100% { opacity: 1; }
|
|
|
|
|
50% { opacity: 0.5; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-indicator {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: 6px;
|
|
|
|
|
height: 6px;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-indicator.operational {
|
2025-12-23 09:26:37 +00:00
|
|
|
background: ${sharedStyles.colors.status.operational};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-indicator.degraded {
|
2025-12-23 09:26:37 +00:00
|
|
|
background: ${sharedStyles.colors.status.degraded};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-indicator.partial_outage {
|
2025-12-23 09:26:37 +00:00
|
|
|
background: ${sharedStyles.colors.status.partial};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-indicator.major_outage {
|
2025-12-23 09:26:37 +00:00
|
|
|
background: ${sharedStyles.colors.status.major};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-indicator.maintenance {
|
2025-12-23 09:26:37 +00:00
|
|
|
background: ${sharedStyles.colors.status.maintenance};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 640px) {
|
|
|
|
|
.container {
|
2025-12-23 09:26:37 +00:00
|
|
|
padding: 0 ${unsafeCSS(sharedStyles.spacing.md)} ${unsafeCSS(sharedStyles.spacing.md)} ${unsafeCSS(sharedStyles.spacing.md)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stats-grid {
|
|
|
|
|
grid-template-columns: 1fr;
|
2025-12-23 09:26:37 +00:00
|
|
|
gap: ${unsafeCSS(sharedStyles.spacing.sm)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-card {
|
2025-12-23 09:26:37 +00:00
|
|
|
padding: ${unsafeCSS(sharedStyles.spacing.md)};
|
2025-06-30 00:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-value {
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
|
return html`
|
|
|
|
|
<div class="container">
|
|
|
|
|
${this.loading ? html`
|
|
|
|
|
<div class="loading-skeleton">
|
|
|
|
|
${Array(4).fill(0).map(() => html`
|
|
|
|
|
<div class="skeleton-card">
|
|
|
|
|
<div class="skeleton-label"></div>
|
|
|
|
|
<div class="skeleton-value"></div>
|
|
|
|
|
</div>
|
|
|
|
|
`)}
|
|
|
|
|
</div>
|
|
|
|
|
` : html`
|
|
|
|
|
<div class="stats-grid">
|
|
|
|
|
<div class="stat-card">
|
|
|
|
|
<div class="stat-label">
|
|
|
|
|
<span class="status-indicator ${this.currentStatus}"></span>
|
|
|
|
|
Current Status
|
|
|
|
|
</div>
|
|
|
|
|
<div class="stat-value">
|
|
|
|
|
${this.formatStatus(this.currentStatus)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="stat-card">
|
|
|
|
|
<div class="stat-label">Uptime</div>
|
|
|
|
|
<div class="stat-value">
|
|
|
|
|
${this.uptime.toFixed(2)}<span class="stat-unit">%</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="stat-change neutral">
|
|
|
|
|
Last ${this.timePeriod}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="stat-card">
|
|
|
|
|
<div class="stat-label">Avg Response Time</div>
|
|
|
|
|
<div class="stat-value">
|
|
|
|
|
${this.avgResponseTime}<span class="stat-unit">ms</span>
|
|
|
|
|
</div>
|
|
|
|
|
${this.renderResponseChange()}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="stat-card">
|
|
|
|
|
<div class="stat-label">Incidents</div>
|
|
|
|
|
<div class="stat-value">
|
|
|
|
|
${this.totalIncidents}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="stat-change neutral">
|
|
|
|
|
${this.affectedServices} of ${this.totalServices} services
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`}
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private formatStatus(status: string): string {
|
|
|
|
|
const statusMap: Record<string, string> = {
|
|
|
|
|
operational: 'Operational',
|
|
|
|
|
degraded: 'Degraded',
|
|
|
|
|
partial_outage: 'Partial Outage',
|
|
|
|
|
major_outage: 'Major Outage',
|
|
|
|
|
maintenance: 'Maintenance',
|
|
|
|
|
};
|
|
|
|
|
return statusMap[status] || 'Unknown';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderResponseChange(): TemplateResult {
|
|
|
|
|
// This could be enhanced with actual trend data
|
|
|
|
|
const trend = this.avgResponseTime < 200 ? 'positive' : this.avgResponseTime > 500 ? 'negative' : 'neutral';
|
|
|
|
|
const icon = trend === 'positive' ? '↓' : trend === 'negative' ? '↑' : '→';
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<div class="stat-change ${trend}">
|
|
|
|
|
<span>${icon}</span>
|
|
|
|
|
<span>${trend === 'positive' ? 'Fast' : trend === 'negative' ? 'Slow' : 'Normal'}</span>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
}
|