-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboards and charts): editable tiles | slottable menu items
- add new edit-tile event to dashboard renderer - forward go to explore to analytics chart through tile definition - add new editable property to tile definition that will add an "edit" item to the analytics chart kebab menu. Clicking on edit, will emit an @edit-tile event with the entire GridTile<T> object containing the tile layout, definition and index
- Loading branch information
1 parent
f29661f
commit ee386d3
Showing
12 changed files
with
147 additions
and
94 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
45 changes: 11 additions & 34 deletions
45
packages/analytics/dashboard-renderer/src/components/BarChartRenderer.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 |
---|---|---|
@@ -1,42 +1,19 @@ | ||
<!-- BarChartRenderer.vue --> | ||
<template> | ||
<QueryDataProvider | ||
v-slot="{ data }" | ||
<BaseAnalyticsChartRenderer | ||
:chart-options="chartOptions" | ||
:context="context" | ||
:query="query" | ||
:definition="definition" | ||
:editable="editable" | ||
:extra-props="{ showAnnotations: false }" | ||
:height="height" | ||
:query-ready="queryReady" | ||
> | ||
<div class="analytics-chart"> | ||
<AnalyticsChart | ||
:allow-csv-export="chartOptions.allowCsvExport" | ||
:chart-data="data" | ||
:chart-options="options" | ||
:chart-title="chartOptions.chartTitle" | ||
legend-position="bottom" | ||
:show-annotations="false" | ||
:synthetics-data-key="chartOptions.syntheticsDataKey" | ||
tooltip-title="" | ||
/> | ||
</div> | ||
</QueryDataProvider> | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import BaseAnalyticsChartRenderer from './BaseAnalyticsChartRenderer.vue' | ||
import type { BarChartOptions, RendererProps } from '../types' | ||
import QueryDataProvider from './QueryDataProvider.vue' | ||
import { computed } from 'vue' | ||
import type { AnalyticsChartOptions } from '@kong-ui-public/analytics-chart' | ||
import { AnalyticsChart } from '@kong-ui-public/analytics-chart' | ||
const props = defineProps<RendererProps<BarChartOptions>>() | ||
const options = computed((): AnalyticsChartOptions => ({ | ||
type: props.chartOptions.type, | ||
stacked: props.chartOptions.stacked, | ||
chartDatasetColors: props.chartOptions.chartDatasetColors, | ||
})) | ||
defineProps<RendererProps<BarChartOptions>>() | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.analytics-chart { | ||
height: v-bind('`${height}px`'); | ||
} | ||
</style> |
61 changes: 61 additions & 0 deletions
61
packages/analytics/dashboard-renderer/src/components/BaseAnalyticsChartRenderer.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,61 @@ | ||
<template> | ||
<QueryDataProvider | ||
v-slot="{ data }" | ||
:context="context" | ||
:query="definition.query" | ||
:query-ready="queryReady" | ||
> | ||
<div class="analytics-chart"> | ||
<AnalyticsChart | ||
:allow-csv-export="chartOptions.allowCsvExport" | ||
:chart-data="data" | ||
:chart-options="options" | ||
:chart-title="chartOptions.chartTitle" | ||
legend-position="bottom" | ||
:synthetics-data-key="chartOptions.syntheticsDataKey" | ||
tooltip-title="" | ||
v-bind="extraProps" | ||
> | ||
<template | ||
v-if="editable" | ||
#menu-items | ||
> | ||
<KDropdownItem @click="editTile"> | ||
{{ i18n.t('renderer.edit') }} | ||
</KDropdownItem> | ||
</template> | ||
</AnalyticsChart> | ||
</div> | ||
</QueryDataProvider> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { RendererProps, TileDefinition } from '../types' | ||
import QueryDataProvider from './QueryDataProvider.vue' | ||
import { computed, defineProps } from 'vue' | ||
import type { AnalyticsChartOptions } from '@kong-ui-public/analytics-chart' | ||
import { AnalyticsChart } from '@kong-ui-public/analytics-chart' | ||
import composables from '../composables' | ||
const props = defineProps<RendererProps<any> & { extraProps?: Record<string, any> }>() | ||
const emit = defineEmits<{ | ||
(e: 'edit-tile', tile: TileDefinition): void | ||
}>() | ||
const { i18n } = composables.useI18n() | ||
const options = computed((): AnalyticsChartOptions => ({ | ||
type: props.chartOptions.type, | ||
stacked: props.chartOptions.stacked ?? false, | ||
chartDatasetColors: props.chartOptions.chartDatasetColors, | ||
})) | ||
const editTile = () => { | ||
emit('edit-tile', props.definition) | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.analytics-chart { | ||
height: v-bind('`${height}px`'); | ||
} | ||
</style> |
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
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
52 changes: 11 additions & 41 deletions
52
packages/analytics/dashboard-renderer/src/components/TimeseriesChartRenderer.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 |
---|---|---|
@@ -1,48 +1,18 @@ | ||
<!-- TimeseriesChartRenderer.vue --> | ||
<template> | ||
<QueryDataProvider | ||
v-slot="{ data }" | ||
<BaseAnalyticsChartRenderer | ||
:chart-options="chartOptions" | ||
:context="context" | ||
:query="query" | ||
:definition="definition" | ||
:editable="editable" | ||
:height="height" | ||
:query-ready="queryReady" | ||
> | ||
<div class="analytics-chart"> | ||
<AnalyticsChart | ||
:allow-csv-export="chartOptions.allowCsvExport" | ||
:chart-data="data" | ||
:chart-options="options" | ||
:chart-title="chartOptions.chartTitle" | ||
legend-position="bottom" | ||
:synthetics-data-key="chartOptions.syntheticsDataKey" | ||
tooltip-title="" | ||
/> | ||
</div> | ||
</QueryDataProvider> | ||
/> | ||
</template> | ||
<script setup lang="ts"> | ||
import type { RendererProps, TimeseriesChartOptions } from '../types' | ||
import QueryDataProvider from './QueryDataProvider.vue' | ||
import { computed } from 'vue' | ||
import type { AnalyticsChartOptions } from '@kong-ui-public/analytics-chart' | ||
import { AnalyticsChart } from '@kong-ui-public/analytics-chart' | ||
const props = defineProps<RendererProps<TimeseriesChartOptions>>() | ||
|
||
const options = computed((): AnalyticsChartOptions => { | ||
// Default `stacked` to false. | ||
const stacked = props.chartOptions.stacked ?? false | ||
<script setup lang="ts"> | ||
import BaseAnalyticsChartRenderer from './BaseAnalyticsChartRenderer.vue' | ||
import type { TimeseriesChartOptions, RendererProps } from '../types' | ||
// Note that `fill` and `stacked` are linked; it's not possible to have a non-filled stacked chart. | ||
// This matches our intuitions about how these charts work. | ||
return { | ||
type: props.chartOptions.type, | ||
stacked, | ||
chartDatasetColors: props.chartOptions.chartDatasetColors, | ||
} | ||
}) | ||
defineProps<RendererProps<TimeseriesChartOptions>>() | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.analytics-chart { | ||
height: v-bind('`${height}px`'); | ||
} | ||
</style> |
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
Oops, something went wrong.