update findValue
This commit is contained in:
parent
6022621b44
commit
ee14dbda74
|
|
@ -11,7 +11,7 @@ const ListLog = () => {
|
|||
const [value, setValue] = useState("");
|
||||
const getListFile = async () => {
|
||||
try {
|
||||
const res = await axios.get(getListLog);
|
||||
const res = await axios.get(getListLog,{value: value});
|
||||
setListFile(res.data);
|
||||
setStatus(res.status);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ import { sendDeviceInfora } from "App/utils/sendDeviceInfor";
|
|||
import InfoDevice from "App/Models/InfoDevice";
|
||||
import LogReport from "App/Models/LogReport";
|
||||
import Cache from "@ioc:Kaperskyguru/Adonis-Cache";
|
||||
import { exec } from 'child_process';
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
|
||||
|
||||
|
|
@ -179,23 +180,17 @@ Route.post("/api/private-log/readFile", async ({ request, response }) => {
|
|||
|
||||
Route.post("/api/find-value", async ({ request, response }) => {
|
||||
try {
|
||||
let result = "";
|
||||
let value = request.all().value;
|
||||
console.log("value ", value)
|
||||
const { value } = request.all();
|
||||
|
||||
exec("grep -nr "+value+" /home/logs", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
// console.error(`Error executing command: ${error.message}`);
|
||||
return "Error:"+ error;
|
||||
}
|
||||
console.log("stdout ", stdout)
|
||||
const { stdout, stderr } = await exec(`grep -nr "${value}" /home/logs`);
|
||||
|
||||
response.status(300).send("blabla"+JSON.stringify(stdout) );
|
||||
});
|
||||
|
||||
response.status(200).send(JSON.stringify(stdout));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
response.status(500).send(`Error: ${error.message}`);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Route.post("/api/test", async () => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue