Skip to content

Commit

Permalink
Issue #340 - render application events
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Matyushentsev authored and Alexander Matyushentsev committed Jul 23, 2018
1 parent 2e1db8f commit 95b237b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{ na
title: 'PARAMETERS', key: 'parameters', content: <ParametersPanel
params={this.state.application.status.parameters || []}
overrides={this.state.application.spec.source.componentParameterOverrides}/>,
}, {
title: 'EVENTS', key: 'event', content: <ApplicationResourceEvents applicationName={this.state.application.metadata.name}/>,
}]}/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { services } from '../../../shared/services';

require('./application-resource-events.scss');

export class ApplicationResourceEvents extends React.Component<{ applicationName: string, resource: models.ResourceNode }, { events: models.Event[] }> {
export class ApplicationResourceEvents extends React.Component<{ applicationName: string, resource?: models.ResourceNode }, { events: models.Event[] }> {

constructor(props: {applicationName: string, resource: models.ResourceNode }) {
constructor(props: {applicationName: string, resource?: models.ResourceNode }) {
super(props);
this.state = { events: null };
}

public async componentDidMount() {
const events = await services.applications.resourceEvents(this.props.applicationName, this.props.resource.state.metadata.uid, this.props.resource.state.metadata.name);
this.setState({ events });
const events = this.props.resource ?
services.applications.resourceEvents(this.props.applicationName, this.props.resource.state.metadata.uid, this.props.resource.state.metadata.name) :
services.applications.events(this.props.applicationName);
this.setState({ events: await events });
}

public render() {
Expand All @@ -28,7 +30,8 @@ export class ApplicationResourceEvents extends React.Component<{ applicationName
<div className='argo-table-list'>
<div className='argo-table-list__head'>
<div className='row'>
<div className='columns small-8'>MESSAGE</div>
<div className='columns small-2'>REASON</div>
<div className='columns small-6'>MESSAGE</div>
<div className='columns small-2'>COUNT</div>
<div className='columns small-2'>EVENT TIMESTAMP</div>
</div>
Expand All @@ -37,7 +40,8 @@ export class ApplicationResourceEvents extends React.Component<{ applicationName
<div className={`argo-table-list__row application-resource-events__event application-resource-events__event--${event.type}`}
key={event.metadata.uid}>
<div className='row'>
<div className='columns small-8'>{event.message}</div>
<div className='columns small-2'>{event.reason}</div>
<div className='columns small-6'>{event.message}</div>
<div className='columns small-2'>{event.count}</div>
<div className='columns small-2'>{event.firstTimestamp}</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/app/shared/services/applications-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class ApplicationsService {
return requests.delete(`/applications/${applicationName}/pods/${podName}`).send().then(() => true);
}

public events(applicationName: string): Promise<models.Event[]> {
return this.resourceEvents(applicationName, null, null);
}

public resourceEvents(applicationName: string, resourceUID: string, resourceName: string): Promise<models.Event[]> {
return requests.get(`/applications/${applicationName}/events`).query({resourceName, resourceUID}).send().then((res) => (res.body as models.EventList).items || []);
}
Expand Down

0 comments on commit 95b237b

Please sign in to comment.