mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
reconnect rocketchat socket
This commit is contained in:
@@ -13,9 +13,6 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="image/*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider android:authorities="${applicationId}.fileprovider" android:exported="false"
|
||||
|
||||
@@ -21,6 +21,10 @@ import { NetworkServiceService, ConnectionStatus } from 'src/app/services/networ
|
||||
import { UserSession } from '../models/user.model';
|
||||
import { PermissionList } from '../models/permission/permissionList';
|
||||
|
||||
import { Plugins } from '@capacitor/core';
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@@ -131,8 +135,6 @@ export class HomePage implements OnInit {
|
||||
);
|
||||
}); */
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
goto(url) {
|
||||
@@ -232,6 +234,22 @@ export class HomePage implements OnInit {
|
||||
})()
|
||||
}, 1000)
|
||||
|
||||
|
||||
/* if (!this.platform.is('desktop')) {
|
||||
App.addListener('appStateChange', ({ isActive }) => {
|
||||
if (isActive) {
|
||||
// The app is in the foreground.
|
||||
console.log('App is in the foreground');
|
||||
this.RochetChatConnectorService.connect()
|
||||
this.reloadComponent(true)
|
||||
} else {
|
||||
// The app is in the background.
|
||||
console.log('App is in the background');
|
||||
// You can perform actions specific to the background state here.
|
||||
}
|
||||
});
|
||||
} */
|
||||
|
||||
}
|
||||
|
||||
clearTabButtonSelection() {
|
||||
@@ -322,4 +340,16 @@ export class HomePage implements OnInit {
|
||||
// this.sqliteservice.deleteAllTables();
|
||||
}
|
||||
|
||||
|
||||
reloadComponent(self:boolean,urlToNavigateTo ?:string){
|
||||
//skipLocationChange:true means dont update the url to / when navigating
|
||||
console.log("Current route I am on:",this.router.url);
|
||||
const url=self ? this.router.url :urlToNavigateTo;
|
||||
this.router.navigateByUrl('/',{skipLocationChange:true}).then(()=>{
|
||||
this.router.navigate([`/${url}`]).then(()=>{
|
||||
console.log(`After navigation I am on:${this.router.url}`)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ export class EditProfilePage implements OnInit {
|
||||
SessionStore = SessionStore
|
||||
production = environment.production
|
||||
environment = environment
|
||||
capturedImage = '';
|
||||
capturedImage: any;
|
||||
capturedImageTitle = '';
|
||||
profilePicture = "";
|
||||
|
||||
@@ -39,7 +39,8 @@ export class EditProfilePage implements OnInit {
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.getProfilpictureFromStorage()
|
||||
|
||||
this.getProfilpictureFromStorage();
|
||||
}
|
||||
getProfilpictureFromStorage() {
|
||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||
@@ -49,15 +50,15 @@ export class EditProfilePage implements OnInit {
|
||||
this.profilePicture = "";
|
||||
})
|
||||
}
|
||||
getProfilpicture(guid) {
|
||||
/* getProfilpicture(guid) {
|
||||
console.log('Get picture ', guid.path)
|
||||
this.attachmentService.downloadFile(guid.path).subscribe(async (picture: any) => {
|
||||
this.attachmentService.getUserProfilePhoto().subscribe(async (picture: any) => {
|
||||
|
||||
|
||||
let downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(picture.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
console.log('Get picture ', downloadFile)
|
||||
console.log('Get picture ', picture)
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString() + "guid", guid.path)
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString(), downloadFile).then((value) => {
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString(), picture).then((value) => {
|
||||
this.profilePicture = picture
|
||||
this.SessionStore.user.UserPhoto = picture;
|
||||
|
||||
|
||||
console.log('picture saved')
|
||||
@@ -69,7 +70,7 @@ export class EditProfilePage implements OnInit {
|
||||
console.log('Error get profile picture: ', error)
|
||||
}))
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
close() {
|
||||
this.modalController.dismiss();
|
||||
@@ -177,18 +178,25 @@ export class EditProfilePage implements OnInit {
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
this.capturedImageTitle = SessionStore.user.Profile;
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
|
||||
this.capturedImage = capturedImage.base64String;
|
||||
var object = JSON.stringify({
|
||||
"ImageBase64": this.capturedImage
|
||||
}
|
||||
)
|
||||
console.log('ATTACHME ', object)
|
||||
|
||||
const blob = this.dataURItoBlob(this.capturedImage)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
this.attachmentService.uploadFile(formData).subscribe((guid) => {
|
||||
this.attachmentService.addUserProfilePhoto(object).subscribe((guid) => {
|
||||
console.log('GUID ', guid)
|
||||
console.log(this.SessionStore.user.RoleID.toString())
|
||||
this.getProfilpicture(guid);
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString(), this.capturedImage).then((value) => {
|
||||
this.profilePicture = 'data:image/jpeg;base64,' +this.capturedImage;
|
||||
|
||||
|
||||
console.log('picture saved')
|
||||
}).catch((error) => {
|
||||
console.log('picture not saved')
|
||||
});
|
||||
/* this.getProfilpicture(guid); */
|
||||
}, ((error) => {
|
||||
console.log('Erro Upload profile picture ', error)
|
||||
}))
|
||||
|
||||
@@ -85,6 +85,8 @@ export class ProfilePage implements OnInit {
|
||||
ngOnInit() {
|
||||
|
||||
this.getNotificationData();
|
||||
|
||||
|
||||
this.getProfilpicture();
|
||||
|
||||
}
|
||||
@@ -92,7 +94,7 @@ export class ProfilePage implements OnInit {
|
||||
getProfilpicture() {
|
||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||
console.log(picture)
|
||||
this.profilePicture = picture
|
||||
this.profilePicture = 'data:image/jpeg;base64,' +picture
|
||||
}).catch((error ) => {
|
||||
this.profilePicture = "";
|
||||
})
|
||||
|
||||
@@ -96,4 +96,5 @@ export class UserSession {
|
||||
Inactivity: boolean
|
||||
UrlBeforeInactivity: string;
|
||||
UserPermissions: any;
|
||||
UserPhoto: string;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
Output,
|
||||
NgZone,
|
||||
} from '@angular/core';
|
||||
import { ModalController, Platform } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
@@ -28,8 +29,13 @@ import { StorageService } from 'src/app/services/storage.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-debugging.page';
|
||||
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
||||
|
||||
|
||||
import { Plugins } from '@capacitor/core';
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
@Component({
|
||||
selector: 'app-chat',
|
||||
templateUrl: './chat.page.html',
|
||||
@@ -115,7 +121,9 @@ export class ChatPage implements OnInit {
|
||||
private storageservice: StorageService,
|
||||
public ChatSystemService: ChatSystemService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private eventTriger: EventTrigger
|
||||
private eventTriger: EventTrigger,
|
||||
private RochetChatConnectorService: RochetChatConnectorService,
|
||||
private zone: NgZone
|
||||
) {
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
@@ -140,6 +148,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
console.log("Loading TestComponent")
|
||||
this.segment = "Contactos";
|
||||
|
||||
this.authService.userData$.subscribe((res: any) => {
|
||||
@@ -164,6 +173,22 @@ export class ChatPage implements OnInit {
|
||||
});
|
||||
|
||||
this.routeCheck()
|
||||
|
||||
|
||||
if (!this.platform.is('desktop')) {
|
||||
App.addListener('appStateChange', ({ isActive }) => {
|
||||
if (isActive) {
|
||||
// The app is in the foreground.
|
||||
console.log('App is in the foreground');
|
||||
this.RochetChatConnectorService.connect()
|
||||
this.reloadComponent(true)
|
||||
} else {
|
||||
// The app is in the background.
|
||||
console.log('App is in the background');
|
||||
// You can perform actions specific to the background state here.
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
routeCheck() {
|
||||
@@ -409,6 +434,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
onSegmentChange() {
|
||||
this.ChatSystemService.getAllRooms();
|
||||
this.ChatSystemService._dm
|
||||
}
|
||||
|
||||
doRefresh(event) {
|
||||
@@ -830,5 +856,18 @@ export class ChatPage implements OnInit {
|
||||
await modal.present();
|
||||
}
|
||||
|
||||
reloadComponent(self:boolean,urlToNavigateTo ?:string){
|
||||
//skipLocationChange:true means dont update the url to / when navigating
|
||||
console.log("Current route I am on:",this.router.url);
|
||||
const url=self ? this.router.url :urlToNavigateTo;
|
||||
this.zone.run(() =>this.router.navigateByUrl('/',{skipLocationChange:true}).then(()=>{
|
||||
this.zone.run(() => this.router.navigate([`/${url}`]).then(()=>{
|
||||
console.log(`After navigation I am on:${this.router.url}`)
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -178,4 +178,26 @@ export class AttachmentsService {
|
||||
return this.http.post(`${geturl}`, body, options);
|
||||
}
|
||||
|
||||
addUserProfilePhoto(formData: any) {
|
||||
const geturl = environment.apiURL + 'UserAuthentication/AddPhoto';
|
||||
|
||||
this.headers = this.headers.set('content-type', "application/json");
|
||||
this.headers = this.headers.set('accept', "application/json");
|
||||
let options = {
|
||||
headers: this.headers
|
||||
};
|
||||
|
||||
return this.http.post(`${geturl}`, formData, options);
|
||||
}
|
||||
|
||||
getUserProfilePhoto() {
|
||||
const geturl = environment.apiURL + 'UserAuthentication/GetPhoto';
|
||||
|
||||
let options = {
|
||||
headers: this.headers
|
||||
};
|
||||
|
||||
return this.http.get(`${geturl}`, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,23 @@ export class RochetChatConnectorService {
|
||||
constructor(private backgroundservice: BackgroundService,) {
|
||||
}
|
||||
|
||||
reConnect() {
|
||||
console.log('Connect1 ',this.ws.connected)
|
||||
if(!this.ws.connected) {
|
||||
this.ws.connect()
|
||||
console.log('Connect2 ',this.ws.connected)
|
||||
}
|
||||
}
|
||||
|
||||
connect() {
|
||||
console.log('Check conetion 11')
|
||||
// dont connect if is already connected
|
||||
if(this.ws.connected == true) {
|
||||
console.log('Check conetion 22')
|
||||
return false
|
||||
}
|
||||
|
||||
console.log('Check conetion 33')
|
||||
this.ws.connect();
|
||||
|
||||
const message = {
|
||||
|
||||
@@ -75,17 +75,20 @@ export class HeaderPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
ngOnInit() {
|
||||
this.hideSearch();
|
||||
/* this.notificationLengthData(); */
|
||||
|
||||
this.getProfilpicture();
|
||||
|
||||
}
|
||||
|
||||
ng
|
||||
|
||||
|
||||
getProfilpicture() {
|
||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||
console.log(picture)
|
||||
this.profilePicture = picture
|
||||
this.profilePicture = 'data:image/jpeg;base64,' +picture
|
||||
}).catch((error ) => {
|
||||
this.profilePicture = "";
|
||||
})
|
||||
|
||||
@@ -59,7 +59,7 @@ self.addEventListener('message', function(event){
|
||||
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', function(event) {
|
||||
/* self.addEventListener('notificationclick', function(event) {
|
||||
console.log("Push Clicked ", event);
|
||||
// Enviar uma mensagem para o cliente (componente)
|
||||
self.clients.matchAll().then((clients) => {
|
||||
@@ -70,4 +70,4 @@ self.addEventListener('notificationclick', function(event) {
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}); */
|
||||
Reference in New Issue
Block a user