Skip to content

Commit

Permalink
tweak(perf_insight): update apis & workflow (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
shhdgit authored Apr 3, 2023
1 parent e4ebe3a commit 96f8d98
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 313 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import AppMonitoring from '~/apps/Monitoring/meta'
import AppClusterInfo from '~/apps/ClusterInfo/meta'
import AppTopSQL from '~/apps/TopSQL/meta'
import AppSlowQuery from '~/apps/SlowQuery/meta'
import AppSQLAdvisor from '~/apps/SQLAdvisor/meta'
import AppStatement from '~/apps/Statement/meta'
import AppKeyViz from '~/apps/KeyViz/meta'
import AppSystemReport from '~/apps/SystemReport/meta'
Expand Down Expand Up @@ -157,7 +156,6 @@ async function webPageStart(appOptions: AppOptions) {
.register(AppClusterInfo)
.register(AppKeyViz)
.register(AppTopSQL)
.register(AppSQLAdvisor)
.register(AppStatement)
.register(AppSystemReport)
.register(AppSlowQuery)
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/tidb-dashboard-for-dbaas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pingcap/tidb-dashboard-for-dbaas",
"version": "0.0.91",
"version": "0.0.92",
"main": "dist/main.js",
"module": "dist/main.js",
"files": [
Expand Down
144 changes: 47 additions & 97 deletions ui/packages/tidb-dashboard-for-dbaas/src/apps/SQLAdvisor/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '@pingcap/tidb-dashboard-lib'

import { IGlobalConfig } from '~/utils/global-config'
import client from '~/client'

class DataSource implements ISQLAdvisorDataSource {
constructor(public globalConfig: IGlobalConfig) {}
Expand All @@ -12,121 +13,70 @@ class DataSource implements ISQLAdvisorDataSource {
orgId = this.clusterInfo.orgId
clusterId = this.clusterInfo.clusterId
projectId = this.clusterInfo.projectId
token = this.globalConfig.apiToken
performanceInsightBaseUrl = this.globalConfig.performanceInsightBaseUrl

client = client.getAxiosInstance()

tuningListGet(pageNumber?: number, pageSize?: number) {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=GetTunedIndexLists&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}&pageNumber=${pageNumber}&pageSize=${pageSize}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
return this.client
.get(
`${this.performanceInsightBaseUrl}/performance_insight/index_advisor/results?page=${pageNumber}&limit=${pageSize}`
)
.then((res) => res.data)
}

tuningTaskCreate(startTime: number, endTime: number) {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=CreateAdviseTask&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}&startTime=${startTime}&endTime=${endTime}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
tuningDetailGet(id: number) {
return this.client
.get(
`${this.performanceInsightBaseUrl}/performance_insight/index_advisor/results/${id}`
)
.then((res) => res.data)
}

cancelRunningTask() {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=CancelAdvisorTask&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
tuningLatestGet() {
return this.client
.get(`${this.performanceInsightBaseUrl}/performance_insight/tasks/latest`)
.then((res) => res.data)
}

tuningTaskStatusGet() {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=IsOKForTuningTask&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
tuningTaskCreate() {
return this.client
.post(`${this.performanceInsightBaseUrl}/performance_insight/tasks`, {})
.then((res) => res.data)
}

tuningDetailGet(id: number) {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=GetTuningResult&ID=${id}&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
tuningTaskCancel(id: number) {
return this.client
.delete(
`${this.performanceInsightBaseUrl}/performance_insight/tasks/${id}`
)
.then((res) => res.data)
}

registerUserDB(params: { userName: string; password: string }) {
activateDBConnection(params: { userName: string; password: string }) {
const { userName, password } = params
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=RegisterUserDB&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}&userName=${userName}&password=${password}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
}

// registerUserDB(params: { userName: string; password: string }) {
// // const { userName, password } = params
// return fetch(
// `${this.performanceInsightBaseUrl}?BackMethod=RegisterUserDB&orgId=${this.orgId}&projectId=${this.projectId}&clusterId=${this.clusterId}`,
// {
// method: 'POST',
// headers: {
// token: `Bearer ${this.token}`
// },
// body: JSON.stringify(params)
// }
// ).then((res) => res.json())
// }

unRegisterUserDB() {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=UnRegisterUserDB&clusterId=${this.clusterId}&projectId=${this.projectId}&orgId=${this.orgId}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
return this.client
.post(
`${this.performanceInsightBaseUrl}/performance_insight/tidb_connection`,
{ user: userName, password }
)
.then((res) => res.data)
}

registerUserDBStatusGet() {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=IsTiDBOKForAdvisor&clusterId=${this.clusterId}&projectId=${this.projectId}&orgId=${this.orgId}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
deactivateDBConnection() {
return this.client
.delete(
`${this.performanceInsightBaseUrl}/performance_insight/tidb_connection`
)
.then((res) => res.data)
}

sqlValidationGet() {
return fetch(
`${this.performanceInsightBaseUrl}?BackMethod=CheckIfUserTiDBOK&clusterId=${this.clusterId}&projectId=${this.projectId}&orgId=${this.orgId}`,
{
headers: {
token: `Bearer ${this.token}`
}
}
).then((res) => res.json())
checkDBConnection() {
return this.client
.get(
`${this.performanceInsightBaseUrl}/performance_insight/tidb_connection`
)
.then((res) => res.data)
}
}

Expand Down
Loading

0 comments on commit 96f8d98

Please sign in to comment.