mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
Inicio page is offline
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AlertController, ModalController, PopoverController } from '@ionic/angular';
|
||||
import { AlertController, ModalController, PopoverController, Platform } from '@ionic/angular';
|
||||
import { EventBody } from 'src/app/models/eventbody.model';
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
@@ -12,6 +12,8 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page';
|
||||
import { Location } from '@angular/common'
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { synchro } from '../../../services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-event',
|
||||
@@ -42,6 +44,7 @@ export class ViewEventPage implements OnInit {
|
||||
dicIndex = 0;
|
||||
isModal = false
|
||||
header = true
|
||||
synch = synchro;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
@@ -55,7 +58,11 @@ export class ViewEventPage implements OnInit {
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toastService: ToastService,
|
||||
private location: Location
|
||||
private location: Location,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService
|
||||
|
||||
|
||||
)
|
||||
{
|
||||
this.isEventEdited = false;
|
||||
@@ -88,8 +95,29 @@ export class ViewEventPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.loadEvent();
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.loadEvent();
|
||||
console.log('Onlineee view-event')
|
||||
|
||||
})
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
this.loadedEvent = event[0];
|
||||
console.log("Event ditails local,", event[0])
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
/* this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
this.loadedEvent = event[0];
|
||||
console.log("Event ditails local,", event[0])
|
||||
})
|
||||
this.loadEvent(); */
|
||||
|
||||
|
||||
window.onresize = (event) => {
|
||||
// if not mobile remove all component
|
||||
@@ -126,6 +154,7 @@ export class ViewEventPage implements OnInit {
|
||||
const loader = this.toastService.loading();
|
||||
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
this.sqliteservice.addEvent(res);
|
||||
/* this.today = new Date(res.StartDate);
|
||||
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
|
||||
loader.remove()
|
||||
@@ -289,4 +318,25 @@ export class ViewEventPage implements OnInit {
|
||||
this.dicIndex = index
|
||||
}
|
||||
|
||||
getEventsFromLocalDb() {
|
||||
console.log("event id details ", this.eventId)
|
||||
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.loadEvent();
|
||||
console.log('Onlineee view-event')
|
||||
|
||||
})
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
this.loadedEvent = event[0];
|
||||
console.log("Event ditails local,", event[0])
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<!-- {{ toDayEventStorage.eventsList | json}} -->
|
||||
|
||||
<ion-list>
|
||||
<ion-item class="item-hover cursor-pointer" lines="none" *ngFor="let event of toDayEventStorage.eventsList"
|
||||
<ion-item class="item-hover cursor-pointer" lines="none" *ngFor="let event of listToPresent"
|
||||
(click)="goToEvent(event.EventId)"
|
||||
>
|
||||
<div class="d-flex content-{{loggeduser.Profile}}-{{event.CalendarName}}">
|
||||
|
||||
@@ -12,10 +12,12 @@ import { EventDetailPage } from './event-detail/event-detail.page';
|
||||
import { ProcessesService } from '../../services/processes.service';
|
||||
import { DailyWorkTask } from '../../models/dailyworktask.model';
|
||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { ToDayEventStorage } from 'src/app/store/to-day-event-storage.service';
|
||||
import { ToDayEventStorage } from 'src/app/store/to-day-event-storage.service';
|
||||
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
|
||||
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
|
||||
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { synchro } from '../../services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-events',
|
||||
@@ -29,16 +31,16 @@ export class EventsPage implements OnInit {
|
||||
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
||||
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
||||
|
||||
customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
|
||||
customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
|
||||
|
||||
/* Setting appropriate greeting according to the time */
|
||||
grettings = ["Bom dia", "Boa tarde", "Boa noite"];
|
||||
greetting='';
|
||||
greetting = '';
|
||||
|
||||
timeDate = this.today.getHours() + ":" + this.today.getMinutes();
|
||||
/* Set segment variable */
|
||||
segment:string;
|
||||
public profile:string;
|
||||
segment: string;
|
||||
public profile: string;
|
||||
currentEvent: any;
|
||||
|
||||
eventsList: Event[];
|
||||
@@ -52,55 +54,65 @@ export class EventsPage implements OnInit {
|
||||
combinedEvents: Event[];
|
||||
|
||||
customText = false;
|
||||
totalEvent=0;
|
||||
totalEvent = 0;
|
||||
currentHoursMinutes: Date | string;
|
||||
|
||||
showLoader: boolean;
|
||||
|
||||
taskslist:DailyWorkTask[] = [];
|
||||
expedientList:any;
|
||||
hideSearchBtn: boolean=false;
|
||||
taskslist: DailyWorkTask[] = [];
|
||||
expedientList: any;
|
||||
hideSearchBtn: boolean = false;
|
||||
|
||||
// shared data
|
||||
toDayEventStorage = ToDayEventStorage
|
||||
expedienteGdStore = ExpedienteGdStore
|
||||
|
||||
|
||||
listToPresent
|
||||
|
||||
expedienteTaskPipe = new ExpedienteTaskPipe()
|
||||
|
||||
@Output() openExpedientListPage:EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() openExpedientListPage: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
loggeduser: LoginUserRespose;
|
||||
|
||||
existingScreenOrientation: string;
|
||||
synch = synchro
|
||||
|
||||
constructor(
|
||||
private eventService: EventsService,
|
||||
private router: Router,
|
||||
private storageService:StorageService,
|
||||
private storageService: StorageService,
|
||||
public activatedRoute: ActivatedRoute,
|
||||
private alertController: AlertService,
|
||||
private authService: AuthService,
|
||||
private processes:ProcessesService,
|
||||
private processes: ProcessesService,
|
||||
/* private gabineteService: GabineteDigitalPage, */
|
||||
private modalController:ModalController,
|
||||
private modalController: ModalController,
|
||||
private screenOrientation: ScreenOrientation,
|
||||
public platform: Platform,
|
||||
) {
|
||||
this.existingScreenOrientation = this.screenOrientation.type;
|
||||
console.log(this.existingScreenOrientation);
|
||||
private sqliteservice: SqliteService,
|
||||
) {
|
||||
this.existingScreenOrientation = this.screenOrientation.type;
|
||||
console.log(this.existingScreenOrientation);
|
||||
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
|
||||
this.prEventList = null;
|
||||
this.prEventList = null;
|
||||
|
||||
this.platform.resize.subscribe(async () => {
|
||||
//console.log('Resize event detected');
|
||||
// console.log('Resize event detected');
|
||||
this.platform.resize.subscribe(async () => {
|
||||
//console.log('Resize event detected');
|
||||
// console.log('Resize event detected');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
try {
|
||||
this.sqliteservice.databaseConn();
|
||||
} catch (error) {
|
||||
console.log("Error creating local database: ", error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.segment = "Combinada";
|
||||
@@ -109,18 +121,20 @@ export class EventsPage implements OnInit {
|
||||
this.showGreeting();
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if(event instanceof NavigationEnd && event.url == '/home/events') {
|
||||
if (event instanceof NavigationEnd && event.url == '/home/events') {
|
||||
this.RefreshEvents();
|
||||
this.LoadList();
|
||||
}
|
||||
});
|
||||
this.hideSearch();
|
||||
|
||||
this.getEventsFromLocalDb();
|
||||
|
||||
//this.checkScreenOrientation();
|
||||
}
|
||||
|
||||
hideSearch(){
|
||||
if(this.router.url == '/home/events'){
|
||||
hideSearch() {
|
||||
if (this.router.url == '/home/events') {
|
||||
this.hideSearchBtn = true;
|
||||
}
|
||||
}
|
||||
@@ -136,28 +150,28 @@ export class EventsPage implements OnInit {
|
||||
}
|
||||
|
||||
// Lock to portrait
|
||||
lockToPortrait(){
|
||||
lockToPortrait() {
|
||||
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);
|
||||
console.log('set');
|
||||
}
|
||||
|
||||
// Lock to landscape
|
||||
lockToLandscape(){
|
||||
// Lock to landscape
|
||||
lockToLandscape() {
|
||||
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
|
||||
}
|
||||
|
||||
// Unlock screen orientation
|
||||
unlockScreenOrientation(){
|
||||
// Unlock screen orientation
|
||||
unlockScreenOrientation() {
|
||||
this.screenOrientation.unlock();
|
||||
}
|
||||
|
||||
checkScreenOrientation(){
|
||||
if( window.innerWidth < 701) {
|
||||
checkScreenOrientation() {
|
||||
if (window.innerWidth < 701) {
|
||||
this.lockToPortrait();
|
||||
console.log('was here');
|
||||
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.unlockScreenOrientation();
|
||||
}
|
||||
}
|
||||
@@ -168,20 +182,24 @@ export class EventsPage implements OnInit {
|
||||
|
||||
let date = new Date();
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let start = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();
|
||||
let end = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" 23:59:59";
|
||||
let start = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
let end = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " 23:59:59";
|
||||
|
||||
|
||||
if(this.loggeduser.Profile == 'MDGPR') {
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
|
||||
let mdOficialEvents = await this.eventService.getAllMdOficialEvents(start, end).toPromise();
|
||||
let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(start, end).toPromise();
|
||||
|
||||
const list = mdOficialEvents.concat(mdPessoalEvents);
|
||||
|
||||
console.log("getAllMdOficialPessoalEvents", list)
|
||||
this.SqliteAddEvent(list);
|
||||
this.listToPresent = this.toDayEventStorage.eventsList
|
||||
this.toDayEventStorage.reset(list)
|
||||
|
||||
if(this.toDayEventStorage.eventsList.length > 0){
|
||||
|
||||
|
||||
if (this.toDayEventStorage.eventsList.length > 0) {
|
||||
this.currentEvent = this.toDayEventStorage.eventsList[0].Subject;
|
||||
this.currentHoursMinutes = this.toDayEventStorage.eventsList[0].StartDate;
|
||||
}
|
||||
@@ -192,18 +210,20 @@ export class EventsPage implements OnInit {
|
||||
}
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
|
||||
let prOficialEvents= await this.eventService.getAllPrOficialEvents(start, end).toPromise();
|
||||
let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
|
||||
let prOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise();
|
||||
let prPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
|
||||
|
||||
const list = prOficialEvents.concat(prPessoalEvents);
|
||||
|
||||
console.log("getAllPrOficialPessoalEvents", list)
|
||||
this.SqliteAddEvent(list);
|
||||
this.toDayEventStorage.reset(list)
|
||||
|
||||
if(this.toDayEventStorage.eventsList.length > 0) {
|
||||
if (this.toDayEventStorage.eventsList.length > 0) {
|
||||
this.currentEvent = this.toDayEventStorage.eventsList[0].Subject;
|
||||
this.currentHoursMinutes = this.toDayEventStorage.eventsList[0].StartDate;
|
||||
}
|
||||
|
||||
this.listToPresent = this.toDayEventStorage.eventsList;
|
||||
this.totalEvent = this.toDayEventStorage.eventsList.length;
|
||||
this.showLoader = false;
|
||||
|
||||
@@ -279,48 +299,110 @@ export class EventsPage implements OnInit {
|
||||
break;
|
||||
} */
|
||||
}
|
||||
SqliteAddEvent(list) {
|
||||
list.forEach((event) => {
|
||||
let data = {
|
||||
EventId: event.EventId,
|
||||
HasAttachments: event.HasAttachments,
|
||||
Subject: event.Subject,
|
||||
Location: event.Location,
|
||||
CalendarId: event.CalendarId,
|
||||
CalendarName: event.CalendarName,
|
||||
StartDate: event.StartDate,
|
||||
EndDate: event.EndDate,
|
||||
EventType: "",
|
||||
Attendees: "",
|
||||
IsMeeting: "",
|
||||
IsRecurring: "",
|
||||
IsAllDayEvent: event.IsAllDayEvent,
|
||||
AppointmentState: "",
|
||||
TimeZone: "",
|
||||
Organizer: "",
|
||||
Category: "",
|
||||
EventRecurrence: "",
|
||||
Attachments: "",
|
||||
Body: ""
|
||||
}
|
||||
|
||||
showGreeting(){
|
||||
if(this.today.getHours() >= 6 && this.today.getHours() < 12){
|
||||
if(!event.Organizer){
|
||||
this.sqliteservice.addEvent(data);
|
||||
console.log("Events page add event sqllite")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getEventsFromLocalDb() {
|
||||
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && event.url == '/home/events') {
|
||||
this.RefreshEvents();
|
||||
this.LoadList();
|
||||
}
|
||||
});
|
||||
console.log('Onlineee')
|
||||
|
||||
})
|
||||
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getAllEvents().then((event) => {
|
||||
this.listToPresent = event
|
||||
this.totalEvent = this.listToPresent.length
|
||||
this.currentEvent = this.listToPresent[0].Subject
|
||||
this.currentHoursMinutes = this.listToPresent[0].StartDate
|
||||
console.log("All events from local,", event)
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
showGreeting() {
|
||||
if (this.today.getHours() >= 6 && this.today.getHours() < 12) {
|
||||
this.greetting = this.grettings[0];
|
||||
}
|
||||
else if(this.today.getHours() >= 12 && this.today.getHours() < 18){
|
||||
else if (this.today.getHours() >= 12 && this.today.getHours() < 18) {
|
||||
this.greetting = this.grettings[1];
|
||||
}
|
||||
else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */{
|
||||
else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */ {
|
||||
this.greetting = this.grettings[2];
|
||||
}
|
||||
}
|
||||
|
||||
gotTo(){
|
||||
gotTo() {
|
||||
this.router.navigate(['/home/events']);
|
||||
}
|
||||
|
||||
changeProfile(){
|
||||
if(this.profile == "mdgpr"){
|
||||
changeProfile() {
|
||||
if (this.profile == "mdgpr") {
|
||||
console.log('pr');
|
||||
this.profile ="pr";
|
||||
this.profile = "pr";
|
||||
this.RefreshEvents();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
console.log('mdgpr');
|
||||
this.profile ="mdgpr";
|
||||
this.profile = "mdgpr";
|
||||
this.RefreshEvents();
|
||||
}
|
||||
}
|
||||
|
||||
logout()
|
||||
{
|
||||
logout() {
|
||||
this.authService.ValidatedUser.BasicAuthKey = "";
|
||||
this.router.navigate(['/home/login']);
|
||||
}
|
||||
|
||||
async openEventDetail1(id:any){
|
||||
async openEventDetail1(id: any) {
|
||||
console.log(id);
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: EventDetailPage,
|
||||
componentProps: {
|
||||
componentProps: {
|
||||
eventId: id,
|
||||
},
|
||||
cssClass: 'event-detail',
|
||||
@@ -335,52 +417,55 @@ export class EventsPage implements OnInit {
|
||||
this.processes.GetTaskListExpediente(false).subscribe(result => {
|
||||
console.log("Expediente", result);
|
||||
|
||||
const ExpedienteTask = result.map( e=> this.expedienteTaskPipe.transform(e))
|
||||
const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
|
||||
|
||||
this.expedienteGdStore.reset(ExpedienteTask)
|
||||
});
|
||||
}
|
||||
|
||||
sortArrayISODate(myArray: any){
|
||||
return myArray.sort(function(a, b) {
|
||||
sortArrayISODate(myArray: any) {
|
||||
return myArray.sort(function (a, b) {
|
||||
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
|
||||
});
|
||||
}
|
||||
|
||||
goToEvent(eventId:any){
|
||||
goToEvent(eventId: any) {
|
||||
this.router.navigate(['/home/events', eventId, 'events']);
|
||||
}
|
||||
|
||||
goToExpediente(SerialNumber:any) {
|
||||
if(this.loggeduser.Profile == 'MDGPR'){
|
||||
goToExpediente(SerialNumber: any) {
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
this.router.navigate(['/home/events/expediente', SerialNumber, 'events']);
|
||||
}
|
||||
else if(this.loggeduser.Profile == 'PR'){
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
this.router.navigate(['/home/events/expedientes-pr', SerialNumber, 'events']);
|
||||
}
|
||||
}
|
||||
|
||||
viewExpedientListPage(){
|
||||
if(this.loggeduser.Profile == 'MDGPR'){
|
||||
if( window.innerWidth < 801){
|
||||
viewExpedientListPage() {
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
if (window.innerWidth < 801) {
|
||||
this.router.navigate(['/home/gabinete-digital/expediente']);
|
||||
}
|
||||
else{
|
||||
let navigationExtras: NavigationExtras = { queryParams: {"expedientes": true,} };
|
||||
else {
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "expedientes": true, } };
|
||||
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
||||
}
|
||||
}
|
||||
else if(this.loggeduser.Profile == 'PR'){
|
||||
if( window.innerWidth < 801){
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
if (window.innerWidth < 801) {
|
||||
this.router.navigate(['/home/gabinete-digital/expedientes-pr']);
|
||||
}
|
||||
else{
|
||||
let navigationExtras: NavigationExtras = { queryParams: {"expedientes-pr": true,} };
|
||||
else {
|
||||
let navigationExtras: NavigationExtras = { queryParams: { "expedientes-pr": true, } };
|
||||
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<ion-list>
|
||||
<div
|
||||
class="expediente ion-no-padding ion-no-margin cursor-pointer"
|
||||
*ngFor = "let task of expedienteGdStore.list"
|
||||
*ngFor = "let task of listToPresent"
|
||||
(click)="goToExpediente(task.SerialNumber)"
|
||||
>
|
||||
<div class="item width-100">
|
||||
|
||||
@@ -4,6 +4,9 @@ import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
||||
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { synchro } from '../../../services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-expediente',
|
||||
@@ -12,22 +15,25 @@ import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
|
||||
})
|
||||
export class ExpedientePage implements OnInit {
|
||||
|
||||
segment:string;
|
||||
segment: string;
|
||||
skeletonLoader = true
|
||||
//profile:string;
|
||||
showLoader:boolean;
|
||||
showLoader: boolean;
|
||||
|
||||
taskslist = [];
|
||||
serialNumber:string;
|
||||
serialNumber: string;
|
||||
|
||||
expedienteGdStore = ExpedienteGdStore
|
||||
expedienteTaskPipe = new ExpedienteTaskPipe()
|
||||
|
||||
listToPresent;
|
||||
synch = synchro
|
||||
constructor(
|
||||
private processes:ProcessesService,
|
||||
private processes: ProcessesService,
|
||||
private router: Router,
|
||||
private toastService: ToastService
|
||||
) {}
|
||||
private toastService: ToastService,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -35,17 +41,19 @@ export class ExpedientePage implements OnInit {
|
||||
const pathname = location.pathname + location.search
|
||||
|
||||
this.LoadList()
|
||||
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationStart && event.url.startsWith(pathname)) {
|
||||
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
this.refreshing()
|
||||
} else {
|
||||
this.LoadList()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.getEventsFromLocalDb();
|
||||
|
||||
}
|
||||
|
||||
async LoadList() {
|
||||
@@ -54,16 +62,17 @@ export class ExpedientePage implements OnInit {
|
||||
try {
|
||||
const expediente: object[] = await this.processes.GetTaskListExpediente(false).toPromise()
|
||||
const result = expediente
|
||||
|
||||
|
||||
this.taskslist = new Array();
|
||||
let res = result.reverse().filter((data: any) => data.workflowInstanceDataFields.Status == "Active");
|
||||
|
||||
res.forEach((element: any) => {
|
||||
|
||||
let task = this.expedienteTaskPipe.transform(element)
|
||||
let task = this.expedienteTaskPipe.transform(element)
|
||||
this.taskslist.push(task);
|
||||
});
|
||||
|
||||
|
||||
this.SqliteAddExpediente(this.taskslist)
|
||||
this.expedienteGdStore.reset(this.taskslist);
|
||||
|
||||
} catch (error) {
|
||||
@@ -92,9 +101,56 @@ export class ExpedientePage implements OnInit {
|
||||
this.router.navigate(['/home/gabinete-digital']);
|
||||
}
|
||||
|
||||
goToExpediente(serialNumber:any){
|
||||
goToExpediente(serialNumber: any) {
|
||||
//console.log('ABRE');
|
||||
this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']);
|
||||
this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
|
||||
SqliteAddExpediente(list) {
|
||||
list.forEach((expediente) => {
|
||||
let data = {
|
||||
serialNumber: expediente.serialNumber,
|
||||
workflowInstanceFolio: expediente.workflowInstanceFolio,
|
||||
Documents: expediente.Documents,
|
||||
actions: expediente.actions,
|
||||
activityInstanceName: expediente.activityInstanceName,
|
||||
formURL: expediente.formURL,
|
||||
originator: expediente.originator,
|
||||
taskStartDate: expediente.taskStartDate,
|
||||
totalDocuments: expediente.totalDocuments,
|
||||
workflowDisplayName: expediente.workflowDisplayName,
|
||||
workflowID: expediente.workflowID,
|
||||
workflowInstanceDataFields: expediente.workflowInstanceDataFields,
|
||||
workflowInstanceID: expediente.workflowInstanceID,
|
||||
workflowName: expediente.workflowName
|
||||
}
|
||||
|
||||
this.sqliteservice.addExpediente(data);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getEventsFromLocalDb() {
|
||||
|
||||
|
||||
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.listToPresent = this.expedienteGdStore.list;
|
||||
console.log('Onlineee')
|
||||
|
||||
})
|
||||
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getAllExpedientes().then((expediente) => {
|
||||
this.listToPresent = expediente
|
||||
console.log("All expedientes from local,", expediente)
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { environment } from 'src/environments/environment';
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { SqliteService } from '../../services/sqlite.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@@ -31,11 +32,14 @@ export class LoginPage implements OnInit {
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
private toastService: ToastService,
|
||||
public alertController: AlertController
|
||||
public alertController: AlertController,
|
||||
private sqliteservice: SqliteService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {}
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
//Function to validade the login inputs
|
||||
validateUsername() {
|
||||
@@ -83,9 +87,9 @@ export class LoginPage implements OnInit {
|
||||
|
||||
if (attempt.UserId == SessionStore.user.UserId) {
|
||||
await this.authService.SetSession(attempt, this.userattempt);
|
||||
await this.authService.loginChat(this.userattempt);
|
||||
//await this.authService.loginChat(this.userattempt);
|
||||
this.getToken();
|
||||
SessionStore.setInativity(true)
|
||||
SessionStore.setInativity(true);
|
||||
|
||||
this.goback()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user