update image for message zulip
This commit is contained in:
parent
025e9aa5df
commit
ad3f9a4e46
|
|
@ -0,0 +1 @@
|
||||||
|
<h1>fjshdkf</h1>
|
||||||
|
|
@ -7,6 +7,8 @@ import KeyValue from "App/Models/KeyValue";
|
||||||
import Database from "@ioc:Adonis/Lucid/Database";
|
import Database from "@ioc:Adonis/Lucid/Database";
|
||||||
import { sendMessToZulip } from "./sendMessToZulip";
|
import { sendMessToZulip } from "./sendMessToZulip";
|
||||||
import { getListLineByItem } from "./getListLineByItem";
|
import { getListLineByItem } from "./getListLineByItem";
|
||||||
|
import { screenShot } from "./screenShot";
|
||||||
|
import { uploadFileToZulip } from "./uploadFileZulip";
|
||||||
|
|
||||||
// export default class loggerAPI {
|
// export default class loggerAPI {
|
||||||
export async function runtimeCheckLogs(folderPath) {
|
export async function runtimeCheckLogs(folderPath) {
|
||||||
|
|
@ -175,7 +177,11 @@ export async function runtimeCheckLogs(folderPath) {
|
||||||
fileDetect?.id_ldf
|
fileDetect?.id_ldf
|
||||||
);
|
);
|
||||||
|
|
||||||
let listReport = await getListLineByItem(logsDetect[0].filter((l)=>l.line>lastLine));
|
await screenShot(fileName);
|
||||||
|
const uriImage = await uploadFileToZulip();
|
||||||
|
let listReport = await getListLineByItem(
|
||||||
|
logsDetect[0].filter((l) => l.line > lastLine)
|
||||||
|
);
|
||||||
let content =
|
let content =
|
||||||
"| |Last updated at | Item/error | Line | Report \n|---|:---:|:---|:---|:-----------:\n";
|
"| |Last updated at | Item/error | Line | Report \n|---|:---:|:---|:---|:-----------:\n";
|
||||||
let spoiler = "";
|
let spoiler = "";
|
||||||
|
|
@ -195,7 +201,9 @@ export async function runtimeCheckLogs(folderPath) {
|
||||||
log.line +
|
log.line +
|
||||||
"|[View](https://logs.danielvu.com/logs/" +
|
"|[View](https://logs.danielvu.com/logs/" +
|
||||||
fileName +
|
fileName +
|
||||||
"#"+log.line+")\n";
|
"#" +
|
||||||
|
log.line +
|
||||||
|
")\n";
|
||||||
});
|
});
|
||||||
// }
|
// }
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
|
|
@ -203,24 +211,30 @@ export async function runtimeCheckLogs(folderPath) {
|
||||||
"stream",
|
"stream",
|
||||||
"Result test - auto.nswteam.net",
|
"Result test - auto.nswteam.net",
|
||||||
"Log Alert",
|
"Log Alert",
|
||||||
":warning: :warning: **" +
|
"------------\n\n:warning: :warning: **" +
|
||||||
fileName +
|
fileName +
|
||||||
"**\n\n" +
|
"**\n\n" +
|
||||||
content +
|
content +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
spoiler
|
spoiler +
|
||||||
|
"\n\n[image](" +
|
||||||
|
uriImage +
|
||||||
|
")\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
sendMessToZulip(
|
sendMessToZulip(
|
||||||
"stream",
|
"stream",
|
||||||
"AUS_VN_Test",
|
"AUS_VN_Test",
|
||||||
"Test Log Alerts",
|
"Test Log Alerts",
|
||||||
":warning: :warning: **" +
|
"------------\n\n:warning: :warning: **" +
|
||||||
fileName +
|
fileName +
|
||||||
"**\n\n" +
|
"**\n\n" +
|
||||||
content +
|
content +
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
spoiler
|
spoiler +
|
||||||
|
"\n\n[image](" +
|
||||||
|
uriImage +
|
||||||
|
")\n"
|
||||||
);
|
);
|
||||||
// }, 3000);
|
// }, 3000);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import puppeteer from 'puppeteer';
|
||||||
|
|
||||||
|
export const screenShot = async (filename) => {
|
||||||
|
const browser = await puppeteer.launch();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Open a new page
|
||||||
|
const page = await browser.newPage();
|
||||||
|
await page.goto("https://logs.danielvu.com/screenShot/" + filename);
|
||||||
|
const bodyHandle = await page.$("body");
|
||||||
|
const { height } = await bodyHandle.boundingBox();
|
||||||
|
await bodyHandle.dispose();
|
||||||
|
await page.setViewport({ width: 1920, height: 500 });
|
||||||
|
setTimeout(async () => {
|
||||||
|
await page.screenshot({ path: "app/utils/screenshot.png" });
|
||||||
|
browser.close();
|
||||||
|
}, 5000);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
|
|
@ -0,0 +1,44 @@
|
||||||
|
import { FormData } from "zulip-js/lib/helper";
|
||||||
|
import axios from "axios";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
|
export const uploadFileToZulip = async () => {
|
||||||
|
// try {
|
||||||
|
const ZULIP_API_URL = "https://zulip.ipsupply.com.au/api/v1";
|
||||||
|
const ZULIP_API_KEY = "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM";
|
||||||
|
const BOT_EMAIL = "networktool-bot@zulip.ipsupply.com.au";
|
||||||
|
// const ZULIP_API_URL = "https://zulip.ipsupply.com.au/api/v1";
|
||||||
|
// const ZULIP_API_KEY = "7XGrpwzFtQyUVDQzdwL3hjdVSbLx55yt";
|
||||||
|
// const BOT_EMAIL = "joseph.le@apactech.io";
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
const fileStream = fs.createReadStream("app/utils/screenshot.png");
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("file", fileStream);
|
||||||
|
|
||||||
|
const response = await axios.post(
|
||||||
|
`${ZULIP_API_URL}/user_uploads`,
|
||||||
|
formData,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/octet-stream",
|
||||||
|
Authorization: `Basic ${Buffer.from(
|
||||||
|
`${BOT_EMAIL}:${ZULIP_API_KEY}`
|
||||||
|
).toString("base64")}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
const uploadedFile = response.data.uri;
|
||||||
|
return uploadedFile;
|
||||||
|
} else {
|
||||||
|
console.error("Failed to upload file:", response.statusText);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error uploading file:", error.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
[api]
|
||||||
|
email=networktool-bot@zulip.ipsupply.com.au
|
||||||
|
key=0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM
|
||||||
|
site=https://zulip.ipsupply.com.au
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
[api]
|
||||||
|
email=joseph.le@apactech.io
|
||||||
|
key=7XGrpwzFtQyUVDQzdwL3hjdVSbLx55yt
|
||||||
|
site=https://zulip.ipsupply.com.au
|
||||||
|
|
@ -5,6 +5,7 @@ import ManageValues from "./pages/ManageValues";
|
||||||
import { Routes, Route, Switch, useParams } from "react-router-dom";
|
import { Routes, Route, Switch, useParams } from "react-router-dom";
|
||||||
import ShowLog from "./components/ShowLog/ShowLog";
|
import ShowLog from "./components/ShowLog/ShowLog";
|
||||||
import ListLog from "./components/ListLog/ListLog";
|
import ListLog from "./components/ListLog/ListLog";
|
||||||
|
import ScreenShot from "./components/ScreenShot/ScreenShot";
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
|
|
@ -15,6 +16,7 @@ function App() {
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/logs/:name" element={<ShowLog />}></Route>
|
<Route path="/logs/:name" element={<ShowLog />}></Route>
|
||||||
<Route path="/logs" element={<ListLog />}></Route>
|
<Route path="/logs" element={<ListLog />}></Route>
|
||||||
|
<Route path="/screenShot/:name" element={<ScreenShot />}></Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
#bodyScreen {
|
||||||
|
height: 100%;
|
||||||
|
padding: 5px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
border: solid gray 5px;
|
||||||
|
white-space: pre;
|
||||||
|
overflow: auto;
|
||||||
|
font-family: monospace;
|
||||||
|
text-rendering: auto;
|
||||||
|
color: fieldtext;
|
||||||
|
letter-spacing: normal;
|
||||||
|
word-spacing: normal;
|
||||||
|
line-height: normal;
|
||||||
|
text-transform: none;
|
||||||
|
text-indent: 0px;
|
||||||
|
text-shadow: none;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: start;
|
||||||
|
appearance: auto;
|
||||||
|
-webkit-rtl-ordering: logical;
|
||||||
|
resize: vertical;
|
||||||
|
cursor: text;
|
||||||
|
background-color: field;
|
||||||
|
column-count: initial !important;
|
||||||
|
writing-mode: horizontal-tb !important;
|
||||||
|
/* box-sizing: border-box; */
|
||||||
|
margin: 0em;
|
||||||
|
/* border-width: 1px; */
|
||||||
|
/* border-style: solid;/ */
|
||||||
|
/* border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133)); */
|
||||||
|
/* border-image: initial; */
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,99 @@
|
||||||
|
import axios from "axios";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { Link, Navigate, useParams } from "react-router-dom";
|
||||||
|
import { getLog } from "../../api/apiLog";
|
||||||
|
import "./ScreenShot.css";
|
||||||
|
const ScreenShot = () => {
|
||||||
|
let { name } = useParams();
|
||||||
|
const [log, setLog] = useState({});
|
||||||
|
const [status, setStatus] = useState(200);
|
||||||
|
const getContentLog = async () => {
|
||||||
|
try {
|
||||||
|
const res = await axios.get(getLog + "/" + name);
|
||||||
|
setLog(res.data);
|
||||||
|
setStatus(res.status);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function scrollToBottom() {
|
||||||
|
const targetDiv = document.getElementById('bodyScreen');
|
||||||
|
targetDiv.scrollTop = targetDiv.scrollHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the function to scroll to the end of the page
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getContentLog();
|
||||||
|
// setTimeout(() => {
|
||||||
|
// scrollToBottom();
|
||||||
|
// }, 2000);
|
||||||
|
}, []);
|
||||||
|
// console.log(window.location.hash);
|
||||||
|
if (status === 200) {
|
||||||
|
return (
|
||||||
|
<div className="main">
|
||||||
|
<div id="bodyScreen">
|
||||||
|
<h3
|
||||||
|
style={{
|
||||||
|
display:
|
||||||
|
log?.modelSpecial === "" && log?.issueItem === ""
|
||||||
|
? "block"
|
||||||
|
: "none",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
No errors were found in the file
|
||||||
|
</h3>
|
||||||
|
<h3 style={{ display: log?.modelSpecial !== "" ? "block" : "none" }}>
|
||||||
|
Extra items:
|
||||||
|
</h3>
|
||||||
|
{log?.modelSpecial?.split("\n")?.map((line) => (
|
||||||
|
<span>
|
||||||
|
<span className="lineNumberLog">{line.split("|-|")[0]}</span>
|
||||||
|
<span>{line.split("|-|")[1]}</span>
|
||||||
|
<span className="itemDetected">
|
||||||
|
<a
|
||||||
|
href={"#" + line.split("|-|")[0]}
|
||||||
|
style={{ textDecoration: "none", color: "black" }}
|
||||||
|
>
|
||||||
|
{line.split("|-|")[2]}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
<span>{line.split("|-|")[3]}</span>
|
||||||
|
<br></br>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
<h3 style={{ display: log?.issueItem !== "" ? "block" : "none" }}>
|
||||||
|
Issue found:
|
||||||
|
</h3>
|
||||||
|
{log?.issueItem?.split("\n")?.reverse().map((line) => (
|
||||||
|
<span>
|
||||||
|
<span className="lineNumberLog">{line.split("|-|")[0]}</span>
|
||||||
|
<span>{line.split("|-|")[1]}</span>
|
||||||
|
<span className="itemDetected">
|
||||||
|
<a
|
||||||
|
href={"#" + line.split("|-|")[0]}
|
||||||
|
style={{ textDecoration: "none", color: "black" }}
|
||||||
|
>
|
||||||
|
{line.split("|-|")[2]}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
<span>{line.split("|-|")[3]}</span>
|
||||||
|
<br></br>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>
|
||||||
|
<i>The file was not found.</i>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ScreenShot;
|
||||||
|
|
@ -76,7 +76,7 @@ const ShowLog = () => {
|
||||||
<h3 style={{ display: log?.modelSpecial !== "" ? "block" : "none" }}>
|
<h3 style={{ display: log?.modelSpecial !== "" ? "block" : "none" }}>
|
||||||
Extra items:
|
Extra items:
|
||||||
</h3>
|
</h3>
|
||||||
{log?.modelSpecial?.split("\n")?.map((line) => (
|
{log?.modelSpecial?.split("\n")?.reverse().map((line) => (
|
||||||
<span>
|
<span>
|
||||||
<span className="lineNumberLog">{line.split("|-|")[0]}</span>
|
<span className="lineNumberLog">{line.split("|-|")[0]}</span>
|
||||||
<span>{line.split("|-|")[1]}</span>
|
<span>{line.split("|-|")[1]}</span>
|
||||||
|
|
@ -95,7 +95,7 @@ const ShowLog = () => {
|
||||||
<h3 style={{ display: log?.issueItem !== "" ? "block" : "none" }}>
|
<h3 style={{ display: log?.issueItem !== "" ? "block" : "none" }}>
|
||||||
Issue found:
|
Issue found:
|
||||||
</h3>
|
</h3>
|
||||||
{log?.issueItem?.split("\n")?.map((line) => (
|
{log?.issueItem?.split("\n")?.reverse().map((line) => (
|
||||||
<span>
|
<span>
|
||||||
<span className="lineNumberLog">{line.split("|-|")[0]}</span>
|
<span className="lineNumberLog">{line.split("|-|")[0]}</span>
|
||||||
<span>{line.split("|-|")[1]}</span>
|
<span>{line.split("|-|")[1]}</span>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -31,11 +31,14 @@
|
||||||
"child_process": "^1.0.2",
|
"child_process": "^1.0.2",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
|
"helpers": "^0.0.6",
|
||||||
"jsonwebtoken": "^9.0.1",
|
"jsonwebtoken": "^9.0.1",
|
||||||
"luxon": "^3.4.0",
|
"luxon": "^3.4.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"mysql2": "^3.6.0",
|
"mysql2": "^3.6.0",
|
||||||
|
"path": "^0.12.7",
|
||||||
"proxy-addr": "^2.0.7",
|
"proxy-addr": "^2.0.7",
|
||||||
|
"puppeteer": "^21.2.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"zulip-js": "^2.0.9"
|
"zulip-js": "^2.0.9"
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export default class AppProvider {
|
||||||
|
|
||||||
public async boot () {
|
public async boot () {
|
||||||
// IoC container is ready
|
// IoC container is ready
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ready () {
|
public async ready () {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,146 @@
|
||||||
|
// const puppeteer = require("puppeteer");
|
||||||
|
|
||||||
|
// (async () => {
|
||||||
|
// // Launch a headless browser
|
||||||
|
// const browser = await puppeteer.launch();
|
||||||
|
|
||||||
|
// // Open a new page
|
||||||
|
// const page = await browser.newPage();
|
||||||
|
// await page.goto(
|
||||||
|
// "http://localhost:3000/screenShot/20230913-TEST01-Session.Port4-6-172.16.20.7.log"
|
||||||
|
// );
|
||||||
|
// const bodyHandle = await page.$('body');
|
||||||
|
// const { height } = await bodyHandle.boundingBox();
|
||||||
|
// await bodyHandle.dispose();
|
||||||
|
// await page.setViewport({ width: 1920, height: 500 });
|
||||||
|
// setTimeout(async () => {
|
||||||
|
// await page.screenshot({ path: "screenshot.png" });
|
||||||
|
// await browser.close();
|
||||||
|
// }, 5000);
|
||||||
|
// // } else {
|
||||||
|
// // console.error(`Element with class name '${className}' not found.`);
|
||||||
|
// // }
|
||||||
|
// // Close the browser
|
||||||
|
// })();
|
||||||
|
|
||||||
|
// const zulip = require("zulip-js");
|
||||||
|
|
||||||
|
// const config = {
|
||||||
|
// zuliprc: "./download",
|
||||||
|
// zulipVersion: "v2",
|
||||||
|
// };
|
||||||
|
|
||||||
|
// async function deleteMessages() {
|
||||||
|
// const client = await zulip(config);
|
||||||
|
|
||||||
|
// // Thay thế "stream-name", "topic-name", và các mốc thời gian cụ thể
|
||||||
|
// const streamName = "Result test - auto.nswteam.net";
|
||||||
|
// const topicName = "Log Alert";
|
||||||
|
// const startTime = Date.parse("2023-09-11T00:00:00Z");
|
||||||
|
// const endTime = Date.parse("2023-09-11T23:59:59Z");
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// const messages = await client.messages.retrieve({
|
||||||
|
// anchor: "oldest",
|
||||||
|
// num_before: 0,
|
||||||
|
// num_after: 5000, // Điều chỉnh theo nhu cầu của bạn
|
||||||
|
// narrow: [
|
||||||
|
// { operator: "stream", operand: streamName },
|
||||||
|
// { operator: "topic", operand: topicName },
|
||||||
|
// // {
|
||||||
|
// // operator: ,
|
||||||
|
// // operand: `169457100,1694571399`,
|
||||||
|
// // },
|
||||||
|
// ],
|
||||||
|
// });
|
||||||
|
// console.log(messages.messages.length)
|
||||||
|
// // for (const message of messages.messages) {
|
||||||
|
// // const res = await client.messages.deleteById({ message_id: message.id });
|
||||||
|
// // console.log(`Deleted message ID ${message.id}`);
|
||||||
|
// // console.log(res)
|
||||||
|
// // }
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("Error:", error);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// deleteMessages();
|
||||||
|
|
||||||
|
// const zulip = require("zulip-js");
|
||||||
|
// const fs = require("fs");
|
||||||
|
|
||||||
|
// const config = {
|
||||||
|
// zuliprc: "./download",
|
||||||
|
// zulipVersion: "v2", // Use the appropriate API version
|
||||||
|
// };
|
||||||
|
// const imageFilePath = "./screenshot.png";
|
||||||
|
// const imageBase64 = fs.readFileSync(imageFilePath, { encoding: "base64" });
|
||||||
|
|
||||||
|
// async function send() {
|
||||||
|
// const client = await zulip(config);
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// const message = {
|
||||||
|
// type: "stream",
|
||||||
|
// to: "Result test - auto.nswteam.net", // Replace with the target stream name or recipient email
|
||||||
|
// topic: "AU-dev", // Replace with the message topic
|
||||||
|
// content: "Check out this image:",
|
||||||
|
// filename: "asakfga",
|
||||||
|
// file: imageBase64
|
||||||
|
// };
|
||||||
|
// client.messages.sendFile(message).then((response) => {
|
||||||
|
// console.log("Message sent successfully:", response);
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("Error:", error);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// send();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Usage example
|
||||||
|
const filePath = __dirname+'\\screenshot.png';
|
||||||
|
uploadFileToZulip(filePath);
|
||||||
|
|
||||||
|
// const zulip = require('zulip-js');
|
||||||
|
|
||||||
|
// // Configure your Zulip API details
|
||||||
|
// const config = {
|
||||||
|
// username: 'joseph.le@apactech.io',
|
||||||
|
// apiKey: '7XGrpwzFtQyUVDQzdwL3hjdVSbLx55yt',
|
||||||
|
// realm: 'https://zulip.ipsupply.com.au',
|
||||||
|
// };
|
||||||
|
|
||||||
|
// async function uploadFileToZulip(filePath) {
|
||||||
|
// try {
|
||||||
|
// const client = await zulip(config);
|
||||||
|
|
||||||
|
// // Read the file as binary data
|
||||||
|
// const fs = require('fs');
|
||||||
|
// const fileData = fs.readFileSync(filePath);
|
||||||
|
|
||||||
|
// // Create a FormData object
|
||||||
|
// const formData = new FormData();
|
||||||
|
// formData.append('file', fileData);
|
||||||
|
|
||||||
|
// // Upload the file
|
||||||
|
// const response = await client.callEndpoint('POST', 'user_uploads', formData, {headers:{
|
||||||
|
// 'Content-Type': 'multipart/form-data',
|
||||||
|
// // other headers if needed
|
||||||
|
// }});
|
||||||
|
|
||||||
|
// // if (response.result === 'success') {
|
||||||
|
// // const uploadedFileURL = response.uri;
|
||||||
|
// // console.log('File uploaded successfully. URL:', uploadedFileURL);
|
||||||
|
// // } else {
|
||||||
|
// // console.error('Failed to upload file:', response.msg);
|
||||||
|
// // }
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error('Error uploading file:', error);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// const filePath = 'screenshot.png'; // Replace with your file path
|
||||||
|
|
||||||
|
// uploadFileToZulip(filePath);
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Server from '@ioc:Adonis/Core/Server'
|
import Server from '@ioc:Adonis/Core/Server'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Global middleware
|
| Global middleware
|
||||||
|
|
@ -21,7 +20,7 @@ import Server from '@ioc:Adonis/Core/Server'
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
Server.middleware.register([
|
Server.middleware.register([
|
||||||
() => import('@ioc:Adonis/Core/BodyParser'),
|
() => import('@ioc:Adonis/Core/BodyParser')
|
||||||
])
|
])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import fs from 'fs';
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
@ -28,6 +29,9 @@ import ErpsController from "App/Controllers/Http/ErpsController";
|
||||||
import LogReport from "App/Models/LogReport";
|
import LogReport from "App/Models/LogReport";
|
||||||
import Database from "@ioc:Adonis/Lucid/Database";
|
import Database from "@ioc:Adonis/Lucid/Database";
|
||||||
import { exec } from "child_process";
|
import { exec } from "child_process";
|
||||||
|
import ImagesController from 'App/Controllers/Http/ImagesController';
|
||||||
|
import { uploadFileToZulip } from 'App/utils/uploadFileZulip';
|
||||||
|
import { screenShot } from 'App/utils/screenShot';
|
||||||
|
|
||||||
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
|
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
|
||||||
|
|
||||||
|
|
@ -201,3 +205,13 @@ Route.post("/api/gitea-webhook", ({ request, response }) => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route.get('/api/images/:filename', "ImagesController.getImage");
|
||||||
|
|
||||||
|
Route.get('/api/test', async ({ request, response }) => {
|
||||||
|
await screenShot("20230915-HELEN1-Session.US2-11-3-127.0.0.1.log")
|
||||||
|
const test = await uploadFileToZulip();
|
||||||
|
// setTimeout(() => {
|
||||||
|
console.log(test)
|
||||||
|
// }, 10000);
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
sdfsdf
|
||||||
|
dfgdfg
|
||||||
|
dfgdf
|
||||||
Loading…
Reference in New Issue