mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
fix ubgs
This commit is contained in:
@@ -45,7 +45,7 @@ export class ChatSystemService {
|
||||
|
||||
onRoomsLoad = new Subscribe({execute : false, deleteOnExecute: true})
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private RochetChatConnectorService: RochetChatConnectorService,
|
||||
private storage: Storage,
|
||||
@@ -76,6 +76,7 @@ export class ChatSystemService {
|
||||
|
||||
await this.chatService.refreshtoken();
|
||||
await this.getUser();
|
||||
this.RochetChatConnectorService.setStatus('online')
|
||||
await this.getAllRooms();
|
||||
this.subscribeToRoom();
|
||||
//
|
||||
@@ -179,7 +180,7 @@ export class ChatSystemService {
|
||||
const rooms = await this.storage.get('Rooms');
|
||||
|
||||
if(rooms) {
|
||||
for (let roomData of rooms.result.update) {
|
||||
for (let roomData of rooms.result.update) {
|
||||
await this.prepareRoom(roomData);
|
||||
}
|
||||
}
|
||||
@@ -213,7 +214,7 @@ export class ChatSystemService {
|
||||
}
|
||||
try {
|
||||
await this.storage.remove('Rooms');
|
||||
} catch(e) {}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
let index = 0
|
||||
@@ -224,7 +225,7 @@ export class ChatSystemService {
|
||||
const roomId = this.getRoomId(roomData);
|
||||
|
||||
if(roomData.t == 'd') {
|
||||
|
||||
|
||||
let error = false
|
||||
let res;
|
||||
|
||||
@@ -238,13 +239,13 @@ export class ChatSystemService {
|
||||
if(error) {
|
||||
res = await this.chatService.getMembers(roomId).toPromise();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const members = res['members'];
|
||||
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
|
||||
rooms.result.update[index]['members'] = members
|
||||
rooms.result.update[index]['membersExcludeMe'] = users
|
||||
|
||||
|
||||
await this.prepareRoom(roomData);
|
||||
} else {
|
||||
if (roomData.t === 'p') {
|
||||
@@ -257,19 +258,19 @@ export class ChatSystemService {
|
||||
await this.chatService.refreshtoken();
|
||||
error = true
|
||||
}
|
||||
|
||||
|
||||
if(error) {
|
||||
res = await this.chatService.getGroupMembers(roomId).toPromise()
|
||||
}
|
||||
|
||||
const members = res['members'];
|
||||
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
|
||||
|
||||
|
||||
rooms.result.update[index]['members'] = members
|
||||
rooms.result.update[index]['membersExcludeMe'] = users
|
||||
|
||||
|
||||
await this.prepareRoom(roomData);
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -283,7 +284,7 @@ export class ChatSystemService {
|
||||
await this.chatService.refreshtoken();
|
||||
error = true
|
||||
}
|
||||
|
||||
|
||||
if(error) {
|
||||
res = await this.chatService.getChannelMembers(roomId).toPromise()
|
||||
}
|
||||
@@ -291,19 +292,19 @@ export class ChatSystemService {
|
||||
|
||||
const members = res['members'];
|
||||
const users = members.filter(data => data.username != this.sessionStore.user.UserName);
|
||||
|
||||
|
||||
rooms.result.update[index]['members'] = members
|
||||
rooms.result.update[index]['membersExcludeMe'] = users
|
||||
await this.prepareRoom(roomData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(roomId == roomIdCallback) {
|
||||
callback()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -372,29 +373,29 @@ export class ChatSystemService {
|
||||
* @param id room id
|
||||
*/
|
||||
private defaultSubtribe(id: any) {
|
||||
|
||||
|
||||
const room = this.getRoomById(id);
|
||||
|
||||
|
||||
if(!room.subscribeAttempt) {
|
||||
room.subscribeAttempt = true;
|
||||
|
||||
|
||||
this.RochetChatConnectorService.streamRoomMessages(id).then((subscription) => {
|
||||
room.status.receive.message = true;
|
||||
})
|
||||
|
||||
|
||||
this.RochetChatConnectorService.subStreamNotifyRoom(id, 'typing', false).then((subscription) => {
|
||||
room.status.receive.typing = true;
|
||||
//
|
||||
})
|
||||
|
||||
|
||||
this.RochetChatConnectorService.subStreamNotifyRoom(id, 'readMessage', false).then((subscription) => {
|
||||
room.status.receive.readMessage = true;
|
||||
})
|
||||
|
||||
|
||||
this.RochetChatConnectorService.streamNotifyRoomDeleteMessage(id).then((subscription) => {
|
||||
room.status.receive.deleteMessage = true;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -485,7 +486,7 @@ export class ChatSystemService {
|
||||
|
||||
this.delete.push(roomId)
|
||||
delete this.group[roomId];
|
||||
this._group = this._group.filter((e)=> e.id != roomId);
|
||||
this._group = this._group.filter((e)=> e.id != roomId);
|
||||
}
|
||||
|
||||
deleteRecently(roomId) {
|
||||
@@ -626,7 +627,7 @@ export class ChatSystemService {
|
||||
return 'Sem nome'
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
return roomData.fname
|
||||
}
|
||||
|
||||
@@ -721,11 +721,11 @@ export class RoomService {
|
||||
|
||||
formatDateToDDMMYYYY(dateStamp) {
|
||||
const date = new Date(dateStamp);
|
||||
|
||||
|
||||
const day = date.getDate().toString().padStart(2, '0');
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // Month is zero-based
|
||||
const year = date.getFullYear();
|
||||
|
||||
|
||||
return `${day}-${month}-${year}`;
|
||||
}
|
||||
|
||||
@@ -780,6 +780,8 @@ export class RoomService {
|
||||
let currentDateMessage = new Date().toLocaleDateString()
|
||||
if(!this.labelDates.find( e => e == currentDateMessage)) {
|
||||
|
||||
this.labelDates.push(currentDateMessage)
|
||||
|
||||
const cloneMessage = new MessageServiceDateLabel()
|
||||
|
||||
cloneMessage.ChatSystemService = this.ChatSystemService
|
||||
|
||||
@@ -18,4 +18,12 @@ export class DataService {
|
||||
return this.data[name]
|
||||
}
|
||||
|
||||
delate(name: string) {
|
||||
delete this.data[name]
|
||||
}
|
||||
|
||||
|
||||
clear() {
|
||||
this.data = {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotificationsEndsPointsService } from './notifications-ends-points.service';
|
||||
|
||||
describe('NotificationsEndsPointsService', () => {
|
||||
let service: NotificationsEndsPointsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(NotificationsEndsPointsService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationsEndsPointsService {
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) { }
|
||||
|
||||
|
||||
|
||||
postToken(token) {
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {
|
||||
UserId: SessionStore.user.UserId,
|
||||
TokenId: token,
|
||||
Status: 1,
|
||||
Service: 1
|
||||
};
|
||||
|
||||
return this.http.post<Token>(`${environment.apiURL}+ 'notifications/token'`, body, { headers })
|
||||
}
|
||||
|
||||
|
||||
DeleteToken(token) {
|
||||
|
||||
const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${token}`;
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {};
|
||||
|
||||
return this.http.delete<Token>(`${geturl}`, { headers, body })
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotificationsStoreService } from './notifications-store.service';
|
||||
|
||||
describe('NotificationsStoreService', () => {
|
||||
let service: NotificationsStoreService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(NotificationsStoreService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationsStoreService {
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotificationsTriggerService } from './notifications-trigger.service';
|
||||
|
||||
describe('NotificationsTriggerService', () => {
|
||||
let service: NotificationsTriggerService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(NotificationsTriggerService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationsTriggerService {
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) { }
|
||||
|
||||
|
||||
|
||||
|
||||
sendNotificationWithSend(userID, title, bodymsg, roomId) {
|
||||
const geturl = environment.apiURL + `notifications/send`;
|
||||
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const message = {
|
||||
"Service": "chat",
|
||||
"IdObject": roomId
|
||||
}
|
||||
let id = 437
|
||||
this.http.post<Token>(geturl + `?userId=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
||||
|
||||
}, (error) => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
ChatSendMessageNotification(userID, title, bodymsg, roomId) {
|
||||
const geturl = environment.apiURL + `notifications/sendbyUsername`;
|
||||
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const message = {
|
||||
"Service": "chat",
|
||||
"IdObject": roomId
|
||||
}
|
||||
let id = 437
|
||||
this.http.post<Token>(geturl + `?username=${userID}&title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
||||
// this.active = true
|
||||
}, (error) => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
ChatSendMessageNotificationGrup(usersID, title, bodymsg, roomId) {
|
||||
const geturl = environment.apiURL + `notifications/sendByUsernames`;
|
||||
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const message = {
|
||||
"Users": usersID,
|
||||
"NotificationData": {
|
||||
"Service": "chat",
|
||||
"IdObject": roomId
|
||||
}
|
||||
}
|
||||
|
||||
this.http.post<Token>(geturl + `?title=${title}&body=${bodymsg}`, message, { headers }).subscribe(data => {
|
||||
// this.active = true
|
||||
}, (error) => {
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotificationsService } from './notifications.service';
|
||||
|
||||
describe('NotificationsService', () => {
|
||||
let service: NotificationsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(NotificationsService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,200 @@
|
||||
import { Injectable, NgZone } from '@angular/core';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { NotificationsEndsPointsService } from './notifications-ends-points.service'
|
||||
import { AngularFireMessaging } from '@angular/fire/messaging';
|
||||
import { NavigationExtras, Router } from '@angular/router';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NotificationsService {
|
||||
|
||||
isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
|
||||
active = false
|
||||
|
||||
constructor(
|
||||
private platform: Platform,
|
||||
private NotificationsEndsPointsService: NotificationsEndsPointsService,
|
||||
private afMessaging: AngularFireMessaging,
|
||||
private router: Router,
|
||||
private zone: NgZone,
|
||||
) { }
|
||||
|
||||
|
||||
requestPermissions() {
|
||||
|
||||
if (this.platform.is('mobile')) {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
PushNotifications.requestPermissions().then(result => {
|
||||
if (result.receive === 'granted') {
|
||||
// Register with Apple / Google to receive push via APNS/FCM
|
||||
PushNotifications.register();
|
||||
} else {
|
||||
// Show some error
|
||||
}
|
||||
});
|
||||
} else {}
|
||||
}
|
||||
|
||||
|
||||
getToken(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.platform.is('mobile')) {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
PushNotifications.addListener('registration',
|
||||
(token: Token) => {
|
||||
resolve(token.value)
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.afMessaging.requestToken.subscribe(
|
||||
(token) => {
|
||||
resolve(token)
|
||||
},
|
||||
(error) => {
|
||||
console.error('Permission denied:', error);
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async registerToken(username) {
|
||||
const token = await this.getToken()
|
||||
|
||||
if (this.platform.is('mobile')) {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
|
||||
this.NotificationsEndsPointsService.postToken(token)
|
||||
} else {
|
||||
this.afMessaging.requestToken.subscribe(
|
||||
(token) => {
|
||||
// Save the token to your server for sending notifications
|
||||
console.log('Permission granted! Token:', token);
|
||||
this.NotificationsEndsPointsService.postToken(token)
|
||||
},
|
||||
(error) => {
|
||||
console.error('Permission denied:', error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onReciveBackground() {
|
||||
|
||||
if(this.platform.is('mobile')) {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
this.active = true
|
||||
console.log('NOtification Listener Backgroud', notification)
|
||||
/* this.DataArray.push(notification.notification)
|
||||
|
||||
this.storageService.store("Notifications", this.DataArray)
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
}) */
|
||||
this.notificatinsRoutes(notification)
|
||||
// this.runNotificationCallback(notification)
|
||||
}
|
||||
);
|
||||
} else {
|
||||
navigator.serviceWorker.onmessage = (event) => {
|
||||
console.log('Mensagem recebida do Service Worker:', event.data.data);
|
||||
let object = {
|
||||
notification: event.data
|
||||
}
|
||||
|
||||
if (event.data.notificationClicked) {
|
||||
console.log('Notificação push do Firebase clicada em segundo plano!');
|
||||
this.notificatinsRoutes(object)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
registrationError() {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
|
||||
PushNotifications.addListener('registrationError',
|
||||
(error: any) => {
|
||||
this.active = false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
notificatinsRoutes = (notification) => {
|
||||
|
||||
console.log('BACK BACK',notification)
|
||||
|
||||
if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda']));
|
||||
}
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") {
|
||||
//this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
|
||||
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.IdObject, 'agenda']));
|
||||
|
||||
} else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true }));
|
||||
}
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") {
|
||||
this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject]));
|
||||
}
|
||||
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") {
|
||||
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject]));
|
||||
}
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
|
||||
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diploma-revisao") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital']));
|
||||
}
|
||||
|
||||
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") {
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "roomId": notification.notification.data.IdObject, } };
|
||||
this.zone.run(() => this.router.navigate(['/home/chat'], navigationExtras));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ export class NotificationsService {
|
||||
active = false
|
||||
isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
|
||||
notificationReceived: EventEmitter<void> = new EventEmitter<void>();
|
||||
token = ''
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@@ -81,6 +82,7 @@ export class NotificationsService {
|
||||
PushNotifications.addListener('registration',
|
||||
(token: Token) => {
|
||||
this.postToken(token.value, geturl)
|
||||
this.token = token.value
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -89,6 +91,7 @@ export class NotificationsService {
|
||||
// Save the token to your server for sending notifications
|
||||
console.log('Permission granted! Token:', token);
|
||||
this.postToken(token, geturl)
|
||||
this.token = token
|
||||
},
|
||||
(error) => {
|
||||
console.error('Permission denied:', error);
|
||||
@@ -98,6 +101,13 @@ export class NotificationsService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
DeletePostToken() {
|
||||
const geturl = environment.apiURL + `notifications/token?userId=${SessionStore.user.UserId}&tokenId=${this.token}`;
|
||||
|
||||
this.DeleteToken(geturl)
|
||||
}
|
||||
|
||||
postToken(token, geturl) {
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {
|
||||
@@ -113,6 +123,19 @@ export class NotificationsService {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
DeleteToken(geturl) {
|
||||
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
|
||||
const body = {};
|
||||
|
||||
this.http.delete<Tokenn>(`${geturl}`, { headers, body }).subscribe(data => {
|
||||
this.active = true
|
||||
}, (error) => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
registrationError() {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
@@ -137,8 +160,8 @@ export class NotificationsService {
|
||||
this.active = true
|
||||
console.log('NOtification Listener', notification)
|
||||
this.storenotification(notification)
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@@ -154,7 +177,7 @@ export class NotificationsService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
storenotification(notification) {
|
||||
console.log('Store Notification ',notification)
|
||||
this.storageService.get("Notifications").then((store) => {
|
||||
@@ -168,21 +191,21 @@ export class NotificationsService {
|
||||
let exists = accumulator.find(item => {
|
||||
return item.id === current.id;
|
||||
});
|
||||
|
||||
if(!exists) {
|
||||
|
||||
if(!exists) {
|
||||
accumulator = accumulator.concat(current);
|
||||
}
|
||||
return accumulator;
|
||||
}, []);
|
||||
|
||||
|
||||
console.log('Notification Result',result);
|
||||
this.storageService.store("Notifications", result).then(() => {
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
this.storageService.store("Notifications", store).then(() => {
|
||||
this.eventtrigger.publishSomeData({
|
||||
@@ -190,11 +213,6 @@ export class NotificationsService {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}).catch((error) => {
|
||||
if (!error) {
|
||||
this.storageService.store("Notifications", [notification])
|
||||
@@ -208,13 +226,13 @@ export class NotificationsService {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
this.active = true
|
||||
console.log('NOtification Listener Backgroud', notification)
|
||||
/* this.DataArray.push(notification.notification)
|
||||
|
||||
|
||||
this.storageService.store("Notifications", this.DataArray)
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
@@ -236,7 +254,7 @@ export class NotificationsService {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sendNotificationWithSend(userID, title, bodymsg, roomId) {
|
||||
@@ -254,7 +272,7 @@ export class NotificationsService {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
ChatSendMessageNotification(userID, title, bodymsg, roomId) {
|
||||
const geturl = environment.apiURL + `notifications/sendbyUsername`;
|
||||
@@ -298,7 +316,7 @@ export class NotificationsService {
|
||||
|
||||
notificatinsRoutes = (notification) => {
|
||||
|
||||
console.log('BACK BACK',notification)
|
||||
console.log('BACK BACK',notification)
|
||||
|
||||
if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export class TaskService {
|
||||
deplomasStore = DeplomasStore
|
||||
|
||||
SessionStore = SessionStore
|
||||
|
||||
|
||||
AllProcess = []
|
||||
showLoader: boolean = false
|
||||
showLoaderNum: number = 0
|
||||
@@ -57,8 +57,8 @@ export class TaskService {
|
||||
funx: Function
|
||||
id: string
|
||||
}
|
||||
} = {}
|
||||
|
||||
} = {}
|
||||
|
||||
|
||||
constructor(
|
||||
private processesbackend: ProcessesService,
|
||||
@@ -95,7 +95,7 @@ export class TaskService {
|
||||
registerCallback({funx, id = uuidv4()}) {
|
||||
|
||||
this.callbacks[id] = { funx, id}
|
||||
|
||||
|
||||
return {
|
||||
delete: ()=> {
|
||||
delete this.callbacks[id]
|
||||
@@ -132,7 +132,7 @@ export class TaskService {
|
||||
if(!isoDateString) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
const creationDate = new Date(isoDateString)
|
||||
return momentG(new Date(), 'dd MMMM yyyy') == momentG(new Date(creationDate), 'dd MMMM yyyy')
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class TaskService {
|
||||
} else if (attribute == 'OverdueTasks') {
|
||||
|
||||
return this.overdueTask(item.Deadline || item.deadline)
|
||||
|
||||
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -168,9 +168,9 @@ export class TaskService {
|
||||
|
||||
sortArrayISODate(myArray: any): any[] {
|
||||
|
||||
return myArray.sort((a,b) =>
|
||||
Date.parse(b.CreateDate || b.taskStartDate || b.TaskStartDate || b.TaskReceiveDate || b.taskReceiveDate )
|
||||
-
|
||||
return myArray.sort((a,b) =>
|
||||
Date.parse(b.CreateDate || b.taskStartDate || b.TaskStartDate || b.TaskReceiveDate || b.taskReceiveDate )
|
||||
-
|
||||
Date.parse(a.CreateDate || b.taskStartDate || b.TaskStartDate || a.TaskReceiveDate || a.taskReceiveDate ))
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ export class TaskService {
|
||||
await this.loadPendestes()
|
||||
|
||||
await this.loadDiplomas()
|
||||
|
||||
|
||||
|
||||
await this.loadEventosParaAprovacao()
|
||||
this.loadCount = true
|
||||
@@ -241,17 +241,17 @@ export class TaskService {
|
||||
try {
|
||||
let expedientes;
|
||||
expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise()
|
||||
|
||||
|
||||
expedientes = (expedientes || [] ).filter(data => data.workflowInstanceDataFields.Status == "" || data.workflowInstanceDataFields.Status == "Active")
|
||||
|
||||
|
||||
expedientes = expedientes.filter((item) => {
|
||||
return item.activityInstanceName != 'Retificar Expediente'
|
||||
});
|
||||
|
||||
|
||||
expedientes = expedientes.map((element) => this.expedienteTaskPipe.transform(element));
|
||||
|
||||
expedientes = this.sortArrayISODate(expedientes).reverse()
|
||||
|
||||
|
||||
this.expedientegbstore.reset(expedientes);
|
||||
} catch (error) {
|
||||
|
||||
@@ -268,15 +268,15 @@ export class TaskService {
|
||||
try {
|
||||
let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise();
|
||||
let pareceresPr = await this.processesbackend.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
|
||||
|
||||
|
||||
let allParecer = pareceres.concat(pareceresPr);
|
||||
|
||||
|
||||
this.pedidosstore.countparecer = Object.keys(allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active")).length;
|
||||
|
||||
|
||||
this.pedidosstore.resetparecer(allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active").map((element) => {
|
||||
return this.customTaskPipe.transform(element)
|
||||
}));
|
||||
|
||||
}));
|
||||
|
||||
let deferimentos = await this.processesbackend.GetTasksList("Pedido de Deferimento", false).toPromise();
|
||||
this.pedidosstore.countdeferimento = Object.keys(deferimentos.filter(data => data.workflowInstanceDataFields.Status == "Active")).length
|
||||
this.pedidosstore.resetdeferimento(deferimentos.filter(data => data.workflowInstanceDataFields.Status == "Active").map((element) => {
|
||||
@@ -292,7 +292,7 @@ export class TaskService {
|
||||
this.showLoaderNum++
|
||||
|
||||
try {
|
||||
|
||||
|
||||
let pendentes = await this.processesbackend.GetPendingTasks(false).toPromise();
|
||||
this.pendentesstore.count = Object.keys(pendentes).length;
|
||||
|
||||
@@ -304,7 +304,7 @@ export class TaskService {
|
||||
}
|
||||
|
||||
this.showLoaderNum--
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ export class TaskService {
|
||||
console.log('PR')
|
||||
// PR dont have event to approve
|
||||
/* if(this.SessionStore.user.Profile != 'PR') { */
|
||||
try {
|
||||
try {
|
||||
for(let calendar of this.eventService.calendarNamesAry) {
|
||||
if(calendar == 'Meu calendario') {
|
||||
// color
|
||||
@@ -324,10 +324,10 @@ export class TaskService {
|
||||
} catch (error) {
|
||||
eventsList = [];
|
||||
}
|
||||
|
||||
|
||||
console.log(calendar, eventsList)
|
||||
this.eventoaprovacaostore.save(calendar, eventsList)
|
||||
|
||||
|
||||
} else {
|
||||
let allEvents = await this.processesbackend.eventsToApprove(calendar.OwnerUserId, 'againete page').toPromise()
|
||||
let eventsList
|
||||
@@ -336,13 +336,13 @@ export class TaskService {
|
||||
} catch(error) {
|
||||
eventsList = []
|
||||
}
|
||||
|
||||
|
||||
console.log(calendar, eventsList)
|
||||
this.eventoaprovacaostore.save(calendar.OwnerUserId, eventsList)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
|
||||
}
|
||||
/* } */
|
||||
|
||||
@@ -357,64 +357,64 @@ export class TaskService {
|
||||
this.showLoaderNum++
|
||||
|
||||
try {
|
||||
|
||||
|
||||
let depachoAPI = await this.processesbackend.GetTasksList("Despacho do Presidente da República", false).toPromise();
|
||||
|
||||
|
||||
|
||||
|
||||
if(SessionStore.user.Profile != 'PR') {
|
||||
|
||||
|
||||
let depacho: any = depachoAPI.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
|
||||
depacho = depacho.filter(data => data.workflowInstanceDataFields.Status == "Active");
|
||||
|
||||
|
||||
depacho = depacho.map((e)=> this.customTaskPipe.transform(e))
|
||||
|
||||
|
||||
this.despachoprstore.reset(depacho)
|
||||
|
||||
|
||||
} else if(SessionStore.user.Profile == 'PR') {
|
||||
|
||||
|
||||
let depacho: any = depachoAPI.filter(data => data.activityInstanceName == "Concluir Despacho").filter(data => data.workflowInstanceDataFields.Status == "Active")
|
||||
depacho = depacho.map((e)=> this.customTaskPipe.transform(e))
|
||||
this.despachoprstore.reset(depacho)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let gerarDiploma = depachoAPI.reverse().filter(data => data.activityInstanceName == "Gerar Diploma" || data.activityInstanceName == "Retificar Diploma");
|
||||
let diplomasList = []
|
||||
|
||||
|
||||
gerarDiploma.forEach(element => {
|
||||
let task: customTask = this.customTaskPipe.transform(element);
|
||||
diplomasList.push(task);
|
||||
});
|
||||
|
||||
|
||||
diplomasList = diplomasList
|
||||
this.deplomasStore.resetDiplomaGerar(diplomasList);
|
||||
|
||||
|
||||
|
||||
|
||||
let diplomasValidar = depachoAPI.filter(data => data.activityInstanceName == "Revisar Diploma");
|
||||
|
||||
|
||||
diplomasValidar = diplomasValidar.filter(data => data.activityInstanceName != "Tarefa de Despacho");
|
||||
|
||||
|
||||
|
||||
|
||||
this.deplomasStore.resetDiplomasReview(diplomasValidar.map((element)=> {
|
||||
|
||||
|
||||
let date = new Date(element.taskStartDate);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();
|
||||
|
||||
|
||||
return this.customTaskPipe.transform(element)
|
||||
}))
|
||||
|
||||
|
||||
|
||||
|
||||
let diplomasAssinar: any = depachoAPI.filter(data => data.activityInstanceName == "Assinar Diploma");
|
||||
diplomasAssinar = diplomasAssinar.map((element) => this.expedienteTaskPipe.transform(element))
|
||||
this.deplomasStore.resetDiplomasParaAssinar(diplomasAssinar)
|
||||
|
||||
|
||||
let diplomasAssinados: any = depachoAPI.filter(data => data.activityInstanceName == "Diploma Assinado");
|
||||
diplomasAssinados = diplomasAssinados.map((element) => this.expedienteTaskPipe.transform(element))
|
||||
this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados)
|
||||
} catch (error) {}
|
||||
|
||||
|
||||
this.showLoaderNum--
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ export class TaskService {
|
||||
|
||||
dynamicSearch({searchSubject, ordinance, list}) {
|
||||
if(searchSubject) {
|
||||
|
||||
|
||||
const AllProcess = list.filter((task) => {
|
||||
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
||||
subject = subject.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user