fix issues

This commit is contained in:
Peter Maquiran
2024-12-05 19:14:11 +01:00
parent dad392335e
commit 5a1bbe6103
46 changed files with 378 additions and 1748 deletions
+12 -1
View File
@@ -12,6 +12,17 @@
<div class="title-content">
<div class="div-title">
<ion-label class="title font-25-em">Chat</ion-label>
<!-- <input
[(ngModel)]="roomName"
style="
background: white;
border: 1px solid black;
height: 30px;
margin-left: 10px;
"
(ngModelChange)="filterList()"
/> -->
</div>
<div class="div-icon">
@@ -41,7 +52,7 @@
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
<div class="width-100">
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
*ngFor="let room of rooms"
*ngFor="let room of filterRoomList"
[class.item-active]="room.$id == selectedRoomId" [class.hide-room]="room.roomType != segment">
<div class="item-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.$id != selectedRoomId && room.roomType == RoomType.Group " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon>
+13 -1
View File
@@ -62,6 +62,9 @@ export class ChatPage implements OnInit {
//items$!: DexieObservable<RoomTable[]>;
items$!: Observable<RoomTable[]>;
rooms: RoomViewModel[] = [];
filterRoomList: RoomViewModel[] = [];
roomName = ''
private subscription: Subscription;
expirationDate = {}
private intervalSubscription: Subscription;
@@ -119,7 +122,17 @@ export class ChatPage implements OnInit {
);
// this.RoomSelected = this.rooms.filter(e => e.id == this.selectedRoomId)[0]
this.filterList()
}
filterList() {
if(this.roomName) {
this.filterRoomList = this.rooms.filter(e => e.roomName.toLocaleLowerCase().indexOf(this.roomName.toLocaleLowerCase()) >= 0)
} else {
this.filterRoomList = this.rooms
}
}
ngOnInit() {
// this.subscription = this.roomListSubject.pipe(
// switchMap(roomList =>
@@ -145,7 +158,6 @@ export class ChatPage implements OnInit {
this.roomLocalDataSourceService.getItemsLive().pipe(
map((roomList) => roomList.map((room)=> new RoomViewModel(room))),
tap((roomList) => {
console.log('update')
this.updatemessage(roomList)
})
).subscribe()
@@ -7,13 +7,13 @@
<!-- <button (click)="ChatMessageDebuggingPage()">Dev</button> -->
<span *ngIf="roomStatus$ | async as roomStatus"><ion-icon *ngIf="roomStatus" class="online" name="ellipse"></ion-icon></span>
</div>
<!-- <div class="right" >
<div class="right" *ngIf="roomType == RoomTypeEnum.Group">
<button title="Menu" class="btn-no-color" (click)="_openMessagesOptions()" >
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/theme/blue/icons-menu.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg">
</ion-icon>
</button>
</div> -->
</div>
</div>
<div class="d-flex header-bottom" >
<div class="header-bottom-icon" *ngIf="roomType == RoomTypeEnum.Group">
@@ -1,17 +0,0 @@
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 {}
@@ -1,20 +0,0 @@
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 {}
@@ -1,62 +0,0 @@
<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>
@@ -1,349 +0,0 @@
@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;
}
@@ -1,24 +0,0 @@
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();
});
});
@@ -1,216 +0,0 @@
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(['/']);
}
}
@@ -1,17 +0,0 @@
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
@@ -1,25 +0,0 @@
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
@@ -1,46 +0,0 @@
<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
@@ -1,219 +0,0 @@
@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
@@ -1,24 +0,0 @@
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
@@ -1,299 +0,0 @@
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);
}
}