Skip to content

Commit 756bfad

Browse files
author
sheepzh
committed
Fix subtitle of trend chart
1 parent 9d2dff9 commit 756bfad

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/app/components/trend/components/chart/wrapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { formatPeriodCommon, formatTime, MILL_PER_DAY } from "@util/time"
3030
import hostAliasService from "@service/host-alias-service"
3131
import HostAlias from "@entity/dao/host-alias"
3232
import { getPrimaryTextColor, getSecondaryTextColor } from "@util/style"
33+
import { labelOfHostInfo } from "../common"
3334

3435
use([
3536
LineChart,
@@ -194,7 +195,7 @@ function getAxias(format: string, dateRange: Date[] | undefined): string[] {
194195
}
195196

196197
async function processSubtitle(host: timer.app.trend.HostInfo) {
197-
let subtitle = host?.toString()
198+
let subtitle = labelOfHostInfo(host)
198199
if (!subtitle) {
199200
return DEFAULT_SUB_TITLE
200201
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) 2022 Hengyang Zhang
3+
*
4+
* This software is released under the MIT License.
5+
* https://opensource.org/licenses/MIT
6+
*/
7+
8+
import { t } from "@app/locale"
9+
10+
/**
11+
* Transfer host info to label
12+
*/
13+
export function labelOfHostInfo(hostInfo: timer.app.trend.HostInfo): string {
14+
const { host, merged } = hostInfo
15+
if (!host) return ''
16+
const mergedLabel = merged ? `[${t(msg => msg.trend.merged)}]` : ''
17+
return `${host}${mergedLabel}`
18+
}

src/app/components/trend/components/filter.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { TrendMessage } from "@app/locale/components/trend"
1515
import DateRangeFilterItem from "@app/components/common/date-range-filter-item"
1616
import SelectFilterItem from "@app/components/common/select-filter-item"
1717
import { ElementDatePickerShortcut } from "@app/element-ui/date"
18+
import { labelOfHostInfo } from "./common"
1819

1920
async function handleRemoteSearch(queryStr: string, trendDomainOptions: Ref<timer.app.trend.HostInfo[]>, searching: Ref<boolean>) {
2021
if (!queryStr) {
@@ -66,13 +67,6 @@ function hostInfoOfKey(key: string): timer.app.trend.HostInfo {
6667
return { host: key.substring(1), merged }
6768
}
6869

69-
function labelOfHostInfo(hostInfo: timer.app.trend.HostInfo): string {
70-
const { host, merged } = hostInfo
71-
if (!host) return ''
72-
const mergedLabel = merged ? `[${t(msg => msg.trend.merged)}]` : ''
73-
return `${host}${mergedLabel}`
74-
}
75-
7670
const _default = defineComponent({
7771
name: "TrendFilter",
7872
props: {

0 commit comments

Comments
 (0)