PublicDashboards: Support timezone on query API (#68560)

This commit is contained in:
Ezequiel Victorero
2023-06-14 17:35:01 -03:00
committed by GitHub
parent 7ea9be6832
commit fc374f93a3
6 changed files with 253 additions and 97 deletions

View File

@@ -113,7 +113,11 @@ export class PublicDashboardDataSource extends DataSourceApi<DataQuery, DataSour
intervalMs,
maxDataPoints,
queryCachingTTL,
timeRange: { from: fromRange.valueOf().toString(), to: toRange.valueOf().toString() },
timeRange: {
from: fromRange.valueOf().toString(),
to: toRange.valueOf().toString(),
timezone: this.getBrowserTimezone(),
},
};
return getBackendSrv()
@@ -155,4 +159,9 @@ export class PublicDashboardDataSource extends DataSourceApi<DataQuery, DataSour
testDatasource(): Promise<TestDataSourceResponse> {
return Promise.resolve({ message: '', status: '' });
}
// Try to get the browser timezone otherwise return blank
getBrowserTimezone(): string {
return window.Intl?.DateTimeFormat().resolvedOptions()?.timeZone || '';
}
}