|
|
@ -1,7 +1,9 @@ |
|
|
|
import { getLocalHostUUID } from '../../accessModule'; |
|
|
|
import { getLocalHostUUID } from '../../accessModule'; |
|
|
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
import { buildQueryHostDetail } from './buildQueryHostDetail'; |
|
|
|
import { buildQueryHostDetail } from './buildQueryHostDetail'; |
|
|
|
|
|
|
|
import { buildQueryResultReducer } from '../../buildQueryResultModifier'; |
|
|
|
import { toLocal } from '../../convertHostUUID'; |
|
|
|
import { toLocal } from '../../convertHostUUID'; |
|
|
|
|
|
|
|
import { getShortHostName } from '../../getShortHostName'; |
|
|
|
import { sanitize } from '../../sanitize'; |
|
|
|
import { sanitize } from '../../sanitize'; |
|
|
|
|
|
|
|
|
|
|
|
export const getHost = buildGetRequestHandler((request, buildQueryOptions) => { |
|
|
|
export const getHost = buildGetRequestHandler((request, buildQueryOptions) => { |
|
|
@ -14,26 +16,21 @@ export const getHost = buildGetRequestHandler((request, buildQueryOptions) => { |
|
|
|
hos.host_name, |
|
|
|
hos.host_name, |
|
|
|
hos.host_uuid |
|
|
|
hos.host_uuid |
|
|
|
FROM hosts AS hos;`;
|
|
|
|
FROM hosts AS hos;`;
|
|
|
|
let afterQueryReturn: QueryResultModifierFunction | undefined = ( |
|
|
|
let afterQueryReturn: QueryResultModifierFunction | undefined = |
|
|
|
output: unknown, |
|
|
|
buildQueryResultReducer<{ [hostUUID: string]: HostOverview }>( |
|
|
|
) => { |
|
|
|
(previous, [hostName, hostUUID]) => { |
|
|
|
let result = output; |
|
|
|
const key = toLocal(hostUUID, localHostUUID); |
|
|
|
|
|
|
|
|
|
|
|
if (output instanceof Array) { |
|
|
|
previous[key] = { |
|
|
|
result = output.reduce<Record<string, HostOverview>>( |
|
|
|
hostName, |
|
|
|
(previous, [hostName, hostUUID]) => { |
|
|
|
hostUUID, |
|
|
|
const key = toLocal(hostUUID, localHostUUID); |
|
|
|
shortHostName: getShortHostName(hostName), |
|
|
|
|
|
|
|
}; |
|
|
|
previous[key] = { hostName, hostUUID }; |
|
|
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
return previous; |
|
|
|
}, |
|
|
|
}, |
|
|
|
{}, |
|
|
|
{}, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hostUUIDs) { |
|
|
|
if (hostUUIDs) { |
|
|
|
({ query, afterQueryReturn } = buildQueryHostDetail({ |
|
|
|
({ query, afterQueryReturn } = buildQueryHostDetail({ |
|
|
|