This commit is contained in:
Peter Maquiran
2021-09-30 15:56:04 +01:00
parent 37a233caec
commit 7364277d95
21 changed files with 36 additions and 23 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PermissionService } from './worker/permission.service';
describe('PermissionService', () => {
let service: PermissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PermissionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+3 -1
View File
@@ -1,7 +1,9 @@
import { Injectable } from '@angular/core';
import { PermissionService } from 'src/app/OtherService/permission.service';
import { AttachmentsService } from '../attachments.service';
import { EventsService } from '../events.service';
import { PermissionService } from '../worker/permission.service';
@Injectable({
providedIn: 'root'
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { DocumentCounterService } from './document-counter.service';
describe('DocumentCounterService', () => {
let service: DocumentCounterService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DocumentCounterService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import { DespachoStore } from 'src/app/store/despacho-store.service';
import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { PendentesStore } from 'src/app/store/pendestes-store.service';
import { PedidosStore } from 'src/app/store/pedidos-store.service';
import { DespachosprStore } from 'src/app/store/despachospr-store.service';
import { DeplomasStore } from 'src/app/store/deplomas.service';
@Injectable({
providedIn: 'root'
})
export class DocumentCounterService {
expedienteGbStore = ExpedienteGdStore;
pendentesStore = PendentesStore;
despachoStore = DespachoStore;
eventoAprovacaoStore = EventoAprovacaoStore;
pedidosStore = PedidosStore;
// expedientePrStore = ExpedienteprStore;
despachoPrStore = DespachosprStore;
deplomasStore = DeplomasStore
constructor() { }
// falta a contagem dos deplomas
get mdTotalDocument(): number {
return this.despachoStore.count + /** this.expedientePrStore.count + */ this.pedidosStore.countdeferimento
+ this.pedidosStore.countparecer + this.expedienteGbStore.count + this.despachoPrStore.count + this.pendentesStore.count
+ this.eventoAprovacaoStore.count + this.deplomasStore.diplomasListCount + this.deplomasStore.countDiplomasAssinadoListCount + this.deplomasStore.deplomasReviewCount
}
get prTotalDocument(): number {
return this.despachoStore.count + /** this.expedientePrStore.count + */ this.pedidosStore.countdeferimento
+ this.pedidosStore.countparecer + this.expedienteGbStore.count + this.despachoPrStore.count + this.pendentesStore.count
+ this.eventoAprovacaoStore.count + this.deplomasStore.diplomasListCount + this.deplomasStore.countDiplomasAssinadoListCount + this.deplomasStore.deplomasReviewCount
}
}
@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';
import { SessionStore } from '../../store/session.service';
@Injectable({
providedIn: 'root'
})
export class PermissionService {
SessionStore = SessionStore
constructor() { }
userRole(args) {
if(!Array.isArray(args)) {
args = [args]
}
return args.includes(this.SessionStore.user.Profile)
}
role(args: any) {
let UserRoleIsValid = this.userRole(args)
return {
permissionAnyOf(role) {
if(!Array.isArray(role)) {
role = [role]
}
if(!UserRoleIsValid) {return false }
return true
}
}
}
}