Merge branch 'developer' of https://bitbucket.org/equilibriumito/gabinete-digital into feature/autologinchat

This commit is contained in:
tiago.kayaya
2022-02-08 15:33:44 +01:00
51 changed files with 2060 additions and 1498 deletions
+53 -16
View File
@@ -9,6 +9,7 @@ import { momentG } from 'src/plugin/momentG';
import { DomSanitizer } from "@angular/platform-browser";
import { EventPerson } from 'src/app/models/eventperson.model';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js';
import { Storage } from '@ionic/storage';
// showTimeline
import { setHours, setMinutes } from 'date-fns';
@@ -179,7 +180,8 @@ export class AgendaPage implements OnInit {
private sqliteservice: SqliteService,
private platform: Platform,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private storage:Storage
) {
this.dateAdapter.setLocale('es');
@@ -770,6 +772,27 @@ export class AgendaPage implements OnInit {
addEventToDB(response, profile) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
let responseArray = [];
response.forEach(element => {
let event = {
CalendarId: element.CalendarId,
CalendarName: element.CalendarName,
EndDate: element.EndDate,
EventId: element.EventId,
HasAttachments: element.HasAttachments,
HumanDate: element.HumanDate,
IsAllDayEvent: element.IsAllDayEvent,
Location: element.Location,
StartDate: element.StartDate,
Subject: element.Subject,
Profile: profile
}
responseArray.push(event)
});
this.storage.set('agendaResponse',responseArray).then(() => {
console.log('Agenda data saved')
})
} else {
if (response.length > 0) {
@@ -796,21 +819,35 @@ export class AgendaPage implements OnInit {
getFromDB() {
console.log('ALL EVENTS FROM DB AGENDA OFFLINE')
this.sqliteservice.getAllEvents().then((events: any[]) => {
console.log('ALL EVENTS FROM DB', events)
let eventArray = [];
this.trasnformDataDB(events)
this.updateEventListBox()
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
})
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('agendaResponse').then((events) => {
this.trasnformDataDB(events)
this.updateEventListBox()
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
})
} else {
this.sqliteservice.getAllEvents().then((events: any[]) => {
console.log('ALL EVENTS FROM DB', events)
let eventArray = [];
this.trasnformDataDB(events)
this.updateEventListBox()
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
})
}
}
updateEventListBox() {
@@ -21,6 +21,7 @@ import { BackgroundService } from 'src/app/services/background.service';
import { StorageService } from 'src/app/services/storage.service';
import { ThemeService } from 'src/app/services/theme.service'
import { RouteService } from 'src/app/services/route.service';
import { Storage } from '@ionic/storage';
@Component({
@@ -74,6 +75,7 @@ export class ViewEventPage implements OnInit {
private storage: StorageService,
public ThemeService: ThemeService,
private RouteService: RouteService,
private ionicStorage: Storage
) {
this.isEventEdited = false;
this.loadedEvent = new Event();
@@ -394,6 +396,9 @@ export class ViewEventPage implements OnInit {
addEventToDb(data) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.ionicStorage.set('eventDetails', data).then(() => {
console.log('Details event saved')
})
} else {
let event = {
Attendees: JSON.stringify(data.Attendees) || JSON.stringify(''),
@@ -423,33 +428,40 @@ export class ViewEventPage implements OnInit {
getFromDb() {
const loader = this.toastService.loading();
this.sqliteservice.getEventById(this.eventId).then((event) => {
let arrayevent = [];
console.log('EVENT ATTENDEES',event[0].Attendees)
let elemet = {
Attendees: (typeof JSON.parse(event[0].Attendees) === 'undefined') ? "" : JSON.parse(event[0].Attendees),
Body: JSON.parse(event[0].Body) || "",
CalendarId: event[0].CalendarId,
CalendarName: event[0].CalendarName,
Category: event[0].Category,
EndDate: event[0].EndDate,
EventId: event[0].EventId,
EventRecurrence: JSON.parse(event[0].EventRecurrence) || "",
EventType: event[0].EventType,
HasAttachments: event[0].HasAttachments,
IsAllDayEvent: event[0].IsAllDayEvent,
IsMeeting: event[0].IsMeeting,
IsRecurring: event[0].IsRecurring,
Location: event[0].Location,
Organizer: JSON.parse(event[0].Organizer) || "",
StartDate: event[0].StartDate,
Subject: event[0].Subject,
TimeZone: event[0].TimeZone
}
arrayevent.push(elemet);
this.loadedEvent = arrayevent[0];
console.log("Event ditails local,", elemet)
})
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.ionicStorage.get('eventDetails').then((events) =>{
this.loadedEvent = events;
})
} else {
this.sqliteservice.getEventById(this.eventId).then((event) => {
let arrayevent = [];
console.log('EVENT ATTENDEES',event[0].Attendees)
let elemet = {
Attendees: (typeof JSON.parse(event[0].Attendees) === 'undefined') ? "" : JSON.parse(event[0].Attendees),
Body: JSON.parse(event[0].Body) || "",
CalendarId: event[0].CalendarId,
CalendarName: event[0].CalendarName,
Category: event[0].Category,
EndDate: event[0].EndDate,
EventId: event[0].EventId,
EventRecurrence: JSON.parse(event[0].EventRecurrence) || "",
EventType: event[0].EventType,
HasAttachments: event[0].HasAttachments,
IsAllDayEvent: event[0].IsAllDayEvent,
IsMeeting: event[0].IsMeeting,
IsRecurring: event[0].IsRecurring,
Location: event[0].Location,
Organizer: JSON.parse(event[0].Organizer) || "",
StartDate: event[0].StartDate,
Subject: event[0].Subject,
TimeZone: event[0].TimeZone
}
arrayevent.push(elemet);
this.loadedEvent = arrayevent[0];
console.log("Event ditails local,", elemet)
})
}
loader.remove()
}
}
+2 -7
View File
@@ -143,8 +143,8 @@ export class ChatPage implements OnInit {
ngOnInit() {
console.log(this.wsChatMethodsService.dm);
console.log(this.wsChatMethodsService.group);
console.log('Rooms INDIVIDUAIS',this.wsChatMethodsService._dm);
console.log(' ROOMS GROUP',this.wsChatMethodsService._group);
this.segment = "Contactos";
@@ -159,11 +159,6 @@ export class ChatPage implements OnInit {
let t = this.showDateDuration(new Date());
this.setStatus('away');
/* if(this.dataService.get("newGroup")){
this.openNewGroupPage();
} */
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
if (this.dataService.get("newGroup")) {
@@ -102,7 +102,7 @@
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments">
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)">
<img *ngIf="msg.image_url" src="{{msg.image_url}}" alt="image" >
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image" >
<ion-icon *ngIf="msg.file.image_url == null" name="download-outline"></ion-icon>
</div>
<div *ngIf="msg.file.type != 'application/img'">
@@ -121,7 +121,7 @@
<ion-label *ngIf="msg.file">
<span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label>
</div>
</div>
@@ -20,12 +20,18 @@ import { NewEventPage } from '../../agenda/new-event/new-event.page';
import { EventPerson } from 'src/app/models/eventperson.model';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service'
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { HttpEventType } from '@angular/common/http';
import { SqliteService } from 'src/app/services/sqlite.service';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { FileType } from 'src/app/models/fileType';
import { Storage } from '@ionic/storage';
import { CameraService } from 'src/app/services/camera.service';
import { SearchPage } from 'src/app/pages/search/search.page';
import { ProcessesService } from 'src/app/services/processes.service';
@Component({
selector: 'app-group-messages',
@@ -87,7 +93,12 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
private changeDetectorRef: ChangeDetectorRef,
private sqlservice: SqliteService,
private platform: Platform,
public wsChatMethodsService: WsChatMethodsService
public wsChatMethodsService: WsChatMethodsService,
private AttachmentsService: AttachmentsService,
private storage: Storage,
private processesService: ProcessesService,
private CameraService: CameraService,
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = true;
@@ -118,6 +129,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.getChatMembers();
this.getRoomMessageDB(this.roomId);
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
console.log('MEMBER', value)
})
}
setStatus(status:string){
@@ -237,7 +251,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id);
}
this.getGroupContacts(this.room);
this.loadGroupMessages(this.room);
this.showLoader = false;
});
}
@@ -286,27 +299,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
}
loadGroupMessages(room:any){
this.showLoader = true;
//If group is private call getGroupMembers
if(this.room.t === 'p'){
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res=>{
console.log(res);
let msgOnly = res['messages'].filter(data => data.t != 'au');
//this.messages = msgOnly.reverse();
this.transformDataMSG(msgOnly.reverse());
this.getRoomMessageDB(this.roomId);
this.showLoader = false;
});
}
//Otherwise call getChannelMembers for públic groups
/* else{
this.chatService.getPublicGroupMessages(this.roomId).subscribe(res=>{
console.log(res);
this.messages = res['messages'].reverse();
});
} */
}
showDateDuration(start:any){
return this.timeService.showDateDuration(start);
@@ -327,7 +319,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
sendMessage() {
this.wsChatMethodsService.getGroupRoom(this.roomId).send()
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
}
async openOptions() {
@@ -354,42 +346,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
});
}
loadPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
console.log(file);
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name;
let body = {
"message":
{
"rid": this.roomId,
"msg": "",
"attachments": [{
//"title": this.capturedImageTitle ,
//"text": "description",
"title_link_download": false,
"image_url": this.capturedImage,
}]
}
}
this.chatService.sendMessage(body).subscribe(res=> {
console.log(res);
},(error) => {
});
//console.log(this.capturedImage)
};
}
viewDocument(file:any, url?:string){
@@ -481,8 +437,119 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
}
async takePicture() {
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
const base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": capturedImage
},
temporaryData: formData,
attachments: [{
"title": capturedImageTitle ,
"image_url": capturedImage, // rocketchat
"text": "description",
"title_link_download": false,
}]
})
}
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
async addFileWebtrix() {
const modal = await this.modalController.create({
component: SearchPage,
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
componentProps: {
type: 'AccoesPresidenciais & ArquivoDespachoElect',
select: true,
showSearchInput: true,
}
});
await modal.present();
modal.onDidDismiss().then(async res=>{
const data = res.data;
if(data.selected) {
const loader = this.toastService.loading();
this.wsChatMethodsService.getDmRoom(this.roomId).send({
file:{
"name": res.data.selected.Assunto,
"type": "application/webtrix",
"ApplicationId": res.data.selected.ApplicationType,
"DocId": res.data.selected.Id,
"Assunto": res.data.selected.Assunto,
},
attachments: [{
"title": res.data.selected.Assunto,
"description": res.data.selected.DocTypeDesc,
// "title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
// "message_link": url_no_options,
"type": "webtrix",
//"thumb_url": "assets/images/webtrix-logo.png",
"text": res.data.selected.DocTypeDesc,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}]
})
loader.remove();
}
});
}
async addFileToChat(types: typeof FileType[] ) {
const file: any = await this.fileService.getFileFromDevice(types);
const imageData = await this.fileToBase64Service.convert(file)
const formData = new FormData();
formData.append("blobFile", file);
this.wsChatMethodsService.getDmRoom(this.roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": imageData
},
temporaryData: formData,
attachments: [{
"title": file.name ,
"text": "description",
"image_url": imageData,
"title_link_download": false,
}]
})
}
async openChatOptions(ev?: any) {
console.log(this.members);
const roomId = this.roomId;
const popover = await this.popoverController.create({
component: ChatOptionsPopoverPage,
@@ -496,29 +563,25 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
translucent: true
});
await popover.present();
await popover.onDidDismiss().then((res)=>{
await popover.onDidDismiss().then( async(res)=>{
console.log(res['data']);
if(res['data'] == 'meeting'){
if (res['data'] == 'meeting') {
this.bookMeeting();
}
else if(res['data'] == 'take-picture'){
this.fileService.addCameraPictureToChat(this.roomId);
//this.loadPicture();
else if (res['data'] == 'take-picture') {
this.takePicture()
}
else if(res['data'] == 'add-picture'){
this.fileService.addPictureToChatMobile(this.roomId);
//this.loadPicture();
}
else if(res['data'] == 'add-document'){
this.fileService.addDocumentToChat(this.roomId);
//this.loadDocument();
}
else if(res['data'] == 'documentoGestaoDocumental'){
else if (res['data'] == 'add-picture') {
this.addImage()
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
//this.addDocGestaoDocumental();
}
this.loadGroupMessages(this.roomId);
else if (res['data'] == 'add-document') {
this.addFile()
}
else if (res['data'] == 'documentoGestaoDocumental') {
this.addFileWebtrix()
}
});
}
@@ -742,7 +805,7 @@ downloadFileMsg(msg) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
console.log('FILE TYPE 22', msg.file.guid)
var name = msg.file.guid;
@@ -102,7 +102,7 @@
<ion-label *ngIf="msg.file && msg.file != ''">
<span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label>
</div>
</div>
+141 -156
View File
@@ -1,11 +1,10 @@
import { AfterViewChecked, AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'
import { GestureController, Gesture, ModalController, NavParams, PopoverController, IonSlides, Platform } from '@ionic/angular';
import { GestureController, Gesture, ModalController, NavParams, PopoverController, Platform } from '@ionic/angular';
import { map } from 'rxjs/operators';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { EventPerson } from 'src/app/models/eventperson.model';
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
import { SearchDocumentDetails, SearchFolderDetails } from 'src/app/models/search-document';
import { ContactsPage } from 'src/app/pages/chat/messages/contacts/contacts.page';
import { AlertService } from 'src/app/services/alert.service';
import { AuthService } from 'src/app/services/auth.service';
@@ -31,6 +30,14 @@ import { HttpEventType } from '@angular/common/http';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
import { MessageService } from 'src/app/services/chat/message.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { CameraService } from 'src/app/services/camera.service';
import { element } from 'protractor';
import { FileType } from 'src/app/models/fileType';
import { SearchPage } from 'src/app/pages/search/search.page';
import { Storage } from '@ionic/storage';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
const IMAGE_DIR = 'stored-images';
@@ -98,7 +105,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private changeDetectorRef: ChangeDetectorRef,
private platform: Platform,
private sqlservice: SqliteService,
public wsChatMethodsService: WsChatMethodsService
public wsChatMethodsService: WsChatMethodsService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private storage: Storage,
private fileToBase64Service: FileToBase64Service,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.roomId = this.navParams.get('roomId');
@@ -121,11 +134,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
ngOnInit() {
//this.load();
this.setStatus('online');
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
console.log('MEMBER', value)
})
//this.loadFiles();
VoiceRecorder.requestAudioRecordingPermission();
this.getChatMembers();
Filesystem.mkdir({
path: IMAGE_DIR,
directory: Directory.Data,
@@ -253,15 +268,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.selectedMsgId = "";
}
setStatus(status: string) {
let body = {
message: '',
status: status,
}
this.chatService.setUserStatus(body).subscribe(res => {
console.log(res);
})
}
notImplemented() {
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
@@ -272,7 +278,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
load() {
this.serverLongPull();
this.getChatMembers();
}
@@ -347,7 +352,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
sendMessage() {
this.wsChatMethodsService.getDmRoom(this.roomId).send()
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
}
@@ -515,9 +520,122 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
}
async takePicture() {
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
const base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
console.log('ALL IMAGE', formData)
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": capturedImage
},
attachments: [{
"image_url": capturedImage,
"title": capturedImageTitle ,
"text": "description",
"title_link_download": false,
}],
temporaryData: formData
})
}
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
async addFileWebtrix() {
const modal = await this.modalController.create({
component: SearchPage,
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
componentProps: {
type: 'AccoesPresidenciais & ArquivoDespachoElect',
select: true,
showSearchInput: true,
}
});
await modal.present();
modal.onDidDismiss().then(async res=>{
const data = res.data;
const roomId = this.roomId
if(data.selected) {
const loader = this.toastService.loading();
this.wsChatMethodsService.getDmRoom(roomId).send({
file:{
"name": res.data.selected.Assunto,
"type": "application/webtrix",
"ApplicationId": res.data.selected.ApplicationType,
"DocId": res.data.selected.Id,
"Assunto": res.data.selected.Assunto,
},
attachments: [{
"title": res.data.selected.Assunto,
"description": res.data.selected.DocTypeDesc,
// "title_link": url_no_options,
"title_link_download": true,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
// "message_link": url_no_options,
"text": res.data.selected.DocTypeDesc,
"type": "webtrix"
}],
})
loader.remove();
}
});
}
async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
const imageData = await this.fileToBase64Service.convert(file)
const formData = new FormData();
formData.append("blobFile", file);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": imageData
},
temporaryData: formData,
attachments: [{
"title": file.name ,
"image_url": imageData,
"text": "description",
"title_link_download": false,
}]
})
}
async openChatOptions(ev?: any) {
const roomId = this.roomId
console.log(this.members);
console.log('MOBILE CHAT OPTION',this.members);
const popover = await this.popoverController.create({
component: ChatOptionsPopoverPage,
@@ -531,66 +649,29 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
translucent: true
});
await popover.present();
popover.onDidDismiss().then((res) => {
popover.onDidDismiss().then( async (res) => {
console.log(res['data']);
if (res['data'] == 'meeting') {
this.bookMeeting();
}
else if (res['data'] == 'take-picture') {
this.fileService.addCameraPictureToChat(roomId);
//this.loadPicture();
this.takePicture()
}
else if (res['data'] == 'add-picture') {
this.fileService.addPictureToChatMobile(roomId);
//this.loadPicture();
this.addImage()
}
else if (res['data'] == 'add-document') {
this.fileService.addDocumentToChat(this.roomId);
//this.loadDocument();
this.addFile()
}
else if (res['data'] == 'documentoGestaoDocumental') {
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
//this.addDocGestaoDocumental();
this.addFileWebtrix()
}
});
}
/*
this.fileService.downloadFile(element.file.guid).subscribe(async (event) => {
var name = element.file.guid;
if (event.type === HttpEventType.DownloadProgress) {
} else if (event.type === HttpEventType.Response) {
var base64 = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '')
);
console.log('TRY ARRAY BUFFER NAME', name);
console.log('TRY ARRAY BUFFER', base64);
await Filesystem.writeFile({
path: `${IMAGE_DIR}/${name}`,
data: base64,
directory: Directory.Data
}).then((foo) => {
console.log('LSKE FS FILE SAVED', foo)
}).catch((error) => {
console.log('error LAKE FS FILE', error)
});
const readFile = await Filesystem.readFile({
path: `${IMAGE_DIR}/${name}`,
directory: Directory.Data,
});
});*/
getRoomMessageDB(roomId) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
@@ -666,108 +747,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
async serverLongPull() {
const roomId = this.roomId
/* this.chatService.getRoomMessages(roomId).subscribe(res=>{
console.log(res);
}) */
this.chatService.getRoomMessages(roomId).subscribe(async res => {
console.log("Chat message", res)
this.transformDataMSG(res['messages'])
this.getRoomMessageDB(this.roomId);
if (res == 502) {
// Connection timeout
// happens when the synchro was pending for too long
// let's reconnect
await this.serverLongPull();
}
else if (res != 200) {
// Show Error
//showMessage(response.statusText);
//this.loadMessages()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
}
//console.log(this.messages);
// Reconnect in one second
if (this.route.url != "/home/chat") {
console.log("Timer message stop")
} else {
//Check if modal is opened
if (document.querySelector('.isMessagesChatOpened')) {
await new Promise(resolve => setTimeout(resolve, 5000));
await this.serverLongPull();
//console.log('Timer message running')
}
}
} else {
// Got message
//let message = await response.text();
//this.loadMessages()
await this.serverLongPull();
}
});
}
sliderOpts = {
zoom: false,
slidesPerView: 1.5,
spaceBetween: 20,
centeredSlides: true
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
zoom: {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale / 5;
this.changeDetectorRef.detectChanges();
}
}
}
async touchEnd(zoomslides: IonSlides, card) {
// Zoom back to normal
const slider = await zoomslides.getSwiper();
const zoom = slider.zoom;
zoom.out();
// Card back to normal
card.el.style['z-index'] = 9;
this.zoomActive = false;
this.changeDetectorRef.detectChanges();
}
touchStart(card) {
// Make card appear above backdrop
card.el.style['z-index'] = 11;
}
downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
console.log('FILE TYPE 22', msg.file.guid)
var name = msg.file.guid;
+26 -1
View File
@@ -21,6 +21,7 @@ import { NetworkConnectionService } from 'src/app/services/network-connection.se
import { BackgroundService } from 'src/app/services/background.service';
import { momentG } from 'src/plugin/momentG';
import { ThemeService } from 'src/app/services/theme.service'
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-events',
templateUrl: './events.page.html',
@@ -95,7 +96,8 @@ export class EventsPage implements OnInit {
private sqliteservice: SqliteService,
private networkconnection: NetworkConnectionService,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private storage: Storage
) {
/* this.existingScreenOrientation = this.screenOrientation.type;
console.log(this.existingScreenOrientation); */
@@ -317,6 +319,9 @@ export class EventsPage implements OnInit {
addEventToDb(list) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('events', list).then(() => {
console.log('Init events saved')
})
} else {
if (list.length > 0) {
list.forEach(element => {
@@ -359,6 +364,9 @@ export class EventsPage implements OnInit {
addProcessToDb(list) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('process', list).then(() => {
console.log('Init process saved')
})
} else {
if (list.length > 0) {
list.forEach(element => {
@@ -376,6 +384,23 @@ export class EventsPage implements OnInit {
let dateToday = date.getFullYear() + "-" + month + "-" + date.getDate();
console.log('dateeeeee', dateToday)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('events').then((events: any[]) => {
console.log('Today events',events)
let todayEvents = new Array()
this.listToPresent = events
this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject
this.currentHoursMinutes = this.listToPresent[0].StartDate
console.log("All events from local,", events)
})
this.storage.get('process').then((process: any[]) => {
console.log('OFOFOFOOF22222', process)
const ExpedienteTask = process.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
})
this.showLoader = false;
} else {
this.sqliteservice.getAllEvents().then((event: any[]) => {
@@ -19,6 +19,7 @@ import { Platform } from '@ionic/angular';
import { ThemeService } from 'src/app/services/theme.service'
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
import { RouteService } from 'src/app/services/route.service';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-approve-event',
@@ -63,7 +64,8 @@ export class ApproveEventPage implements OnInit {
private platform: Platform,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
private offlineManager: OfflineManagerService
private offlineManager: OfflineManagerService,
private storage: Storage
) {
this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]);
@@ -110,6 +112,9 @@ export class ApproveEventPage implements OnInit {
addProcessToDB(data) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('approve_event_detils', data).then(() => {
console.log('APPROVE EVENT DETAILS SAVED')
})
} else {
this.sqliteservice.updateProcess(data);
}
@@ -117,69 +122,85 @@ export class ApproveEventPage implements OnInit {
getProcessFromDB() {
this.platform.ready().then(() => {
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
console.log('event aprove serial', process)
var doc;
var action = [];
var origi = [];
var wordafi = {};
if (process[0].Documents === "null" || process[0].Documents === "undefined") {
doc = []
} else {
doc = JSON.parse(process[0].Documents)
}
if (process[0].actions === "null" || process[0].actions === "undefined") {
action = []
} else {
action = JSON.parse(process[0].Documents)
}
if (process[0].originator === "null" || process[0].originator === "undefined") {
origi = []
} else {
origi = JSON.parse(process[0].Documents)
}
if (process[0].workflowInstanceDataFields === "null" || process[0].workflowInstanceDataFields === "undefined") {
wordafi = []
} else {
wordafi = JSON.parse(process[0].workflowInstanceDataFields)
}
let task = {
"Documents": doc,
"actions": action,
"activityInstanceName": process[0].activityInstanceName,
"formURL": process[0].formURL,
"originator": origi,
"serialNumber": process[0].serialNumber,
"taskStartDate": process[0].taskStartDate,
"totalDocuments": process[0].totalDocuments,
"workflowDisplayName": process[0].workflowDisplayName,
"workflowID": process[0].workflowID,
"workflowInstanceDataFields": wordafi,
"workflowInstanceFolio": process[0].workflowInstanceFolio,
"workflowInstanceID": process[0].workflowInstanceID,
"workflowName": process[0].workflowInstanceID
}
this.loadedEvent = task
console.log('offline event', this.loadedEvent);
this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId;
this.loadedAttachments = this.loadedEvent.Documents;
console.log('Attatara', this.loadedAttachments)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('approve_event_detils').then((event) => {
this.loadedEvent = event
console.log('offline event', this.loadedEvent);
this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId;
this.loadedAttachments = this.loadedEvent.Documents;
console.log('Attatara', this.loadedAttachments)
})
})
} else {
this.platform.ready().then(() => {
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
console.log('event aprove serial', process)
var doc;
var action = [];
var origi = [];
var wordafi = {};
if (process[0].Documents === "null" || process[0].Documents === "undefined") {
doc = []
} else {
doc = JSON.parse(process[0].Documents)
}
if (process[0].actions === "null" || process[0].actions === "undefined") {
action = []
} else {
action = JSON.parse(process[0].Documents)
}
if (process[0].originator === "null" || process[0].originator === "undefined") {
origi = []
} else {
origi = JSON.parse(process[0].Documents)
}
if (process[0].workflowInstanceDataFields === "null" || process[0].workflowInstanceDataFields === "undefined") {
wordafi = []
} else {
wordafi = JSON.parse(process[0].workflowInstanceDataFields)
}
let task = {
"Documents": doc,
"actions": action,
"activityInstanceName": process[0].activityInstanceName,
"formURL": process[0].formURL,
"originator": origi,
"serialNumber": process[0].serialNumber,
"taskStartDate": process[0].taskStartDate,
"totalDocuments": process[0].totalDocuments,
"workflowDisplayName": process[0].workflowDisplayName,
"workflowID": process[0].workflowID,
"workflowInstanceDataFields": wordafi,
"workflowInstanceFolio": process[0].workflowInstanceFolio,
"workflowInstanceID": process[0].workflowInstanceID,
"workflowName": process[0].workflowInstanceID
}
this.loadedEvent = task
console.log('offline event', this.loadedEvent);
this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId;
this.loadedAttachments = this.loadedEvent.Documents;
console.log('Attatara', this.loadedAttachments)
})
})
}
console.log('Offlineee')
}
@@ -14,6 +14,7 @@ import { Platform } from '@ionic/angular';
import { SortService } from 'src/app/services/functions/sort.service';
import { ThemeService } from 'src/app/services/theme.service'
import { RouteService } from 'src/app/services/route.service';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-event-list',
@@ -46,7 +47,8 @@ export class EventListPage implements OnInit {
private sortService: SortService,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
private RouteService: RouteService
private RouteService: RouteService,
private storage: Storage
) { }
ngOnInit() {
@@ -83,22 +85,37 @@ export class EventListPage implements OnInit {
getEventToAproveFromDB() {
this.platform.ready().then(() => {
this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => {
this.eventsMDGPRList = this.sortService.sortDate(this.transformaDataDB(event), 'taskStartDate')
//this.eventsMDGPRList = this.eventsMDGPRList.filter(element => element.interveners != null)
console.log('MD event to aprove', this.eventsMDGPRList)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('event-to-aproveMD').then((events) => {
this.eventsMDGPRList = events
})
this.storage.get('event-to-aprovePR').then((events) => {
this.eventsPRList = events
})
} else {
this.platform.ready().then(() => {
this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => {
this.eventsMDGPRList = this.sortService.sortDate(this.transformaDataDB(event), 'taskStartDate')
//this.eventsMDGPRList = this.eventsMDGPRList.filter(element => element.interveners != null)
console.log('MD event to aprove', this.eventsMDGPRList)
})
this.sqliteservice.getListOfEventAprove('Agenda Oficial PR', 'Agenda Pessoal PR').then((event: any[]) => {
this.eventsPRList = this.sortService.sortDate(this.transformaDataDB(event), 'taskStartDate')
console.log('PR event to aprove', this.eventsPRList)
})
})
this.sqliteservice.getListOfEventAprove('Agenda Oficial PR', 'Agenda Pessoal PR').then((event: any[]) => {
this.eventsPRList = this.sortService.sortDate(this.transformaDataDB(event), 'taskStartDate')
console.log('PR event to aprove', this.eventsPRList)
}
})
})
console.log('Offlineee')
}
@@ -143,16 +160,24 @@ export class EventListPage implements OnInit {
let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise();
this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal);
this.eventsMDGPRList = this.sortService.sortDate(this.eventsMDGPRList, 'taskStartDate')
this.eventsMDGPRList = this.sortService.sortArrayByDate(this.eventsMDGPRList)
console.log('MD EVENT TO APROVE ONLINE',this.eventsMDGPRList)
this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse());
this.storage.set('event-to-aproveMD',this.eventsMDGPRList).then(() => {
console.log(' EVENTMD TO APROVE SAVED')
})
//this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse());
}
else if (this.segment == 'PR') {
let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise();
let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise();
this.eventsPRList = prEventsOficial.concat(prEventsPessoal);
this.eventsPRList = this.sortService.sortDate(this.eventsPRList, 'taskStartDate')
this.eventsPRList = this.sortService.sortArrayByDate(this.eventsPRList)
console.log('PR EVENT TO APROVE ONLINE',this.eventsPRList)
this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
this.storage.set('event-to-aprovePR',this.eventsPRList).then(() => {
console.log(' EVENTPR TO APROVE SAVED')
})
//this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
}
this.showLoader = false;
this.skeletonLoader = false
@@ -162,6 +187,8 @@ export class EventListPage implements OnInit {
})
}
async openApproveModal(eventSerialNumber, event) {
const modal = await this.modalController.create({
component: ApproveEventModalPage,
@@ -33,6 +33,7 @@ import { BackgroundService } from 'src/app/services/background.service';
import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page';
import { DataService } from 'src/app/services/data.service';
import { RouteService } from 'src/app/services/route.service';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-expediente-detail',
@@ -82,6 +83,7 @@ export class ExpedienteDetailPage implements OnInit {
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
private dataService: DataService,
private storage: Storage
) {
this.activatedRoute.paramMap.subscribe(params => {
if (params["params"].SerialNumber) {
@@ -112,63 +114,106 @@ export class ExpedienteDetailPage implements OnInit {
updateProcessDB(res) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('expediente_details',res).then(() =>{
console.log('EXPEDIENTE DETAILS SAVED')
})
} else {
this.sqliteservice.updateProcess(res)
}
}
getFromDB() {
this.platform.ready().then(() => {
this.onlinecheck = false;
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
console.log("expedient ditail", process)
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
origina = JSON.parse(process[0].originator)
}
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('expediente_details').then((process) => {
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": workflow.Subject,
"Senders": origina.email || process[0].originator,
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": workflow.ViewerRequest,
"Remetente": workflow.Sender,
"Note": workflow.TaskMessage || workflow.Note,
"FolderId": workflow.FolderID,
"FsId": workflow.FsId,
"DocId": workflow.DocID,
"WorkflowName": process[0].workflowDisplayName,
"Status": workflow.Status,
"DispatchNumber": workflow.DispatchNumber,
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
"InstanceID": workflow.InstanceID
"SerialNumber": process.serialNumber,
"Folio": process.workflowInstanceDataFields.Subject,
"Senders": process.originator || process.originator,
"CreateDate": momentG(new Date(process.taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": process.workflowInstanceDataFields.ViewerRequest,
"Remetente": process.workflowInstanceDataFields.Sender,
"Note": process.workflowInstanceDataFields.TaskMessage || process.workflowInstanceDataFields.Note,
"FolderId": process.workflowInstanceDataFields.FolderID,
"FsId": process.workflowInstanceDataFields.FsId,
"DocId": process.workflowInstanceDataFields.DocID,
"WorkflowName": process.workflowDisplayName,
"Status": process.workflowInstanceDataFields.Status,
"DispatchNumber": process.workflowInstanceDataFields.DispatchNumber,
"AttachmentsProcessLastInstanceID": process.workflowInstanceDataFields.AttachmentsProcessLastInstanceID,
"InstanceID": process.workflowInstanceDataFields.InstanceID
}
this.fulltask = {
Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL,
interveners: process[0].interveners,
originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName,
Documents: process.Documents,
actions: process.actions,
activityInstanceName: process.activityInstanceName,
formURL: process.formURL,
interveners: process.interveners,
originator: process.originator,
serialNumber: process.serialNumber,
taskStartDate: process.taskStartDate,
totalDocuments: process.totalDocuments,
workflowDisplayName: process.workflowDisplayName,
workflowID: process.workflowID,
workflowInstanceDataFields: process.workflowInstanceDataFields,
workflowInstanceFolio: process.workflowInstanceFolio,
workflowInstanceID: process.workflowInstanceID,
workflowName: process.workflowName,
}
})
})
} else {
this.platform.ready().then(() => {
this.onlinecheck = false;
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
console.log("expedient ditail", process)
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
origina = JSON.parse(process[0].originator)
}
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": workflow.Subject,
"Senders": origina.email || process[0].originator,
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": workflow.ViewerRequest,
"Remetente": workflow.Sender,
"Note": workflow.TaskMessage || workflow.Note,
"FolderId": workflow.FolderID,
"FsId": workflow.FsId,
"DocId": workflow.DocID,
"WorkflowName": process[0].workflowDisplayName,
"Status": workflow.Status,
"DispatchNumber": workflow.DispatchNumber,
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
"InstanceID": workflow.InstanceID
}
this.fulltask = {
Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL,
interveners: process[0].interveners,
originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName,
}
})
})
}
}
@@ -9,6 +9,7 @@ import { Platform } from '@ionic/angular';
import { BackgroundService } from '../../../services/background.service';
import { ThemeService } from 'src/app/services/theme.service'
import { SortService } from 'src/app/services/functions/sort.service';
import {Storage } from '@ionic/storage';
@Component({
selector: 'app-expediente',
@@ -40,6 +41,7 @@ export class ExpedientePage implements OnInit {
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
private sortService: SortService,
private storage: Storage
) { }
ngOnInit() {
@@ -112,63 +114,48 @@ export class ExpedientePage implements OnInit {
addProcessTODb(task) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('gabinete-expediente',task).then(() => {
console.log('GABINETE EXPEDIENTE SAVED')
})
} else {
this.sqliteservice.addProcess(task);
}
}
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() {
this.taskslist = new Array();
this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => {
console.log("All expedientes from local,", expediente)
expediente.forEach((element) => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
let exped = {
"CreateDate": element.taskStartDate,
"DocumentsQty": element.totalDocuments,
"Senders": workflow.Senders,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"Subject": workflow.Subject,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName
}
this.taskslist.push(exped)
});
this.listToPresent = this.taskslist
})
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('gabinete-expediente').then((expediente) => {
this.listToPresent = expediente
})
} else {
this.taskslist = new Array();
this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => {
console.log("All expedientes from local,", expediente)
expediente.forEach((element) => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
let exped = {
"CreateDate": element.taskStartDate,
"DocumentsQty": element.totalDocuments,
"Senders": workflow.Senders,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"Subject": workflow.Subject,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName
}
this.taskslist.push(exped)
});
this.listToPresent = this.taskslist
})
}
}
}
@@ -31,6 +31,7 @@ import { Platform } from '@ionic/angular';
import { BackgroundService } from 'src/app/services/background.service';
import { SortService } from 'src/app/services/functions/sort.service';
import { DataService } from 'src/app/services/data.service';
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-gabinete-digital',
@@ -135,6 +136,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
public ThemeService: ThemeService,
private sortService: SortService,
private dataService: DataService,
private storage: Storage
) {
this.loggeduser = authService.ValidatedUser;
@@ -215,7 +217,9 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
addProcessToDB(data) {
this.platform.ready().then(() => {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('GabineteProcess', data).then(() => {
console.log('Gabinete process saved')
})
} else {
data.forEach(element => {
@@ -245,39 +249,77 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
getAllProcessFromDB() {
this.hideRefreshButton();
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('GabineteProcess').then((allprocess: any[]) => {
console.log('ALL PROCESS WEB',allprocess )
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();
let task = {
"SerialNumber": element.serialNumber,
"Folio": element.workflowInstanceDataFields.Subject,
"Senders": element.workflowInstanceDataFields.Sender,
//"CreateDate": taskDate,
"CreateDate": new Date(element.taskStartDate),
"DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
"Remetente": element.workflowInstanceDataFields.Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": element.workflowInstanceDataFields.DispatchDocId,
"FolderID": element.workflowInstanceDataFields.FolderID,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
"Status": element.workflowInstanceDataFields.Status,
"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.sortService.sortDate(this.allProcessesList, 'CreateDate')
});
})
} 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.sortService.sortDate(this.allProcessesList, 'CreateDate')
});
console.log("All process from db ", allprocess)
})
}
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);
dataTranform(data) {
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.sortService.sortDate(this.allProcessesList, 'CreateDate')
});
console.log("All process from db ", allprocess)
})
}
sortArrayISODate(myArray: any) {
@@ -495,6 +537,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
let allProcessesList = allPreocesses_;
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Conhecimento')
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Revisar Diploma')
if (!this.p.userRole(['PR'])) {
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas')
@@ -14,6 +14,7 @@ import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { Platform } from '@ionic/angular';
import { SortService } from 'src/app/services/functions/sort.service';
import { Storage } from '@ionic/storage';
@Component({
@@ -47,6 +48,7 @@ export class PendentesPage implements OnInit {
private platform: Platform,
private backgroundservices: BackgroundService,
private sortService: SortService,
private storage: Storage
) {
this.loggeduser = authService.ValidatedUser;
this.profile = 'mdgpr';
@@ -104,6 +106,9 @@ export class PendentesPage implements OnInit {
pendentesList = removeDuplicate(pendentesList)
pendentesList = this.sortService.sortDate(pendentesList, 'CreateDate');
this.listToPresent = pendentesList;
this.storage.set('pendente-list',pendentesList).then(() => {
console.log('Pendente list SAVED')
})
this.skeletonLoader = false;
}, (error) => {
@@ -116,34 +121,41 @@ export class PendentesPage implements OnInit {
getFromDb() {
this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((process: any[]) => {
var pendingList = []
console.log('Pendentes off off',process )
process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
if (workflow.Status === "Pending") {
let task = {
"CreateDate": new Date(element.taskStartDate),
"DocumentsQty": element.totalDocuments,
"FolderID": workflow.FolderID,
"Folio": workflow.Subject,
"Senders": workflow.Sender,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"WorkflowName": element.workflowDisplayName
}
pendingList.push(task)
}
});
pendingList = this.sortService.sortDate(pendingList, 'CreateDate');
this.listToPresent = pendingList;
console.log('pendentes', pendingList)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('pendente-list').then((pendentes) => {
this.listToPresent =pendentes
})
})
} else {
this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((process: any[]) => {
var pendingList = []
console.log('Pendentes off off',process )
process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
if (workflow.Status === "Pending") {
let task = {
"CreateDate": new Date(element.taskStartDate),
"DocumentsQty": element.totalDocuments,
"FolderID": workflow.FolderID,
"Folio": workflow.Subject,
"Senders": workflow.Sender,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"WorkflowName": element.workflowDisplayName
}
pendingList.push(task)
}
});
pendingList = this.sortService.sortDate(pendingList, 'CreateDate');
this.listToPresent = pendingList;
console.log('pendentes', pendingList)
})
})
}
}
async refreshing() {
@@ -172,20 +172,23 @@ export class NewPublicationPage implements OnInit {
this.capturedImageTitle = new Date().getTime() + '.jpeg';
} */
laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
async laodPicture() {
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Uri,
source: CameraSource.Photos
});
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name
this.convertBlobToBase64Worker.postMessage(blob);
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
this.capturedImage = oEvent.data
console.log(this.capturedImage)
};
}
}
@@ -38,11 +38,15 @@
*ngFor="let publication of getpublication"
(click)="goToPublicationDetail(publication.DocumentId)"
>
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
<ion-img src="{{publication.FileBase64}}" alt="image"></ion-img>
</div>
<div *ngIf="publication.FileBase64.length < 30" class="post-img">
<img src="/assets/icon/icon-no-image.svg" alt="image">
<div *ngIf="publication.FileBase64 != null">
<div *ngIf="publication.FileBase64.length < 30; else imageLoaded" class="post-img">
<img src="/assets/icon/icon-no-image.svg">
</div>
<ng-template #imageLoaded>
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
<img src="{{publication.FileBase64}}" alt="">
</div>
</ng-template>
</div>
<div class="post-content px-20">
<div class="post-title-time">
@@ -68,15 +68,16 @@ export class ViewPublicationsPage implements OnInit {
if (typeof (this.folderId) == 'object') {
this.folderId = this.folderId['ProcessId']
}
this.testForkJoin()
//this.testForkJoin()
this.getPublicationDetail();
setTimeout(() => {
this.getPublicationsIds();
/* setTimeout(() => {
this.getPublicationsIds();
}, 1000);
}, 1000); */
this.backgroundservice.registerBackService('Online', () => {
this.getPublicationDetail();
this.testForkJoin()
//this.testForkJoin()
})
@@ -91,18 +92,18 @@ export class ViewPublicationsPage implements OnInit {
// if (typeof (this.id == 'object') {
// this.id = this.id['ProcessId']
// }
this.testForkJoin()
this.getPublicationDetail();
//this.testForkJoin()
//this.getPublicationDetail();
// this.getPublicationsIds();
}
doRefresh = (event) => {
setTimeout(() => {
this.testForkJoin()
//setTimeout(() => {
//this.testForkJoin()
this.getPublicationDetail();
// this.getPublicationsIds();
this.getPublicationsIds();
event.target.complete();
}, 3000);
//}, 3000);
}
@@ -116,13 +117,14 @@ export class ViewPublicationsPage implements OnInit {
}
getPublicationDetail() {
this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{
this.publications.GetPresidentialAction(this.folderId).subscribe(res => {
console.log(res);
this.item = res;
this.sqliteservice.updatePublicationsDetails(this.folderId, JSON.stringify(res));
});
}
// goes to fork
// goes to fork
// getPublicationsIds() {
// this.showLoader = true;
@@ -138,22 +140,22 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = true;
const folderId = this.folderId
this.getFromDB()
this.publications.GetPublicationsImages(this.folderId).subscribe(res => {
console.log('publications ids', res)
this.publicationList = new Array();
/* for(let i of res) {
this.publications.GetPublicationById(i).subscribe(ress => {
console.log('publications by ids', ress)
let item: Publication = this.publicationPipe.itemList(ress)
console.log('publications by ids 2', item)
this.publicationList.push(item);
})
} */
for(let i = 0; i < res.length; i++) {
this.publications.GetPublicationById(res[i]).subscribe(ress => {
console.log('publications by ids', ress)
let item: Publication = this.publicationPipe.itemList(ress)
console.log('publications by ids 2', item)
this.publicationList.push(item);
})
}
res.forEach(element => {
/* res.forEach(element => {
console.log('publications elements', element)
this.publications.GetPublicationById(element).subscribe(ress => {
console.log('publications by ids', ress)
@@ -162,13 +164,13 @@ export class ViewPublicationsPage implements OnInit {
this.publicationList.push(ress);
})
});
}); */
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList;
this.showLoader = false;
/* this.publicationList = new Array();
@@ -189,7 +191,7 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = true;
const folderId = this.folderId
this.getFromDB();
this.publications.GetPublications(this.folderId).subscribe(res => {
console.log(this.folderId)
@@ -223,13 +225,13 @@ export class ViewPublicationsPage implements OnInit {
});
}
testForkJoin(){
testForkJoin() {
forkJoin([
this.getPublicationsIds(),
this.getPublications(),
]).subscribe(allResults =>{
]).subscribe(allResults => {
this.publicationList = allResults[2]
})
}
@@ -238,7 +240,7 @@ export class ViewPublicationsPage implements OnInit {
this.sqliteservice.getActionById(this.folderId).then((publications) => {
console.log('publications', publications)
let item = {
/* let item = {
ActionType: publications[0].ActionType,
DateBegin: publications[0].DateBegin,
DateEnd: publications[0].DateEnd,
@@ -246,10 +248,11 @@ export class ViewPublicationsPage implements OnInit {
Detail: publications[0].Detail,
ProcessId: publications[0].ProcessId
}
this.publicationDitails = item;
this.publicationDitails = item; */
this.item = this.isJson(publications[0].publicationsDetails);
let publicationArray = [];
JSON.parse(publications[0].publications).forEach(element => {
this.isJson(publications[0].publications).forEach(element => {
let publicationlis = {
DateIndex: element.DateIndex,
DatePublication: element.DatePublication,
@@ -264,11 +267,20 @@ export class ViewPublicationsPage implements OnInit {
publicationArray.push(publicationlis);
});
this.getpublication = publicationArray;
})
}
isJson(str) {
try {
JSON.parse(str);
} catch (e) {
return str;
}
return JSON.parse(str);
}
async AddPublication(publicationType: any, folderId: any) {
const modal = await this.modalController.create({
component: NewPublicationPage,