Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#877] apply formatting and linting to login module #1134

Merged
merged 1 commit into from
Jan 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[#877] apply formatting and linting to login module
  • Loading branch information
bossenti committed Jan 20, 2023
commit a21d69765ba59a8d83e82cc392524ba4249b1a55
1 change: 0 additions & 1 deletion ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -28,4 +28,3 @@ src/app/data-explorer
src/app/editor
src/app/files
src/app/info
src/app/login
1 change: 0 additions & 1 deletion ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -28,4 +28,3 @@ src/app/data-explorer
src/app/editor
src/app/files
src/app/info
src/app/login
Original file line number Diff line number Diff line change
@@ -23,14 +23,19 @@ <h1>Account activation</h1>
<div fxLayout="column" fxFlex="100">
<div fxLayout="column" class="mt-10">
<div>
<h5 *ngIf="!activationPerformed">Verifying account activation...</h5>
<h5 *ngIf="activationPerformed && activationSuccess">Account successfully activated.</h5>
<h5 *ngIf="activationPerformed && !activationSuccess">Your account could not be activated.</h5>
<h5 *ngIf="!activationPerformed">
Verifying account activation...
</h5>
<h5 *ngIf="activationPerformed && activationSuccess">
Account successfully activated.
</h5>
<h5 *ngIf="activationPerformed && !activationSuccess">
Your account could not be activated.
</h5>
</div>
<div>
<a [routerLink]="['/login']">Go to login page</a>
</div>
</div>
</div>

</sp-auth-box>
Original file line number Diff line number Diff line change
@@ -21,38 +21,43 @@ import { AccountActivationService } from '../../services/account-activation.serv
import { ActivatedRoute, Router } from '@angular/router';

@Component({
selector: 'sp-activate-account',
templateUrl: './activate-account.component.html',
styleUrls: ['../login/login.component.scss']
selector: 'sp-activate-account',
templateUrl: './activate-account.component.html',
styleUrls: ['../login/login.component.scss'],
})
export class ActivateAccountComponent implements OnInit {
activationCode: string;
activationSuccess: boolean;
activationPerformed = false;

activationCode: string;
activationSuccess: boolean;
activationPerformed = false;
constructor(
private accountActivationService: AccountActivationService,
private route: ActivatedRoute,
private router: Router,
) {}

constructor(private accountActivationService: AccountActivationService,
private route: ActivatedRoute,
private router: Router) {}

ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.activationCode = params['activationCode'];
if (this.activationCode) {
this.accountActivationService.activateAccount(this.activationCode).subscribe(success => {
this.activationPerformed = true;
this.activationSuccess = true;
}, error => {
this.activationPerformed = true;
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.activationCode = params['activationCode'];
if (this.activationCode) {
this.accountActivationService
.activateAccount(this.activationCode)
.subscribe(
success => {
this.activationPerformed = true;
this.activationSuccess = true;
},
error => {
this.activationPerformed = true;
},
);
} else {
this.activationPerformed = true;
}
});
} else {
this.activationPerformed = true;
}
});
}

navigateToLoginPage() {
this.router.navigate(['/login']);
}
}

navigateToLoginPage() {
this.router.navigate(['/login']);
}
}
23 changes: 8 additions & 15 deletions ui/src/app/login/components/auth-box/auth-box.component.ts
Original file line number Diff line number Diff line change
@@ -16,22 +16,15 @@
*
*/

