feat(admin-web): surface monitoring platform authorization status
Dashboard and question-detail views now read platform_authorization_status from the API. Tracking disables collect-now when the account has no desktop client, no authorized platforms, or the selected platform is unauthorized, and keeps the six-platform matrix stable; question-detail replaces tabs and cards with an explicit unavailable notice when the account is not authorized for monitoring. Adds the shared type and en/zh strings covering each status. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import type {
|
||||
Brand,
|
||||
DesktopAccountInfo,
|
||||
MonitoringHotQuestion,
|
||||
MonitoringPlatformAuthorizationStatus,
|
||||
} from "@geo/shared-types";
|
||||
import { aiPlatformCatalog } from "@geo/shared-types";
|
||||
import { computed, watch } from "vue";
|
||||
@@ -283,6 +284,22 @@ const currentUserClientOnline = computed(() => {
|
||||
return dashboardQuery.data.value?.runtime.current_user_client_online === true;
|
||||
});
|
||||
|
||||
const platformBreakdownRows = computed(() => {
|
||||
return dashboardQuery.data.value?.platform_breakdown ?? [];
|
||||
});
|
||||
|
||||
const platformAuthorizationStatus = computed<MonitoringPlatformAuthorizationStatus>(() => {
|
||||
return dashboardQuery.data.value?.runtime.platform_authorization_status ?? "authorized";
|
||||
});
|
||||
|
||||
const selectedPlatformAuthorized = computed(() => {
|
||||
if (selectedPlatformId.value === "all") {
|
||||
return true;
|
||||
}
|
||||
const authorizedPlatformIDs = dashboardQuery.data.value?.runtime.authorized_monitoring_platform_ids ?? [];
|
||||
return authorizedPlatformIDs.some((item) => normalizeMonitoringPlatformId(item) === selectedPlatformId.value);
|
||||
});
|
||||
|
||||
const collectNowDisabledReason = computed(() => {
|
||||
if (!selectedBrandId.value) {
|
||||
return t("tracking.collectBrandRequired");
|
||||
@@ -296,6 +313,15 @@ const collectNowDisabledReason = computed(() => {
|
||||
if (dashboardQuery.isLoading.value && !dashboardQuery.data.value) {
|
||||
return t("tracking.collectClientChecking");
|
||||
}
|
||||
if (platformAuthorizationStatus.value === "no_desktop_client") {
|
||||
return t("tracking.noDesktopClientCollectReason");
|
||||
}
|
||||
if (platformAuthorizationStatus.value === "no_authorized_platforms") {
|
||||
return t("tracking.noAuthorizedPlatformsCollectReason");
|
||||
}
|
||||
if (selectedPlatformId.value !== "all" && dashboardQuery.data.value && !selectedPlatformAuthorized.value) {
|
||||
return t("tracking.collectPlatformUnauthorized");
|
||||
}
|
||||
if (!currentUserClientOnline.value) {
|
||||
return t("tracking.collectClientOnlineRequired");
|
||||
}
|
||||
@@ -625,7 +651,7 @@ function normalizeTrackingBusinessDate(value: unknown): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
const today = dayjs().startOf("day");
|
||||
const today = dayjs(trackingToday).startOf("day");
|
||||
const earliestAllowed = today.subtract(trackingMaxHistoryDays - 1, "day");
|
||||
if (parsed.isAfter(today, "day") || parsed.isBefore(earliestAllowed, "day")) {
|
||||
return null;
|
||||
@@ -634,8 +660,8 @@ function normalizeTrackingBusinessDate(value: unknown): string | null {
|
||||
}
|
||||
|
||||
function disableTrackingDate(current: dayjs.Dayjs): boolean {
|
||||
const today = dayjs().endOf("day");
|
||||
const earliestAllowed = dayjs().subtract(trackingMaxHistoryDays - 1, "day").startOf("day");
|
||||
const today = dayjs(trackingToday).endOf("day");
|
||||
const earliestAllowed = dayjs(trackingToday).subtract(trackingMaxHistoryDays - 1, "day").startOf("day");
|
||||
return current.isAfter(today) || current.isBefore(earliestAllowed);
|
||||
}
|
||||
</script>
|
||||
@@ -739,7 +765,7 @@ function disableTrackingDate(current: dayjs.Dayjs): boolean {
|
||||
<h3 class="panel-title">{{ t("tracking.platformMatrixTitle") }}</h3>
|
||||
</div>
|
||||
|
||||
<div class="platform-table">
|
||||
<div v-if="platformBreakdownRows.length" class="platform-table">
|
||||
<div class="platform-table__head">
|
||||
<span>{{ t("tracking.columns.platform") }}</span>
|
||||
<span>{{ t("tracking.metrics.mentionRate") }}</span>
|
||||
@@ -748,7 +774,7 @@ function disableTrackingDate(current: dayjs.Dayjs): boolean {
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="item in dashboardQuery.data.value?.platform_breakdown ?? []"
|
||||
v-for="item in platformBreakdownRows"
|
||||
:key="item.ai_platform_id"
|
||||
class="platform-table__row"
|
||||
>
|
||||
@@ -763,6 +789,11 @@ function disableTrackingDate(current: dayjs.Dayjs): boolean {
|
||||
</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
<a-empty
|
||||
v-else
|
||||
:description="t('tracking.noPlatformBreakdown')"
|
||||
class="tracking-panel__empty"
|
||||
/>
|
||||
</a-card>
|
||||
</div>
|
||||
|
||||
@@ -1188,6 +1219,10 @@ function disableTrackingDate(current: dayjs.Dayjs): boolean {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.tracking-panel__empty {
|
||||
padding: 28px 0 16px;
|
||||
}
|
||||
|
||||
.tracking-metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
|
||||
Reference in New Issue
Block a user