mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
-implement create chat group
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<div class="div-title">
|
||||
<ion-label class="title">Contactos</ion-label>
|
||||
</div>
|
||||
<app-btn-seguinte (click)="groupMessages()"></app-btn-seguinte>
|
||||
<app-btn-seguinte *ngIf="groupName" (click)="createGroup()"></app-btn-seguinte>
|
||||
</div>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
|
||||
<div *virtualItem="let user" class="item-checkbox">
|
||||
<ion-checkbox color="primary"></ion-checkbox>
|
||||
<ion-checkbox (ionChange)="selectedContact(user)" color="primary"></ion-checkbox>
|
||||
<p>{{user.name}}</p>
|
||||
<ion-icon name="ellipse"></ion-icon>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { ModalController, NavParams } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { NewGroupPage } from '../../new-group/new-group.page';
|
||||
import { GroupMessagesPage } from '../group-messages.page';
|
||||
|
||||
@Component({
|
||||
@@ -24,12 +25,15 @@ export class GroupContactsPage implements OnInit {
|
||||
textSearch:string;
|
||||
room:any;
|
||||
dm:any;
|
||||
isGroupCreated:boolean;
|
||||
groupName:string;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private http: HttpClient,
|
||||
private chatService: ChatService,
|
||||
private authService: AuthService,
|
||||
private navParams: NavParams,
|
||||
)
|
||||
{
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
@@ -37,12 +41,16 @@ export class GroupContactsPage implements OnInit {
|
||||
});
|
||||
this.textSearch="";
|
||||
this.dm=null;
|
||||
this.room=null;
|
||||
this.room=null;
|
||||
this.isGroupCreated = this.navParams.get('isCreated');
|
||||
this.groupName = this.navParams.get('name');
|
||||
this.room = this.navParams.get('room');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.loadUsers();
|
||||
|
||||
console.log(this.groupName);
|
||||
console.log(this.isGroupCreated);
|
||||
}
|
||||
|
||||
loadUsers(){
|
||||
@@ -82,8 +90,28 @@ export class GroupContactsPage implements OnInit {
|
||||
doRefresh(event){
|
||||
|
||||
}
|
||||
close(){
|
||||
this.modalController.dismiss(true);
|
||||
|
||||
async close(){
|
||||
this.modalController.dismiss();
|
||||
if(this.isGroupCreated){
|
||||
console.log('go to conversa');
|
||||
}
|
||||
else{
|
||||
this.modalController.dismiss();
|
||||
console.log('go to new group page');
|
||||
const modal = await this.modalController.create({
|
||||
component: NewGroupPage,
|
||||
componentProps: {
|
||||
name:this.groupName,
|
||||
duration:'',
|
||||
},
|
||||
cssClass: 'new-group',
|
||||
backdropDismiss: false,
|
||||
});
|
||||
await modal.present();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
onChange(event){
|
||||
this.textSearch = event.detail.value;
|
||||
@@ -92,22 +120,50 @@ export class GroupContactsPage implements OnInit {
|
||||
console.log('clicked');
|
||||
|
||||
}
|
||||
async groupMessages(){
|
||||
selectedContact(user:any){
|
||||
this.groupName = this.room.name;
|
||||
console.log(user);
|
||||
|
||||
}
|
||||
createGroup(){
|
||||
if(!this.isGroupCreated){
|
||||
let body = { "name":this.groupName, }
|
||||
this.chatService.addGroup(body).subscribe(res=>{
|
||||
console.log(res['group']);
|
||||
this.openGroupMessages(res['group']);
|
||||
});
|
||||
}
|
||||
else{
|
||||
this.openGroupMessages(this.room);
|
||||
}
|
||||
}
|
||||
async newGroup(){
|
||||
this.close();
|
||||
const modal = await this.modalController.create({
|
||||
component: NewGroupPage,
|
||||
cssClass: 'new-group',
|
||||
backdropDismiss: false,
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
async openGroupMessages(room:any){
|
||||
console.log(room);
|
||||
this.createGroup();
|
||||
this.isGroupCreated=true;
|
||||
this.close();
|
||||
const modal = await this.modalController.create({
|
||||
component: GroupMessagesPage,
|
||||
componentProps: {},
|
||||
cssClass: 'contacts',
|
||||
componentProps: {
|
||||
room: room,
|
||||
},
|
||||
cssClass: 'group-messages',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(res=>{
|
||||
if(res.data){
|
||||
console.log('go to new group');
|
||||
|
||||
}
|
||||
});
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo
|
||||
import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popover.page';
|
||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||
import { NewGroupPage } from '../new-group/new-group.page';
|
||||
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
@@ -13,9 +14,12 @@ import { NewGroupPage } from '../new-group/new-group.page';
|
||||
styleUrls: ['./group-messages.page.scss'],
|
||||
})
|
||||
export class GroupMessagesPage implements OnInit {
|
||||
isGroupCreated:boolean;
|
||||
loggedUser: any;
|
||||
message:any;
|
||||
messages:any;
|
||||
|
||||
|
||||
room:any;
|
||||
members:any;
|
||||
contacts: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
|
||||
@@ -28,7 +32,8 @@ export class GroupMessagesPage implements OnInit {
|
||||
private chatService: ChatService,
|
||||
private navParams: NavParams,
|
||||
private authService: AuthService,
|
||||
) {
|
||||
) {
|
||||
this.isGroupCreated = true;
|
||||
this.room = this.navParams.get('room');
|
||||
}
|
||||
|
||||
@@ -144,8 +149,11 @@ export class GroupMessagesPage implements OnInit {
|
||||
}
|
||||
async addContacts(){
|
||||
const modal = await this.modalController.create({
|
||||
component: ContactsPage,
|
||||
componentProps: {},
|
||||
component: GroupContactsPage,
|
||||
componentProps: {
|
||||
isCreated: this.isGroupCreated,
|
||||
room: this.room,
|
||||
},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<ion-content>
|
||||
<div class="main-content">
|
||||
<div class="item-container">
|
||||
<ion-input placeholder="Título"></ion-input>
|
||||
<ion-input [(ngModel)]="groupName" placeholder="Título"></ion-input>
|
||||
</div>
|
||||
<div class="item-container-no-border">
|
||||
<ion-checkbox (ionChange)="_ionChange($event)" color="primary"></ion-checkbox>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { analyzeAndValidateNgModules } from '@angular/compiler';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ModalController, PickerController, PopoverController } from '@ionic/angular';
|
||||
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
|
||||
import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page';
|
||||
import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page';
|
||||
|
||||
@@ -10,17 +10,22 @@ import { GroupContactsPage } from '../group-messages/group-contacts/group-contac
|
||||
styleUrls: ['./new-group.page.scss'],
|
||||
})
|
||||
export class NewGroupPage implements OnInit {
|
||||
isGroupCreated:boolean;
|
||||
showLoader: boolean;
|
||||
displayDuration: any;
|
||||
showDuration: boolean;
|
||||
selectedDuration = ['','',''];
|
||||
groupName:string;
|
||||
|
||||
constructor(
|
||||
private pickerController: PickerController,
|
||||
private popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
) {
|
||||
|
||||
private modalController: ModalController,
|
||||
private navParams: NavParams,
|
||||
)
|
||||
{
|
||||
this.isGroupCreated = false;
|
||||
this.groupName = this.navParams.get('name');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -34,16 +39,20 @@ export class NewGroupPage implements OnInit {
|
||||
}
|
||||
|
||||
async addContacts(){
|
||||
this.close();
|
||||
this.modalController.dismiss();
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: GroupContactsPage,
|
||||
componentProps: {},
|
||||
componentProps: {
|
||||
isCreated:this.isGroupCreated,
|
||||
name:this.groupName,
|
||||
duration:'',
|
||||
},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
await modal.present();
|
||||
|
||||
modal.onDidDismiss();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,11 @@ export class AttendeeModalPage implements OnInit {
|
||||
}
|
||||
|
||||
save(){
|
||||
this.modalCtrl.dismiss(this.contacts.filter(function(contact) {
|
||||
this.modalCtrl.dismiss(
|
||||
this.contacts.filter(function(contact) {
|
||||
return contact.IsRequired == true;
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
close(){
|
||||
|
||||
Reference in New Issue
Block a user