diff --git a/package-lock.json b/package-lock.json index 6565008..43c2635 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2187,6 +2187,11 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "countup.js": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/countup.js/-/countup.js-1.9.3.tgz", + "integrity": "sha1-zj5QzXFgRB5HjwfaMYle3MDxyd0=" + }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -5989,6 +5994,16 @@ "resolved": "https://registry.npmjs.org/react-context-toolbox/-/react-context-toolbox-2.0.2.tgz", "integrity": "sha512-tY4j0imkYC3n5ZlYSgFkaw7fmlCp3IoQQ6DxpqeNHzcD0hf+6V+/HeJxviLUZ1Rv1Yn3N3xyO2EhkkZwHn0m1A==" }, + "react-countup": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/react-countup/-/react-countup-4.2.2.tgz", + "integrity": "sha512-6mTJiXDt/x/K5odlKL2mAbQLYQLT9PyqmLcmLO6iCxeGy8yfcaRZTKw9BuzCR6qSHNsR6uzLAyJh6kjf0HvhcQ==", + "requires": { + "countup.js": "^1.9.3", + "prop-types": "^15.6.2", + "warning": "^4.0.2" + } + }, "react-dom": { "version": "16.8.6", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.8.6.tgz", diff --git a/package.json b/package.json index 430c111..23b9a9a 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "node-stream-zip": "^1.8.2", "react": "^16.8.6", "react-bootstrap": "^1.0.0-beta.10", + "react-countup": "^4.2.2", "react-dom": "^16.8.6", "react-file-drop": "^0.2.8", "react-loading": "^2.0.3", diff --git a/server/MongoHelper.js b/server/MongoHelper.js index 348ffcc..b9779f0 100644 --- a/server/MongoHelper.js +++ b/server/MongoHelper.js @@ -98,10 +98,24 @@ const getFBMap = () => { }) } +const getUserCount = () => { + return new Promise((resolve, reject) => { + MongoPool.getInstance((client) => { + let db = client.db("pricemydata") + let collectionName = "price_entries" + db.collection(collectionName).count({}, function(error, numOfDocs){ + if(error) return callback(error); + resolve(numOfDocs); + }); + }) + }) +} + module.exports = { appendPriceEntry, getFBMap, - getGoogleMap + getGoogleMap, + getUserCount } diff --git a/server/index.js b/server/index.js index c77010f..a1018aa 100644 --- a/server/index.js +++ b/server/index.js @@ -41,7 +41,7 @@ MongoPool.createPool(mongo, options); app.post('/valueFB', upload.single('fbFile'), valueFBData); -app.post('/valueGoogle', upload.single('googleFile'), valueGoogleData) +app.post('/valueGoogle', upload.single('googleFile'), valueGoogleData); //app.post('/loginUser', processLogin); @@ -59,6 +59,13 @@ app.post('/api/appendEntry', (req, res) => { }) }) +app.post('/fetchUserCount', async (req, res) => { + let userCount = await MongoHelper.getUserCount(); + res.json({ + count: userCount + }) +}) + /* app.post('/api/fetchFBMeans', async (req, res) => { diff --git a/src/components/Home.js b/src/components/Home.js index e2de5fe..66a9d34 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -1,21 +1,50 @@ import React, {Component} from 'react'; import Button from 'react-bootstrap/Button' +import CountUp from 'react-countup'; import "../styles/HomeStyle.css" -export default function Home(props) { - return( - -

How much is your data really worth?

-
Crowdfunding data valuations, for a safer, friendlier and more secure tomorrow.
-
- -
-

Read more about this project here

-

By using us to price your data, you agree to our terms and conditions

- -
- ); +export default class Home extends Component { + + constructor(props) { + super(props); + this.state = { + users:0 + } + } + + componentDidMount() { + const endpoint = "./fetchUserCount"; + fetch(endpoint, { + method: 'POST', + headers:{ + 'Content-Type': 'application/json' + }, + }).then(res => res.json()).then(response => { + let {count} = response; + console.log(count); + this.setState({users:count}) + }) + .catch( + error => console.log(error) + ); + } + + render() { + let {users} = this.state; + return( + +

How much is your data really worth?

+
Crowdfunding data valuations, for a safer, friendlier and more secure tomorrow.
+
+ +
+

Read more about this project here

+

By using us to price your data, you agree to our terms and conditions

+ +
+ ); + } } \ No newline at end of file diff --git a/src/components/PriceData.js b/src/components/PriceData.js index f100f60..3b2dc49 100644 --- a/src/components/PriceData.js +++ b/src/components/PriceData.js @@ -239,7 +239,7 @@ export default class PriceData extends Component { Google -

{this.state.download.message}

+

{this.state.download.message}

{this.state.content}

How much would you charge for:

diff --git a/src/styles/HomeStyle.css b/src/styles/HomeStyle.css index f47b072..2937a26 100644 --- a/src/styles/HomeStyle.css +++ b/src/styles/HomeStyle.css @@ -34,15 +34,12 @@ border-color: #ffffff; } -.circularButton { +.counter { position: absolute; top:1vh; left:1vw; - height:5vh; - width:5vh; - border-radius: 50%; background-color: transparent; - border-color: #ffffff; + color: #ffffff; } .readMore {