-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: database performance insights (#2361)
- Loading branch information
Showing
38 changed files
with
1,955 additions
and
2,223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div class="rounded border text-base"> | ||
<div | ||
class="flex cursor-pointer select-none flex-row items-center justify-between gap-2 p-4" | ||
@click="toggleVisibility" | ||
:class="{ | ||
'!pb-2': isVisible | ||
}" | ||
> | ||
<div> | ||
<p class="font-medium text-gray-800"> | ||
{{ label }} | ||
</p> | ||
<p class="mt-2 text-sm text-gray-700" v-if="subLabel"> | ||
{{ subLabel }} | ||
</p> | ||
</div> | ||
<slot name="actions" v-if="isVisible"></slot> | ||
</div> | ||
|
||
<div v-if="isVisible" class="text-sm leading-normal"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'ToggleContent', | ||
props: { | ||
label: { | ||
type: String, | ||
required: true | ||
}, | ||
subLabel: { | ||
type: String, | ||
default: '' | ||
} | ||
}, | ||
data() { | ||
return { | ||
isVisible: false | ||
}; | ||
}, | ||
methods: { | ||
toggleVisibility() { | ||
this.isVisible = !this.isVisible; | ||
} | ||
} | ||
}; | ||
</script> |
76 changes: 76 additions & 0 deletions
76
dashboard/src2/components/devtools/database/DatabaseAddIndexButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template> | ||
<Button v-if="isJobRunning" @click="viewJob" variant="ghost" class="w-full" | ||
>View Job</Button | ||
> | ||
<Button | ||
v-else | ||
@click="addIndex" | ||
:loading="this.$resources.addIndex.loading" | ||
loadingText="Adding Index" | ||
iconLeft="plus" | ||
variant="ghost" | ||
class="w-full" | ||
>Add DB Index</Button | ||
> | ||
</template> | ||
<script> | ||
import { toast } from 'vue-sonner'; | ||
export default { | ||
props: { | ||
row: { type: Object, required: true }, | ||
site: { type: String, required: true } | ||
}, | ||
data() { | ||
return { | ||
isJobRunning: false, | ||
jobName: null | ||
}; | ||
}, | ||
resources: { | ||
addIndex() { | ||
return { | ||
url: 'press.api.client.run_doc_method', | ||
initialData: {}, | ||
makeParams: () => { | ||
return { | ||
dt: 'Site', | ||
dn: this.site, | ||
method: 'add_database_index', | ||
args: { | ||
table: this.row['Table'], | ||
column: this.row['Column'] | ||
} | ||
}; | ||
}, | ||
onSuccess: data => { | ||
if (data?.message) { | ||
if (data?.message?.success) { | ||
toast.success(data?.message?.message); | ||
this.isJobRunning = true; | ||
this.jobName = data?.message?.job_name; | ||
} else { | ||
toast.error(data?.message?.message); | ||
} | ||
} | ||
}, | ||
auto: false | ||
}; | ||
} | ||
}, | ||
methods: { | ||
addIndex() { | ||
this.$resources.addIndex.submit(); | ||
}, | ||
viewJob() { | ||
if (this.jobName) { | ||
window.open( | ||
this.$router.resolve( | ||
`/sites/${this.site}/insights/jobs/${this.jobName}` | ||
).href, | ||
'_blank' | ||
); | ||
} | ||
} | ||
} | ||
}; | ||
</script> |
55 changes: 55 additions & 0 deletions
55
dashboard/src2/components/devtools/database/DatabaseProcessKillButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<p v-if="isKilled">Process Killed</p> | ||
<Button | ||
v-else | ||
@click="killProcess" | ||
:loading="this.$resources.killProcess.loading" | ||
loadingText="Killing" | ||
iconLeft="trash" | ||
variant="ghost" | ||
class="w-full" | ||
>Kill Process</Button | ||
> | ||
</template> | ||
<script> | ||
import { toast } from 'vue-sonner'; | ||
export default { | ||
props: { | ||
row: { type: Object, required: true }, | ||
site: { type: String, required: true } | ||
}, | ||
data() { | ||
return { | ||
isKilled: false | ||
}; | ||
}, | ||
resources: { | ||
killProcess() { | ||
return { | ||
url: 'press.api.client.run_doc_method', | ||
initialData: {}, | ||
makeParams: () => { | ||
return { | ||
dt: 'Site', | ||
dn: this.site, | ||
method: 'kill_database_process', | ||
args: { | ||
id: this.row.ID | ||
} | ||
}; | ||
}, | ||
onSuccess: data => { | ||
this.isKilled = true; | ||
toast.success('Database Process Killed'); | ||
}, | ||
auto: false | ||
}; | ||
} | ||
}, | ||
methods: { | ||
killProcess() { | ||
this.$resources.killProcess.submit(); | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.