remove chat data and ownerCalendar

This commit is contained in:
Peter Maquiran
2024-11-06 08:24:37 +01:00
parent 52d333ad16
commit ecb2f6c08e
39 changed files with 1845 additions and 264 deletions
+6
View File
@@ -0,0 +1,6 @@
export class Preference {
LoginPreference = null
UrlBeforeInactivity= ''
Inactivity= true
PIN = ''
}
+58
View File
@@ -0,0 +1,58 @@
import { z } from "zod";
import { SHA1 } from 'crypto-js'
import { localstoreService } from "src/app/store/localstore.service";
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
});
// Define the schema for the main response object
const UserDataSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
});
export type IUser = z.infer<typeof UserDataSchema>
export class UserEntity {
wxUserId: number
wxFullName: string
wxeMail: string
role: string
roleId: number
userPhoto: string
adUserSID: string
authorization: string
refreshToken: string
permissions: number[]
Profile: 'PR' | 'MDGPR'| 'Consultant'| 'SGGPR'| 'Unknown'
constructor(input: IUser) {
Object.assign(this, input)
if (input) {
if (input?.user?.roleId == 100000014) {
this.Profile = 'PR'
} else if (input.user.roleId == 100000011) {
this.Profile = 'MDGPR'
} else if (input.user.roleId == 99999872) {
this.Profile = 'Consultant'
} else if (input.user.roleId == 99999886) {
this.Profile = 'SGGPR'
} else {
this.Profile = 'Unknown'
}
}
}
}
@@ -0,0 +1,16 @@
import { HttpErrorResponse } from "@angular/common/http";
import { Result } from "neverthrow";
import { HttpResult } from "src/app/infra/http/type";
import { UserLoginInput, UserLoginOutput } from "../use-case/user-login-use-case.service";
import { z } from "zod";
const UserRepositoryLoginParams = z.object({
Auth: z.string(),
ChannelId: z.number()
})
export type IUserRepositoryLoginParams = z.infer<typeof UserRepositoryLoginParams>
export abstract class IUserRemoteRepository {
abstract login(input: IUserRepositoryLoginParams): Promise<Result<HttpResult<UserLoginOutput>, HttpErrorResponse>>
}
@@ -0,0 +1,100 @@
import { Injectable } from '@angular/core';
import { z } from 'zod';
import { IUserRemoteRepository } from '../repository/user-remote-repository';
import { XTracerAsync, TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
import { zodSafeValidation } from 'src/app/utils/zodValidation';
import { AlertController, Platform } from '@ionic/angular';
import { AESEncrypt } from 'src/app/services/aesencrypt.service';
const UserLoginInputSchema = z.object({
username: z.string(),
password: z.string(),
domainName: z.string(),
BasicAuthKey: z.string()
})
export type UserLoginInput = z.infer<typeof UserLoginInputSchema>
// Define the schema for the user object
const UserSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
role: z.string(),
roleId: z.number(),
userPhoto: z.string(),
adUserSID: z.string(),
});
// Define the schema for the main response object
const UserLoginOutputSchema = z.object({
user: UserSchema,
authorization: z.string(),
refreshToken: z.string(),
permissions: z.array(z.number()),
});
// Define the main schema for the response
const LoginUserResponseSchema = z.object({
success: z.boolean(),
message: z.nullable(z.string()), // Message can be null
data: UserLoginOutputSchema,
});
export type UserLoginOutput = z.infer<typeof LoginUserResponseSchema>
@Injectable({
providedIn: 'root'
})
export class UserLoginUseCaseService {
constructor(
private userRemoteRepository: IUserRemoteRepository,
private aesencrypt: AESEncrypt,
private platform: Platform
) { }
@XTracerAsync({name:'UserLoginUseCaseService', module:'user', bugPrint: true})
async execute(input: UserLoginInput, tracing?: TracingType) {
const validation = zodSafeValidation<UserLoginInput>(UserLoginInputSchema, input)
if(validation.isOk()) {
let channelId;
if ( this.platform.is('desktop') || this.platform.is("mobileweb")){
channelId = 2
} else {
channelId = 1
}
const auth = btoa(input.username + ':' + this.aesencrypt.encrypt(input.password, input.username))
const result = await this.userRemoteRepository.login({
Auth: auth,
ChannelId: channelId
})
if(result.isOk()) {
if(result.value) {
}
}
return result.map(e => e.data.data)
} else {
tracing.setAttribute('parameter error','true')
// Logger.error('failed to send message doe to invalid attachment', {
// zodErrorList: validation.error.errors,
// data: data
// })
return validation
}
}
}
+7 -6
View File
@@ -68,12 +68,13 @@ export class AuthGuard implements CanActivate {
return false
}
} else if (pathname.startsWith('/home/events')) {
if(SessionStore?.user?.OwnerCalendars.length >= 1 || this.p.userPermission([this.p.permissionList.Gabinete.access])) {
return true
} else {
this.router.navigate(['/login']);
return false
}
return true
// if(SessionStore?.user?.OwnerCalendars.length >= 1 || this.p.userPermission([this.p.permissionList.Gabinete.access])) {
// return true
// } else {
// this.router.navigate(['/login']);
// return false
// }
} else if (pathname == '/') {
this.router.navigate(['/login']);
return false
+4 -2
View File
@@ -29,7 +29,8 @@ export class InactivityGuard implements CanActivate {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) {
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0){
//if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0){
if(this.p.userPermission(this.p.permissionList.Agenda.access)){
this.router.navigate(['/home/agenda']);
}
else{
@@ -79,7 +80,8 @@ export class InactivityGuard implements CanActivate {
if((SessionStore?.user?.Inactivity)) {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0) {
//if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0) {
if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
this.router.navigate(['/home/agenda']);
}
else{
+4 -2
View File
@@ -6,8 +6,10 @@
<app-header ></app-header>
</ion-header>
<ion-tab-bar id="bottom-navigation" class="dnone" *ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access]) && SessionStore.user.OwnerCalendars.length != 0) || p.userPermission([permissionList.Gabinete.access])" class="bottoms" slot="bottom">
<ion-tab-button *ngIf="SessionStore.user.OwnerCalendars.length >= 1 || p.userPermission([permissionList.Gabinete.access])" (click)="goto('/home/events')" tab="events" [class.active]="ActiveTabService.pages.home">
<!-- <ion-tab-bar id="bottom-navigation" class="dnone" *ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access]) && SessionStore.user.OwnerCalendars.length != 0) || p.userPermission([permissionList.Gabinete.access])" class="bottoms" slot="bottom">
<ion-tab-button *ngIf="SessionStore.user.OwnerCalendars.length >= 1 || p.userPermission([permissionList.Gabinete.access])" (click)="goto('/home/events')" tab="events" [class.active]="ActiveTabService.pages.home"> -->
<ion-tab-bar id="bottom-navigation" class="dnone" *ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access])) || p.userPermission([permissionList.Gabinete.access])" class="bottoms" slot="bottom">
<ion-tab-button *ngIf="p.userPermission([permissionList.Gabinete.access])" (click)="goto('/home/events')" tab="events" [class.active]="ActiveTabService.pages.home">
<!-- <ion-icon name="home"></ion-icon> -->
<ion-icon *ngIf="!ActiveTabService.pages.home" class="font-30-em" src="assets/images/icons-nav-home.svg"></ion-icon>
<ion-icon *ngIf="ActiveTabService.pages.home" class="font-30-em" src="assets/images/nav-hover/icons-nav-home-active.svg"></ion-icon>
+3 -3
View File
@@ -229,9 +229,9 @@ export class HomePage implements OnInit {
throw (SessionStore.user.FullName + 'cant have MD and PR authorization at same time');
}
if (this.p.userPermission([this.p.permissionList.Chat.access]) && !SessionStore.user?.ChatData?.data) {
throw ('Chat temporarily unavailable for ' + SessionStore.user.FullName + '. No ChatData');
}
// if (this.p.userPermission([this.p.permissionList.Chat.access]) && !SessionStore.user?.ChatData?.data) {
// throw ('Chat temporarily unavailable for ' + SessionStore.user.FullName + '. No ChatData');
// }
// if (this.p.userPermission([this.p.permissionList.Agenda.access]) && !this.eventService.hasAnyCalendar) {
// // throw ('User ' + SessionStore.user.FullName + 'has No calendar');
+14 -14
View File
@@ -78,7 +78,7 @@ export class ChatTokenInterceptor implements HttpInterceptor {
authToken: token['data'].authToken
}
}
SessionStore.user.ChatData = data
//SessionStore.user.ChatData = data
SessionStore.save()
/* this.setheader() */
@@ -104,8 +104,8 @@ export class ChatTokenInterceptor implements HttpInterceptor {
try {
headers = headers.set('X-User-Id', SessionStore?.user?.ChatData?.data?.userId);
headers = headers.set('X-Auth-Token', SessionStore?.user?.ChatData?.data.authToken);
//headers = headers.set('X-User-Id', SessionStore?.user?.ChatData?.data?.userId);
//headers = headers.set('X-Auth-Token', SessionStore?.user?.ChatData?.data.authToken);
return request.clone({
setHeaders: {
@@ -151,19 +151,19 @@ export class ChatTokenInterceptor implements HttpInterceptor {
setheader() {
try {
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) && SessionStore.user.ChatData) {
// this.headers = new HttpHeaders();;
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
//
this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
this.options = {
headers: this.headers,
};
// if (this.p.userPermission(this.p.permissionList.Chat.access)) {
// //
// //this.headers = this.headers.set('X-User-Id', SessionStore.user.ChatData.data.userId);
// //this.headers = this.headers.set('X-Auth-Token', SessionStore.user.ChatData.data.authToken);
// this.options = {
// headers: this.headers,
// };
}
}
// }
// }
} catch (error) {
}
@@ -6,13 +6,16 @@ export class AgendaPermission{
constructor() {
if(SessionStore.exist) {
for (let calendar of SessionStore?.user?.OwnerCalendars) {
this.hasOwnCalendar = true
}
// for (let calendar of SessionStore?.user?.OwnerCalendars) {
// this.hasOwnCalendar = true
// }
for (let sharedCalendar of SessionStore?.user?.SharedCalendars) {
this.hasSharedCalendar = true
}
// for (let sharedCalendar of SessionStore?.user?.SharedCalendars) {
// this.hasSharedCalendar = true
// }
this.hasOwnCalendar = true
this.hasSharedCalendar = true
}
}
get access () {
-51
View File
@@ -10,31 +10,10 @@ export class LoginUserRespose {
BasicAuthKey: string;
UserId: number;
Authorization: string;
ChatData: {
status: string,
data: {
userId: string,
authToken: string
}
}
Email: string
FullName: string
OwnerCalendars: {
CalendarId: string
CalendarName: "Oficial" | "Pessoal";
CalendarRoleId: string;
Id: number;
}[]
RoleDescription: string
RoleID: number
SharedCalendars: {
CalendarId: string
CalendarName: "Oficial" | "Pessoal";
CalendarRoleId: string;
Id: number;
OwnerUserId: string;
TypeShare: number;
}[]
UserName: string
Profile: any;
UserPermissions: any;
@@ -53,40 +32,10 @@ export class UserSession {
BasicAuthKey: string;
UserId: number;
Authorization: string;
ChatData: {
status: string,
data: {
userId: string,
authToken: string
}
}
Email: string
FullName: string
ManagerName: string
OwnerCalendars: {
CalendarId: string
CalendarName: "Oficial" | "Pessoal";
CalendarRoleId: string;
Id: number;
OwnerUserId: any
}[]
RoleDescription: string
RoleID: number
SharedCalendars: {
CalendarId: string
CalendarName: "Oficial" | "Pessoal";
/**
* @description User Role Id
*/
CalendarRoleId: string;
Id: number;
OwnerUserId: string;
TypeShare: number;
/**
* @description deprecated
*/
CalendarToken: string;
}[]
UserName: string
Password: string
RochetChatUserId: string
@@ -0,0 +1,135 @@
import { Injectable } from '@angular/core';
import { UserEntity } from 'src/app/core/user/entity/userEntity';
import { SHA1 } from 'crypto-js'
import { localstoreService } from 'src/app/store/localstore.service';
import { Preference } from 'src/app/core/user/entity/preference';
@Injectable({
providedIn: 'root'
})
export class SessionService {
user?:UserEntity
preference = new Preference()
forceToLoginWithForceToLogInWithPassword = false
private keyName: string;
constructor() {
if(this.exist) {
this.keyName = (SHA1("")).toString()
let restore: any = this.getDataFromLocalStorage()
if(restore?.user) {
this.user = new UserEntity(restore.user)
}
if(this.preference.LoginPreference == 'Pin') {
this.preference.Inactivity = false
}
}
}
getDataFromLocalStorage() {
return localstoreService.get(this.keyName, {}).user as UserEntity
}
get exist() {
let restore = localstoreService.get(this.keyName, {})
let user: UserEntity = restore.user
if(user) {
if(user.Profile) {
console.log('exist')
return true
}
}
console.log('exist not', restore)
return false
}
setLoginPreference(loginPreference: 'None' | 'Password' | 'Pin' | null) {
this.preference.LoginPreference = loginPreference
this.save()
}
setPin(pin: string) {
this.preference.PIN = SHA1(pin).toString()
this.save()
}
validatePin(pin: string) {
return this.preference.PIN == SHA1(pin).toString()
}
needToValidateUser() {
return this.preference.Inactivity
}
isUserActive() {
return this.preference.Inactivity
}
setInativity(value: boolean) {
this.preference.Inactivity = value
this.preference.UrlBeforeInactivity = ''
this.save()
}
setUrlBeforeInactivity(pathname: string) {
this.preference.UrlBeforeInactivity = pathname
this.save()
}
get hasPin() {
if(!this.preference.PIN) {
return false
}
return this.preference.PIN.length >= 2
}
reset(user) {
console.log('reset')
console.log('user', user)
this.user = user
this.setInativity(true)
this.save()
}
delete() {
console.log('edeletet')
localstoreService.delete(this.keyName)
this.preference = new Preference()
delete this.user
}
save() {
console.log('save')
localstoreService.set(this.keyName, {
user: this.user,
preference: this.preference
})
}
get getInitials() {
let names = this.user.wxFullName.split(' ') || ' ',
initials = names[0].substring(0, 1).toUpperCase();
if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
}
}
export const SessionStore = new SessionService()
@@ -0,0 +1,26 @@
import { Injectable } from '@angular/core';
import { IUserRemoteRepository } from 'src/app/core/user/repository/user-remote-repository';
import { UserLoginInput, UserLoginUseCaseService } from 'src/app/core/user/use-case/user-login-use-case.service';
import { SessionStore } from './service/session.service'
import { UserEntity } from 'src/app/core/user/entity/userEntity';
@Injectable({
providedIn: 'root'
})
export class UserService {
constructor(
private userLoginUseCaseService: UserLoginUseCaseService,
) { }
async login(input: UserLoginInput) {
const result = await this.userLoginUseCaseService.execute(input)
if(result.isOk()) {
SessionStore.reset(new UserEntity({...result.value, ...result.value.user}))
}
return result
}
}
+27
View File
@@ -0,0 +1,27 @@
import { NgModule } from '@angular/core';
import { HttpModule } from 'src/app/infra/http/http.module';
import { IUserRemoteRepository } from 'src/app/core/user/repository/user-remote-repository';
import { UserRemoteRepositoryService } from './data/datasource/user-remote-repository.service';
import { UserService } from './domain/user.service'
@NgModule({
imports: [HttpModule],
providers: [
{
provide: IUserRemoteRepository,
useClass: UserRemoteRepositoryService, // or MockDataService
},
],
declarations: [],
schemas: [],
entryComponents: [
]
})
export class UserModule {
constructor(
private UserService:UserService
) {}
}
+2 -1
View File
@@ -174,7 +174,8 @@ export class InactivityPage implements OnInit {
if (this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) {
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars?.length == 0) {
//if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars?.length == 0) {
if (this.p.userPermission(this.p.permissionList.Agenda.access)) {
this.router.navigate(['/home/agenda']);
}
else {
+9 -14
View File
@@ -146,22 +146,16 @@ export class LoginPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run();
if (attempt.ChatData) {
try {
await this.AgendaDataRepositoryService.getSharedCalendar()
try {
this.NotificationHolderService.clear()
await this.authService.loginToChatWs();
await this.AgendaDataRepositoryService.getSharedCalendar()
this.NotificationHolderService.clear()
await this.authService.loginToChatWs();
this.NotificationRepositoryService.init()
} catch(error) {
console.log("faild to clear chat")
}
this.NotificationRepositoryService.init()
} catch(error) {
console.log("faild to clear chat")
}
this.changeProfileService.runLogin();
@@ -236,7 +230,8 @@ export class LoginPage implements OnInit {
} else {
if (this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) {
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0) {
//if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0) {
if (this.p.userPermission(this.p.permissionList.Agenda.access)) {
this.router.navigate(['/home/agenda']);
}
else {
+2 -2
View File
@@ -176,7 +176,7 @@ export class AuthService {
loginToChatWs() {
setTimeout(() => {
if (SessionStore.user.ChatData?.data) {
//if (SessionStore.user.ChatData?.data) {
// this.RochetChatConnectorService.logout();
// this.RochetChatConnectorService.connect();
// this.RochetChatConnectorService.login().then((message: any) => {
@@ -204,7 +204,7 @@ export class AuthService {
// }
// })
}
//}
+2 -1
View File
@@ -18,7 +18,8 @@ export class FirstEnterService {
enter( ) {
if(this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)){
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user?.OwnerCalendars?.length == 0){
//if(this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore.user?.OwnerCalendars?.length == 0){
if(this.p.userPermission(this.p.permissionList.Agenda.access)) {
this.router.navigate(['/home/agenda']);
}
else{
@@ -4,7 +4,6 @@ import { HttpServiceService } from 'src/app/services/http/http-service.service';
import { Observable} from 'rxjs';
import { CreateEvent, EditEvent, EventDetailsDTO, EventsDTO, IuploadFileLK, refreshTokenDTO } from "./interface";
import { HttpClient, HttpEvent, HttpHeaders, HttpParams } from '@angular/common/http';
import { DetectCalendars, makeHeaderForCalendar } from '../../utils/utils';
import { z } from "zod";
import { ok, err } from 'neverthrow';
import { SessionStore } from 'src/app/store/session.service';
@@ -38,103 +37,103 @@ export class MiddlewareServiceService {
// ================================ Calendar =================================================
GetEvents(startDate: string, endDate: string, calendarId): Observable<EventsDTO[]> {
// GetEvents(startDate: string, endDate: string, calendarId): Observable<EventsDTO[]> {
let geturl = environment.apiURL + 'calendar/GetEvents';
geturl = geturl.replace('/V4/', '/V5/')
// let geturl = environment.apiURL + 'calendar/GetEvents';
// geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams();
// let params = new HttpParams();
params = params.set("StartDate", startDate);
params = params.set("EndDate", endDate);
// params = params.set("StartDate", startDate);
// params = params.set("EndDate", endDate);
const calendar = DetectCalendars(calendarId)
const header = makeHeaderForCalendar(calendar)
// const calendar = DetectCalendars(calendarId)
// const header = makeHeaderForCalendar(calendar)
let options = {
headers: header,
params: params
};
// let options = {
// headers: header,
// params: params
// };
// return this.HttpServiceService.get<Event[]>(`${geturl}`, options);
// // return this.HttpServiceService.get<Event[]>(`${geturl}`, options);
return {} as any
}
// return {} as any
// }
GetEventDetail(eventId: string, calendarId: string) {
let geturl = environment.apiURL + 'calendar/GetEvent';
let params = new HttpParams();
// GetEventDetail(eventId: string, calendarId: string) {
// let geturl = environment.apiURL + 'calendar/GetEvent';
// let params = new HttpParams();
params = params.set("EventId", eventId);
// params = params.set("EventId", eventId);
const calendar = DetectCalendars(calendarId)
const header = makeHeaderForCalendar(calendar)
// const calendar = DetectCalendars(calendarId)
// const header = makeHeaderForCalendar(calendar)
let options = {
headers: header,
params: params
}
return this.HttpServiceService.get<EventDetailsDTO>(`${geturl}`, options);
}
// let options = {
// headers: header,
// params: params
// }
// return this.HttpServiceService.get<EventDetailsDTO>(`${geturl}`, options);
// }
createEvent(event: CreateEvent, calendarName: string, CalendarId) {
const puturl = environment.apiURL + 'Calendar/PostEvent';
let params = new HttpParams();
// createEvent(event: CreateEvent, calendarName: string, CalendarId) {
// const puturl = environment.apiURL + 'Calendar/PostEvent';
// let params = new HttpParams();
if(!event.TimeZone) {
const now = new Date();
event.TimeZone = event.TimeZone = now.toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1];
}
// if(!event.TimeZone) {
// const now = new Date();
// event.TimeZone = event.TimeZone = now.toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1];
// }
if(!event.Organizer) {
event.Organizer = {
"Id": SessionStore.user.UserId,
"EmailAddress": SessionStore.user.Email,
"Name": SessionStore.user.UserName,
"IsRequired": true,
"UserType": "GD"
}
}
// if(!event.Organizer) {
// event.Organizer = {
// "Id": SessionStore.user.UserId,
// "EmailAddress": SessionStore.user.Email,
// "Name": SessionStore.user.UserName,
// "IsRequired": true,
// "UserType": "GD"
// }
// }
params = params.set("CalendarName", calendarName);
params = params.set("notifyUsers", true)
// params = params.set("CalendarName", calendarName);
// params = params.set("notifyUsers", true)
let options: any;
// let options: any;
const calendar = DetectCalendars(CalendarId)
const header = makeHeaderForCalendar(calendar)
// const calendar = DetectCalendars(CalendarId)
// const header = makeHeaderForCalendar(calendar)
options = {
headers: header,
params: params
};
// options = {
// headers: header,
// params: params
// };
return this.HttpServiceService.post<string>(`${puturl}`, event, options)
}
// return this.HttpServiceService.post<string>(`${puturl}`, event, options)
// }
editEvent(event: EditEvent, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, CalendarId? ) {
// editEvent(event: EditEvent, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, CalendarId? ) {
let options: any;
// let options: any;
const calendar = DetectCalendars(CalendarId)
const header = makeHeaderForCalendar(calendar)
let params = new HttpParams();
// const calendar = DetectCalendars(CalendarId)
// const header = makeHeaderForCalendar(calendar)
// let params = new HttpParams();
params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
params.set('CalendarId', event.CalendarId)
params.set('CalendarName', event.CalendarName)
// params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
// params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
// params.set('CalendarId', event.CalendarId)
// params.set('CalendarName', event.CalendarName)
options = {
headers: header,
params: params
};
// options = {
// headers: header,
// params: params
// };
const putUrl = environment.apiURL + 'calendar/PutEvent';
return this.HttpServiceService.put<string>(`${putUrl}`, event, options);
// const putUrl = environment.apiURL + 'calendar/PutEvent';
// return this.HttpServiceService.put<string>(`${putUrl}`, event, options);
}
// }
// ================================ Acções =================================================
+12 -12
View File
@@ -2,16 +2,16 @@ import { HttpHeaders } from "@angular/common/http";
import { calendarInterface } from "src/app/models/user.model";
import { SessionStore } from "src/app/store/session.service";
export function DetectCalendars(CalendarId) {
const calendars = SessionStore.user.OwnerCalendars.concat(SessionStore.user.SharedCalendars)
return calendars.find((e) => e.CalendarId == CalendarId)
}
// export function DetectCalendars(CalendarId) {
// const calendars = SessionStore.user.OwnerCalendars.concat(SessionStore.user.SharedCalendars)
// return calendars.find((e) => e.CalendarId == CalendarId)
// }
export function makeHeaderForCalendar(calendar: calendarInterface) {
let header = new HttpHeaders();;
header = header.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
header = header.set('CalendarId', calendar.CalendarId);
header = header.set('CalendarRoleId', calendar.CalendarRoleId);
header = header.set('CalendarName', calendar.CalendarName);
return header
}
// export function makeHeaderForCalendar(calendar: calendarInterface) {
// let header = new HttpHeaders();;
// header = header.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
// header = header.set('CalendarId', calendar.CalendarId);
// header = header.set('CalendarRoleId', calendar.CalendarRoleId);
// header = header.set('CalendarName', calendar.CalendarName);
// return header
// }
+8 -62
View File
@@ -15,31 +15,6 @@ class SessionService {
private keyName: string;
forceToLoginWithForceToLogInWithPassword = false
permission = {
Agenda: {
access: false
},
Gabinete: {
access: false,
pr_tasks: false,
md_tasks: false,
aprove_event: false
},
Actions: {
access : false,
create : false,
delete : false,
edit : false,
createPost : false,
deletePost : false,
editPost : false
},
Chat: {
access: false
}
}
hasPassLogin = false
constructor() {
@@ -153,44 +128,15 @@ class SessionService {
}
get getManagerInitials() {
let names = this._user.ManagerName.split(' ') || ' ',
initials = names[0].substring(0, 1).toUpperCase();
if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
// get getManagerInitials() {
// let names = this._user.ManagerName.split(' ') || ' ',
// initials = names[0].substring(0, 1).toUpperCase();
// if (names.length > 1) {
// initials += names[names.length - 1].substring(0, 1).toUpperCase();
// }
return initials;
}
clearPermission() {
this.permission = {
Agenda: {
access: false
},
Gabinete: {
access: false,
pr_tasks: false,
md_tasks: false,
aprove_event: false
},
Actions: {
access : false,
create : false,
delete : false,
edit : false,
createPost : false,
deletePost : false,
editPost : false
},
Chat: {
access: false
}
}
}
setPermission() {}
// return initials;
// }
}
@@ -37,9 +37,7 @@ export class EditGroupPage implements OnInit {
private httpErrorHandle: HttpErrorHandle,
private toastService: ToastService,
private chatServiceService: ChatServiceService,
) {
this.loggedUser = SessionStore.user.ChatData['data'];
}
) {}
ngOnInit() {
// this.chatService.refreshtoken();
@@ -31,7 +31,6 @@ export class NewGroupPage implements OnInit{
event: any
link = ''
documents: any;
loggedUserChat: any;
contact: {
Email: string
DisplayName: string
@@ -58,7 +57,6 @@ export class NewGroupPage implements OnInit{
private toastService: ToastService,
)
{
this.loggedUserChat = SessionStore.user.ChatData['data'];
this.isGroupCreated = false;
}
@@ -18,7 +18,6 @@ import { RoomViewModel } from '../../../store/model/room';
})
export class ContactsPage implements OnInit {
loading: boolean;
loggedUser: any;
users = [];
contacts:any;
@@ -44,7 +43,6 @@ export class ContactsPage implements OnInit {
private chatServiceService: ChatServiceService
)
{
this.loggedUser = SessionStore.user.ChatData['data'];
this.textSearch="";
this.dm=null;
@@ -32,7 +32,6 @@ export class NewGroupPage implements OnInit {
thedate: any;
groupName: string;
documents: any;
loggedUserChat: any;
constructor(
private pickerController: PickerController,
@@ -43,7 +42,7 @@ export class NewGroupPage implements OnInit {
public chatSystemService: ChatServiceService,
private toastService: ToastService,
) {
this.loggedUserChat = SessionStore.user.ChatData['data'];
this.isGroupCreated = false;
this.groupName = this.navParams.get('name');
this.documents = this.navParams.get('documents');
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { InactivityPage } from './inactivity.page';
const routes: Routes = [
{
path: '',
component: InactivityPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class InactivityPageRoutingModule {}
@@ -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 { InactivityPageRoutingModule } from './inactivity-routing.module';
import { InactivityPage } from './inactivity.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
InactivityPageRoutingModule
],
declarations: [InactivityPage]
})
export class InactivityPageModule {}
@@ -0,0 +1,62 @@
<ion-content class="text-white">
<div class="main-wrapper">
<div class="main-content d-flex flex-column width " >
<div class="div-top-header header-fix">
<div class="div-logo">
<img style="max-width: 90px;" *ngIf="ThemeService.currentTheme == 'default' " src='assets/images/logo-bg-removebg-preview.png' alt='logo'>
<img style="max-width: 80px;" *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png' alt='logo'>
</div>
</div>
<div class=" align-center justify-center d-flex flex-column width-100">
<div *ngIf="SessionStore.hasPin" class="title">Digite o PIN</div>
<div *ngIf="!SessionStore.hasPin" class="title">Digite o novo PIN</div>
<div class="terminal">
<div class="d-flex pt-25 align-center justify-center pin-4">
<div class="dot" [class.dot-active]="code.length >= 1"></div>
<div class="dot" [class.dot-active]="code.length >= 2"></div>
<div class="dot" [class.dot-active]="code.length >= 3"></div>
<div class="dot"[class.dot-active]="code.length >= 4"></div>
</div>
<div [class.hide]="code.length == 4" class="d-flex align-center justify-center">
<div class="circle" (click)="setCode('1')">1</div> <div class="circle" (click)="setCode('2')">2</div> <div class="circle" (click)="setCode('3')">3</div>
</div>
<div [class.hide]="code.length == 4" class="d-flex align-center justify-center">
<div class="circle" (click)="setCode('4')">4</div> <div class="circle" (click)="setCode('5')">5</div> <div class="circle" (click)="setCode('6')">6</div>
</div>
<div [class.hide]="code.length == 4" class="d-flex align-center justify-center">
<div class="circle" (click)="setCode('7')">7</div> <div class="circle" (click)="setCode('8')">8</div> <div class="circle" (click)="setCode('9')">9</div>
</div>
<div [class.hide]="code.length == 4" class="d-flex align-center justify-center">
<div class="circle" (click)="setCode('0')">0</div>
</div>
<div class="voltar cursor-pointer d-flex align-center justify-center pt-25 clear" (click)="enterWithPasswordButton()" >
Entrar com senha
</div>
<div id="clear" class="cy-clear voltar cursor-pointer d-flex align-center justify-center pt-25 clear" (click)="clearCode()">
Limpar
</div>
</div>
</div>
</div>
</div>
</ion-content>
@@ -0,0 +1,349 @@
@import '~src/function.scss';
:host, app-login {
ion-content {
background: linear-gradient(180deg, #42B9FE 0%, #0782C9 100%) !important;
}
}
ion-content{
background-color: white !important;
}
.main-wrapper{
background: var(--PinBackground);
display: flex;
width: 100vw;
height: 100vh;
overflow: auto;
display: flex;
align-items: center;
justify-content: center;
}
.wrapper{
/* width: 400px; */
height: auto;
padding: 0 !important;
/* margin: auto !important; */
overflow: auto;
width: 100%;
background: linear-gradient(180deg, #42B9FE 0%, #0782C9 100%) !important;
}
.logo{
width: 400px;
height: 400px;
background-position: center;
background-repeat: no-repeat;
}
.bg-1{
width: 250px;
height: 250px;
overflow: auto;
border-radius: 50%;
background: #4cb9f825;
margin: auto;
.bg-2{
width: 225px;
height: 225px;
overflow: auto;
border-radius: 50%;
background: #61bdf2b4;
margin: auto;
.bg-3{
width: 200px;
height: 200px;
overflow: auto;
border-radius: 50%;
background: #96d3f8be;
margin: auto;
.bg-4{
width: 175px;
height: 175px;
overflow: auto;
border-radius: 50%;
background: rgba(255, 255, 255, 0.918);
padding: 15px;
margin: auto;
.bg-4 img{
width: 100%;
}
}
}
}
}
.div-logo{
width: 200px !important;
margin: 0 auto;
padding-bottom: 15px;
}
.div-logo img{
width: 100%;
}
.wrapper ion-input{
font-size: rem(16);
}
.wrapper ion-button{
font-size: medium;
margin-top: 16px;
}
ion-item{
--background: transparent;
}
.form{
width: 300px;
margin: auto;
overflow: auto;
}
.form-label{
margin: 15px 0 5px 0;
font-size: rem(15);
}
.form-input{
--background: #fff;
--color:#000;
border-radius: 22.5px;
margin: 10px 0 10px 0;
}
.btn-login{
font-size: rem(16);
}
.div-top-header{
margin: 0 em(20px);
padding-top: em(15px);
border: 0!important;
z-index: 1000;
}
.div-logo {
background: transparent;
width: em(140px);
justify-content: center;
display: flex;
}
.div-logo img{
width: 100%;
margin: 0px auto;
}
.circle{
color: white;
width: 70px;
height: 70px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1rem(12);
background: var(--PinDots);;
border-radius: 56px;
margin-bottom: 15px;
user-select: none;
margin-right: 15px;
margin-left: 15px;
}
.title{
padding-top: 32px;
z-index: 1000;
height: unset !important;
position: relative;
top: -30px;
}
.terminal {
justify-content: center;
display: flex;
flex-direction: column;
background-image: var(--PinCircleBackground);
background-position: center;
background-repeat: no-repeat;
width: 100%;
z-index: 100;
background-size: 610px;
}
.clear{
color: var(--PinTextColor);
font-size: rem(16);
z-index: 1000;
}
.dot-active{
background: var(--PinDots);
}
.dot{
width: rem(25);
height: rem(25);
margin: 0 10px 0 0;
border: 3px solid var(--PinDots);
box-sizing: border-box;
border-radius: 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
-ms-border-radius: 50px;
-o-border-radius: 50px;
}
.main-content {
width: 100vw;
/* background-color: white; */
text-align: center;
align-items: center;
/* justify-content: center; */
background-size: 686px 674px;
background-position: center;
background-position-y: 110px;
background-repeat: no-repeat;
margin: auto;
/* justify-content: space-around; */
}
.voltar{
user-select: none;
}
.msg-bottom{
width: 100%;
color: #fff;
align-items: center;
justify-content: center;
.msg-bottom-p{
width: 220px;
position: absolute;
bottom: 0 !important;
text-align: center;
}
}
@media only screen and (max-height: 746px){
.msg-bottom-p {
padding-top: 20px;
position: unset !important;
}
}
.pin-4 {
z-index: 1000;
margin-bottom: 107px;
}
@media only screen and (min-height: 168px) {
.circle{
width: 60px;
height: 60px;
margin-bottom: 7px;
margin-right: 7px;
margin-left: 7px;
}
.terminal{
margin-top: -33px !important;
}
.pin-4 {
position: relative;
top: 49px;
}
.clear {
padding-top: 10px !important;
}
.div-top-header {
position: unset ;
top: unset ;
}
}
@media only screen and (min-height: 640px) {
.circle{
width: 60px;
height: 60px;
margin-bottom: 9px;
margin-right: 9px;
margin-left: 9px;
}
.terminal{
margin-top: -33px !important;
}
.pin-4 {
position: relative;
top: 49px;
}
}
@media only screen and (min-height: 667px) {
.circle{
width: 60px;
height: 60px;
margin-bottom: 7px;
margin-right: 7px;
margin-left: 7px;
}
.terminal{
margin-top: 0px !important;
}
.clear {
padding-top: 25px !important;
}
}
@media only screen and (min-height: 731px) {
.circle{
width: 63px;
height: 63px;
margin-bottom: 10px;
margin-right: 10px;
margin-left: 10px;
}
.terminal{
margin-top: -33px !important;
}
.pin-4 {
position: relative;
top: 35px;
}
}
@media only screen and (min-height: 832px) {
.circle{
width: 65px;
height: 65px;
margin-bottom: 15px;
margin-right: 15px;
margin-left: 15px;
}
.terminal{
margin-top: -33px !important;
}
.pin-4 {
position: relative;
top: unset !important;
margin-bottom: 107px;
}
}
.hide {
opacity: 0 !important;
}
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { InactivityPage } from './inactivity.page';
describe('InactivityPage', () => {
let component: InactivityPage;
let fixture: ComponentFixture<InactivityPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ InactivityPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(InactivityPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,216 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';
import { UserForm } from 'src/app/models/user.model';
import { ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment';
import { AlertController } from '@ionic/angular';
import { NotificationsService } from 'src/app/services/notifications.service';
import { SessionStore} from 'src/app/module/user/domain/service/session.service'
import { ThemeService } from 'src/app/services/theme.service';
import { PermissionService } from 'src/app/services/permission.service';
@Component({
selector: 'app-inactivity',
templateUrl: './inactivity.page.html',
styleUrls: ['./inactivity.page.scss'],
})
export class InactivityPage implements OnInit {
username: string = environment.defaultuser;
password: string = environment.defaultuserpwd;
userattempt: UserForm;
code = []
setPin = false
SessionStore = SessionStore
enterWithPassword = false
constructor(
private notificatinsservice: NotificationsService,
private router: Router,
private authService: AuthService,
private toastService: ToastService,
public alertController: AlertController,
public ThemeService: ThemeService,
public p: PermissionService,
) { }
loop = false
ngOnInit() { }
runloop() {
}
async presentAlert(message: string) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Mensagem do sistema',
message: message,
buttons: ['OK']
});
await alert.present();
}
//Function to validade the login inputs
validateUsername() {
return (
this.username.trim().length > 0
);
}
validatePassword() {
return (
this.password.trim().length > 0
);
}
async Login() {
if (this.validateUsername()) {
if (this.validatePassword()) {
this.userattempt = {
username: this.username,
password: this.password,
domainName: environment.domain,
BasicAuthKey: ""
}
let attempt = await this.authService.login(this.userattempt, { saveSession: false })
if (attempt) {
// if current attemp is equal to the current user
if (attempt.UserId == SessionStore.user.wxUserId) {
await this.authService.SetSession(attempt, this.userattempt);
if (this.p.userPermission(this.p.permissionList.Chat.access)) {
// this.authService.loginChat();
}
this.getToken();
SessionStore.setInativity(true)
this.goback()
} else {
SessionStore.delete()
window.localStorage.clear();
SessionStore.setInativity(true)
await this.authService.SetSession(attempt, this.userattempt);
}
this.enterWithPassword = false
}
}
else {
this.toastService._badRequest('Por favor, insira a sua palavra-passe');
}
}
else {
this.toastService._badRequest('Por favor, insira o seu nome de utilizador');
}
}
getToken() {
this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError();
// this.notificatinsservice.getAndpostToken(this.username);
}
setCode(code: string) {
if (this.code.length < 4) {
this.code.push(code)
}
if (this.code.length == 4) {
if (!SessionStore.hasPin) {
//
this.storePin()
this.pinLogin()
} else {
this.pinLogin()
}
}
}
clearCode() {
this.code = []
}
pinLogin() {
const code = this.code.join('')
if (SessionStore.validatePin(code)) {
SessionStore.setInativity(true)
this.goback()
setTimeout(() => {
this.clearCode()
}, 3000)
} else {
this.toastService._badRequest('Pin incorreto')
this.code = []
}
}
goback() {
const pathName = this.SessionStore.preference.UrlBeforeInactivity
if (pathName) {
this.router.navigate([pathName], { replaceUrl: true });
} else {
setTimeout(() => {
if (this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) {
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
//if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars?.length == 0) {
if (this.p.userPermission(this.p.permissionList.Agenda.access)) {
this.router.navigate(['/home/agenda']);
}
else {
this.router.navigate(['/home/events']);
}
}
//If user has access permission to both Chat and Action, goes to Chat by default.
else if ((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)) {
this.router.navigate(['/home/chat']);
}
else if (this.p.userPermission(this.p.permissionList.Actions.access)) {
this.router.navigate(['/home/publications']);
}
}, 100)
}
}
storePin() {
const code = this.code.join('');
SessionStore.setPin(code);
}
enterWithPasswordButton() {
this.enterWithPassword = true
SessionStore.forceToLoginWithForceToLogInWithPassword = true
this.router.navigate(['/']);
}
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginPage } from './login.page';
const routes: Routes = [
{
path: '',
component: LoginPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class LoginPageRoutingModule {}
+25
View File
@@ -0,0 +1,25 @@
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { LoginPageRoutingModule } from './login-routing.module';
import { LoginPage } from './login.page';
import { UserModule } from 'src/app/module/user/user.module';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
LoginPageRoutingModule,
// UserModule
],
declarations: [
LoginPage
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class LoginPageModule {}
+46
View File
@@ -0,0 +1,46 @@
<ion-content class="text-white">
<div class="main-wrapper">
<div class="wrapper">
<div class="bg-1 d-flex justify-center align-center">
<div class="bg-2 d-flex justify-center align-center">
<div class="bg-3 d-flex justify-center align-center">
<div class="bg-4 d-flex justify-center align-center">
<div class="div-logo">
<img *ngIf="ThemeService.currentTheme == 'default' " src='assets/images/donit.jpg' alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'gov' " src='assets/images/theme/gov/governoangola_A.png' alt='logo'>
<img *ngIf="ThemeService.currentTheme == 'doneIt' " src='assets/images/doneit.jpg' alt='logo'>
</div>
</div>
</div>
</div>
</div>
<!-- <h3 class="center text-white">doneIT</h3> -->
<h3 class="center text-white">Gabinete Digital</h3>
<form class="form">
<p class="form-label">Email</p>
<ion-item class="form-input">
<ion-input class="cy-email" type="text" [(ngModel)]="username" name="input-username"></ion-input>
</ion-item>
<p class="form-label">Palavra-passe</p>
<ion-item class="form-input">
<ion-input class="cy-password" (keyup.enter)="Login()" [type]="showPassword ? 'text' : 'password' " [(ngModel)]="password" name="input-password" ></ion-input>
<div (click)="togglePassword()">
<ion-icon slot="end" [name]="passwordIcon" ></ion-icon>
</div>
</ion-item>
<div class="d-flex pt-25">
<button class="btn-ok btn-login {{ Cy.p.login.b.enter }}" fill="clear" expand="block" shape="round" (click)="Login()">Iniciar a sessão</button>
</div>
</form>
<div class="msg-bottom d-flex">
<p class="msg-bottom-p"> </p>
</div>
</div>
</div>
<ion-icon style="width: 0px; height: 0px;" src='assets/images/theme/gov/icons-search.svg'></ion-icon>
<ion-icon style="width: 0px; height: 0px;" src='assets/images/icons-most-searched-words-open.svg'></ion-icon>
</ion-content>
+219
View File
@@ -0,0 +1,219 @@
@import '~src/function.scss';
:host, app-login {
ion-content {
background: linear-gradient(180deg, #c0ccd3 0%, #737b80 100%) !important;
}
}
ion-content{
background-color: white !important;
}
.main-wrapper{
background: var(--login-background);
display: flex;
width: 100vw;
height: 100vh;
overflow: auto;
position: absolute;
}
.wrapper{
width: rem(400);
height: auto;
padding: 0 !important;
margin: auto !important;
overflow: auto;
}
.logo{
width: rem(400);
height: rem(400);
background-image: url("/assets/background/auth.svg");
background-position: center;
background-repeat: no-repeat;
}
.bg-1{
width: rem(250);
height: rem(250);
overflow: auto;
border-radius: 50%;
margin: auto;
.bg-2{
width: rem(225);
height: rem(225);
overflow: auto;
border-radius: 50%;
margin: auto;
.bg-3{
width: rem(200);
height: rem(200);
overflow: auto;
border-radius: 50%;
margin: auto;
.bg-4{
width: rem(175);
height: rem(175);
overflow: hidden;
border-radius: 50%;
padding: 15px;
margin: auto;
background-color: #fff !important;
.bg-4 img{
width: 100%;
overflow: hidden;
}
}
}
}
}
.div-logo{
width: rem(200) !important;
margin: 0 auto;
padding: rem(15) !important;
}
.div-logo img{
width: 100%;
}
.wrapper ion-input{
font-size: rem(16);
}
.wrapper ion-button{
font-size: medium;
margin-top: 16px;
}
ion-item{
--background: transparent;
}
.form{
width: rem(300);
margin: auto;
overflow: auto;
}
.form-label{
margin: rem(15) 0 rem(5) 0;
font-size: rem(15);
color: var(--login-label-text);
}
.form-input{
--background: #fff;
--color:#000;
border-radius: 22.5px;
margin: rem(10) 0 rem(10) 0;
}
.btn-login{
font-size: rem(16);
background-color: #F2F2F2 !important;
color: #000;
}
.btn-login:hover{
background-color: var(--button-hover);
}
.div-top-header{
margin: 0 em(20);
padding-top: em(15);
border: 0!important;
}
.div-logo {
background: transparent;
width: rem(140);
justify-content: center;
display: flex;
}
.div-logo img{
width: 100%;
margin: 0px auto;
}
.circle{
color: white;
width: 70px;
height: 70px;
display: flex;
align-items: center;
justify-content: center;
font-size: rem(25);
background: #44b5ea;
border-radius: 56px;
margin-left: 30px;
margin-bottom: 15px;
user-select: none;
}
.title {
padding-top: 32px;
}
.terminal {
padding-top: 112px;
margin-left: -30px;
justify-content: center;
display: flex;
flex-direction: column;
align-items: center;
}
.clear{
color: #44b5ea;
font-size: rem(16);
}
.dot-active{
background: #44b5ea;
}
.dot{
width: rem(25);
height: rem(25);
margin: 0 10px 0 0;
border: 3px solid #44b5ea;
box-sizing: border-box;
border-radius: 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
-ms-border-radius: 50px;
-o-border-radius: 50px;
}
.main-content {
width: 100vw;
height: 100vh;
background-color: white;
text-align: center;
align-items: center;
justify-content: center;
background-image: url("/assets/background/auth.svg");
background-size: 686px 674px;
background-position: center;
background-position-y: 110px;
background-repeat: no-repeat;
margin: auto;
}
.voltar{
user-select: none;
}
.msg-bottom{
width: 100%;
color: #fff;
align-items: center;
justify-content: center;
.msg-bottom-p {
width: rem(220);
position: absolute;
bottom: 0 !important;
text-align: center;
}
}
@media only screen and (max-height: 746px) {
.msg-bottom-p {
padding-top: rem(20);
position: unset !important;
}
}
+24
View File
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { LoginPage } from './login.page';
describe('LoginPage', () => {
let component: LoginPage;
let fixture: ComponentFixture<LoginPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(LoginPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
+299
View File
@@ -0,0 +1,299 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';
import { UserForm } from 'src/app/models/user.model';
import { ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment';
import { AlertController } from '@ionic/angular';
import { NotificationsService } from 'src/app/services/notifications.service';
import { SessionStore} from 'src/app/module/user/domain/service/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 { PermissionService } from 'src/app/services/permission.service';
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
import { Platform } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { StorageService } from 'src/app/services/storage.service';
import { Cy } from 'cypress/enum'
import { AgendaDataRepositoryService } from 'src/app/module/agenda/data/repository/agenda-data-repository.service';
import { NotificationRepositoryService } from 'src/app/module/notification/data/notification-repository.service'
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
import { RoomLocalRepository } from 'src/app/module/chat/data/repository/room/room-local-repository.service'
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service'
import { UserService } from 'src/app/module/user/domain/user.service'
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
logstatus: boolean;
username: string = environment.defaultuser;
password: string = environment.defaultuserpwd;
userattempt: UserForm;
code = []
hasPin: boolean
loginPreference: string
sessionStore = SessionStore;
showPassword = false;
passwordIcon = "eye";
Cy = Cy
constructor(
private notificatinsservice: NotificationsService,
private router: Router,
private authService: AuthService,
private toastService: ToastService,
public alertController: AlertController,
private clearStoreService: ClearStoreService,
private changeProfileService: ChangeProfileService,
public ThemeService: ThemeService,
public p: PermissionService,
// public ChatSystemService: ChatSystemService,
private platform: Platform,
private storage: Storage,
private storageService: StorageService,
private NotificationHolderService: NotificationHolderService,
public AgendaDataRepositoryService: AgendaDataRepositoryService,
private NotificationRepositoryService: NotificationRepositoryService,
private ChatServiceService: ChatServiceService,
private RoomLocalRepository: RoomLocalRepository,
private MessageLocalDataSourceService: MessageLocalDataSourceService,
//private UserService: UserService
) { }
ngOnInit() { }
togglePassword() {
this.showPassword = !this.showPassword;
if (this.passwordIcon == "eye") {
this.passwordIcon = "eye-off";
} else {
this.passwordIcon = "eye";
}
}
//Function to validade the login inputs
validateUsername() {
return (
this.username.trim().length > 0
);
}
validatePassword() {
return (
this.password.trim().length > 0
);
}
getToken() {
try {
this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError();
// this.notificatinsservice.getAndpostToken(this.username);
} catch (e) {}
}
async Login() {
if (this.validateUsername()) {
if (this.validatePassword()) {
let newUserName = ""
if (this.usernameAsDomain(environment.domain, this.username.trim())) {
newUserName = this.username.trim();
} else {
newUserName = this.username.trim() + "@" + environment.domain;
}
// const loader = this.toastService.loading()
// SessionStore.delete();
// window.localStorage.clear();
// await this.UserService.login({
// username: newUserName.trim(),
// password: this.password.trim(),
// domainName: environment.domain,
// BasicAuthKey: ""
// })
// await this.RoomLocalRepository.clear()
// await this.MessageLocalDataSourceService.clear()
// await this.NotificationRepositoryService.clearData()
// this.ChatServiceService.start()
// await this.AgendaDataRepositoryService.clearSharedCalendar()
// this.clearStoreService.clear();
// // this.ChatSystemService.clearChat();
// this.NotificationHolderService.clear()
// this.storage.clear();
// // await this.authService.SetSession(attempt, this.userattempt);
// // this.NotificationRepositoryService.init()
// /* CPSession.save(data) */
// //this.changeProfileService.run();
// //this.storageService.remove("Notifications")
// // this.getToken();
if (!this.platform.is('desktop') && !this.platform.is('mobileweb')) {
if (this.sessionStore.hasPin) {
this.router.navigateByUrl('/home/events');
} else {
this.router.navigateByUrl('/pin', { replaceUrl: true });
}
} else {
this.router.navigate(['/home/events']);
}
//SessionStore.hasPassLogin = true;
//loader.remove()
// let attempt = await this.authService.login(this.userattempt, { saveSession: false })
/* const data = await this.authService.loginContenteProduction(this.userattempt, { saveSession: true }) */
// if (attempt) {
// if (attempt.UserId == SessionStore.user.wxUserId) {
// // await this.authService.SetSession(attempt, this.userattempt);
// // this.changeProfileService.run();
// // if (attempt.ChatData) {
// // try {
// // await this.AgendaDataRepositoryService.getSharedCalendar()
// // this.NotificationHolderService.clear()
// // await this.authService.loginToChatWs();
// // this.NotificationRepositoryService.init()
// // } catch(error) {
// // console.log("faild to clear chat")
// // }
// // }
// // this.changeProfileService.runLogin();
// // this.getToken();
// // SessionStore.setInativity(true);
// // SessionStore.hasPassLogin = true;
// // this.goback();
// // this.ChatServiceService.start()
// } else {
// // await this.RoomLocalRepository.clear()
// // await this.MessageLocalDataSourceService.clear()
// // await this.NotificationRepositoryService.clearData()
// // this.ChatServiceService.start()
// // await this.AgendaDataRepositoryService.clearSharedCalendar()
// // this.clearStoreService.clear();
// // // this.ChatSystemService.clearChat();
// // this.NotificationHolderService.clear()
// // SessionStore.delete();
// // window.localStorage.clear();
// // this.storage.clear();
// // await this.authService.SetSession(attempt, this.userattempt);
// // this.NotificationRepositoryService.init()
// // /* CPSession.save(data) */
// // this.changeProfileService.run();
// // this.storageService.remove("Notifications")
// // this.getToken();
// // if (!this.platform.is('desktop') && !this.platform.is('mobileweb')) {
// // if (this.sessionStore.hasPin) {
// // this.router.navigateByUrl('/home/events');
// // } else {
// // this.router.navigateByUrl('/pin', { replaceUrl: true });
// // }
// // } else {
// // this.router.navigate(['/home/events']);
// // }
// // SessionStore.hasPassLogin = true;
// }
// }
/*
else{
this.toastService._badRequest('Ocorreu um problema por favor valide o username e password');
} */
}
else {
this.toastService._badRequest('Por favor, insira a sua palavra-passe');
}
}
else {
this.toastService._badRequest('Por favor, insira o seu nome de utilizador');
}
}
goback() {
const pathName = SessionStore.preference.UrlBeforeInactivity
if (pathName) {
this.router.navigate([pathName]);
} else {
if (this.p.userPermission(this.p.permissionList.Agenda.access) || this.p.userPermission(this.p.permissionList.Gabinete.access)) {
//When user has got access to Agenda but does not have their own calendar, goes to Agenda
//if (this.p.userPermission(this.p.permissionList.Agenda.access) && SessionStore?.user?.OwnerCalendars.length == 0) {
if (this.p.userPermission(this.p.permissionList.Agenda.access)) {
this.router.navigate(['/home/agenda']);
}
else {
this.router.navigate(['/home/events']);
}
}
//If user has access permission to both Chat and Action, goes to Chat by default.
else if ((this.p.userPermission(this.p.permissionList.Chat.access) && this.p.userPermission(this.p.permissionList.Actions.access)) || this.p.userPermission(this.p.permissionList.Chat.access)) {
this.router.navigate(['/home/chat']);
}
else if (this.p.userPermission(this.p.permissionList.Actions.access)) {
this.router.navigate(['/home/publications']);
}
}
}
usernameAsDomain(substring, mainString) {
return mainString.includes(substring);
}
}
@@ -113,8 +113,11 @@
</div>
</div>
<!-- <div class="d-flex flex-1 pr-20 pl-50"
*ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access]) && loggeduser.OwnerCalendars.length != 0) || p.userPermission([permissionList.Gabinete.access])"> -->
<div class="d-flex flex-1 pr-20 pl-50"
*ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access]) && loggeduser.OwnerCalendars.length != 0) || p.userPermission([permissionList.Gabinete.access])">
*ngIf="p.userPermissionCount([permissionList.Agenda.access, permissionList.Gabinete.access, permissionList.Actions.access, permissionList.Chat.access]) >= 2 || (p.userPermission([permissionList.Agenda.access])) || p.userPermission([permissionList.Gabinete.access])">
<div
*ngIf="p.userPermission([permissionList.Agenda.access]) || p.userPermission([permissionList.Gabinete.access])"
+7 -7
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "eedb66a1c",
"SHA": "eedb66a1cf766552965265cc0b4d5c30ed7ed57b",
"branch": "developer",
"shortSHA": "52d333ad1",
"SHA": "52d333ad167e7e87cfe1bfafd9574101affc32af",
"branch": "feature/login-v2",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Tue Oct 29 16:00:19 2024 +0100'",
"lastCommitMessage": "add telemetry",
"lastCommitNumber": "6122",
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 1 commit.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/pages/events/attendees/attendees.page.ts\n\tmodified: src/app/shared/event/attendee-modal/attendee-modal.page.ts",
"lastCommitTime": "'Tue Oct 29 16:05:47 2024 +0100'",
"lastCommitMessage": "filter contact by name",
"lastCommitNumber": "6123",
"changeStatus": "On branch feature/login-v2\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tnew file: src/app/core/user/entity/preference.ts\n\tnew file: src/app/core/user/entity/userEntity.ts\n\tnew file: src/app/core/user/repository/user-remote-repository.ts\n\tnew file: src/app/core/user/use-case/user-login-use-case.service.ts\n\tmodified: src/app/guards/auth.guard.ts\n\tmodified: src/app/guards/inactivity.guard.ts\n\tmodified: src/app/home/home.page.html\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/interceptors/chatToken.interceptor.ts\n\tmodified: src/app/models/permission/agenda-permission.ts\n\tmodified: src/app/models/user.model.ts\n\tnew file: src/app/module/user/domain/service/session.service.ts\n\tnew file: src/app/module/user/domain/user.service.ts\n\tnew file: src/app/module/user/user.module.ts\n\tmodified: src/app/pages/inactivity/inactivity.page.ts\n\tmodified: src/app/pages/login/login.page.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/first-enter.service.ts\n\tmodified: src/app/shared/API/middleware/middleware-service.service.ts\n\tmodified: src/app/shared/utils/utils.ts\n\tmodified: src/app/store/session.service.ts\n\tmodified: src/app/ui/chat/component/edit-group/edit-group.page.ts\n\tmodified: src/app/ui/chat/component/new-group/new-group.page.ts\n\tmodified: src/app/ui/chat/modal/messages/contacts/contacts.page.ts\n\tmodified: src/app/ui/chat/modal/new-group/new-group.page.ts\n\tnew file: src/app/ui/login/inactivity/inactivity-routing.module.ts\n\tnew file: src/app/ui/login/inactivity/inactivity.module.ts\n\tnew file: src/app/ui/login/inactivity/inactivity.page.html\n\tnew file: src/app/ui/login/inactivity/inactivity.page.scss\n\tnew file: src/app/ui/login/inactivity/inactivity.page.spec.ts\n\tnew file: src/app/ui/login/inactivity/inactivity.page.ts\n\tnew file: src/app/ui/login/login/login-routing.module.ts\n\tnew file: src/app/ui/login/login/login.module.ts\n\tnew file: src/app/ui/login/login/login.page.html\n\tnew file: src/app/ui/login/login/login.page.scss\n\tnew file: src/app/ui/login/login/login.page.spec.ts\n\tnew file: src/app/ui/login/login/login.page.ts\n\tmodified: src/app/ui/shared/components/header/header.page.html",
"changeAuthor": "peter.maquiran"
}