fix array to object
This commit is contained in:
parent
736030da39
commit
e669971e8a
1 changed files with 26 additions and 28 deletions
|
|
@ -271,42 +271,40 @@ export class ReportController extends Controller {
|
|||
output: string;
|
||||
sequence: string[];
|
||||
}
|
||||
const content = queryData.hits.hits.map((x) => {
|
||||
const source = x._source as DocumentSource;
|
||||
return {
|
||||
id: x._id,
|
||||
startTimeStamp: source.startTimeStamp,
|
||||
userName: source.userName,
|
||||
host: source.host,
|
||||
endpoint: source.endpoint,
|
||||
method: source.method,
|
||||
responseCode: source.responseCode,
|
||||
logType: source.logType,
|
||||
responseDescription: source.responseDescription,
|
||||
input: source.input,
|
||||
output: JSON.parse(/*JSON.stringify(*/source.output/*, null, 2)*/),
|
||||
sequence: source.sequence ? source.sequence : [{
|
||||
action:"-",
|
||||
status:"-",
|
||||
description:"-",
|
||||
request:{
|
||||
method:"-",
|
||||
url:"-",
|
||||
response:"-",
|
||||
},
|
||||
}],
|
||||
};
|
||||
});
|
||||
|
||||
const x = queryData.hits.hits[0]
|
||||
const source = x._source as DocumentSource;
|
||||
const content = {
|
||||
id: x._id,
|
||||
startTimeStamp: source.startTimeStamp,
|
||||
userName: source.userName,
|
||||
host: source.host,
|
||||
endpoint: source.endpoint,
|
||||
method: source.method,
|
||||
responseCode: source.responseCode,
|
||||
logType: source.logType,
|
||||
responseDescription: source.responseDescription,
|
||||
input: JSON.parse(source.input),
|
||||
output: JSON.parse(source.output),
|
||||
sequence: source.sequence ? source.sequence : [{
|
||||
action:"-",
|
||||
status:"-",
|
||||
description:"-",
|
||||
request:{
|
||||
method:"-",
|
||||
url:"-",
|
||||
response:"-",
|
||||
},
|
||||
}],
|
||||
};
|
||||
|
||||
const contentString = JSON.parse(JSON.stringify(content, null, 2));
|
||||
downloadFile(200, contentString, {
|
||||
"Content-Type": "application/octet-stream",
|
||||
"Content-Disposition": `attachment; filename="log_${id}.txt"`,
|
||||
"Content-Length": contentString.length.toString(),
|
||||
});
|
||||
}
|
||||
catch (error:any) {
|
||||
console.error("An error occurred:", error);
|
||||
throw new Error("Failed to process logs: " + error.message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue