Skip to content

Commit

Permalink
feat: add running tasks count card
Browse files Browse the repository at this point in the history
  • Loading branch information
strahe committed Nov 12, 2024
1 parent a50381b commit 2db16fe
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ui/src/gql/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,9 @@ export const GetRunningTasks = gql`
}
${taskFragment}
`

export const GetTasksCount = gql`
query GetTasksCount {
tasksCount
}
`
3 changes: 2 additions & 1 deletion ui/src/views/overview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ChainConnectivity from '@/views/widgets/data/ChainConnectivity.vue'
import StorageOverview from '@/views/widgets/statistics/StorageOverview.vue'
import CompletedTaskOverviewChart from '@/views/widgets/chart/CompletedTaskOverviewChart.vue'
import BlocksMined from '@/views/widgets/statistics/BlocksMined.vue'
import RunningTasksCount from '@/views/widgets/statistics/RunningTasksCount.vue'
</script>

<template>
Expand Down Expand Up @@ -38,7 +39,7 @@ import BlocksMined from '@/views/widgets/statistics/BlocksMined.vue'
md="3"
sm="6"
>
<MinerPower />
<RunningTasksCount />
</v-col>
</v-row>
<v-row class="mb-0">
Expand Down
3 changes: 3 additions & 0 deletions ui/src/views/widgets/chart/MiningOverviewChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const chartOptions = computed(() => {
dataLabels: {
total: {
enabled: true,
style: {
color: '#eff0f1',
},
},
},
},
Expand Down
48 changes: 48 additions & 0 deletions ui/src/views/widgets/statistics/RunningTasksCount.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<script setup lang="ts">
import { computed, ComputedRef, ref } from 'vue'
import { useQuery } from '@vue/apollo-composable'
import { IconBrandAsana } from '@tabler/icons-vue'
import { GetTasksCount } from '@/gql/task'
import moment from 'moment'
const { result, onResult } = useQuery(GetTasksCount, null, () => ({
fetchPolicy: 'cache-first',
pollInterval: 3000,
}))
const updateTime = ref(new Date())
const count: ComputedRef<number> = computed(() => result.value?.tasksCount || 0)
onResult(() => {
updateTime.value = new Date()
})
</script>

<template>
<v-card elevation="0">
<v-card variant="outlined">
<v-card-text>
<div class="d-flex align-items-center justify-space-between">
<div>
<h5 class="text-h5">{{ $t('fields.Running Tasks') }}</h5>
<h3 class="text-h3 my-2">{{ count }}</h3>
<h6 class="text-caption font-weight-medium mb-0">
updated {{ moment(updateTime).fromNow() }}
</h6>
</div>
<span class="d-flex align-center">
<v-btn
:icon="IconBrandAsana"
rounded="md"
size="small"
variant="flat"
/>
</span>
</div>
</v-card-text>
</v-card>
</v-card>
</template>

<style scoped lang="scss">
</style>

0 comments on commit 2db16fe

Please sign in to comment.