feat(datasource): enhance DataSourceSettings and DataSourceSyncLogs UI

- Improved DataSourceSettings component with better loading handling and UI updates for data source cards.
- Refactored layout and styling for data source cards, including enhanced title and status display.
- Updated DataSourceSyncLogs component with improved summary statistics and log display styles.
- Enhanced responsiveness and visual consistency across components with updated padding, margins, and font sizes.
This commit is contained in:
wizardchen
2026-03-30 14:50:31 +08:00
committed by lyingbug
parent d5ec5dc0ea
commit 8021647929
2 changed files with 178 additions and 118 deletions
@@ -26,7 +26,6 @@ const logsVisible = ref(false)
const logsDsId = ref('') const logsDsId = ref('')
const logsDsName = ref('') const logsDsName = ref('')
async function loadList() { async function loadList() {
loading.value = true loading.value = true
try { try {
@@ -66,11 +65,11 @@ function handleDelete(ds: DataSource) {
try { try {
await deleteDataSource(ds.id) await deleteDataSource(ds.id)
MessagePlugin.success(t('datasource.deleteSuccess')) MessagePlugin.success(t('datasource.deleteSuccess'))
loadList() await loadList()
confirmDialog.hide()
} catch { } catch {
MessagePlugin.error(t('datasource.deleteFailed')) MessagePlugin.error(t('datasource.deleteFailed'))
} }
confirmDialog.destroy()
}, },
}) })
} }
@@ -202,15 +201,18 @@ onMounted(loadList)
<div v-else class="ds-list"> <div v-else class="ds-list">
<div v-for="ds in dataSources" :key="ds.id" class="ds-card"> <div v-for="ds in dataSources" :key="ds.id" class="ds-card">
<div class="ds-card-header"> <div class="ds-card-header">
<div class="ds-card-identity"> <div class="ds-card-title-wrap">
<div class="ds-name-row"> <div class="ds-title-text">
<span class="ds-name">{{ ds.name }}</span> <div class="ds-name-row">
<t-tag size="small" :theme="statusTheme(ds.status)" variant="light-outline"> <span class="ds-name" :title="ds.name">{{ ds.name }}</span>
{{ statusLabel(ds.status) }} <t-tag size="small" :theme="statusTheme(ds.status)" variant="light-outline" class="ds-status-tag">
</t-tag> {{ statusLabel(ds.status) }}
</t-tag>
</div>
<span class="ds-type-desc">{{ connectorLabel(ds.type) }}</span>
</div> </div>
<span class="ds-type-label">{{ connectorLabel(ds.type) }}</span>
</div> </div>
<div class="ds-card-actions"> <div class="ds-card-actions">
<t-tooltip :content="t('datasource.syncNow')"> <t-tooltip :content="t('datasource.syncNow')">
<t-button size="small" variant="text" theme="primary" @click="handleSync(ds)"> <t-button size="small" variant="text" theme="primary" @click="handleSync(ds)">
@@ -254,41 +256,43 @@ onMounted(loadList)
</div> </div>
</div> </div>
<div class="ds-card-body"> <div class="ds-card-stats">
<div class="ds-info-cell"> <div class="ds-stat-item">
<span class="ds-info-label">{{ t('datasource.syncModeLabel') }}</span> <span class="ds-stat-label">{{ t('datasource.syncModeLabel') }}</span>
<span class="ds-info-value">{{ syncModeLabel(ds.sync_mode) }}</span> <span class="ds-stat-value">{{ syncModeLabel(ds.sync_mode) }}</span>
</div> </div>
<div class="ds-info-cell"> <div class="ds-stat-item">
<span class="ds-info-label">{{ t('datasource.schedule') }}</span> <span class="ds-stat-label">{{ t('datasource.schedule') }}</span>
<span class="ds-info-value">{{ scheduleLabel(ds.sync_schedule) }}</span> <span class="ds-stat-value">{{ scheduleLabel(ds.sync_schedule) }}</span>
</div> </div>
<div class="ds-info-cell"> <div class="ds-stat-item">
<span class="ds-info-label">{{ t('datasource.lastSync') }}</span> <span class="ds-stat-label">{{ t('datasource.lastSync') }}</span>
<t-tooltip :content="lastSyncFullTime(ds)" :disabled="!lastSyncFullTime(ds)"> <t-tooltip :content="lastSyncFullTime(ds)" :disabled="!lastSyncFullTime(ds)">
<span class="ds-info-value">{{ lastSyncTime(ds) }}</span> <span class="ds-stat-value">{{ lastSyncTime(ds) }}</span>
</t-tooltip> </t-tooltip>
</div> </div>
<div class="ds-info-cell"> <div class="ds-stat-item" style="flex: 1.2">
<span class="ds-info-label">{{ t('datasource.lastStatus') }}</span> <span class="ds-stat-label">{{ t('datasource.lastStatus') }}</span>
<span class="ds-info-value"> <div class="ds-stat-value">
<template v-if="ds.latest_sync_log"> <template v-if="ds.latest_sync_log">
<span :style="{ color: lastSyncStatusColor(ds), fontWeight: 500 }">{{ lastSyncStatusLabel(ds) }}</span> <span :style="{ color: lastSyncStatusColor(ds), fontWeight: 500 }">{{ lastSyncStatusLabel(ds) }}</span>
<span v-for="pill in syncResultPills(ds)" :key="pill.cls" :class="['ds-pill', pill.cls]">{{ pill.text }}</span> <span v-for="pill in syncResultPills(ds)" :key="pill.cls" :class="['ds-pill', pill.cls]">{{ pill.text }}</span>
</template> </template>
<span v-else class="ds-info-placeholder">--</span> <span v-else class="ds-stat-placeholder">--</span>
</span> </div>
</div> </div>
</div> </div>
<div v-if="ds.error_message" class="ds-error"> <div v-if="ds.error_message" class="ds-card-error">
<t-icon name="error-circle-filled" size="14px" /> <t-icon name="error-circle-filled" size="16px" />
<span>{{ ds.error_message }}</span> <span>{{ ds.error_message }}</span>
</div> </div>
</div> </div>
<div class="ds-card-add" @click="openCreate"> <div class="ds-card-add" @click="openCreate">
<t-icon name="add" size="18px" /> <div class="ds-card-add-icon">
<t-icon name="add" size="20px" />
</div>
<span>{{ t('datasource.addCard') }}</span> <span>{{ t('datasource.addCard') }}</span>
</div> </div>
</div> </div>
@@ -320,7 +324,7 @@ onMounted(loadList)
.section-title { .section-title {
margin: 0 0 6px 0; margin: 0 0 6px 0;
font-size: 18px; font-size: 20px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
letter-spacing: -0.01em; letter-spacing: -0.01em;
@@ -386,34 +390,42 @@ onMounted(loadList)
/* --- Card --- */ /* --- Card --- */
.ds-card { .ds-card {
position: relative; position: relative;
border: 1px solid var(--td-border-level-2-color);
border-radius: 10px;
padding: 16px 18px;
background: var(--td-bg-color-container); background: var(--td-bg-color-container);
transition: border-color 0.2s, box-shadow 0.2s; border: 1px solid var(--td-border-level-2-color);
border-radius: 12px;
padding: 20px;
transition: all 0.2s ease;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
} }
.ds-card:hover { .ds-card:hover {
border-color: var(--td-brand-color-hover); border-color: var(--td-brand-color);
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
} }
/* --- Card header --- */ /* --- Card header --- */
.ds-card-header { .ds-card-header {
display: flex; display: flex;
align-items: flex-start;
justify-content: space-between; justify-content: space-between;
gap: 12px; align-items: flex-start;
margin-bottom: 20px;
} }
.ds-card-identity { .ds-card-title-wrap {
display: flex; display: flex;
flex-direction: column; align-items: center;
gap: 2px; gap: 16px;
min-width: 0; min-width: 0;
flex: 1; flex: 1;
} }
.ds-title-text {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
}
.ds-name-row { .ds-name-row {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -422,64 +434,79 @@ onMounted(loadList)
} }
.ds-name { .ds-name {
font-size: 14px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
line-height: 22px; line-height: 24px;
} }
.ds-type-label { .ds-status-tag {
font-size: 12px; border-radius: 4px;
color: var(--td-text-color-placeholder); }
.ds-type-desc {
font-size: 13px;
color: var(--td-text-color-secondary);
line-height: 18px; line-height: 18px;
} }
.ds-card-actions { .ds-card-actions {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 2px; gap: 4px;
flex-shrink: 0; flex-shrink: 0;
margin-top: 2px; opacity: 0.6;
transition: opacity 0.2s ease;
} }
/* --- Info grid --- */ .ds-card:hover .ds-card-actions {
.ds-card-body { opacity: 1;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px 24px;
margin-top: 14px;
padding: 12px 14px;
background: var(--td-bg-color-secondarycontainer);
border-radius: 8px;
} }
.ds-info-cell { .ds-card-actions :deep(.t-button) {
border-radius: 6px;
}
/* --- Info stats --- */
.ds-card-stats {
display: flex;
gap: 24px;
padding-top: 16px;
border-top: 1px solid var(--td-border-level-1-color);
}
.ds-stat-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px; gap: 6px;
flex: 1;
} }
.ds-info-label { .ds-stat-label {
font-size: 12px; font-size: 11px;
font-weight: 500;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
line-height: 18px; text-transform: uppercase;
letter-spacing: 0.5px;
line-height: 16px;
white-space: nowrap;
} }
.ds-info-value { .ds-stat-value {
font-size: 13px;
color: var(--td-text-color-primary);
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 6px;
flex-wrap: wrap; flex-wrap: wrap;
font-size: 13px;
color: var(--td-text-color-primary);
line-height: 20px; line-height: 20px;
} }
.ds-info-placeholder { .ds-stat-placeholder {
color: var(--td-text-color-placeholder); color: var(--td-text-color-disabled);
} }
/* --- Sync result pills --- */ /* --- Sync result pills --- */
@@ -499,16 +526,16 @@ onMounted(loadList)
.ds-pill.failed { background: var(--td-error-color-1); color: var(--td-error-color); } .ds-pill.failed { background: var(--td-error-color-1); color: var(--td-error-color); }
/* --- Error alert --- */ /* --- Error alert --- */
.ds-error { .ds-card-error {
margin-top: 16px;
padding: 10px 14px;
border-radius: 8px;
background: var(--td-error-color-1);
color: var(--td-error-color);
font-size: 13px;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
gap: 6px; gap: 8px;
color: var(--td-error-color);
font-size: 12px;
background: var(--td-error-color-1);
padding: 8px 12px;
border-radius: 6px;
margin-top: 10px;
line-height: 20px; line-height: 20px;
} }
@@ -517,19 +544,40 @@ onMounted(loadList)
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 6px; gap: 12px;
padding: 14px; padding: 15px;
border: 1px dashed var(--td-border-level-2-color); background: var(--td-bg-color-secondarycontainer);
border-radius: 10px; border: 1px solid transparent;
color: var(--td-text-color-placeholder); border-radius: 12px;
font-size: 13px; color: var(--td-text-color-secondary);
font-size: 14px;
font-weight: 500;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s ease;
margin-top: 4px;
}
.ds-card-add-icon {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 8px;
background: var(--td-bg-color-component);
color: var(--td-text-color-placeholder);
transition: all 0.2s ease;
} }
.ds-card-add:hover { .ds-card-add:hover {
background: var(--td-bg-color-container);
border-color: var(--td-brand-color); border-color: var(--td-brand-color);
color: var(--td-brand-color); color: var(--td-brand-color);
background: rgba(0, 82, 217, 0.04); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.ds-card-add:hover .ds-card-add-icon {
background: var(--td-brand-color-light);
color: var(--td-brand-color);
} }
</style> </style>
@@ -251,32 +251,36 @@ const groupedLogs = computed(() => {
padding: 80px 0; padding: 80px 0;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
font-size: 13px; font-size: 13px;
gap: 8px; gap: 12px;
} }
/* --- Summary --- */ /* --- Summary --- */
.logs-summary { .logs-summary {
display: flex; display: flex;
gap: 4px; gap: 8px;
padding-bottom: 16px; padding-bottom: 24px;
margin-bottom: 8px; margin-bottom: 12px;
border-bottom: 1px solid var(--td-border-level-2-color); border-bottom: 1px solid var(--td-border-level-1-color);
} }
.summary-stat { .summary-stat {
flex: 1; flex: 1;
text-align: center; text-align: center;
padding: 8px 0; padding: 16px 8px;
border-radius: 6px; border-radius: 12px;
background: var(--td-bg-color-secondarycontainer); background: var(--td-bg-color-container);
border: 1px solid var(--td-border-level-1-color);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
display: flex;
flex-direction: column;
gap: 4px;
} }
.stat-num { .stat-num {
display: block; font-size: 20px;
font-size: 18px;
font-weight: 700; font-weight: 700;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
line-height: 1.3; line-height: 1.2;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
} }
@@ -285,6 +289,9 @@ const groupedLogs = computed(() => {
.stat-label { .stat-label {
font-size: 11px; font-size: 11px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
} }
@@ -295,14 +302,14 @@ const groupedLogs = computed(() => {
} }
.timeline-group { .timeline-group {
margin-bottom: 0; margin-bottom: 8px;
} }
.timeline-date { .timeline-date {
font-size: 11px; font-size: 11px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
padding: 10px 0 6px 24px; padding: 12px 0 8px 24px;
position: sticky; position: sticky;
top: 0; top: 0;
background: var(--td-bg-color-container); background: var(--td-bg-color-container);
@@ -315,6 +322,7 @@ const groupedLogs = computed(() => {
display: flex; display: flex;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
margin-bottom: 4px;
} }
/* --- Dot column: continuous line --- */ /* --- Dot column: continuous line --- */
@@ -335,7 +343,7 @@ const groupedLogs = computed(() => {
bottom: 0; bottom: 0;
left: 50%; left: 50%;
width: 1.5px; width: 1.5px;
background: var(--td-border-level-2-color); background: var(--td-border-level-1-color);
transform: translateX(-50%); transform: translateX(-50%);
} }
@@ -350,8 +358,8 @@ const groupedLogs = computed(() => {
flex-shrink: 0; flex-shrink: 0;
position: relative; position: relative;
z-index: 1; z-index: 1;
margin-top: 15px; margin-top: 18px;
box-shadow: 0 0 0 3px var(--td-bg-color-container); box-shadow: 0 0 0 4px var(--td-bg-color-container);
} }
.tl-dot .tl-spin { .tl-dot .tl-spin {
@@ -366,10 +374,9 @@ const groupedLogs = computed(() => {
.tl-content { .tl-content {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
padding: 6px 10px; padding: 12px 14px;
margin: 2px 0; border-radius: 10px;
border-radius: 6px; transition: background 0.2s ease;
transition: background 0.15s;
} }
.timeline-item:hover .tl-content { .timeline-item:hover .tl-content {
@@ -378,8 +385,8 @@ const groupedLogs = computed(() => {
.tl-header { .tl-header {
display: flex; display: flex;
align-items: baseline; align-items: center;
gap: 6px; gap: 8px;
} }
.tl-status { .tl-status {
@@ -396,8 +403,12 @@ const groupedLogs = computed(() => {
.tl-duration { .tl-duration {
margin-left: auto; margin-left: auto;
font-size: 11px; font-size: 11px;
font-weight: 500;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
background: var(--td-bg-color-component);
padding: 2px 6px;
border-radius: 4px;
} }
/* --- Pills --- */ /* --- Pills --- */
@@ -405,13 +416,13 @@ const groupedLogs = computed(() => {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 4px; gap: 4px;
margin-top: 6px; margin-top: 8px;
} }
.pill { .pill {
font-size: 11px; font-size: 11px;
padding: 0 5px; padding: 1px 6px;
border-radius: 3px; border-radius: 4px;
font-weight: 500; font-weight: 500;
line-height: 18px; line-height: 18px;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
@@ -425,12 +436,12 @@ const groupedLogs = computed(() => {
/* --- Expanded detail --- */ /* --- Expanded detail --- */
.tl-detail { .tl-detail {
margin-top: 8px; margin-top: 12px;
padding-top: 8px; padding-top: 12px;
border-top: 1px dashed var(--td-border-level-2-color); border-top: 1px dashed var(--td-border-level-2-color);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 6px;
} }
.detail-row { .detail-row {
@@ -438,6 +449,7 @@ const groupedLogs = computed(() => {
justify-content: space-between; justify-content: space-between;
font-size: 12px; font-size: 12px;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
line-height: 20px;
} }
.detail-label { .detail-label {
@@ -445,9 +457,9 @@ const groupedLogs = computed(() => {
} }
.tl-error { .tl-error {
margin-top: 6px; margin-top: 8px;
padding: 6px 8px; padding: 8px 12px;
border-radius: 4px; border-radius: 6px;
background: var(--td-error-color-1); background: var(--td-error-color-1);
color: var(--td-error-color); color: var(--td-error-color);
font-size: 12px; font-size: 12px;
@@ -464,7 +476,7 @@ const groupedLogs = computed(() => {
} }
.logs-drawer-title { .logs-drawer-title {
font-size: 15px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
overflow: hidden; overflow: hidden;
@@ -474,11 +486,11 @@ const groupedLogs = computed(() => {
/* --- Drawer overrides --- */ /* --- Drawer overrides --- */
.ds-logs-drawer :deep(.t-drawer__header) { .ds-logs-drawer :deep(.t-drawer__header) {
padding: 16px 24px; padding: 20px 24px;
border-bottom: 1px solid var(--td-border-level-2-color); border-bottom: 1px solid var(--td-border-level-1-color);
} }
.ds-logs-drawer :deep(.t-drawer__body) { .ds-logs-drawer :deep(.t-drawer__body) {
padding: 16px 20px; padding: 20px 24px;
} }
</style> </style>