update routes

This commit is contained in:
joseph le 2023-09-12 15:38:15 +07:00
parent c7512e2041
commit a51028f16b
1 changed files with 31 additions and 26 deletions

View File

@ -52,8 +52,8 @@ Route.post("/api/account/checkLogin", "UsersController.checkLogin");
//Log //Log
Route.get("/api/log/showLog/:name?", async ({ request, response }) => { Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
try { try {
// fghf // fghf
console.log(request.params().name) console.log(request.params().name);
let fileDetect = await LogDetectFile.findBy( let fileDetect = await LogDetectFile.findBy(
"file_name", "file_name",
request.params().name request.params().name
@ -81,10 +81,9 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
i.$original.key === "CATCH_FAULTY" i.$original.key === "CATCH_FAULTY"
); );
let MODEL_SPECIAL = allValue.filter( let MODEL_SPECIAL = allValue
(i) => .filter((i) => i.$original.key === "MODEL_SPECIAL")
i.$original.key === "MODEL_SPECIAL" .map((obj) => obj.$original.value);
).map(obj => obj.$original.value);
let listExcludeErr = allValue let listExcludeErr = allValue
.filter((i) => i.$original.key === "EXCLUDE_ERR") .filter((i) => i.$original.key === "EXCLUDE_ERR")
@ -92,18 +91,16 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
let data = content.data.split("\n"); let data = content.data.split("\n");
data.map((line, index) => { data.map((line, index) => {
data[index] = data[index] = index + 1 + "|-|" + line;
(index + 1) +
"|-|" +
line;
listKeyValues listKeyValues
.map((obj) => obj.$original.value) .map((obj) => obj.$original.value)
.map(async (value) => { .map(async (value) => {
if (line.search(value) !== -1 && if (
listExcludeErr.filter((err) => line.includes(err)) line.search(value) !== -1 &&
.length === 0) { listExcludeErr.filter((err) => line.includes(err)).length === 0
) {
data[index] = data[index] =
data[index].slice(0, data[index].search(value)) + data[index].slice(0, data[index].search(value)) +"|-|" +
value + value +
"|-|" + "|-|" +
data[index].slice(data[index].search(value) + value.length); data[index].slice(data[index].search(value) + value.length);
@ -111,20 +108,22 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
} }
}); });
}); });
listLine.map((u) => { listLine.map((u) => {
if (listExcludeErr.filter((err) => data[u - 1].includes(err)).length === 0) { if (
if(MODEL_SPECIAL.filter((i)=>data[u - 1].includes(i)).length>0){ listExcludeErr.filter((err) => data[u - 1].includes(err)).length === 0
modelSpecialDetected.push(data[u - 1]) ) {
}else{ if (MODEL_SPECIAL.filter((i) => data[u - 1].includes(i)).length > 0) {
issueSpecialDetected.push(data[u - 1]) modelSpecialDetected.push(data[u - 1]);
} else {
issueSpecialDetected.push(data[u - 1]);
} }
} }
}); });
let modelSpecial = modelSpecialDetected.length>0?"\n\n<b>Extra items:</b>\n" + modelSpecialDetected.join("\n") + "\n":"\n" let modelSpecial =
let issueItem = issueSpecialDetected.length>0?"\n<b>Issue found:</b>\n" + issueSpecialDetected.join("\n")+"\n\n":"\n"; modelSpecialDetected.length > 0 ? modelSpecialDetected.join("\n") : "";
let issueItem =
issueSpecialDetected.length > 0 ? issueSpecialDetected.join("\n") : "";
// response.send( // response.send(
// "<html>\ // "<html>\
// <body>\ // <body>\
@ -152,14 +151,20 @@ Route.get("/api/log/showLog/:name?", async ({ request, response }) => {
// border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));\ // border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));\
// border-image: initial;\ // border-image: initial;\
// padding: 2px;'><b>"+request.params().name+"</b>" + modelSpecial + issueItem // padding: 2px;'><b>"+request.params().name+"</b>" + modelSpecial + issueItem
// + // +
// data.join("\n") + // data.join("\n") +
// "</div>\ // "</div>\
// </body>\ // </body>\
// </html>" // </html>"
// ); // );
response.status(200).send({modelSpecial:modelSpecial, issueItem:issueItem, contentFile: data.join("\n")}) response
.status(200)
.send({
modelSpecial: modelSpecial,
issueItem: issueItem,
contentFile: data.join("\n"),
});
} catch (error) { } catch (error) {
console.error(error); console.error(error);
response.send("<h1>-------------- File not found --------------</h1>"); response.send("<h1>-------------- File not found --------------</h1>");