mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Merge branch 'developer' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -4,6 +4,9 @@ import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js';
|
||||
import { SqliteService } from '../../../services/sqlite.service';
|
||||
import { synchro } from '../../../services/socket/synchro.service';
|
||||
import { Platform } from '@ionic/angular';
|
||||
|
||||
@Component({
|
||||
selector: 'app-all-processes',
|
||||
@@ -13,29 +16,24 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js';
|
||||
export class AllProcessesPage implements OnInit {
|
||||
|
||||
skeletonLoader = true;
|
||||
allProcessesList:any[] = [];
|
||||
allProcessesList: any[] = [];
|
||||
loggeduser: LoginUserRespose;
|
||||
|
||||
synch = synchro;
|
||||
|
||||
constructor(
|
||||
private processesService: ProcessesService,
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
private sqliteservice: SqliteService,
|
||||
private platform: Platform
|
||||
) {
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.loadAllProcesses();
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) {
|
||||
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
this.refreshing();
|
||||
} else {
|
||||
this.loadAllProcesses();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.getAllProcessFromDB()
|
||||
}
|
||||
|
||||
doRefresh() {
|
||||
@@ -52,9 +50,10 @@ export class AllProcessesPage implements OnInit {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
async loadAllProcesses(){
|
||||
let allProcessesList = await this.processesService.GetTasksList("", false).toPromise();
|
||||
async loadAllProcesses() {
|
||||
let allProcessesList = await this.processesService.GetTasksList("", false).toPromise();
|
||||
console.log(allProcessesList);
|
||||
this.addProcessToDB(allProcessesList)
|
||||
|
||||
this.skeletonLoader = true;
|
||||
|
||||
@@ -63,7 +62,8 @@ export class AllProcessesPage implements OnInit {
|
||||
allProcessesList.forEach(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();
|
||||
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
|
||||
|
||||
let task = {
|
||||
"SerialNumber": element.serialNumber,
|
||||
@@ -81,104 +81,185 @@ export class AllProcessesPage implements OnInit {
|
||||
"Agenda": element.workflowInstanceDataFields.Agenda,
|
||||
"customDate": this.setFormatDate(new Date(element.workflowInstanceDataFields.StartDate), new Date(element.workflowInstanceDataFields.EndDate), element.workflowInstanceDataFields.IsAllDayEvent),
|
||||
}
|
||||
this.allProcessesList.push(task);
|
||||
this.allProcessesList = removeDuplicate( this.allProcessesList)
|
||||
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
|
||||
this.allProcessesList.push(task);
|
||||
this.allProcessesList = removeDuplicate(this.allProcessesList)
|
||||
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
|
||||
|
||||
});
|
||||
|
||||
this.skeletonLoader = false;
|
||||
}
|
||||
|
||||
sortArrayISODate(myArray: any){
|
||||
return myArray.sort(function(a, b) {
|
||||
|
||||
addProcessToDB(data) {
|
||||
|
||||
data.forEach(element => {
|
||||
|
||||
let process = {
|
||||
"serialNumber": element.serialNumber,
|
||||
"workflowInstanceFolio": element.workflowInstanceFolio,
|
||||
"Documents": element.Documents,
|
||||
"actions": element.actions,
|
||||
"activityInstanceName": element.activityInstanceName,
|
||||
"formURL": element.formURL,
|
||||
"originator": element.originator,
|
||||
"taskStartDate": element.taskStartDate,
|
||||
"totalDocuments": element.totalDocuments,
|
||||
"workflowDisplayName": element.workflowDisplayName,
|
||||
"workflowID": element.workflowID,
|
||||
"workflowInstanceDataFields": element.workflowInstanceDataFields,
|
||||
"workflowInstanceID": element.workflowInstanceID,
|
||||
"workflowName": element.workflowName
|
||||
}
|
||||
|
||||
this.sqliteservice.addProcess(process);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
getAllProcessFromDB() {
|
||||
|
||||
if(synchro.connected === true) {
|
||||
this.loadAllProcesses();
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) {
|
||||
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
this.refreshing();
|
||||
} else {
|
||||
this.loadAllProcesses();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
|
||||
allprocess.forEach(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();
|
||||
|
||||
var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields);
|
||||
|
||||
let task = {
|
||||
"SerialNumber": element.serialNumber,
|
||||
"Folio": workflowInstanceDataFields.Subject,
|
||||
"Senders": workflowInstanceDataFields.Sender,
|
||||
"CreateDate": taskDate,
|
||||
"DocumentURL": workflowInstanceDataFields.ViewerRequest,
|
||||
"Remetente": workflowInstanceDataFields.Remetente,
|
||||
"DocumentsQty": element.totalDocuments,
|
||||
"DocId": workflowInstanceDataFields.DispatchDocId,
|
||||
"FolderID": workflowInstanceDataFields.FolderID,
|
||||
"WorkflowName": element.workflowDisplayName,
|
||||
"activityInstanceName": element.activityInstanceName,
|
||||
"Status": workflowInstanceDataFields.Status,
|
||||
"Agenda": workflowInstanceDataFields.Agenda,
|
||||
"customDate": this.setFormatDate(new Date(workflowInstanceDataFields.StartDate), new Date(workflowInstanceDataFields.EndDate), workflowInstanceDataFields.IsAllDayEvent),
|
||||
}
|
||||
|
||||
this.allProcessesList.push(task);
|
||||
this.allProcessesList = removeDuplicate(this.allProcessesList)
|
||||
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
this.allProcessesList = allprocess;
|
||||
console.log("All process from db ", allprocess)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
sortArrayISODate(myArray: any) {
|
||||
return myArray.sort(function (a, b) {
|
||||
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
|
||||
});
|
||||
}
|
||||
|
||||
setFormatDate(start:any, end:any, allday:boolean){
|
||||
setFormatDate(start: any, end: any, allday: boolean) {
|
||||
let customDate;
|
||||
/* start = new Date();
|
||||
end= new Date("2021-08-04T18:01:04.753Z"); */
|
||||
//end = new Date("2021-09-04T18:01:04.753Z");
|
||||
|
||||
const totalSeconds = Math.floor((end - (start))/1000);;
|
||||
const totalMinutes = Math.floor(totalSeconds/60);
|
||||
const totalHours = Math.floor(totalMinutes/60);
|
||||
const totalDays = Math.floor(totalHours/24);
|
||||
const totalSeconds = Math.floor((end - (start)) / 1000);;
|
||||
const totalMinutes = Math.floor(totalSeconds / 60);
|
||||
const totalHours = Math.floor(totalMinutes / 60);
|
||||
const totalDays = Math.floor(totalHours / 24);
|
||||
|
||||
const hours = totalHours - ( totalDays * 24 );
|
||||
const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
|
||||
const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
|
||||
const hours = totalHours - (totalDays * 24);
|
||||
const minutes = totalMinutes - (totalDays * 24 * 60) - (hours * 60);
|
||||
const seconds = totalSeconds - (totalDays * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60);
|
||||
|
||||
let diffDays = totalDays;
|
||||
let diffMinutes = minutes;
|
||||
|
||||
if(totalDays == 0) {
|
||||
if(allday) {
|
||||
customDate = this.getCustomDate(start)+", "+this.getCustomHours(start)+" (todo dia)";
|
||||
if (totalDays == 0) {
|
||||
if (allday) {
|
||||
customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " (todo dia)";
|
||||
console.log(customDate);
|
||||
return customDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+" ("+minutes+" mins)";
|
||||
customDate = this.getCustomDate(start)+", "+this.getCustomHours(start)+" | "+this.getCustomHours(end);
|
||||
customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " | " + this.getCustomHours(end);
|
||||
return customDate;
|
||||
}
|
||||
}
|
||||
else{
|
||||
customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+
|
||||
" (termina:"+ this.getCustomDate(end)+","+this.getCustomHours(end)+")";
|
||||
else {
|
||||
customDate = this.getCustomDate(start) + "," + this.getCustomHours(start) +
|
||||
" (termina:" + this.getCustomDate(end) + "," + this.getCustomHours(end) + ")";
|
||||
return customDate;
|
||||
}
|
||||
}
|
||||
|
||||
getCustomDate(thedate: Date){
|
||||
return (thedate.getDay()+1) + "/" +
|
||||
(thedate.getMonth()+1) + "/" +
|
||||
thedate.getFullYear();
|
||||
getCustomDate(thedate: Date) {
|
||||
return (thedate.getDay() + 1) + "/" +
|
||||
(thedate.getMonth() + 1) + "/" +
|
||||
thedate.getFullYear();
|
||||
}
|
||||
getCustomHours(thedate: Date){
|
||||
getCustomHours(thedate: Date) {
|
||||
return thedate.getHours() + ":" +
|
||||
thedate.getMinutes();
|
||||
thedate.getMinutes();
|
||||
}
|
||||
|
||||
goToProcess(serialNumber:string, workflowName:string, activityName:string){
|
||||
if(workflowName == 'Despacho') {
|
||||
if(activityName == 'Tarefa de Despacho'|| activityName == 'Concluir Despacho'){
|
||||
this.router.navigate(['/home/gabinete-digital/despachos',serialNumber,'gabinete-digital']);
|
||||
goToProcess(serialNumber: string, workflowName: string, activityName: string) {
|
||||
if (workflowName == 'Despacho') {
|
||||
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') {
|
||||
this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
}
|
||||
else if(workflowName == 'Despacho do Presidente da República') {
|
||||
if(activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho'){
|
||||
this.router.navigate(['/home/gabinete-digital/despachos-pr',serialNumber,'gabinete-digital']);
|
||||
else if (workflowName == 'Despacho do Presidente da República') {
|
||||
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') {
|
||||
this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma'){
|
||||
this.router.navigate(['/home/gabinete-digital/diplomas',serialNumber,'gabinete-digital']);
|
||||
else if (activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma') {
|
||||
this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(activityName == 'Diploma Assinado'){
|
||||
this.router.navigate(['/home/gabinete-digital/diplomas-assinar',serialNumber,'gabinete-digital']);
|
||||
else if (activityName == 'Diploma Assinado') {
|
||||
this.router.navigate(['/home/gabinete-digital/diplomas-assinar', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
}
|
||||
else if(workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']);
|
||||
else if (workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(workflowName == 'Expediente') {
|
||||
this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']);
|
||||
else if (workflowName == 'Expediente') {
|
||||
this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') {
|
||||
this.router.navigate(['/home/gabinete-digital/expedientes-pr',serialNumber,'gabinete-digital']);
|
||||
else if (workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') {
|
||||
this.router.navigate(['/home/gabinete-digital/expedientes-pr', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if (workflowName == "Pedido de Parecer do Presidente") {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']);
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
/* else if (workflowName == "Expediente") {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']);
|
||||
} */
|
||||
else if(workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR') {
|
||||
this.router.navigate(['/home/gabinete-digital/event-list/approve-event',serialNumber, 'gabinete-digital']);
|
||||
else if (workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR') {
|
||||
this.router.navigate(['/home/gabinete-digital/event-list/approve-event', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else {
|
||||
else {
|
||||
console.log('cant find page for this task')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { StorageService } from '../../services/storage.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { NotificationsService } from '../../services/notifications.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { EventTrigger } from '../../services/eventTrigger.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
@@ -33,7 +34,8 @@ export class HeaderPage implements OnInit {
|
||||
private animationController: AnimationController,
|
||||
private storageservice: StorageService,
|
||||
private platform: Platform,
|
||||
private notificationsService: NotificationsService,
|
||||
private notificationsService: NotificationsService,
|
||||
private eventrigger: EventTrigger
|
||||
) {
|
||||
this.loggeduser = SessionStore.user;
|
||||
router.events.subscribe((val) => {
|
||||
@@ -46,12 +48,20 @@ export class HeaderPage implements OnInit {
|
||||
this.hideSearch();
|
||||
this.notificationLengthData();
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
/* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
console.log('Notifications not supported')
|
||||
this.UpdateNotificationCount();
|
||||
} else {
|
||||
this.UpdateNotificationCount();
|
||||
}
|
||||
} */
|
||||
|
||||
this.eventrigger.getObservable().subscribe((data)=>{
|
||||
if(data.notification == "delete" || "recive"){
|
||||
this.notificationLengthData();
|
||||
console.log('Deleted notification',data )
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user