Merge branch 'develop_bitOut' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into develop_bitOut

This commit is contained in:
Eudes Inácio
2022-12-19 17:14:22 +01:00
16 changed files with 335 additions and 309 deletions
+4 -5
View File
@@ -32,14 +32,10 @@ export class AuthGuard implements CanActivate {
this.router.navigate(['/']);
return false
} else {
if(this.p.userPermission(this.p.permissionList.Chat.access) == true) {
// this.authService.loginChat();
}
const pathname = state.url
if(pathname.startsWith('/home/agenda')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
return true;
} else {
@@ -48,7 +44,7 @@ export class AuthGuard implements CanActivate {
}
} else if ( pathname.startsWith('/home/gabinete-digital')) {
console.log('gabinete');
if(this.p.userPermission(this.p.permissionList.Gabinete.access)) {
return true;
@@ -87,6 +83,9 @@ export class AuthGuard implements CanActivate {
}
}
return true
}
}
+1
View File
@@ -21,6 +21,7 @@ export class InactivityGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
console.log('hire inactinity!', state.url)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){
+1
View File
@@ -19,6 +19,7 @@ export class LoginGuard implements CanActivate {
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(SessionStore.exist && SessionStore.user.Inactivity && SessionStore.user.LoginPreference != 'Pin' ) {
this.router.navigate(['/home/events']);
return false
+4 -3
View File
@@ -125,7 +125,8 @@ export class HomePage implements OnInit {
}
goto(url) {
this.router.navigate([url])
// this.router.navigateByUrl('/home/events', { replaceUrl: true });
this.router.navigate([url], { replaceUrl: true })
}
refreshing() { }
@@ -134,8 +135,8 @@ export class HomePage implements OnInit {
this.logDeviceInfo();
this.notificationsService.onReciveForeground();
this.notificationsService.onReciveBackground();
// this.notificationsService.onReciveForeground();
// this.notificationsService.onReciveBackground();
window.addEventListener('online', () => {
// console.log('Became online')
+1 -1
View File
@@ -178,7 +178,7 @@ export class ProfilePage implements OnInit {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
}
this.notificationservice.tempClearArray();
// this.notificationservice.tempClearArray();
this.deleteNotification(index);
this.eventtrigger.publishSomeData({
notification: "deleted"
+3 -3
View File
@@ -797,8 +797,8 @@ export class AgendaPage implements OnInit {
this.listToPresent = this.CalendarStore.eventSource
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
console.log(this.CalendarStore.eventSource)
console.log('this.TimelineMDList', this.TimelineMDList)
// console.log(this.CalendarStore.eventSource)
// console.log('this.TimelineMDList', this.TimelineMDList)
this.myCal.update();
@@ -847,7 +847,7 @@ export class AgendaPage implements OnInit {
this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
console.log('this.TimelinePRList', this.TimelinePRList)
// console.log('this.TimelinePRList', this.TimelinePRList)
//
this.myCal.update();
+33 -33
View File
@@ -79,54 +79,54 @@ export class EventsPage implements OnInit {
private changeProfileService: ChangeProfileService,
) {
this.loggeduser = SessionStore.user;
// this.loggeduser = SessionStore.user;
this.platform.resize.subscribe(async () => {
//
//
// this.platform.resize.subscribe(async () => {
// //
// //
});
// });
window['zipPhoneCallback'] = function (zipphone) {
var frame = document.getElementById('home-iframe');
if(frame) {
frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }});
}
}
// window['zipPhoneCallback'] = function (zipphone) {
// var frame = document.getElementById('home-iframe');
// if(frame) {
// frame['contentWindow']['postMessage']({call:'cookies', value: { cookies: {} }});
// }
// }
this.changeProfileService.registerCallback(() => {
// this.changeProfileService.registerCallback(() => {
this.listToPresent = [];
this.listToPresentexpediente = []
})
// this.listToPresent = [];
// this.listToPresentexpediente = []
// })
}
ngOnInit() {
this.segment = "Combinada";
this.profile = "mdgpr";
// this.segment = "Combinada";
// this.profile = "mdgpr";
this.showGreeting();
// this.showGreeting();
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
// this.router.events.forEach((event) => {
// if (event instanceof NavigationEnd && event.url == '/home/events') {
// this.RefreshEvents();
// setTimeout(() => {
// this.LoadList();
// }, 1500)
// }
// });
// this.hideSearch();
this.backgroundservice.registerBackService('Online', () => {
this.showGreeting();
this.RefreshEvents();
this.LoadList();
this.hideSearch();
});
// this.backgroundservice.registerBackService('Online', () => {
// this.showGreeting();
// this.RefreshEvents();
// this.LoadList();
// this.hideSearch();
// });
}
+6 -4
View File
@@ -38,7 +38,7 @@ export class InactivityPage implements OnInit {
loop = false
ngOnInit() {
alert('pin')
}
runloop() {
@@ -101,6 +101,8 @@ export class InactivityPage implements OnInit {
} else {
SessionStore.delete()
window.localStorage.clear();
SessionStore.setInativity(true)
await this.authService.SetSession(attempt, this.userattempt);
}
@@ -117,9 +119,9 @@ export class InactivityPage implements OnInit {
}
getToken() {
this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError();
this.notificatinsservice.getAndpostToken(this.username);
// this.notificatinsservice.requestPermissions();
// this.notificatinsservice.registrationError();
// this.notificatinsservice.getAndpostToken(this.username);
}
setCode(code: string) {
+14 -5
View File
@@ -15,6 +15,8 @@ import { MessageModel, DeleteMessageModel } from '../../models/beast-orm';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
import { ChatService } from 'src/app/services/chat.service';
import { Platform } from '@ionic/angular';
@Component({
@@ -49,7 +51,8 @@ export class LoginPage implements OnInit {
public p: PermissionService,
private RochetChatConnectorService: RochetChatConnectorService,
public ChatSystemService: ChatSystemService,
private ChatService: ChatService
private ChatService: ChatService,
private platform: Platform,
) {}
ngOnInit() {
@@ -93,9 +96,9 @@ export class LoginPage implements OnInit {
}
getToken() {
this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError();
this.notificatinsservice.getAndpostToken(this.username);
// this.notificatinsservice.requestPermissions();
// this.notificatinsservice.registrationError();
// this.notificatinsservice.getAndpostToken(this.username);
}
async Login() {
@@ -157,7 +160,13 @@ export class LoginPage implements OnInit {
this.getToken();
this.router.navigateByUrl('/home/events', { replaceUrl: true });
if(!this.platform.is('desktop') && !this.platform.is('mobileweb')) {
this.router.navigateByUrl('/pin', { replaceUrl: true });
} else {
this.router.navigateByUrl('/home/events');
}
}
}
else{
+3
View File
@@ -50,10 +50,13 @@ export class AuthService {
this.headers = new HttpHeaders();
if (SessionStore.exist) {
SessionStore.setInativity(true)
if(this.p.userPermission(this.p.permissionList.Chat.access) == true ) {
this.loginToChatWs()
}
}
+8 -3
View File
@@ -136,9 +136,14 @@ export class MessageService {
private usernameToDisplayName(username) {
const firstName = capitalizeTxt(username.split('.')[0])
const lastName = capitalizeTxt(username.split('.')[1])
return firstName + ' ' + lastName
try {
const firstName = capitalizeTxt(username.split('.')[0])
const lastName = capitalizeTxt(username.split('.')[1])
return firstName + ' ' + lastName
} catch (error) {
return username
}
}
async send(): Promise<any> {
+8 -3
View File
@@ -992,9 +992,14 @@ export class RoomService {
usernameToDisplayName(username) {
const firstName = capitalizeTxt(username.split('.')[0])
const lastName = capitalizeTxt(username.split('.')[1])
return firstName + ' ' + lastName
try {
const firstName = capitalizeTxt(username.split('.')[0])
const lastName = capitalizeTxt(username.split('.')[1])
return firstName + ' ' + lastName
} catch(error) {
return username
}
}
sendReadMessage() {
+28 -28
View File
@@ -17,7 +17,7 @@ export class TimeService {
end = new Date();
start = new Date(start);
const totalSeconds = Math.floor((end - (start))/1000);;
const totalSeconds = Math.floor((end - (start))/1000);
const totalMinutes = Math.floor(totalSeconds/60);
const totalHours = Math.floor(totalMinutes/60);
const totalDays = Math.floor(totalHours/24);
@@ -75,37 +75,37 @@ export class TimeService {
}
countDownDateTimer(date:any, roomId:string){
let timer = setInterval(() =>{
let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
// let timer = setInterval(() =>{
// let difference = new Date(date).getTime() - new Date().getTime();
// let c_day = Math.floor(difference/(1000*60*60*24));
// let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
// let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
// let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
// this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0) {
clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room'];
// if(difference < 0) {
// clearInterval(timer);
// this.countDownTime = "Expired";
// let body = { "roomId":roomId, }
// this.chatService.getRoomInfo(roomId).subscribe(room=>{
// this.room = room['room'];
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
this.ChatSystemService.deleteRoom(roomId)
});
}
else{
// if(this.room.t === 'p'){
// this.chatService.deleteGroup(body).subscribe(res=>{
// this.ChatSystemService.deleteRoom(roomId)
// });
// }
// else{
this.chatService.deleteChannel(body).subscribe(res=>{
this.ChatSystemService.deleteRoom(roomId)
});
}
});
}
})
return this.countDownTime;
// this.chatService.deleteChannel(body).subscribe(res=>{
// this.ChatSystemService.deleteRoom(roomId)
// });
// }
// });
// }
// })
// return this.countDownTime;
}
addZero(i) {
+127 -127
View File
@@ -14,7 +14,7 @@ import { BackgroundService } from './background.service';
import { v4 as uuidv4 } from 'uuid';
import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service';
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
// import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
@Injectable({
providedIn: 'root'
@@ -57,170 +57,170 @@ export class NotificationsService {
}
registerCallback(type: string, funx: Function, object: any = {}) {
// registerCallback(type: string, funx: Function, object: any = {}) {
const id = uuidv4()
this.callbacks.push({ type, funx, id })
if (!object.hasOwnProperty('desktop') && object['desktop'] != false) {
this.backgroundservice.registerBackService('Notification', funx, type)
}
// const id = uuidv4()
// this.callbacks.push({ type, funx, id })
// if (!object.hasOwnProperty('desktop') && object['desktop'] != false) {
// this.backgroundservice.registerBackService('Notification', funx, type)
// }
return id;
}
// return id;
// }
deleteCallback(id) {
this.callbacks.forEach((e, index) => {
if (e.id == id) {
if (index > -1) {
this.callbacks.splice(index, 1);
}
}
})
// deleteCallback(id) {
// this.callbacks.forEach((e, index) => {
// if (e.id == id) {
// if (index > -1) {
// this.callbacks.splice(index, 1);
// }
// }
// })
}
// }
getTokenByUserIdAndId(user, userID) {
// const geturl = environment.apiURL + 'notifications/user/' + userID;
// getTokenByUserIdAndId(user, userID) {
// // const geturl = environment.apiURL + 'notifications/user/' + userID;
// return this.http.get<Tokenn[]>(`${geturl}`);
}
// // return this.http.get<Tokenn[]>(`${geturl}`);
// }
requestPermissions() {
PushNotifications.requestPermissions().then(result => {
if (result.receive === 'granted') {
// Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register();
} else {
// Show some error
}
});
}
// requestPermissions() {
// PushNotifications.requestPermissions().then(result => {
// if (result.receive === 'granted') {
// // Register with Apple / Google to receive push via APNS/FCM
// PushNotifications.register();
// } else {
// // Show some error
// }
// });
// }
getAndpostToken(username) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
// getAndpostToken(username) {
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
const geturl = environment.apiURL + 'notifications/token';
PushNotifications.addListener('registration',
(token: Token) => {
// } else {
// const geturl = environment.apiURL + 'notifications/token';
// PushNotifications.addListener('registration',
// (token: Token) => {
this.storageService.store(username, token.value);
this.storageService.get(username).then(value => {
// this.storageService.store(username, token.value);
// this.storageService.get(username).then(value => {
this.storageService.get(AuthConnstants.USER).then(res => {
// this.storageService.get(AuthConnstants.USER).then(res => {
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const body = {
UserId: res.UserId,
TokenId: token.value,
Status: 1,
Service: 1
};
// const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
// const body = {
// UserId: res.UserId,
// TokenId: token.value,
// Status: 1,
// Service: 1
// };
this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
// this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
}, (error) => {
// }, (error) => {
})
});
// })
// });
});
}
);
}
// });
// }
// );
// }
}
// }
registrationError() {
PushNotifications.addListener('registrationError',
(error: any) => {
// registrationError() {
// PushNotifications.addListener('registrationError',
// (error: any) => {
}
);
}
// }
// );
// }
onReciveForeground() {
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotificationSchema) => {
// onReciveForeground() {
// PushNotifications.addListener('pushNotificationReceived',
// (notification: PushNotificationSchema) => {
this.DataArray.push(notification)
// this.DataArray.push(notification)
this.storageService.store("Notifications", this.DataArray)
this.eventtrigger.publishSomeData({
notification: "recive"
})
}
);
}
// this.storageService.store("Notifications", this.DataArray)
// this.eventtrigger.publishSomeData({
// notification: "recive"
// })
// }
// );
// }
onReciveBackground() {
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: ActionPerformed) => {
// onReciveBackground() {
// PushNotifications.addListener('pushNotificationActionPerformed',
// (notification: ActionPerformed) => {
/* this.DataArray.push(notification.notification)
// /* this.DataArray.push(notification.notification)
this.storageService.store("Notifications", this.DataArray)
this.eventtrigger.publishSomeData({
notification: "recive"
}) */
this.notificatinsRoutes(notification)
}
);
}
// this.storageService.store("Notifications", this.DataArray)
// this.eventtrigger.publishSomeData({
// notification: "recive"
// }) */
// this.notificatinsRoutes(notification)
// }
// );
// }
tempClearArray() {
this.DataArray = new Array;
}
// tempClearArray() {
// this.DataArray = new Array;
// }
notificatinsRoutes = (notification) => {
// notificatinsRoutes = (notification) => {
if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
// if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda']));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expediente") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") {
//this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.IdObject, 'agenda']));
// this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda']));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expediente") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital']));
// }
// else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") {
// //this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
// this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.notification.data.IdObject, 'agenda']));
} else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") {
// } else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true }));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true }));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "parecer") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "deferimento") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.notification.data.IdObject, 'gabinete-digital']));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "despachos-pr") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") {
this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject]));
}
else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") {
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject]));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.notification.data.IdObject, 'gabinete-digital']));
// }
// else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "accao") {
// this.zone.run(() => this.router.navigate(['/home/publications', notification.notification.data.IdObject]));
// }
// else if (notification.notification.data.Service === "accoes" && notification.notification.data.Object === "publicacao") {
// this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.notification.data.FolderId, notification.data.IdObject]));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.notification.data.IdObject, 'gabinete-digital']));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "diplomas-assinar") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital']));
}
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', notification.notification.data.IdObject, 'gabinete-digital']));
// }
// else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes-pr") {
// this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.notification.data.IdObject, 'gabinete-digital']));
// }
}
// }
}