-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dashboards and charts): editable tiles | slottable menu items #1758
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
42 changes: 9 additions & 33 deletions
42
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,18 @@ | ||
<!-- BarChartRenderer.vue --> | ||
<template> | ||
<QueryDataProvider | ||
v-slot="{ data }" | ||
<BaseAnalyticsChartRenderer | ||
:chart-options="chartOptions" | ||
:context="context" | ||
:extra-props="{ showAnnotations: false }" | ||
:height="height" | ||
:query="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" | ||
: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> |
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
<template> | ||
<QueryDataProvider | ||
v-slot="{ data }" | ||
:context="context" | ||
:query="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" | ||
:show-menu="context.editable" | ||
:synthetics-data-key="chartOptions.syntheticsDataKey" | ||
tooltip-title="" | ||
v-bind="extraProps" | ||
> | ||
<template | ||
v-if="context.editable" | ||
#menu-items | ||
> | ||
<KDropdownItem @click="editTile"> | ||
{{ i18n.t('renderer.edit') }} | ||
</KDropdownItem> | ||
</template> | ||
</AnalyticsChart> | ||
</div> | ||
</QueryDataProvider> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { RendererProps } 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'): 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') | ||
} | ||
</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
49 changes: 9 additions & 40 deletions
49
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,17 @@ | ||
<!-- TimeseriesChartRenderer.vue --> | ||
<template> | ||
<QueryDataProvider | ||
v-slot="{ data }" | ||
<BaseAnalyticsChartRenderer | ||
:chart-options="chartOptions" | ||
:context="context" | ||
:height="height" | ||
:query="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="" | ||
/> | ||
</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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a type error here that's somehow getting past CI... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's from updates to analytics-utilities which introduced the
ai
datasource, while the provider props in metrics provider defines datasource property like so:datasource?: "basic" | "advanced" | undefined;
Not sure if my change is the right one, or we should add
ai
to the acceptable datasources in MetricsProviderThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. I'll make a note to look at this later. I think this is the fault of the schema; it shouldn't allow setting
ai
as a datasource for metric cards. I think what you have for now is fine.