update screenshot
This commit is contained in:
		
							parent
							
								
									6e2308b070
								
							
						
					
					
						commit
						ad1bc5300b
					
				| 
						 | 
					@ -176,9 +176,9 @@ export async function runtimeCheckLogs(folderPath) {
 | 
				
			||||||
                    "select * from log_reports where id_file = " +
 | 
					                    "select * from log_reports where id_file = " +
 | 
				
			||||||
                      fileDetect?.id_ldf
 | 
					                      fileDetect?.id_ldf
 | 
				
			||||||
                  );
 | 
					                  );
 | 
				
			||||||
 | 
					                    const timeImage = Date.now()
 | 
				
			||||||
                  await screenShot(fileName);
 | 
					                  await screenShot(fileName, timeImage);
 | 
				
			||||||
                  const uriImage = await uploadFileToZulip();
 | 
					                  const uriImage = await uploadFileToZulip(fileName, timeImage);
 | 
				
			||||||
                  let listReport = await getListLineByItem(
 | 
					                  let listReport = await getListLineByItem(
 | 
				
			||||||
                    logsDetect[0].filter((l) => l.line > lastLine)
 | 
					                    logsDetect[0].filter((l) => l.line > lastLine)
 | 
				
			||||||
                  );
 | 
					                  );
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
import puppeteer from 'puppeteer';
 | 
					import puppeteer from 'puppeteer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const screenShot = async (filename) => {
 | 
					export const screenShot = async (filename, time) => {
 | 
				
			||||||
  const browser = await puppeteer.launch({
 | 
					  const browser = await puppeteer.launch({
 | 
				
			||||||
    headless: true,
 | 
					    headless: true,
 | 
				
			||||||
    args: ["--no-sandbox"],
 | 
					    args: ["--no-sandbox"],
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,7 @@ export const screenShot = async (filename) => {
 | 
				
			||||||
    await bodyHandle.dispose();
 | 
					    await bodyHandle.dispose();
 | 
				
			||||||
    await page.setViewport({ width: 1920, height: 500 });
 | 
					    await page.setViewport({ width: 1920, height: 500 });
 | 
				
			||||||
    setTimeout(async () => {
 | 
					    setTimeout(async () => {
 | 
				
			||||||
      await page.screenshot({ path: "app/store/screenshot/"+Date.now()+filename+".png" });
 | 
					      await page.screenshot({ path: "/home/screenshot/"+time+"_"+filename+".png" });
 | 
				
			||||||
      browser.close();
 | 
					      browser.close();
 | 
				
			||||||
    }, 5000);
 | 
					    }, 5000);
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@ import { FormData } from "zulip-js/lib/helper";
 | 
				
			||||||
import axios from "axios";
 | 
					import axios from "axios";
 | 
				
			||||||
import fs from "fs";
 | 
					import fs from "fs";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const uploadFileToZulip = async () => {
 | 
					export const uploadFileToZulip = async (filename, time) => {
 | 
				
			||||||
  //   try {
 | 
					  //   try {
 | 
				
			||||||
  const ZULIP_API_URL = "https://zulip.ipsupply.com.au/api/v1";
 | 
					  const ZULIP_API_URL = "https://zulip.ipsupply.com.au/api/v1";
 | 
				
			||||||
  const ZULIP_API_KEY = "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM";
 | 
					  const ZULIP_API_KEY = "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM";
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ export const uploadFileToZulip = async () => {
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      const fileStream = fs.createReadStream("app/utils/screenshot.png");
 | 
					      const fileStream = fs.createReadStream("/home/screenshot/"+time+"_"+filename+".png");
 | 
				
			||||||
      const formData = new FormData();
 | 
					      const formData = new FormData();
 | 
				
			||||||
      formData.append("file", fileStream);
 | 
					      formData.append("file", fileStream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue