@littlebearapps/platform-admin-sdk 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/dist/templates.d.ts +1 -1
- package/dist/templates.js +121 -3
- package/package.json +1 -1
- package/templates/full/dashboard/src/components/notifications/NotificationDropdown.tsx +130 -0
- package/templates/full/dashboard/src/components/notifications/NotificationItem.tsx +264 -0
- package/templates/full/dashboard/src/components/patterns/PatternInfoButton.tsx +60 -0
- package/templates/full/dashboard/src/components/reports/FeatureUsageReport.tsx +339 -0
- package/templates/full/dashboard/src/components/search/SearchResultGroup.tsx +46 -0
- package/templates/full/dashboard/src/components/search/SearchResultItem.tsx +212 -0
- package/templates/full/dashboard/src/pages/api/patterns/[id]/approve.ts +49 -0
- package/templates/full/dashboard/src/pages/api/patterns/[id]/reject.ts +50 -0
- package/templates/full/dashboard/src/pages/api/reports/digests/stats.ts +38 -0
- package/templates/full/dashboard/src/pages/api/reports/digests.ts +39 -0
- package/templates/full/dashboard/src/pages/api/search/reindex/[type].ts +56 -0
- package/templates/full/dashboard/src/pages/api/test-reports/[id].ts +102 -0
- package/templates/full/dashboard/src/pages/feedback.astro +365 -0
- package/templates/full/dashboard/src/pages/kiosk.astro +206 -0
- package/templates/full/dashboard/src/pages/map.astro +561 -0
- package/templates/full/dashboard/src/pages/revenue.astro +72 -0
- package/templates/full/dashboard/src/pages/tests.astro +431 -0
- package/templates/full/scripts/ops/audit-cost-anomaly.ts +430 -0
- package/templates/full/scripts/ops/verify-account-total.ts +256 -0
- package/templates/full/tests/integration/feedback-schema.test.ts +361 -0
- package/templates/full/tests/integration/r2-archive.test.ts +108 -0
- package/templates/shared/.github/workflows/dependabot-automerge.yml +41 -0
- package/templates/shared/.github/workflows/validate-controls.yml +27 -0
- package/templates/shared/dashboard/src/components/Breadcrumbs.astro +101 -0
- package/templates/shared/dashboard/src/components/EmptyState.astro +46 -0
- package/templates/shared/dashboard/src/components/ErrorBoundary.astro +79 -0
- package/templates/shared/dashboard/src/components/LoadingSkeleton.astro +105 -0
- package/templates/shared/dashboard/src/components/PageShell.astro +72 -0
- package/templates/shared/dashboard/src/components/SkipLinks.astro +22 -0
- package/templates/shared/dashboard/src/components/Toast.astro +170 -0
- package/templates/shared/dashboard/src/components/ToastContainer.astro +156 -0
- package/templates/shared/dashboard/src/components/costs/ProviderCostsGrid.tsx +401 -0
- package/templates/shared/dashboard/src/components/costs/index.ts +4 -0
- package/templates/shared/dashboard/src/components/overview/AlertBanner.tsx +94 -0
- package/templates/shared/dashboard/src/components/overview/index.ts +9 -0
- package/templates/shared/dashboard/src/components/resources/CostChart.tsx +170 -0
- package/templates/shared/dashboard/src/components/resources/ProviderCard.tsx +272 -0
- package/templates/shared/dashboard/src/components/resources/ProviderDetail.tsx +293 -0
- package/templates/shared/dashboard/src/components/settings/SettingsCard.astro +102 -0
- package/templates/shared/dashboard/src/components/usage/AllowanceGauge.astro +170 -0
- package/templates/shared/dashboard/src/components/usage/AnomalyAlerts.astro +633 -0
- package/templates/shared/dashboard/src/components/usage/BillingCycleCountdown.astro +192 -0
- package/templates/shared/dashboard/src/components/usage/BurnRateHero.astro +539 -0
- package/templates/shared/dashboard/src/components/usage/CircuitBreakerEventLog.astro +542 -0
- package/templates/shared/dashboard/src/components/usage/CircuitBreakerPanel.tsx +292 -0
- package/templates/shared/dashboard/src/components/usage/CircuitBreakerStatus.astro +669 -0
- package/templates/shared/dashboard/src/components/usage/CompactThresholdBanner.astro +531 -0
- package/templates/shared/dashboard/src/components/usage/ComparisonModeSelector.astro +651 -0
- package/templates/shared/dashboard/src/components/usage/CostBreakdownChart.astro +381 -0
- package/templates/shared/dashboard/src/components/usage/CostBreakdownTable.astro +210 -0
- package/templates/shared/dashboard/src/components/usage/CostDataTable.astro +0 -0
- package/templates/shared/dashboard/src/components/usage/CostDonutChart.astro +311 -0
- package/templates/shared/dashboard/src/components/usage/DailyCostChart.astro +632 -0
- package/templates/shared/dashboard/src/components/usage/ExportButton.astro +114 -0
- package/templates/shared/dashboard/src/components/usage/FeatureBudgetsTable.astro +872 -0
- package/templates/shared/dashboard/src/components/usage/FilterBar.astro +190 -0
- package/templates/shared/dashboard/src/components/usage/FilterToggles.astro +175 -0
- package/templates/shared/dashboard/src/components/usage/GitHubUsageCard.astro +537 -0
- package/templates/shared/dashboard/src/components/usage/OverageCostCard.astro +212 -0
- package/templates/shared/dashboard/src/components/usage/PlanUtilizationCard.astro +193 -0
- package/templates/shared/dashboard/src/components/usage/ProjectCard.astro +640 -0
- package/templates/shared/dashboard/src/components/usage/ProjectCardsGrid.astro +272 -0
- package/templates/shared/dashboard/src/components/usage/ResourceSearch.astro +279 -0
- package/templates/shared/dashboard/src/components/usage/ServiceUtilizationList.astro +604 -0
- package/templates/shared/dashboard/src/components/usage/SparklineCard.astro +399 -0
- package/templates/shared/dashboard/src/components/usage/StatsHero.astro +600 -0
- package/templates/shared/dashboard/src/components/usage/TableFilters.astro +1033 -0
- package/templates/shared/dashboard/src/components/usage/ThresholdAlert.astro +271 -0
- package/templates/shared/dashboard/src/components/usage/ThresholdSettings.astro +618 -0
- package/templates/shared/dashboard/src/components/usage/TopSpenderCard.astro +170 -0
- package/templates/shared/dashboard/src/components/usage/UnifiedResourceTable.astro +1737 -0
- package/templates/shared/dashboard/src/components/usage/UsageCard.astro +135 -0
- package/templates/shared/dashboard/src/components/usage/UsageHealthBanner.astro +387 -0
- package/templates/shared/dashboard/src/components/usage/UtilizationBar.astro +159 -0
- package/templates/shared/dashboard/src/components/usage/WorkersBreakdownTable.astro +659 -0
- package/templates/shared/dashboard/src/components/usage/daily/CostChart.astro +461 -0
- package/templates/shared/dashboard/src/components/usage/daily/CostTable.astro +946 -0
- package/templates/shared/dashboard/src/components/usage/daily/DailyOverview.astro +1079 -0
- package/templates/shared/dashboard/src/components/usage/design-tokens.ts +187 -0
- package/templates/shared/dashboard/src/components/usage/filters/InlineDateRange.astro +285 -0
- package/templates/shared/dashboard/src/components/usage/filters/PeriodButtons.astro +157 -0
- package/templates/shared/dashboard/src/components/usage/filters/ProjectSelect.astro +284 -0
- package/templates/shared/dashboard/src/components/usage/scripts/ai-tab-controller.ts +419 -0
- package/templates/shared/dashboard/src/components/usage/scripts/constants.ts +60 -0
- package/templates/shared/dashboard/src/components/usage/scripts/formatters.ts +62 -0
- package/templates/shared/dashboard/src/components/usage/scripts/overview-controller.ts +1633 -0
- package/templates/shared/dashboard/src/components/usage/scripts/resource-table-builder.ts +294 -0
- package/templates/shared/dashboard/src/components/usage/scripts/tabs-filters-controller.ts +464 -0
- package/templates/shared/dashboard/src/components/usage/state/index.ts +55 -0
- package/templates/shared/dashboard/src/components/usage/state/usageActions.ts +439 -0
- package/templates/shared/dashboard/src/components/usage/state/usageStore.ts +376 -0
- package/templates/shared/dashboard/src/components/usage/types.ts +283 -0
- package/templates/shared/dashboard/src/components/usage/usage-colors.ts +292 -0
- package/templates/shared/dashboard/src/pages/api/usage/ai-models.ts +235 -0
- package/templates/shared/dashboard/src/pages/api/usage/billing-context.ts +296 -0
- package/templates/shared/scripts/test-telemetry-flow.ts +464 -0
- package/templates/shared/tests/e2e/usage-export.test.ts +784 -0
- package/templates/shared/tests/e2e/usage-mobile.test.ts +531 -0
- package/templates/standard/dashboard/src/components/errors/PriorityBadge.astro +27 -0
- package/templates/standard/dashboard/src/components/infrastructure/HealthchecksStatus.tsx +293 -0
- package/templates/standard/dashboard/src/components/infrastructure/InfrastructureTabs.tsx +268 -0
- package/templates/standard/dashboard/src/pages/analytics.astro +64 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/alerts.ts +85 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/healthchecks/[id]/flips.ts +110 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/healthchecks.ts +101 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/uptime/[id]/response-times.ts +121 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/uptime.ts +89 -0
- package/templates/standard/dashboard/src/pages/api/test/service-auth.ts +178 -0
- package/templates/standard/tests/integration/connectors.test.ts +241 -0
- package/templates/standard/tests/integration/github-monitor.test.ts +143 -0
- package/templates/standard/tests/integration/ingestion.test.ts +211 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* ServiceUtilizationList - Service metrics table with utilization bars
|
|
4
|
+
*
|
|
5
|
+
* Displays a list of services with:
|
|
6
|
+
* - Service name and icon
|
|
7
|
+
* - Current usage vs limit
|
|
8
|
+
* - Utilisation bar with percentage
|
|
9
|
+
* - Cost estimate
|
|
10
|
+
* - Overage details (if applicable)
|
|
11
|
+
*/
|
|
12
|
+
import type { UtilizationStatus } from './types';
|
|
13
|
+
import UtilizationBar from './UtilizationBar.astro';
|
|
14
|
+
import { formatLargeNumber, formatCurrency } from './types';
|
|
15
|
+
|
|
16
|
+
interface ResourceMetric {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
provider: 'cloudflare' | 'github';
|
|
20
|
+
current: number;
|
|
21
|
+
limit: number | null;
|
|
22
|
+
unit: string;
|
|
23
|
+
percentage: number;
|
|
24
|
+
costEstimate: number;
|
|
25
|
+
status: UtilizationStatus;
|
|
26
|
+
overage: number;
|
|
27
|
+
overageCost: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Props {
|
|
31
|
+
/** Title for the section */
|
|
32
|
+
title: string;
|
|
33
|
+
/** Provider type */
|
|
34
|
+
provider: 'cloudflare' | 'github';
|
|
35
|
+
/** Array of service metrics */
|
|
36
|
+
services?: ResourceMetric[];
|
|
37
|
+
/** Show overage column */
|
|
38
|
+
showOverage?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { title, provider, services = [], showOverage = true } = Astro.props;
|
|
42
|
+
|
|
43
|
+
const providerIcons: Record<string, Record<string, string>> = {
|
|
44
|
+
cloudflare: {
|
|
45
|
+
'cf-workers': '⚡',
|
|
46
|
+
'cf-d1': '🗄️',
|
|
47
|
+
'cf-kv': '🔑',
|
|
48
|
+
'cf-r2': '📦',
|
|
49
|
+
'cf-do': '🔗',
|
|
50
|
+
'cf-vectorize': '🧮',
|
|
51
|
+
'cf-workers-ai': '🤖',
|
|
52
|
+
'cf-queues': '📬',
|
|
53
|
+
'cf-ai-gateway': '🌐',
|
|
54
|
+
},
|
|
55
|
+
github: {
|
|
56
|
+
'gh-actions-minutes': '⏱️',
|
|
57
|
+
'gh-actions-storage': '💾',
|
|
58
|
+
'gh-ghas-code': '🔍',
|
|
59
|
+
'gh-ghas-secrets': '🔐',
|
|
60
|
+
'gh-ghec': '👥',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getIcon = (id: string, prov: string): string => {
|
|
65
|
+
return providerIcons[prov]?.[id] ?? '📊';
|
|
66
|
+
};
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
<div class="service-list-section" id={`service-list-${provider}`} data-provider={provider}>
|
|
70
|
+
<h3 class="section-title">{title}</h3>
|
|
71
|
+
|
|
72
|
+
{/* Empty state - shown when no services, hidden by JS when populated */}
|
|
73
|
+
<div
|
|
74
|
+
class="empty-state"
|
|
75
|
+
id={`service-list-empty-${provider}`}
|
|
76
|
+
style={services.length > 0 ? 'display: none;' : ''}
|
|
77
|
+
>
|
|
78
|
+
<span class="empty-icon">📭</span>
|
|
79
|
+
<p>No services with usage data</p>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
{/* Table structure - always rendered but hidden when empty */}
|
|
83
|
+
<div
|
|
84
|
+
class="service-table"
|
|
85
|
+
id={`service-list-table-${provider}`}
|
|
86
|
+
style={services.length === 0 ? 'display: none;' : ''}
|
|
87
|
+
>
|
|
88
|
+
<div class="table-header">
|
|
89
|
+
<span class="col-service">Service</span>
|
|
90
|
+
<span class="col-usage">Usage</span>
|
|
91
|
+
<span class="col-utilization">Utilisation</span>
|
|
92
|
+
<span class="col-cost">Cost</span>
|
|
93
|
+
{showOverage && <span class="col-overage">Overage</span>}
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<div class="table-body" id={`service-list-body-${provider}`}>
|
|
97
|
+
{
|
|
98
|
+
services.map((service) => (
|
|
99
|
+
<div class="service-row" data-id={service.id} data-status={service.status}>
|
|
100
|
+
<div class="col-service">
|
|
101
|
+
<span class="service-icon">{getIcon(service.id, provider)}</span>
|
|
102
|
+
<span class="service-name">{service.label}</span>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div class="col-usage">
|
|
106
|
+
<span class="usage-current">{formatLargeNumber(service.current)}</span>
|
|
107
|
+
{service.limit !== null ? (
|
|
108
|
+
<span class="usage-limit">
|
|
109
|
+
/ {formatLargeNumber(service.limit)} {service.unit}
|
|
110
|
+
</span>
|
|
111
|
+
) : (
|
|
112
|
+
<span class="usage-limit">{service.unit}</span>
|
|
113
|
+
)}
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div class="col-utilization">
|
|
117
|
+
{service.limit !== null ? (
|
|
118
|
+
<UtilizationBar
|
|
119
|
+
percentage={service.percentage}
|
|
120
|
+
status={service.status}
|
|
121
|
+
height={6}
|
|
122
|
+
showLabel
|
|
123
|
+
/>
|
|
124
|
+
) : (
|
|
125
|
+
<span class="subscription-badge">Subscription</span>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="col-cost">
|
|
130
|
+
<span class="cost-value">{formatCurrency(service.costEstimate)}</span>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{showOverage && (
|
|
134
|
+
<div class="col-overage">
|
|
135
|
+
{service.overage > 0 ? (
|
|
136
|
+
<span class="overage-value overage-active">
|
|
137
|
+
+{formatLargeNumber(service.overage)}
|
|
138
|
+
<span class="overage-cost">({formatCurrency(service.overageCost)})</span>
|
|
139
|
+
</span>
|
|
140
|
+
) : (
|
|
141
|
+
<span class="overage-value overage-none">—</span>
|
|
142
|
+
)}
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
))
|
|
147
|
+
}
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
<style>
|
|
153
|
+
.service-list-section {
|
|
154
|
+
background: var(--color-surface, #ffffff);
|
|
155
|
+
border: 1px solid var(--color-border, #e5e7eb);
|
|
156
|
+
border-radius: 12px;
|
|
157
|
+
padding: 16px;
|
|
158
|
+
margin-bottom: 16px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:global(.dark) .service-list-section {
|
|
162
|
+
background: var(--color-surface-dark, #1f2937);
|
|
163
|
+
border-color: var(--color-border-dark, #374151);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.section-title {
|
|
167
|
+
font-size: 14px;
|
|
168
|
+
font-weight: 600;
|
|
169
|
+
color: var(--color-text, #111827);
|
|
170
|
+
margin: 0 0 12px;
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
gap: 8px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:global(.dark) .section-title {
|
|
177
|
+
color: var(--color-text-dark, #f9fafb);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.empty-state {
|
|
181
|
+
display: flex;
|
|
182
|
+
flex-direction: column;
|
|
183
|
+
align-items: center;
|
|
184
|
+
padding: 24px;
|
|
185
|
+
color: var(--color-text-secondary, #6b7280);
|
|
186
|
+
gap: 8px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.empty-icon {
|
|
190
|
+
font-size: 24px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.service-table {
|
|
194
|
+
width: 100%;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.table-header {
|
|
198
|
+
display: grid;
|
|
199
|
+
grid-template-columns: 2fr 1.5fr 2fr 1fr 1fr;
|
|
200
|
+
gap: 12px;
|
|
201
|
+
padding: 8px 12px;
|
|
202
|
+
background: var(--color-surface-secondary, #f9fafb);
|
|
203
|
+
border-radius: 8px;
|
|
204
|
+
font-size: 11px;
|
|
205
|
+
font-weight: 600;
|
|
206
|
+
text-transform: uppercase;
|
|
207
|
+
letter-spacing: 0.5px;
|
|
208
|
+
color: var(--color-text-secondary, #6b7280);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
:global(.dark) .table-header {
|
|
212
|
+
background: var(--color-surface-secondary-dark, #111827);
|
|
213
|
+
color: var(--color-text-secondary-dark, #9ca3af);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.table-body {
|
|
217
|
+
display: flex;
|
|
218
|
+
flex-direction: column;
|
|
219
|
+
gap: 2px;
|
|
220
|
+
margin-top: 8px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.service-row {
|
|
224
|
+
display: grid;
|
|
225
|
+
grid-template-columns: 2fr 1.5fr 2fr 1fr 1fr;
|
|
226
|
+
gap: 12px;
|
|
227
|
+
padding: 10px 12px;
|
|
228
|
+
border-radius: 6px;
|
|
229
|
+
align-items: center;
|
|
230
|
+
transition: background 0.15s ease;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.service-row:hover {
|
|
234
|
+
background: var(--color-surface-secondary, #f9fafb);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
:global(.dark) .service-row:hover {
|
|
238
|
+
background: var(--color-surface-secondary-dark, #111827);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.service-row[data-status='warning'] {
|
|
242
|
+
background: rgba(234, 179, 8, 0.05);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.service-row[data-status='critical'],
|
|
246
|
+
.service-row[data-status='overage'] {
|
|
247
|
+
background: rgba(239, 68, 68, 0.05);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.col-service {
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: center;
|
|
253
|
+
gap: 8px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.service-icon {
|
|
257
|
+
font-size: 16px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.service-name {
|
|
261
|
+
font-size: 13px;
|
|
262
|
+
font-weight: 500;
|
|
263
|
+
color: var(--color-text, #111827);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
:global(.dark) .service-name {
|
|
267
|
+
color: var(--color-text-dark, #f9fafb);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.col-usage {
|
|
271
|
+
display: flex;
|
|
272
|
+
align-items: baseline;
|
|
273
|
+
gap: 4px;
|
|
274
|
+
font-size: 13px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.usage-current {
|
|
278
|
+
font-weight: 600;
|
|
279
|
+
color: var(--color-text, #111827);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
:global(.dark) .usage-current {
|
|
283
|
+
color: var(--color-text-dark, #f9fafb);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.usage-limit {
|
|
287
|
+
font-size: 11px;
|
|
288
|
+
color: var(--color-text-secondary, #6b7280);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
:global(.dark) .usage-limit {
|
|
292
|
+
color: var(--color-text-secondary-dark, #9ca3af);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.col-utilization {
|
|
296
|
+
min-width: 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.subscription-badge {
|
|
300
|
+
display: inline-block;
|
|
301
|
+
font-size: 11px;
|
|
302
|
+
font-weight: 500;
|
|
303
|
+
padding: 2px 8px;
|
|
304
|
+
background: var(--color-primary-bg, #dbeafe);
|
|
305
|
+
color: var(--color-primary, #2563eb);
|
|
306
|
+
border-radius: 9999px;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
:global(.dark) .subscription-badge {
|
|
310
|
+
background: rgba(37, 99, 235, 0.2);
|
|
311
|
+
color: #93c5fd;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.col-cost,
|
|
315
|
+
.col-overage {
|
|
316
|
+
text-align: right;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.cost-value {
|
|
320
|
+
font-size: 13px;
|
|
321
|
+
font-weight: 500;
|
|
322
|
+
color: var(--color-text, #111827);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
:global(.dark) .cost-value {
|
|
326
|
+
color: var(--color-text-dark, #f9fafb);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.overage-value {
|
|
330
|
+
font-size: 12px;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.overage-active {
|
|
334
|
+
color: var(--color-critical, #ef4444);
|
|
335
|
+
font-weight: 500;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.overage-cost {
|
|
339
|
+
font-size: 11px;
|
|
340
|
+
margin-left: 2px;
|
|
341
|
+
opacity: 0.8;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.overage-none {
|
|
345
|
+
color: var(--color-text-secondary, #6b7280);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/* Responsive: stack columns on mobile */
|
|
349
|
+
@media (max-width: 768px) {
|
|
350
|
+
.table-header {
|
|
351
|
+
display: none;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.service-row {
|
|
355
|
+
grid-template-columns: 1fr;
|
|
356
|
+
gap: 8px;
|
|
357
|
+
padding: 12px;
|
|
358
|
+
border-bottom: 1px solid var(--color-border, #e5e7eb);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
:global(.dark) .service-row {
|
|
362
|
+
border-color: var(--color-border-dark, #374151);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.col-service {
|
|
366
|
+
justify-content: flex-start;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.col-usage,
|
|
370
|
+
.col-cost,
|
|
371
|
+
.col-overage {
|
|
372
|
+
text-align: left;
|
|
373
|
+
font-size: 12px;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.col-overage {
|
|
377
|
+
display: flex;
|
|
378
|
+
align-items: center;
|
|
379
|
+
gap: 4px;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.col-overage::before {
|
|
383
|
+
content: 'Overage: ';
|
|
384
|
+
color: var(--color-text-secondary, #6b7280);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
</style>
|
|
388
|
+
|
|
389
|
+
<script>
|
|
390
|
+
/**
|
|
391
|
+
* Update service utilization list with new data
|
|
392
|
+
* Uses safe DOM methods instead of innerHTML
|
|
393
|
+
*/
|
|
394
|
+
interface ResourceMetric {
|
|
395
|
+
id: string;
|
|
396
|
+
label: string;
|
|
397
|
+
provider: 'cloudflare' | 'github';
|
|
398
|
+
current: number;
|
|
399
|
+
limit: number | null;
|
|
400
|
+
unit: string;
|
|
401
|
+
percentage: number;
|
|
402
|
+
costEstimate: number;
|
|
403
|
+
status: 'ok' | 'warning' | 'critical' | 'overage';
|
|
404
|
+
overage: number;
|
|
405
|
+
overageCost: number;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const formatLargeNumber = (num: number): string => {
|
|
409
|
+
if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(1)}B`;
|
|
410
|
+
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
|
|
411
|
+
if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
|
|
412
|
+
return num.toFixed(0);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
const formatCurrency = (amount: number): string => {
|
|
416
|
+
if (amount === 0) return '$0.00';
|
|
417
|
+
if (amount < 0.01) return '< $0.01';
|
|
418
|
+
return `$${amount.toFixed(2)}`;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const getStatusColor = (status: string): string => {
|
|
422
|
+
const colors: Record<string, string> = {
|
|
423
|
+
ok: '#22c55e',
|
|
424
|
+
warning: '#eab308',
|
|
425
|
+
critical: '#ef4444',
|
|
426
|
+
overage: '#dc2626',
|
|
427
|
+
};
|
|
428
|
+
return colors[status] ?? colors.ok;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
const getIcon = (id: string, provider: string): string => {
|
|
432
|
+
const icons: Record<string, Record<string, string>> = {
|
|
433
|
+
cloudflare: {
|
|
434
|
+
'cf-workers': '⚡',
|
|
435
|
+
'cf-d1': '🗄️',
|
|
436
|
+
'cf-kv': '🔑',
|
|
437
|
+
'cf-r2': '📦',
|
|
438
|
+
'cf-do': '🔗',
|
|
439
|
+
'cf-vectorize': '🧮',
|
|
440
|
+
'cf-workers-ai': '🤖',
|
|
441
|
+
'cf-queues': '📬',
|
|
442
|
+
'cf-ai-gateway': '🌐',
|
|
443
|
+
},
|
|
444
|
+
github: {
|
|
445
|
+
'gh-actions-minutes': '⏱️',
|
|
446
|
+
'gh-actions-storage': '💾',
|
|
447
|
+
'gh-ghas-code': '🔍',
|
|
448
|
+
'gh-ghas-secrets': '🔐',
|
|
449
|
+
'gh-ghec': '👥',
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
return icons[provider]?.[id] ?? '📊';
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Create a service row element using safe DOM methods
|
|
457
|
+
*/
|
|
458
|
+
function createServiceRow(service: ResourceMetric, provider: string): HTMLElement {
|
|
459
|
+
const row = document.createElement('div');
|
|
460
|
+
row.className = 'service-row';
|
|
461
|
+
row.dataset.id = service.id;
|
|
462
|
+
row.dataset.status = service.status;
|
|
463
|
+
|
|
464
|
+
// Service column
|
|
465
|
+
const colService = document.createElement('div');
|
|
466
|
+
colService.className = 'col-service';
|
|
467
|
+
|
|
468
|
+
const iconSpan = document.createElement('span');
|
|
469
|
+
iconSpan.className = 'service-icon';
|
|
470
|
+
iconSpan.textContent = getIcon(service.id, provider);
|
|
471
|
+
|
|
472
|
+
const nameSpan = document.createElement('span');
|
|
473
|
+
nameSpan.className = 'service-name';
|
|
474
|
+
nameSpan.textContent = service.label;
|
|
475
|
+
|
|
476
|
+
colService.appendChild(iconSpan);
|
|
477
|
+
colService.appendChild(nameSpan);
|
|
478
|
+
|
|
479
|
+
// Usage column
|
|
480
|
+
const colUsage = document.createElement('div');
|
|
481
|
+
colUsage.className = 'col-usage';
|
|
482
|
+
|
|
483
|
+
const currentSpan = document.createElement('span');
|
|
484
|
+
currentSpan.className = 'usage-current';
|
|
485
|
+
currentSpan.textContent = formatLargeNumber(service.current);
|
|
486
|
+
|
|
487
|
+
const limitSpan = document.createElement('span');
|
|
488
|
+
limitSpan.className = 'usage-limit';
|
|
489
|
+
if (service.limit !== null) {
|
|
490
|
+
limitSpan.textContent = `/ ${formatLargeNumber(service.limit)} ${service.unit}`;
|
|
491
|
+
} else {
|
|
492
|
+
limitSpan.textContent = service.unit;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
colUsage.appendChild(currentSpan);
|
|
496
|
+
colUsage.appendChild(limitSpan);
|
|
497
|
+
|
|
498
|
+
// Utilization column
|
|
499
|
+
const colUtil = document.createElement('div');
|
|
500
|
+
colUtil.className = 'col-utilization';
|
|
501
|
+
|
|
502
|
+
if (service.limit !== null) {
|
|
503
|
+
const barContainer = document.createElement('div');
|
|
504
|
+
barContainer.className = 'utilization-bar-container';
|
|
505
|
+
barContainer.dataset.percentage = String(service.percentage);
|
|
506
|
+
barContainer.dataset.status = service.status;
|
|
507
|
+
|
|
508
|
+
const track = document.createElement('div');
|
|
509
|
+
track.className = 'utilization-bar-track';
|
|
510
|
+
track.style.height = '6px';
|
|
511
|
+
|
|
512
|
+
const fill = document.createElement('div');
|
|
513
|
+
fill.className = 'utilization-bar-fill';
|
|
514
|
+
fill.style.width = `${Math.min(service.percentage, 100)}%`;
|
|
515
|
+
fill.style.backgroundColor = getStatusColor(service.status);
|
|
516
|
+
|
|
517
|
+
track.appendChild(fill);
|
|
518
|
+
|
|
519
|
+
const label = document.createElement('span');
|
|
520
|
+
label.className = `utilization-bar-label status-${service.status}`;
|
|
521
|
+
label.textContent = `${service.percentage.toFixed(0)}%`;
|
|
522
|
+
|
|
523
|
+
barContainer.appendChild(track);
|
|
524
|
+
barContainer.appendChild(label);
|
|
525
|
+
colUtil.appendChild(barContainer);
|
|
526
|
+
} else {
|
|
527
|
+
const badge = document.createElement('span');
|
|
528
|
+
badge.className = 'subscription-badge';
|
|
529
|
+
badge.textContent = 'Subscription';
|
|
530
|
+
colUtil.appendChild(badge);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Cost column
|
|
534
|
+
const colCost = document.createElement('div');
|
|
535
|
+
colCost.className = 'col-cost';
|
|
536
|
+
const costSpan = document.createElement('span');
|
|
537
|
+
costSpan.className = 'cost-value';
|
|
538
|
+
costSpan.textContent = formatCurrency(service.costEstimate);
|
|
539
|
+
colCost.appendChild(costSpan);
|
|
540
|
+
|
|
541
|
+
// Overage column
|
|
542
|
+
const colOverage = document.createElement('div');
|
|
543
|
+
colOverage.className = 'col-overage';
|
|
544
|
+
|
|
545
|
+
const overageSpan = document.createElement('span');
|
|
546
|
+
if (service.overage > 0) {
|
|
547
|
+
overageSpan.className = 'overage-value overage-active';
|
|
548
|
+
overageSpan.textContent = `+${formatLargeNumber(service.overage)}`;
|
|
549
|
+
|
|
550
|
+
const costSpanOv = document.createElement('span');
|
|
551
|
+
costSpanOv.className = 'overage-cost';
|
|
552
|
+
costSpanOv.textContent = `(${formatCurrency(service.overageCost)})`;
|
|
553
|
+
overageSpan.appendChild(costSpanOv);
|
|
554
|
+
} else {
|
|
555
|
+
overageSpan.className = 'overage-value overage-none';
|
|
556
|
+
overageSpan.textContent = '—';
|
|
557
|
+
}
|
|
558
|
+
colOverage.appendChild(overageSpan);
|
|
559
|
+
|
|
560
|
+
// Assemble row
|
|
561
|
+
row.appendChild(colService);
|
|
562
|
+
row.appendChild(colUsage);
|
|
563
|
+
row.appendChild(colUtil);
|
|
564
|
+
row.appendChild(colCost);
|
|
565
|
+
row.appendChild(colOverage);
|
|
566
|
+
|
|
567
|
+
return row;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
type UpdateServiceListFn = (
|
|
571
|
+
provider: 'cloudflare' | 'github',
|
|
572
|
+
services: ResourceMetric[]
|
|
573
|
+
) => void;
|
|
574
|
+
|
|
575
|
+
(window as unknown as { updateServiceList: UpdateServiceListFn }).updateServiceList = (
|
|
576
|
+
provider: 'cloudflare' | 'github',
|
|
577
|
+
services: ResourceMetric[]
|
|
578
|
+
) => {
|
|
579
|
+
const bodyEl = document.getElementById(`service-list-body-${provider}`);
|
|
580
|
+
const tableEl = document.getElementById(`service-list-table-${provider}`);
|
|
581
|
+
const emptyEl = document.getElementById(`service-list-empty-${provider}`);
|
|
582
|
+
if (!bodyEl) return;
|
|
583
|
+
|
|
584
|
+
// Clear existing rows
|
|
585
|
+
while (bodyEl.firstChild) {
|
|
586
|
+
bodyEl.removeChild(bodyEl.firstChild);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// Toggle empty state vs table visibility
|
|
590
|
+
if (services.length > 0) {
|
|
591
|
+
if (emptyEl) emptyEl.style.display = 'none';
|
|
592
|
+
if (tableEl) tableEl.style.display = '';
|
|
593
|
+
|
|
594
|
+
// Add new rows using safe DOM methods
|
|
595
|
+
for (const service of services) {
|
|
596
|
+
const row = createServiceRow(service, provider);
|
|
597
|
+
bodyEl.appendChild(row);
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
if (emptyEl) emptyEl.style.display = '';
|
|
601
|
+
if (tableEl) tableEl.style.display = 'none';
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
</script>
|