fix(striker-ui-api): add hostType to /host/:hostUUID

main
Tsu-ba-me 2 years ago
parent 6f8a3f93c7
commit 58c9e05a9b
  1. 17
      striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts

@ -28,6 +28,7 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({
const query = `
SELECT
hos.host_name,
hos.host_type,
hos.host_uuid,
var.variable_name,
var.variable_value
@ -42,16 +43,18 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({
const afterQueryReturn: QueryResultModifierFunction =
buildQueryResultModifier((output) => {
const [hostName, hostUUID] = output[0];
const [hostName, hostType, hostUUID] = output[0];
const shortHostName = getShortHostName(hostName);
return output.reduce<
{ hostName: string; hostUUID: string; shortHostName: string } & Record<
string,
string
>
{
hostName: string;
hostType: string;
hostUUID: string;
shortHostName: string;
} & Record<string, string>
>(
(previous, [, , variableName, variableValue]) => {
(previous, [, , , variableName, variableValue]) => {
const [variablePrefix, ...restVariableParts] =
variableName.split('::');
const key = MAP_TO_EXTRACTOR[variablePrefix](restVariableParts);
@ -60,7 +63,7 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({
return previous;
},
{ hostName, hostUUID, shortHostName },
{ hostName, hostType, hostUUID, shortHostName },
);
});

Loading…
Cancel
Save