mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
chat notification added
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, NgZone } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { NavigationExtras, Router } from '@angular/router';
|
||||
import { AnimationController, ModalController, Platform } from '@ionic/angular';
|
||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
@@ -187,7 +187,8 @@ export class ProfilePage implements OnInit {
|
||||
else if (Service === "gabinete-digital" && Object === "expedientes-pr") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
|
||||
} else if (Service === "chat") {
|
||||
this.zone.run(() => this.router.navigate(['/home/chat', IdObject, 'chat']));
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "roomId": IdObject, } };
|
||||
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
|
||||
}
|
||||
|
||||
// this.notificationservice.tempClearArray();
|
||||
|
||||
@@ -27,6 +27,7 @@ import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-debugging.page';
|
||||
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -114,6 +115,7 @@ export class ChatPage implements OnInit {
|
||||
private storageservice: StorageService,
|
||||
public ChatSystemService: ChatSystemService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private eventTriger: EventTrigger
|
||||
) {
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
@@ -127,6 +129,13 @@ export class ChatPage implements OnInit {
|
||||
|
||||
this.segment = 'Contactos'
|
||||
|
||||
this.eventTriger.getObservable().subscribe((event) => {
|
||||
if(event.notification == "recive") {
|
||||
this.onSegmentChange()
|
||||
}
|
||||
console.log(event)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -382,15 +382,24 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
sendMessage(msg) {
|
||||
let lastMsg = msg.pop();
|
||||
console.log(msg)
|
||||
console.log(lastMsg._id,lastMsg.msg,lastMsg.msg)
|
||||
this.ChatSystemService.getDmRoom(this.roomId).send({}).then(() => {
|
||||
console.log(this.members)
|
||||
this.notificationService.ChatSendMessageNotification(this.members[1].username,this.members[1].name,lastMsg.msg,this.roomId)
|
||||
})
|
||||
}
|
||||
|
||||
/* sendMessage(msg) {
|
||||
let lastMsg = msg.pop();
|
||||
console.log(msg)
|
||||
console.log(lastMsg._id,lastMsg.u.username,lastMsg.msg)
|
||||
this.ChatSystemService.getDmRoom(this.roomId).send({}).then(() => {
|
||||
if(lastMsg.u.username == this.members[1].username) {
|
||||
this.notificationService.ChatSendMessageNotification(this.members[0].username,this.members[1].name,lastMsg.msg,this.roomId)
|
||||
} else if (msg.u.username == this.members[0].username) {
|
||||
this.notificationService.ChatSendMessageNotification(this.members[1].username,this.members[1].name,lastMsg.msg,this.roomId)
|
||||
}
|
||||
|
||||
})
|
||||
} */
|
||||
|
||||
base64toBlob(base64Data, contentType) {
|
||||
contentType = contentType || '';
|
||||
var sliceSize = 1024;
|
||||
|
||||
@@ -19,6 +19,7 @@ import { AESEncrypt } from '../aesencrypt.service'
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { NetworkServiceService} from 'src/app/services/network-service.service';
|
||||
import { ViewedMessageService } from './viewed-message.service'
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -56,7 +57,8 @@ export class ChatSystemService {
|
||||
private AESEncrypt: AESEncrypt,
|
||||
private AttachmentsService:AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ViewedMessageService: ViewedMessageService
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService
|
||||
) {
|
||||
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
@@ -417,7 +419,7 @@ export class ChatSystemService {
|
||||
if (setData.name != 'Rocket Cat' && setData.name != 'general' ) {
|
||||
// create room
|
||||
if(!this.roomExist(roomId)) {
|
||||
let room:RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService)
|
||||
let room:RoomService = new RoomService(this.RochetChatConnectorService, new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this,this.notificationService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this, this.ViewedMessageService,this.notificationService)
|
||||
room.setData(setData)
|
||||
room.receiveMessage()
|
||||
room.getAllUsers = this.getUsers
|
||||
|
||||
@@ -13,6 +13,7 @@ import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service';
|
||||
import { ChatSystemService } from './chat-system.service';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -72,7 +73,8 @@ export class MessageService {
|
||||
private AESEncrypt: AESEncrypt,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ChatSystemService: ChatSystemService,) {
|
||||
private ChatSystemService: ChatSystemService,
|
||||
private notificationService: NotificationsService) {
|
||||
}
|
||||
|
||||
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference = 'out-'+uuidv4() , viewed = [], received = [], delate = false, delateRequest =false, from, sendAttempt = 0, origin }:Message) {
|
||||
@@ -289,7 +291,7 @@ export class MessageService {
|
||||
clearTimeout(this.functionTimer);
|
||||
|
||||
this.redefinedMessage(ChatMessage)
|
||||
|
||||
console.log()
|
||||
}
|
||||
).catch((error) => {
|
||||
clearTimeout(this.functionTimer);
|
||||
@@ -366,9 +368,17 @@ export class MessageService {
|
||||
this.addReceived(user._id)
|
||||
}
|
||||
|
||||
if(!roomObject.isGroup) {
|
||||
var memeberTosend = this.ChatSystemService.getRoomById(this.rid).membersExcludeMe
|
||||
this.notificationService.ChatSendMessageNotification(memeberTosend[0].username,ChatMessage.u.username,ChatMessage.msg,this.rid)
|
||||
}
|
||||
|
||||
|
||||
await this.saveChanges()
|
||||
}
|
||||
|
||||
sendNotificaton
|
||||
|
||||
downloadFileMsg() {
|
||||
|
||||
this.downloadLoader = true;
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ConnectionStatus, NetworkServiceService} from 'src/app/services/network
|
||||
import { ChatSystemService } from './chat-system.service';
|
||||
import { ViewedMessageService } from './viewed-message.service'
|
||||
import * as FIFOProcessQueue from 'fifo-process-queue';
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -97,7 +98,8 @@ export class RoomService {
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ChatSystemService: ChatSystemService,
|
||||
private ViewedMessageService: ViewedMessageService
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService
|
||||
) {
|
||||
this.NativeNotificationService.askForPermission()
|
||||
|
||||
@@ -158,7 +160,7 @@ export class RoomService {
|
||||
}
|
||||
}
|
||||
|
||||
setData({membersExcludeMe, members, u, customFields = {}, id, name, t, lastMessage = new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this.ChatSystemService), _updatedAt }) {
|
||||
setData({membersExcludeMe, members, u, customFields = {}, id, name, t, lastMessage = new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this.ChatSystemService,this.notificationService), _updatedAt }) {
|
||||
this.customFields = customFields
|
||||
this.id = id
|
||||
this.name = name
|
||||
@@ -811,7 +813,7 @@ export class RoomService {
|
||||
async prepareCreate({message, save = true}): Promise<MessageService> {
|
||||
message = this.fix_updatedAt(message)
|
||||
|
||||
const wewMessage = new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this.ChatSystemService)
|
||||
const wewMessage = new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this.ChatSystemService,this.notificationService)
|
||||
wewMessage.setData(message)
|
||||
wewMessage.loadHistory = this.hasLoadHistory
|
||||
|
||||
@@ -823,7 +825,7 @@ export class RoomService {
|
||||
|
||||
simplePrepareMessage(message) {
|
||||
message = this.fix_updatedAt(message)
|
||||
const wewMessage = new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this.ChatSystemService)
|
||||
const wewMessage = new MessageService(this.NfService, this.RochetChatConnectorService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService, this.ChatSystemService,this.notificationService)
|
||||
wewMessage.setData(message)
|
||||
wewMessage.loadHistory = this.hasLoadHistory
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { StorageService } from 'src/app/services/storage.service';
|
||||
import { AuthConnstants } from 'src/app/config/auth-constants';
|
||||
import { Tokenn } from '../models/token.model';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
import { Router } from '@angular/router';
|
||||
import { NavigationExtras, Router } from '@angular/router';
|
||||
import { EventTrigger } from '../services/eventTrigger.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
@@ -129,6 +129,7 @@ export class NotificationsService {
|
||||
}
|
||||
|
||||
onReciveForeground() {
|
||||
console.log('foregrund');
|
||||
PushNotifications.addListener('pushNotificationReceived',
|
||||
(notification: PushNotificationSchema) => {
|
||||
this.active = true
|
||||
@@ -155,6 +156,7 @@ export class NotificationsService {
|
||||
}
|
||||
|
||||
onReciveBackground() {
|
||||
console.log('fbackgrund');
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
this.active = true
|
||||
@@ -175,18 +177,13 @@ export class NotificationsService {
|
||||
const geturl = environment.apiURL + `notifications/send`;
|
||||
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {
|
||||
UserId: userID,
|
||||
title: title,
|
||||
body: bodymsg,
|
||||
data: {
|
||||
Service: "chat",
|
||||
IdObject: roomId
|
||||
const message = {
|
||||
"Service": "chat",
|
||||
"IdObject": roomId
|
||||
}
|
||||
};
|
||||
let id = 437
|
||||
console.log(userID,title,bodymsg,roomId)
|
||||
this.http.post<Tokenn>(geturl+`?userId=${userID}&title=${title}&body=${bodymsg}`, body, { headers }).subscribe(data => {
|
||||
this.http.post<Tokenn>(geturl+`?userId=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
||||
this.active = true
|
||||
console.log(data)
|
||||
}, (error) => {
|
||||
@@ -246,7 +243,8 @@ export class NotificationsService {
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
} else if (notification.notification.data.Service === "chat") {
|
||||
this.zone.run(() => this.router.navigate(['/home/chat', notification.notification.data.IdObject, 'chat']));
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "roomId": notification.notification.data.IdObject, } };
|
||||
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ThemeService } from '../../services/theme.service';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { PermissionList } from 'src/app/models/permission/permissionList';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { EventTrigger } from 'src/app/services/eventTrigger.service'
|
||||
/* import { Events } from 'ionic-angular' */
|
||||
|
||||
@Component({
|
||||
@@ -46,7 +47,7 @@ export class HeaderPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
public RouteService: RouteService,
|
||||
public p: PermissionService,
|
||||
/* private eventTriger: Events, */
|
||||
private eventTriger: EventTrigger,
|
||||
) {
|
||||
this.loggeduser = SessionStore.user;
|
||||
router.events.subscribe((val) => {
|
||||
@@ -55,10 +56,12 @@ export class HeaderPage implements OnInit {
|
||||
this.showProfileModal = false
|
||||
});
|
||||
|
||||
/* this.eventTriger.subscribe('notificatioRecive', () => {
|
||||
this.notificationLengthData();
|
||||
console.log('Header update with notificatio')
|
||||
}); */
|
||||
this.eventTriger.getObservable().subscribe((event) => {
|
||||
if(event.notification == "recive") {
|
||||
this.notificationLengthData()
|
||||
}
|
||||
console.log(event)
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="35" height="35" viewBox="0 0 35 35">
|
||||
<defs>
|
||||
<linearGradient id="dqrp73f7qc" x1="50%" x2="50%" y1="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#80C2FF"/>
|
||||
<stop offset="99.962%" stop-color="#0085FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="70ojnupnmf" x1="50%" x2="50%" y1="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#FFEFBB"/>
|
||||
<stop offset="100%" stop-color="#FFC200"/>
|
||||
</linearGradient>
|
||||
<filter id="p7hjmzg55a" width="117.4%" height="120%" x="-8.7%" y="-5%" filterUnits="objectBoundingBox">
|
||||
<feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/>
|
||||
<feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation=".5"/>
|
||||
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"/>
|
||||
<feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.187390734 0"/>
|
||||
</filter>
|
||||
<filter id="ap0wf93zpd" width="125%" height="128.6%" x="-12.5%" y="-7.1%" filterUnits="objectBoundingBox">
|
||||
<feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/>
|
||||
<feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation=".5"/>
|
||||
<feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"/>
|
||||
<feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.187390734 0"/>
|
||||
</filter>
|
||||
<path id="7nmw8qqr9b" d="M14.5 19.1c1.404 0 2.75-.208 3.993-.59.666-.206 4.252 1.758 4.853 1.459.607-.302-1.77-2.867-1.243-3.253C24.493 14.966 26 12.404 26 9.55 26 4.276 20.851 0 14.5 0S3 4.276 3 9.55c0 5.275 5.149 9.55 11.5 9.55z"/>
|
||||
<path id="xu6zub6ewe" d="M8 25.37c.977 0 1.913-.146 2.778-.414.463-.143 2.958 1.232 3.376 1.022.422-.21-1.232-2.006-.865-2.277C14.951 22.476 16 20.683 16 18.685c0-1.552-.633-2.98-1.695-4.115C12.841 13.006 10.561 12 8 12c-4.418 0-8 2.993-8 6.685 0 1.037.282 2.018.786 2.894C2.077 23.822 4.822 25.37 8 25.37z"/>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<g transform="translate(-30 -471) translate(20 248) translate(0 210) translate(10 10) translate(0 3) translate(5 5)">
|
||||
<use fill="#000" filter="url(#p7hjmzg55a)" xlink:href="#7nmw8qqr9b"/>
|
||||
<path fill="url(#dqrp73f7qc)" stroke="#EBEBEB" stroke-linejoin="square" stroke-opacity=".194" d="M14.5.5c3.05 0 5.813 1.022 7.812 2.682C24.275 4.812 25.5 7.06 25.5 9.55c0 2.698-1.437 5.111-3.692 6.763-.066 1.374.22 1.842.51 2.307.17.273.342.545.467.782-.413.145-1.28-.44-1.758-.634-1.178-.478-2.317-.848-2.68-.737-1.199.369-2.495.57-3.847.57-3.05 0-5.813-1.022-7.812-2.682C4.725 14.289 3.5 12.04 3.5 9.55c0-2.49 1.225-4.738 3.188-6.368C8.688 1.522 11.45.5 14.5.5z"/>
|
||||
</g>
|
||||
<g transform="translate(-30 -471) translate(20 248) translate(0 210) translate(10 10) translate(0 3) translate(5 5) matrix(-1 0 0 1 16 0)">
|
||||
<use fill="#000" filter="url(#ap0wf93zpd)" xlink:href="#xu6zub6ewe"/>
|
||||
<path fill="url(#70ojnupnmf)" stroke="#EBEBEB" stroke-linejoin="square" stroke-opacity=".194" d="M8 12.5c2.41 0 4.56.938 5.94 2.412.974 1.04 1.56 2.349 1.56 3.773 0 1.842-.979 3.487-2.508 4.614-.152 1.023.008 1.308.19 1.608.14.225.26.421.355.587-.296-.022-.819-.446-.939-.495-.868-.355-1.702-.602-1.968-.52-.82.253-1.705.392-2.63.392-1.477 0-2.856-.353-4.02-.965-1.186-.623-2.15-1.515-2.76-2.576-.46-.8-.72-1.697-.72-2.645 0-1.7.834-3.232 2.164-4.343C4.029 13.2 5.917 12.5 8 12.5z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
@@ -3,4 +3,4 @@ import { oaprProd } from './suport/oapr'
|
||||
import { doneITProd } from './suport/doneIt'
|
||||
|
||||
|
||||
export const environment: Environment = doneITProd;
|
||||
export const environment: Environment = oaprProd;
|
||||
Reference in New Issue
Block a user