Merge branch 'develop' into bugfix/chat-create-event

This commit is contained in:
Peter Maquiran
2022-08-03 14:30:13 +01:00
39 changed files with 337 additions and 244 deletions
+2 -1
View File
@@ -45,7 +45,8 @@
</ion-buttons>
</div>
<div class="line"></div>
<ion-label (click)="asyncNotification()">{{notificationdata.length}} novas notificações</ion-label>
<ion-label (click)="asyncNotification()" *ngIf="notificationdata">{{notificationdata.length}} novas notificações</ion-label>
<ion-label (click)="asyncNotification()" *ngIf="!notificationdata">0 novas notificações</ion-label>
</div>
</ion-header>
+17 -13
View File
@@ -14,28 +14,32 @@
</div>
</ion-header>
<ion-content fullscreen>
<div class="media d-flex align-items-center justify-center">
<div *ngIf="view" class="media d-flex align-items-center justify-center">
<div class="media-content w-100 d-flex align-items-center justify-center">
<ion-slides style="width: 100%; height: 100%;" [options]="sliderOpts">
<ion-slide>
<div class="swiper-zoom-container">
<div>
<div class="swiper-zoom-container" >
<div style="overflow: scroll; width: 100%; height:100%;">
<img src="{{image}}">
</div>
<!-- <div *ngIf="type == 'application/pdf'">
<iframe width="100%" height="100%" [src]="base64Sanitize" type="application/vnd.openxmlformats-officedocument.wordprocessingml.document"></iframe> -->
<!-- <pdf-viewer [src]="image"
[render-text]="true"
[original-size]="false"
style="width: 400px; height: 500px"
></pdf-viewer> -->
<!-- </div> -->
</div>
<div *ngIf="!view" class="swiper-zoom-container" >
<img src="{{image}}">
</div>
</ion-slide>
</ion-slides>
</div>
</div>
</ion-content>
<ion-slides *ngIf="!view" style="width: 100%; height: 100%;" [options]="sliderOpts">
<ion-slide>
<div class="swiper-zoom-container" >
<img src="{{image}}">
</div>
</ion-slide>
</ion-slides>
</ion-content>
+10 -7
View File
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams } from '@ionic/angular';
import { ModalController, NavParams, Platform } from '@ionic/angular';
import { DomSanitizer} from '@angular/platform-browser';
import { pdfDefaultOptions } from 'ngx-extended-pdf-viewer';
@@ -14,10 +14,10 @@ export class ViewMediaPage implements OnInit {
type: any;
name: string
_updatedAt: string
view: boolean
sliderOpts = {
zoom: true,
maxRation: 2
zoom: true
};
base64Sanitize:any = "";
@@ -26,6 +26,7 @@ export class ViewMediaPage implements OnInit {
private modalController: ModalController,
private navParams:NavParams,
public sanitizer: DomSanitizer,
private platform: Platform,
) {
this.image = this.navParams.get('image')
@@ -38,6 +39,12 @@ export class ViewMediaPage implements OnInit {
ngOnInit() {
this.base64Sanitize = this.sanitizer.bypassSecurityTrustResourceUrl(this.image);
if (this.platform.is('desktop')) {
this.view = true;
} else {
this.view = false;
}
}
@@ -60,10 +67,6 @@ export class ViewMediaPage implements OnInit {
const blob = new Blob(byteArrays, { type: contentType });
return blob;
};
close(){
this.modalController.dismiss()
@@ -117,9 +117,9 @@
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<mat-form-field class="date-hour-picker">
<mat-form-field appearance="none" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date"
placeholder="Data Inicio*"
[(ngModel)]="postEvent.StartDate"
[disabled]="disabled"
[min]="currentDate"
@@ -149,9 +149,9 @@
-->
<div (click)="openFim()" class="ion-input-class flex-grow-1 justify-center align-center materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<mat-form-field class="date-hour-picker">
<mat-form-field appearance="none" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date"
placeholder="Data de fim*"
[(ngModel)]="postEvent.EndDate"
[disabled]="disabled"
[min]="currentDate"
@@ -104,21 +104,6 @@ export class NewEventPage implements OnInit {
this.selectedDate = this.navParams.get('eventSelectedDate');
this.taskParticipants = this.navParams.get('attendees');
let now = new Date();
if(now.getMinutes() <= 30){
this.autoStartTime = new Date(now.setMinutes(30));
this.postEvent.StartDate = this.autoStartTime;
this.autoEndTime = new Date(this.autoStartTime.getTime() + 30 * 60000);
this.postEvent.EndDate = this.autoEndTime;
}
else{
this.autoStartTime = new Date(now.setHours(now.getHours()+1));
this.autoStartTime = new Date(this.autoStartTime.setMinutes(0));
this.postEvent.StartDate = this.autoStartTime;
this.autoEndTime = new Date(this.autoStartTime.getTime() + 30 * 60000);
this.postEvent.EndDate = this.autoEndTime;
}
}
ngOnInit() {
+3 -1
View File
@@ -37,6 +37,7 @@
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
<div class="width-100" [ngSwitch]="segment">
<ion-list *ngSwitchCase="'Contactos'">
@@ -133,12 +134,13 @@
<div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.id ==idSelected">
<div class="item-message" *ngIf="group.otherUserType == false">{{group.lastMessage.u.name}}: {{group.lastMessage.msg}} </div>
<div *ngIf="group.otherUserType == true">{{group.userThatIsTyping}} está escrever ...</div>
<div class="item-files add-ellipsis" *ngIf="group.lastMessage.file">
<fa-icon *ngIf="group.lastMessage.file.type != 'application/meeting' && group.lastMessage.file.type != 'application/audio'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<fa-icon *ngIf="group.lastMessage.file.type == 'application/audio'" icon="file-audio" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<span *ngIf="group.lastMessage.file.type == 'application/audio'" class="item-files-title"> audio </span>
<fa-icon *ngIf="group.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<span *ngIf="group.lastMessage.file.type != 'application/audio'" class="item-files-title"> {{ group.lastMessage.attachments[0].title }}</span>
<span *ngIf="group.lastMessage.file.type != 'application/audio' && group.lastMessage.attachments" class="item-files-title"> {{ group.lastMessage.attachments[0].title }}</span>
</div>
<div class="item-files" *ngIf="group.attachments">
<div *ngIf="group.value.lastMessage.attachments[0].image_url">
+8 -4
View File
@@ -125,6 +125,8 @@ export class ChatPage implements OnInit {
this.showLoader = true;
this.segment = 'Contactos'
}
ngOnInit() {
@@ -320,7 +322,6 @@ export class ChatPage implements OnInit {
async setIntervenient(data) {
this.taskParticipants = removeDuplicate(data)
}
async setIntervenientCC(data) {
@@ -339,12 +340,11 @@ export class ChatPage implements OnInit {
}
onSegmentChange() {
//this.load();
this.wsChatMethodsService.getAllRooms();
}
doRefresh(event) {
setTimeout(() => {
//this.load();
event.target.complete();
}, 1000);
}
@@ -357,7 +357,6 @@ export class ChatPage implements OnInit {
});
}
getDirectMessagesDB() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storageservice.get("rooms").then((rooms) =>{
@@ -560,6 +559,11 @@ export class ChatPage implements OnInit {
}
roomDataFileType(roomData) {
return roomData?.lastMessage?.file?.type || null
}
async transformGroups(data) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
let groupsArray = [];
@@ -150,7 +150,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
})
//this.loadFiles();
}
setStatus(status: string) {
@@ -104,7 +104,6 @@ export class ContactsPage implements OnInit {
this.room = res['room'];
await this.WsChatMethodsService.getAllRooms();
this.getDirectMessage(this.room._id);
});
@@ -139,26 +138,10 @@ export class ContactsPage implements OnInit {
}
async openMessages(username:string){
/* this.close(); */
let dm:any;
//Create new room
this.createRoom(username);
//Get direct messages (dm)
/* this.getDirectMessage(this.room._id); */
this.createRoom(username);
/* const modal = await this.modalController.create({
component: MessagesPage,
cssClass: 'group-messages',
backdropDismiss: false,
componentProps: {
dm: dm,
},
});
await modal.present();
modal.onDidDismiss(); */
}
}
+9 -2
View File
@@ -40,6 +40,7 @@ import { HttpErrorResponse } from '@angular/common/http';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { Filesystem, Directory } from '@capacitor/filesystem';
const IMAGE_DIR = 'stored-images';
@@ -125,7 +126,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private sqlservice: SqliteService,
public wsChatMethodsService: WsChatMethodsService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private storage: Storage,
@@ -149,7 +149,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.wsChatMethodsService.openRoom(this.roomId)
@@ -162,6 +161,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
ngOnInit() {
this.createDirectoryImage()
this.wsChatMethodsService.getAllRooms();
this.chatService.refreshtoken();
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
@@ -1075,6 +1075,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
// });
// }
async createDirectoryImage() {
await Filesystem.mkdir({
path: IMAGE_DIR,
directory: Directory.Data,
recursive: true
});
}
}
@@ -184,11 +184,14 @@ export class DiplomasGerarPage implements OnInit {
async sendExpedienteToPending() {
const loader = this.toastService.loading()
this.despachoService.sendExpedienteToPending(this.serialnumber).subscribe(res => {
this.goBack();
this.toastService.successMessage()
loader.remove()
},
error => {
loader.remove()
this.toastService.badRequest("Processo não enviado para despacho")
});
@@ -324,12 +324,15 @@ export class ExpedienteDetailPage implements OnInit {
}
sendExpedienteToPending() {
const loader = this.toastService.loading()
this.processes.SetTaskToPending(this.serialNumber).subscribe(res => {
this.toastService._successMessage('Processo enviado para pendentes')
this.goBack();
loader.remove()
},
(error) => {
loader.remove()
this.toastService._badRequest('Processo não enviado para pendentes')
});
}
@@ -133,12 +133,15 @@ export class ExpedientePrPage implements OnInit {
}
sendExpedienteToPending() {
const loader = this.toastService.loading()
this.processes.SetTaskToPending(this.serialnumber).subscribe(res=>{
this.toastService._successMessage('Processo enviado para pendentes')
this.goBack();
loader.remove()
},
(error)=>{
loader.remove()
this.toastService._badRequest('Processo não enviado para pendentes')
});
}
+13 -1
View File
@@ -13,7 +13,11 @@ import { ThemeService } from 'src/app/services/theme.service';
import { StorageService } from 'src/app/services/storage.service';
import { PermissionService } from 'src/app/services/permission.service';
import { PermissionList } from 'src/app/models/permission/permissionList';
import { MessageModel, DeleteMessageModel } from '../../models/beast-orm'
import { MessageModel, DeleteMessageModel } from '../../models/beast-orm';
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { Storage } from '@ionic/storage';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
import { ChatService } from 'src/app/services/chat.service';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
@@ -46,6 +50,10 @@ export class LoginPage implements OnInit {
public ThemeService: ThemeService,
private storageservice: StorageService,
public p: PermissionService,
private WsChatService: WsChatService,
private storage: Storage,
public WsChatMethodsService: WsChatMethodsService,
private ChatService: ChatService
) {}
ngOnInit() {
@@ -124,6 +132,7 @@ export class LoginPage implements OnInit {
await this.authService.loginChat(attempt.ChatData.data);
await this.authService.loginToChatWs();
this.ChatService.setheader()
}
@@ -134,7 +143,9 @@ export class LoginPage implements OnInit {
} else {
this.WsChatService.logout();
this.clearStoreService.clear();
this.WsChatMethodsService.clearChat();
SessionStore.delete();
window.localStorage.clear();
await MessageModel.deleteAll()
@@ -148,6 +159,7 @@ export class LoginPage implements OnInit {
if(attempt.ChatData) {
await this.authService.loginChat(attempt.ChatData.data);
await this.authService.loginToChatWs();
this.ChatService.setheader()
}
this.getToken();
@@ -31,7 +31,7 @@
<ion-datetime
[(ngModel)]="folder.DateBegin"
class="d-block d-md-none"
placeholder="Início"
placeholder="Data início*"
displayFormat="D MMM YYYY H:mm"
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
@@ -41,7 +41,7 @@
<mat-form-field appearance="none" class="date-hour-picker d-none d-md-block">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date"
placeholder="Data inicio*"
[formControl]="dateControlStart"
[min]="minDate"
[disabled]="disabled"
@@ -70,7 +70,7 @@
<ion-datetime
class="d-block d-md-none"
[(ngModel)]="folder.DateEnd"
placeholder="Fim"
placeholder="Data de fim*"
displayFormat="D MMM YYYY H:mm"
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
@@ -78,9 +78,9 @@
max="2025">
</ion-datetime>
<mat-form-field class="date-hour-picker d-none d-md-block">
<mat-form-field appearance="none" class="date-hour-picker d-none d-md-block">
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date"
placeholder="Data de fim*"
[formControl]="dateControlEnd"
[min]="endMinDate"
[disabled]="disabled"
@@ -75,14 +75,14 @@ export class NewActionPage implements OnInit {
this.dateControlStart = new FormControl(moment(new Date()));
this.dateControlEnd = new FormControl(moment(new Date(new Date().getTime() + 15 * 60000)));
this.folder.DateBegin = new Date().toISOString()
this.folder.DateEnd = (new Date(new Date().getTime() + 15 * 60000)).toISOString()
// this.folder.DateBegin = new Date().toISOString()
// this.folder.DateEnd = (new Date(new Date().getTime() + 15 * 60000)).toISOString()
}
ngOnInit() {
this.segment = "Evento";
this.setDefaultTime()
// this.setDefaultTime()
}
setDefaultTime() {
+8 -2
View File
@@ -20,7 +20,7 @@ import { RoomService } from './chat/room.service';
import { Storage } from '@ionic/storage';
import { InitialsService } from './functions/initials.service';
import { PermissionService } from './permission.service';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
@Injectable({
providedIn: 'root'
})
@@ -48,7 +48,8 @@ export class AuthService {
private AttachmentsService: AttachmentsService,
private storage: Storage,
private initialsService: InitialsService,
public p: PermissionService, ) {
public p: PermissionService,
public WsChatMethodsService: WsChatMethodsService, ) {
this.headers = new HttpHeaders();
@@ -201,6 +202,11 @@ export class AuthService {
this.WsChatService.setStatus('online')
setTimeout(() => {
this.WsChatMethodsService.getAllRooms();
}, 200);
// alert('wsLogin')
}).catch((message) => {
+31 -25
View File
@@ -1,14 +1,13 @@
import { HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AuthService } from './auth.service';
import { HttpService } from './http.service';
import { StorageService } from './storage.service';
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { Storage } from '@ionic/storage';
import { PermissionService } from './permission.service';
import { SessionStore } from '../store/session.service';
import { ChangeProfileService } from 'src/app/services/change-profile.service';
@Injectable({
providedIn: 'root'
})
@@ -24,19 +23,21 @@ export class ChatService {
constructor(
private http: HttpClient,
private httpService: HttpService,
private authService: AuthService,
private storage: Storage,
private storageService: StorageService,
public p: PermissionService) {
public p: PermissionService,
private changeProfileService: ChangeProfileService,) {
this.setheader()
this.changeProfileService.registerCallback(() => {
this.setheader();
})
}
getDocumentDetails(url: string) {
let headersc = new HttpHeaders();
headersc = headersc.set('X-User-Id', this.loggedUserChat['data'].userId);
headersc = headersc.set('X-Auth-Token', this.loggedUserChat['data'].authToken);
headersc = headersc.set('X-User-Id', SessionStore.user.ChatData.data.userId);
headersc = headersc.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
headersc = headersc.set('Sec-Fetch-Dest', 'attachment');
headersc = headersc.set('Sec-Fetch-Mode', 'navigate');
headersc = headersc.set('Cookie', 'rc_uid=fsMwcNdufWvdnChj7');
@@ -342,7 +343,6 @@ export class ChatService {
setheader() {
try {
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
this.loggedUserChat = this.authService.ValidatedUserChat;
this.headers = new HttpHeaders();
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
@@ -360,24 +360,30 @@ export class ChatService {
}
refreshtoken() {
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
let options = {
headers: this.headers
};
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
let data = {
status: res['status'],
data: {
userId: res['data'].userId,
authToken: res['data'].authToken
if(this.headers) {
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
let options = {
headers: this.headers
};
return this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).subscribe(async res => {
let data = {
status: res['status'],
data: {
userId: res['data'].userId,
authToken: res['data'].authToken
}
}
}
SessionStore.user.ChatData = data
SessionStore.save()
SessionStore.user.ChatData = data
SessionStore.save()
this.setheader()
// console.log(res)
// console.log(SessionStore.user.ChatData)
});
} else {
this.setheader()
// console.log(res)
// console.log(SessionStore.user.ChatData)
});
}
}
}
+2 -2
View File
@@ -77,7 +77,7 @@ export class MessageService {
this.ts = ts
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""}
this.t = t
this._id = _id
this._id = _id || ""
this._updatedAt = _updatedAt || new Date().getTime()
this.file = file
this.temporaryData = temporaryData
@@ -310,7 +310,7 @@ export class MessageService {
async addMessageDB() {
if(!this.addToDb) {
this.addToDb= true
this.addToDb = true
const message = this.getChatObj()
delete message.id
+77 -26
View File
@@ -39,6 +39,7 @@ export class RoomService {
name = ''
_updatedAt = {}
hasLoadHistory = false
hasLoadHistoryMessageRF = []
restoreFromOffline = false
duration = ''
isTyping = false
@@ -179,7 +180,7 @@ export class RoomService {
if(difference < 0) {
this.deleteRoom()
this.deleteRoom();
} else {
setTimeout(() => {
@@ -236,18 +237,20 @@ export class RoomService {
let IncomingChatMessageArgs = IncomingChatMessage.fields.args[0]
let ChatMessage : ChatMessageInterface = this.fix_updatedAt(IncomingChatMessageArgs)
if(!this.messagesLocalReference.includes(ChatMessage.localReference)) {
const allMessageIds = this.messages.map((e)=> e._id);
if(!this.messagesLocalReference.includes(ChatMessage.localReference) && !allMessageIds.includes(ChatMessage?._id)) {
this.messagesLocalReference.push(ChatMessage.localReference);
const message = await this.prepareCreate({message: ChatMessage, save: true})
const message = await this.prepareCreate({message: ChatMessage, save: true});
message.messageSend = true
this.lastMessage = message
this.calDateDuration(ChatMessage._updatedAt)
this.lastMessage = message;
this.calDateDuration(ChatMessage._updatedAt);
if (message.t == 'r') {
this.name = message.msg
this.name = message.msg;
}
if(this.isSenderIsNotMe(ChatMessage)) {
@@ -312,19 +315,17 @@ export class RoomService {
this.otherUserType = args[1]
this.readAllMessage()
//
// alert(JSON.stringify(args))
} else if(args[0]?.method == 'viewMessage' || args[1]?.method == 'viewMessage') {
this.readAllMessage()
} else if(args[0]?.method == 'deleteMessage' || args[1]?.method == 'deleteMessage') {
// alert('delete')
//
this.deleteMessage(args[1]?.method?._id)
} else {
// alert('miss')
}
@@ -468,7 +469,7 @@ export class RoomService {
deleteAll() {
this.messages.forEach((message)=>{
this.messages.forEach((message) => {
if(message?._id) {
this.sendDeleteRequest(message._id)
}
@@ -477,7 +478,7 @@ export class RoomService {
async delateMessageToSendToOthers(userId) {
const deleteMessage = await DeleteMessageModel.all()
const deleteMessage = await DeleteMessageModel.all();
const toSend = deleteMessage.filter((DeleteMessage:string[])=> ! DeleteMessage.includes(userId))
@@ -493,8 +494,8 @@ export class RoomService {
this.WsChatService.deleteMessage(msgId).then(async() => {
message.delateRequest = true
await message.save()
this.deleteMessage(msgId)
await message.save();
this.deleteMessage(msgId);
})
} else {
@@ -516,7 +517,7 @@ export class RoomService {
*/
async send({file = null, attachments = null, temporaryData = {}}) {
const localReference = uuidv4()
const localReference = uuidv4();
let offlineChatMessage = {
rid: this.id,
@@ -529,9 +530,9 @@ export class RoomService {
this.message= ''
this.messagesLocalReference.push(localReference)
const message: MessageService = await this.prepareCreate({message:offlineChatMessage, save: environment.chatOffline})
this.messagesLocalReference.push(localReference)
await message.addMessageDB()
message.send()
@@ -547,7 +548,9 @@ export class RoomService {
this.sortRoomList()
}
if(this.hasLoadHistory == false) {
this.hasLoadHistoryMessageRF.push(localReference)
}
}
@@ -679,17 +682,17 @@ export class RoomService {
}
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
// console.log('load history', chatHistory)
//
const messagesId = this.messages.map((message)=> message._id)
chatHistory.result.messages.reverse().forEach(async(message: any) => {
await chatHistory.result.messages.reverse().forEach(async(message: any) => {
if (!messagesId.includes(message._id)) {
const messagesToSave = await this.prepareMessageCreateIfNotExist_iD({message: message});
if(messagesToSave) {
await messagesToSave.addMessageDB()
messagesToSave.addMessageDB()
}
}
@@ -703,6 +706,28 @@ export class RoomService {
}, 50)
this.hasLoadHistory = true
this.messageReorder();
}
async messageReorder() {
const reorderMessage: MessageService[] = this.messages.filter((message) =>
this.hasLoadHistoryMessageRF.includes(message?.localReference)
);
await this.messages.forEach( async (message, i) => {
if(this.hasLoadHistoryMessageRF.includes(message?.localReference)) {
this.messages.splice(i, 1)
}
})
this.hasLoadHistoryMessageRF = [];
reorderMessage.forEach((message) => {
this.messages.push(message)
});
}
@@ -714,10 +739,10 @@ export class RoomService {
await this.messages.forEach( async (message, index) => {
if(message._id) {
if(message._id) {
if(message.viewed.length == 0) {
this.messages[index].viewed = membersIds
this.messages[index].received = membersIds
this.messages[index].viewed = membersIds;
this.messages[index].received = membersIds;
await this.messages[index].save()
}
@@ -797,7 +822,33 @@ export class RoomService {
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
this.messages.push(wewMessage)
let found;
if(wewMessage.localReference != null) {
found = this.messages.find((MessageService, index) => {
if ( MessageService.localReference == wewMessage.localReference ) {
return true
} else {
return false
}
})
} else {
found = this.messages.find((MessageService, index) => {
if ( MessageService._id == wewMessage._id) {
return true
} else {
return false
}
})
}
if (!found) {
this.messages.push(wewMessage)
return wewMessage
}
return wewMessage
}
@@ -840,7 +891,7 @@ export class RoomService {
message = this.fix_updatedAt(message)
const found = this.messages.find((MessageService, index) => {
if (MessageService._id == message._id ) {
if (MessageService._id == message._id) {
return true
} else {
return false
@@ -14,7 +14,6 @@ import { SortService } from '../functions/sort.service';
import { chatUser } from 'src/app/models/chatMethod';
import { NfService } from 'src/app/services/chat/nf.service'
import { ChangeProfileService } from '../change-profile.service';
import { AuthService } from '../auth.service';
import { ChatStorageService } from './chat-storage.service';
import { ChatMethodsService } from './chat-methods.service';
import { AESEncrypt } from '../aesencrypt.service'
@@ -41,7 +40,7 @@ export class WsChatMethodsService {
users: chatUser[] = []
sessionStore = SessionStore
loggedUser: any;
delete = []
@@ -56,7 +55,6 @@ export class WsChatMethodsService {
private NfService: NfService,
private changeProfileService: ChangeProfileService,
private chatService: ChatService,
private authService: AuthService,
private ChatStorageService: ChatStorageService,
private ChatMethodsService:ChatMethodsService,
private AESEncrypt: AESEncrypt,
@@ -64,7 +62,7 @@ export class WsChatMethodsService {
private NetworkServiceService: NetworkServiceService,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.loadChat()
@@ -93,13 +91,6 @@ export class WsChatMethodsService {
})
// on change profile remove a rooms
this.changeProfileService.registerCallback(() => {
this.clearChat()
this.ReLoadChat()
this.storage.remove('Rooms');
})
}
private loadChat() {
@@ -173,8 +164,10 @@ export class WsChatMethodsService {
async getAllRooms () {
this.loadingWholeList = true
const rooms = await this.WsChatService.getRooms();
try {
await this.storage.remove('Rooms');
} catch(e) {}
await this.storage.remove('Rooms');
await rooms.result.update.forEach( async (roomData: room, index) => {
const roomId = this.getRoomId(roomData);
+12 -2
View File
@@ -78,7 +78,6 @@ export class WsChatService {
//
if(message.result) {
if(message.result.token) {
this.isLogin = true
this.loginResponse = message
@@ -106,6 +105,7 @@ export class WsChatService {
getRooms(roomOlder = 1480377601) {
//const requestId = uuidv4()
const requestId = uuidv4()
const message = {
@@ -121,7 +121,6 @@ export class WsChatService {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId) { // same request send
resolve(message)
//
return true
}
}})
@@ -186,6 +185,7 @@ export class WsChatService {
logout() {
this.isLogin = false
this.ws.connected = false
this.ws.disconnect()
}
// send message to room
@@ -749,6 +749,7 @@ export class WsChatService {
const data = JSON.parse(event.data)
//
// console.log(data)
for (const [key, value] of Object.entries(this.wsCallbacks)) {
if(value.type== 'Onmessage') {
@@ -777,6 +778,15 @@ export class WsChatService {
onerror: (event: any) => {
},
disconnect:() => {
if(this.socket) {
this.socket.onopen = (event: any) => {}
this.socket.onmessage = (event: any) => {}
this.socket.onclose = (event: any) => {}
this.socket.onerror = (event: any) => {}
this.socket.close()
}
}
}}
@@ -123,9 +123,9 @@
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<mat-form-field class="date-hour-picker">
<mat-form-field appearance="none" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date"
placeholder="Data Inicio*"
[(ngModel)]="postEvent.StartDate"
[disabled]="disabled"
[min]="currentDate"
@@ -155,9 +155,9 @@
-->
<div (click)="openFim()" class="ion-input-class flex-grow-1 justify-center align-center materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<mat-form-field class="date-hour-picker">
<mat-form-field appearance="none" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date"
placeholder="Data de fim*"
[(ngModel)]="postEvent.EndDate"
[disabled]="disabled"
[min]="currentDate"
@@ -133,22 +133,6 @@ export class NewEventPage implements OnInit {
this.loggeduser = userService.ValidatedUser;
this.postEvent = new Event();
let now = new Date();
if(now.getMinutes() <= 30) {
this.autoStartTime = new Date(now.setMinutes(30));
this.postEvent.StartDate = this.autoStartTime;
this.autoEndTime = new Date(this.autoStartTime.getTime() + 30 * 60000);
this.postEvent.EndDate = this.autoEndTime;
}
else {
this.autoStartTime = new Date(now.setHours(now.getHours()+1));
this.autoStartTime = new Date(this.autoStartTime.setMinutes(0));
this.postEvent.StartDate = this.autoStartTime;
this.autoEndTime = new Date(this.autoStartTime.getTime() + 30 * 60000);
this.postEvent.EndDate = this.autoEndTime;
}
}
ngOnInit() {
+7 -19
View File
@@ -27,13 +27,11 @@ import { DocumentViewer, DocumentViewerOptions } from '@ionic-native/document-vi
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { DomSanitizer } from '@angular/platform-browser';
import { AlertController, Platform } from '@ionic/angular';
import { Platform } from '@ionic/angular';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorResponse } from '@angular/common/http';
import { Howl } from 'howler';
import { runInThisContext } from 'vm';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
@@ -49,8 +47,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
@ViewChild('message-item') messageContainer: ElementRef;
loggedUser: any;
messages: any;
dm: any;
userPresence = '';
@@ -126,7 +122,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private platform: Platform,
private fileOpener: FileOpener,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.checkAudioPermission()
}
@@ -448,15 +443,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
else {
var str = msg.attachments[0].image_url;
str = str.substring(1, ((str.length) - 1));
// var str = msg.attachments[0].image_url;
// str = str.substring(1, ((str.length) - 1));
const encodedData = btoa(str);
// const encodedData = btoa(str);
let file = this.base64toBlob(encodedData, 'application/pdf')
let fileURL = URL.createObjectURL(file)
// let file = this.base64toBlob(encodedData, 'application/pdf')
// let fileURL = URL.createObjectURL(file)
window.open(fileURL);
// window.open(fileURL);
}
}
@@ -1028,7 +1023,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
this.downloadFileMsg(msg)
//this.testDownlod(msg)
} else {
var str = msg.attachments[0].image_url;
@@ -1075,12 +1069,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
testEditMessage(msg: MessageService) {
// msg.receptorReceive()
// alert('cool!')
}
start(track) {
if(this.audioPlay){
this.audioPlay.stop();
+60 -34
View File
@@ -59,7 +59,6 @@ export class NewGroupPage implements OnInit{
}
});
}
@@ -76,9 +75,8 @@ export class NewGroupPage implements OnInit{
}
}
close(){
//this.modalController.dismiss();
close() {
this.addGroupMessage.emit();
}
@@ -91,6 +89,9 @@ export class NewGroupPage implements OnInit{
let customFields = {}
let res:any;
const loader = this.toastService.loading();
if(this.thedate) {
let customFields = {
"countDownDate":this.thedate
@@ -102,6 +103,8 @@ export class NewGroupPage implements OnInit{
}
loader.remove();
// FsId
// DocId
@@ -109,36 +112,17 @@ export class NewGroupPage implements OnInit{
this.addGroupMessage.emit(res.result.rid);
await this.wsChatMethodsService.getAllRooms();
setTimeout(()=> {
this.documents.forEach(element => {
this.wsChatMethodsService.getGroupRoom(res.result.rid).send({
file: {
"name": element.Assunto,
"type": "application/webtrix",
"ApplicationId": element.ApplicationId,
"DocId": element.DocId,
"Assunto": element.Assunto,
},
temporaryData: {
data: {
selected: {
Id: element.DocId,
ApplicationType: element.ApplicationId
}
}
},
attachments: [{
"title": element.Assunto,
"description": element.Assunto,
"title_link_download": true,
"type": "webtrix",
"text": element.Assunto,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}],
})
});
}, 500)
if(!this.wsChatMethodsService.getGroupRoom(res.result.rid)) {
this.createGroupWithAttachmentsCath(res)
} else {
setTimeout(()=> {
this.createGroupWithAttachments(res)
}, 500)
}
} else {
@@ -148,6 +132,48 @@ export class NewGroupPage implements OnInit{
}
createGroupWithAttachmentsCath(res: any) {
if(!this.wsChatMethodsService.getGroupRoom(res.result.rid)) {
setTimeout(()=>{
this.createGroupWithAttachmentsCath(res)
}, 1500)
} else {
this.createGroupWithAttachments(res)
}
}
createGroupWithAttachments(res: any) {
this.wsChatMethodsService.getGroupRoom(res.result.rid).hasLoadHistory = true;
this.documents.forEach(element => {
this.wsChatMethodsService.getGroupRoom(res.result.rid).send({
file: {
"name": element.Assunto,
"type": "application/webtrix",
"ApplicationId": element.ApplicationId,
"DocId": element.DocId,
"Assunto": element.Assunto,
},
temporaryData: {
data: {
selected: {
Id: element.DocId,
ApplicationType: element.ApplicationId
}
}
},
attachments: [{
"title": element.Assunto,
"description": element.Assunto,
"title_link_download": true,
"type": "webtrix",
"text": element.Assunto,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}],
})
});
}
async addContacts(){
this.close();
@@ -278,6 +278,12 @@ export class EditEventToApproveComponent implements OnInit {
}
})
this.startDate = new Date(this.startDate);
this.startDate.setHours(this.startDate.getHours() + 1);
this.endDate = new Date(this.endDate);
this.endDate.setHours(this.endDate.getHours() + 1);
const event: EventToApproveEdit = {
SerialNumber: this.eventProcess.serialNumber,
Body: this.eventProcess.workflowInstanceDataFields.Body,
@@ -304,9 +310,9 @@ export class EditEventToApproveComponent implements OnInit {
this.eventsService.postEventToApproveEdit(event).subscribe(()=>{
this.toastService.successMessage('Evento editado');
this.toastService._successMessage('Evento editado');
}, error =>{
this.toastService.badRequest('Evento não editado');
this.toastService._badRequest('Evento não editado');
})
@@ -314,16 +320,16 @@ export class EditEventToApproveComponent implements OnInit {
if(document['action'] == 'add') {
delete document.action
this.attachmentsService.setEventAttachmentById(document).subscribe(()=>{
this.toastService.successMessage();
this.toastService._successMessage();
}, error =>{
this.toastService.badRequest();
this.toastService._badRequest();
});
} else if(document['action'] == 'delete') {
delete document.action
this.attachmentsService.deleteEventAttachmentById(document.Id).subscribe( res=>{
this.toastService.successMessage()
this.toastService._successMessage()
}, error =>{
this.toastService.badRequest()
this.toastService._badRequest()
})
}
@@ -2,7 +2,7 @@
<ion-progress-bar type="indeterminate" *ngIf="skeletonLoader"></ion-progress-bar>
<div class="title">
<div class="thetitle"><ion-label >Expediente</ion-label></div>
<div class="theicon">
<div class="theicon" (click)="refreshing()">
<button title="Atualizar" class="btn-no-color" (click)="refreshing()">
<ion-icon slot="end" class="title-icon font-awesome" name="reload-circle"></ion-icon>
</button>
@@ -84,6 +84,7 @@ export class ExpedientesPrPage implements OnInit {
}
refreshing() {
setTimeout(() => {
this.LoadList();
}, 1000);
@@ -95,6 +95,7 @@ export class ExpedientsPage implements OnInit {
}
doRefresh() {
setTimeout(() => {
this.LoadList();
}, 1000)
@@ -72,14 +72,16 @@ export class DespachosOptionsPage implements OnInit {
});
}
sendExpedienteToPending(){
sendExpedienteToPending() {
const loader = this.toastService.loading()
this.popoverController.dismiss();
this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{
this.toastService._successMessage()
loader.remove()
this.close();
},()=>{
loader.remove()
this.toastService._badRequest('Processo não encontrado')
});
}
@@ -98,11 +98,14 @@ export class DespachosPrOptionsPage implements OnInit {
}
sendExpedienteToPending() {
const loader = this.toastService.loading()
this.processes.SetTaskToPending(this.serialNumber).subscribe(res=>{
this.toastService._successMessage()
this.popoverController.dismiss('close')
loader.remove()
},()=>{
loader.remove()
this.toastService._badRequest('Processo não encontrado')
});
@@ -107,12 +107,14 @@ export class DiplomasGerarOptionsPage implements OnInit {
}
async sendExpedienteToPending() {
const loader = this.toastService.loading()
this.despachoService.sendExpedienteToPending(this.serialNumber).subscribe(res => {
this.goBack();
this.toastService.successMessage()
loader.remove()
},
error => {
loader.remove()
this.toastService.badRequest("Processo não enviado para despacho")
});
@@ -252,12 +252,14 @@ export class OptsExpedientePrPage implements OnInit {
sendExpedienteToPending(){
this.popoverController.dismiss();
const loader = this.toastService.loading()
this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{
loader.remove()
this.close();
},()=>{
this.toastService._badRequest('Processo não encontrado')
loader.remove()
});
}
@@ -81,11 +81,14 @@ export class RequestOptionsPage implements OnInit {
}
sendExpedienteToPending() {
const loader = this.toastService.loading()
this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{
this.toastService._successMessage()
this.close();
loader.remove()
},()=>{
loader.remove()
this.toastService._badRequest('Processo não encontrado')
});
@@ -30,7 +30,7 @@
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1">
<ion-datetime
<!-- <ion-datetime
class="d-block d-md-none"
[(ngModel)]="folder.DateBegin"
placeholder="Início"
@@ -38,12 +38,12 @@
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
max="2025">
</ion-datetime>
</ion-datetime> -->
<mat-form-field appearance="none" class="width-100 date-hour-picker d-md-block">
<mat-form-field appearance="none" class="width-100 date-hour-picker d-md-block">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date*"
placeholder="Data inicio*"
[(ngModel)]="folder.DateBegin"
[disabled]="disabled"
[min]="currentDate"
@@ -68,7 +68,7 @@
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class d-flex flex-grow-1">
<ion-datetime
<!-- <ion-datetime
class="flex-grow-1 d-md-none"
[(ngModel)]="folder.DateEnd"
placeholder="Fim"
@@ -76,16 +76,16 @@
minuteValues="0,5,10,15,20,25,30,35,40,45,50,55"
monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
max="2025">
</ion-datetime>
</ion-datetime> -->
<mat-form-field appearance="none" class="width-100 date-hour-picker d-md-block">
<input matInput [ngxMatDatetimePicker]="picker2"
placeholder="Choose a date*"
placeholder="Data de fim*"
[(ngModel)]="folder.DateEnd"
[disabled]="disabled"
[min]="currentDate"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker2"></mat-datepicker-toggle>
<mat-datepicker-toggle id="new-fim" matSuffix [for]="picker2"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker2
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
@@ -45,10 +45,10 @@ export class NewActionPage implements OnInit {
this.folder = new PublicationFolder();
this.folder = Object.assign(this.folder, {
/* this.folder = Object.assign(this.folder, {
DateBegin: new Date().toISOString(),
DateEnd: (new Date(new Date().getTime() + 15 * 60000)).toISOString(),
})
}) */
}