summaryrefslogtreecommitdiffstats
path: root/webui/src/Components/Timeline/EventNode.js
diff options
context:
space:
mode:
Diffstat (limited to 'webui/src/Components/Timeline/EventNode.js')
-rw-r--r--webui/src/Components/Timeline/EventNode.js76
1 files changed, 5 insertions, 71 deletions
diff --git a/webui/src/Components/Timeline/EventNode.js b/webui/src/Components/Timeline/EventNode.js
index 9b2a308..74022a7 100644
--- a/webui/src/Components/Timeline/EventNode.js
+++ b/webui/src/Components/Timeline/EventNode.js
@@ -1,97 +1,31 @@
import React, { Component } from 'react';
import './EventNode.scss';
-import moment from 'moment';
class EventNode extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- event: props.event,
- alignment: props.alignment
- };
- }
-
- getColorClass() {
-
- if(this.state.event.type === "StartupEvent")
- return "green";
-
- if(this.state.event.type === "WebhookAction")
- return "blue";
-
- return "purple";
- }
-
- getTitle() {
-
- if(this.state.event.type === "StartupEvent")
- return "Startup";
-
- if(this.state.event.type === "WebhookAction")
- return "Webhook";
-
- return this.state.event.type;
- }
-
- getSubtitle() {
-
- if(this.state.event.type === "StartupEvent") {
-
- if(this.state.event.address)
- return "Listening on " + this.state.event.address + " port " + this.state.event.port;
-
- return "Starting up.."
- }
-
- if(this.state.event.type === "WebhookAction")
- return "Incoming request from " + this.state.event['client-address'];
-
- return this.state.event.type;
- }
-
- getDate() {
- return moment.unix(this.state.event.timestamp).format("YYYY-MM-DD");
- }
-
- getTime() {
- return moment.unix(this.state.event.timestamp).format("HH:mm");
- }
-
- getIconName() {
-
- if(this.state.event.success === false)
- return "alert"
-
- if(this.state.event.type === "StartupEvent")
- return "alert-circle";
-
- return "check";
- }
getIconElement() {
- if(this.state.event.waiting === true) {
+ if(this.props.event.isWaiting()) {
return (
<div className="icon spinner"></div>
);
}
return (
- <i className={"icon mdi mdi-" + this.getIconName()} />
+ <i className={"icon mdi mdi-" + this.props.event.getIconName()} />
);
}
render() {
return (
- <div className={"EventNode " + this.state.alignment + " " + this.getColorClass()}>
+ <div className={"EventNode " + this.props.alignment + " " + this.props.event.getColorClass()}>
<span className="horizontal-line"></span>
<span className="timeline-icon"></span>
<div className="inner">
<div className="header">
{this.getIconElement()}
- <p className="title">{this.getTitle()}</p>
- <p className="subtitle">{this.getSubtitle()}</p>
+ <p className="title">{this.props.event.getTitle()}</p>
+ <p className="subtitle">{this.props.event.getSubtitle()}</p>
</div>
<div className="body">
{this.props.children}