Skip to content

Commit

Permalink
fix: cannot scroll on dashboard page
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Jan 13, 2025
1 parent 00f8c1f commit 9cae946
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/src2/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function downloadDashboardImage() {
</header>

<div class="relative flex h-full w-full overflow-hidden">
<div ref="dashboardContainer" class="h-fit flex-1 overflow-y-auto p-4">
<div ref="dashboardContainer" class="flex-1 overflow-y-auto p-4">
<VueGridLayout
v-if="dashboard.doc.items.length > 0"
class="h-fit w-full"
Expand Down
18 changes: 12 additions & 6 deletions frontend/src2/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ export function showErrorToast(err: Error, raise = true) {
export function downloadImage(element: HTMLElement, filename: string, scale = 1, options = {}) {
return domtoimage
.toPng(element, {
height: element.offsetHeight * scale,
width: element.offsetWidth * scale,
height: element.scrollHeight * scale,
width: element.scrollWidth * scale,
style: {
transform: 'scale(' + scale + ')',
transformOrigin: 'top left',
width: element.offsetWidth + 'px',
height: element.offsetHeight + 'px',
width: element.scrollWidth + 'px',
height: element.scrollHeight + 'px',
},
bgColor: 'white',
...options,
Expand Down Expand Up @@ -395,9 +395,11 @@ export function createHeaders(columns: QueryResultColumn[]) {
// i.e first day of each month, then we format the values as 'Oct 2016', 'Nov 2016', 'Dec 2016'

for (let headerRow of groupedHeaders) {
const areDates = areValidDates(headerRow.map((header) => header.label))
if (!areDates) continue

const areFirstOfYear = areFirstDayOfYear(headerRow.map((header) => header.label))
const areFirstOfMonth = areFirstDayOfMonth(headerRow.map((header) => header.label))
const areDates = areValidDates(headerRow.map((header) => header.label))

for (let header of headerRow) {
if (!isValidDate(header.label)) continue
Expand Down Expand Up @@ -431,7 +433,11 @@ function areValidDates(data: string[]) {
}

function isValidDate(value: string) {
return !isNaN(new Date(value).getTime())
// almost all dates will have a valid 4 digit year
if (!value) return false
if (!/\d{4}/.test(value)) return false
const date = new Date(value)
return !isNaN(date.getTime()) && date.getFullYear() >= 1900 && date.getFullYear() <= 2900
}

const callCache = new Map<string, any>()
Expand Down

0 comments on commit 9cae946

Please sign in to comment.