update routes.ts
This commit is contained in:
parent
7bcef420ab
commit
47bd1875f4
|
|
@ -3,4 +3,5 @@ const API = "https://logs.danielvu.com/api";
|
|||
export const getKeyValues = API + "/getKeyValue";
|
||||
export const deleteValue = API + "/deleteValue";
|
||||
export const addKeyValue = API + "/addValue";
|
||||
export const getLog = API + "/log/showLog";
|
||||
export const getLog = API + "/log/showLog";
|
||||
export const getListLog = API + "/getAllLogDetect";
|
||||
|
|
@ -1,9 +1,38 @@
|
|||
import React from 'react'
|
||||
import axios from "axios";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Navigate, useParams } from "react-router-dom";
|
||||
import { getListLog } from "../../api/apiLog";
|
||||
|
||||
const ListLog = () => {
|
||||
return (
|
||||
<div>ListLog</div>
|
||||
)
|
||||
}
|
||||
const [listFile, setListFile] = useState({});
|
||||
const [status, setStatus] = useState();
|
||||
const getListFile = async () => {
|
||||
try {
|
||||
const res = await axios.get(getListLog);
|
||||
setListFile(res.data);
|
||||
setStatus(res.status);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
export default ListLog
|
||||
if (status === 200) {
|
||||
return (
|
||||
<div>
|
||||
{listFile?.map((file) => {
|
||||
<span>{file}</span>;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
<h1>
|
||||
<i>No files</i>
|
||||
</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default ListLog;
|
||||
|
|
|
|||
|
|
@ -139,6 +139,21 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
|
|||
}
|
||||
});
|
||||
|
||||
Route.get("/api/getAllLogDetect", async ({ request, response }) => {
|
||||
try {
|
||||
// fghf
|
||||
console.log(request.params().name);
|
||||
let fileDetect = await LogDetectFile.all()
|
||||
let listFiles = fileDetect.map(obj=>obj.file_name)
|
||||
response
|
||||
.status(200)
|
||||
.send(listFiles);
|
||||
} catch (error) {
|
||||
response
|
||||
.status(203)
|
||||
.send("NO FILE");
|
||||
}
|
||||
});
|
||||
//Key-Value
|
||||
|
||||
Route.post("/api/getKeyValue", async ({ request, response }) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue