add timebomb to mobile view

This commit is contained in:
tiago.kayaya
2021-10-28 15:40:41 +01:00
parent 2b442e76db
commit bccb4ed0d5
12 changed files with 151 additions and 169 deletions
@@ -11,7 +11,7 @@
<div class="div-title">
<ion-label class="title">Contactos</ion-label>
</div>
<app-btn-seguinte (click)="createGroup()"></app-btn-seguinte>
<app-btn-seguinte (click)="updateGroup()"></app-btn-seguinte>
</div>
</div>
</ion-toolbar>
@@ -59,42 +59,6 @@ export class GroupContactsPage implements OnInit {
console.log(this.isGroupCreated);
}
deleteMember(data:any){
let body = {
"roomId": this.room._id,
"userId": data._id,
}
console.log(body);
if(this.room.t == "p"){
this.chatService.removeGroupMember(body).subscribe(res=>{
console.log(res);
this.getMembers();
});
}
else if(this.room.t == "c"){
this.chatService.removeChannelMember(body).subscribe(res=>{
console.log(res);
this.getMembers();
});
}
}
getMembers(){
if(this.room.t == "p"){
this.chatService.getGroupMembers(this.room._id).subscribe(res=>{
this.members = res['members'];
this.loadUsers();
});
}
else if(this.room.t == "c"){
this.chatService.getChannelMembers(this.room._id).subscribe(res=>{
this.members = res['members'];
this.loadUsers();
});
}
}
loadUsers(){
this.options = {
headers: this.headers,
@@ -121,6 +85,21 @@ export class GroupContactsPage implements OnInit {
});
}
getMembers(){
if(this.room.t == "p"){
this.chatService.getGroupMembers(this.room._id).subscribe(res=>{
this.members = res['members'];
this.loadUsers();
});
}
else if(this.room.t == "c"){
this.chatService.getChannelMembers(this.room._id).subscribe(res=>{
this.members = res['members'];
this.loadUsers();
});
}
}
separateLetter(record, recordIndex, records){
if(recordIndex == 0){
return record.name[0];
@@ -135,6 +114,27 @@ export class GroupContactsPage implements OnInit {
return null;
}
deleteMember(data:any){
let body = {
"roomId": this.room._id,
"userId": data._id,
}
console.log(body);
if(this.room.t == "p"){
this.chatService.removeGroupMember(body).subscribe(res=>{
console.log(res);
this.getMembers();
});
}
else if(this.room.t == "c"){
this.chatService.removeChannelMember(body).subscribe(res=>{
console.log(res);
this.getMembers();
});
}
}
doRefresh(ev){
this.loadUsers();
this.getMembers();
@@ -143,26 +143,8 @@ export class GroupContactsPage implements OnInit {
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;
}
@@ -194,50 +176,21 @@ export class GroupContactsPage implements OnInit {
});
}
createGroup(){
if(!this.isGroupCreated){
/* this.close(); */
let body = { "name":this.groupName, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
this.addContacts(res['group']);
this.openGroupMessages(res['group']);
});
}
else{
updateGroup(){
this.chatService.getRoomInfo(this.room._id).subscribe(room=>{
this.room = room['room'];
this.addContacts(this.room);
this.close();
/* this.openGroupMessages(this.room); */
/* this.chatService.getGroupInfo(this.room._id).subscribe(res=>{
console.log(res);
this.addContacts(res['group']);
this.openGroupMessages(res['group']);
}) */
}
}
async newGroup(){
this.close();
const modal = await this.modalController.create({
component: NewGroupPage,
cssClass: 'new-group',
backdropDismiss: false,
this.openGroupMessages(room['room']._id);
});
await modal.present();
modal.onDidDismiss();
}
async openGroupMessages(room:any){
async openGroupMessages(roomId:any){
this.close();
console.log(roomId);
const modal = await this.modalController.create({
component: GroupMessagesPage,
componentProps: {
room: room,
roomId: roomId,
},
cssClass: 'group-messages',
backdropDismiss: false
@@ -35,6 +35,10 @@
</ion-label>
</div>
</div>
<div *ngIf="room.customFields.countDownDate" class="d-flex align-items-center yellow-orange pl-10">
<i class="far fa-clock font-15"></i>
<ion-label class="font-15 pl-10" color="warning">{{countDownDate(room.customFields.countDownDate, room._id)}}</ion-label>
</div>
</div>
</ion-toolbar>
</ion-header>
@@ -254,33 +254,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
showDateDuration(start:any){
return this.timeService.showDateDuration(start);
/* let end;
end = new Date();
start = new Date(start);
let customizedDate;
const totalSeconds = Math.floor((end - (start))/1000);;
const totalMinutes = Math.floor(totalSeconds/60);
const totalHours = Math.floor(totalMinutes/60);
const totalDays = Math.floor(totalHours/24);
const hours = totalHours - ( totalDays * 24 );
const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
if(totalDays == 0){
if(start.getDate() == new Date().getDate()){
let time = start.getHours() + ":" + this.addZero(start.getUTCMinutes());
return time;
}
else{
return 'Ontem';
}
}
else{
let date = start.getDate() + "/" + (start.getMonth()+1) + "/" + start.getFullYear();
return date;
} */
}
countDownDate(date:any, roomId:string){
return this.timeService.countDownDate(date, roomId);
}
addZero(i) {