Skip to content

Commit

Permalink
Fix to render panels and follow the selected timezone from URL query …
Browse files Browse the repository at this point in the history
…if specified. (#224)

* Update browser.ts

Fixing the rendered panel timezone with a custom TZ from URL queries

* add setTimezone

* Add setTimezone to renderCSV

update the browser timezone in csv rendering
  • Loading branch information
Bujupah authored Jun 10, 2021
1 parent 44505eb commit 378d82e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ export class Browser {

return launcherOptions;
}

async setTimezone(page, options) {
const timezone = options.timezone || this.config.timezone;
if (timezone) {
await page.emulateTimezone(timezone);
}
}

async preparePage(page: any, options: any) {
if (this.config.verboseLogging) {
Expand Down Expand Up @@ -193,6 +200,7 @@ export class Browser {
});

await this.preparePage(page, options);
await this.setTimezone(page, options);

if (this.config.verboseLogging) {
this.log.debug('Moving mouse on page', 'x', options.width, 'y', options.height);
Expand Down Expand Up @@ -255,7 +263,8 @@ export class Browser {

async exportCSV(page: any, options: any): Promise<RenderCSVResponse> {
await this.preparePage(page, options);

await this.setTimezone(page, options);

const downloadPath = uniqueFilename(os.tmpdir());
fs.mkdirSync(downloadPath);
const watcher = chokidar.watch(downloadPath);
Expand Down

0 comments on commit 378d82e

Please sign in to comment.