diff --git a/packages/analytics/analytics-chart/src/components/AnalyticsChart.vue b/packages/analytics/analytics-chart/src/components/AnalyticsChart.vue index 6cf40329ff..01fd31f79e 100644 --- a/packages/analytics/analytics-chart/src/components/AnalyticsChart.vue +++ b/packages/analytics/analytics-chart/src/components/AnalyticsChart.vue @@ -68,6 +68,7 @@ {{ i18n.t('csvExport.exportButton') }} + @@ -230,6 +231,11 @@ const props = defineProps({ required: false, default: false, }, + showMenu: { + type: Boolean, + required: false, + default: false, + }, }) const emit = defineEmits<{ @@ -361,7 +367,7 @@ const showChartHeader = computed(() => { return (hasValidChartData.value && resultSetTruncated.value && maxEntitiesShown.value) || props.chartTitle || (props.allowCsvExport && hasValidChartData.value) }) -const hasMenuOptions = computed(() => (props.allowCsvExport && hasValidChartData.value) || !!props.goToExplore) +const hasMenuOptions = computed(() => (props.allowCsvExport && hasValidChartData.value) || !!props.goToExplore || props.showMenu) const timeSeriesGranularity = computed(() => { diff --git a/packages/analytics/dashboard-renderer/sandbox/pages/RendererDemo.vue b/packages/analytics/dashboard-renderer/sandbox/pages/RendererDemo.vue index 9b3323ebeb..e603e58700 100644 --- a/packages/analytics/dashboard-renderer/sandbox/pages/RendererDemo.vue +++ b/packages/analytics/dashboard-renderer/sandbox/pages/RendererDemo.vue @@ -13,6 +13,7 @@ :class="{ 'custom-styling': isToggled}" :config="(dashboardConfig as DashboardConfig)" :context="context" + @edit-tile="onEditTile" > diff --git a/packages/analytics/dashboard-renderer/src/components/BaseAnalyticsChartRenderer.vue b/packages/analytics/dashboard-renderer/src/components/BaseAnalyticsChartRenderer.vue new file mode 100644 index 0000000000..65357da1d9 --- /dev/null +++ b/packages/analytics/dashboard-renderer/src/components/BaseAnalyticsChartRenderer.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/packages/analytics/dashboard-renderer/src/components/DashboardRenderer.vue b/packages/analytics/dashboard-renderer/src/components/DashboardRenderer.vue index b037b76ea0..dbd7873f72 100644 --- a/packages/analytics/dashboard-renderer/src/components/DashboardRenderer.vue +++ b/packages/analytics/dashboard-renderer/src/components/DashboardRenderer.vue @@ -26,6 +26,7 @@ :definition="tile.meta" :height="tile.layout.size.rows * (config.tileHeight || DEFAULT_TILE_HEIGHT) + parseInt(KUI_SPACE_70, 10)" :query-ready="queryReady" + @edit-tile="onEditTile(tile)" /> @@ -53,6 +54,10 @@ const props = defineProps<{ config: DashboardConfig, }>() +const emit = defineEmits<{ + (e: 'edit-tile', tile: GridTile): void +}>() + const { i18n } = composables.useI18n() // Note: queryBridge is not directly used by the DashboardRenderer component. It is required by many of the @@ -129,7 +134,7 @@ const gridTiles = computed(() => { }) const mergedContext = computed(() => { - let { tz, refreshInterval } = props.context + let { tz, refreshInterval, editable } = props.context if (!tz) { tz = (new Intl.DateTimeFormat()).resolvedOptions().timeZone @@ -140,17 +145,26 @@ const mergedContext = computed(() => { refreshInterval = DEFAULT_TILE_REFRESH_INTERVAL_MS } + if (editable === undefined) { + editable = false + } + return { ...props.context, tz, timeSpec: timeSpec.value, refreshInterval, + editable, } }) // Right now, tiles don't have unique keys. Perhaps in the future they will, // and we can use that instead of `index` as the fragment key. +const onEditTile = (tile: GridTile) => { + emit('edit-tile', tile) +} + diff --git a/packages/analytics/dashboard-renderer/src/locales/en.json b/packages/analytics/dashboard-renderer/src/locales/en.json index b823239c6d..b41b0e493d 100644 --- a/packages/analytics/dashboard-renderer/src/locales/en.json +++ b/packages/analytics/dashboard-renderer/src/locales/en.json @@ -5,7 +5,8 @@ "24h": "Last 24-Hour Summary", "7d": "Last 7-Day Summary", "30d": "Last 30-Day Summary" - } + }, + "edit": "Edit" }, "queryDataProvider": { "timeRangeExceeded": "The time range for this report is outside of your organization's data retention period" diff --git a/packages/analytics/dashboard-renderer/src/types/dashboard-renderer-types.ts b/packages/analytics/dashboard-renderer/src/types/dashboard-renderer-types.ts index a1fac860ce..974298e930 100644 --- a/packages/analytics/dashboard-renderer/src/types/dashboard-renderer-types.ts +++ b/packages/analytics/dashboard-renderer/src/types/dashboard-renderer-types.ts @@ -22,6 +22,7 @@ export interface DashboardRendererContext { timeSpec?: TimeRangeV4 tz?: string refreshInterval?: number + editable?: boolean } type FromSchemaWithOptions = FromSchema