fix(striker-ui-api): correct ID condition in query host detail
This commit is contained in:
parent
df7b5fa397
commit
78b75c649a
@ -33,6 +33,9 @@ export const buildUnknownIDCondition = (
|
||||
};
|
||||
|
||||
export const buildKnownIDCondition = (
|
||||
keys: string[] | '*' = '*',
|
||||
keys: string[] | 'all' | '*' = 'all',
|
||||
conditionPrefix: string,
|
||||
) => (keys[0] === '*' ? '' : buildIDCondition(keys, conditionPrefix));
|
||||
) =>
|
||||
!(keys instanceof Array) || keys.some((v) => ['all', '*'].includes(v))
|
||||
? ''
|
||||
: buildIDCondition(keys, conditionPrefix);
|
||||
|
@ -42,7 +42,7 @@ const setCvar = (
|
||||
export const buildQueryHostDetail: BuildQueryDetailFunction = ({
|
||||
keys: hostUUIDs = '*',
|
||||
} = {}) => {
|
||||
const condHostUUIDs = buildKnownIDCondition(hostUUIDs, 'a.host_uuid');
|
||||
const condHostUUIDs = buildKnownIDCondition(hostUUIDs, 'WHERE a.host_uuid');
|
||||
|
||||
stdout(`condHostUUIDs=[${condHostUUIDs}]`);
|
||||
|
||||
@ -74,7 +74,7 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({
|
||||
ON b.variable_name LIKE '%link%_mac%'
|
||||
AND b.variable_value = c.network_interface_mac_address
|
||||
AND a.host_uuid = c.network_interface_host_uuid
|
||||
WHERE ${condHostUUIDs}
|
||||
${condHostUUIDs}
|
||||
ORDER BY a.host_name ASC,
|
||||
cvar_name ASC,
|
||||
b.variable_name ASC;`;
|
||||
|
@ -49,6 +49,9 @@ export const getHost = buildGetRequestHandler((request, buildQueryOptions) => {
|
||||
);
|
||||
|
||||
if (hostUUIDs) {
|
||||
// TODO: the output of host detail is designed to only contain one
|
||||
// host, correct it to support multiple hosts to allow selecting
|
||||
// multiple hosts' detail.
|
||||
({ query, afterQueryReturn } = buildQueryHostDetail({
|
||||
keys: sanitize(hostUUIDs, 'string[]', {
|
||||
modifierType: 'sql',
|
||||
|
Loading…
Reference in New Issue
Block a user