mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { AuthService } from '../services/auth.service';
|
||||||
import { LocalstoreService } from '../store/localstore.service';
|
import { LocalstoreService } from '../store/localstore.service';
|
||||||
import { SessionStore } from '../store/session.service';
|
import { SessionStore } from '../store/session.service';
|
||||||
|
|
||||||
@@ -10,7 +11,8 @@ import { SessionStore } from '../store/session.service';
|
|||||||
export class AuthGuard implements CanActivate {
|
export class AuthGuard implements CanActivate {
|
||||||
constructor(
|
constructor(
|
||||||
private router:Router,
|
private router:Router,
|
||||||
private localstoreService: LocalstoreService
|
private localstoreService: LocalstoreService,
|
||||||
|
private authService: AuthService,
|
||||||
){}
|
){}
|
||||||
|
|
||||||
canActivate(
|
canActivate(
|
||||||
@@ -27,7 +29,8 @@ export class AuthGuard implements CanActivate {
|
|||||||
this.router.navigate(['/']);
|
this.router.navigate(['/']);
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
return true
|
this.authService.loginChat();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ export class SetRoomOwnerPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.chatService.addGroupOwner(body).subscribe((res)=>{
|
this.chatService.addGroupOwner(body).subscribe((res)=>{
|
||||||
alert('here');
|
|
||||||
console.log(res);
|
console.log(res);
|
||||||
this.close();
|
this.close();
|
||||||
this.toastService._successMessage('Operação realizada com sucesso');
|
this.toastService._successMessage('Operação realizada com sucesso');
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import { FileType } from 'src/app/models/fileType';
|
|||||||
import { SearchPage } from 'src/app/pages/search/search.page';
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||||
import { Storage } from '@ionic/storage';
|
import { Storage } from '@ionic/storage';
|
||||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
|
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
|
|
||||||
@@ -551,6 +552,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async addImageMobile() {
|
||||||
|
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
|
}
|
||||||
|
|
||||||
async addImage() {
|
async addImage() {
|
||||||
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
@@ -604,13 +609,51 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async addFileToChatMobile(types: typeof FileType[] ) {
|
||||||
|
const roomId = this.roomId
|
||||||
|
|
||||||
|
const file = await Camera.getPhoto({
|
||||||
|
quality: 90,
|
||||||
|
// allowEditing: true,
|
||||||
|
resultType: CameraResultType.Base64,
|
||||||
|
source: CameraSource.Photos
|
||||||
|
});
|
||||||
|
console.log('ADDFILECHAT', file)
|
||||||
|
//const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
//console.log('ADDFILECHAT', imageData)
|
||||||
|
|
||||||
|
const response = await fetch('data:image/jpeg;base64,'+ file.base64String!);
|
||||||
|
const blob = await response.blob();
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", blob);
|
||||||
|
|
||||||
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
|
file: {
|
||||||
|
"type": "application/img",
|
||||||
|
"guid": '',
|
||||||
|
"image_url": 'data:image/jpeg;base64,' +file.base64String
|
||||||
|
},
|
||||||
|
temporaryData: formData,
|
||||||
|
attachments: [{
|
||||||
|
"title": file.path ,
|
||||||
|
"image_url": 'data:image/jpeg;base64,' +file.base64String,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async addFileToChat(types: typeof FileType[] ) {
|
async addFileToChat(types: typeof FileType[] ) {
|
||||||
const roomId = this.roomId
|
const roomId = this.roomId
|
||||||
|
|
||||||
const file: any = await this.fileService.getFileFromDevice(types);
|
const file: any = await this.fileService.getFileFromDevice(types);
|
||||||
|
console.log('ADDFILECHAT', file)
|
||||||
const imageData = await this.fileToBase64Service.convert(file)
|
const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
console.log('ADDFILECHAT', imageData)
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("blobFile", file);
|
formData.append("blobFile", file);
|
||||||
@@ -656,7 +699,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.takePicture()
|
this.takePicture()
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-picture') {
|
else if (res['data'] == 'add-picture') {
|
||||||
this.addImage()
|
this.addImageMobile()
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-document') {
|
else if (res['data'] == 'add-document') {
|
||||||
this.addFile()
|
this.addFile()
|
||||||
|
|||||||
-1
@@ -261,7 +261,6 @@ export class BookMeetingModalPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this.task.FsId == '8') {
|
if(this.task.FsId == '8') {
|
||||||
alert('Chegou')
|
|
||||||
const loader = this.toastService.loading()
|
const loader = this.toastService.loading()
|
||||||
try {
|
try {
|
||||||
switch (this.loggeduser.Profile) {
|
switch (this.loggeduser.Profile) {
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ export class InactivityPage implements OnInit {
|
|||||||
loop = false
|
loop = false
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
|
|
||||||
// window.addEventListener('resize', (event) => {
|
// window.addEventListener('resize', (event) => {
|
||||||
// if(this.router.url != '/login') return false
|
// if(this.router.url != '/login') return false
|
||||||
|
|
||||||
// if(this.loop == false) {
|
// if(this.loop == false) {
|
||||||
// this.loop = true
|
// this.loop = true
|
||||||
// this.runloop()
|
// this.runloop()
|
||||||
@@ -54,7 +54,7 @@ export class InactivityPage implements OnInit {
|
|||||||
// const containerHeight = 651
|
// const containerHeight = 651
|
||||||
|
|
||||||
// let circleHeight = document.querySelector('.circle')['offsetHeight']
|
// let circleHeight = document.querySelector('.circle')['offsetHeight']
|
||||||
// let circleWidth = document.querySelector('.circle')['offsetWidth']
|
// let circleWidth = document.querySelector('.circle')['offsetWidth']
|
||||||
// console.log(window.innerHeight, ' < ', containerHeight)
|
// console.log(window.innerHeight, ' < ', containerHeight)
|
||||||
|
|
||||||
// console.log(circleHeight)
|
// console.log(circleHeight)
|
||||||
@@ -64,7 +64,7 @@ export class InactivityPage implements OnInit {
|
|||||||
// e['style']['width'] = (circleWidth -1 )+'px'
|
// e['style']['width'] = (circleWidth -1 )+'px'
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
||||||
// if( window.innerHeight< containerHeight) {
|
// if( window.innerHeight< containerHeight) {
|
||||||
// setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
// this.runloop()
|
// this.runloop()
|
||||||
@@ -114,14 +114,14 @@ export class InactivityPage implements OnInit {
|
|||||||
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
|
let attempt = await this.authService.login(this.userattempt, {saveSession: false})
|
||||||
|
|
||||||
if (attempt) {
|
if (attempt) {
|
||||||
|
|
||||||
// if current attemp is equal to the current user
|
// if current attemp is equal to the current user
|
||||||
if (attempt.UserId == SessionStore.user.UserId) {
|
if (attempt.UserId == SessionStore.user.UserId) {
|
||||||
await this.authService.SetSession(attempt, this.userattempt);
|
await this.authService.SetSession(attempt, this.userattempt);
|
||||||
this.authService.loginChat(this.userattempt);
|
this.authService.loginChat();
|
||||||
this.getToken();
|
this.getToken();
|
||||||
SessionStore.setInativity(true)
|
SessionStore.setInativity(true)
|
||||||
|
|
||||||
this.goback()
|
this.goback()
|
||||||
} else {
|
} else {
|
||||||
SessionStore.delete()
|
SessionStore.delete()
|
||||||
@@ -174,10 +174,10 @@ export class InactivityPage implements OnInit {
|
|||||||
const code = this.code.join('')
|
const code = this.code.join('')
|
||||||
|
|
||||||
if( SessionStore.validatePin(code)) {
|
if( SessionStore.validatePin(code)) {
|
||||||
|
|
||||||
SessionStore.setInativity(true)
|
SessionStore.setInativity(true)
|
||||||
this.goback()
|
this.goback()
|
||||||
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
this.clearCode()
|
this.clearCode()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
@@ -196,7 +196,7 @@ export class InactivityPage implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
this.router.navigate(['/home/events'], {replaceUrl: true});
|
this.router.navigate(['/home/events'], {replaceUrl: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storePin() {
|
storePin() {
|
||||||
|
|||||||
@@ -100,10 +100,9 @@ export class LoginPage implements OnInit {
|
|||||||
|
|
||||||
// login to API successfully
|
// login to API successfully
|
||||||
if (attempt) {
|
if (attempt) {
|
||||||
|
|
||||||
if (attempt.UserId == SessionStore.user.UserId) {
|
if (attempt.UserId == SessionStore.user.UserId) {
|
||||||
await this.authService.SetSession(attempt, this.userattempt);
|
await this.authService.SetSession(attempt, this.userattempt);
|
||||||
await this.authService.loginChat(this.userattempt);
|
await this.authService.loginChat();
|
||||||
this.getToken();
|
this.getToken();
|
||||||
SessionStore.setInativity(true);
|
SessionStore.setInativity(true);
|
||||||
|
|
||||||
@@ -117,7 +116,7 @@ export class LoginPage implements OnInit {
|
|||||||
await this.authService.SetSession(attempt, this.userattempt);
|
await this.authService.SetSession(attempt, this.userattempt);
|
||||||
|
|
||||||
this.changeProfileService.run()
|
this.changeProfileService.run()
|
||||||
await this.authService.loginChat(this.userattempt);
|
await this.authService.loginChat();
|
||||||
this.getToken();
|
this.getToken();
|
||||||
this.router.navigateByUrl('/pin', { replaceUrl: true });
|
this.router.navigateByUrl('/pin', { replaceUrl: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,12 +108,17 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Login to rocketChat server
|
//Login to rocketChat server2
|
||||||
async loginChat(user: UserForm) {
|
//user: UserForm
|
||||||
const expireDate = new Date(new Date().getTime() + 60*1000);
|
async loginChat() {
|
||||||
|
|
||||||
|
const expirationMinutes = 60;
|
||||||
|
let date = new Date().getTime();
|
||||||
|
let expirationDate = new Date(new Date().getTime() + expirationMinutes*60*1000);
|
||||||
|
|
||||||
let postData = {
|
let postData = {
|
||||||
"user": user.username,
|
"user": SessionStore.user.RochetChatUser,
|
||||||
"password": user.password,
|
"password": SessionStore.user.Password,
|
||||||
}
|
}
|
||||||
|
|
||||||
let responseChat = await this.httpService.post('login', postData).toPromise();
|
let responseChat = await this.httpService.post('login', postData).toPromise();
|
||||||
@@ -126,17 +131,19 @@ export class AuthService {
|
|||||||
this.ValidatedUserChat = responseChat;
|
this.ValidatedUserChat = responseChat;
|
||||||
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||||
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
||||||
|
|
||||||
/* this.autologout(10000); */
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
console.log('Network error');
|
console.log('Network error');
|
||||||
this.presentAlert('Network error');
|
this.presentAlert('Network error');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.autoLoginChat(expirationDate.getTime() - date);
|
||||||
|
}
|
||||||
|
|
||||||
|
async autoLoginChat(expirationDate:number){
|
||||||
|
setTimeout(()=>{
|
||||||
|
this.loginChat();
|
||||||
|
}, expirationDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
private loginToChatWs() {
|
private loginToChatWs() {
|
||||||
@@ -151,8 +158,8 @@ export class AuthService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
this.NfService.beforeSendAttachment = async (message: MessageService, room?: RoomService) => {
|
this.NfService.beforeSendAttachment = async (message: MessageService, room?: RoomService) => {
|
||||||
|
|
||||||
if(message.hasFile) {
|
if(message.hasFile) {
|
||||||
if(message.file.type != 'application/webtrix') {
|
if(message.file.type != 'application/webtrix') {
|
||||||
const formData = message.temporaryData
|
const formData = message.temporaryData
|
||||||
@@ -164,14 +171,14 @@ export class AuthService {
|
|||||||
console.log('add picture to chat IMAGE SAVED')
|
console.log('add picture to chat IMAGE SAVED')
|
||||||
message.getFileFromDb()
|
message.getFileFromDb()
|
||||||
});
|
});
|
||||||
|
|
||||||
return true
|
return true
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const res = message.temporaryData
|
const res = message.temporaryData
|
||||||
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
|
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");
|
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
||||||
@@ -182,7 +189,7 @@ export class AuthService {
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,12 +214,12 @@ export class WsChatMethodsService {
|
|||||||
*/
|
*/
|
||||||
private defaultSubtribe(id: any) {
|
private defaultSubtribe(id: any) {
|
||||||
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
|
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
|
||||||
console.log('streamRoomMessages', subscription)
|
//console.log('streamRoomMessages', subscription)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
|
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
|
||||||
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
|
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
|
||||||
console.log('streamNotifyRoomDeleteMessage', subscription);
|
//console.log('streamNotifyRoomDeleteMessage', subscription);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -657,11 +657,11 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
|
|||||||
for (const [key, item] of Object.entries(this.wsMsgQueue)) {
|
for (const [key, item] of Object.entries(this.wsMsgQueue)) {
|
||||||
|
|
||||||
if(item.loginRequired == true && this.isLogin == true) {
|
if(item.loginRequired == true && this.isLogin == true) {
|
||||||
console.log('run msgQueue ', key)
|
//console.log('run msgQueue ', key)
|
||||||
this.ws.send(item);
|
this.ws.send(item);
|
||||||
delete this.wsMsgQueue[key]
|
delete this.wsMsgQueue[key]
|
||||||
} else if(item.loginRequired == false) {
|
} else if(item.loginRequired == false) {
|
||||||
console.log('run msgQueue ', key)
|
//console.log('run msgQueue ', key)
|
||||||
this.ws.send(item);
|
this.ws.send(item);
|
||||||
delete this.wsMsgQueue[key]
|
delete this.wsMsgQueue[key]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export class FileService {
|
|||||||
data: base64Data,
|
data: base64Data,
|
||||||
directory: Directory.Data
|
directory: Directory.Data
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//new method 3
|
//new method 3
|
||||||
@@ -160,7 +160,7 @@ export class FileService {
|
|||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
input.onchange = async () => {
|
input.onchange = async () => {
|
||||||
const file = this.fileLoaderService.getFirstFile(input)
|
const file = this.fileLoaderService.getFirstFile(input)
|
||||||
|
|
||||||
resolve(file);
|
resolve(file);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export class NewGroupPage implements OnInit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ngOnDestroy(){
|
/* ngOnDestroy(){
|
||||||
alert('Destroy')
|
|
||||||
this.dataService.set("newGroup", false);
|
this.dataService.set("newGroup", false);
|
||||||
this.dataService.set("task", null);
|
this.dataService.set("task", null);
|
||||||
this.dataService.set("newGroupName", '');
|
this.dataService.set("newGroupName", '');
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class SessionService {
|
|||||||
// main data
|
// main data
|
||||||
private _user = new UserSession()
|
private _user = new UserSession()
|
||||||
// local storage keyName
|
// local storage keyName
|
||||||
private keyName: string;
|
private keyName: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class SessionService {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return this._user.PIN.length >= 2
|
return this._user.PIN.length >= 2
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(user) {
|
reset(user) {
|
||||||
@@ -98,4 +98,4 @@ class SessionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const SessionStore = new SessionService()
|
export const SessionStore = new SessionService()
|
||||||
|
|||||||
Reference in New Issue
Block a user