30" class="post-img">
diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts
index b8c63dfb3..5a7bb8264 100644
--- a/src/app/pages/publications/view-publications/view-publications.page.ts
+++ b/src/app/pages/publications/view-publications/view-publications.page.ts
@@ -12,6 +12,7 @@ import { BackgroundService } from 'src/app/services/background.service';
import { ThemeService } from 'src/app/services/theme.service'
import { forkJoin } from 'rxjs';
import { ToastService } from 'src/app/services/toast.service';
+import { PermissionService } from 'src/app/services/permission.service';
@Component({
selector: 'app-view-publications',
@@ -42,7 +43,8 @@ export class ViewPublicationsPage implements OnInit {
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
- private toastService: ToastService,) {
+ private toastService: ToastService,
+ public p: PermissionService,) {
this.item = new PublicationFolder();
this.activatedRoute.paramMap.subscribe(params => {
@@ -259,7 +261,7 @@ export class ViewPublicationsPage implements OnInit {
publicationArray.push(publicationlis);
});
-
+
this.publicationList = publicationArray;
})
}
diff --git a/src/app/services/chat/chat-methods.service.ts b/src/app/services/chat/chat-methods.service.ts
index 61e446163..379d048b5 100644
--- a/src/app/services/chat/chat-methods.service.ts
+++ b/src/app/services/chat/chat-methods.service.ts
@@ -47,13 +47,8 @@ export class ChatMethodsService {
return this.chatService.sendMessage(body)
}
-
deleteMessage(body) {
return this.chatService.deleteMessage(body)
}
-
-
-
-
}
\ No newline at end of file
diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts
index e4bdcc206..de1e78de2 100644
--- a/src/app/services/chat/message.service.ts
+++ b/src/app/services/chat/message.service.ts
@@ -12,6 +12,7 @@ import { MessageModel, DeleteMessageModel } from '../../models/beast-orm'
import { AESEncrypt } from '../aesencrypt.service'
import { HttpClient, HttpEventType } from '@angular/common/http';
import { AttachmentsService } from 'src/app/services/attachments.service';
+import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service';
@Injectable({
providedIn: 'root'
@@ -62,7 +63,8 @@ export class MessageService {
private ChatStorageService: ChatStorageService,
private ChatMethodsService: ChatMethodsService,
private AESEncrypt: AESEncrypt,
- private AttachmentsService: AttachmentsService,) {
+ private AttachmentsService: AttachmentsService,
+ private NetworkServiceService: NetworkServiceService) {
}
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference , viewed = [], received = [], delate = false, delateRequest =false, }:Message) {
@@ -184,24 +186,30 @@ export class MessageService {
delete params?.attachments?.image_url
}
- this.ChatMethodsService.send(params).subscribe(
- (response: any) => {
- const ChatMessage = response.message
- this.messageSend = true
- this.redefinedMessage(ChatMessage)
- },
- (error) => {
- this.WsChatService.registerCallback({
- type: 'reConnect',
- funx: async ()=> {
- this.send()
- return true
- }
- })
- }
- )
+ if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) {
+
+ this.WsChatService.send(params).then(
+ (ChatMessage: any) => {
+ ChatMessage = ChatMessage.message.result
+
+ this.messageSend = true
+ this.redefinedMessage(ChatMessage)
+ }
+ )
+
+ } else {
+ this.WsChatService.registerCallback({
+ type: 'reConnect',
+ funx: async ()=> {
+
+ this.send()
+ return true
+ }
+ })
+ }
+
}
async redefinedMessage(ChatMessage , update = true) {
diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts
index b5099f4fe..80fcab564 100644
--- a/src/app/services/chat/room.service.ts
+++ b/src/app/services/chat/room.service.ts
@@ -22,6 +22,7 @@ import { DeleteMessageModel, MessageModel } from '../../models/beast-orm'
import { AESEncrypt } from '../aesencrypt.service'
import { IncomingChatMessage, ChatMessageInterface, falseTypingMethod } from 'src/app/models/message.model';
import { AttachmentsService } from 'src/app/services/attachments.service';
+import { ConnectionStatus, NetworkServiceService} from 'src/app/services/network-service.service';
@Injectable({
providedIn: 'root'
@@ -77,18 +78,16 @@ export class RoomService {
private ChatStorageService: ChatStorageService,
private ChatMethodsService: ChatMethodsService,
private AESEncrypt: AESEncrypt,
- private AttachmentsService: AttachmentsService
+ private AttachmentsService: AttachmentsService,
+ private NetworkServiceService: NetworkServiceService
) {
this.NativeNotificationService.askForPermission()
- // this.restoreMessageFromDB()
-
this.WsChatService.getUserStatus((d) => {
const userId = d.fields.args[0][0]
const statusNum = d.fields.args[0][2]
const statusText = this.statusNumberToText(statusNum)
- //
if(this.members?.map) {
const membersIds = this.members.map((user)=> user._id)
@@ -145,7 +144,7 @@ export class RoomService {
}
}
- setData({members, u, customFields = {}, id, name, t, lastMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService), _updatedAt }) {
+ setData({members, u, customFields = {}, id, name, t, lastMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService), _updatedAt }) {
this.customFields = customFields
this.id = id
this.name = name
@@ -343,7 +342,6 @@ export class RoomService {
}
-
async receiveMessageDelete() {
this.WsChatService.updateRoomEventss(
@@ -372,14 +370,6 @@ export class RoomService {
if(this.messages[i]?._id == id ) {
-
- //Get previous last message from room
- const previousLastMessage = this.messages.slice(-1)[0];
- this.lastMessage = previousLastMessage;
-
- this.calDateDuration(previousLastMessage._updatedAt)
- this.sortRoomList()
-
if (SessionStore.user.RochetChatUser == this.messages[i]?.u?.username) {
const allMemberThatIsOffline = this.getAllMemberThatIsOffline()
@@ -393,10 +383,14 @@ export class RoomService {
}
this.messages[i]?.delateDB()
-
- // console.log(_id,'==',this.messages[i]?._id, true)
this.messages.splice(i, 1)
+ //Get previous last message from room
+ const previousLastMessage = this.messages.slice(-1)[0];
+ this.lastMessage = previousLastMessage;
+ this.calDateDuration(previousLastMessage._updatedAt)
+ this.sortRoomList()
+
return true
} else {
@@ -429,40 +423,28 @@ export class RoomService {
const message = this.messages.find((e)=>e._id == msgId)
await message.delateStatusFalse()
- this.ChatMethodsService.deleteMessage({_id:msgId, msgId:msgId, roomId:message.rid}).subscribe(
- async (response: any) => {
-
+ if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) {
+
+ this.WsChatService.deleteMessage(msgId).then(async() => {
message.delateRequest = true
await message.save()
this.deleteMessage(msgId)
+ })
- },
- async (response) => {
-
- if (response?.error?.error.startsWith('No message found with the id of')) {
+ } else {
+ this.WsChatService.registerCallback({
+ type: 'reConnect',
+ funx: async ()=> {
- this.deleteMessage(msgId)
- message.delateRequest = true
- await message.save()
-
- } else {
- this.WsChatService.registerCallback({
- type: 'reConnect',
- funx: async ()=> {
-
- this.sendDeleteRequest(msgId)
- return true
- }
- })
+ this.sendDeleteRequest(msgId)
+ return true
}
-
- }
- )
+ })
+ }
}
-
/**
* @description sen text message
*/
@@ -629,7 +611,7 @@ export class RoomService {
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
- console.log('load chatHistory', JSON.stringify(chatHistory))
+ // console.log('load chatHistory', JSON.stringify(chatHistory))
const messagesId = this.messages.map((message)=> message._id)
@@ -685,7 +667,7 @@ export class RoomService {
message = this.fix_updatedAt(message)
- const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService)
+ const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService)
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
@@ -742,7 +724,7 @@ export class RoomService {
async prepareCreate({message, save = true}): Promise
{
message = this.fix_updatedAt(message)
- const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService)
+ const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService)
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
@@ -754,7 +736,7 @@ export class RoomService {
simplePrepareMessage(message) {
message = this.fix_updatedAt(message)
- const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService)
+ const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService)
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts
index db3e320d7..82dae5b98 100644
--- a/src/app/services/chat/ws-chat-methods.service.ts
+++ b/src/app/services/chat/ws-chat-methods.service.ts
@@ -20,6 +20,7 @@ import { ChatStorageService } from './chat-storage.service'
import { ChatMethodsService } from './chat-methods.service'
import { AESEncrypt } from '../aesencrypt.service'
import { AttachmentsService } from 'src/app/services/attachments.service';
+import { NetworkServiceService} from 'src/app/services/network-service.service';
@Injectable({
providedIn: 'root'
@@ -57,7 +58,8 @@ export class WsChatMethodsService {
private ChatStorageService: ChatStorageService,
private ChatMethodsService:ChatMethodsService,
private AESEncrypt: AESEncrypt,
- private AttachmentsService:AttachmentsService
+ private AttachmentsService:AttachmentsService,
+ private NetworkServiceService: NetworkServiceService
) {
this.loggedUser = authService.ValidatedUserChat['data'];
@@ -314,7 +316,7 @@ export class WsChatMethodsService {
// create room
if(!this.roomExist(roomId)) {
- let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService , this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService)
+ let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService , this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService)
room.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
diff --git a/src/app/services/network-service.service.spec.ts b/src/app/services/network-service.service.spec.ts
new file mode 100644
index 000000000..987fc15ec
--- /dev/null
+++ b/src/app/services/network-service.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { NetworkServiceService } from './network-service.service';
+
+describe('NetworkServiceService', () => {
+ let service: NetworkServiceService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(NetworkServiceService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/services/network-service.service.ts b/src/app/services/network-service.service.ts
new file mode 100644
index 000000000..8e5e32d36
--- /dev/null
+++ b/src/app/services/network-service.service.ts
@@ -0,0 +1,62 @@
+import { Injectable } from '@angular/core';
+import { ToastController, Platform } from '@ionic/angular';
+import { BehaviorSubject, Observable } from 'rxjs';
+import { Network } from '@ionic-native/network/ngx'
+
+
+export enum ConnectionStatus {
+ Online,
+ Offline
+}
+
+
+@Injectable({
+ providedIn: 'root'
+})
+export class NetworkServiceService {
+ private status: BehaviorSubject = new BehaviorSubject(ConnectionStatus.Offline);
+
+ constructor(private network: Network, private toastController: ToastController, private plt: Platform) {
+ this.plt.ready().then(() => {
+ this.initializeNetworkEvents();
+ let status = this.network.type !== 'none' ? ConnectionStatus.Online : ConnectionStatus.Offline;
+ this.status.next(status);
+ });
+
+ }
+
+ public initializeNetworkEvents() {
+
+ this.network.onDisconnect().subscribe(() => {
+ if (this.status.getValue() === ConnectionStatus.Online) {
+ this.updateNetworkStatus(ConnectionStatus.Offline);
+ }
+ });
+
+ this.network.onConnect().subscribe(() => {
+ if (this.status.getValue() === ConnectionStatus.Offline) {
+ this.updateNetworkStatus(ConnectionStatus.Online);
+ }
+ });
+ }
+
+ private async updateNetworkStatus(status: ConnectionStatus) {
+ this.status.next(status);
+
+ let connection = status == ConnectionStatus.Offline ? 'Offline' : 'Online';
+ let toast = this.toastController.create({
+ message: `You are now ${connection}`,
+ duration: 3000,
+ position: 'bottom'
+ });
+ toast.then(toast => toast.present());
+ }
+
+ public onNetworkChange(): Observable {
+ return this.status.asObservable();
+ }
+
+ public getCurrentNetworkStatus(): ConnectionStatus {
+ return this.status.getValue();
+ }
+}
diff --git a/src/app/services/permission.service.ts b/src/app/services/permission.service.ts
index 3587a5dc6..b0ebcf48f 100644
--- a/src/app/services/permission.service.ts
+++ b/src/app/services/permission.service.ts
@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
+import { PermissionList } from '../models/permission/permissionList';
import { SessionStore } from '../store/session.service';
@Injectable({
@@ -6,6 +7,7 @@ import { SessionStore } from '../store/session.service';
})
export class PermissionService {
+ permissionList = new PermissionList();
SessionStore = SessionStore
constructor() { }
@@ -20,19 +22,17 @@ export class PermissionService {
}
userPermission(args) {
-
if(!Array.isArray(args)) {
args = [args]
}
- for(let permission of (this.SessionStore.user.UserPermissions || [])){
- if (args.includes(permission)){
+ for(let permission of (this.SessionStore.user.UserPermissions || [])) {
+ if (args.includes(permission)) {
return true;
}
}
return false;
-
}
role(args: any) {
@@ -46,7 +46,7 @@ export class PermissionService {
role = [role]
}
- if(!UserRoleIsValid) {return false }
+ if(!UserRoleIsValid) { return false }
return true
diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts
index 829ce53d3..46f3658e9 100644
--- a/src/app/shared/chat/group-messages/group-messages.page.ts
+++ b/src/app/shared/chat/group-messages/group-messages.page.ts
@@ -152,9 +152,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
ngOnInit() {
- console.log(this.roomId);
- this.loggedUser = this.loggedUserChat;
-
this.loggedUser=this.loggedUserChat;
setTimeout(() => {
this.getRoomInfo();
diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html
index 7769fc17e..06d76d173 100644
--- a/src/app/shared/header/header.page.html
+++ b/src/app/shared/header/header.page.html
@@ -66,7 +66,7 @@
-
@@ -76,7 +76,9 @@
Início
-
+
+
@@ -85,7 +87,9 @@
Agenda
-
+
+
@@ -94,7 +98,9 @@
Gabinete
-
+
+
@@ -102,7 +108,9 @@
Acções
-
+
+
diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts
index 36a61ad9c..b91aa2d7a 100644
--- a/src/app/shared/header/header.page.ts
+++ b/src/app/shared/header/header.page.ts
@@ -11,7 +11,7 @@ import { EventTrigger } from '../../services/eventTrigger.service';
import { ThemeService } from '../../services/theme.service';
import { interval } from 'rxjs';
import { RouteService } from 'src/app/services/route.service';
-import { PermissionList } from 'src/app/models/permissionList';
+import { PermissionList } from 'src/app/models/permission/permissionList';
import { PermissionService } from 'src/app/services/permission.service';
@Component({
diff --git a/src/app/shared/popover/deploma-options/deploma-options.page.ts b/src/app/shared/popover/deploma-options/deploma-options.page.ts
index f388b9636..9ba87b910 100644
--- a/src/app/shared/popover/deploma-options/deploma-options.page.ts
+++ b/src/app/shared/popover/deploma-options/deploma-options.page.ts
@@ -8,6 +8,7 @@ import { ProcessesService } from 'src/app/services/processes.service';
import { ToastService } from 'src/app/services/toast.service';
import { Location } from '@angular/common';
import { RouteService } from 'src/app/services/route.service';
+import { PermissionService } from 'src/app/services/permission.service';
@Component({
selector: 'app-deploma-options',
@@ -23,7 +24,8 @@ export class DeplomaOptionsPage implements OnInit {
fulltask: any
- constructor(public popoverController: PopoverController,
+ constructor(
+ public popoverController: PopoverController,
private modalController: ModalController,
private activatedRoute: ActivatedRoute,
private processes: ProcessesService,
@@ -31,7 +33,8 @@ export class DeplomaOptionsPage implements OnInit {
private toastService: ToastService,
private router: Router,
private deplomaService: DeplomaService,
- private RouteService: RouteService) {
+ private RouteService: RouteService,
+ public p: PermissionService,) {
this.serialNumber = this.navParams.get('serialNumber');
this.task = this.navParams.get('task');
this.fulltask = this.navParams.get('fulltask');
@@ -138,7 +141,7 @@ export class DeplomaOptionsPage implements OnInit {
modal.onDidDismiss();
}
-
+
async askSignature(note:string, documents:any) {
let body = {
"serialNumber": this.serialNumber,
@@ -162,7 +165,7 @@ export class DeplomaOptionsPage implements OnInit {
loader.remove()
}
- }
+ }
async sign(note:string, documents:any) {
diff --git a/src/app/shared/popover/despachos-options/despachos-options.page.html b/src/app/shared/popover/despachos-options/despachos-options.page.html
index 1a33fae72..7e0840c6a 100644
--- a/src/app/shared/popover/despachos-options/despachos-options.page.html
+++ b/src/app/shared/popover/despachos-options/despachos-options.page.html
@@ -28,7 +28,7 @@
Marcar como Concluído
Enviar para Reexecução
- Marcar Reunião
+ Marcar Reunião
Enviar para Pendentes
@@ -40,7 +40,7 @@
Efetuar Despacho
Solicitar Parecer
-
Marcar Reunião
+
Marcar Reunião
Enviar para Pendentes
@@ -51,7 +51,7 @@
Efetuar Despacho
Solicitar Parecer
-
Marcar Reunião
+
Marcar Reunião
Enviar para Pendentes
@@ -60,7 +60,7 @@
Efetuar Despacho
Solicitar Parecer
-
Marcar Reunião
+
Marcar Reunião
Enviar para Pendentes
Enviar para Reexecução
diff --git a/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.html b/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.html
index f46731c61..1bf5ad3aa 100644
--- a/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.html
+++ b/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.html
@@ -9,27 +9,27 @@
- Responder ao PR
- Executado
- Reencaminhar para Área jurídica
- Gerar Diploma
- Outras opções
- Efetuar Despacho
+ Responder ao PR
+ Executado
+ Reencaminhar para Área jurídica
+ Gerar Diploma
+ Outras opções
+ Efetuar Despacho
- Solicitar Parecer
+ Solicitar Parecer
- Delegar
- Enviar para pendentes
+ Delegar
+ Enviar para pendentes
Cancelar
- Marcar como Concluído
- Enviar para Reexecução
- Marcar Reunião
- Enviar para Pendentes
+ Marcar como Concluído
+ Enviar para Reexecução
+ Marcar Reunião
+ Enviar para Pendentes
Cancelar
diff --git a/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.html b/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.html
index d4515ed1b..5bfe9c8ad 100644
--- a/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.html
+++ b/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.html
@@ -8,7 +8,7 @@