add timebomb feature

This commit is contained in:
tiago.kayaya
2021-10-27 08:45:37 +01:00
parent 5c942e6e9b
commit ae9bc339c9
12 changed files with 153 additions and 27 deletions
+1 -1
View File
@@ -47,7 +47,7 @@
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" /> <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
</platform> </platform>
<mfp:android> <mfp:android>
<mfp:sdkChecksum>3077110622</mfp:sdkChecksum> <mfp:sdkChecksum>1109370933</mfp:sdkChecksum>
<mfp:appChecksum>3619450036</mfp:appChecksum> <mfp:appChecksum>3619450036</mfp:appChecksum>
<mfp:security> <mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" /> <mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
+2 -1
View File
@@ -96,7 +96,8 @@
<div class="item-title" [class.item-title-active]="group._id ==idSelected"> <div class="item-title" [class.item-title-active]="group._id ==idSelected">
<ion-label>{{group.name.split('-').join(' ')}}</ion-label> <ion-label>{{group.name.split('-').join(' ')}}</ion-label>
</div> </div>
<div class="item-date" [class.item-date-active]="group._id ==idSelected" *ngIf="group.lastMessage">{{showDateDuration(group._updatedAt)}}</div> <div class="item-date" [class.item-date-active]="group._id ==idSelected" *ngIf="group.lastMessage && !group.customFields.countDownDate">{{showDateDuration(group._updatedAt)}}</div>
<div class="item-date" *ngIf="group.customFields.countDownDate">{{countDownDate(group.customFields.countDownDate, group._id)}}</div>
</div> </div>
<div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group._id ==idSelected"> <div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group._id ==idSelected">
<div class="item-message">{{group.lastMessage.u.name}}: {{group.lastMessage.msg}} </div> <div class="item-message">{{group.lastMessage.u.name}}: {{group.lastMessage.msg}} </div>
+2 -2
View File
@@ -98,7 +98,7 @@ ion-content{
margin-top: 10px; margin-top: 10px;
} }
.item-title{ .item-title{
width: calc(100% - 75px); width: calc(100% - 80px);
float: left; float: left;
font-size: 15px; font-size: 15px;
color: #0d89d1; color: #0d89d1;
@@ -107,7 +107,7 @@ ion-content{
color: #fff; color: #fff;
} }
.item-date{ .item-date{
width: 75px; width: 80px;
float: right; float: right;
font-size: 13px; font-size: 13px;
color: #797979; color: #797979;
+6 -2
View File
@@ -420,6 +420,10 @@ hideRefreshButton(){
return this.timeService.showDateDuration(start); return this.timeService.showDateDuration(start);
} }
countDownDate(date:any, roomId:string){
return this.timeService.countDownDate(date, roomId);
}
async getChatMembers(){ async getChatMembers(){
//return await this.chatService.getMembers(roomId).toPromise(); //return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res=> { this.chatService.getAllUsers().subscribe(res=> {
@@ -432,7 +436,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);
if(res.groups != 200){ if(res.groups != 200){
this.privateGroups = res.groups; this.privateGroups = res.groups;
@@ -444,7 +448,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")
+7
View File
@@ -209,8 +209,12 @@ export class ChatService {
/* GROUPS */ /* GROUPS */
addGroup(body:any){ addGroup(body:any){
console.log(body);
return this.http.post(environment.apiChatUrl+'groups.create', body, this.options); return this.http.post(environment.apiChatUrl+'groups.create', body, this.options);
} }
setGroupCustomFields(body:any){
return this.http.post(environment.apiChatUrl+'groups.setCustomFields', body, this.options);
}
getGroupMembers(roomId:string){ getGroupMembers(roomId:string){
let params = new HttpParams(); let params = new HttpParams();
@@ -223,6 +227,7 @@ export class ChatService {
} }
return this.http.get(url, opts); return this.http.get(url, opts);
} }
getChannelMembers(roomId:string){ getChannelMembers(roomId:string){
let params = new HttpParams(); let params = new HttpParams();
let url=environment.apiChatUrl+'channels.members'; let url=environment.apiChatUrl+'channels.members';
@@ -274,9 +279,11 @@ export class ChatService {
} }
return this.http.post(environment.apiChatUrl+'channels.kick', body, opts); return this.http.post(environment.apiChatUrl+'channels.kick', body, opts);
} }
deleteGroup(body:any){ deleteGroup(body:any){
return this.http.post(environment.apiChatUrl+'groups.delete', body, this.options); return this.http.post(environment.apiChatUrl+'groups.delete', body, this.options);
} }
deleteChannel(body:any){ deleteChannel(body:any){
return this.http.post(environment.apiChatUrl+'channels.delete', body, this.options); return this.http.post(environment.apiChatUrl+'channels.delete', body, this.options);
} }
+39 -1
View File
@@ -1,11 +1,14 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ChatService } from '../chat.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class TimeService { export class TimeService {
countDownTime: any;
room: any;
constructor() { } constructor(private chatService: ChatService) { }
showDateDuration(start:any){ showDateDuration(start:any){
let end; let end;
@@ -13,6 +16,7 @@ export class TimeService {
start = new Date(start); start = new Date(start);
let customizedDate; let customizedDate;
const totalSeconds = Math.floor((end - (start))/1000);; const totalSeconds = Math.floor((end - (start))/1000);;
const totalMinutes = Math.floor(totalSeconds/60); const totalMinutes = Math.floor(totalSeconds/60);
const totalHours = Math.floor(totalMinutes/60); const totalHours = Math.floor(totalMinutes/60);
@@ -37,6 +41,40 @@ export class TimeService {
} }
} }
countDownDate(date:any, roomId:string){
/* let timer = setInterval(() =>{ */
console.log('Show TIMER');
let difference = new Date(date).getTime() - new Date().getTime();
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_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = c_day + " : " + c_hours + " : " + c_minutes + " : " + c_seconds ;
if(difference < 0){
//clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room'];
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
console.log(res);
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
console.log(res);
});
}
});
}
//})
return this.countDownTime;
}
addZero(i) { addZero(i) {
if (i < 10) { if (i < 10) {
i = "0" + i; i = "0" + i;
@@ -21,6 +21,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>
@@ -237,9 +237,15 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
return this.timeService.showDateDuration(start); return this.timeService.showDateDuration(start);
} }
countDownDate(date:any, roomId:string){
return this.timeService.countDownDate(date, roomId);
}
getRoomInfo(){ getRoomInfo(){
this.showLoader = true; this.showLoader = true;
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{ this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
console.log(room);
this.room = room['room']; this.room = room['room'];
if(this.room.name){ if(this.room.name){
this.roomName = this.room.name.split('-').join(' '); this.roomName = this.room.name.split('-').join(' ');
@@ -20,12 +20,13 @@
<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 *ngIf="true" 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 *ngIf="showDuration" class="container-div"> <div 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>
@@ -35,6 +36,11 @@
</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>
@@ -15,7 +15,10 @@ export class NewGroupPage implements OnInit {
showLoader: boolean; showLoader: boolean;
displayDuration: any; displayDuration: any;
showDuration: boolean; showDuration: boolean;
thedate:any;
_day:any;
selectedDuration = ['','','']; selectedDuration = ['','',''];
countDownTime:any;
//groupName:string; //groupName:string;
@Input() groupName:string; @Input() groupName:string;
@@ -37,7 +40,13 @@ export class NewGroupPage implements OnInit {
} }
_ionChange(event){ _ionChange(event){
console.log(event);
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();
} }
close(){ close(){
//this.modalController.dismiss(); //this.modalController.dismiss();
@@ -51,7 +60,16 @@ export class NewGroupPage implements OnInit {
this.chatService.addGroup(body).subscribe(res=>{ this.chatService.addGroup(body).subscribe(res=>{
console.log('group created'); console.log('group created');
console.log(res['group']); console.log(res['group']);
this.addGroupMessage.emit(res['group']._id); this.addGroupMessage.emit(res['group']._id);
let countDownBody = {
"roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate}
}
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res);
});
}); });
} }
@@ -98,6 +116,29 @@ 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');
console.log(value);
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());
/* let timer = setInterval(() =>{
console.log('Show TIMER');
let difference = this.thedate.getTime() - new Date().getTime();
this._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_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = c_day + ":" + c_hours + ":" + c_minutes + ":" + c_seconds ;
if(difference < 0){
clearInterval(timer);
this.countDownTime = "Expired";
}
}) */
this.selectedDuration = [ this.selectedDuration = [
value.days.value, value.days.value,
value.hours.value, value.hours.value,
@@ -155,6 +196,8 @@ export class NewGroupPage implements OnInit {
{ text: '2', value: 2 }, { text: '2', value: 2 },
{ text: '3', value: 3 }, { text: '3', value: 3 },
{ text: '4', value: 4 }, { text: '4', value: 4 },
{ text: '5', value: 5 },
{ text: '6', value: 6 },
] ]
}, },
{ {
@@ -0,0 +1,13 @@
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="a">
<feColorMatrix in="SourceGraphic" values="0 0 0 0 1.000000 0 0 0 0 0.717647 0 0 0 0 0.011765 0 0 0 1.000000 0"/>
</filter>
</defs>
<g transform="translate(0 -3)" filter="url(#a)" fill="none" fill-rule="evenodd">
<g transform="translate(0 3)" stroke="#42B9FE" stroke-width="2">
<rect x="4" y="4" width="12" height="12" rx="6"/>
<rect x="9.8" y="10.6" width="2" height="1" rx=".5"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 589 B

+4
View File
@@ -77,6 +77,7 @@ $app-theme: mat-light-theme((
--ion-color-warning-contrast-rgb: 0, 0, 0; --ion-color-warning-contrast-rgb: 0, 0, 0;
--ion-color-warning-shade: #e0ac08; --ion-color-warning-shade: #e0ac08;
--ion-color-warning-tint: #ffca22; --ion-color-warning-tint: #ffca22;
--ion-color-yellow-orange:#ffb703;
/** danger **/ /** danger **/
--ion-color-red:#d30a0a; --ion-color-red:#d30a0a;
@@ -274,6 +275,9 @@ $app-theme: mat-light-theme((
--ion-color-expediente: #dae3f3; --ion-color-expediente: #dae3f3;
} }
} }
.yellow-orange{
color: #ffb703 !important;
}
.center{ .center{
text-align: center; text-align: center;
} }