update screenshot

This commit is contained in:
joseph le 2023-09-15 14:01:05 +07:00
parent 6e2308b070
commit ad1bc5300b
3 changed files with 7 additions and 7 deletions

View File

@ -176,9 +176,9 @@ export async function runtimeCheckLogs(folderPath) {
"select * from log_reports where id_file = " +
fileDetect?.id_ldf
);
await screenShot(fileName);
const uriImage = await uploadFileToZulip();
const timeImage = Date.now()
await screenShot(fileName, timeImage);
const uriImage = await uploadFileToZulip(fileName, timeImage);
let listReport = await getListLineByItem(
logsDetect[0].filter((l) => l.line > lastLine)
);

View File

@ -1,6 +1,6 @@
import puppeteer from 'puppeteer';
export const screenShot = async (filename) => {
export const screenShot = async (filename, time) => {
const browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox"],
@ -15,7 +15,7 @@ export const screenShot = async (filename) => {
await bodyHandle.dispose();
await page.setViewport({ width: 1920, height: 500 });
setTimeout(async () => {
await page.screenshot({ path: "app/store/screenshot/"+Date.now()+filename+".png" });
await page.screenshot({ path: "/home/screenshot/"+time+"_"+filename+".png" });
browser.close();
}, 5000);
} catch (error) {

View File

@ -2,7 +2,7 @@ import { FormData } from "zulip-js/lib/helper";
import axios from "axios";
import fs from "fs";
export const uploadFileToZulip = async () => {
export const uploadFileToZulip = async (filename, time) => {
// try {
const ZULIP_API_URL = "https://zulip.ipsupply.com.au/api/v1";
const ZULIP_API_KEY = "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM";
@ -13,7 +13,7 @@ export const uploadFileToZulip = async () => {
try {
const fileStream = fs.createReadStream("app/utils/screenshot.png");
const fileStream = fs.createReadStream("/home/screenshot/"+time+"_"+filename+".png");
const formData = new FormData();
formData.append("file", fileStream);