Merge with peter changes

This commit is contained in:
Eudes Inácio
2021-08-30 15:00:44 +01:00
37 changed files with 560 additions and 208 deletions
+4
View File
@@ -43,3 +43,7 @@ src/environments/environment.e2e.ts
.env .env
platforms_ platforms_
_platforms _platforms
src/app/store/notification.service.spec.ts
src/app/store/notification.service.ts
+12 -15
View File
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { customTask, fullTask } from '../models/dailyworktask.model'; import { customTask, fullTask, fullTaskList } from '../models/dailyworktask.model';
import { AttachmentList } from '../models/Excludetask'; import { AttachmentList } from '../models/Excludetask';
import { PermissionService } from '../OtherService/permission.service'; import { PermissionService } from '../OtherService/permission.service';
import { CustomTaskPipe } from '../pipes/custom-task.pipe'; import { CustomTaskPipe } from '../pipes/custom-task.pipe';
@@ -189,7 +189,7 @@ export class DespachoService {
} }
async getList({updateStore = false}): Promise<customTask[]> { async getList({updateStore = false}): Promise<customTask[]> | null {
if (this.LoaderService.loading) { if (this.LoaderService.loading) {
return this.despachoStore.list return this.despachoStore.list
@@ -197,21 +197,12 @@ export class DespachoService {
this.LoaderService.push({}) this.LoaderService.push({})
let result: fullTask[] = [] let result: fullTaskList[] = []
let despachoList: customTask[] = [];
try { try {
result = await this.processes.GetTasksList("Despacho", false).toPromise(); result = await this.processes.GetTasksList("Despacho", false).toPromise();
} catch (error) { result = result.filter((data:fullTaskList) => data.workflowInstanceDataFields.Status == "Active")
} finally {
this.LoaderService.pop({})
}
result = result.filter(data => data.workflowInstanceDataFields.Status == "Active")
let despachoList: customTask[] = new Array();
result.forEach((element, index) => { result.forEach((element, index) => {
let task: customTask = this.customTaskPipe.transform(element); let task: customTask = this.customTaskPipe.transform(element);
@@ -225,7 +216,13 @@ export class DespachoService {
this.despachoStore.reset(despachoList); this.despachoStore.reset(despachoList);
} }
return despachoList } catch (error) {
} finally {
this.LoaderService.pop({})
return this.despachoStore.list
}
} }
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
+4 -1
View File
@@ -17,7 +17,10 @@ export class AuthGuard implements CanActivate {
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(window.location.pathname != '' && !SessionStore.exist) { if(!SessionStore.user.Inactivity) {
this.router.navigate(['/inactivity']);
}
else if(window.location.pathname != '' && !SessionStore.exist) {
this.router.navigate(['/']); this.router.navigate(['/']);
return false return false
} else { } else {
+1 -4
View File
@@ -16,12 +16,9 @@ export class InactivityGuard implements CanActivate {
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin) { if(SessionStore.exist && SessionStore.user.Inactivity && !SessionStore.hasPin ) {
// alert('stay set pin')
return true return true
} else if(SessionStore.exist && !SessionStore.user.Inactivity) { } else if(SessionStore.exist && !SessionStore.user.Inactivity) {
// alert('stay conform')
return true return true
} else { } else {
this.router.navigate(['/home/events']); this.router.navigate(['/home/events']);
+19 -37
View File
@@ -6,32 +6,18 @@ import { Component, OnInit, NgZone } from '@angular/core';
import { Event } from '../models/event.model'; import { Event } from '../models/event.model';
import { NotificationsService } from '../services/notifications.service'; import { NotificationsService } from '../services/notifications.service';
import { WebNotificationsService } from '../services/webnotifications.service'; import { WebNotificationsService } from '../services/webnotifications.service';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service'; import { ToDayEventStorage } from '../store/to-day-event-storage.service';
import { DocumentCounterService } from 'src/app/OtherService/document-counter.service' import { DocumentCounterService } from 'src/app/OtherService/document-counter.service'
import { PermissionService } from '../OtherService/permission.service'; import { PermissionService } from '../OtherService/permission.service';
import { TotalDocumentStore } from '../store/total-document.service'; import { TotalDocumentStore } from '../store/total-document.service';
import { connection } from '../services/socket/synchro.service'; import { synchro } from '../services/socket/synchro.service';
import { DespachoService } from '../Rules/despacho.service'; import { DespachoService } from '../Rules/despacho.service';
import { ExpedienteGdStore } from '../store/expedientegd-store.service'; import { ExpedienteGdStore } from '../store/expedientegd-store.service';
import { InativityService } from '../services/inativity.service'; import { InativityService } from '../services/inativity.service';
import { SessionStore } from '../store/session.service'; import { SessionStore } from '../store/session.service';
import { StorageService } from '../services/storage.service';
// import * as Sentry from "@sentry/browser";
// import { Integrations } from "@sentry/tracing";
// Sentry.init({
// dsn: "https://b374f7c7e09a49adb04197845ded60e9@o927946.ingest.sentry.io/5877459",
// integrations: [new Integrations.BrowserTracing()],
// // Set tracesSampleRate to 1.0 to capture 100%
// // of transactions for performance monitoring.
// // We recommend adjusting this value in production
// tracesSampleRate: 1.0,
// });
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@@ -72,7 +58,7 @@ export class HomePage implements OnInit {
postEvent: any; postEvent: any;
folderId: string; folderId: string;
connection = connection synchro = synchro
constructor( constructor(
private zone: NgZone, private zone: NgZone,
@@ -85,7 +71,8 @@ export class HomePage implements OnInit {
public p: PermissionService, public p: PermissionService,
public documentCounterService: DocumentCounterService, public documentCounterService: DocumentCounterService,
private despachoRule: DespachoService, private despachoRule: DespachoService,
private inativityService: InativityService) { private inativityService: InativityService,
private storageService: StorageService,) {
this.router.events.subscribe((val) => { this.router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove()) document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
@@ -93,8 +80,9 @@ export class HomePage implements OnInit {
this.updateList() this.updateList()
window['platform'] = platform
window['inactivity/function'] = () => { window['inactivity/function'] = () => {
if(window.location.pathname != '/inactivity') { if(window.location.pathname != '/inactivity') {
const pathname = window.location.pathname const pathname = window.location.pathname
@@ -103,25 +91,18 @@ export class HomePage implements OnInit {
} }
} }
var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url) );
// if (typeof Worker !== 'undefined') { myWorker.onmessage = function(oEvent) {
// // Create a new console.log('Worker said : ' + oEvent.data);
// const worker = new Worker(new URL('./nice.worker.ts', import.meta.url)); }
// worker.onmessage = ({ data }) => {
// console.log(`page got message: ${data}`); myWorker.postMessage('ali');
// };
// worker.postMessage('hello');
// } else {
// // Web workers are not supported in this environment.
// // You should add a fallback so that your program still executes correctly.
// }
} }
refreshing() { refreshing() {}
}
ngOnInit() { ngOnInit() {
/* this.network.checkNetworkConnection; /* this.network.checkNetworkConnection;
@@ -137,9 +118,6 @@ export class HomePage implements OnInit {
} }
} }
mobilefirstConnect() { mobilefirstConnect() {
if(window['WLAuthorizationManager']) { if(window['WLAuthorizationManager']) {
@@ -184,6 +162,10 @@ export class HomePage implements OnInit {
} }
) )
synchro.registerCallback('Notification', (notification)=> {
console.log('notification====== £=======£==========£======', notification)
}, 'any')
} }
} }
+5
View File
@@ -0,0 +1,5 @@
postMessage("I\'m working before postMessage(\'ali\').");
onmessage = function(oEvent) {
postMessage('Hi ' + oEvent.data);
};
-6
View File
@@ -1,6 +0,0 @@
// / <reference lib="webworker" />
addEventListener('message', ({ data }) => {
const response = `worker response to ${data}`;
//postMessage(response);
});
@@ -546,7 +546,7 @@ export class CreateProcessPage implements OnInit {
taskParticipants: this.taskParticipants, taskParticipants: this.taskParticipants,
taskParticipantsCc: this.taskParticipantsCc taskParticipantsCc: this.taskParticipantsCc
}, },
cssClass: 'attendee', cssClass: 'attendee modal-desktop',
backdropDismiss: false backdropDismiss: false
}); });
+1 -1
View File
@@ -28,7 +28,7 @@
</ion-buttons> </ion-buttons>
</div> </div>
<div class="line"></div> <div class="line"></div>
<ion-label>{{notificationdata.length}} novas notificações</ion-label> <ion-label (click)="asyncNotification()">{{notificationdata.length}} novas notificações</ion-label>
</div> </div>
</ion-header> </ion-header>
+5 -2
View File
@@ -10,6 +10,7 @@ import { EditProfilePage } from './edit-profile/edit-profile.page';
import { JsonStore } from '../../services/jsonStore.service'; import { JsonStore } from '../../services/jsonStore.service';
import { StorageService } from '../../services/storage.service'; import { StorageService } from '../../services/storage.service';
import { NotificationsService } from '../../services/notifications.service'; import { NotificationsService } from '../../services/notifications.service';
import { SessionStore } from 'src/app/store/session.service';
@Component({ @Component({
selector: 'app-profile', selector: 'app-profile',
@@ -65,6 +66,8 @@ export class ProfilePage implements OnInit {
notImplemented() { } notImplemented() { }
asyncNotification(){}
async getNotificationData(){ async getNotificationData(){
this.storageservice.get("Notifications").then((value) => { this.storageservice.get("Notifications").then((value) => {
console.log("Init get store", value) console.log("Init get store", value)
@@ -201,10 +204,10 @@ export class ProfilePage implements OnInit {
} }
logout() { logout() {
window.localStorage.clear(); SessionStore.setInativity(false)
setTimeout(() => { setTimeout(() => {
this.router.navigateByUrl('/', { replaceUrl: true }); this.router.navigate(['/inactivity']);
}, 100) }, 100)
} }
+28
View File
@@ -67,6 +67,34 @@ export class fullTask {
workflowName: string workflowName: string
} }
export interface fullTaskList {
serialNumber: string;
taskStartDate: string;
workflowDisplayName: string;
activityInstanceName: string;
totalDocuments: number;
workflowInstanceDataFields: {
Subject: string;
Sender: string;
FolderID: number;
DispatchDocId: number;
Status: string;
// all list
ViewerRequest?: any
Remetente?: any
Agenda?: any // event to approve
StartDate?: any // event to approve
EndDate?: any // event to approve
InstanceId?: string // event to approve
Location?: string // event to approve
IsAllDayEvent?: any // event to approve
// pedidos
DocIdDiferimento?: any
// pedidos deferimento // Despacho do Presidente da República
originator?: any
}
}
export class customFullTask { export class customFullTask {
serialNumber: string; serialNumber: string;
taskStartDate: string; taskStartDate: string;
+57 -1
View File
@@ -127,6 +127,7 @@ export interface EventToApproveEdit {
MDEmail: string; MDEmail: string;
IsAllDayEvent: boolean; IsAllDayEvent: boolean;
Status: string; Status: string;
Category: string
EventType: string; EventType: string;
IsRecurring: boolean; IsRecurring: boolean;
ParticipantsList: ParticipantsList[]; ParticipantsList: ParticipantsList[];
@@ -140,4 +141,59 @@ export interface EventToApproveEdit {
InstanceId?: string; InstanceId?: string;
} }
// ================================================================================ // // ================================================================================
// export interface EventToApproveDetails {
// serialNumber: string;
// originator: {
// email: string;
// manager: string;
// displayName: string;
// fqn: string;
// username: string;
// }[]
// actions: string[];
// activityInstanceName: string;
// workflowInstanceFolio: string;
// taskStartDate: string;
// workflowID: number;
// workflowInstanceID: number;
// workflowName: string;
// workflowDisplayName: string;
// formURL: string;
// workflowInstanceDataFields: {
// Body: string;
// Location: string;
// Subject: string;
// StartDate: string;
// EndDate: string;
// Participants: string;
// CC: string;
// Private: boolean;
// ReviewUserComment: string;
// MDName: string;
// MDEmail: string;
// OriginatorComments: string;
// Agenda: string;
// EventType: string;
// TimeZone: string;
// EventID: string;
// HasAttachments: boolean;
// ParticipantsList: {
// $type?: any;
// EmailAddress: string;
// Name: string;
// IsRequired: boolean;
// }[]
// EventOrganizer: string;
// CreatEvent: string;
// IsAllDayEvent: boolean;
// MDwxUserID: number;
// SerializedItem: string;
// DeserializedItem: string;
// Status: string;
// Message: string;
// InstanceId: string;
// }
// totalDocuments?: any;
// Documents?: any;
// }
+1 -2
View File
@@ -1,7 +1,6 @@
import { Component, OnInit, ViewChild, Inject, LOCALE_ID, Input } from '@angular/core'; import { Component, OnInit, ViewChild, Inject, LOCALE_ID } from '@angular/core';
import { CalendarComponent } from 'ionic2-calendar'; import { CalendarComponent } from 'ionic2-calendar';
import { AlertController, ModalController } from '@ionic/angular'; import { AlertController, ModalController } from '@ionic/angular';
import { formatDate } from '@angular/common';
import { EventsService } from 'src/app/services/events.service'; import { EventsService } from 'src/app/services/events.service';
import { Event } from '../../models/event.model'; import { Event } from '../../models/event.model';
import { Router, NavigationEnd } from '@angular/router'; import { Router, NavigationEnd } from '@angular/router';
@@ -265,7 +265,7 @@ export class EditEventPage implements OnInit {
taskParticipants: this.taskParticipants, taskParticipants: this.taskParticipants,
taskParticipantsCc: this.taskParticipantsCc taskParticipantsCc: this.taskParticipantsCc
}, },
cssClass: 'attendee', cssClass: 'modal attendee modal-desktop',
backdropDismiss: false backdropDismiss: false
}); });
@@ -279,9 +279,14 @@ export class EditEventPage implements OnInit {
const newAttendees: EventPerson[] = data['taskParticipants']; const newAttendees: EventPerson[] = data['taskParticipants'];
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
if(newAttendees.length) {
this.setIntervenient(newAttendees); this.setIntervenient(newAttendees);
}
if(newAttendeesCC) {
this.setIntervenientCC(newAttendeesCC); this.setIntervenientCC(newAttendeesCC);
} }
}
}); });
} }
@@ -296,9 +296,9 @@ export class NewEventPage implements OnInit {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: AttendeesPageModal, component: AttendeesPageModal,
componentProps: { componentProps: {
eventAttendees: this.postEvent.Attendees,
adding: this.adding, adding: this.adding,
taskParticipants: this.taskParticipants taskParticipants: this.taskParticipants,
taskParticipantsCc: this.taskParticipantsCc
}, },
cssClass: 'attendee modal modal-desktop', cssClass: 'attendee modal modal-desktop',
backdropDismiss: false backdropDismiss: false
@@ -308,19 +308,27 @@ export class NewEventPage implements OnInit {
modal.onDidDismiss().then((data) => { modal.onDidDismiss().then((data) => {
if(data){ if(data) {
data = data['data']; data = data['data'];
if(data) {
const newAttendees: EventPerson[] = data['taskParticipants']; const newAttendees: EventPerson[] = data['taskParticipants'];
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
if(newAttendees.length) {
this.setIntervenient(newAttendees); this.setIntervenient(newAttendees);
}
if(newAttendeesCC) {
this.setIntervenientCC(newAttendeesCC); this.setIntervenientCC(newAttendeesCC);
} }
}
}
}); });
} }
setIntervenient(data){ setIntervenient(data) {
this.taskParticipants = data; this.taskParticipants = data;
this.postEvent.Attendees = data; this.postEvent.Attendees = data;
} }
@@ -329,7 +337,7 @@ export class NewEventPage implements OnInit {
this.taskParticipantsCc = data; this.taskParticipantsCc = data;
} }
addParticipants(){ addParticipants() {
this.adding = 'intervenient' this.adding = 'intervenient'
this.openAttendees(); this.openAttendees();
} }
+3 -3
View File
@@ -5,7 +5,7 @@ import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page
import { AlertService } from 'src/app/services/alert.service'; import { AlertService } from 'src/app/services/alert.service';
import { AuthService } from 'src/app/services/auth.service'; import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { connection } from 'src/app/services/socket/synchro.service'; import { synchro } from 'src/app/services/socket/synchro.service';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page'; import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page';
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page'; import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
@@ -33,7 +33,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
members:any; members:any;
scrollingOnce:boolean = true; scrollingOnce:boolean = true;
connection = connection; synchro = synchro;
chatMessageStore = ChatMessageStore chatMessageStore = ChatMessageStore
chatUserStorage = ChatUserStorage chatUserStorage = ChatUserStorage
@@ -258,7 +258,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
if (res == 502) { if (res == 502) {
// Connection timeout // Connection timeout
// happens when the connection was pending for too long // happens when the synchro was pending for too long
// let's reconnect // let's reconnect
await this.serverLongPull(); await this.serverLongPull();
} else if (res != 200) { } else if (res != 200) {
@@ -461,7 +461,10 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
let despachos = await this.despachoRule.getList({updateStore: true}) let despachos = await this.despachoRule.getList({updateStore: true})
if(despachos) {
this.despachoStore.reset(despachos) this.despachoStore.reset(despachos)
}
let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise(); 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 pareceresPr = await this.processesbackend.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
@@ -79,10 +79,12 @@ export class InactivityPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
await this.authService.loginChat(this.userattempt); await this.authService.loginChat(this.userattempt);
await this.getToken(); await this.getToken();
SessionStore.setInativity(true)
this.goback() this.goback()
} else { } else {
SessionStore.delete() SessionStore.delete()
window.localStorage.clear();
await this.authService.SetSession(attempt, this.userattempt); await this.authService.SetSession(attempt, this.userattempt);
} }
-2
View File
@@ -6,7 +6,6 @@ import { ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { AlertController } from '@ionic/angular'; import { AlertController } from '@ionic/angular';
import { NotificationsService } from 'src/app/services/notifications.service'; import { NotificationsService } from 'src/app/services/notifications.service';
import crypto from 'crypto-js'
import { LocalstoreService } from 'src/app/store/localstore.service'; import { LocalstoreService } from 'src/app/store/localstore.service';
import { SessionStore } from 'src/app/store/session.service'; import { SessionStore } from 'src/app/store/session.service';
@@ -40,7 +39,6 @@ export class LoginPage implements OnInit {
ngOnInit() { ngOnInit() {
let userData = this.sessionStore.user let userData = this.sessionStore.user
const loginPreference = userData?.LoginPreference const loginPreference = userData?.LoginPreference
-31
View File
@@ -1,31 +0,0 @@
import { Injectable } from '@angular/core';
import { Network } from '@ionic-native/network/ngx';
import { Platform } from '@ionic/angular';
import { fromEvent, merge, of, Observable } from 'rxjs';
import { mapTo } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class NetworkService {
constructor(
private network: Network) { }
checkNetworkConnection(){
this.network.onConnect().subscribe((value) => {
document.body.style.setProperty(`--color`, "#0782C9");
console.log('network connected!',value);
});
}
checkNetworkDisconnection(){
this.network.onDisconnect().subscribe((value) => {
document.body.style.setProperty(`--color`, "#eeeb30");
console.log('network was disconnected :-('),value;
});
}
}
+15 -5
View File
@@ -13,6 +13,7 @@ import { NavigationExtras,Router } from '@angular/router';
import { ToastService } from '../services/toast.service'; import { ToastService } from '../services/toast.service';
import { Optional } from '@angular/core'; import { Optional } from '@angular/core';
import { JsonStore } from './jsonStore.service'; import { JsonStore } from './jsonStore.service';
import { synchro } from './socket/synchro.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -39,13 +40,15 @@ export class NotificationsService {
private toastService: ToastService, private toastService: ToastService,
private zone: NgZone, private zone: NgZone,
private activeroute: ActivatedRoute, private activeroute: ActivatedRoute,
private jsonstore: JsonStore) { private jsonstore: JsonStore) { }
registerCallback(type: string, funx: Function, object: any = {} ) {
this.callbacks.push({type, funx})
if(!object.hasOwnProperty('desktop') && object['desktop'] != false) {
synchro.registerCallback('Notification',funx, type)
} }
registerCallback(type: string, funx: Function ) {
this.callbacks.push({type, funx})
} }
getTokenByUserIdAndId(user, userID) { getTokenByUserIdAndId(user, userID) {
@@ -168,8 +171,12 @@ export class NotificationsService {
console.log('Push notification recived: failure ' + error.responseText); console.log('Push notification recived: failure ' + error.responseText);
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
} }
); )
} else {
console.log('not called')
} }
} else {
console.log('not called')
} }
@@ -216,6 +223,9 @@ export class NotificationsService {
console.log(message); console.log(message);
var data = JSON.parse(message.payload); var data = JSON.parse(message.payload);
synchro.$send(data)
console.log('data.Service', data.Service); // module console.log('data.Service', data.Service); // module
console.log('data.IdObject', data.IdObject); // Object id console.log('data.IdObject', data.IdObject); // Object id
console.log('data.Object', data.Object); // details console.log('data.Object', data.Object); // details
@@ -1,13 +1,13 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { NetworkService } from './network.service'; import { ObjectQueryService } from './object-query.service';
describe('NavigationService', () => { describe('ObjectQueryService', () => {
let service: NetworkService; let service: ObjectQueryService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); TestBed.configureTestingModule({});
service = TestBed.inject(NetworkService); service = TestBed.inject(ObjectQueryService);
}); });
it('should be created', () => { it('should be created', () => {
+60
View File
@@ -0,0 +1,60 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ObjectQueryService {
data : any[] = []
save: Function = () =>{}
constructor() {}
Update(select:Function, update:Function, data: any[] = this.data ) {
let changes = 0
data.forEach((e)=> {
if(select(e)) {
changes++
update(e)
}
})
if(changes != 0) {
this.save()
}
}
select(select:Function, data: any[] = this.data ) {
return data.filter((e)=>{
return select(e)
})
}
Delete(select:Function, data: any[] = this.data) {
let changes = 0
data.forEach((e, index)=>{
if(select(e)) {
if (index > -1) {
changes++
data.splice(index, 1);
}
}
})
if(changes != 0) this.save()
}
Insert(inert:any, data: any[] = this.data ) {
data.push(inert)
}
print() {
console.log(this.data)
}
}
+3 -2
View File
@@ -8,6 +8,7 @@ import { DocumentSetUpMeeting } from '../models/CallMeeting';
import { Excludetask } from '../models/Excludetask'; import { Excludetask } from '../models/Excludetask';
import { ExpedienteFullTask } from '../models/Expediente'; import { ExpedienteFullTask } from '../models/Expediente';
import { GetTasksListType } from '../models/GetTasksListType'; import { GetTasksListType } from '../models/GetTasksListType';
import { fullTaskList } from '../models/dailyworktask.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -24,7 +25,7 @@ export class ProcessesService {
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
} }
GetTasksList(processname: typeof GetTasksListType, onlycount:boolean): Observable<any> GetTasksList(processname: typeof GetTasksListType, onlycount:boolean): Observable<fullTaskList[]>
{ {
const geturl = environment.apiURL + 'tasks/List'; const geturl = environment.apiURL + 'tasks/List';
let params = new HttpParams(); let params = new HttpParams();
@@ -37,7 +38,7 @@ export class ProcessesService {
params: params params: params
}; };
return this.http.get<any>(`${geturl}`, options); return this.http.get<fullTaskList[]>(`${geturl}`, options);
} }
GetTaskListExpediente(onlycount1): Observable<ExpedienteFullTask[]> { GetTaskListExpediente(onlycount1): Observable<ExpedienteFullTask[]> {
+68 -12
View File
@@ -1,6 +1,8 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { SessionStore } from 'src/app/store/session.service';
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { BackgroundService } from '../background.service'; import { BackgroundService } from '../background.service';
import { environment } from 'src/environments/environment';
export interface wss{ export interface wss{
@@ -17,7 +19,7 @@ export interface wss{
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class SynchroService { class SynchroService {
[x: string]: any; [x: string]: any;
private connection!: WebSocket; private connection!: WebSocket;
@@ -27,10 +29,12 @@ export class SynchroService {
callback = function(){} callback = function(){}
private _connected = false; private _connected = false;
private BackgroundService = new BackgroundService() private BackgroundService = new BackgroundService()
private callBacks: { callBacks: {
type: 'Offline' | 'Online' type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notification' | 'Notifications' | '',
object?: string
funx: Function funx: Function
}[] = [] }[] = []
private msgQueue = []
constructor(){} constructor(){}
@@ -55,10 +59,11 @@ export class SynchroService {
this.url = `${wss.url}${wss.header.id}/${wss.header.jwt}/${wss.header.bluePrint}/${this.id}/` this.url = `${wss.url}${wss.header.id}/${wss.header.jwt}/${wss.header.bluePrint}/${this.id}/`
} }
registerCallback(type: 'Offline' | 'Online', funx: Function) { registerCallback(type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notifications' | 'Notification', funx: Function, object='') {
this.callBacks.push({ this.callBacks.push({
type, type,
funx funx,
object
}) })
} }
@@ -85,22 +90,72 @@ export class SynchroService {
console.log('open ======================= welcome to socket server') console.log('open ======================= welcome to socket server')
this._connected = true this._connected = true
// send all saved data due to internet connection
this.msgQueue.forEach((item, index, object) => {
this.$send(item);
object.splice(index, 1);
})
} }
public $send(object: any) { public $send(object: any) {
let message = { if(!this._connected) { // save data to send when back online
message: '{"person.adress.country":"1Angola"}', this.msgQueue.push(object)
username: '', }
let payload = {
message: JSON.stringify(object) || '{"person.adress.country":"1Angola"}',
username: SessionStore.user.FullName,
idConnection: this.id idConnection: this.id
} }
let sendData = JSON.stringify(Object.assign({}, message));
let sendData = JSON.stringify(payload);
console.log(sendData)
this.connection.send(sendData); this.connection.send(sendData);
} }
private onmessage = async (event: any)=> { private onmessage = async (event: any)=> {
let data = JSON.parse(event.data)
let payload = JSON.parse(data.message)
payload.message = JSON.parse(payload.message)
const idConnection = payload.idConnection
const username = payload.username
if(idConnection != this.id ) {
if(window['platform'].is('desktop') || this.platform.is('mobileweb')) {}
else return false
if(environment.production) return false
this.callBacks.forEach((e)=> {
if(payload.message[0]) {
if(payload.message[0].Service && payload.message[0].Object && payload.message[0].IdObject) {
if(e.type == '' && !e.object) {
if(username == SessionStore.user.FullName) {
e.funx(payload.message, data)
}
}
if(e.type == 'Notifications' ) {
e.funx(payload.message, data)
}
}
} else if(payload.message.Service && payload.message.Object && payload.message.IdObject) {
if(e.type == 'Notification' && e.object == payload.message.Object || e.type == 'Notification' && e.object == 'any' ) {
e.funx(payload.message, data)
}
}
})
}
this.callback() this.callback()
} }
@@ -137,7 +192,8 @@ export class SynchroService {
} }
export const connection = new SynchroService() export const synchro = new SynchroService()
connection.setUrl() synchro.setUrl()
connection.connect() synchro.connect()
window['synchro'] = synchro
@@ -87,6 +87,48 @@
</div> </div>
</div> </div>
<div class="container-div">
<div class="ion-item-class-2">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class" [class.input-error]="Form?.get('Categories')?.invalid && validateFrom ">
<ion-select placeholder="Selecione tipo de evento*"
class="d-block d-md-none"
[(ngModel)]="eventProcess.workflowInstanceDataFields.Category"
interface="action-sheet"
Cancel-text="Cancelar" required>
<ion-select-option value="Reunião">Reunião</ion-select-option>
<ion-select-option value="Viagem">Viagem</ion-select-option>
<ion-select-option value="Conferência">Conferência</ion-select-option>
<ion-select-option value="Encontro">Encontro</ion-select-option>
</ion-select>
<mat-form-field class="d-none d-md-block" appearance="none" class="width-100" placeholder="Sample Type" required>
<!-- <input matInput type="text" > -->
<mat-select [(ngModel)]="eventProcess.workflowInstanceDataFields.Category" >
<mat-option value="Reunião">
Reunião
</mat-option>
<mat-option value="Viagem">
Viagem
</mat-option>
<mat-option value="Conferência">
Conferência
</mat-option>
<mat-option value="Encontro">
Encontro
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
<div *ngIf="Form && validateFrom" > <div *ngIf="Form && validateFrom" >
<div *ngIf="Form.get('participantes').invalid " class="input-errror-message"> <div *ngIf="Form.get('participantes').invalid " class="input-errror-message">
<div *ngIf="Form.get('participantes').errors?.required"> <div *ngIf="Form.get('participantes').errors?.required">
@@ -72,6 +72,7 @@ export class EditEventToApprovePage implements OnInit {
workflowInstanceDataFields:{ workflowInstanceDataFields:{
Body: "", Body: "",
OccurrenceType: '', OccurrenceType: '',
Category: '',
LastOccurrence: '', LastOccurrence: '',
IsRecurring: false, IsRecurring: false,
ParticipantsList: [], ParticipantsList: [],
@@ -146,7 +147,7 @@ export class EditEventToApprovePage implements OnInit {
async getTask() { async getTask() {
this.processes.GetTask(this.serialNumber).subscribe( result =>{ this.processes.GetTask(this.serialNumber).subscribe( (result) =>{
this.eventProcess = result this.eventProcess = result
this.restoreDatepickerData() this.restoreDatepickerData()
@@ -302,6 +303,7 @@ export class EditEventToApprovePage implements OnInit {
LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence, LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence,
}, },
ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList, ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList,
Category: this.eventProcess.workflowInstanceDataFields.Category
} }
try { try {
@@ -55,7 +55,7 @@
</div> </div>
</div> </div>
123123
<div class="container-div"> <div class="container-div">
<div class="ion-item-class-2 width-100 d-flex"> <div class="ion-item-class-2 width-100 d-flex">
<div class="ion-icon-class"> <div class="ion-icon-class">
@@ -8,7 +8,7 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page'; import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
import { ContactsPage } from '../new-group/contacts/contacts.page'; import { ContactsPage } from '../new-group/contacts/contacts.page';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { connection } from 'src/app/services/socket/synchro.service'; import { synchro } from 'src/app/services/socket/synchro.service';
import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page'; import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page';
import { ChatMessageStore } from 'src/app/store/chat/chat-message.service'; import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service'; import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
@@ -39,7 +39,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
@Output() openNewEventPage:EventEmitter<any> = new EventEmitter<any>(); @Output() openNewEventPage:EventEmitter<any> = new EventEmitter<any>();
connection = connection; synchro = synchro;
chatMessageStore = ChatMessageStore chatMessageStore = ChatMessageStore
chatUserStorage = ChatUserStorage chatUserStorage = ChatUserStorage
@@ -152,7 +152,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
sendMessage() { sendMessage() {
this.connection.$send({}) this.synchro.$send({})
let body = { let body = {
"message": "message":
@@ -68,6 +68,49 @@
</div> </div>
</div> </div>
<div class="container-div width-100">
<div class="ion-item-class-2">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class" [class.input-error]="Form?.get('Categories')?.invalid && validateFrom ">
<ion-select placeholder="Selecione tipo de evento*"
class="d-block d-md-none"
[(ngModel)]="eventProcess.workflowInstanceDataFields.Category"
interface="action-sheet"
Cancel-text="Cancelar" required>
<ion-select-option value="Reunião">Reunião</ion-select-option>
<ion-select-option value="Viagem">Viagem</ion-select-option>
<ion-select-option value="Conferência">Conferência</ion-select-option>
<ion-select-option value="Encontro">Encontro</ion-select-option>
</ion-select>
<mat-form-field class="d-none d-md-block" appearance="none" class="width-100" placeholder="Sample Type" required>
<!-- <input matInput type="text" > -->
<mat-select [(ngModel)]="eventProcess.workflowInstanceDataFields.Category" >
<mat-option value="Reunião">
Reunião
</mat-option>
<mat-option value="Viagem">
Viagem
</mat-option>
<mat-option value="Conferência">
Conferência
</mat-option>
<mat-option value="Encontro">
Encontro
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
<div class="container-div width-100"> <div class="container-div width-100">
<div class="ion-item-class-2 width-100"> <div class="ion-item-class-2 width-100">
<div class="ion-icon-class"> <div class="ion-icon-class">
@@ -68,6 +68,7 @@ export class EditEventToApproveComponent implements OnInit {
workflowInstanceDataFields:{ workflowInstanceDataFields:{
Body: "", Body: "",
OccurrenceType: '', OccurrenceType: '',
Category: '',
LastOccurrence: '', LastOccurrence: '',
ParticipantsList: [], ParticipantsList: [],
Agenda: '', Agenda: '',
@@ -135,6 +136,7 @@ export class EditEventToApproveComponent implements OnInit {
console.log(result); console.log(result);
this.eventProcess = result this.eventProcess = result
this.eventProcess.workflowInstanceDataFields.Category = result.workflowInstanceDataFields.EventType
this.startDate = new Date(this.eventProcess.workflowInstanceDataFields.StartDate); this.startDate = new Date(this.eventProcess.workflowInstanceDataFields.StartDate);
this.endDate = new Date(this.eventProcess.workflowInstanceDataFields.EndDate); this.endDate = new Date(this.eventProcess.workflowInstanceDataFields.EndDate);
@@ -254,6 +256,7 @@ export class EditEventToApproveComponent implements OnInit {
LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence, LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence,
}, },
ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList, ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList,
Category: this.eventProcess.workflowInstanceDataFields.Category
} }
console.log(event); console.log(event);
@@ -307,15 +310,20 @@ export class EditEventToApproveComponent implements OnInit {
modal.onDidDismiss().then((data) => { modal.onDidDismiss().then((data) => {
if(data){ if(data) {
data = data['data']; data = data['data'];
const newAttendees: EventPerson[] = data['taskParticipants']; const newAttendees: EventPerson[] = data['taskParticipants'];
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
if(newAttendees.length) {
this.setIntervenient(newAttendees); this.setIntervenient(newAttendees);
}
if(newAttendeesCC) {
this.setIntervenientCC(newAttendeesCC); this.setIntervenientCC(newAttendeesCC);
} }
}
}); });
} else { } else {
this.showAttendees = true this.showAttendees = true
+7 -1
View File
@@ -77,8 +77,14 @@
</div> </div>
<div class="div-profile d-flex cursor-pointer" (click)="openProfile()"> <div class="div-profile d-flex cursor-pointer" (click)="openProfile()">
<ion-icon class="icon" src='assets/images/icons-profile.svg'></ion-icon> <ion-icon class="icon" src='assets/images/icons-profile.svg'></ion-icon>
<ion-label class="profile-text">{{profileLabel(loggeduser.Profile)}}</ion-label>
<div class="profile-text">
<ion-label>{{profileLabel(loggeduser.Profile)}}</ion-label>
<div *ngIf="this.notificationLength > 0 && !production" class="icon-badge" style="right: -18px;top: -9px;" >{{this.notificationLength}}</div>
</div>
</div> </div>
</div> </div>
</div> </div>
+5 -3
View File
@@ -7,6 +7,7 @@ import { ProfilePage } from 'src/app/modals/profile/profile.page';
import { StorageService } from '../../services/storage.service'; import { StorageService } from '../../services/storage.service';
import { SessionStore } from 'src/app/store/session.service'; import { SessionStore } from 'src/app/store/session.service';
import { NotificationsService } from '../../services/notifications.service'; import { NotificationsService } from '../../services/notifications.service';
import { environment } from 'src/environments/environment';
@Component({ @Component({
selector: 'app-header', selector: 'app-header',
@@ -24,6 +25,8 @@ export class HeaderPage implements OnInit {
notificationLength: 0; notificationLength: 0;
SessionStore = SessionStore SessionStore = SessionStore
production = environment.production
constructor( constructor(
private router: Router, private router: Router,
private modalController: ModalController, private modalController: ModalController,
@@ -47,8 +50,6 @@ export class HeaderPage implements OnInit {
this.UpdateNotificationCount(); this.UpdateNotificationCount();
} }
} }
UpdateNotificationCount() { UpdateNotificationCount() {
@@ -154,7 +155,8 @@ export class HeaderPage implements OnInit {
componentProps: { componentProps: {
} }
}); });
return await modal.present(); await modal.present();
} }
async dynamicSearch() { async dynamicSearch() {
@@ -26,7 +26,7 @@ export class ProfileComponent implements OnInit {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
console.log(this.loggeduser.RoleDescription) // console.log(this.loggeduser.RoleDescription)
this.checkState() this.checkState()
} }
+77 -8
View File
@@ -1,7 +1,8 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { localstoreService } from './localstore.service' import { localstoreService } from './localstore.service'
import { AES, enc, SHA1 } from 'crypto-js' import { SHA1 } from 'crypto-js'
import { customTask } from '../models/dailyworktask.model'; import { customTask } from '../models/dailyworktask.model';
import { ObjectQueryService } from '../services/object-query.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -14,10 +15,12 @@ export class DespachoStoreService {
private keyName: string; private keyName: string;
private _count = 0 private _count = 0
ObjectQueryService = new ObjectQueryService()
constructor() { constructor() {
this.keyName = (SHA1(this.constructor.name+ 'home/eventSource')).toString() this.keyName = (SHA1(this.constructor.name+ 'home/eventSource')).toString()
window['ObjectQueryService'] = this.Query()
setTimeout(()=>{ setTimeout(()=>{
let restore = localstoreService.get(this.keyName, {}) let restore = localstoreService.get(this.keyName, {})
@@ -25,9 +28,72 @@ export class DespachoStoreService {
this._count = parseInt(restore.count) || 0 this._count = parseInt(restore.count) || 0
}, 10) }, 10)
setTimeout(()=>{
// this.Query().Update(
// (select:customTask): boolean => select.Folio == 'Formação',
// (update:customTask) => update.Folio = 'Formação 5'
// )
// this.Query().Update(
// (select:customTask): boolean => select.Folio == 'Formação',
// (update:customTask) => {
// update.Folio = 'Formação 7';
// update.DocumentURL = 'peter';
// }
// )
// this.Query().Update(
// (select:customTask): boolean => select.Folio == 'Formação',
// (update:customTask): customTask => ({
// CreateDate: '',
// DocId: 0,
// DocumentURL: '',
// DocumentsQty: '',
// FolderID: 0,
// Folio:' ',
// Remetente: '',
// Senders: '',
// SerialNumber: '',
// Status: '',
// WorkflowName: '',
// activityInstanceName: ''
// })
// )
// this.Query().Delete(
// (select: customTask): boolean => select.DocId == 3 && select.DocId >= 1
// )
}, 5000)
} }
get list() { Query() {
return {
Update: (select:Function, update:Function) => {
this.ObjectQueryService.Update(select, update, this._list )
this.save({dynamicCount : true})
},
select: (select) => {
this.ObjectQueryService.select(select, this._list )
this.save({dynamicCount : true})
},
Delete : (select) => {
this.ObjectQueryService.Delete(select, this._list )
this.save({dynamicCount : true})
},
Insert: (insert: customTask | customTask[]) =>{
this.ObjectQueryService.Insert(insert, this._list)
this.save({dynamicCount : true})
}
}
}
ObjectQuery() {}
get list(): customTask[] {
return this._list || [] return this._list || []
} }
@@ -37,17 +103,20 @@ export class DespachoStoreService {
set count(value: number) { set count(value: number) {
this._count = value this._count = value
this.save() this.save({})
} }
reset(eventsList: any) { reset(eventsList: any) {
this._list = eventsList this._list = eventsList
this.save({dynamicCount:true})
this.count = this._list.length }
this.save()
private save = ({dynamicCount = false})=> {
if(dynamicCount) {
this._count = this._list.length
} }
private save() {
setTimeout(()=>{ setTimeout(()=>{
localstoreService.set(this.keyName,{ localstoreService.set(this.keyName,{
list: this._list, list: this._list,
+2 -2
View File
@@ -13,7 +13,6 @@ class SessionService {
private _user = new UserSession() private _user = new UserSession()
// local storage keyName // local storage keyName
private keyName: string; private keyName: string;
private _needTovalidateUser = false
constructor() { constructor() {
@@ -53,7 +52,7 @@ class SessionService {
return this._user.PIN == SHA1(pin).toString() return this._user.PIN == SHA1(pin).toString()
} }
needTovalidateUser() { needToValidateUser() {
return this._user.Inactivity return this._user.Inactivity
} }
@@ -73,6 +72,7 @@ class SessionService {
return false return false
} }
return this._user.PIN.length >= 2 return this._user.PIN.length >= 2
} }
reset(user) { reset(user) {
+1 -1
View File
@@ -10,7 +10,7 @@ export const environment = {
/* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */ /* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */
domain: 'gabinetedigital.local', //gabinetedigital.local domain: 'gabinetedigital.local', //gabinetedigital.local
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local
defaultuserpwd: 'tabteste@006' //tabteste@006 defaultuserpwd: 'tabteste@006', //tabteste@006,
}; };
/* /*