Skip to content
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
3 changes: 2 additions & 1 deletion public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"author": "Thuan Envity",
"dependencies": {
"axios": "^0.19.0",
"bootstrap": "^4.4.0",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.1.0",
"core-js": "^3.3.2",
"jquery": "^3.4.1",
"lodash": "^4.17.15",
Expand Down
25 changes: 23 additions & 2 deletions public/src/api/service.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,38 @@ import axios from "axios";
const URL_SERVER = process.env.VUE_APP_URL_SERVER;
export default {
registerUser: async function (data) {
return await axios({
return axios({
method: "POST",
url: `${URL_SERVER}/auth/register`,
data: data
});
},
loginUser: async function (data) {
return await axios({
return axios({
method: "POST",
url: `${URL_SERVER}/auth/login`,
data: data
});
},
getAllUsers: async function(params){
return axios({
method: "GET",
url: `${URL_SERVER}/user/getAllUsers`,
params: params
});
},
getAllRooms: async function(params){
return axios({
method: "GET",
url: `${URL_SERVER}/room/getAllRooms`,
params: params
});
},
createRoom: async function(data){
return axios({
method: "POST",
url: `${URL_SERVER}/room/createRoom`,
data: data
});
}
}
7 changes: 5 additions & 2 deletions public/src/components/auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,18 @@
async handleSubmit() {
this.errors = [];
if (this.username && this.password) {
await api
return await api
.loginUser({username: this.username, password: this.password})
.then(async res => {
console.log(res);
if (res.status === 200) {
localStorage.setItem("authToken", res.data.token);
setAuthToken(res.data.token);
this.$router.push({name: "Home"});
}
})
.catch(error =>{
console.log(error);
console.log('login fail!!!');
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions public/src/components/auth/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@
async handleSubmit() {
this.errors = [];
if (this.username && this.password) {
await api
return await api
.registerUser({username: this.username, password: this.password})
.then(async res => {
console.log(res.status);
if (res.status === 200) {
localStorage.setItem("authToken", res.data.token);
setAuthToken(res.data.token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@

<script>
export default {
name: "Conservation",
name: "Conversation",
props: {
conversation: {
type: Object,
required: true,
default: function () {
return {
name: '',
icon: '',
type: 0,
content: []
}
}
}
},
data() {
return {
listMessage: []
Expand All @@ -33,7 +47,7 @@
});
if (parseInt(newPost.content)) {
for (let index = 0; index < parseInt(newPost.content); index++) {
if (index > 5) {
if (index > 10) {
break;
} else {
this.listMessage.push({
Expand Down Expand Up @@ -68,9 +82,10 @@
border: 1px solid #cccccc;
border-radius: 0px 20px 20px 0px;
border-left: none;
padding: 10px;
text-align: center;
padding: 9.5px;
background: #f1f1f1;
white-space: pre-line;
text-align: left;
}

.img-icon-user-conversation-right {
Expand All @@ -81,7 +96,9 @@
float: right;
border-radius: 20px 0px 0px 20px;
border-right: none;
background: #fffce1;
background: #f1f1f1;
padding: 8px;
margin-top: 1px;
}

.div-content-message-right {
Expand Down
139 changes: 32 additions & 107 deletions public/src/components/room/ListFriend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<div class="page list-room">
<table class="table-full-width">
<tbody>
<tr v-for="friend in listFriend" :key="friend.id">
<tr v-for="(friend, index) in listFriend" :key="index">
<td>
<button type="button"
class="btn btn-light btn-block btn-friend-in-list"
@click="chooseFriend(friend)">
<img src="../../assets/icon_user.png"
alt="icon-room"
class="icon-friend-in-list"/>
<span>{{ friend.user_name }}</span>
<span>{{ friend.username }}</span>
</button>
</td>
</tr>
Expand All @@ -20,122 +20,47 @@
</template>

<script>
import api from '../../api/service.api';
export default {
name: "ListFriend",
props: ["message"],
data: function () {
return {
users: [],
errors: [],
listFriend: [
{
id: 1,
user_name: "name 1",
user_icon: ""
},
{
id: 2,
user_name: "name 2",
user_icon: ""
},
{
id: 3,
user_name: "name 3",
user_icon: ""
},
{
id: 4,
user_name: "name 4",
user_icon: ""
},
{
id: 5,
user_name: "name 5",
user_icon: ""
},
{
id: 6,
user_name: "name 6",
user_icon: ""
},
{
id: 7,
user_name: "name 7",
user_icon: ""
},
{
id: 8,
user_name: "name 8",
user_icon: ""
},
{
id: 9,
user_name: "name 9",
user_icon: ""
},
{
id: 10,
user_name: "name 10",
user_icon: ""
},
{
id: 11,
user_name: "name 11",
user_icon: ""
},
{
id: 12,
user_name: "name 12",
user_icon: ""
},
{
id: 13,
user_name: "name 13",
user_icon: ""
},
{
id: 14,
user_name: "name 14",
user_icon: ""
},
{
id: 15,
user_name: "name 15",
user_icon: ""
},
{
id: 16,
user_name: "name 16",
user_icon: ""
},
{
id: 17,
user_name: "name 17",
user_icon: ""
},
{
id: 18,
user_name: "name 18",
user_icon: ""
},
{
id: 19,
user_name: "name 19",
user_icon: ""
},
{
id: 20,
user_name: "name 20",
user_icon: ""
}
]
listFriend: []
};
},
computed: {},
computed: {
},
mounted(){
this.getListFriend();
},
methods: {
chooseFriend(friend) {
let roomConservation = friend.id;
this.$emit("chooseFriend", roomConservation);
//call API to get content

this.$emit("chooseFriend", {
type: 1,
conversation: {
icon: friend.social.image,
name: friend.username,
content: []
}
});
},
async getListFriend(currentUser){
return await api
.getAllUsers(currentUser)
.then(async res => {
if( res.status === 200 ){
this.listFriend = res.data.users;
}
})
.catch(error =>{
console.log(error);
console.log('GET listFriend Fail!');
});
}
}
};
Expand Down
Loading