Skip to content

Commit

Permalink
Working on chat(4).
Browse files Browse the repository at this point in the history
  • Loading branch information
RakhithaRR committed Mar 17, 2018
1 parent 454b5b9 commit 46b0f8a
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 68 deletions.
137 changes: 81 additions & 56 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 22 additions & 12 deletions Client/src/components/Projects/ViewProjects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@
<v-list-tile-title>{{ item.text }}</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-list-tile-action-text>{{getTime(item.date) +" "+new Date(item.date).toDateString() }}</v-list-tile-action-text>
<v-list-tile-action-text>{{getTime(item.date) + " " + new Date(item.date).toDateString() }}
</v-list-tile-action-text>
</v-list-tile-action>
</v-list-tile>
</v-list>
Expand Down Expand Up @@ -249,6 +250,20 @@
});
},
getMessages() {
axios.post("http://localhost:3000/chats/getMessages",
{
key: this.key
},
{"headers": {'Content-Type': 'application/json'}})
.then((response) => {
})
.catch((error) => {
console.log(error);
});
},
getCompletion(cProject) {
var nTasks = 0;
Expand Down Expand Up @@ -315,14 +330,17 @@
}
},
getTime(dateString){
getTime(dateString) {
var d = new Date(dateString);
return d.getHours()+":"+d.getMinutes()
return d.getHours() + ":" + d.getMinutes()
},
sendMessage() {
console.log("CLICKED");
socket.emit('chat', {msg:{username: this.cUser.Name, text: this.textMessage, date: new Date()}, key: this.key});
socket.emit('chat', {
msg: {username: this.cUser.Name, text: this.textMessage, date: new Date()},
key: this.key
});
this.$refs.msg.focus();
this.textMessage = "";
Expand All @@ -335,14 +353,6 @@
this.messages.push(data);
return this.messages
// console.log(data.messages);
// for(var i in data.messages){
// if(data.messages.hasOwnProperty(i)){
// var obj = data.messages[i]
// this.messages.push(obj)
// }
// }
});
}
Expand Down
2 changes: 2 additions & 0 deletions Server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ io.sockets.on('connection', (socket) => {
//routes
const users = require('./routes/user');
const project = require('./routes/project');
const chat = require('./routes/chat');

app.use('/users', users);
app.use('/project', project);
app.use('/chats',chat);


app.get('/', (req, res) => {
Expand Down
19 changes: 19 additions & 0 deletions Server/routes/chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var express = require('express');
var router = express.Router();
var firebaseSDK = require('firebase');

//importing the database
const firebase = require('../database/database');


router.post('/getMessages',(req,res,next) =>{
var key = req.body.key;
var chatRef = firebase.database.ref('messages/'+key);

chatRef.orderByChild('date').once('value', (snapshot)=> {

})
});


module.exports = router

0 comments on commit 46b0f8a

Please sign in to comment.