mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +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"
|
||||
|
||||
+45
-15
@@ -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',
|
||||
@@ -89,10 +93,10 @@ export class HomePage implements OnInit {
|
||||
public eventService: EventsService,
|
||||
public ActiveTabService: ActiveTabService,
|
||||
private RoleIdService: RoleIdService
|
||||
) {
|
||||
if (SessionStore.exist) {
|
||||
this.user = SessionStore.user;
|
||||
}
|
||||
) {
|
||||
if (SessionStore.exist) {
|
||||
this.user = SessionStore.user;
|
||||
}
|
||||
|
||||
this.router.events.subscribe((val) => {
|
||||
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
|
||||
@@ -124,14 +128,12 @@ export class HomePage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
/* navigator.serviceWorker.ready.then((registration) => {
|
||||
console.log('yes please')
|
||||
registration.active.postMessage(
|
||||
"Test message sent immediately after creation",
|
||||
);
|
||||
}); */
|
||||
|
||||
|
||||
/* navigator.serviceWorker.ready.then((registration) => {
|
||||
console.log('yes please')
|
||||
registration.active.postMessage(
|
||||
"Test message sent immediately after creation",
|
||||
);
|
||||
}); */
|
||||
|
||||
}
|
||||
|
||||
@@ -220,18 +222,34 @@ export class HomePage implements OnInit {
|
||||
|
||||
|
||||
|
||||
(()=>{
|
||||
(() => {
|
||||
document.addEventListener('click', (e: any) => {
|
||||
const closest = e.target.closest(".mat-datepicker-content");
|
||||
if(closest) {
|
||||
if (closest) {
|
||||
e.preventDefault()
|
||||
document.activeElement['blur']();
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
})()
|
||||
}, 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)
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString()+"guid", guid.path)
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString(), downloadFile).then((value) => {
|
||||
console.log('Get picture ', picture)
|
||||
this.storageService.store(this.SessionStore.user.RoleID.toString() + "guid", guid.path)
|
||||
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,20 +178,27 @@ 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)
|
||||
console.log('Erro Upload profile picture ', error)
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
@@ -85,14 +85,16 @@ export class ProfilePage implements OnInit {
|
||||
ngOnInit() {
|
||||
|
||||
this.getNotificationData();
|
||||
this.getProfilpicture();
|
||||
|
||||
|
||||
this.getProfilpicture();
|
||||
|
||||
}
|
||||
|
||||
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}`)
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export class AttachmentsService {
|
||||
this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey);
|
||||
}
|
||||
|
||||
uploadFile(formData:any) {
|
||||
uploadFile(formData: any) {
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export class AttachmentsService {
|
||||
return this.http.post(`${geturl}`, formData, options);
|
||||
}
|
||||
|
||||
getFile(guid:any) {
|
||||
getFile(guid: any) {
|
||||
const geturl = environment.apiURL + 'lakefs/StreamFile';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -66,9 +66,9 @@ export class AttachmentsService {
|
||||
return this.http.get<any>(`${geturl}`, options);
|
||||
}
|
||||
|
||||
downloadFile(guid:any) {
|
||||
downloadFile(guid: any) {
|
||||
|
||||
let downloadUrl = environment.apiURL +'objectserver/streamfiles?path='+guid;
|
||||
let downloadUrl = environment.apiURL + 'objectserver/streamfiles?path=' + guid;
|
||||
var name = new Date().getTime();
|
||||
return this.http.get(downloadUrl, {
|
||||
responseType: "arraybuffer",
|
||||
@@ -77,30 +77,30 @@ export class AttachmentsService {
|
||||
|
||||
}
|
||||
|
||||
downloadFileAndStore(guid:any) {
|
||||
downloadFileAndStore(guid: any) {
|
||||
var name = new Date().getTime();
|
||||
const downloadPath = (
|
||||
this.platform.is('android')
|
||||
) ? this.file.externalDataDirectory : this.file.documentsDirectory;
|
||||
) ? this.file.externalDataDirectory : this.file.documentsDirectory;
|
||||
|
||||
|
||||
let vm = this;
|
||||
let vm = this;
|
||||
|
||||
/** HttpClient - @angular/common/http */
|
||||
this.http.get(
|
||||
environment.apiURL +'objectserver/streamfiles?path='+guid,
|
||||
/** HttpClient - @angular/common/http */
|
||||
this.http.get(
|
||||
environment.apiURL + 'objectserver/streamfiles?path=' + guid,
|
||||
{
|
||||
responseType: 'arraybuffer',
|
||||
responseType: 'arraybuffer',
|
||||
}
|
||||
).subscribe((fileBlob: Uint8Array) => {
|
||||
).subscribe((fileBlob: Uint8Array) => {
|
||||
/** File - @ionic-native/file/ngx */
|
||||
vm.file.writeFile(downloadPath, "YourFileName.pdf", fileBlob, {replace: true});
|
||||
vm.file.writeFile(downloadPath, "YourFileName.pdf", fileBlob, { replace: true });
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getAttachmentsBySerial(serialNumber: string): Observable<Attachment[]>{
|
||||
getAttachmentsBySerial(serialNumber: string): Observable<Attachment[]> {
|
||||
let geturl = environment.apiURL + 'attachments/GetAttachments';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -150,7 +150,7 @@ export class AttachmentsService {
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(`${geturl}`, body, options);
|
||||
return this.http.post(`${geturl}`, body, options);
|
||||
}
|
||||
|
||||
deleteEventAttachmentById(attachmentId) {
|
||||
@@ -166,7 +166,7 @@ export class AttachmentsService {
|
||||
params: params
|
||||
}
|
||||
|
||||
return this.http.delete(`${geturl}`, options);
|
||||
return this.http.delete(`${geturl}`, options);
|
||||
}
|
||||
|
||||
AddAttachment(body: any) {
|
||||
@@ -175,7 +175,29 @@ export class AttachmentsService {
|
||||
let options = {
|
||||
headers: this.headers,
|
||||
}
|
||||
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,) {
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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