diff --git a/pkg/apiserver/debugapi/apis.go b/pkg/apiserver/debugapi/apis.go index 58524d902a..c1741c3d10 100644 --- a/pkg/apiserver/debugapi/apis.go +++ b/pkg/apiserver/debugapi/apis.go @@ -105,6 +105,10 @@ var apiEndpoints = []endpoint.APIDefinition{ Component: topo.KindTiDB, Path: "/ddl/history", Method: resty.MethodGet, + QueryParams: []endpoint.APIParamDefinition{ + endpoint.APIParamInt("start_job_id", false), + endpoint.APIParamIntWithDefaultVal("limit", false, "10"), + }, }, { ID: "tidb_server_info", diff --git a/pkg/apiserver/debugapi/endpoint/models.go b/pkg/apiserver/debugapi/endpoint/models.go index f3e72f1354..75876f7f49 100644 --- a/pkg/apiserver/debugapi/endpoint/models.go +++ b/pkg/apiserver/debugapi/endpoint/models.go @@ -46,6 +46,7 @@ func (d *APIParamDefinition) Resolve(value string) ([]string, error) { // UIComponentTextProps is the type of UIComponentProps when UIComponentKind is "text". type UIComponentTextProps struct { Placeholder string `json:"placeholder"` + DefaultVal string `json:"default_val"` } func APIParamText(name string, required bool) APIParamDefinition { @@ -57,12 +58,21 @@ func APIParamText(name string, required bool) APIParamDefinition { } func APIParamInt(name string, required bool) APIParamDefinition { + return APIParamIntWithDefaultVal(name, required, "") +} + +func APIParamIntWithDefaultVal(name string, required bool, defVal string) APIParamDefinition { + placeHolder := "(int)" + if defVal != "" { + placeHolder = fmt.Sprintf("(int, default: %s)", defVal) + } return APIParamDefinition{ Name: name, Required: required, UIComponentKind: "text", UIComponentProps: UIComponentTextProps{ - Placeholder: "(int)", + Placeholder: placeHolder, + DefaultVal: defVal, }, OnResolve: func(value string) ([]string, error) { if _, err := strconv.Atoi(value); err != nil { diff --git a/ui/packages/tidb-dashboard-for-op/src/utils/distro/strings_res.json b/ui/packages/tidb-dashboard-for-op/src/utils/distro/strings_res.json index ab075ffcf6..50381b2716 100644 --- a/ui/packages/tidb-dashboard-for-op/src/utils/distro/strings_res.json +++ b/ui/packages/tidb-dashboard-for-op/src/utils/distro/strings_res.json @@ -1,7 +1 @@ -{ - "tidb": "TiDB", - "tikv": "TiKV", - "pd": "PD", - "tiflash": "TiFlash", - "ticdc": "TiCDC" -} +{"tidb":"TiDB","tikv":"TiKV","pd":"PD","tiflash":"TiFlash","ticdc":"TiCDC"} \ No newline at end of file diff --git a/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/apilist/ApiForm.tsx b/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/apilist/ApiForm.tsx index 9c96a3f361..a41a690481 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/apilist/ApiForm.tsx +++ b/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/apilist/ApiForm.tsx @@ -51,10 +51,17 @@ export default function ApiForm({ setLoading(true) const { [endpointHostParamKey]: host, ...p } = values const [hostname, port] = host.split(':') - // filter the null value params const param_values = Object.entries(p).reduce((prev, [k, v]) => { if (!(isUndefined(v) || isNull(v) || v === '')) { prev[k] = v + } else { + // handle the null value params + // fill it with the default value if it has + const param = params.find((p) => p.name === k) + const defVal = (param?.ui_props as any)?.default_val + if (!!defVal) { + prev[k] = defVal + } } return prev }, {}) diff --git a/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/translations/en.yaml b/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/translations/en.yaml index 1237da7be0..28add18fa2 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/translations/en.yaml +++ b/ui/packages/tidb-dashboard-lib/src/apps/DebugAPI/translations/en.yaml @@ -24,7 +24,7 @@ debug_api: tidb_schema_by_db: Schema Information - by Database tidb_schema_by_table: Schema Information - by Database + Table tidb_schema_by_table_id: Schema and Table Information - by TableID - tidb_ddl_history: DDL History - All + tidb_ddl_history: DDL History tidb_server_info: Server Information - Current tidb_all_servers_info: Server Information - All Servers tidb_all_regions_meta: Region - All @@ -44,7 +44,6 @@ debug_api: tidb_schema_db: Schema Information - by Database tidb_schema_db_table: Schema Information - by Database + Table tidb_dbtable_tableid: Schema and Table Information - by TableID - # tidb_ddl_history: DDL History - All tidb_info: Server Information - Current tidb_info_all: Server Information - All Servers tidb_regions_meta: Region - All