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

This commit is contained in:
Peter Maquiran
2021-12-09 18:03:36 +01:00
41 changed files with 1052 additions and 370 deletions
+282 -193
View File
@@ -9,7 +9,7 @@ import {
ComponentFactory,
Output
} from '@angular/core';
import { ModalController } from '@ionic/angular';
import { ModalController, Platform } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { GroupMessagesPage } from './group-messages/group-messages.page';
@@ -30,6 +30,7 @@ import { environment } from 'src/environments/environment';
import { TimeService } from 'src/app/services/functions/time.service';
import { ThemeService } from 'src/app/services/theme.service'
import { DataService } from 'src/app/services/data.service';
import { SqliteService } from 'src/app/services/sqlite.service';
@@ -43,13 +44,13 @@ export class ChatPage implements OnInit {
showLoader: boolean;
headers: HttpHeaders;
options:any;
X_User_Id:any;
X_Auth_Token:any;
options: any;
X_User_Id: any;
X_Auth_Token: any;
loggedUser: any;
/* Set segment variable */
segment:string;
segment: string;
allGroups: any[];
privateGroups: any[];
publicGroups: any[];
@@ -57,8 +58,8 @@ export class ChatPage implements OnInit {
userRooms: any[];
userChannels: any[];
userDirectMessages: any[];
result:any;
dmUsers:any[] = [];
result: any;
dmUsers: any[] = [];
idSelected: string;
desktopComponent: any = {
@@ -70,17 +71,17 @@ export class ChatPage implements OnInit {
//@ViewChild('groupMessages') child:GroupMessagesPage;
componentRef: any;
roomId:any;
groupRoomId:any;
showEmptyComponent=true;
showMessages=false;
showContacts=false;
showNewGroup=false;
showEditGroup=false;
showGroupMessages=false;
showGroupContacts=false;
showNewEvent=false;
showAttendees=false;
roomId: any;
groupRoomId: any;
showEmptyComponent = true;
showMessages = false;
showContacts = false;
showNewGroup = false;
showEditGroup = false;
showGroupMessages = false;
showGroupContacts = false;
showNewEvent = false;
showAttendees = false;
emptyTextDescription = 'Sem conversa selecionada';
@Output() getRoomInfo;
@@ -97,169 +98,171 @@ export class ChatPage implements OnInit {
/* Fim websockets variables*/
loggedUserChat:any;
loggedUserChat: any;
hideRefreshBtn = true;
taskParticipants: any = [];
taskParticipantsCc: any = [];
adding: "intervenient" | "CC" = "intervenient";
profile:'mdgpr' | 'pr';
profile: 'mdgpr' | 'pr';
eventSelectedDate: Date = new Date();
contacts: EventPerson[];
showEventEditOrOpen: "edit" | "add" | "" | "eventoToApprove" = ""
contacts: EventPerson[];
showEventEditOrOpen: "edit" | "add" | "" | "eventoToApprove" = ""
constructor(
private http:HttpClient,
private http: HttpClient,
private chatService: ChatService,
private modalController: ModalController,
private authService: AuthService,
private storage:Storage,
private storage: Storage,
private resolver: ComponentFactoryResolver,
private route: Router,
private timeService: TimeService,
public ThemeService: ThemeService,
private dataService:DataService,
private dataService: DataService,
private router: Router,
){
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.headers = new HttpHeaders();
window.onresize = (event) => {
if( window.innerWidth > 701){
this.modalController.dismiss();
}
};
private sqlservice: SqliteService,
private platform: Platform
}
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.headers = new HttpHeaders();
window.onresize = (event) => {
if (window.innerWidth > 701) {
this.modalController.dismiss();
}
};
}
ngOnInit() {
console.log(this.loggedUserChat);
this.segment = "Contactos";
this.authService.userData$.subscribe((res:any)=>{
this.loggedUser=res;
this.authService.userData$.subscribe((res: any) => {
this.loggedUser = res;
console.log(this.loggedUser);
this.load();
});
/* websocket functions */
//this.sendMsg();
/* websocket functions */
//this.sendMsg();
/* Fim websocket functions */
this.hideRefreshButton();
this.getChatMembers();
/* Fim websocket functions */
this.hideRefreshButton();
this.getChatMembers();
//Teste
let t = this.showDateDuration(new Date());
console.log(t);
//Teste
let t = this.showDateDuration(new Date());
console.log(t);
this.setStatus('away');
if(this.dataService.get("newGroup")){
this.openNewGroupPage();
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 (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) {
//alert('OIII')
} else {
if (this.dataService.get("newGroup")) {
this.openNewGroupPage();
}
}
}
});
}
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) {
alert('OIII')
} else {
if(this.dataService.get("newGroup")){
this.openNewGroupPage();
ngOnDestroy() {
this.setStatus('offline');
console.log('On Destroy')
}
setStatus(status: string) {
let body = {
message: '',
status: status,
}
this.chatService.setUserStatus(body).subscribe(res => {
console.log(res);
})
}
hideRefreshButton() {
window.onresize = (event) => {
if (window.innerWidth < 701) {
this.idSelected = '';
this.hideRefreshBtn = false;
}
else {
this.hideRefreshBtn = true;
if (this.idSelected == '') {
this.showEmptyComponent = true;
}
}
}
});
}
ngOnDestroy(){
this.setStatus('offline');
console.log('On Destroy')
}
setStatus(status:string){
let body = {
message: '',
status: status,
}
this.chatService.setUserStatus(body).subscribe(res => {
console.log(res);
})
}
hideRefreshButton(){
window.onresize = (event) => {
if( window.innerWidth < 701) {
if (window.innerWidth < 701) {
this.idSelected = '';
this.hideRefreshBtn = false;
}
else{
this.hideRefreshBtn = true;
if(this.idSelected == ''){
this.showEmptyComponent=true;
}
}
}
if(window.innerWidth < 701){
this.idSelected = '';
this.hideRefreshBtn = false;
}
}
/* loadMessage(){
this.chatService.messages.subscribe(msg => {
console.log("Response from websocket: " + msg);
});
} */
/* sendMsg() {
console.log("new message from client to websocket: ", this.message);
this.chatService.messages.next(this.message);
this.message.msg = "";
} */
/* loadMessage(){
this.chatService.messages.subscribe(msg => {
console.log("Response from websocket: " + msg);
});
} */
/* sendMsg() {
console.log("new message from client to websocket: ", this.message);
this.chatService.messages.next(this.message);
this.message.msg = "";
} */
/* Fim websockets functions */
closeAllDesktopComponents() {
this.showMessages=false;
this.showContacts=false;
this.showNewGroup=false;
this.showEditGroup=false;
this.showGroupMessages=false;
this.showEmptyComponent=false;
this.showGroupContacts=false;
this.showNewEvent=false;
this.showAttendees=false;
this.showMessages = false;
this.showContacts = false;
this.showNewGroup = false;
this.showEditGroup = false;
this.showGroupMessages = false;
this.showEmptyComponent = false;
this.showGroupContacts = false;
this.showNewEvent = false;
this.showAttendees = false;
console.log('All components closed!');
}
showEmptyContainer(){
showEmptyContainer() {
this.idSelected = '';
this.showEmptyComponent=true;
this.showEmptyComponent = true;
}
openGroupContactsPage(data){
openGroupContactsPage(data) {
this.idSelected = '';
this.groupRoomId = data;
this.closeAllDesktopComponents();
if(window.innerWidth < 801){
if (window.innerWidth < 801) {
}
else{
else {
this.showGroupContacts = true;
}
}
openMessagesPage(rid) {
if( window.innerWidth < 701){
if (window.innerWidth < 701) {
this.openMessagesModal(rid);
//this.router.navigate(['/home/chat/messages',rid,]);
}
else{
else {
this.idSelected = rid;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.roomId = rid;
this.showMessages=true;
this.showMessages = true;
}
}
openContactsPage() {
@@ -267,63 +270,63 @@ hideRefreshButton(){
this.idSelected = '';
this.closeAllDesktopComponents();
if( window.innerWidth < 701){
if (window.innerWidth < 701) {
this.selectContact();
}
else{
else {
console.log('here');
this.showContacts=true;
this.showContacts = true;
}
}
openNewGroupPage() {
this.idSelected = '';
if( window.innerWidth < 801){
if (window.innerWidth < 801) {
this.newGroup();
}
else{
else {
this.closeAllDesktopComponents();
this.showNewGroup=true;
this.showNewGroup = true;
}
}
openEditGroupPage(rid) {
if( window.innerWidth < 801){
if (window.innerWidth < 801) {
this.editGroup(rid);
}
else{
else {
this.closeAllDesktopComponents();
this.showEditGroup=true;
this.showEditGroup = true;
}
}
openGroupMessagesPage(rid) {
if( window.innerWidth < 701){
if (window.innerWidth < 701) {
this.openGroupMessagesModal(rid);
}
else{
else {
this.idSelected = rid;
this.closeAllDesktopComponents();
this.showEmptyComponent = false;
this.roomId = rid;
console.log(this.roomId);
this.showGroupMessages=true;
this.showGroupMessages = true;
}
}
openNewEventPage(data:any){
this.taskParticipants = data.members.map((val) =>{
openNewEventPage(data: any) {
this.taskParticipants = data.members.map((val) => {
return {
Name: val.name,
EmailAddress: val.username+"@"+environment.domain,
EmailAddress: val.username + "@" + environment.domain,
IsRequired: "true",
}
});
this.closeAllDesktopComponents();
if(window.innerWidth < 701){
if (window.innerWidth < 701) {
console.log('Mobile');
}
else{
this.showNewEvent=true;
else {
this.showNewEvent = true;
}
}
@@ -337,7 +340,7 @@ hideRefreshButton(){
this.contacts = [];
}
async setContact(data:EventPerson[]) {
async setContact(data: EventPerson[]) {
this.contacts = data;
}
@@ -352,7 +355,7 @@ hideRefreshButton(){
async closeAttendeesComponent() {
this.closeAllDesktopComponents();
this.showNewEvent = true;
this.showNewEvent = true;
}
async closeNewEventComponent() {
@@ -361,24 +364,23 @@ hideRefreshButton(){
this.idSelected = "";
}
onSegmentChange(){
onSegmentChange() {
this.load();
}
doRefresh(event){
doRefresh(event) {
setTimeout(() => {
this.load();
event.target.complete();
}, 1000);
}
refreshing(){
refreshing() {
this.load();
}
load(){
switch (this.segment)
{
load() {
switch (this.segment) {
case "Contactos":
this.getDirectMessages();
break;
@@ -388,106 +390,193 @@ hideRefreshButton(){
break;
}
}
customRoom(){
customRoom() {
let params = new HttpParams();
params = params.set("types", "c");
this.chatService.customsRooms(params).subscribe(res=>{
this.chatService.customsRooms(params).subscribe(res => {
console.log(res);
});
}
async getDirectMessages(event?){
getDirectMessagesDB() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
this.sqlservice.getAllChatRoom().then((rooms: any) => {
let roomsArray = [];
rooms.forEach(element => {
let roomListDB = {
_id: element.Id,
uids: JSON.parse(element.Uids),
usernames: JSON.parse(element.Usernames),
lastMessage: JSON.parse(element.LastMessage),
_updatedAt: element.UpdatedAt
}
roomsArray.push(roomListDB)
});
this.chatService.getAllDirectMessages().subscribe(async (res:any)=>{
//console.log(res.ims);
if(res != 200){
//console.log(res.ims);
this.userDirectMessages = res.ims.sort((a,b)=>{
this.userDirectMessages = roomsArray.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
});
console.log('DIRECTMESSAGE FROM DB', this.userDirectMessages);
console.log('ROOMS FROM DB', rooms)
})
this.sqlservice.getAllChatUsers().then((userslist: any) => {
console.log('USERS FOM DB 1', userslist)
let chatusersArray = [];
userslist.forEach(element => {
console.log('USERS FOM DB 2', element)
let userListDB = {
_id: element.Id,
name: element.Name,
username: element.Username
}
chatusersArray.push(userListDB);
});
this.dmUsers = chatusersArray.filter(data => data.username != this.loggedUserChat.me.username);
})
}
}
transformDataRoomList(data) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
data.forEach(element => {
let roomList = {
id: element._id,
uids: element.uids,
usernames: element.usernames,
lastMessage: element.lastMessage,
updatedat: element._updatedAt
}
console.log('TRANSFORM ROOM LIST', roomList)
this.sqlservice.addChatListRoom(roomList);
});
}
}
transformDataUserList(users) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
users.forEach(element => {
console.log('TRANSFORM USER CHAT 1', element)
let chatusers = {
id: element._id,
name: element.name,
username: element.username
}
console.log('TRANSFORM USER CHAT 2', chatusers)
this.sqlservice.addChatListUsers(chatusers);
});
}
}
async getDirectMessages(event?) {
this.chatService.getAllDirectMessages().subscribe(async (res: any) => {
this.transformDataRoomList(res.ims)
this.getDirectMessagesDB()
console.log('Chat list', res);
if (res != 200) {
//console.log(res.ims);
/* this.userDirectMessages = res.ims.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
}); */
//console.log(this.userDirectMessages);
if(this.route.url != "/home/chat"){
if (this.route.url != "/home/chat") {
//console.log("Timer message stop")
}
else {
//console.log('TIMER');
//Check if modal is opened
if(this.segment == "Contactos" && this.showMessages != true){
if (this.segment == "Contactos" && this.showMessages != true) {
await new Promise(resolve => setTimeout(resolve, 1000));
await this.getDirectMessages();
//console.log('Timer contactos list running')
}
else{
else {
//console.log('No timer!');
}
}
}
else{
else {
await this.getDirectMessages();
}
});
}
showDateDuration(start:any){
showDateDuration(start: any) {
return this.timeService.showDateDuration(start);
}
countDownDate(date:any, roomId:string){
countDownDate(date: any, roomId: string) {
return this.timeService.countDownDate(date, roomId);
}
async getChatMembers(){
async getChatMembers() {
//return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res=> {
console.log(res);
this.chatService.getAllUsers().subscribe(res => {
console.log('chatusers', res);
this.transformDataUserList(res['users'])
this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
console.log(this.dmUsers);
//this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
//console.log(this.dmUsers);
});
}
async getGroups(event?){
this.result = this.chatService.getAllPrivateGroups().subscribe(async (res:any)=>{
async getGroups(event?) {
this.result = this.chatService.getAllPrivateGroups().subscribe(async (res: any) => {
//console.log(res);
if(res.groups != 200){
if (res.groups != 200) {
this.privateGroups = res.groups;
/* this.result = this.chatService.getAllUserChannels().subscribe((res:any)=>{
this.publicGroups = res.channels; */
this.privateGroups = res.groups;
/* this.result = this.chatService.getAllUserChannels().subscribe((res:any)=>{
this.publicGroups = res.channels; */
//let all = this.privateGroups.concat(this.publicGroups);
this.allGroups = this.privateGroups.sort((a,b)=>{
this.allGroups = this.privateGroups.sort((a, b) => {
var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime();
return dateB - dateA;
});
//console.log(this.allGroups);
/* }); */
if(this.route.url != "/home/chat"){
console.log("Timer message stop")
/* }); */
if (this.route.url != "/home/chat") {
console.log("Timer message stop")
}
else {
//Check if modal is opened
if (this.segment == "Grupos" && this.showGroupMessages != true) {
await new Promise(resolve => setTimeout(resolve, 1000));
await this.getGroups();
//console.log('Timer groups list running')
}
}
}
else {
//Check if modal is opened
if(this.segment == "Grupos" && this.showGroupMessages != true){
await new Promise(resolve => setTimeout(resolve, 1000));
await this.getGroups();
//console.log('Timer groups list running')
}
await this.getGroups();
}
}
else{
await this.getGroups();
}
});
}
async selectContact(){
async selectContact() {
const modal = await this.modalController.create({
component: ContactsPage,
cssClass: 'modal modal-desktop',
@@ -496,7 +585,7 @@ hideRefreshButton(){
modal.onDidDismiss();
}
async newGroup(){
async newGroup() {
const modal = await this.modalController.create({
component: NewGroupPage,
cssClass: 'modal modal-desktop',
@@ -505,7 +594,7 @@ hideRefreshButton(){
modal.onDidDismiss();
}
async editGroup(roomId){
async editGroup(roomId) {
const modal = await this.modalController.create({
component: EditGroupPage,
cssClass: 'modal modal-desktop',
@@ -514,13 +603,13 @@ hideRefreshButton(){
},
});
await modal.present();
modal.onDidDismiss().then((res)=>{
modal.onDidDismiss().then((res) => {
console.log(res.data);
this.modalController.dismiss(res.data);
});
}
async openMessagesModal(roomId:any){
async openMessagesModal(roomId: any) {
this.closeAllDesktopComponents();
console.log(roomId);
@@ -536,7 +625,7 @@ hideRefreshButton(){
modal.onDidDismiss();
}
async openGroupMessagesModal(roomId:any){
async openGroupMessagesModal(roomId: any) {
console.log(roomId);
@@ -551,10 +640,10 @@ hideRefreshButton(){
modal.onDidDismiss();
}
// this.crop.crop('path/to/image.jpg', {quality: 75})
// .then(
// newImage => console.log('new image path is: ' + newImage),
// error => console.error('Error cropping image', error)
// );
// this.crop.crop('path/to/image.jpg', {quality: 75})
// .then(
// newImage => console.log('new image path is: ' + newImage),
// error => console.error('Error cropping image', error)
// );
}
}
@@ -19,15 +19,14 @@ import { AngularCropperjsModule } from 'angular-cropperjs';
@NgModule({
imports: [
CommonModule,
BrowserModule,
FormsModule,
FontAwesomeModule,
IonicModule,
GroupMessagesPageRoutingModule,
ChatPopoverPageModule,
BtnModalDismissPageModule,
ImageCropperModule,
AngularCropperjsModule
/* ImageCropperModule,
AngularCropperjsModule */
],
declarations: [GroupMessagesPage]
@@ -53,11 +53,11 @@
<div (click)="handleClick()" class="messages overflow-y-auto" #scrollMe>
<div class="welcome-text">
<ion-label>Esta conversa passou a grupo</ion-label><br />
<ion-label>Esta conversa passou a grupo TIAGO</ion-label><br />
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)">
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -66,7 +66,9 @@
<ion-label>{{msg.msg}}</ion-label>
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" >
<div (click)="openPreview(msg)">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" >
</div>
<div>
<div>
<div class="file">
@@ -90,9 +92,9 @@
</div>
</div>
</div>
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
@@ -21,6 +21,7 @@ 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';
@Component({
selector: 'app-group-messages',
@@ -29,7 +30,7 @@ import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.
})
export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
showLoader: boolean;
isGroupCreated:boolean;
@@ -593,7 +594,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
@@ -601,40 +602,40 @@ sliderZoomOpts = {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale/5;
this.changeDetectorRef.detectChanges();
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;
}
async openPreview(img) {
async openPreview(msg) {
const modal = await this.modalController.create({
component: PreviewCameraPage,
cssClass: 'transparent-modal',
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: img.attachments[0].image_url,
username: img.u.name,
_updatedAt: img._updatedAt
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt,
}
});
modal.present();
@@ -49,7 +49,7 @@
</ion-refresher-content>
</ion-refresher> -->
<div (click)="handleClick()" class="messages" #scrollMe>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last"
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last"
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)">
<div class="title">
@@ -60,7 +60,9 @@
<ion-label>{{msg.msg}}</ion-label>
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments let i = index">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)">
<div (click)="openPreview(msg)">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
</div>
<div>
<div>
<div class="file">
@@ -76,7 +78,7 @@
</div>
</div>
<div class="file-details-optional">
<ion-label *ngIf="msg.file">
<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>
@@ -138,7 +140,7 @@
<button (click)="stopRecording()">Stop Recording</button> -->
<div class="container width-100 d-flex">
<div>
<button class="btn-no-color" (click)="openChatOptions()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-options" src="assets/images/icons-add.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-options" src="assets/images/theme/gov/icons-add.svg"></ion-icon>
+87 -14
View File
@@ -1,6 +1,6 @@
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 } from '@ionic/angular';
import { GestureController, Gesture, ModalController, NavParams, PopoverController, IonSlides, 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';
@@ -24,6 +24,9 @@ import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
import { SqliteService } from 'src/app/services/sqlite.service';
import { elementAt } from 'rxjs-compat/operator/elementAt';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
const IMAGE_DIR = 'stored-images';
@@ -89,9 +92,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private processes: ProcessesService,
public ThemeService: ThemeService,
private changeDetectorRef: ChangeDetectorRef,
private platform: Platform,
private sqlservice: SqliteService
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.roomId = this.navParams.get('roomId');
console.log('ROOM ID', this.roomId)
window.onresize = (event) => {
if( window.innerWidth > 701){
@@ -111,6 +117,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
directory: Directory.Data,
recursive: true
});
this.getRoomMessageDB(this.roomId);
}
ngAfterViewInit() {
@@ -544,6 +551,71 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
});
}
getRoomMessageDB(roomId) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
this.sqlservice.getAllChatMSG(roomId).then((msg: any) => {
let chatmsgArray = [];
let array = []
msg.forEach(element => {
console.log('CHANNEL ELEMENT',element.channels)
let msgChat = {
_id: element.Id,
attachments: this.isJson(element.Attachments),
channels: this.isJson(element.Channels),
file: this.isJson(element.File),
mentions: this.isJson(element.Mentions),
msg: element.Msg,
rid: element.Rid,
ts: element.Ts,
u: this.isJson(element.U),
_updatedAt: element.UpdatedAt
}
chatmsgArray.push(msgChat)
});
this.messages = chatmsgArray.reverse();
console.log('CHAT MSG FROM DB', chatmsgArray)
})
}
}
isJson(str) {
try {
JSON.parse(str);
} catch (e) {
return "";
}
return JSON.parse(str);
}
transformDataMSG(res) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
res.forEach(element => {
let chatmsg = {
_id: element._id,
attachments: element.attachments,
channels: element.channels,
file: element.file,
mentions: element.mentions,
msg: element.msg,
rid: element.rid,
ts: element.ts,
u: element.u,
_updatedAt: element._updatedAt
}
this.sqlservice.addChatMSG(chatmsg)
});
}
}
async serverLongPull() {
const roomId = this.roomId
@@ -557,6 +629,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
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
@@ -568,8 +643,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
// Show Error
//showMessage(response.statusText);
//this.loadMessages()
this.messages = res['messages'].reverse();
this.chatMessageStore.add(roomId, this.messages)
//this.messages = res['messages'].reverse();
//this.chatMessageStore.add(roomId, this.messages)
//console.log(this.messages);
// Reconnect in one second
@@ -593,7 +668,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
});
}
sliderOpts = {
zoom: false,
slidesPerView: 1.5,
@@ -602,7 +677,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
@@ -610,27 +685,27 @@ sliderZoomOpts = {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale/5;
this.changeDetectorRef.detectChanges();
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;
@@ -639,15 +714,13 @@ touchStart(card) {
async openPreview(msg) {
const modal = await this.modalController.create({
component: PreviewCameraPage,
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt,
}
});
modal.present();
}
@@ -109,9 +109,10 @@ export class ApproveEventPage implements OnInit {
}
addProcessToDB(data) {
this.platform.ready().then(() => {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
this.sqliteservice.updateProcess(data);
});
}
}
getProcessFromDB() {
@@ -186,6 +187,7 @@ export class ApproveEventPage implements OnInit {
this.processes.GetTask(this.serialNumber).subscribe(async res => {
this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise();
this.addProcessToDB(this.loadedEvent)
console.log(this.loadedEvent);
this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
@@ -38,10 +38,10 @@
<div class="content height-100 d-flex flex-column">
<div [ngSwitch]="segment">
<ion-list class="width-100 height-100" *ngSwitchCase="'MDGPR'">
<div *ngIf="eventaprovacaostore.listmd" class="overflow-y-auto height-100">
<div *ngIf="eventsMDGPRList" class="overflow-y-auto height-100">
<ion-item-sliding>
<ion-item class="Rectangle cursor-pointer" lines="none"
*ngFor="let event of eventaprovacaostore.listmd" (click)="goToEventToApproveDetail(event.serialNumber)">
*ngFor="let event of eventsMDGPRList" (click)="goToEventToApproveDetail(event.serialNumber)">
<div class="content-mdgpr-{{event.workflowInstanceDataFields.Agenda}} width-100">
<div class="approve-event-time">
@@ -61,10 +61,10 @@
<ion-label></ion-label>
<ion-list *ngSwitchCase="'PR'">
<div *ngIf="eventaprovacaostore.listpr" class="overflow-y-auto height-100">
<div *ngIf="eventsPRList" class="overflow-y-auto height-100">
<ion-item-sliding>
<ion-item class="Rectangle cursor-pointer" lines="none"
*ngFor="let event of eventaprovacaostore.listpr" (click)="goToEventToApproveDetail(event.serialNumber)">
*ngFor="let event of eventsPRList" (click)="goToEventToApproveDetail(event.serialNumber)">
<div class="content-pr-{{event.workflowInstanceDataFields.Agenda}} width-100">
<div class="approve-event-time">
<p>{{event.workflowInstanceDataFields.StartDate | date: 'HH:mm'}}</p>
@@ -85,7 +85,7 @@
<div class="height-100" [ngSwitch]="segment">
<div *ngSwitchCase="'MDGPR'" class="d-flex height-100 align-center justify-content-center" >
<div
*ngIf="!skeletonLoader && eventaprovacaostore.listmd.length == 0"
*ngIf="!skeletonLoader && eventsMDGPRList.length == 0"
class="empty-list d-flex height-100 align-center justify-content-center"
>
<span>Lista vazia</span>
@@ -94,7 +94,7 @@
<div *ngSwitchCase="'PR'" class="d-flex height-100 align-center justify-content-center">
<div
*ngIf="!skeletonLoader && eventaprovacaostore.listpr.length == 0"
*ngIf="!skeletonLoader && eventsPRList.length == 0"
class="empty-list d-flex height-100 align-center justify-content-center"
>
<span>Lista vazia</span>
@@ -84,18 +84,48 @@ export class EventListPage implements OnInit {
this.platform.ready().then(() => {
this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => {
this.eventsMDGPRList = this.sortService.sortDate(event, 'taskStartDate')
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(event, 'taskStartDate')
this.eventsPRList = this.sortService.sortDate(this.transformaDataDB(event), 'taskStartDate')
console.log('PR event to aprove', this.eventsPRList)
})
})
console.log('Offlineee')
}
transformaDataDB(events) {
let MdEventsArray = [];
for (let i of events) {
let eventMD = {
Documents: i.Documents,
actions: i.actions,
activityInstanceName: i.activityInstanceName,
formURL: i.formURL,
interveners: i.interveners,
originator: i.originator,
serialNumber: i.serialNumber,
taskStartDate: i.taskStartDate,
totalDocuments: i.totalDocuments,
workflowDisplayName: i.workflowDisplayName,
workflowID: i.workflowID,
workflowInstanceDataFields: JSON.parse(i.workflowInstanceDataFields),
workflowInstanceFolio: i.workflowInstanceFolio,
workflowInstanceID: i.workflowInstanceID,
workflowName: i.workflowName,
}
MdEventsArray.push(eventMD);
}
return MdEventsArray;
}
segmentChanged(ev: any) {
this.LoadToApproveEvents();
}
@@ -111,13 +141,15 @@ 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')
console.log('MD EVENT TO APROVE ONLINE',this.eventsMDGPRList)
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.sortDate(this.eventsPRList, 'taskStartDate')
console.log('PR EVENT TO APROVE ONLINE',this.eventsPRList)
this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
}
this.showLoader = false;
@@ -118,7 +118,7 @@
<button (click)="openExpedientActionsModal('1',fulltask)" class="btn-cancel" shape="round" >Solicitar Parecer</button>
<button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
<button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
<button (click)="openNewGroupPage()" class="btn-cancel" shape="round" >Iniciar Conversa</button>
<button (click)="openNewGroupPage(task)" class="btn-cancel" shape="round" >Iniciar Conversa</button>
<div hidden class="solid"></div>
<button hidden class="btn-cancel" shape="round" >Delegar</button>
</div> -->
@@ -642,8 +642,8 @@ export class ExpedienteDetailPage implements OnInit {
}
else {
this.dataService.set("newGroup", true);
/* this.closeAllDesktopComponents();
this.showNewGroup=true; */
this.dataService.set("task", this.task);
this.dataService.set("newGroupName", this.task.Folio);
}
}
@@ -653,6 +653,7 @@ export class ExpedienteDetailPage implements OnInit {
cssClass: 'modal modal-desktop',
componentProps: {
name: this.task.Folio,
task: this.task
},
});
await modal.present();
@@ -63,7 +63,7 @@
<div class="bottom-content width-100">
<ion-list>
<h5>Documentos Anexados</h5>
<ion-item *ngFor="let attachment of attachments"
<ion-item *ngFor="let attachment of attachments"
class="ion-no-margin ion-no-padding cursor-pointer"
>
<ion-label
@@ -130,6 +130,9 @@
<button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
<button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
</div>
<div class="buttons">
<button (click)="openNewGroupPage(task)" class="btn-cancel" shape="round" >Iniciar Conversa</button>
</div>
</div>
</div>
</div>
@@ -26,6 +26,8 @@ import { BackgroundService } from 'src/app/services/background.service';
import { PermissionService } from 'src/app/services/worker/permission.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service'
import { DataService } from 'src/app/services/data.service';
import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page';
@Component({
@@ -66,7 +68,8 @@ export class PedidoPage implements OnInit {
private sqliteservice: SqliteService,
private backgroundservices: BackgroundService,
private platform: Platform,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private dataService: DataService,
) {
this.loggeduser = authService.ValidatedUser;
@@ -477,6 +480,33 @@ export class PedidoPage implements OnInit {
modal.onDidDismiss();
}
openNewGroupPage(task?:any){
this.router.navigate(['/home/chat']);
this.dataService.set("newGroup", true);
if( window.innerWidth < 801){
this.newGroup();
}
else{
this.dataService.set("newGroup", true);
this.dataService.set("task", this.task);
this.dataService.set("newGroupName", this.task.Folio);
}
}
async newGroup(){
const modal = await this.modalController.create({
component: NewGroupPage,
cssClass: 'modal modal-desktop',
componentProps: {
name: this.task.Folio,
task: this.task
},
});
await modal.present();
modal.onDidDismiss();
}
// async viewEventDetail(eventId: any) {
// const modal = await this.modalController.create({
@@ -108,7 +108,7 @@ export class NewPublicationPage implements OnInit {
async takePicture() {
const image = await Camera.getPhoto({
quality: 20,
quality: 90,
allowEditing: false,
width:50,
height: 50,
@@ -398,7 +398,7 @@ export class NewPublicationPage implements OnInit {
async selectImage() {
const image = await Camera.getPhoto({
quality: 20,
quality: 90,
allowEditing: false,
resultType: CameraResultType.Uri,
source: CameraSource.Camera // Camera, Photos or Prompt!
@@ -521,10 +521,10 @@ export class NewPublicationPage implements OnInit {
compressFile() {
//this.imgResultBeforeCompress = image;
//this.imgResultBeforeCompress = image;s
this.imageCompress.getOrientation(this.capturedImage).then((orientation) => {
console.log('Size in bytes was:', this.imageCompress.byteCount(this.capturedImage));
this.imageCompress.compressFile(this.capturedImage, orientation, 20, 20).then(
this.imageCompress.compressFile(this.capturedImage, orientation, 90, 90).then(
result => {
this.capturedImage = result;
console.log('Size in bytes is now:', this.imageCompress.byteCount(result));
@@ -23,7 +23,7 @@
</div>
<div class="post-item overflow-y-auto">
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
<div (click)="openPreview(publication)" *ngIf="publication.FileBase64.length > 30" class="post-img">
<img src="{{publication.FileBase64}}" alt="image" >
</div>
<div *ngIf="publication.FileBase64.length < 30" class="post-img">
@@ -8,6 +8,7 @@ import { ImageModalPage } from '../../gallery/image-modal/image-modal.page';
import { NewPublicationPage } from '../../new-publication/new-publication.page';
import { Location } from '@angular/common';
import { ThemeService } from 'src/app/services/theme.service'
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
@Component({
@@ -122,7 +123,7 @@ export class PublicationDetailPage implements OnInit {
} finally {
loader.remove()
}
}
@@ -146,13 +147,17 @@ export class PublicationDetailPage implements OnInit {
});
}
openPreview(imageUrl:string){
this.modalController.create({
component: ImageModalPage,
async openPreview(item) {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
imageUrl:imageUrl,
image: item.FileBase64,
username: item.Title,
_updatedAt: item.DatePublication
}
}).then(modal => modal.present());
});
modal.present();
}
@@ -45,8 +45,6 @@
width: 100%; /* 400px */
height: 100%;
font-family: Roboto;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
background-color: #fff;
overflow:hidden;
padding: 25px 20px 0px 20px;
@@ -96,9 +94,11 @@
/* padding: 0!important; */
float: left;
margin: 2.5px 0 0 5px;
color: #000 !important;
}
.title{
font-size: 25px;
color: #000 !important;
}
.actions-icon{
@@ -126,7 +126,7 @@
}
.post-img{
width: 100%;
height: 400px;
//height: 400px;
margin: 0 auto;
border-radius: 0px!important;
overflow: hidden;
@@ -116,17 +116,12 @@ export class ViewPublicationsPage implements OnInit {
}
getPublicationDetail() {
setTimeout(() => {
let allActions = this.publicationEventFolderStorage.list.concat(this.publicationTravelFolderService.list)
this.item = allActions.find((e) => e.ProcessId == this.folderId);
this.publicationDitails = this.item
console.log('item', this.item)
}, 100);
this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{
console.log(res);
this.item = res;
});
}
// goes to fork
// getPublicationsIds() {
@@ -177,14 +172,14 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = false;
/* this.publicationList = new Array();
res.forEach(element => {
console.log('getPublications', element)
let item: Publication = this.publicationPipe.itemList(element)
this.publicationList.push(item);
});
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList; */
});
@@ -232,8 +227,8 @@ export class ViewPublicationsPage implements OnInit {
forkJoin([
this.getPublicationsIds(),
this.getPublications(),
]).subscribe(allResults =>{
this.publicationList = allResults[2]
})