diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index db3b417bf..69db837c9 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -223,6 +223,10 @@ const routes = [ path: 'custom-image-cache', loadChildren: () => import('./services/file/custom-image-cache/custom-image-cache.module').then( m => m.CustomImageCachePageModule) }, + { + path: 'view-media', + loadChildren: () => import('./modals/view-media/view-media.module').then( m => m.ViewMediaPageModule) + }, diff --git a/src/app/modals/view-media/view-media-routing.module.ts b/src/app/modals/view-media/view-media-routing.module.ts new file mode 100644 index 000000000..e21bc8eb9 --- /dev/null +++ b/src/app/modals/view-media/view-media-routing.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +import { ViewMediaPage } from './view-media.page'; + +const routes: Routes = [ + { + path: '', + component: ViewMediaPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class ViewMediaPageRoutingModule {} diff --git a/src/app/modals/view-media/view-media.module.ts b/src/app/modals/view-media/view-media.module.ts new file mode 100644 index 000000000..7a78f5148 --- /dev/null +++ b/src/app/modals/view-media/view-media.module.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { IonicModule } from '@ionic/angular'; + +import { ViewMediaPageRoutingModule } from './view-media-routing.module'; + +import { ViewMediaPage } from './view-media.page'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + FontAwesomeModule, + ViewMediaPageRoutingModule + ], + declarations: [ViewMediaPage] +}) +export class ViewMediaPageModule {} diff --git a/src/app/modals/view-media/view-media.page.html b/src/app/modals/view-media/view-media.page.html new file mode 100644 index 000000000..75b8f918e --- /dev/null +++ b/src/app/modals/view-media/view-media.page.html @@ -0,0 +1,22 @@ + +
+
+ +
+
+
+ {{name}}, {{_updatedAt | date}} + +
+
+
+
+ +
+
+ +
+
+
diff --git a/src/app/modals/view-media/view-media.page.scss b/src/app/modals/view-media/view-media.page.scss new file mode 100644 index 000000000..4185866b7 --- /dev/null +++ b/src/app/modals/view-media/view-media.page.scss @@ -0,0 +1,79 @@ +.main-header{ + width: 100%; /* 400px */ + height: 100%; + font-family: Roboto; + border-top-left-radius: 25px; + border-top-right-radius: 25px; + background-color: #fff; + overflow:hidden; + padding: 30px 20px 5px 20px; + color:#000; + transform: translate3d(0, 1px, 0); + + .left{ + width: fit-content; + float: left; + //font-size: 35px; + overflow: hidden; + + .header-top-btn{ + background: transparent; + font-size: 25px !important; + font-weight: 100 !important; + /* color: #0782c9; */ + color: #42b9fe; + } + } + + .middle-container{ + overflow: auto; + width:calc(100% - 45px); + height: auto; + + .middle{ + padding: 0!important; + float: left; + width:calc(100% - 77px); + margin: 0px 0 0 10px; + display: flex; + align-items: center; + + .title{ + font-size: 25px; + white-space: nowrap; + overflow: hidden !important; + text-overflow: ellipsis !important; + float: left; + } + } + } +} + +.media { + background-color: #ebebeb; + padding: 10px !important; + height: 100% !important; + overflow: auto !important; + + .media-content{ + height: fit-content !important; + overflow: auto !important; + img{ + width: fit-content !important; + height: 100% !important; + } + } +} + + +@media only screen and (min-width: 800px) { + .media { + .media-content{ + height: 100% !important; + } + } +} + + + + diff --git a/src/app/modals/view-media/view-media.page.spec.ts b/src/app/modals/view-media/view-media.page.spec.ts new file mode 100644 index 000000000..8759d3bdb --- /dev/null +++ b/src/app/modals/view-media/view-media.page.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { ViewMediaPage } from './view-media.page'; + +describe('ViewMediaPage', () => { + let component: ViewMediaPage; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ ViewMediaPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(ViewMediaPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/modals/view-media/view-media.page.ts b/src/app/modals/view-media/view-media.page.ts new file mode 100644 index 000000000..a5754085b --- /dev/null +++ b/src/app/modals/view-media/view-media.page.ts @@ -0,0 +1,30 @@ +import { Component, OnInit } from '@angular/core'; +import { ModalController, NavParams } from '@ionic/angular'; + +@Component({ + selector: 'app-view-media', + templateUrl: './view-media.page.html', + styleUrls: ['./view-media.page.scss'], +}) +export class ViewMediaPage implements OnInit { + + image: any; + name: string + _updatedAt: string + + constructor( + private modalController: ModalController, + private navParams:NavParams, + ) { + this.image = this.navParams.get('image') + this.name = this.navParams.get('username') + this._updatedAt = this.navParams.get('_updatedAt') + } + + ngOnInit() { + } + + close(){ + this.modalController.dismiss() + } +} diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index 879f56f13..4921e409b 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -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) + // ); - } +} diff --git a/src/app/pages/chat/group-messages/group-messages.module.ts b/src/app/pages/chat/group-messages/group-messages.module.ts index cc970708b..d5c64132d 100644 --- a/src/app/pages/chat/group-messages/group-messages.module.ts +++ b/src/app/pages/chat/group-messages/group-messages.module.ts @@ -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] diff --git a/src/app/pages/chat/group-messages/group-messages.page.html b/src/app/pages/chat/group-messages/group-messages.page.html index fe648ee08..cd041f368 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.html +++ b/src/app/pages/chat/group-messages/group-messages.page.html @@ -53,11 +53,11 @@
- Esta conversa passou a grupo
+ Esta conversa passou a grupo TIAGO
A conversa original mantêm-se como chat individual
-
+
{{msg.u.name}} {{showDateDuration(msg._updatedAt)}} @@ -66,7 +66,9 @@ {{msg.msg}}
- image +
+ image +
@@ -90,9 +92,9 @@
- +
- +
{{last ? scrollToBottom() : ''}}
diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index e571c6e4e..6a0063bdd 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -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(); diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html index cf14f59d9..eaf404443 100644 --- a/src/app/pages/chat/messages/messages.page.html +++ b/src/app/pages/chat/messages/messages.page.html @@ -49,7 +49,7 @@ -->
-
@@ -60,7 +60,9 @@ {{msg.msg}}
- image +
+ image +
@@ -76,7 +78,7 @@
- + {{file.description}} {{msg.file.type.replace('application/','').toUpperCase()}} @@ -138,7 +140,7 @@ -->
- + - +
--> diff --git a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts index 24daead73..e5ea396b7 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts @@ -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(); diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html index b83ec04b7..65578e163 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html @@ -63,7 +63,7 @@
Documentos Anexados
- Marcar Reunião
+
+ +
diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts index f6dc796ef..5a7c2a1eb 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts @@ -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({ diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index cf37bd3e8..60a6eaa06 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -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)); diff --git a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html index 0a0caf116..ed7fccafb 100644 --- a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html +++ b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html @@ -23,7 +23,7 @@
-
+
image
diff --git a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts index 7806b556e..7fb0feba0 100644 --- a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts +++ b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts @@ -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(); } diff --git a/src/app/pages/publications/view-publications/view-publications.page.scss b/src/app/pages/publications/view-publications/view-publications.page.scss index 77534f9d2..2eed91594 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.scss +++ b/src/app/pages/publications/view-publications/view-publications.page.scss @@ -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; diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts index 8d8839623..d95ba7411 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -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] }) diff --git a/src/app/services/functions/file.service.ts b/src/app/services/functions/file.service.ts index 78f5c0a43..5973e67df 100644 --- a/src/app/services/functions/file.service.ts +++ b/src/app/services/functions/file.service.ts @@ -10,11 +10,9 @@ import { SearchList } from 'src/app/models/search-document'; import { ProcessesService } from '../processes.service'; import { ToastService } from '../toast.service'; import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera'; -import { -FileSharer} from '@byteowls/capacitor-filesharer'; import { Filesystem, Directory } from '@capacitor/filesystem'; -import { Share } from '@capacitor/share'; -import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; const IMAGE_DIR = 'stored-images'; @@ -40,6 +38,8 @@ export class FileService { photos: any[] = []; idroom: any; + headers: HttpHeaders; + constructor( private fileLoaderService: FileLoaderService, private fileToBase64Service: FileToBase64Service, @@ -50,9 +50,35 @@ export class FileService { private toastService: ToastService, private platform: Platform, private loadingCtrl: LoadingController, - private http: HttpClient + private http: HttpClient, ) { } + uploadFile(formData:any){ + alert('OIEE') + + //const geturl = environment.apiURL + 'Tasks/DelegateTask'; + const geturl = environment.apiURL + 'lakefs/UploadFiles'; + + let options = { + headers: this.headers + }; + + return this.http.post(`${geturl}`, formData, options); + } + + getFile(guid:any){ + const geturl = environment.apiURL + 'lakefs/StreamFile'; + let params = new HttpParams(); + + params = params.set("path", guid); + + let options = { + headers: this.headers, + params: params + }; + return this.http.get(`${geturl}`, options); + } + async takePicture() { const capturedImage = await Camera.getPhoto({ quality: 90, @@ -89,9 +115,9 @@ export class FileService { reader.readAsDataURL(blob); }); - loadPicture() { + async loadPicture() { const input = this.fileLoaderService.createInput({ - accept: ['image/apng', 'image/jpeg', 'image/png'] + accept: ['image/apng', 'image/jpeg', 'image/png', '.pdf'] }) input.onchange = async () => { @@ -195,7 +221,7 @@ export class FileService { console.log('ALL IMAGE', this.images) this.capturedImage = this.images[0].data - + this.capturedImageTitle = new Date().getTime() + '.jpeg'; let body = { @@ -236,11 +262,8 @@ export class FileService { await this.saveImage(image,roomId) } - await Share.share({ - title: 'Check my image', - url: image.path - }) - + //this.capturedImage = this.capturedImage; + } @@ -258,11 +281,6 @@ export class FileService { await this.saveImage(capturedImage,roomId) } - await Share.share({ - title: 'Check my image', - url: capturedImage.path - }) - /* const response = await fetch(capturedImage.webPath!); const blob = await response.blob(); @@ -303,17 +321,17 @@ export class FileService { reader.onloadend=()=>{ const result = reader.result as string const base64Data = result.split(',')[1] - - FileSharer.share({ + + /* FileSharer.share({ filename:'any.pdf', base64Data, contentType: "application/pdf", - }) + }) */ reader.readAsDataURL(res) } - + }) - + } addPictureToChat(roomId) { @@ -335,10 +353,15 @@ export class FileService { const file = this.fileLoaderService.getFirstFile(input) console.log(file); - const loader = this.toastService.loading(); - const imageData = await this.fileToBase64Service.convert(file) - this.capturedImage = imageData; + + const formData = new FormData(); + formData.append("blobFile", file); + let guid: any = await this.uploadFile(formData).toPromise() + console.log(guid.path); + + /* const imageData = await this.fileToBase64Service.convert(file) + this.capturedImage = imageData; */ this.capturedImageTitle = file.name; let body = { @@ -350,8 +373,12 @@ export class FileService { //"title": this.capturedImageTitle , //"text": "description", "title_link_download": false, - "image_url": this.capturedImage, - }] + //"image_url": this.capturedImage, + }], + "file":{ + "type": "application/img", + "guid": guid.path, + } } } @@ -359,10 +386,9 @@ export class FileService { console.log(this.capturedImage) this.chatService.sendMessage(body).subscribe(res=> { - loader.remove(); + //console.log(res); },(error) => { - loader.remove(); }); //console.log(this.capturedImage) }; diff --git a/src/app/services/processes.service.ts b/src/app/services/processes.service.ts index 24404944e..0385d53b5 100644 --- a/src/app/services/processes.service.ts +++ b/src/app/services/processes.service.ts @@ -43,6 +43,19 @@ export class ProcessesService { this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); } + uploadFile(formData:any){ + alert('OIEE') + + //const geturl = environment.apiURL + 'Tasks/DelegateTask'; + const geturl = environment.apiURL + 'lakefs/UploadFiles'; + + let options = { + headers: this.headers + }; + + return this.http.post(`${geturl}`, formData, options); + } + GetTasksList(processname: typeof GetTasksListType, onlycount:boolean): Observable { const geturl = environment.apiURL + 'tasks/List'; diff --git a/src/app/services/sqlite.service.ts b/src/app/services/sqlite.service.ts index 01bd2cfb6..ce10d1711 100644 --- a/src/app/services/sqlite.service.ts +++ b/src/app/services/sqlite.service.ts @@ -14,11 +14,17 @@ export class SqliteService { readonly allprocess: string = "ALLPROCESS"; readonly actions: string = "ACTIONS"; readonly publications: string = "PUBLICATIONS"; + readonly chatlistroom: string = "CHATLISTROOM"; + readonly chatlistUsers: string = "CHATLISTUSERS"; + readonly chatmsg: string = "CHATMSG"; EVENTS: Array; EXPEDIENTES: Array; ALLPROCESS: Array; PROCESS: Array; ALLACTIONS: Array; + ALLChatROOM: Array; + ALLChatUSERs: Array; + ALLCHATMSG: Array; constructor(private platform: Platform, private sqlite: SQLite) { @@ -127,8 +133,55 @@ export class SqliteService { console.log("Sucess action Table created: ", res) }) .catch((error) => console.log(JSON.stringify(error))); + + await sqLite.executeSql(` + CREATE TABLE IF NOT EXISTS ${this.chatlistroom} ( + Id varchar(255) PRIMARY KEY, + Uids Text, + Usernames Text, + LastMessage Text, + UpdatedAt varchar(255) + )`, []) + .then((res) => { + console.log("Sucess chat list room Table created: ", res) + }) + .catch((error) => console.log(JSON.stringify(error))); + + await sqLite.executeSql(` + CREATE TABLE IF NOT EXISTS ${this.chatlistUsers} ( + Id varchar(255) PRIMARY KEY, + Name varchar(255), + Username varchar(255) + + )`, []) + .then((res) => { + console.log("Sucess chat list users Table created: ", res) + }) + .catch((error) => console.log(JSON.stringify(error))); + + await sqLite.executeSql(` + CREATE TABLE IF NOT EXISTS ${this.chatmsg} ( + Id varchar(255) PRIMARY KEY, + Attachments Text, + Channels Text, + File Text, + Mentions Text, + Msg varchar(255), + Rid varchar(255), + Ts varchar(255), + U Text, + UpdatedAt varchar(255) + )`, []) + .then((res) => { + console.log("Sucess chat msg Table created: ", res) + }) + .catch((error) => console.log(JSON.stringify(error))); + + }) .catch((error) => console.log(JSON.stringify(error))); + + }).catch((error) => { console.log('Platform ready error', error) }); @@ -191,6 +244,48 @@ export class SqliteService { }); } + //chatlistroom + public addChatListRoom(data) { + console.log('INSIDE DB CHAT LIST ROOM',data,) + this.dbInstance.executeSql(` + INSERT OR REPLACE INTO ${this.chatlistroom} (Id,Uids,Usernames,LastMessage,UpdatedAt) + VALUES ('${data.id}','${JSON.stringify(data.uids)}','${JSON.stringify(data.usernames)}','${JSON.stringify(data.lastMessage)}','${data.updatedat}')`, []) + .then(() => { + console.log("chat room add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + + //chatlistusers + public addChatListUsers(data) { + console.log('INSIDE DB CHAT LIST ROOM',data,) + this.dbInstance.executeSql(` + INSERT OR REPLACE INTO ${this.chatlistUsers} (Id,Name,Username) + VALUES ('${data.id}','${data.name}','${data.username}')`, []) + .then(() => { + console.log("chat users add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + + //chatlistusers + public addChatMSG(data) { + console.log('INSIDE DB CHAT MSG',data,) + this.dbInstance.executeSql(` + INSERT OR REPLACE INTO ${this.chatmsg} (Id,Attachments,Channels,File,Mentions,Msg,Rid, Ts ,U, UpdatedAt) + VALUES ('${data._id}','${JSON.stringify(data.attachments)}','${JSON.stringify(data.channels)}','${JSON.stringify(data.file)}','${JSON.stringify(data.mentions)}','${data.msg}','${data.rid}','${data.ts}','${JSON.stringify(data.u)}','${data._updatedAt}')`, []) + .then(() => { + console.log("chat msg add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + //updateevent public updateEvent(data) { this.dbInstance.executeSql(` @@ -348,6 +443,51 @@ export class SqliteService { console.log(" Get all actions error", JSON.stringify(e)); }); } + + //getAllChatRoom + getAllChatRoom() { + return this.dbInstance.executeSql(`SELECT * FROM ${this.chatlistroom}`, []).then((res) => { + this.ALLChatROOM = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.ALLChatROOM.push(res.rows.item(i)); + } + return this.ALLChatROOM; + } + }, (e) => { + console.log(" Get all chat room error", JSON.stringify(e)); + }); + } + + //getAllChatUsers + getAllChatUsers() { + return this.dbInstance.executeSql(`SELECT * FROM ${this.chatlistUsers}`, []).then((res) => { + this.ALLChatUSERs = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.ALLChatUSERs.push(res.rows.item(i)); + } + return this.ALLChatUSERs; + } + }, (e) => { + console.log(" Get all chat users error", JSON.stringify(e)); + }); + } + + //getAllChatMSG + getAllChatMSG(roomId) { + return this.dbInstance.executeSql(`SELECT * FROM ${this.chatmsg} WHERE Rid = ?`, [roomId]).then((res) => { + this.ALLCHATMSG = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.ALLCHATMSG.push(res.rows.item(i)); + } + return this.ALLCHATMSG; + } + }, (e) => { + console.log(" Get all chat users error", JSON.stringify(e)); + }); + } //getlistOfEventAprove getListOfEventAprove(process, type) { return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE workflowDisplayName = ? OR workflowDisplayName = ? `, [process, type]).then((res) => { diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 0ebc7fdbb..6d04f1ced 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -44,7 +44,7 @@ A conversa original mantêm-se como chat individual
-
+
@@ -60,7 +60,9 @@ {{msg.msg}}
- image +
+ image +
diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index aed1437d7..7c07a530d 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -20,6 +20,7 @@ import { FileService } from 'src/app/services/functions/file.service'; 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 * as pdfjsLib from 'pdfjs-dist'; @@ -555,7 +556,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise(); let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); console.log(url_no_options); - console.log('Oie'); + //console.log('Oie'); let body = { "message": @@ -769,7 +770,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } } - + sliderOpts = { zoom: false, slidesPerView: 1.5, @@ -778,7 +779,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe }; zoomActive = false; zoomScale = 1; - + sliderZoomOpts = { allowSlidePrev: false, allowSlideNext: false, @@ -786,44 +787,44 @@ 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) { - const modal = await this.modalController.create({ - component: PreviewCameraPage, - cssClass: 'transparent-modal', - componentProps: { - image: img.attachments[0].image_url, - username: img.u.username, - _updatedAt: img._updatedAt - } - }); - modal.present(); - } +async openPreview(msg) { + const modal = await this.modalController.create({ + component: ViewMediaPage, + cssClass: 'modal modal-desktop', + componentProps: { + image: msg.attachments[0].image_url, + username: msg.u.name, + _updatedAt: msg._updatedAt, + } + }); + modal.present(); +} } diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 8f1fe149b..e2f1887cc 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -37,7 +37,7 @@
-
+
@@ -53,11 +53,14 @@ {{msg.msg}}
- image +
+ + image +
-
+
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index b3eec13c2..67fb6bc09 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -17,6 +17,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'; 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-messages', @@ -245,9 +246,16 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy }) } - viewDocument(file:any, url?:string){ - if(file.type == "application/webtrix") { - this.openViewDocumentModal(file); + async viewDocument(msg:any, url?:string){ + if(msg.file.type == "application/img"){ + let response:any = await this.fileService.getFile(msg.file.guid).toPromise(); + console.log(response); + + //this.openPreview(msg); + + } + else if(msg.file.type == "application/webtrix") { + this.openViewDocumentModal(msg.file); } else{ let fullUrl; @@ -428,8 +436,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy this.fileService.addCameraPictureToChat(roomId); } addImage(){ - const roomId = this.roomId + const roomId = this.roomId; this.fileService.addPictureToChat(roomId); + //this.fileService.loadPicture(); + //this.fileService.addPictureToChat(roomId); } addFile(){ this.fileService.addDocumentToChat(this.roomId); @@ -563,7 +573,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy }; zoomActive = false; zoomScale = 1; - + sliderZoomOpts = { allowSlidePrev: false, allowSlideNext: false, @@ -571,27 +581,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; @@ -599,8 +609,8 @@ touchStart(card) { async openPreview(msg) { const modal = await this.modalController.create({ - component: PreviewCameraPage, - cssClass: 'transparent-modal', + component: ViewMediaPage, + cssClass: 'modal modal-desktop', componentProps: { image: msg.attachments[0].image_url, username: msg.u.username, diff --git a/src/app/shared/chat/new-group/new-group.page.ts b/src/app/shared/chat/new-group/new-group.page.ts index 1c183a0cd..afcdba940 100644 --- a/src/app/shared/chat/new-group/new-group.page.ts +++ b/src/app/shared/chat/new-group/new-group.page.ts @@ -1,7 +1,8 @@ import { analyzeAndValidateNgModules } from '@angular/compiler'; -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular'; import { ChatService } from 'src/app/services/chat.service'; +import { DataService } from 'src/app/services/data.service'; import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page'; import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page'; @@ -10,7 +11,7 @@ import { GroupContactsPage } from '../group-messages/group-contacts/group-contac templateUrl: './new-group.page.html', styleUrls: ['./new-group.page.scss'], }) -export class NewGroupPage implements OnInit { +export class NewGroupPage implements OnInit{ isGroupCreated:boolean; showLoader: boolean; displayDuration: any; @@ -20,6 +21,7 @@ export class NewGroupPage implements OnInit { selectedDuration = ['','','']; countDownTime:any; //groupName:string; + task:any; @Input() groupName:string; @Output() addGroupMessage:EventEmitter = new EventEmitter(); @@ -29,16 +31,28 @@ export class NewGroupPage implements OnInit { private popoverController: PopoverController, private modalController: ModalController, private chatService: ChatService, - //private navParams: NavParams, + private dataService:DataService, ) { this.isGroupCreated = false; //this.groupName = this.navParams.get('name'); + } ngOnInit() { + if(this.dataService.get("newGroup")){ + this.task = this.dataService.get("task"); + this.groupName = this.task.Folio; + } + console.log(this.task); } + /* ngOnDestroy(){ + alert('Destroy') + this.dataService.set("newGroup", false); + this.dataService.set("task", null); + this.dataService.set("newGroupName", ''); + } */ _ionChange(event){ console.log(event); console.log(event.detail.checked); diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html index 27acb350c..34d0f448b 100644 --- a/src/app/shared/header/header.page.html +++ b/src/app/shared/header/header.page.html @@ -20,7 +20,7 @@ - {{loggeduser.Profile}} +
diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index 9633211b2..3a7671340 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -51,7 +51,7 @@ export class HeaderPage implements OnInit { ngOnInit() { this.hideSearch(); this.update() - /* this.notificationLengthData(); + /* this.notificationLengthData(); this.eventrigger.getObservable().subscribe(async (data) => { if (data.notification === "delete" || "recive") { await this.notificationLengthData(); diff --git a/src/app/shared/popover/request-options/request-options.page.html b/src/app/shared/popover/request-options/request-options.page.html index 31045eda0..7105f2577 100644 --- a/src/app/shared/popover/request-options/request-options.page.html +++ b/src/app/shared/popover/request-options/request-options.page.html @@ -54,5 +54,8 @@
+
+ +
diff --git a/src/app/shared/popover/request-options/request-options.page.ts b/src/app/shared/popover/request-options/request-options.page.ts index d64b9d583..b8616959b 100644 --- a/src/app/shared/popover/request-options/request-options.page.ts +++ b/src/app/shared/popover/request-options/request-options.page.ts @@ -10,6 +10,8 @@ import { ProcessesService } from 'src/app/services/processes.service'; import { ToastService } from 'src/app/services/toast.service'; import { PedidoService } from 'src/app/Rules/pedido.service'; import { PermissionService } from 'src/app/services/worker/permission.service'; +import { DataService } from 'src/app/services/data.service'; +import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page'; @Component({ @@ -34,7 +36,8 @@ export class RequestOptionsPage implements OnInit { private toastService: ToastService, private router: Router, public p: PermissionService, - private pedidoService: PedidoService + private pedidoService: PedidoService, + private dataService: DataService, ) { this.task = this.navParams.get('task'); this.fulltask = this.navParams.get('fulltask'); @@ -109,6 +112,32 @@ export class RequestOptionsPage implements OnInit { modal.onDidDismiss(); } + openNewGroupPage(){ + this.router.navigate(['/home/chat']); + this.dataService.set("newGroup", true); + + if( window.innerWidth < 801){ + this.newGroup(); + } + else{ + this.dataService.set("newGroup", true); + /* this.closeAllDesktopComponents(); + this.showNewGroup=true; */ + } + } + + async newGroup(){ + const modal = await this.modalController.create({ + component: NewGroupPage, + cssClass: 'modal modal-desktop', + componentProps: { + name: this.task.Folio, + }, + }); + await modal.present(); + modal.onDidDismiss(); + } + async openExpedientActionsModal(taskAction: any, task: any) { //this.modalController.dismiss(); diff --git a/src/app/shared/publication/new-publication/new-publication.page.html b/src/app/shared/publication/new-publication/new-publication.page.html index 8b2e040d5..d3f327380 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.html +++ b/src/app/shared/publication/new-publication/new-publication.page.html @@ -61,7 +61,8 @@
- + +
Tirar Fotografia @@ -72,7 +73,8 @@
- + +
Anexar Fotografia diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index 4d25f3b8f..42526fa0b 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -8,6 +8,7 @@ import { ToastService } from 'src/app/services/toast.service'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FileLoaderService } from 'src/app/services/file/file-loader.service' import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service'; +import { ThemeService } from 'src/app/services/theme.service'; import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera'; @Component({ selector: 'app-new-publication', @@ -50,7 +51,8 @@ export class NewPublicationPage implements OnInit { private publications: PublicationsService, private toastService: ToastService, private fileLoaderService: FileLoaderService, - private fileToBase64Service: FileToBase64Service + private fileToBase64Service: FileToBase64Service, + public ThemeService: ThemeService ) { this.publicationTitle = 'Nova Publicação'; } diff --git a/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.html b/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.html index cdfff5aa2..a4da7ec2c 100644 --- a/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.html +++ b/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.html @@ -25,8 +25,8 @@
-
- image +
+ image
image diff --git a/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts b/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts index 0dc8d3c09..2890a9b3e 100644 --- a/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts +++ b/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts @@ -8,6 +8,7 @@ import { ToastService } from 'src/app/services/toast.service'; import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page'; import { SuccessMessagePage } from 'src/app/shared/popover/success-message/success-message.page'; import { ThemeService } from 'src/app/services/theme.service' +import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page'; @Component({ selector: 'app-publication-detail-shared', @@ -32,7 +33,7 @@ export class PublicationDetailPage implements OnInit { private toastService: ToastService, public ThemeService: ThemeService ) { - + /* this.folderId = this.navParams.get('folderIdId'); */ this.publication = { DateIndex: null, @@ -50,7 +51,7 @@ export class PublicationDetailPage implements OnInit { ngOnInit() { console.log(this.folderId); - + /* console.log(this.publication.FileBase64); */ this.getPublicationDetail(); } @@ -133,22 +134,26 @@ export class PublicationDetailPage implements OnInit { } - openPreview(imageUrl:string){ - this.modalController.create({ - component: ImageModalPage, - componentProps: { - imageUrl:imageUrl, - } - }).then(modal => modal.present()); - } - async goBack(){ this.goBackToViewPublications.emit(); } + async openPreview(item) { + const modal = await this.modalController.create({ + component: ViewMediaPage, + cssClass: 'modal modal-desktop', + componentProps: { + image: item.FileBase64, + username: item.Title, + _updatedAt: item.DatePublication + } + }); + modal.present(); + } + + -