From 9116ac4d064b779b42afafabeca788d9ae2f77ca Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Tue, 13 Dec 2022 17:21:48 +0100 Subject: [PATCH] save --- src/app/guards/auth.guard.ts | 2 +- .../preview-camera/preview-camera.page.html | 2 +- src/app/models/user.model.ts | 2 +- src/app/pages/events/events.page.html | 4 +- src/app/pages/events/events.page.ts | 5 +-- src/app/pages/inactivity/inactivity.page.ts | 2 +- src/app/pages/login/login.page.ts | 7 ---- src/app/services/auth.service.ts | 12 +----- src/app/services/background.service.ts | 42 +++++++++++++------ src/app/services/chat.service.ts | 4 +- src/app/services/chat/chat-system.service.ts | 2 + src/app/shared/header/header.page.ts | 33 ++++++++------- src/environments/environment.prod.ts | 8 ++-- src/environments/environment.ts | 6 +-- 14 files changed, 68 insertions(+), 63 deletions(-) diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index f1b5506ee..9beca8a4b 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -33,7 +33,7 @@ export class AuthGuard implements CanActivate { return false } else { if(this.p.userPermission(this.p.permissionList.Chat.access) == true) { - this.authService.loginChat(); + // this.authService.loginChat(); } const pathname = state.url diff --git a/src/app/modals/preview-camera/preview-camera.page.html b/src/app/modals/preview-camera/preview-camera.page.html index 713edaa99..7e54af7c3 100644 --- a/src/app/modals/preview-camera/preview-camera.page.html +++ b/src/app/modals/preview-camera/preview-camera.page.html @@ -5,7 +5,7 @@
- +
diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index 6b5ce1173..b6a4e0dc6 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -76,7 +76,7 @@ export class UserSession { UserName: string Password: string RochetChatUserId: string - Profile: 'PR' | 'MDGPR' | 'Consultant' ; + Profile: 'PR' | 'MDGPR' | 'Consultant' | 'Unknown' ; LoginPreference: 'None' | 'Password' | 'Pin' | null; PIN: string Inactivity: boolean diff --git a/src/app/pages/events/events.page.html b/src/app/pages/events/events.page.html index d4be4c61f..4a398e0d2 100644 --- a/src/app/pages/events/events.page.html +++ b/src/app/pages/events/events.page.html @@ -28,7 +28,7 @@
-
+
@@ -88,7 +88,7 @@
-
+
diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index 97d25ce28..e22c7f711 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -14,7 +14,6 @@ import { BackgroundService } from 'src/app/services/background.service'; import { momentG } from 'src/plugin/momentG'; import { ThemeService } from 'src/app/services/theme.service' import { Storage } from '@ionic/storage'; -import { PermissionList } from 'src/app/models/permission/permissionList'; import { PermissionService } from 'src/app/services/permission.service'; import { ViewEventPage } from 'src/app/modals/view-event/view-event.page'; import { ChangeProfileService } from 'src/app/services/change-profile.service'; @@ -65,8 +64,6 @@ export class EventsPage implements OnInit { loggeduser: LoginUserRespose; - permissionList = new PermissionList(); - constructor( private eventService: EventsService, private router: Router, @@ -81,7 +78,7 @@ export class EventsPage implements OnInit { public p: PermissionService, private changeProfileService: ChangeProfileService, ) { - + this.loggeduser = SessionStore.user; diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index ac3dbd8cb..27255c30d 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -123,7 +123,7 @@ export class InactivityPage implements OnInit { await this.authService.SetSession(attempt, this.userattempt); if(this.p.userPermission(this.p.permissionList.Chat.access)){ - this.authService.loginChat(); + // this.authService.loginChat(); } this.getToken(); diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index a30acb3cc..5baee9067 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -10,12 +10,10 @@ import { SessionStore } from 'src/app/store/session.service'; import { ClearStoreService } from 'src/app/services/clear-store.service'; import { ChangeProfileService } from 'src/app/services/change-profile.service'; import { ThemeService } from 'src/app/services/theme.service'; -import { StorageService } from 'src/app/services/storage.service'; import { PermissionService } from 'src/app/services/permission.service'; import { PermissionList } from 'src/app/models/permission/permissionList'; import { MessageModel, DeleteMessageModel } from '../../models/beast-orm'; import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'; -import { Storage } from '@ionic/storage'; import { ChatSystemService } from 'src/app/services/chat/chat-system.service'; import { ChatService } from 'src/app/services/chat.service'; @@ -37,7 +35,6 @@ export class LoginPage implements OnInit { loginPreference: string sessionStore = SessionStore; - permissionList = new PermissionList(); showPassword = false; passwordIcon = "eye"; @@ -50,10 +47,8 @@ export class LoginPage implements OnInit { private clearStoreService: ClearStoreService, private changeProfileService: ChangeProfileService, public ThemeService: ThemeService, - private storageservice: StorageService, public p: PermissionService, private RochetChatConnectorService: RochetChatConnectorService, - private storage: Storage, public ChatSystemService: ChatSystemService, private ChatService: ChatService ) {} @@ -128,7 +123,6 @@ export class LoginPage implements OnInit { await this.authService.SetSession(attempt, this.userattempt); if(attempt.ChatData) { - await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginToChatWs(); this.ChatService.setheader() @@ -157,7 +151,6 @@ export class LoginPage implements OnInit { if(attempt.ChatData) { - await this.authService.loginChat(attempt.ChatData.data); await this.authService.loginToChatWs(); this.ChatService.setheader(); this.ChatSystemService.loadChat(); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 4a23f7923..8b8ede159 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -34,11 +34,9 @@ export class AuthService { constructor( private http: HttpClient, - private httpService: HttpService, private storageService:StorageService, public alertController: AlertController, private aesencrypt: AESEncrypt, - private cookieService: CookieService, private RochetChatConnectorService: RochetChatConnectorService, private router: Router, private NfService:NfService, @@ -96,6 +94,8 @@ export class AuthService { session.Profile = 'MDGPR' } else if(session.RoleID == 99999872) { session.Profile = 'Consultant' + } else { + session.Profile = 'Unknown' } session.Password = user.password @@ -111,14 +111,6 @@ export class AuthService { this.initialsService.getInitials(session.FullName); } - async loginChat(responseChat?) { - - - } - - async autoLoginChat(expirationDate:number) { - } - loginToChatWs() { setTimeout(() => { diff --git a/src/app/services/background.service.ts b/src/app/services/background.service.ts index eba6fa6a5..df1843528 100644 --- a/src/app/services/background.service.ts +++ b/src/app/services/background.service.ts @@ -1,6 +1,8 @@ import { Injectable } from '@angular/core'; import { ThemeService } from 'src/app/services/theme.service'; import { StorageService} from 'src/app/services/storage.service'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' @@ -15,7 +17,8 @@ export class BackgroundService { constructor( private themeservice: ThemeService, - private storageservice: StorageService + private storageservice: StorageService, + private http: HttpClient, ) { } online() { @@ -54,18 +57,33 @@ export class BackgroundService { } } - offline() { - document.body.style.setProperty(`--color`, "#ffb703"); - document.body.style.setProperty(`--color2`, "#ffb703"); - document.body.style.setProperty(`--color3`, "#ffb703"); - document.body.style.setProperty(`--color4`, "#ffb703"); - document.body.style.setProperty(`--color5`, "#ffb703"); - this.storageservice.store('networkCheckStore','offline'); - this.callBacks.forEach((e) => { - if (e.type == 'Offline') { - e.funx() + async offline() { + + let opts = { + headers: {}, + } + + try { + await this.http.post(environment.apiURL + "UserAuthentication/Login", '', opts).toPromise(); + } catch (error) { + if(error.status != 400) { + + document.body.style.setProperty(`--color`, "#ffb703"); + document.body.style.setProperty(`--color2`, "#ffb703"); + document.body.style.setProperty(`--color3`, "#ffb703"); + document.body.style.setProperty(`--color4`, "#ffb703"); + document.body.style.setProperty(`--color5`, "#ffb703"); + this.storageservice.store('networkCheckStore','offline'); + this.callBacks.forEach((e) => { + if (e.type == 'Offline') { + e.funx() + } + }) + } - }) + } + + } registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') { diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index bcfa787ae..bff0e12e0 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -343,7 +343,7 @@ export class ChatService { setheader() { try { - if (this.p.userPermission(this.p.permissionList.Chat.access)) { + if (this.p.userPermission(this.p.permissionList.Chat.access) && SessionStore.user.ChatData) { this.headers = new HttpHeaders(); if (this.p.userPermission(this.p.permissionList.Chat.access)) { @@ -364,7 +364,7 @@ export class ChatService { async refreshtoken() { - if(this.headers) { + if(this.headers && SessionStore.user.ChatData) { this.headers = this.headers.set('Authorization', SessionStore.user.BasicAuthKey); let options = { headers: this.headers diff --git a/src/app/services/chat/chat-system.service.ts b/src/app/services/chat/chat-system.service.ts index d7e662f65..d1d9716d0 100644 --- a/src/app/services/chat/chat-system.service.ts +++ b/src/app/services/chat/chat-system.service.ts @@ -576,6 +576,8 @@ export class ChatSystemService { const firstName = capitalizeTxt(roomName.split('.')[0]) const lastName = capitalizeTxt(roomName.split('.')[1]) return firstName + ' ' + lastName + } else if(roomData.name) { + return roomData.name } else { return 'Sem nome' } diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index 781d71326..bd6ac1616 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -28,11 +28,13 @@ export class HeaderPage implements OnInit { notificationLength: 0; SessionStore = SessionStore check: boolean; - permissionList = new PermissionList(); production = environment.production environment = environment canOpenSearch = false + showProfileModal = false + permissionList = new PermissionList(); + constructor( private router: Router, @@ -48,6 +50,7 @@ export class HeaderPage implements OnInit { router.events.subscribe((val) => { this.showSearch = false; this.canOpenSearch = true; + this.showProfileModal = false }); @@ -179,20 +182,22 @@ export class HeaderPage implements OnInit { return enterAnimation(baseEl).direction('reverse'); } + if(!this.showProfileModal) { + this.showProfileModal = true + const modal = await this.modalController.create({ + component: ProfilePage, + cssClass: 'model profile-modal search-submodal', + componentProps: { + } + }); + await modal.present(); + + modal.onDidDismiss().then(() => { + this.notificationLengthData() + this.showProfileModal = false + }) + } - const modal = await this.modalController.create({ - component: ProfilePage, - cssClass: 'model profile-modal search-submodal', - componentProps: { - } - }); - await modal.present(); - - modal.onDidDismiss().then(() => { - this.notificationLengthData() - }) - - } async dynamicSearch() { diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 639610c63..2fd020f10 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,16 +1,14 @@ export const environment = { - // apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', - apiURL: 'https://gdapi-dev.dyndns.info/GabineteDigital.Services/V5/api/', + apiURL: 'https://gd-api.oapr.gov.ao/GabineteDigital.Services/V5/api/', // apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', // apiChatUrl: 'http://192.168.0.29:3000/api/v1/', // apiWsChatUrl: 'wss://192.168.0.29:3000/websocket', - apiChatUrl: 'https://gdchat-dev.dyndns.info/api/v1/', - apiWsChatUrl: 'wss://gdchat-dev.dyndns.info/websocket', + apiChatUrl: 'https://gd-chat.oapr.gov.ao/api/v1/', + apiWsChatUrl: 'ws://gd-chat.oapr.gov.ao/websocket', /* apiChatUrl: 'https://www.tabularium.pt/api/v1/', apiWsChatUrl: 'wss://www.tabularium.pt/websocket', */ // apiChatUrl: 'https://www.tabularium.pt/api/v1/', - production: true, domain: 'gabinetedigital.local', defaultuser: '',//paulo.pinto paulo.pinto@gabinetedigital.local diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 25cc39335..cd5fccff9 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -22,10 +22,10 @@ export const environment = { production: false, //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', - apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', + apiURL: 'https://gd-api.oapr.gov.ao/GabineteDigital.Services/V5/api/', //apiURL: 'https://gdapi-dev.dyndns.info/GabineteDigital.Services/V5/api/', - apiChatUrl: 'http://192.168.0.29:3000/api/v1/', - apiWsChatUrl: 'ws://192.168.0.29:3000/websocket', + apiChatUrl: 'https://gd-chat.oapr.gov.ao/api/v1/', + apiWsChatUrl: 'ws://gd-chat.oapr.gov.ao/websocket', // apiChatUrl: 'https://gdchat-dev.dyndns.info/api/v1/', // apiWsChatUrl: 'wss://gdchat-dev.dyndns.info/websocket', /* apiChatUrl: 'https://www.tabularium.pt/api/v1/',