Skip to content

Commit

Permalink
chore(topsql): show cluster name and disable auto-refresh for clinic
Browse files Browse the repository at this point in the history
  • Loading branch information
baurine committed Oct 25, 2023
1 parent c6ca8cf commit 4424cc5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
9 changes: 7 additions & 2 deletions ui/packages/tidb-dashboard-for-clinic-cloud/public/ngm.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,14 @@
const provider = searchParams.get('provider') || ''
const region = searchParams.get('region') || ''
const orgId = searchParams.get('orgId') || ''
const orgName = searchParams.get('orgName') || ''
const projectId = searchParams.get('projectId') || ''
const clusterId = searchParams.get('clusterId') || ''
const deployType = searchParams.get('deployType') || ''

const orgName = searchParams.get('orgName') || ''
const clusterName = searchParams.get('clusterName') || ''
const userName = searchParams.get('userName') || ''

if (
apiToken === '' ||
provider === '' ||
Expand Down Expand Up @@ -170,6 +173,7 @@
checkNgm: false,
showSetting: false,
orgName,
clusterName,
userName,

timeRangeSelector: {
Expand All @@ -183,7 +187,8 @@
24 * 60 * 60
],
customAbsoluteRangePicker: true
}
},
autoRefresh: false
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ export interface ITopSQLConfig {
recentSeconds: number[]
customAbsoluteRangePicker: boolean
}
autoRefresh?: boolean

// for clinic
orgName?: string
clusterName?: string
userName?: string
}

Expand Down
20 changes: 17 additions & 3 deletions ui/packages/tidb-dashboard-lib/src/apps/TopSQL/pages/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import React, {
useContext,
useEffect,
useRef,
useState
useState,
useMemo
} from 'react'
import { Space, Button, Spin, Alert, Tooltip, Drawer, Result } from 'antd'
import {
Expand Down Expand Up @@ -126,6 +127,18 @@ export function TopSQLList() {

const chartRef = useRef<any>(null)

// only for clinic
const clusterInfo = useMemo(() => {
const infos: string[] = []
if (ctx?.cfg.orgName) {
infos.push(`Org: ${ctx?.cfg.orgName}`)
}
if (ctx?.cfg.clusterName) {
infos.push(`Cluster: ${ctx?.cfg.clusterName}`)
}
return infos.join(' | ')
}, [ctx?.cfg.orgName, ctx?.cfg.clusterName])

return (
<>
<div className={styles.container} ref={containerRef}>
Expand Down Expand Up @@ -156,9 +169,9 @@ export function TopSQLList() {
)}

<Card noMarginBottom>
{ctx?.cfg.orgName && (
{clusterInfo && (
<div style={{ marginBottom: 8, textAlign: 'right' }}>
Org: {ctx?.cfg.orgName}
{clusterInfo}
</div>
)}

Expand Down Expand Up @@ -194,6 +207,7 @@ export function TopSQLList() {
disabled={isLoading}
/>
<AutoRefreshButton
defaultValue={ctx?.cfg.autoRefresh === false ? 0 : undefined}
disabled={isLoading}
onRefresh={async () => {
await fetchInstancesAndSelectInstance()
Expand Down

0 comments on commit 4424cc5

Please sign in to comment.