This commit is contained in:
Tiago Kayaya
2020-11-03 11:52:21 +01:00
parent 21eb3d3cf1
commit 6f753b6a75
3 changed files with 43 additions and 17 deletions
+4 -4
View File
@@ -21,10 +21,10 @@
<ion-list *ngSwitchCase="'Contactos'" > <ion-list *ngSwitchCase="'Contactos'" >
<ion-item-group> <ion-item-group>
<ion-item-sliding> <ion-item-sliding>
<ion-item> <ion-item *ngFor="let user of userConnectedList" (click)="starConversation(user)">
<ion-icon slot="start" src="assets/images/icons-chat-chat-40.svg" class="iconschatchat-40"></ion-icon> <ion-icon slot="start" src="assets/images/icons-chat-chat-40.svg" class="iconschatchat-40"></ion-icon>
<div> <div>
<h3>Secretario Assuntos Sociais</h3> <h3>{{user.name}}</h3>
<p>Podemos marcar reunião para amanha</p> <p>Podemos marcar reunião para amanha</p>
</div> </div>
</ion-item> </ion-item>
@@ -34,10 +34,10 @@
<ion-list *ngSwitchCase="'Grupos'" > <ion-list *ngSwitchCase="'Grupos'" >
<ion-item-group> <ion-item-group>
<ion-item-sliding> <ion-item-sliding>
<ion-item> <ion-item *ngFor="let group of groupList">
<ion-icon slot="start" src="assets/images/icons-chat-group-chat-40.svg" class="iconschatgroup-chat-40"></ion-icon> <ion-icon slot="start" src="assets/images/icons-chat-group-chat-40.svg" class="iconschatgroup-chat-40"></ion-icon>
<div> <div>
<h3>Viagem a Maputo</h3> <h3>{{group.name}}</h3>
<p>Grande momento.</p> <p>Grande momento.</p>
</div> </div>
</ion-item> </ion-item>
+30 -6
View File
@@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service'; import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { ConversationPage } from './conversation/conversation.page';
@Component({ @Component({
selector: 'app-chat', selector: 'app-chat',
@@ -12,10 +14,12 @@ export class ChatPage implements OnInit {
/* Set segment variable */ /* Set segment variable */
segment:string; segment:string;
groupList: any[]; groupList: any[];
userConnectedList: any[];
result:any; result:any;
constructor( constructor(
private chatService: ChatService, private chatService: ChatService,
private modalController: ModalController,
private authService: AuthService) { } private authService: AuthService) { }
ngOnInit() { ngOnInit() {
@@ -23,17 +27,37 @@ export class ChatPage implements OnInit {
this.authService.userData$.subscribe((res:any)=>{ this.authService.userData$.subscribe((res:any)=>{
this.loggedUser=res; this.loggedUser=res;
}); });
/* this.getGroups(); */ this.getGroups();
this.getConnectedUsers();
} }
onSegmentChange(){ onSegmentChange(){
this.RefreshEvents(); this.RefreshEvents();
} }
RefreshEvents(){} RefreshEvents(){}
/* getGroups(){ getGroups(){
this.result = this.chatService.getPrivateGroups().subscribe((res:any)=>{ this.result = this.chatService.getAllPrivateGroups().subscribe((res:any)=>{
this.groupList = res.users; this.groupList = res.groups;
console.log(this.groupList); /* console.log(this.groupList); */
}); });
} */ }
getConnectedUsers(){
this.result = this.chatService.getAllConnectedUsers().subscribe((res:any)=>{
this.userConnectedList = res.users;
console.log(this.userConnectedList);
});
}
async starConversation(selectedUser) {
const modal = await this.modalController.create({
component: ConversationPage,
cssClass: 'conversation',
backdropDismiss: false,
componentProps: {
user: selectedUser,
}
});
await modal.present();
modal.onDidDismiss();
}
} }
+8 -6
View File
@@ -25,17 +25,19 @@ export class ChatService {
this.headers = this.headers.set('X-User-Id', res.userId); this.headers = this.headers.set('X-User-Id', res.userId);
this.headers = this.headers.set('X-Auth-Token', res.authToken); this.headers = this.headers.set('X-Auth-Token', res.authToken);
}); });
}
getAllUsers(){
this.options = { this.options = {
headers: this.headers, headers: this.headers,
}; };
console.log(this.headers); }
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);
} }
getPrivateGroups(){ getAllConnectedUsers(){
this.http.get(environment.apiChatUrl+'groups.list', this.options); return this.http.get(environment.apiChatUrl+'users.presence', this.options);
}
getAllPrivateGroups(){
return this.http.get(environment.apiChatUrl+'groups.list', this.options);
} }
} }