diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..50148c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +node_modules/ +package-lock.json +package.json diff --git a/app.js b/app.js new file mode 100644 index 0000000..e69de29 diff --git a/app_label.js b/app_label.js new file mode 100644 index 0000000..c71e08c --- /dev/null +++ b/app_label.js @@ -0,0 +1,120 @@ + +var firebase = require('firebase'); +var admin = require('firebase-admin'); +var funcs = require('firebase-functions'); + +var firebaseConfig = { + apiKey: "AIzaSyCvIgWTTi16ESUYEhbQlRda9ItjXgvRgyU", + authDomain: "minerva-7ae74.firebaseapp.com", + databaseURL: "https://minerva-7ae74.firebaseio.com", + projectId: "minerva-7ae74", + storageBucket: "", + messagingSenderId: "1018992044633", + appId: "1:1018992044633:web:dcdfdb4754bde54e095f48" +}; + +firebase.initializeApp(firebaseConfig); + +let db = firebase.firestore(); +db.collection("data1") +.get() +.then(querySnapshot => { + if (!querySnapshot.empty) { + //We know there is one doc in the querySnapshot + const queryDocumentSnapshot = querySnapshot.docs[0].label_distribution; + return console.log(queryDocumentSnapshot); + } else { + console.log("No document corresponding to the query!"); + return null; + } +}); +console.log("NONLADASKNONLADASKNONLADASKNONLADASKNONLADASKNONLADASKNONLADASKNONLADASK"); + +db.collection('data1').get() + .then((snapshot) => { + + snapshot.forEach((doc) => { + var fragment = create(''); + + var generateHere = document.getElementById("generate-datapoint_labels") + generateHere.insertBefore(fragment, generateHere.firstChild); + console.log(doc.id, '=>', doc.data()); + }); + }) + .catch((err) => { + console.log('Error getting documents', err); + }); + + + +window.onload = function () { + + var chart = new CanvasJS.Chart("chartContainer", { + title: { + text: "Realit" + }, + axisY: { + title: "Temperature", + suffix: " °C" + }, + data: [{ + type: "column", + yValueFormatString: "#,### °C", + indexLabel: "{y}", + dataPoints: [ + { label: "boiler1", y: 206 }, + { label: "boiler2", y: 163 }, + { label: "boiler3", y: 154 }, + { label: "boiler4", y: 176 }, + { label: "boiler5", y: 184 }, + { label: "boiler6", y: 122 } + ] + }] + }); + + var pie_chart = new CanvasJS.Chart("chartContainer", { + theme: "dark2", // "light1", "light2", "dark1", "dark2" + exportEnabled: true, + animationEnabled: true, + title: { + text: "Cats" //dynamic according to the label that the user is in + }, + data: [{ + type: "pie", + startAngle: 25, + toolTipContent: "{label}: {y}%", + showInLegend: "true", + legendText: "{label}", + indexLabelFontSize: 16, + indexLabel: "{label} - {y}%", + dataPoints: [ + { y: 51.08, label: "Chrome" }, + { y: 27.34, label: "Internet Explorer" }, + { y: 10.62, label: "Firefox" }, + { y: 5.02, label: "Microsoft Edge" }, + { y: 4.07, label: "Safari" }, + { y: 1.22, label: "Opera" }, + { y: 0.44, label: "Others" } + ] + }] + }); + pie_chart.render(); + + function updateChart() { + var boilerColor, deltaY, yVal; + var dps = chart.options.data[0].dataPoints; + for (var i = 0; i < dps.length; i++) { + deltaY = Math.round(2 + Math.random() *(-2-2)); + yVal = deltaY + dps[i].y > 0 ? dps[i].y + deltaY : 0; + boilerColor = yVal > 200 ? "#FF2500" : yVal >= 170 ? "#FF6000" : yVal < 170 ? "#6B8E23 " : null; + dps[i] = {label: "Boiler "+(i+1) , y: yVal, color: boilerColor}; + } + chart.options.data[0].dataPoints = dps; + chart.render(); + }; + updateChart(); + var generateHere = document.getElementById("generate-here"); + generateHere.insertBefore(fragment, generateHere.firstChild); + setInterval(function() {updateChart()}, 500); + + } \ No newline at end of file diff --git a/blah.html b/blah.html new file mode 100644 index 0000000..2ebc086 --- /dev/null +++ b/blah.html @@ -0,0 +1 @@ +
0
+ + +
+
+
+
+
\ No newline at end of file
diff --git a/main.css b/main.css
new file mode 100644
index 0000000..839bcea
--- /dev/null
+++ b/main.css
@@ -0,0 +1,167 @@
+@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700);
+
+html{ background:url(http://thekitemap.com/images/feedback-img.jpg) no-repeat;
+ background-size: cover;
+ height:100%;
+}
+
+#feedback-page{
+ text-align:center;
+}
+
+#form-main{
+ width:100%;
+ float:left;
+ padding-top:0px;
+}
+
+#form-div {
+ background-color:rgba(72,72,72,0.4);
+ padding-left:35px;
+ padding-right:35px;
+ padding-top:35px;
+ padding-bottom:50px;
+ width: 450px;
+ float: left;
+ left: 50%;
+ position: absolute;
+ margin-top:30px;
+ margin-left: -260px;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+}
+
+.feedback-input {
+ color:#3c3c3c;
+ font-family: Helvetica, Arial, sans-serif;
+ font-weight:500;
+ font-size: 18px;
+ border-radius: 0;
+ line-height: 22px;
+ background-color: #fbfbfb;
+ padding: 13px 13px 13px 54px;
+ margin-bottom: 10px;
+ width:100%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -ms-box-sizing: border-box;
+ box-sizing: border-box;
+ border: 3px solid rgba(0,0,0,0);
+}
+
+.feedback-input:focus{
+ background: #fff;
+ box-shadow: 0;
+ border: 3px solid #3498db;
+ color: #3498db;
+ outline: none;
+ padding: 13px 13px 13px 54px;
+}
+
+.focused{
+ color:#30aed6;
+ border:#30aed6 solid 3px;
+}
+
+/* Icons ---------------------------------- */
+#name{
+ background-image: url(http://rexkirby.com/kirbyandson/images/name.svg);
+ background-size: 30px 30px;
+ background-position: 11px 8px;
+ background-repeat: no-repeat;
+}
+
+#name:focus{
+ background-image: url(http://rexkirby.com/kirbyandson/images/name.svg);
+ background-size: 30px 30px;
+ background-position: 8px 5px;
+ background-position: 11px 8px;
+ background-repeat: no-repeat;
+}
+
+#email{
+ background-image: url(http://rexkirby.com/kirbyandson/images/email.svg);
+ background-size: 30px 30px;
+ background-position: 11px 8px;
+ background-repeat: no-repeat;
+}
+
+#email:focus{
+ background-image: url(http://rexkirby.com/kirbyandson/images/email.svg);
+ background-size: 30px 30px;
+ background-position: 11px 8px;
+ background-repeat: no-repeat;
+}
+
+#comment{
+ background-image: url(http://rexkirby.com/kirbyandson/images/comment.svg);
+ background-size: 30px 30px;
+ background-position: 11px 8px;
+ background-repeat: no-repeat;
+}
+
+textarea {
+ width: 100%;
+ height: 150px;
+ line-height: 150%;
+ resize:vertical;
+}
+
+input:hover, textarea:hover,
+input:focus, textarea:focus {
+ background-color:white;
+}
+
+#button-blue{
+ font-family: 'Montserrat', Arial, Helvetica, sans-serif;
+ float:left;
+ width: 100%;
+ border: #fbfbfb solid 4px;
+ cursor:pointer;
+ background-color: #3498db;
+ color:white;
+ font-size:24px;
+ padding-top:22px;
+ padding-bottom:22px;
+ -webkit-transition: all 0.3s;
+ -moz-transition: all 0.3s;
+ transition: all 0.3s;
+ margin-top:-4px;
+ font-weight:700;
+}
+
+#button-blue:hover{
+ background-color: rgba(0,0,0,0);
+ color: #0493bd;
+}
+
+.submit:hover {
+ color: #3498db;
+}
+
+.ease {
+ width: 0px;
+ height: 74px;
+ background-color: #fbfbfb;
+ -webkit-transition: .3s ease;
+ -moz-transition: .3s ease;
+ -o-transition: .3s ease;
+ -ms-transition: .3s ease;
+ transition: .3s ease;
+}
+
+.submit:hover .ease{
+ width:100%;
+ background-color:white;
+}
+
+@media only screen and (max-width: 580px) {
+ #form-div{
+ left: 3%;
+ margin-right: 3%;
+ width: 88%;
+ margin-left: 0;
+ padding-left: 3%;
+ padding-right: 3%;
+ }
+}
\ No newline at end of file
diff --git a/public/client.js b/public/client.js
new file mode 100644
index 0000000..37e6e33
--- /dev/null
+++ b/public/client.js
@@ -0,0 +1,23 @@
+console.log('Client-side code running');
+
+const button = document.getElementById('submit_btn');
+console.log('Casdlfkj');
+
+button.addEventListener('click', function(e) {
+
+ console.log('button was clickedsanzeed' );
+
+});
+
+
+
+
+
+// button.addEventListener('')
+// a = function(e) {
+
+// console.log('button was clicked');
+// }
+// button.addEventListener('click', a);
+
+
diff --git a/public/index.js b/public/index.js
new file mode 100644
index 0000000..d75eed4
--- /dev/null
+++ b/public/index.js
@@ -0,0 +1 @@
+console.log("sdaf")
\ No newline at end of file
diff --git a/sample_html.html b/sample_html.html
new file mode 100644
index 0000000..ea15079
--- /dev/null
+++ b/sample_html.html
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/server.js b/server.js
new file mode 100644
index 0000000..592d87d
--- /dev/null
+++ b/server.js
@@ -0,0 +1,185 @@
+var ip_address = '18.20.216.61';
+
+var http = require("http");
+var fs = require('fs');
+
+
+var firebase = require('firebase');
+
+var firebaseConfig = {
+ apiKey: "AIzaSyCvIgWTTi16ESUYEhbQlRda9ItjXgvRgyU",
+ authDomain: "minerva-7ae74.firebaseapp.com",
+ databaseURL: "https://minerva-7ae74.firebaseio.com",
+ projectId: "minerva-7ae74",
+ storageBucket: "",
+ messagingSenderId: "1018992044633",
+ appId: "1:1018992044633:web:dcdfdb4754bde54e095f48"
+};
+
+firebase.initializeApp(firebaseConfig);
+
+let db = firebase.firestore();
+
+
+// db.collection('cats').get()
+// .then((snapshot) => {
+// snapshot.forEach((doc) => {
+// console.log(doc.id, '=>', doc.data());
+// console.log("ldsakfjjasdfjlfsd")
+// });
+// })
+// .catch((err) => {
+// console.log('Error getting documents', err);
+// });
+
+
+
+// //this is how you write to db!!!
+// let docRef = db.collection('cats').doc('writing_first_time');
+// let writing_first_time = docRef.set({
+// 'Adi': 'bad',
+// 'bad': 15,
+// 'good': 10,
+// predicted_label: 'bad'
+// }); npm install express --save
+
+
+
+
+
+// http.createServer(function (request, response) {
+// // Send the HTTP header
+// // HTTP Status: 200 : OK
+// // Content Type: text/plain
+// response.writeHead(200, {'Content-Type': 'text/html'});
+// // Send the response body as "Hello World"
+// // response.end('Hello World\n');
+
+// fs.readFile('./upload.html', null, function (error, data) {
+// if (error) {
+// response.writeHead(404);
+// respone.write('Whoops! File not found!');
+// } else {
+// response.write(data);
+
+// // response.write(data);
+// }
+// response.end();
+// });
+
+// }).listen(3000, ip_address);
+
+
+// Console will print the message
+console.log('Server running at http://127.0.0.1:8081/');
+
+
+
+
+console.log('Server-side code running');
+
+const express = require('express');
+
+const app = express();
+
+app.use(express.static('public'));
+
+// start the express web server listening on 8080
+app.listen(8080, () => {
+ console.log('listening on 8080');
+});
+
+// serve the homepage
+app.get('/', (req, res) => {
+
+ res.sendFile(__dirname + '/welcome.html');
+});
+
+
+app.get('/clicked', (req, res) => {
+ const click = {clickTime: new Date()};
+ console.log(click);
+ console.log("kkmkmmkm");
+
+ // db.collection('data1').doc('express-test');
+ let docRef = db.collection('test').doc()
+
+ let writing_first_time = docRef.set({
+ 'Adi': 'bad',
+ 'bad': 15,
+ 'good': 10,
+ predicted_label: 'bad'
+ });
+ res.sendFile(__dirname + '/labelling_session.html');
+
+});
+
+app.post('/submit', (req, res) => {
+ console.log("kkmkmmkm");
+ res.sendFile(__dirname + '/labelling_session.html');
+
+});
+var path = process.cwd();
+
+app.route('/uploading')
+ .get(function (req, res) {
+
+ res.sendFile(__dirname + '/upload.html');
+ });
+
+ app.route('/login')
+ .get(function (req, res) {
+
+ res.sendFile(__dirname + '/login.html');
+ });
+
+
+app.route('/goData')
+ .get(function (req, res) {
+
+var sentiment = {negative_c: 0, positive_c:0, neutral_c:0}
+var ejs_i = 0;
+var data_json = [{},sentiment, ejs_i];
+var index = 0;
+
+db.collection('data1').get()
+ .then((snapshot) => {
+ snapshot.forEach((doc) => {
+ sentiment.negative_c = sentiment.negative_c + parseInt(JSON.stringify(doc.data().label_distribution.Negative));
+ sentiment.neutral_c = sentiment.neutral_c + parseInt(JSON.stringify(doc.data().label_distribution.Neutral));
+ sentiment.positive_c = sentiment.positive_c + parseInt(JSON.stringify(doc.data().label_distribution.Positive));
+ });
+})
+
+
+ .catch((err) => {
+ console.log('Error getting documents', err);
+ });
+
+ console.log("outside fo the db read");
+
+ db.collection('data1').get()
+ .then((snapshot) => {
+ console.log("in the snapshot");
+
+ snapshot.forEach((doc) => {
+ data_json[0][index] = doc.data();
+ index++;
+ // console.log('bruh', data_json.data)
+ // options = data_json.label_distribution
+ // const html_gen = window.document.createElement('')
+ // console.log(html_gen)
+ });
+
+ app.set('view engine', 'ejs');
+ console.log(Object.keys(data_json[0]).length);
+ res.render(path + '/labelling_session.ejs', {dynamic : data_json});
+ })
+ .catch((err) => {
+ console.log('Error getting documents', err);
+ });
+});
+
+
+
+
\ No newline at end of file
diff --git a/upload.html b/upload.html
new file mode 100644
index 0000000..6114635
--- /dev/null
+++ b/upload.html
@@ -0,0 +1,41 @@
+
+
+
+