diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index 06b324206..2aec463e7 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -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(); diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index dd63fce4a..bc410e53c 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -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() { diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index e3ea00806..f92f6b018 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -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; diff --git a/src/app/services/chat/chat-system.service.ts b/src/app/services/chat/chat-system.service.ts index 37a5d0d16..4e666deaf 100644 --- a/src/app/services/chat/chat-system.service.ts +++ b/src/app/services/chat/chat-system.service.ts @@ -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 diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index a641a1042..2d01c0d87 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -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; diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index ef53c987b..90a41611a 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -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 { 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 diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index b04c93800..644494403 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -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(geturl+`?userId=${userID}&title=${title}&body=${bodymsg}`, body, { headers }).subscribe(data => { + this.http.post(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)); } } diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index 3612e026d..3ad89fdfe 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -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) + }); } diff --git a/src/assets/images/icons-nav-agenda-active.svg b/src/assets/images/icons-nav-agenda-active.svg new file mode 100644 index 000000000..351f44834 --- /dev/null +++ b/src/assets/images/icons-nav-agenda-active.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 38a854fa6..53f31b337 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -3,4 +3,4 @@ import { oaprProd } from './suport/oapr' import { doneITProd } from './suport/doneIt' -export const environment: Environment = doneITProd; \ No newline at end of file +export const environment: Environment = oaprProd; \ No newline at end of file diff --git a/version/git-version.ts b/version/git-version.ts index 694607b51..a214f268b 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "a712f6271", - "SHA": "a712f6271de72b42cd03c1a4aeec71a0fd05b048", + "shortSHA": "cc9c5a9cf", + "SHA": "cc9c5a9cf574d37b4d2269e37743f359bc1d7b8d", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Jan 30 17:45:06 2023 +0100'", - "lastCommitMessage": "save", - "lastCommitNumber": "4696", + "lastCommitTime": "'Mon Jan 30 23:21:47 2023 +0100'", + "lastCommitMessage": "fix", + "lastCommitNumber": "4700", "change": "", - "changeStatus": "On branch no_bug_movemente\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/pages/chat/messages/messages.page.html\n\tmodified: src/app/pages/chat/messages/messages.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos/despacho/despacho.page.html\n\tmodified: src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html\n\tmodified: src/app/services/chat/message.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/agenda/approve-event/approve-event.page.ts\n\tmodified: src/app/shared/popover/despachos-options/despachos-options.page.html\n\tmodified: src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.html\n\tmodified: src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.html\n\tmodified: src/app/shared/popover/opts-expediente/opts-expediente.page.html\n\tmodified: src/environments/environment.prod.ts\n\tmodified: version/git-version.ts", - "changeAuthor": "peter.maquiran" + "changeStatus": "On branch no_bug_movemente\nYour branch is behind 'origin/no_bug_movemente' by 8 commits, and can be fast-forwarded.\n (use \"git pull\" to update your local branch)\n\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/pages/chat/chat.page.ts\n\tmodified: src/app/pages/chat/messages/messages.page.ts\n\tmodified: src/app/services/chat/chat-system.service.ts\n\tmodified: src/app/services/chat/message.service.ts\n\tmodified: src/app/services/chat/room.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/header/header.page.ts\n\tnew file: src/assets/images/icons-nav-agenda-active.svg\n\tmodified: src/environments/environment.prod.ts", + "changeAuthor": "eudes.inacio" } \ No newline at end of file