| |
| |
| |
| |
| |
| |
|
|
| <template> |
| <div class="row sparklinesGrid"> |
| <div |
| v-for="(sparkline, index) in flatSparklines" |
| :key="index" |
| :class="columnClasses" |
| > |
| <SparklineCard |
| :sparkline="sparkline" |
| :are-sparklines-linkable="areSparklinesLinkable" |
| :all-metrics-documentation="allMetricsDocumentation" |
| /> |
| </div> |
| </div> |
| </template> |
|
|
| <script lang="ts"> |
| import { |
| computed, |
| defineComponent, |
| nextTick, |
| onMounted, |
| PropType, |
| } from 'vue'; |
| import SparklineCard from '../Sparklines/SparklineCard.vue'; |
| import { SparklineEntry } from '../Sparklines/types'; |
| |
| export default defineComponent({ |
| name: 'SparklinesGrid', |
| components: { |
| SparklineCard, |
| }, |
| props: { |
| sparklines: { |
| type: Object as PropType<Record<string, SparklineEntry[]>>, |
| required: true, |
| }, |
| areSparklinesLinkable: { |
| type: Boolean, |
| default: true, |
| }, |
| |
| |
| allMetricsDocumentation: { |
| type: Object as PropType<Record<string, string>>, |
| default: () => ({}), |
| }, |
| isWidget: { |
| type: Boolean, |
| default: false, |
| }, |
| }, |
| setup(props) { |
| |
| |
| |
| |
| const flatSparklines = computed<SparklineEntry[]>( |
| () => ([] as SparklineEntry[]) |
| .concat(...Object.values(props.sparklines || {})) |
| .filter((sparkline) => !!sparkline.url) |
| .sort((a, b) => a.order - b.order), |
| ); |
| |
| |
| |
| const columnClasses = computed(() => (props.isWidget ? 'col s6' : 'col s6 m6 l4 xl3')); |
| |
| onMounted(() => { |
| |
| |
| nextTick(() => { |
| window.initializeSparklines(); |
| }); |
| }); |
| |
| return { |
| flatSparklines, |
| columnClasses, |
| }; |
| }, |
| }); |
| </script> |
|
|