Skip to content

Commit

Permalink
chore: show loading while downloading chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Jan 18, 2024
1 parent 0082ab1 commit 2e65feb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions frontend/src/query/ChartSection.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup>
import { downloadImage } from '@/utils'
import widgets from '@/widgets/widgets'
import { computed, inject, ref } from 'vue'
import ChartActionButtons from './ChartActionButtons.vue'
import ChartSectionEmptySvg from './ChartSectionEmptySvg.vue'
import ChartTypeSelector from './ChartTypeSelector.vue'
import { downloadImage } from '@/utils'
const query = inject('query')
const chartRef = ref(null)
Expand Down Expand Up @@ -44,6 +44,7 @@ const fullscreenDialog = ref(false)
function showInFullscreenDialog() {
fullscreenDialog.value = true
}
const downloading = ref(false)
function downloadChartImage() {
if (!chartRef.value) {
$notify({
Expand All @@ -52,8 +53,11 @@ function downloadChartImage() {
})
return
}
downloading.value = true
const title = query.chart.doc.options.title || query.doc.title
downloadImage(chartRef.value.$el, `${title}.png`)
downloadImage(chartRef.value.$el, `${title}.png`).then(() => {
downloading.value = false
})
}
</script>
Expand Down Expand Up @@ -100,7 +104,12 @@ function downloadChartImage() {
:key="JSON.stringify(query.chart.doc)"
/>
<div class="absolute top-0 right-0 p-2">
<Button variant="outline" @click="downloadChartImage" icon="download">
<Button
variant="outline"
@click="downloadChartImage"
:loading="downloading"
icon="download"
>
</Button>
</div>
</div>
Expand Down

0 comments on commit 2e65feb

Please sign in to comment.