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

Loading…
Cancel
Save