Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1117 from agnetedjupvik/header-panel
Browse files Browse the repository at this point in the history
Project Presence panel
  • Loading branch information
agnetedjupvik authored Jun 7, 2019
2 parents 7b0118e + ac3a899 commit 57a50d6
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 64 deletions.
6 changes: 3 additions & 3 deletions Source/Analytics/Web.Frontend/src/components/Analytics.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from "react";
import AnalyticsBanner from "./AnalyticsBanner.js";
import Map from "./Map.js";
import Diagram from "./Diagram.js";
import ProjectPresence from "./ProjectPresence.js";

export const BASE_URL = process.env.API_BASE_URL;

Expand All @@ -12,8 +12,8 @@ class Analytics extends Component {
render() {
return (
<div className="analytics--container">
<AnalyticsBanner />
<Map />
<ProjectPresence />

<Diagram
selectedSeries={["Total"]}
hasDatePicker
Expand Down
5 changes: 3 additions & 2 deletions Source/Analytics/Web.Frontend/src/components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { connect } from "react-redux";
import { Map, Popup, CircleMarker, TileLayer } from "react-leaflet";
import { formatDate, toOrDefault, fromOrDefault } from "../utils/dateUtils";
import { getJson } from "../utils/request";
import { Alert, Button } from "evergreen-ui";
import { Alert, Button, Text } from "evergreen-ui";

import { BASE_URL } from "./Analytics";

Expand Down Expand Up @@ -90,13 +90,14 @@ class MapWidget extends Component {
);
}
return (
<Map center={position} zoom={6}>
<Map center={position} zoom={5} style={{height: 210, width: 210}}>
<TileLayer
attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"
/>
<OutbreakMarkers outbreaks={this.state.outbreaks} />
</Map>

);
}
}
Expand Down
34 changes: 34 additions & 0 deletions Source/Analytics/Web.Frontend/src/components/PresenceIndicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import { Heading, UnorderedList, ListItem } from "evergreen-ui";

export class PresenceIndicator extends React.Component {
createInfoLine(presenceData) {
let text = "";
Object.values(presenceData).forEach(value => {text = value + " " + text}); //prepend to the text as we want the numbers before the description
return text;
}

render() {
return (
<div className="analytics--headerPanel" style={{marginRight: 30}}>
<i className={`${this.props.icon} fa fa-5x analytics--headerPanelIcon`} />

<Heading color={this.props.color} size={600} paddingTop={"20px"}>
{this.props.headline}
</Heading>

<div className="analytics--listContainer">
<UnorderedList size={500}>
{this.props.list.map(
(data, index) => (
<ListItem key={index}>
{this.createInfoLine(data)}
</ListItem>
)
)}
</UnorderedList>
</div>
</div>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import {
Heading,
UnorderedList,
ListItem,
Button,
Spinner,
Alert,
Text
} from "evergreen-ui";
import { DatePicker } from "./DatePicker";
import { PresenceIndicator } from "./PresenceIndicator";
import Map from "./Map.js";
import { updateRange } from "../actions/analysisactions";
import { formatDate, fromOrDefault, toOrDefault } from "../utils/dateUtils";
import { BASE_URL } from "./Analytics";
import { getJson } from "../utils/request";

class AnalyticsBanner extends Component {
class ProjectPresence extends Component {
constructor(props) {
super(props);

Expand Down Expand Up @@ -154,65 +154,37 @@ class AnalyticsBanner extends Component {
);
}

let headerPanelContainerStyle = {
display: 'flex',
flexWrap: 'wrap',
marginTop: 10,
marginBottom: 10
};

return (
<>
{header}
<div className="analytics--headerPanelContainer">
<div className="analytics--headerPanel">
<i className=" fa fa-heartbeat fa-5x analytics--headerPanelIcon" />

<Heading color="#9f0000" size={600} paddingTop={"20px"}>
{this.state.caseReports.totalNumberOfReports}{" "}
Reports
</Heading>
<div className="analytics--listContainer">
<UnorderedList size={500}>
{this.state.caseReports.reportedHealthRisks.map(
(data, index) => (
<ListItem key={index}>
{data.numberOfReports} {data.name}
</ListItem>
)
)}
</UnorderedList>
</div>
</div>
<div className="analytics--headerPanel">
<i className="analytics--headerPanelIcon fa fa-user fa-5x" />

<Heading color="#009f00" size={600} paddingTop={"20px"}>
{`${
this.state.dataCollectors.activeDataCollectors
} Active Data Collectors`}
</Heading>
<div className="analytics--listContainer">
<UnorderedList size={500}>
<ListItem>{`${
this.state.dataCollectors
.inactiveDataCollectors
} Inactive`}</ListItem>
</UnorderedList>
</div>
</div>
<div className="analytics--headerPanel">
<i className="analytics--headerPanelIcon fa fa-exclamation-triangle fa-5x " />

<Heading color="#9f0000" size={600} paddingTop={"20px"}>
{`${this.state.alerts.totalNumberOfAlerts} Alerts`}
</Heading>
<div className="analytics--listContainer">
<UnorderedList size={500}>
{this.state.alerts.alertsPerHealthRisk.map(
(data, index) => (
<ListItem key={index}>
{data.numberOfReports}{" "}
{data.healthRisk}
</ListItem>
)
)}
</UnorderedList>
</div>
<Heading size={800} marginTop={20}>Project Presence</Heading>

<div className="analytics--headerPanelContainer" style={headerPanelContainerStyle}>
<PresenceIndicator
headline={`${this.state.caseReports.totalNumberOfReports} Reports`}
list={this.state.caseReports.reportedHealthRisks}
color="#9f0000"
icon="fa-heartbeat"
/>

<PresenceIndicator
headline={`${this.state.dataCollectors.activeDataCollectors} Active Data Collectors`}
list={[{name:"Inactive Data Collectors", inactiveDataCollectors: this.state.dataCollectors.inactiveDataCollectors}]}
color="#009f00"
icon="fa-user"
/>

<div>
<Map />
</div>

</div>
</>
);
Expand All @@ -232,4 +204,4 @@ function mapDispatchToProps(dispatch) {
export default connect(
mapStateToProps,
mapDispatchToProps
)(AnalyticsBanner);
)(ProjectPresence);

0 comments on commit 57a50d6

Please sign in to comment.