Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,436 changes: 2 additions & 2,434 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900" rel="stylesheet">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand All @@ -21,7 +22,7 @@
-->
<title>React App</title>
</head>
<body>
<body class="body">
<noscript>
You need to enable JavaScript to run this app.
</noscript>
Expand Down
3 changes: 2 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ io.on('connection', (socket) => {
* @param {number} count - user count
* @param {boolean} drop - drop database
*/
generateRandomUsers(10, true);

generateRandomUsers(13, true);
// regenerateLiveFeed();

25 changes: 20 additions & 5 deletions server/utils/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ import {
hourlyGenerationPercentage as hourlyRates
} from '../mock-data/rates.json';

const RAND_MIN = 0.95;
const RAND_MAX = 1.05;
const RAND_MIN = 0.89;
const RAND_MAX = 1.11;

export function generateRandomUsers(userCount, drop = false) {
const kwhs = [5, 10, 15, 20, 30];
if (drop) {
db.dropFeedCollection();
}

const fireUid = 'ZsZoocWfU0NMs1CzifhlE1KU6aE3';
const kwh = 15;
db.postNewFeed({
uid: fireUid,
dailyAvg: generateAvgFeed(kwh),
live: generateLiveFeed(kwh, fireUid),
kwh
});

for (let i = userCount; i > 0; i--) {
const uid = '_' + Math.random().toString(36).substr(2, 9);
const kwh = 10;
const kwh = kwhs[i % 5];

db.postNewFeed({
uid,
Expand All @@ -33,7 +43,12 @@ function generateAvgFeed(kwh) {

for (let date = fromDate; date.getTime() < toDate.getTime(); date.setDate(date.getDate() + 1)) {
const rand = Math.random().toFixed(3) * (RAND_MAX - RAND_MIN) + RAND_MIN;
const value = kwh * dailyRates[date.getMonth()] * rand;

const rate = dailyRates[date.getMonth()] < dailyRates[date.getMonth() + 1]
? dailyRates[date.getMonth()] + (dailyRates[date.getMonth() + 1] - dailyRates[date.getMonth()]) * (date.getDate() / 30)
: dailyRates[date.getMonth()] - (dailyRates[date.getMonth()] - dailyRates[date.getMonth() + 1]) * (date.getDate() / 30)

const value = kwh * rate * rand;
dailyAvg.push({
date: new Date(date.getTime()).getTime(),
value
Expand Down Expand Up @@ -91,5 +106,5 @@ function startPush({uid, kwh}) {
uid,
live: {date: date.getTime(), value}
});
}, 10000);
}, 8000);
}
4 changes: 1 addition & 3 deletions server/utils/database-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ export function pushLive(data) {
return Feed.update(
{ uid: data.uid },
{ $push: {live: data.live}},
(err, res) => {
console.log(err, res);
}
(err, res) => {}
);
}

Expand Down
69 changes: 65 additions & 4 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.App {
text-align: center;
background-color: #e6ecf0;
}

.App-logo {
Expand All @@ -8,12 +9,48 @@
}

.App-header {
background-color: #222;
height: 80px;
padding: 20px;
color: white;
background-color: white;
height:50px;
padding: 10px 10px 7px 10px;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.25);
margin-bottom: 1px;
}

.App-header-backdrop {
height: 320px;
background: url('./assets/img/backdrop.jpg') 50% 22% no-repeat;
background-size: cover;
}

.App-header-profile-avatar {
position: absolute;
height: 208px;
width: 208px;
border-radius: 104px;
padding: 4px;
background-color: white;
z-index: 1;
bottom: -42px;
left: 65px;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.25);
}

.App-header-profile-photo {
margin: 3px 0px 0px 3px;
height: 200px;
width: 200px;
background: url('./assets/img/avatar.png') no-repeat;
}

.App-header-bottom {
position: relative;
height: 46px;
padding: 10px 0;
background-color: white;
z-index: 1;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.25);
}

.App-title {
font-size: 1.5em;
}
Expand All @@ -22,7 +59,31 @@
font-size: large;
}

.Highcharts-wrapper {
padding: 58px 144px 0;
position: relative;
background-color: #e6ecf0;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

.navbar-nav,
.navbar-nav li a {
margin-top: 0 ;
padding-top: 0;
}

.navbar-nav {
padding-bottom: 18px;
}

.fake-section {
margin: 0 auto;
width: 1286px;
height: 800px;
background: url('./assets/img/fake.png') no-repeat;
background-size: contain;
}
17 changes: 3 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@ import logo from './logo.svg';
import './App.css';
import SimpleLineChart from './charts/SimpleLineChart';
import SplineWithPlotBands from './charts/SplineWithPlotBands';
import LiveUpdate from './charts/LiveUpdate';
import Root from './components/Root';
import Live from './components/Live';
import Header from './components/Header';
import Avg from './components/Avg';
import Profile from './components/Profile';
import './config';

class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
</header>

{/* <button onClick={() => this.requestLiveData(123)}>LiveData</button> */}
<Live />

<BrowserRouter>
<Route path="/" component={Root} />
</BrowserRouter>

<SimpleLineChart />
<SplineWithPlotBands />
{/* <LiveUpdate /> */}

</div>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/assets/bootstrap.min.css

Large diffs are not rendered by default.

Binary file added src/assets/img/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/backdrop.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/backdrop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/fake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions src/assets/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*///////////////////////////////*//*Global Styles*/
body {
margin: 0px;
background-color: #E6ECF0;
padding: 0px;
font-family: 'lato', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.nav{
padding: 20px;
float: left;

}
header
{background-color: white;
}
a, a:hover{
outline: none;
text-decoration: none;
text-transform: none;
}
a:hover{
cursor: pointer;
opacity: 0.5;
}

li a{
padding: 20px
}

.nav li{
float: left;
margin-left: 30px;
}
.active{
border-bottom: 2px solid #008000;
}
.pic1{
width: 100%;
}
.avaLittle{
width: 50px;
}
.descrtion{
padding: 20px 0;
}
.marathonBox{
background-color: #FFFEF1;
padding: 20px 0;
}
h1{
font-family: Lato;
font-size: 26px;
font-weight: bold;
font-style: normal;
font-stretch: normal;
line-height: normal;
text-align: left;
color: #667580;
margin-top: 10px;
}
.infoBox{
width: 46%;
height: 100px;
background-color: #ffffff;
border: solid 1px rgba(0, 170, 165, 0.3);
padding: 20px;
margin-top: 10px;
float: left;
margin-left: 15px;

}
.text1{
font-size: 14px;
display: block;
font-weight: bold;
letter-spacing: 0.3px;
text-align: left;
color: #9b9b9b;
}
.text2{
font-size: 24px;
color: #4a90e2;
}

.thForChart{
background-color: #00aaa5;
width: 100%;
margin-top: 10px;
}
.thForChart span{
color: #ffffff;
padding: 5px 10px;
display: block;
}
.chart img{
width: 100%;
}
.avaRight{
float: right;
margin-top: 10px;
}
4 changes: 2 additions & 2 deletions src/charts/SimpleLineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

const plotOptions = {
series: {
pointStart: 2010
pointStart: 2011
}
};

Expand All @@ -15,7 +15,7 @@ const App = () => (
<HighchartsChart plotOptions={plotOptions}>
<Chart />

<Title>Solar Employment Growth by Sector, 2010-2016</Title>
<Title>Solar Employment Growth by Sector, 2011-2017</Title>

<Subtitle>Source: thesolarfoundation.com</Subtitle>

Expand Down
Loading