import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'sp-auth-box',
templateUrl: './auth-box.component.html',
styleUrls: ['./auth-box.component.scss']
selector: 'sp-auth-box',
templateUrl: './auth-box.component.html',
styleUrls: ['./auth-box.component.scss'],
})
export class AuthBoxComponent implements OnInit {


ngOnInit(): void {
}

openDocumentation() {
window.open('https://streampipes.apache.org/docs', '_blank');
}


export class AuthBoxComponent {
openDocumentation() {
window.open('https://streampipes.apache.org/docs', '_blank');
}
}
82 changes: 55 additions & 27 deletions ui/src/app/login/components/login/login.component.html
Original file line number Diff line number Diff line change
@@ -21,49 +21,77 @@
<h1>Login</h1>
</div>
<div fxFlex="100" fxLayout="column">
<form [formGroup]="parentForm" fxFlex="100" fxLayout="column" *ngIf="configReady">
<form
[formGroup]="parentForm"
fxFlex="100"
fxLayout="column"
*ngIf="configReady"
>
<div fxFlex="100" fxLayout="column">
<mat-form-field fxFlex color="accent">
<mat-label>Email</mat-label>
<input formControlName="username"
matInput
name="username"
class="sp"
required
data-cy="login-email"/>
<input
formControlName="username"
matInput
name="username"
class="sp"
required
data-cy="login-email"
/>
</mat-form-field>
<mat-form-field fxFlex color="accent">
<mat-label>Password</mat-label>
<input formControlName="password"
matInput
name="password"
type="password"
class="sp"
required
data-cy="login-password"/>
<input
formControlName="password"
matInput
name="password"
type="password"
class="sp"
required
data-cy="login-password"
/>
</mat-form-field>
</div>
<div class="form-actions" style="margin-top:20px;">
<button mat-button
mat-raised-button
color="accent"
data-cy="login-button"
(click)="logIn()"
[disabled]="!parentForm.valid || loading">
<div class="form-actions" style="margin-top: 20px">
<button
mat-button
mat-raised-button
color="accent"
data-cy="login-button"
(click)="logIn()"
[disabled]="!parentForm.valid || loading"
>
<span *ngIf="loading">Logging in...</span>
<span *ngIf="!loading">Login</span>
</button>
<mat-spinner [mode]="'indeterminate'" color="accent" [diameter]="20"
*ngIf="loading" style="margin-top:10px;"></mat-spinner>
<mat-spinner
[mode]="'indeterminate'"
color="accent"
[diameter]="20"
*ngIf="loading"
style="margin-top: 10px"
></mat-spinner>
<div class="md-warn" *ngIf="authenticationFailed">
<h5 class="login-error">User not found or incorrect password provided.<br/>Please try again.</h5>
<h5 class="login-error">
User not found or incorrect password provided.<br />Please
try again.
</h5>
</div>
<div fxLayout="row" class="mt-10">
<div *ngIf="loginSettings.allowPasswordRecovery">
<a [routerLink]="['/restore-password']">Forgot password?</a>
<a [routerLink]="['/restore-password']"
>Forgot password?</a
>
</div>
<span style="margin-left: 5px; margin-right: 5px;"
*ngIf="loginSettings.allowSelfRegistration && loginSettings.allowPasswordRecovery"> | </span>
<span
style="margin-left: 5px; margin-right: 5px"
*ngIf="
loginSettings.allowSelfRegistration &&
loginSettings.allowPasswordRecovery
"
>
|
</span>
<div *ngIf="loginSettings.allowSelfRegistration">
<a [routerLink]="['/register']">Create new account</a>
</div>
20 changes: 10 additions & 10 deletions ui/src/app/login/components/login/login.component.scss
Original file line number Diff line number Diff line change
@@ -17,23 +17,23 @@
*/

.login-error {
background: #ffa2a2;
padding: 8px;
color: #3e3e3e;
border-radius: 5px;
background: #ffa2a2;
padding: 8px;
color: #3e3e3e;
border-radius: 5px;
}

.info-box {
padding: 8px;
border-radius: 5px;
padding: 8px;
border-radius: 5px;
}

.register-error {
background: #ffa2a2;
color: #3e3e3e;
background: #ffa2a2;
color: #3e3e3e;
}

.register-success {
background: #a2ffa2;
color: #3e3e3e;
background: #a2ffa2;
color: #3e3e3e;
}
75 changes: 44 additions & 31 deletions ui/src/app/login/components/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -22,15 +22,19 @@ import { LoginService } from '../../services/login.service';
import { Router } from '@angular/router';
import { AuthService } from '../../../services/auth.service';
import { LoginModel } from './login.model';
import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import {
UntypedFormBuilder,
UntypedFormControl,
UntypedFormGroup,
Validators,
} from '@angular/forms';

@Component({
selector: 'login',
selector: 'sp-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
styleUrls: ['./login.component.scss'],
})
export class LoginComponent implements OnInit {

parentForm: UntypedFormGroup;
configReady = false;
loading: boolean;
@@ -39,46 +43,55 @@ export class LoginComponent implements OnInit {

loginSettings: LoginModel;

constructor(private loginService: LoginService,
private router: Router,
private shepherdService: ShepherdService,
private authService: AuthService,
private fb: UntypedFormBuilder) {
constructor(
private loginService: LoginService,
private router: Router,
private shepherdService: ShepherdService,
private authService: AuthService,
private fb: UntypedFormBuilder,
) {
this.loading = false;
this.authenticationFailed = false;
this.credentials = {};
}

ngOnInit() {
this.loginService.fetchLoginSettings().subscribe(result => {
this.loginSettings = result;
this.configReady = true;
this.parentForm = this.fb.group({});
this.parentForm.addControl('username', new UntypedFormControl('', Validators.required));
this.parentForm.addControl('password', new UntypedFormControl('', Validators.required));
this.loginService.fetchLoginSettings().subscribe(result => {
this.loginSettings = result;
this.configReady = true;
this.parentForm = this.fb.group({});
this.parentForm.addControl(
'username',
new UntypedFormControl('', Validators.required),
);
this.parentForm.addControl(
'password',
new UntypedFormControl('', Validators.required),
);

this.parentForm.valueChanges.subscribe(v => {
this.credentials.username = v.username;
this.credentials.password = v.password;
this.parentForm.valueChanges.subscribe(v => {
this.credentials.username = v.username;
this.credentials.password = v.password;
});
});
});
}



logIn() {
this.authenticationFailed = false;
this.loading = true;
this.loginService.login(this.credentials)
.subscribe(response => { // success
this.authService.login(response);
this.loading = false;
this.router.navigate(['']);
}, response => { // error
this.loading = false;
this.authenticationFailed = true;
}
);
this.loginService.login(this.credentials).subscribe(
response => {
// success
this.authService.login(response);
this.loading = false;
this.router.navigate(['']);
},
response => {
// error
this.loading = false;
this.authenticationFailed = true;
},
);
}

setSheperdServiceDelay() {
4 changes: 2 additions & 2 deletions ui/src/app/login/components/login/login.model.ts
Original file line number Diff line number Diff line change
@@ -17,6 +17,6 @@
*/

export interface LoginModel {
allowSelfRegistration: boolean;
allowPasswordRecovery: boolean;
allowSelfRegistration: boolean;
allowPasswordRecovery: boolean;
}
Loading