Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/internal/infra/store/usage_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (s *UsageStore) ListUser(ctx context.Context, userID int64, filter appusage
WithAPIKey().
WithAccount().
WithGroup().
Offset((filter.Page - 1) * filter.PageSize).
Offset((filter.Page-1)*filter.PageSize).
Limit(filter.PageSize).
Order(ent.Desc(entusagelog.FieldCreatedAt)).
Order(ent.Desc(entusagelog.FieldCreatedAt), ent.Desc(entusagelog.FieldID)).
All(ctx)
if err != nil {
return nil, 0, err
Expand Down Expand Up @@ -75,9 +75,9 @@ func (s *UsageStore) ListAdmin(ctx context.Context, filter appusage.ListFilter)
WithAPIKey().
WithAccount().
WithGroup().
Offset((filter.Page - 1) * filter.PageSize).
Offset((filter.Page-1)*filter.PageSize).
Limit(filter.PageSize).
Order(ent.Desc(entusagelog.FieldCreatedAt)).
Order(ent.Desc(entusagelog.FieldCreatedAt), ent.Desc(entusagelog.FieldID)).
All(ctx)
if err != nil {
return nil, 0, err
Expand Down
4 changes: 2 additions & 2 deletions web/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@
"active_users_label": "Active users: {{count}}",
"image_suffix": "PIC",
"image_response_time": "Image: {{time}}",
"time_range": "Time Range:",
"time_range": "Time Range",
"range_today": "Today",
"range_7d": "7 Days",
"range_30d": "30 Days",
"range_90d": "90 Days",
"range_custom": "Custom",
"granularity": "Granularity:",
"granularity": "Granularity",
"granularity_hour": "Hourly",
"granularity_day": "Daily",
"model_distribution": "Model Distribution",
Expand Down
4 changes: 2 additions & 2 deletions web/src/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@
"active_users_label": "活跃用户: {{count}}",
"image_suffix": "PIC",
"image_response_time": "图片: {{time}}",
"time_range": "时间范围",
"time_range": "时间范围",
"range_today": "今天",
"range_7d": "近 7 天",
"range_30d": "近 30 天",
"range_90d": "近 90 天",
"range_custom": "自定义",
"granularity": "粒度",
"granularity": "粒度",
"granularity_hour": "按小时",
"granularity_day": "按天",
"model_distribution": "模型分布",
Expand Down
8 changes: 4 additions & 4 deletions web/src/pages/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ function MetricCard({
<div className="ag-dashboard-metric-copy">
<div className="truncate text-sm font-semibold tracking-normal text-text-tertiary">{title}</div>
<div className="mt-1 flex min-w-0 items-baseline gap-2">
<div className="flex min-w-0 items-baseline font-mono text-[22px] font-semibold leading-none text-text 2xl:text-2xl">
<div className="flex min-w-0 items-baseline font-mono text-xl font-semibold leading-none text-text 2xl:text-2xl">
{value}
{valueSuffix ? <span className="ml-1.5 text-sm font-medium text-text-tertiary">{valueSuffix}</span> : null}
{valueSuffix ? <span className="ml-1.5 text-xs font-medium text-text-tertiary 2xl:text-sm">{valueSuffix}</span> : null}
</div>
<div className={`min-w-0 truncate text-xs font-semibold ${META_TONE_CLASSES[metaTone]}`}>{meta}</div>
</div>
</div>
<span className={`flex h-10 w-10 shrink-0 items-center justify-center rounded-[var(--field-radius)] ring-1 shadow-sm 2xl:h-11 2xl:w-11 ${METRIC_TONE_CLASSES[tone]}`}>
<span className={`hidden h-11 w-11 shrink-0 items-center justify-center rounded-[var(--field-radius)] ring-1 shadow-sm 2xl:flex ${METRIC_TONE_CLASSES[tone]}`}>
{icon}
</span>
</Card.Content>
Expand All @@ -198,7 +198,7 @@ function StatsSkeleton() {
<Skeleton className="h-3 w-32" />
</div>
</div>
<Skeleton className="h-10 w-10 shrink-0 rounded-[var(--field-radius)]" />
<Skeleton className="hidden h-11 w-11 shrink-0 rounded-[var(--field-radius)] 2xl:block" />
</Card.Content>
</Card>
))}
Expand Down
49 changes: 22 additions & 27 deletions web/src/pages/admin/GroupsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ export default function GroupsPage() {
totalPages={totalPages}
/>
)}
minWidth={1180}
minWidth={1120}
>
<CommonTable.Header>
<CommonTable.Column id="name">{t('common.name')}</CommonTable.Column>
<CommonTable.Column id="platform">{t('groups.platform')}</CommonTable.Column>
<CommonTable.Column id="subscription_type">{t('groups.subscription_type')}</CommonTable.Column>
<CommonTable.Column id="rate_multiplier" style={{ width: 96 }}>
<CommonTable.Column id="name" style={{ width: 160 }}>{t('common.name')}</CommonTable.Column>
<CommonTable.Column id="platform" style={{ width: 112 }}>{t('groups.platform')}</CommonTable.Column>
<CommonTable.Column id="subscription_type" style={{ width: 88 }}>{t('groups.subscription_type')}</CommonTable.Column>
<CommonTable.Column id="rate_multiplier" style={{ width: 80 }}>
{t('groups.rate_multiplier')}
</CommonTable.Column>
<CommonTable.Column id="is_exclusive" style={{ width: 96 }}>
<CommonTable.Column id="is_exclusive" style={{ width: 76 }}>
{t('groups.group_type')}
</CommonTable.Column>
<CommonTable.Column id="account_stats" style={{ width: '10.75rem' }}>
Expand All @@ -173,10 +173,10 @@ export default function GroupsPage() {
<CommonTable.Column id="usage" style={{ width: '10.75rem' }}>
{t('groups.usage')}
</CommonTable.Column>
<CommonTable.Column id="capacity" style={{ width: 128 }}>
<CommonTable.Column id="capacity" style={{ minWidth: 112, width: 112 }}>
{t('groups.capacity')}
</CommonTable.Column>
<CommonTable.Column id="sort_weight" style={{ width: 96 }}>
<CommonTable.Column id="sort_weight" style={{ width: 72 }}>
{t('groups.sort_weight')}
</CommonTable.Column>
<CommonTable.Column id="actions" style={{ width: 132 }}>
Expand All @@ -198,21 +198,21 @@ export default function GroupsPage() {
rows.map((row) => (
<CommonTable.Row id={String(row.id)} key={row.id}>
<CommonTable.Cell>
<span className="inline-flex items-center gap-1.5">
<span className="inline-flex max-w-[9.5rem] items-center gap-1.5">
{isImageGroup(row) ? (
<Image className="w-3.5 h-3.5" style={{ color: 'var(--ag-primary)' }} />
<Image className="h-3.5 w-3.5 shrink-0" style={{ color: 'var(--ag-primary)' }} />
) : (
<Text className="w-3.5 h-3.5" style={{ color: 'var(--ag-text-tertiary)' }} />
<Text className="h-3.5 w-3.5 shrink-0" style={{ color: 'var(--ag-text-tertiary)' }} />
)}
<span style={{ color: 'var(--ag-text)' }} className="font-medium">
<span style={{ color: 'var(--ag-text)' }} className="truncate font-medium">
{row.name}
</span>
</span>
</CommonTable.Cell>
<CommonTable.Cell>
<span className="inline-flex items-center gap-1.5">
<PlatformIcon platform={row.platform} className="w-3.5 h-3.5" />
{platformName(row.platform)}
<span className="inline-flex max-w-[6.5rem] items-center gap-1.5">
<PlatformIcon platform={row.platform} className="h-3.5 w-3.5 shrink-0" />
<span className="truncate">{platformName(row.platform)}</span>
</span>
</CommonTable.Cell>
<CommonTable.Cell>
Expand All @@ -236,22 +236,17 @@ export default function GroupsPage() {
</CommonTable.Cell>
<CommonTable.Cell className="ag-groups-metric-cell">
<MetricChips
className="ag-metric-chips--stack ag-metric-chips--markup ag-metric-chips--compact-y"
className="ag-metric-chips--stack ag-metric-chips--markup ag-metric-chips--account-stats ag-metric-chips--compact-y"
items={[
{
color: 'default' as const,
label: t('groups.account_available'),
value: String(row.account_active),
label: `${t('groups.account_available')}/${t('groups.account_total')}`,
value: `${row.account_active}/${row.account_total}`,
},
...(row.account_error > 0 ? [{
color: 'default' as const,
{
color: row.account_error > 0 ? 'danger' as const : 'default' as const,
label: t('groups.account_error'),
value: String(row.account_error),
}] : []),
{
color: 'default' as const,
label: t('groups.account_total'),
value: String(row.account_total),
},
]}
/>
Expand All @@ -278,11 +273,11 @@ export default function GroupsPage() {
/>
</CommonTable.Cell>
<CommonTable.Cell>
<div>
<div className="inline-flex min-w-[6.75rem] items-center justify-end whitespace-nowrap font-mono tabular-nums">
<span className="font-mono" style={{ color: row.capacity_used > 0 ? 'var(--ag-primary)' : undefined }}>
{row.capacity_used}
</span>
<span style={{ color: 'var(--ag-text-tertiary)' }}> / </span>
<span className="mx-0.5" style={{ color: 'var(--ag-text-tertiary)' }}>/</span>
<span className="font-mono">{row.capacity_total}</span>
</div>
</CommonTable.Cell>
Expand Down
13 changes: 9 additions & 4 deletions web/src/pages/admin/accounts/useAccountTableColumns.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo, useRef, type MouseEvent } from 'react';
import { useMemo, useRef, type CSSProperties, type MouseEvent } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { RefreshCw } from 'lucide-react';
Expand All @@ -7,7 +7,6 @@ import { accountsApi } from '../../../shared/api/accounts';
import { queryKeys } from '../../../shared/queryKeys';
import type { AccountResp } from '../../../shared/types';
import { PlatformIcon, useToast } from '../../../shared/ui';
import { GROUP_CHIP_STYLE } from '../../../shared/components/groupChipStyle';
import {
AccountCapacityChip,
AccountRowActions,
Expand All @@ -23,6 +22,12 @@ import {

type QuotaRefreshResult = Awaited<ReturnType<typeof accountsApi.refreshQuota>>;

const ACCOUNT_GROUP_CARD_STYLE: CSSProperties = {
background: 'var(--ag-bg-surface)',
border: '1px solid var(--ag-glass-border)',
color: 'var(--ag-text-secondary)',
};

type UseAccountTableColumnsArgs = {
applyQuotaRefreshResult: (id: number, result: QuotaRefreshResult) => void;
groupMap: Map<number, string>;
Expand Down Expand Up @@ -145,15 +150,15 @@ export function useAccountTableColumns({
<span
key={name}
className="ag-account-group-chip"
style={GROUP_CHIP_STYLE}
style={ACCOUNT_GROUP_CARD_STYLE}
>
{name}
</span>
))}
{hiddenCount > 0 ? (
<span
className="ag-account-group-chip ag-account-group-chip--more"
style={GROUP_CHIP_STYLE}
style={ACCOUNT_GROUP_CARD_STYLE}
>
+{hiddenCount}
</span>
Expand Down
2 changes: 1 addition & 1 deletion web/src/shared/components/MetricChips.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chip } from '@heroui/react';

type MetricChipColor = 'default' | 'warning' | 'success' | 'accent';
type MetricChipColor = 'default' | 'warning' | 'success' | 'accent' | 'danger';

export type MetricChipItem = {
amount?: number;
Expand Down
14 changes: 14 additions & 0 deletions web/src/styles/pages.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@
min-width: 10.25rem;
}

.ag-groups-table .ag-metric-chips--markup.ag-metric-chips--account-stats .ag-metric-chip {
grid-template-columns: minmax(max-content, 1fr) max-content;
}

.ag-groups-table .ag-metric-chips--markup.ag-metric-chips--account-stats .ag-metric-chip-label,
.ag-groups-table .ag-metric-chips--markup.ag-metric-chips--account-stats .ag-metric-chip-value {
overflow: visible;
text-overflow: clip;
}

.ag-groups-table .ag-metric-chips--markup.ag-metric-chips--account-stats .ag-metric-chip-value {
min-width: 0;
}

:is(.ag-api-keys-table, .ag-groups-table) .ag-metric-chips--compact-y {
gap: 0.25rem;
}
Expand Down
Loading