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
+3 -3
View File
@@ -379,7 +379,7 @@ hideRefreshButton(){
async getDirectMessages(event?){ async getDirectMessages(event?){
this.chatService.getAllDirectMessages().subscribe(async (res:any)=>{ this.chatService.getAllDirectMessages().subscribe(async (res:any)=>{
console.log(res.ims); //console.log(res.ims);
if(res != 200){ if(res != 200){
//console.log(res.ims); //console.log(res.ims);
@@ -433,7 +433,7 @@ hideRefreshButton(){
async getGroups(event?){ async getGroups(event?){
this.result = this.chatService.getAllPrivateGroups().subscribe(async (res:any)=>{ this.result = this.chatService.getAllPrivateGroups().subscribe(async (res:any)=>{
console.log(res); //console.log(res);
if(res.groups != 200){ if(res.groups != 200){
this.privateGroups = res.groups; this.privateGroups = res.groups;
@@ -445,7 +445,7 @@ hideRefreshButton(){
var dateB = new Date(b._updatedAt).getTime(); var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA; return dateB - dateA;
}); });
console.log(this.allGroups); //console.log(this.allGroups);
/* }); */ /* }); */
if(this.route.url != "/home/chat"){ if(this.route.url != "/home/chat"){
console.log("Timer message stop") console.log("Timer message stop")
@@ -11,7 +11,7 @@
<div class="div-title"> <div class="div-title">
<ion-label class="title">Contactos</ion-label> <ion-label class="title">Contactos</ion-label>
</div> </div>
<app-btn-seguinte (click)="createGroup()"></app-btn-seguinte> <app-btn-seguinte (click)="updateGroup()"></app-btn-seguinte>
</div> </div>
</div> </div>
</ion-toolbar> </ion-toolbar>
@@ -59,42 +59,6 @@ export class GroupContactsPage implements OnInit {
console.log(this.isGroupCreated); 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(){ loadUsers(){
this.options = { this.options = {
headers: this.headers, 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){ separateLetter(record, recordIndex, records){
if(recordIndex == 0){ if(recordIndex == 0){
return record.name[0]; return record.name[0];
@@ -135,6 +114,27 @@ export class GroupContactsPage implements OnInit {
return null; 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){ doRefresh(ev){
this.loadUsers(); this.loadUsers();
this.getMembers(); this.getMembers();
@@ -143,26 +143,8 @@ export class GroupContactsPage implements OnInit {
async close(){ async close(){
this.modalController.dismiss(); 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){ onChange(event){
this.textSearch = event.detail.value; this.textSearch = event.detail.value;
} }
@@ -194,50 +176,21 @@ export class GroupContactsPage implements OnInit {
}); });
} }
createGroup(){ updateGroup(){
if(!this.isGroupCreated){ this.chatService.getRoomInfo(this.room._id).subscribe(room=>{
/* this.close(); */ this.room = room['room'];
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{
this.addContacts(this.room); this.addContacts(this.room);
this.close(); this.openGroupMessages(room['room']._id);
/* 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,
}); });
await modal.present();
modal.onDidDismiss();
} }
async openGroupMessages(room:any){ async openGroupMessages(roomId:any){
this.close(); this.close();
console.log(roomId);
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: GroupMessagesPage, component: GroupMessagesPage,
componentProps: { componentProps: {
room: room, roomId: roomId,
}, },
cssClass: 'group-messages', cssClass: 'group-messages',
backdropDismiss: false backdropDismiss: false
@@ -35,6 +35,10 @@
</ion-label> </ion-label>
</div> </div>
</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> </div>
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
@@ -254,33 +254,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
showDateDuration(start:any){ showDateDuration(start:any){
return this.timeService.showDateDuration(start); 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{ countDownDate(date:any, roomId:string){
return 'Ontem'; return this.timeService.countDownDate(date, roomId);
}
}
else{
let date = start.getDate() + "/" + (start.getMonth()+1) + "/" + start.getFullYear();
return date;
} */
} }
addZero(i) { addZero(i) {
@@ -11,7 +11,11 @@
<div class="middle"> <div class="middle">
<ion-label class="title">Novo Grupo</ion-label> <ion-label class="title">Novo Grupo</ion-label>
</div> </div>
<app-btn-seguinte *ngIf="groupName" (click)="addContacts()"></app-btn-seguinte> <div *ngIf="groupName">
<button class="btn-no-color btn-criar" (click)="createGroup()">
<ion-label>Criar grupo</ion-label>
</button>
</div>
</div> </div>
</div> </div>
</ion-toolbar> </ion-toolbar>
@@ -22,7 +26,7 @@
<div class="item-container"> <div class="item-container">
<ion-input [(ngModel)]="groupName" placeholder="Título"></ion-input> <ion-input [(ngModel)]="groupName" placeholder="Título"></ion-input>
</div> </div>
<div *ngIf="false" class="item-container-no-border"> <div class="item-container-no-border">
<ion-checkbox (ionChange)="_ionChange($event)" color="primary"></ion-checkbox> <ion-checkbox (ionChange)="_ionChange($event)" color="primary"></ion-checkbox>
<ion-label>Grupo Ultra-secreto</ion-label> <ion-label>Grupo Ultra-secreto</ion-label>
</div> </div>
@@ -64,6 +64,13 @@ ion-content{
width: 221px; width: 221px;
margin: 2.5px 0 0 5px; margin: 2.5px 0 0 5px;
} }
.btn-criar{
padding: 0!important;
float: right;
font-size: 15px;
color: var(--font-awesome);
margin: 8px 5px 0 5px;
}
.right{ .right{
padding: 0!important; padding: 0!important;
float: right; float: right;
+41 -5
View File
@@ -4,6 +4,7 @@ import { ModalController, NavParams, PickerController, PopoverController } from
import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page'; import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page';
import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page'; import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page';
import { ThemeService } from 'src/app/services/theme.service' import { ThemeService } from 'src/app/services/theme.service'
import { ChatService } from 'src/app/services/chat.service';
@Component({ @Component({
selector: 'app-new-group', selector: 'app-new-group',
@@ -16,6 +17,7 @@ export class NewGroupPage implements OnInit {
displayDuration: any; displayDuration: any;
showDuration: boolean; showDuration: boolean;
selectedDuration = ['','','']; selectedDuration = ['','',''];
thedate:any;
groupName:string; groupName:string;
constructor( constructor(
@@ -23,7 +25,8 @@ export class NewGroupPage implements OnInit {
private popoverController: PopoverController, private popoverController: PopoverController,
private modalController: ModalController, private modalController: ModalController,
private navParams: NavParams, private navParams: NavParams,
public ThemeService: ThemeService public ThemeService: ThemeService,
private chatService: ChatService,
) )
{ {
this.isGroupCreated = false; this.isGroupCreated = false;
@@ -35,12 +38,44 @@ export class NewGroupPage implements OnInit {
} }
_ionChange(event){ _ionChange(event){
this.showDuration = event.detail.checked; this.showDuration = event.detail.checked;
if(event.detail.checked){
this.thedate = new Date();
}
else{
this.thedate = '';
}
} }
close(){ close(){
this.modalController.dismiss(); this.modalController.dismiss();
} }
async addContacts(){ createGroup(){
let name = this.groupName.split(' ').join('-');
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
//this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = {
"roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate}
}
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res);
});
}
this.isGroupCreated = true;
this.addContacts(res['group']);
});
}
async addContacts(room){
this.close(); this.close();
let name = this.groupName.split(' ').join('-'); let name = this.groupName.split(' ').join('-');
@@ -49,9 +84,7 @@ export class NewGroupPage implements OnInit {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: GroupContactsPage, component: GroupContactsPage,
componentProps: { componentProps: {
isCreated:this.isGroupCreated, room: room,
name: name,
duration:'',
}, },
cssClass: 'contacts', cssClass: 'contacts',
backdropDismiss: false backdropDismiss: false
@@ -83,6 +116,9 @@ export class NewGroupPage implements OnInit {
cssClass: 'btn-cancel', cssClass: 'btn-cancel',
handler:(value:any)=>{ handler:(value:any)=>{
console.log('button done pressed'); console.log('button done pressed');
let now = new Date();
this.thedate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + value.days.value, now.getHours() + value.hours.value, now.getMinutes() + value.minutes.value, now.getSeconds(), now.getMilliseconds());
this.selectedDuration = [ this.selectedDuration = [
value.days.value, value.days.value,
value.hours.value, value.hours.value,
@@ -43,7 +43,6 @@ export class TimeService {
countDownDate(date:any, roomId:string){ countDownDate(date:any, roomId:string){
/* let timer = setInterval(() =>{ */ /* let timer = setInterval(() =>{ */
console.log('Show TIMER');
let difference = new Date(date).getTime() - new Date().getTime(); let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24)); let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60)); let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
@@ -21,12 +21,12 @@
<ion-input [(ngModel)]="groupName" placeholder="Título"></ion-input> <ion-input [(ngModel)]="groupName" placeholder="Título"></ion-input>
</div> </div>
<div *ngIf="true" class="item-container-no-border"> <div class="item-container-no-border">
<ion-checkbox (ionChange)="_ionChange($event)" color="primary"></ion-checkbox> <ion-checkbox (ionChange)="_ionChange($event)" color="primary"></ion-checkbox>
<ion-label>Grupo Ultra-secreto</ion-label> <ion-label>Grupo Ultra-secreto</ion-label>
</div> </div>
<!-- *ngIf="showDuration" -->
<div class="container-div"> <div *ngIf="showDuration" class="container-div">
<div class="ion-item-class-2"> <div class="ion-item-class-2">
<div class="ion-icon-class"> <div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-duration.svg"></ion-icon> <ion-icon slot="start" src="assets/images/icons-duration.svg"></ion-icon>
@@ -36,11 +36,5 @@
</div> </div>
</div> </div>
</div> </div>
<ion-label>{{displayDuration}}</ion-label>
<br />
<ion-label>{{thedate}}</ion-label>
<br />
<ion-label>{{countDownTime}}</ion-label>
</div> </div>
</ion-content> </ion-content>
@@ -42,12 +42,16 @@ export class NewGroupPage implements OnInit {
_ionChange(event){ _ionChange(event){
console.log(event); console.log(event);
console.log(event.detail.checked); console.log(event.detail.checked);
this.showDuration = event.detail.checked; this.showDuration = event.detail.checked;
//this.thedate = new Date(2021, 10, 1, 10, 33, 30, 0);
this.thedate = new Date();
if(event.detail.checked){
this.thedate = new Date();
} }
else{
this.thedate = '';
}
}
close(){ close(){
//this.modalController.dismiss(); //this.modalController.dismiss();
console.log('close'); console.log('close');
@@ -63,6 +67,7 @@ export class NewGroupPage implements OnInit {
this.addGroupMessage.emit(res['group']._id); this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = { let countDownBody = {
"roomId": res['group']._id, "roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate} "customFields":{"countDownDate":this.thedate}
@@ -70,6 +75,7 @@ export class NewGroupPage implements OnInit {
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{ this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res); console.log(res);
}); });
}
}); });
} }
+3
View File
@@ -627,6 +627,9 @@ body {
--indicator-color: transparent !important; --indicator-color: transparent !important;
--indicator-color-checked: transparent !important; --indicator-color-checked: transparent !important;
} }
.yellow-orange{
color: #ffb703 !important;
}
.tribunal { .tribunal {
--ion-color-primary: #000; --ion-color-primary: #000;