mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save
This commit is contained in:
@@ -4,8 +4,8 @@ import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { ConversationPage } from './conversation/conversation.page';
|
||||
import { GroupMessagesPage } from './group-messages/group-messages.page';
|
||||
import { MessagesPage } from './messages/messages.page';
|
||||
import { ContactsPage } from './messages/contacts/contacts.page';
|
||||
import { MessagesPage } from './messages/messages.page';
|
||||
import { NewGroupPage } from './new-group/new-group.page';
|
||||
import { NewchatPage } from './newchat/newchat.page';
|
||||
|
||||
@@ -39,22 +39,24 @@ export class ChatPage implements OnInit {
|
||||
this.doRefresh();
|
||||
}
|
||||
doRefresh(){
|
||||
this.getGroups();
|
||||
/* this.getGroups(); */
|
||||
this.getConnectedUsers();
|
||||
}
|
||||
getGroups(){
|
||||
/* getGroups(){
|
||||
this.showLoader = true;
|
||||
this.result = this.chatService.getAllPrivateGroups().subscribe((res:any)=>{
|
||||
this.groupList = res.groups;
|
||||
this.showLoader = false;
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
getConnectedUsers(){
|
||||
this.showLoader = true;
|
||||
|
||||
this.result = this.chatService.getAllConnectedUsers().subscribe((res:any)=>{
|
||||
this.userConnectedList = res.users;
|
||||
console.log(this.userConnectedList);
|
||||
/* this.userConnectedList = res.users; */
|
||||
/* console.log(res); */
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export class LoginPage implements OnInit {
|
||||
userattempt: User;
|
||||
|
||||
public body = {"user": this.username,"password": this.password};
|
||||
public postData = {"user": "admin","password": this.password};
|
||||
public postData = {"user": this.username,"password": this.password};
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
|
||||
@@ -14,6 +14,8 @@ import { Storage } from '@ionic/storage';
|
||||
export class ChatService {
|
||||
headers: HttpHeaders;
|
||||
options:any;
|
||||
X_User_Id:any;
|
||||
X_Auth_Token:any;
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -27,12 +29,20 @@ export class ChatService {
|
||||
this.storage.get('user').then((val) => {
|
||||
console.log(JSON.parse(unescape(atob(val))).data.userId);
|
||||
let user = JSON.parse(unescape(atob(val))).data;
|
||||
|
||||
this.headers = this.headers.set('Access-Control-Allow-Origin', 'http://localhost:8100');
|
||||
this.headers = this.headers.set('Access-Control-Allow-Credentials', 'true');
|
||||
this.headers = this.headers.set('Access-Control-Allow-Headers', 'Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Headers, x-requested-with, Content-Type, X-Auth-Token, X-User-Id, origin, authorization, accept, client-security-token');
|
||||
this.headers = this.headers.set('X-User-Id', user.userId);
|
||||
console.log(user.userId);
|
||||
this.X_User_Id = user.userId;
|
||||
this.headers = this.headers.set('X-Auth-Token', user.authToken);
|
||||
console.log(user.authToken);
|
||||
this.X_Auth_Token = user.authToken;
|
||||
this.options = {
|
||||
headers: {
|
||||
'X-User-Id': this.X_User_Id,
|
||||
'X-Auth-Token': this.X_Auth_Token
|
||||
},
|
||||
};
|
||||
this.getAllConnectedUsers(this.options);
|
||||
|
||||
});
|
||||
|
||||
/* this.authService.userData$.subscribe((res:any)=>{
|
||||
@@ -40,18 +50,23 @@ export class ChatService {
|
||||
this.headers = this.headers.set('X-Auth-Token', res.authToken);
|
||||
}); */
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
headers: {
|
||||
'X-User-Id': this.X_User_Id,
|
||||
'X-Auth-Token': this.X_Auth_Token
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
getAllUsers(){
|
||||
console.log(this.headers);
|
||||
return this.http.get(environment.apiChatUrl+'users.list', this.options);
|
||||
/* return this.http.get(environment.apiChatUrl+'users.list', this.options); */
|
||||
}
|
||||
getAllConnectedUsers(){
|
||||
return this.http.get(environment.apiChatUrl+'users.presence', this.options);
|
||||
getAllConnectedUsers(opts){
|
||||
console.log(opts);
|
||||
|
||||
return this.http.get(environment.apiChatUrl+'users.presence', opts);
|
||||
}
|
||||
getAllPrivateGroups(){
|
||||
return this.http.get(environment.apiChatUrl+'groups.list', this.options);
|
||||
/* return this.http.get(environment.apiChatUrl+'groups.list', this.options); */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user