This commit is contained in:
Peter Maquiran
2023-01-03 21:08:49 +01:00
parent f7aae9aa00
commit fcc8bc6b74
20 changed files with 356 additions and 68 deletions
+4
View File
@@ -256,6 +256,10 @@ const routes = [
},
{
path: 'add-user',
loadChildren: () => import('./shared/chat/add-user/add-user.module').then( m => m.AddUserPageModule)
},
{
path: 'information',
loadChildren: () => import('./modals/information/information.module').then( m => m.InformationPageModule)
}
+75 -4
View File
@@ -6,16 +6,23 @@ import { PermissionService } from '../services/permission.service';
import { LocalstoreService } from '../store/localstore.service';
import { SessionStore } from '../store/session.service';
import { RouteService } from 'src/app/services/route.service'
import { InformationPage } from 'src/app/modals/information/information.page'
import { FirstEnterService } from 'src/app/services/first-enter.service'
// import { ModalController } from '@ionic/angular';
import { AlertController, Platform } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(
private router:Router,
private localstoreService: LocalstoreService,
private authService: AuthService,
public p: PermissionService,
private RouteService: RouteService
private RouteService: RouteService,
private FirstEnterService: FirstEnterService,
private InformationPage: InformationPage,
private alertController: AlertController,
// private modalController: ModalController,
){}
canActivate(
@@ -41,7 +48,39 @@ export class AuthGuard implements CanActivate {
if(pathname.startsWith('/home/agenda')) {
if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
return true;
if((SessionStore.user.OwnerCalendars.length != 0 || SessionStore.user.SharedCalendars.length != 0)) {
return true
}
if(['/pin','/login', '/inactivity' , '', '/'].includes(window.location.pathname)) {
this.FirstEnterService.enter()
setTimeout(() => {
// this.modalController.create({
// component: InformationPage,
// componentProps: {
// },
// cssClass: 'discart-expedient-modal',
// backdropDismiss: false
// });
// this.alertController.create({
// cssClass: 'my-custom-class',
// header: 'utilizador não tem calendário',
// buttons: [{
// text: 'Ok',
// handler: () => {
// }
// }]
// }).then( async (alertPopup) => {
// await alertPopup.present();
// })
}, 1000)
}
return false;
} else {
this.router.navigate(['/login']);
return false;
@@ -59,6 +98,38 @@ export class AuthGuard implements CanActivate {
}
else if(pathname.startsWith('/home/chat')) {
if(this.p.userPermission(this.p.permissionList.Chat.access)) {
if(!SessionStore.user.ChatData?.data) {
if(['/pin','/login', '/inactivity' , '', '/'].includes(window.location.pathname)) {
this.FirstEnterService.enter()
setTimeout(() => {
// this.modalController.create({
// component: InformationPage,
// componentProps: {
// },
// cssClass: 'discart-expedient-modal',
// backdropDismiss: false
// });
// this.alertController.create({
// cssClass: 'my-custom-class',
// header: 'Serviço temporariamente indisponível',
// buttons: [{
// text: 'Ok',
// handler: () => {
// }
// }]
// }).then( async (alertPopup) => {
// await alertPopup.present();
// })
}, 1000)
}
return false
}
return true;
} else {
this.router.navigate(['/login']);
+1 -2
View File
@@ -7,7 +7,6 @@ import { ChatPageModule } from '../pages/chat/chat.module';
import { EventsPageModule } from '../pages/events/events.module';
import { GabineteDigitalPageModule } from '../pages/gabinete-digital/gabinete-digital.module';
import { PublicationsPageModule } from '../pages/publications/publications.module';
import { UserDataResolver } from '../resolvers/userData.resolver';
import { HomePage } from './home.page';
const routes: Routes = [
@@ -15,7 +14,6 @@ const routes: Routes = [
path: 'home',
component: HomePage,
resolve: {
userData: UserDataResolver,
},
children: [
{
@@ -368,6 +366,7 @@ const routes: Routes = [
},
],
canActivate: [AuthGuard]
},
{
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { InformationPage } from './information.page';
const routes: Routes = [
{
path: '',
component: InformationPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class InformationPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { InformationPageRoutingModule } from './information-routing.module';
import { InformationPage } from './information.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
InformationPageRoutingModule
],
declarations: [InformationPage]
})
export class InformationPageModule {}
@@ -0,0 +1,20 @@
<ion-header class="ion-no-border">
</ion-header>
<ion-content>
<div class="header-content width-100">
<div class="header-title d-flex width-100">
<h3>{{ message }}</h3>
</div>
</div>
<div class="header-body width-100">
<p>{{ note }}</p>
</div>
</ion-content>
<ion-footer>
<div class="buttons width-100">
<button class="btn-ok-medium" shape="round" (click)="close()">Não</button>
<button class="btn-delete-medium" shape="round" (click)="save()">Sim</button>
</div>
</ion-footer>
@@ -0,0 +1,27 @@
ion-content{
--padding-top:15px;
--padding-start: 15px;
--padding-end: 15px;
}
.header-content{
overflow: hidden;
margin: 0 auto;
align-items: center;
justify-content: center;
}
.header-title{
font-family: Roboto;
font-size: 20px;
color:#000;
margin: 0 5px 0 5px;
}
.header-body{
margin: 0 5px 0 5px;
}
.buttons{
display: flex;
justify-content: space-between;
padding: 15px 0 15px 0;
}
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { InformationPage } from './information.page';
describe('InformationPage', () => {
let component: InformationPage;
let fixture: ComponentFixture<InformationPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ InformationPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(InformationPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,32 @@
import { Component, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { NavParams } from '@ionic/angular';
@Component({
selector: 'app-information',
templateUrl: './information.page.html',
styleUrls: ['./information.page.scss'],
})
export class InformationPage implements OnInit {
message = ""
note = ""
constructor(
private modalController: ModalController,
private navParams: NavParams,
) {
this.message = this.navParams.get('message');
this.note = this.navParams.get('note');
}
ngOnInit() {}
close() {
this.modalController.dismiss('No');
}
save() {
this.modalController.dismiss('Yes');
}
}
+18
View File
@@ -0,0 +1,18 @@
const object = [
'agenda',
'event-list',
'accao',
'publicacao',
//
'expediente',
'gabinete-digital',
'parecer',
'deferimento',
'despachos-pr',
'diplomas-assinar',
'diplomas',
'expedientes-pr',
'despachos',
] as const;
export type IdObject = typeof object[number];
+1 -1
View File
@@ -115,7 +115,7 @@ export class ChatPage implements OnInit {
public ChatSystemService: ChatSystemService,
) {
this.loggedUserChat = SessionStore.user.ChatData['data'];
this.loggedUserChat = SessionStore.user.ChatData?.data;
this.headers = new HttpHeaders();
window.onresize = (event) => {
if (window.innerWidth > 701) {
+4 -2
View File
@@ -243,8 +243,10 @@ export class EventsPage implements OnInit {
this.storage.get('process').then((process: any[] = []) => {
//
const ExpedienteTask = process.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
if(Array.isArray(process)) {
const ExpedienteTask = process.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
}
})
this.showLoader = false;
@@ -1,7 +1,7 @@
<ion-header class="ion-no-border">
<app-header></app-header>
</ion-header>
<!-- {{ NotificationsService.active }} -->
<ion-content class="height-100 container-wrapper">
<ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
<ion-refresher-content>
@@ -12,7 +12,7 @@
<!-- Aside left -->
<div class="aside-wrapper d-flex flex-column width-md-40 flex-grow-1">
<ion-progress-bar type="indeterminate" *ngIf="getloadKeys.length >= 1"></ion-progress-bar>
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<div class="title-container">
<div class="title">
<ion-label>Gabinete Digital</ion-label>
@@ -41,7 +41,7 @@ import { DataService } from 'src/app/services/data.service';
import { Storage } from '@ionic/storage';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { SessionStore } from 'src/app/store/session.service';
import { NotificationsService } from 'src/app/services/notifications.service'
@Component({
selector: 'app-gabinete-digital',
templateUrl: './gabinete-digital.page.html',
@@ -140,7 +140,8 @@ export class GabineteDigitalPage implements OnInit {
private DeplomasServiceService: DeplomasServiceService,
private AproveEventService: AproveEventService,
private ParecerService: ParecerService,
private DespachoPRService: DespachoPRService
private DespachoPRService: DespachoPRService,
public NotificationsService: NotificationsService
) {
@@ -179,13 +180,16 @@ export class GabineteDigitalPage implements OnInit {
const pathname = window.location.pathname
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == pathname) {
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.checkRoutes();
// console.log('FIRST CALL')
this.LoadCounts();
if(this.NotificationsService.active === false) {
this.checkRoutes();
this.LoadCounts();
} else {
this.checkRoutes();
this.LoadCounts();
}
}
})
}
@@ -204,6 +208,73 @@ export class GabineteDigitalPage implements OnInit {
this.backgroundservice.registerBackService('Online', () => {
this.loadAllProcesses();
});
this.NotificationsService.registerCallback(
'despachos',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'despachos-pr',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'expediente',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'gabinete-digital',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'parecer',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'deferimento',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'diplomas-assinar',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'diplomas',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
this.NotificationsService.registerCallback(
'expedientes-pr',
() => {
this.LoadCounts();
console.log('refresh with notification')
}
)
}
async loadAllProcesses() {
@@ -382,7 +453,7 @@ export class GabineteDigitalPage implements OnInit {
else if (activityName == 'Diploma Assinado') {
this.router.navigate(['/home/gabinete-digital/diplomas-assinar', serialNumber, 'gabinete-digital']);
} else {
alert('bug!')
console.log('no route!')
}
}
else if (workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') {
-13
View File
@@ -1,13 +0,0 @@
import { Injectable } from '@angular/core';
import { AuthService } from '../services/auth.service';
@Injectable({
providedIn: 'root'
})
export class UserDataResolver{
constructor(private authService: AuthService){}
resolve(){
return this.authService.getUserData();
}
}
+1 -13
View File
@@ -95,14 +95,11 @@ export class AuthService {
} else {
session.Profile = 'Unknown'
}
session.Password = user.password
session.BasicAuthKey = user.BasicAuthKey
SessionStore.reset(session)
this.storageService.store(AuthConnstants.USER, response);
return true;
}
@@ -220,15 +217,6 @@ export class AuthService {
}
// Get user data from RocketChat | global object
getUserData() {
this.storageService.get(AuthConnstants.AUTH).then(res=>{
this.userData$.next(res);
}).catch((error) => {
console.error('storage getuserdata',error)
});
}
logoutChat() {
}
+7 -2
View File
@@ -389,18 +389,23 @@ export class ChatService {
} catch (error) {
this.resetTimer();
await this.refreshtoken();
setTimeout(async() =>{
await this.refreshtoken();
}, 8000)
}
} else if(!SessionStore.user.ChatData) {
// do nothing
} else if (!this.headers) {
this.setheader()
this.refreshtoken()
} else {
setTimeout(async ()=>{
await this.refreshtoken();
}, 4000)
}, 8000)
}
}
+14 -11
View File
@@ -15,6 +15,7 @@ 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 { IdObject } from '../models/notifications';
/* import { Events } from 'ionic-angular' */
@Injectable({
@@ -32,6 +33,8 @@ export class NotificationsService {
id: string
}[] = []
active = false
constructor(
private http: HttpClient,
private storageService: StorageService,
@@ -48,18 +51,17 @@ export class NotificationsService {
/* private eventTriger: Events, */
/* private fcm: FCM */) {
this.storageService.get("Notifications").then((value) => {
this.storageService.get("Notifications").then((value) => {
}).catch((error)=>{
console.error('storage getnotification',error)
}).catch((error)=>{
console.error('storage getnotification',error)
}).catch(() => {
this.storageService.store("Notifications", [])
})
}
registerCallback(type: string, funx: Function, object: any = {}) {
registerCallback(type: IdObject, funx: Function, object: any = {}) {
const id = uuidv4()
this.callbacks.push({ type, funx, id })
@@ -105,7 +107,8 @@ export class NotificationsService {
const geturl = environment.apiURL + 'notifications/token';
PushNotifications.addListener('registration',
(token: Token) => {
this.active = false
this.storageService.store(username, token.value);
this.storageService.get(username).then(value => {
@@ -138,11 +141,11 @@ export class NotificationsService {
}
registrationError() {
PushNotifications.addListener('registrationError',
(error: any) => {
}
);
PushNotifications.addListener('registrationError',
(error: any) => {
this.active = false
}
);
}
onReciveForeground() {