Skip to content

Commit

Permalink
fix: app reports nits (#2788)
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoCasa committed Dec 6, 2023
1 parent b5f5355 commit 0b13f2d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions frontend/src/lib/components/apps/editor/AppReportsDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,21 @@
sendUserToast('App reporting disabled')
}
const appPreviewScript = `import puppeteer from \'puppeteer-core\';
const appPreviewScript = `import puppeteer from 'puppeteer-core';
export async function main(app_path: string, startup_duration = 5, kind: 'pdf' | 'png' = 'pdf') {
const browser = await puppeteer.launch({ headless: \'new\', executablePath: \'/usr/bin/chromium\', args: [\'--no-sandbox\'] });
const browser = await puppeteer.launch({ headless: 'new', executablePath: '/usr/bin/chromium', args: ['--no-sandbox'] });
const page = await browser.newPage();
await page.setCookie({
"name": "token",
"value": Bun.env["WM_TOKEN"],
"domain": Bun.env["WM_BASE_URL"]?.replace(/https?:\\/\\//, \'\')
"domain": Bun.env["WM_BASE_URL"]?.replace(/https?:\\/\\//, '')
})
page
.on('console', msg =>
console.log(msg.type().substr(0, 3).toUpperCase() + " " + msg.text()))
.on('pageerror', ({ msg }) => console.log(msg))
.on('response', response => {
console.log(response.status, response.url);
})
.on('requestfailed', request => {
console.log(request.failure().errorText, request.url);
});
await page.goto(Bun.env["WM_BASE_URL"] + \'/apps/get/\' + app_path + \'?workspace=\' + Bun.env["WM_WORKSPACE"]);
.on('pageerror', ({ msg }) => console.log(msg));
await page.setViewport({ width: 1200, height: 2000 });
await page.goto(Bun.env["WM_BASE_URL"] + '/apps/get/' + app_path + '?workspace=' + Bun.env["WM_WORKSPACE"] + "&hideRefreshBar=true&hideEditBtn=true");
await page.waitForSelector("#app-content", { timeout: 20000 })
await new Promise((resolve, _) => {
setTimeout(resolve, startup_duration * 1000)
Expand All @@ -167,7 +162,7 @@ export async function main(app_path: string, startup_duration = 5, kind: 'pdf' |
await page.$eval("#content", el => el.classList.remove("md:pl-12"))
await page.$$eval(".app-component-refresh-btn", els => els.forEach(el => el.remove()))
await page.$$eval(".app-table-footer-btn", els => els.forEach(el => el.remove()))
const elem = await page.$(\'#app-content\');
const elem = await page.$('#app-content');
const { height } = await elem.boundingBox();
await page.setViewport({ width: 1200, height });
await new Promise((resolve, _) => {
Expand All @@ -182,7 +177,7 @@ export async function main(app_path: string, startup_duration = 5, kind: 'pdf' |
type: "png"
});
await browser.close();
return Buffer.from(screenshot).toString(\'base64\');
return Buffer.from(screenshot).toString('base64');
}`
const notificationScripts = {
Expand Down

0 comments on commit 0b13f2d

Please sign in to comment.