Skip to content

Commit

Permalink
added tooltip, show in progress action earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Jan 26, 2023
1 parent 7bb2268 commit 7ff346d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import type { EuiTableFieldDataColumnType } from '@elastic/eui';
import { EuiToolTip } from '@elastic/eui';
import {
EuiBasicTable,
EuiButton,
Expand Down Expand Up @@ -131,7 +132,10 @@ export const AgentDiagnosticsTab: React.FunctionComponent<AgentDiagnosticsProps>
</EuiText>
) : (
<EuiText color="subdued">
<EuiIcon type="alert" color="red" /> &nbsp;
<EuiToolTip content={`File status: ${currentItem?.status}`}>
<EuiIcon type="alert" color="red" />
</EuiToolTip>
&nbsp;
{currentItem?.name}
</EuiText>
);
Expand Down
25 changes: 18 additions & 7 deletions x-pack/plugins/fleet/server/services/agents/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function getAgentUploads(

const results = [];
for (const action of actions) {
const file = await getFile(action.fileId);
const file = action.fileId ? await getFile(action.fileId) : undefined;
const fileName = file?.name ?? `${moment(action.timestamp!).format('YYYY-MM-DD HH:mm:ss')}.zip`;
const filePath = file ? agentRouteService.getAgentFileDownloadLink(file.id, file.name) : '';
const result = {
Expand All @@ -86,7 +86,7 @@ export async function getAgentUploads(
async function _getRequestDiagnosticsActions(
esClient: ElasticsearchClient,
agentId: string
): Promise<Array<{ actionId: string; timestamp?: string; fileId: string }>> {
): Promise<Array<{ actionId: string; timestamp?: string; fileId?: string }>> {
const agentActionRes = await esClient.search<any>({
index: AGENT_ACTIONS_INDEX,
ignore_unavailable: true,
Expand All @@ -109,14 +109,17 @@ async function _getRequestDiagnosticsActions(
},
});

const agentActionIds = agentActionRes.hits.hits.map((hit) => hit._source?.action_id as string);
const agentActions = agentActionRes.hits.hits.map((hit) => ({
actionId: hit._source?.action_id as string,
timestamp: hit._source?.['@timestamp'],
}));

if (agentActionIds.length === 0) {
if (agentActions.length === 0) {
return [];
}

try {
const actionResults = await esClient.search<any>({
const actionResultsRes = await esClient.search<any>({
index: AGENT_ACTIONS_RESULTS_INDEX,
ignore_unavailable: true,
size: SO_SEARCH_LIMIT,
Expand All @@ -125,7 +128,7 @@ async function _getRequestDiagnosticsActions(
must: [
{
terms: {
action_id: agentActionIds,
action_id: agentActions.map((action) => action.actionId),
},
},
{
Expand All @@ -137,11 +140,19 @@ async function _getRequestDiagnosticsActions(
},
},
});
return actionResults.hits.hits.map((hit) => ({
const actionResults = actionResultsRes.hits.hits.map((hit) => ({
actionId: hit._source?.action_id as string,
timestamp: hit._source?.['@timestamp'],
fileId: hit._source?.data?.file_id as string,
}));
return agentActions.map((action) => {
const actionResult = actionResults.find((result) => result.actionId === action.actionId);
return {
actionId: action.actionId,
timestamp: actionResult?.timestamp ?? action.timestamp,
fileId: actionResult?.fileId,
};
});
} catch (err) {
if (err.statusCode === 404) {
// .fleet-actions-results does not yet exist
Expand Down

0 comments on commit 7ff346d

Please sign in to comment.