mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
reconnect rocketchat socket
This commit is contained in:
@@ -13,9 +13,6 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<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>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<provider android:authorities="${applicationId}.fileprovider" android:exported="false"
|
<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 { UserSession } from '../models/user.model';
|
||||||
import { PermissionList } from '../models/permission/permissionList';
|
import { PermissionList } from '../models/permission/permissionList';
|
||||||
|
|
||||||
|
import { Plugins } from '@capacitor/core';
|
||||||
|
|
||||||
|
const { App } = Plugins;
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
@@ -131,8 +135,6 @@ export class HomePage implements OnInit {
|
|||||||
);
|
);
|
||||||
}); */
|
}); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto(url) {
|
goto(url) {
|
||||||
@@ -232,6 +234,22 @@ export class HomePage implements OnInit {
|
|||||||
})()
|
})()
|
||||||
}, 1000)
|
}, 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() {
|
clearTabButtonSelection() {
|
||||||
@@ -322,4 +340,16 @@ export class HomePage implements OnInit {
|
|||||||
// this.sqliteservice.deleteAllTables();
|
// 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
|
SessionStore = SessionStore
|
||||||
production = environment.production
|
production = environment.production
|
||||||
environment = environment
|
environment = environment
|
||||||
capturedImage = '';
|
capturedImage: any;
|
||||||
capturedImageTitle = '';
|
capturedImageTitle = '';
|
||||||
profilePicture = "";
|
profilePicture = "";
|
||||||
|
|
||||||
@@ -39,7 +39,8 @@ export class EditProfilePage implements OnInit {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getProfilpictureFromStorage()
|
|
||||||
|
this.getProfilpictureFromStorage();
|
||||||
}
|
}
|
||||||
getProfilpictureFromStorage() {
|
getProfilpictureFromStorage() {
|
||||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||||
@@ -49,15 +50,15 @@ export class EditProfilePage implements OnInit {
|
|||||||
this.profilePicture = "";
|
this.profilePicture = "";
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
getProfilpicture(guid) {
|
/* getProfilpicture(guid) {
|
||||||
console.log('Get picture ', guid.path)
|
console.log('Get picture ', guid.path)
|
||||||
this.attachmentService.downloadFile(guid.path).subscribe(async (picture: any) => {
|
this.attachmentService.getUserProfilePhoto().subscribe(async (picture: any) => {
|
||||||
|
|
||||||
|
console.log('Get picture ', picture)
|
||||||
let downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(picture.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
|
||||||
console.log('Get picture ', downloadFile)
|
|
||||||
this.storageService.store(this.SessionStore.user.RoleID.toString() + "guid", guid.path)
|
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')
|
console.log('picture saved')
|
||||||
@@ -69,7 +70,7 @@ export class EditProfilePage implements OnInit {
|
|||||||
console.log('Error get profile picture: ', error)
|
console.log('Error get profile picture: ', error)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
}
|
} */
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.modalController.dismiss();
|
this.modalController.dismiss();
|
||||||
@@ -177,18 +178,25 @@ export class EditProfilePage implements OnInit {
|
|||||||
source: CameraSource.Camera
|
source: CameraSource.Camera
|
||||||
});
|
});
|
||||||
|
|
||||||
this.capturedImageTitle = SessionStore.user.Profile;
|
this.capturedImage = capturedImage.base64String;
|
||||||
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
|
var object = JSON.stringify({
|
||||||
|
"ImageBase64": this.capturedImage
|
||||||
|
}
|
||||||
|
)
|
||||||
|
console.log('ATTACHME ', object)
|
||||||
|
|
||||||
const blob = this.dataURItoBlob(this.capturedImage)
|
this.attachmentService.addUserProfilePhoto(object).subscribe((guid) => {
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("blobFile", blob);
|
|
||||||
|
|
||||||
this.attachmentService.uploadFile(formData).subscribe((guid) => {
|
|
||||||
console.log('GUID ', guid)
|
console.log('GUID ', guid)
|
||||||
console.log(this.SessionStore.user.RoleID.toString())
|
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) => {
|
}, ((error) => {
|
||||||
console.log('Erro Upload profile picture ', error)
|
console.log('Erro Upload profile picture ', error)
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ export class ProfilePage implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.getNotificationData();
|
this.getNotificationData();
|
||||||
|
|
||||||
|
|
||||||
this.getProfilpicture();
|
this.getProfilpicture();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -92,7 +94,7 @@ export class ProfilePage implements OnInit {
|
|||||||
getProfilpicture() {
|
getProfilpicture() {
|
||||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||||
console.log(picture)
|
console.log(picture)
|
||||||
this.profilePicture = picture
|
this.profilePicture = 'data:image/jpeg;base64,' +picture
|
||||||
}).catch((error ) => {
|
}).catch((error ) => {
|
||||||
this.profilePicture = "";
|
this.profilePicture = "";
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -96,4 +96,5 @@ export class UserSession {
|
|||||||
Inactivity: boolean
|
Inactivity: boolean
|
||||||
UrlBeforeInactivity: string;
|
UrlBeforeInactivity: string;
|
||||||
UserPermissions: any;
|
UserPermissions: any;
|
||||||
|
UserPhoto: string;
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
ViewChild,
|
ViewChild,
|
||||||
ViewContainerRef,
|
ViewContainerRef,
|
||||||
Output,
|
Output,
|
||||||
|
NgZone,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ModalController, Platform } from '@ionic/angular';
|
import { ModalController, Platform } from '@ionic/angular';
|
||||||
import { AuthService } from 'src/app/services/auth.service';
|
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 { SessionStore } from 'src/app/store/session.service';
|
||||||
import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-debugging.page';
|
import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-debugging.page';
|
||||||
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
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({
|
@Component({
|
||||||
selector: 'app-chat',
|
selector: 'app-chat',
|
||||||
templateUrl: './chat.page.html',
|
templateUrl: './chat.page.html',
|
||||||
@@ -115,7 +121,9 @@ export class ChatPage implements OnInit {
|
|||||||
private storageservice: StorageService,
|
private storageservice: StorageService,
|
||||||
public ChatSystemService: ChatSystemService,
|
public ChatSystemService: ChatSystemService,
|
||||||
private activatedRoute: ActivatedRoute,
|
private activatedRoute: ActivatedRoute,
|
||||||
private eventTriger: EventTrigger
|
private eventTriger: EventTrigger,
|
||||||
|
private RochetChatConnectorService: RochetChatConnectorService,
|
||||||
|
private zone: NgZone
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
@@ -140,6 +148,7 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
|
console.log("Loading TestComponent")
|
||||||
this.segment = "Contactos";
|
this.segment = "Contactos";
|
||||||
|
|
||||||
this.authService.userData$.subscribe((res: any) => {
|
this.authService.userData$.subscribe((res: any) => {
|
||||||
@@ -164,6 +173,22 @@ export class ChatPage implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.routeCheck()
|
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() {
|
routeCheck() {
|
||||||
@@ -409,6 +434,7 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
onSegmentChange() {
|
onSegmentChange() {
|
||||||
this.ChatSystemService.getAllRooms();
|
this.ChatSystemService.getAllRooms();
|
||||||
|
this.ChatSystemService._dm
|
||||||
}
|
}
|
||||||
|
|
||||||
doRefresh(event) {
|
doRefresh(event) {
|
||||||
@@ -830,5 +856,18 @@ export class ChatPage implements OnInit {
|
|||||||
await modal.present();
|
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);
|
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,) {
|
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() {
|
connect() {
|
||||||
|
console.log('Check conetion 11')
|
||||||
// dont connect if is already connected
|
// dont connect if is already connected
|
||||||
if(this.ws.connected == true) {
|
if(this.ws.connected == true) {
|
||||||
|
console.log('Check conetion 22')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Check conetion 33')
|
||||||
this.ws.connect();
|
this.ws.connect();
|
||||||
|
|
||||||
const message = {
|
const message = {
|
||||||
|
|||||||
@@ -75,17 +75,20 @@ export class HeaderPage implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
ngOnInit() {
|
||||||
this.hideSearch();
|
this.hideSearch();
|
||||||
/* this.notificationLengthData(); */
|
|
||||||
this.getProfilpicture();
|
this.getProfilpicture();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ng
|
||||||
|
|
||||||
|
|
||||||
getProfilpicture() {
|
getProfilpicture() {
|
||||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||||
console.log(picture)
|
console.log(picture)
|
||||||
this.profilePicture = picture
|
this.profilePicture = 'data:image/jpeg;base64,' +picture
|
||||||
}).catch((error ) => {
|
}).catch((error ) => {
|
||||||
this.profilePicture = "";
|
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);
|
console.log("Push Clicked ", event);
|
||||||
// Enviar uma mensagem para o cliente (componente)
|
// Enviar uma mensagem para o cliente (componente)
|
||||||
self.clients.matchAll().then((clients) => {
|
self.clients.matchAll().then((clients) => {
|
||||||
@@ -70,4 +70,4 @@ self.addEventListener('notificationclick', function(event) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}); */
|
||||||
Reference in New Issue
Block a user