mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
add repository patter for chat
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
<div class="item-container-no-border">
|
||||
<ion-checkbox (ionChange)="_ionChange($event)" color="primary"></ion-checkbox>
|
||||
<ion-checkbox (ionChange)="onDateExpirationChange($event)" color="primary"></ion-checkbox>
|
||||
<ion-label>Grupo Ultra-secreto</ion-label>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import { GroupContactsPage } from '../group-messages/group-contacts/group-contac
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
@Component({
|
||||
selector: 'app-new-group',
|
||||
templateUrl: './new-group.page.html',
|
||||
@@ -18,7 +20,7 @@ export class NewGroupPage implements OnInit{
|
||||
showLoader: boolean;
|
||||
displayDuration: any;
|
||||
showDuration: boolean;
|
||||
thedate:any;
|
||||
expirationDate:any;
|
||||
_day:any;
|
||||
selectedDuration = ['','',''];
|
||||
countDownTime:any;
|
||||
@@ -49,7 +51,8 @@ export class NewGroupPage implements OnInit{
|
||||
private toastService: ToastService,
|
||||
public ThemeService: ThemeService,
|
||||
private RouteService: RouteService,
|
||||
private viewContainerRef: ViewContainerRef
|
||||
private viewContainerRef: ViewContainerRef,
|
||||
private roomRepositoryService: RoomRepositoryService
|
||||
)
|
||||
{
|
||||
this.loggedUserChat = SessionStore.user.ChatData['data'];
|
||||
@@ -83,15 +86,15 @@ export class NewGroupPage implements OnInit{
|
||||
|
||||
}
|
||||
|
||||
_ionChange(event) {
|
||||
onDateExpirationChange(event) {
|
||||
|
||||
this.showDuration = event.detail.checked;
|
||||
|
||||
if(event.detail.checked) {
|
||||
this.thedate = new Date();
|
||||
this.expirationDate = new Date();
|
||||
}
|
||||
else {
|
||||
this.thedate = '';
|
||||
this.expirationDate = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,61 +116,83 @@ export class NewGroupPage implements OnInit{
|
||||
}
|
||||
|
||||
async createGroup() {
|
||||
this.createGroup1()
|
||||
|
||||
let name = this.groupName.split(' ').join('-');
|
||||
//Take out all special characters in string
|
||||
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
// let name = this.groupName.split(' ').join('-');
|
||||
// //Take out all special characters in string
|
||||
// name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
|
||||
let customFields = {}
|
||||
let res:any;
|
||||
// let customFields = {}
|
||||
// let res:any;
|
||||
|
||||
|
||||
const loader = this.toastService.loading();
|
||||
// const loader = this.toastService.loading();
|
||||
|
||||
if(this.thedate) {
|
||||
let customFields = {
|
||||
"countDownDate":this.thedate
|
||||
}
|
||||
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
|
||||
}
|
||||
else {
|
||||
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
|
||||
}
|
||||
// if(this.expirationDate) {
|
||||
// let customFields = {
|
||||
// "countDownDate":this.expirationDate
|
||||
// }
|
||||
// res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
|
||||
// }
|
||||
// else {
|
||||
// res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
|
||||
// }
|
||||
|
||||
|
||||
loader.remove();
|
||||
// loader.remove();
|
||||
|
||||
// FsId
|
||||
// DocId
|
||||
// // FsId
|
||||
// // DocId
|
||||
|
||||
if(res?.result?.rid) {
|
||||
this.addGroupMessage.emit(res.result.rid);
|
||||
// if(res?.result?.rid) {
|
||||
// this.addGroupMessage.emit(res.result.rid);
|
||||
|
||||
this.ChatSystemService.getAllRooms(() => {
|
||||
if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
|
||||
this.createGroupWithAttachmentsCath(res)
|
||||
} else {
|
||||
setTimeout(()=> {
|
||||
// this.ChatSystemService.getAllRooms(() => {
|
||||
// if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
|
||||
// this.createGroupWithAttachmentsCath(res)
|
||||
// } else {
|
||||
// setTimeout(()=> {
|
||||
|
||||
this.createGroupWithAttachments(res)
|
||||
// this.createGroupWithAttachments(res)
|
||||
|
||||
}, 500)
|
||||
}
|
||||
}, res.result.rid);
|
||||
// }, 500)
|
||||
// }
|
||||
// }, res.result.rid);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
// } else {
|
||||
|
||||
this.toastService._badRequest('Existe um grupo com este nome!');
|
||||
// this.toastService._badRequest('Existe um grupo com este nome!');
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
async createGroup1() {
|
||||
const result = await this.roomRepositoryService.create({
|
||||
roomName: this.groupName,
|
||||
createdBy: 0,
|
||||
roomType: 0,
|
||||
expirationDate: null
|
||||
})
|
||||
|
||||
|
||||
console.log(result)
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
} else if(result.error instanceof HttpErrorResponse) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
createGroupWithAttachmentsCath(res: any) {
|
||||
if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
this.createGroupWithAttachmentsCath(res)
|
||||
}, 1500)
|
||||
} else {
|
||||
@@ -261,7 +286,7 @@ export class NewGroupPage implements OnInit{
|
||||
handler:(value:any)=>{
|
||||
|
||||
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.expirationDate = 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 = [
|
||||
value.days.value,
|
||||
|
||||
Reference in New Issue
Block a user