diff --git a/components/automate-ui/src/app/entities/desktop/desktop.actions.ts b/components/automate-ui/src/app/entities/desktop/desktop.actions.ts index 422981fac1d..efeaa9281b5 100644 --- a/components/automate-ui/src/app/entities/desktop/desktop.actions.ts +++ b/components/automate-ui/src/app/entities/desktop/desktop.actions.ts @@ -1,6 +1,7 @@ import { Action } from '@ngrx/store'; import { HttpErrorResponse } from '@angular/common/http'; +import { NodeRun } from 'app/types/types'; import { DailyCheckInCountCollection, NodeRunsDailyStatusCollection, TopErrorsCollection, CountedDurationCollection, Desktop, TermFilter, PageSizeChangeEvent, NodeMetadataCount } from './desktop.model'; @@ -50,6 +51,12 @@ export enum DesktopActionTypes { 'DESKTOP::GET::DESKTOPS_TOTAL::SUCCESS', GET_DESKTOPS_TOTAL_FAILURE = 'DESKTOP::GET::DESKTOPS_TOTAL::FAILURE', + GET_DESKTOP = + 'DESKTOP::GET::DESKTOP', + GET_DESKTOP_SUCCESS = + 'DESKTOP::GET::DESKTOP::SUCCESS', + GET_DESKTOP_FAILURE = + 'DESKTOP::GET::DESKTOP::FAILURE', SET_SELECTED_DESKTOP = 'DESKTOP::SET::DESKTOP', SET_SELECTED_DAYS_AGO = @@ -170,6 +177,21 @@ export class GetDesktopsFailure implements Action { constructor(public payload: HttpErrorResponse) { } } +export class GetDesktop implements Action { + readonly type = DesktopActionTypes.GET_DESKTOP; + constructor(public payload: { nodeId: string, runId: string }) { } +} + +export class GetDesktopSuccess implements Action { + readonly type = DesktopActionTypes.GET_DESKTOP_SUCCESS; + constructor(public payload: NodeRun) { } +} + +export class GetDesktopFailure implements Action { + readonly type = DesktopActionTypes.GET_DESKTOP_FAILURE; + constructor(public payload: HttpErrorResponse) { } +} + export class GetDesktopsTotal implements Action { readonly type = DesktopActionTypes.GET_DESKTOPS_TOTAL; } @@ -241,6 +263,9 @@ export type DesktopActions = | GetDesktops | GetDesktopsSuccess | GetDesktopsFailure + | GetDesktop + | GetDesktopSuccess + | GetDesktopFailure | GetDesktopsTotal | GetDesktopsTotalSuccess | GetDesktopsTotalFailure diff --git a/components/automate-ui/src/app/entities/desktop/desktop.effects.ts b/components/automate-ui/src/app/entities/desktop/desktop.effects.ts index a5fe3444a34..07d34ef22a1 100644 --- a/components/automate-ui/src/app/entities/desktop/desktop.effects.ts +++ b/components/automate-ui/src/app/entities/desktop/desktop.effects.ts @@ -1,9 +1,11 @@ import { catchError, mergeMap, map, withLatestFrom, switchMap } from 'rxjs/operators'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; -import { of, combineLatest } from 'rxjs'; +import { of, combineLatest, from } from 'rxjs'; import { NgrxStateAtom } from 'app/ngrx.reducers'; import { Store } from '@ngrx/store'; +import { NodeRunsService } from 'app/services/node-details/node-runs.service'; +import { NodeRun } from 'app/types/types'; import { GetDailyCheckInTimeSeries, @@ -25,6 +27,9 @@ import { GetDesktops, GetDesktopsSuccess, GetDesktopsFailure, + GetDesktop, + GetDesktopSuccess, + GetDesktopFailure, GetDesktopsTotal, GetDesktopsTotalSuccess, GetDesktopsTotalFailure @@ -39,7 +44,8 @@ export class DesktopEffects { constructor( private actions$: Actions, private requests: DesktopRequests, - private store$: Store + private store$: Store, + private nodeRunsService: NodeRunsService ) { } @Effect() @@ -168,6 +174,26 @@ export class DesktopEffects { }); })); + @Effect() + getDesktop$ = this.actions$.pipe( + ofType(DesktopActionTypes.GET_DESKTOP), + switchMap((action: GetDesktop) => + from(this.nodeRunsService.getNodeRun(action.payload.nodeId, action.payload.runId)).pipe( + map((nodeRun: NodeRun) => new GetDesktopSuccess(nodeRun)), + catchError((error) => of(new GetDesktopFailure(error)))) + )); + + @Effect() + getDesktopFailure$ = this.actions$.pipe( + ofType(DesktopActionTypes.GET_DESKTOP_FAILURE), + map(({ payload: { error } }: GetDesktopFailure) => { + const msg = error.error; + return new CreateNotification({ + type: Type.error, + message: `Could not get desktop errors: ${msg || error}` + }); + })); + @Effect() getDesktopsTotal$ = this.actions$.pipe( ofType(DesktopActionTypes.GET_DESKTOPS_TOTAL), diff --git a/components/automate-ui/src/app/entities/desktop/desktop.model.ts b/components/automate-ui/src/app/entities/desktop/desktop.model.ts index 6c53f85e543..c2dfe3e02d0 100644 --- a/components/automate-ui/src/app/entities/desktop/desktop.model.ts +++ b/components/automate-ui/src/app/entities/desktop/desktop.model.ts @@ -1,3 +1,5 @@ +import { NodeRun } from 'app/types/types'; + export enum Terms { DesktopName = 'name', Platform = 'platform', @@ -16,6 +18,7 @@ export enum SortOrder { export interface Selected { desktop: Desktop; daysAgo: number; + nodeRun: NodeRun; } export interface DailyCheckInCountCollection { @@ -87,6 +90,7 @@ export interface Desktop { platformVersion: string; chefVersion: string; domain: string; + latestRunId: string; } export interface Filter { diff --git a/components/automate-ui/src/app/entities/desktop/desktop.reducer.ts b/components/automate-ui/src/app/entities/desktop/desktop.reducer.ts index ddd99d74dc9..4f5379c4332 100644 --- a/components/automate-ui/src/app/entities/desktop/desktop.reducer.ts +++ b/components/automate-ui/src/app/entities/desktop/desktop.reducer.ts @@ -31,6 +31,7 @@ export interface DesktopEntityState { desktopListTitle: string; desktops: Desktop[]; getDesktopsStatus: EntityStatus; + getDesktopStatus: EntityStatus; desktopsTotal: number; getDesktopsTotalStatus: EntityStatus; getDesktopsFilter: Filter; @@ -41,7 +42,8 @@ export const desktopEntityInitialState: DesktopEntityState = { getDailyCheckInTimeSeriesStatus: EntityStatus.notLoaded, selected: { desktop: undefined, - daysAgo: 3 + daysAgo: 3, + nodeRun: undefined }, topErrorCollection: {items: [], updated: new Date(0)}, getTopErrorCollectionStatus: EntityStatus.notLoaded, @@ -52,6 +54,7 @@ export const desktopEntityInitialState: DesktopEntityState = { desktopListTitle: 'Desktops', desktops: [], getDesktopsStatus: EntityStatus.notLoaded, + getDesktopStatus: EntityStatus.notLoaded, desktopsTotal: 0, getDesktopsTotalStatus: EntityStatus.notLoaded, dailyNodeRuns: { @@ -152,6 +155,17 @@ export function desktopEntityReducer(state: DesktopEntityState = desktopEntityIn case DesktopActionTypes.GET_DESKTOPS_FAILURE: return set('getDesktopsStatus', EntityStatus.loadingFailure, state); + case DesktopActionTypes.GET_DESKTOP: + return set('getDesktopStatus', EntityStatus.loading, state); + + case DesktopActionTypes.GET_DESKTOP_SUCCESS: + return pipe( + set('getDesktopStatus', EntityStatus.loadingSuccess), + set('selected.nodeRun', action.payload))(state) as DesktopEntityState; + + case DesktopActionTypes.GET_DESKTOP_FAILURE: + return set('getDesktopStatus', EntityStatus.loadingFailure, state); + case DesktopActionTypes.GET_DESKTOPS_TOTAL: return set('getDesktopsTotalStatus', EntityStatus.loading, state); diff --git a/components/automate-ui/src/app/entities/desktop/desktop.requests.ts b/components/automate-ui/src/app/entities/desktop/desktop.requests.ts index 4028b14a55c..52eba0a9e67 100644 --- a/components/automate-ui/src/app/entities/desktop/desktop.requests.ts +++ b/components/automate-ui/src/app/entities/desktop/desktop.requests.ts @@ -159,7 +159,8 @@ export class DesktopRequests { platformFamily: respDesktop.platform_family, platformVersion: respDesktop.platform_version, chefVersion: respDesktop.chef_version, - domain: respDesktop.domain + domain: respDesktop.domain, + latestRunId: respDesktop.latest_run_id }; } diff --git a/components/automate-ui/src/app/entities/desktop/desktop.selectors.ts b/components/automate-ui/src/app/entities/desktop/desktop.selectors.ts index 02f5ce6eb87..5de48ca612f 100644 --- a/components/automate-ui/src/app/entities/desktop/desktop.selectors.ts +++ b/components/automate-ui/src/app/entities/desktop/desktop.selectors.ts @@ -29,6 +29,11 @@ export const getSelectedDesktop = createSelector( (state) => state.selected.desktop ); +export const getSelectedNodeRun = createSelector( + desktopState, + (state) => state.selected.nodeRun +); + export const getDailyNodeRuns = createSelector( desktopState, (state) => state.dailyNodeRuns diff --git a/components/automate-ui/src/app/modules/desktop/dashboard/dashboard.component.html b/components/automate-ui/src/app/modules/desktop/dashboard/dashboard.component.html index 510b3309035..1affce3af79 100644 --- a/components/automate-ui/src/app/modules/desktop/dashboard/dashboard.component.html +++ b/components/automate-ui/src/app/modules/desktop/dashboard/dashboard.component.html @@ -90,6 +90,7 @@

class="dashboard-detail-column"> ; public pageSize$: Observable; public termFilters$: Observable; + public selectedNodeRun$: Observable; public checkInNumDays = 15; public desktopListVisible = false; public desktopListFullscreened = false; @@ -110,6 +114,8 @@ export class DashboardComponent implements OnInit { this.desktopListTitle$ = this.store.select(desktopListTitle); this.desktops$ = this.store.select(desktops); + this.selectedNodeRun$ = this.store.select(getSelectedNodeRun); + this.totalDesktopCount$ = this.store.select(desktopsTotal); this.checkInCountCollection$ = this.store.select(dailyCheckInCountCollection).pipe( @@ -309,6 +315,7 @@ export class DashboardComponent implements OnInit { public onDesktopSelected(desktop: Desktop) { this.selectedDesktop = desktop; this.store.dispatch(new SetSelectedDesktop({desktop})); + this.store.dispatch(new GetDesktop({ nodeId: desktop.id, runId: desktop.latestRunId })); this.store.dispatch( new GetDailyNodeRunsStatusTimeSeries(this.selectedDesktop.id, this.checkInNumDays)); this.desktopDetailVisible = true; diff --git a/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.html b/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.html index 4afc1e2d9e0..5885f040aec 100644 --- a/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.html +++ b/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.html @@ -76,13 +76,13 @@

Check-in History

-
+

Overview

Host Name - {{ desktop.name }} + {{ nodeRun.nodeName }} Chef Infra Server @@ -90,39 +90,39 @@

Overview

Node ID - {{ desktop.id }} + {{ nodeRun.nodeId }} - Platform Version - {{ desktop.platform }} + Platform + {{ nodeRun.platform }} Total Memory - 16.64GB + {{ nodeRun.memoryTotal }} Domain - chef.io + {{ nodeRun.domain }} IP Address - 192.168.5.30 + {{ nodeRun.ipaddress }} IPV6 Address - fe80:20c:29ff:fe2a:76e5 + {{ nodeRun.ip6address }} MAC Address - 00:0C:29:2A:76:E5 + {{ nodeRun.macaddress }} Uptime - {{ desktop.uptimeSeconds }} + {{ nodeRun.uptimeSeconds }} Time Zone - GMT + {{ nodeRun.timezone }}
@@ -132,11 +132,11 @@

Chef Infra Client

Version - {{ desktop.chefVersion }} + {{ nodeRun.chefVersion }} Last Run End Time - {{ desktop.checkin }} + {{ nodeRun.endTime }} @@ -146,11 +146,11 @@

System

Manufacturer - LENOVO + {{ nodeRun.dmiSystemManufacturer }} Serial Number - R90QS96N + {{ nodeRun.dmiSystemSerialNumber }} @@ -160,11 +160,11 @@

Virtualization

System - vmware + {{ nodeRun.virtualizationSystem }} Role - guest + {{ nodeRun.virtualizationRole }} @@ -174,11 +174,11 @@

Kernel

Version - 10.0.18362 + {{ nodeRun.kernelVersion }} Release - 10.0.18362 + {{ nodeRun.kernelRelease }} diff --git a/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.ts b/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.ts index ff3241a7c4d..766e62828fe 100644 --- a/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.ts +++ b/components/automate-ui/src/app/modules/desktop/desktop-detail/desktop-detail.component.ts @@ -6,6 +6,7 @@ import { saveAs } from 'file-saver'; import { DateTime } from 'app/helpers/datetime/datetime'; import { NodeRunsService } from 'app/services/node-details/node-runs.service'; import { RunHistoryStore } from 'app/services/run-history-store/run-history.store'; +import { NodeRun } from 'app/types/types'; @Component({ selector: 'app-desktop-detail', @@ -15,6 +16,7 @@ import { RunHistoryStore } from 'app/services/run-history-store/run-history.stor export class DesktopDetailComponent { @Input() desktop: Desktop; + @Input() nodeRun: NodeRun; @Input() fullscreened = false; @Input() checkInHistory: DailyNodeRuns; @Input() checkInNumDays = 15; diff --git a/components/automate-ui/src/app/services/node-details/node-runs.service.ts b/components/automate-ui/src/app/services/node-details/node-runs.service.ts index 638eaa0c4b0..69bbf9f127b 100644 --- a/components/automate-ui/src/app/services/node-details/node-runs.service.ts +++ b/components/automate-ui/src/app/services/node-details/node-runs.service.ts @@ -91,9 +91,13 @@ export class NodeRunsService { .then((res) => new PolicyCookbooks(res)); } - getNodeRun(nodeId: string, runId: string, endTime: Date): Promise { + getNodeRun(nodeId: string, runId: string, endTime?: Date): Promise { const url = `${CONFIG_MGMT_URL}/nodes/${nodeId}/runs/${runId}`; - const searchParam = new HttpParams().set('end_time', endTime.toISOString()); + let searchParam = new HttpParams(); + + if (endTime) { + searchParam = searchParam.set('end_time', endTime.toISOString()); + } const options = { params: searchParam diff --git a/components/automate-ui/src/app/types/types.ts b/components/automate-ui/src/app/types/types.ts index 471fab89175..d937c0503a8 100644 --- a/components/automate-ui/src/app/types/types.ts +++ b/components/automate-ui/src/app/types/types.ts @@ -294,6 +294,19 @@ export interface RespNodeRun { run_list: ExpandedRunListItem[]; }; versioned_cookbooks: VersionedCookbook[]; + ip6address?: string; + timezone?: string; + domain?: string; + hostname?: string; + memory_total?: string; + macaddress?: string; + dmi_system_serial_number?: string; + dmi_system_manufacturer?: string; + virtualization_role?: string; + virtualization_system?: string; + kernel_version?: string; + kernel_release?: string; + cloud_provider?: string; } export interface Deprecation { @@ -371,7 +384,20 @@ export class NodeRun { name: '', version: '' } - ] + ], + ip6address: '', + timezone: '', + domain: '', + hostname: '', + memory_total: '', + macaddress: '', + dmi_system_serial_number: '', + dmi_system_manufacturer: '', + virtualization_role: '', + virtualization_system: '', + kernel_version: '', + kernel_release: '', + cloud_provider: '' }); nodeId: string; @@ -420,6 +446,19 @@ export class NodeRun { run_list: ExpandedRunListItem[]; }; versionedCookbooks: VersionedCookbook[]; + ip6address?: string; + timezone?: string; + domain?: string; + hostname?: string; + memoryTotal?: string; + macaddress?: string; + dmiSystemSerialNumber?: string; + dmiSystemManufacturer?: string; + virtualizationRole?: string; + virtualizationSystem?: string; + kernelVersion?: string; + kernelRelease?: string; + cloudProvider?: string; constructor(respNodeRun: RespNodeRun) { this.nodeId = respNodeRun.node_id; @@ -457,6 +496,19 @@ export class NodeRun { this.uptimeSeconds = respNodeRun.uptime_seconds; this.deprecations = respNodeRun.deprecations; this.versionedCookbooks = respNodeRun.versioned_cookbooks; + this.ip6address = respNodeRun.ip6address; + this.timezone = respNodeRun.timezone; + this.domain = respNodeRun.domain; + this.hostname = respNodeRun.hostname; + this.memoryTotal = respNodeRun.memory_total; + this.macaddress = respNodeRun.macaddress; + this.dmiSystemSerialNumber = respNodeRun.dmi_system_serial_number; + this.dmiSystemManufacturer = respNodeRun.dmi_system_manufacturer; + this.virtualizationRole = respNodeRun.virtualization_role; + this.virtualizationSystem = respNodeRun.virtualization_system; + this.kernelVersion = respNodeRun.kernel_version; + this.kernelRelease = respNodeRun.kernel_release; + this.cloudProvider = respNodeRun.cloud_provider; } isPolicyFile(): boolean {