mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
save
This commit is contained in:
@@ -18,6 +18,7 @@ import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { RoomService } from './chat/room.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { InitialsService } from './functions/initials.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -44,7 +45,8 @@ export class AuthService {
|
||||
private NfService:NfService,
|
||||
private processesService: ProcessesService,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private storage: Storage ) {
|
||||
private storage: Storage,
|
||||
private initialsService: InitialsService ) {
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
|
||||
@@ -74,6 +76,8 @@ export class AuthService {
|
||||
|
||||
try {
|
||||
response = await this.http.post<LoginUserRespose>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
|
||||
console.log(response);
|
||||
|
||||
if(saveSession) {
|
||||
this.SetSession(response, user)
|
||||
}
|
||||
@@ -94,6 +98,9 @@ export class AuthService {
|
||||
} else if(session.RoleID == 100000011) {
|
||||
session.Profile = 'MDGPR'
|
||||
}
|
||||
else{
|
||||
session.Profile = this.initialsService.getInitials(session.FullName);
|
||||
}
|
||||
|
||||
session.Password = user.password
|
||||
session.RochetChatUser = user.username.split('@')[0]
|
||||
@@ -149,7 +156,7 @@ export class AuthService {
|
||||
|
||||
this.WsChatService.connect();
|
||||
this.WsChatService.login().then((message: any) => {
|
||||
|
||||
|
||||
SessionStore.user.RochetChatUserId = message.result.id
|
||||
SessionStore.save()
|
||||
this.WsChatService.setStatus('online')
|
||||
|
||||
@@ -439,7 +439,7 @@ export class RoomService {
|
||||
},
|
||||
async (response) => {
|
||||
|
||||
if (response.error.error.startsWith('No message found with the id of')) {
|
||||
if (response?.error?.error.startsWith('No message found with the id of')) {
|
||||
|
||||
this.deleteMessage(msgId)
|
||||
message.delateRequest = true
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { InitialsService } from './initials.service';
|
||||
|
||||
describe('InitialsService', () => {
|
||||
let service: InitialsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(InitialsService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class InitialsService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
getInitials(name:string){
|
||||
let names = name.split(' '),
|
||||
initials = names[0].substring(0, 1).toUpperCase();
|
||||
if (names.length > 1) {
|
||||
initials += names[names.length - 1].substring(0, 1).toUpperCase();
|
||||
}
|
||||
return initials;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PermissionService } from './worker/permission.service';
|
||||
import { PermissionService } from './permission.service';
|
||||
|
||||
describe('PermissionService', () => {
|
||||
let service: PermissionService;
|
||||
|
||||
+19
-5
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SessionStore } from '../../store/session.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -15,12 +15,26 @@ export class PermissionService {
|
||||
if(!Array.isArray(args)) {
|
||||
args = [args]
|
||||
}
|
||||
|
||||
return args.includes(this.SessionStore.user.Profile)
|
||||
|
||||
return args.includes(this.SessionStore.user.Profile)
|
||||
}
|
||||
|
||||
userPermission(args) {
|
||||
|
||||
if(!Array.isArray(args)) {
|
||||
args = [args]
|
||||
}
|
||||
for(let permission of this.SessionStore.user.UserPermissions){
|
||||
if (args.includes(permission)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
role(args: any) {
|
||||
|
||||
|
||||
let UserRoleIsValid = this.userRole(args)
|
||||
|
||||
return {
|
||||
@@ -39,4 +53,4 @@ export class PermissionService {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AttachmentsService } from '../attachments.service';
|
||||
import { EventsService } from '../events.service';
|
||||
import { PermissionService } from '../worker/permission.service';
|
||||
import { PermissionService } from '../permission.service';
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class EventService {
|
||||
|
||||
|
||||
create({body, calendar}) {
|
||||
|
||||
|
||||
|
||||
if(this.p.userRole(['PR'])) {
|
||||
return this.eventService.postEventPr(body, calendar)
|
||||
|
||||
Reference in New Issue
Block a user