admin login page

This commit is contained in:
Diamantis Tziotzios 2019-02-15 11:18:14 +02:00
parent 54779bf53f
commit 326e5e0356
4 changed files with 41 additions and 34 deletions

View File

@ -88,6 +88,13 @@ const appRoutes: Routes = [
breadcrumb: true
},
},
{
path: 'login/admin',
loadChildren: './ui/auth/admin-login/admin-login.module#AdminLoginModule',
data: {
breadcrumb: true
},
},
{
path: 'login',
loadChildren: './ui/auth/login/login.module#LoginModule',

View File

@ -11,6 +11,7 @@ import { BaseService } from '../../common/base/base.service';
import { Credential } from '../../model/auth/credential';
import { LoginInfo } from '../../model/auth/login-info';
import { Principal } from '../../model/auth/Principal';
import { UiNotificationService, SnackBarNotificationLevel } from '../notification/ui-notification-service';
@Injectable()
@ -20,9 +21,10 @@ export class AuthService extends BaseService {
constructor(
private http: HttpClient,
public snackBar: MatSnackBar,
public language: TranslateService,
public router: Router
private snackBar: MatSnackBar,
private language: TranslateService,
private router: Router,
private uiNotificationService: UiNotificationService
) {
super();
this.actionUrl = environment.Server + 'auth/';
@ -133,18 +135,12 @@ export class AuthService extends BaseService {
}
public onLogOutSuccess(logoutMessage: any) {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT'), SnackBarNotificationLevel.Success);
this.router.navigate(['/login']);
}
public onLogOutError(errorMessage: string) {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT'), SnackBarNotificationLevel.Error);
this.router.navigate(['/login']);
}
}

View File

@ -4,31 +4,31 @@
<div class="row col-md-6 col-sm-6 col-md-offset-3 col-sm-offset-3">
<div class="card col-md-8 col-md-offset-2">
<div class="card-header">
<h4>Login</h4>
<div class="social-btns">
<div>
<div class="card-form">
<div class="form-row">
<i class="material-icons">person</i>
<mat-form-field color="accent">
<input type="text" [(ngModel)]="credential.username" matInput placeholder="Username" />
</mat-form-field>
</div>
<div class="form-row">
<i class="material-icons">lock_outline</i>
<mat-form-field color="accent">
<input type="password" [(ngModel)]="credential.secret" matInput placeholder="Password" />
</mat-form-field>
</div>
</div>
<div class="card-footer">
<button mat-button (click)="nativeLogin()">LOGIN</button>
</div>
</div>
</div>
<h4>Admin Login</h4>
</div>
<!-- <div class="social-btns">
<div>
<div class="card-form">
<div class="form-row">
<i class="material-icons">person</i> -->
<mat-form-field color="accent">
<input type="text" [(ngModel)]="credential.username" matInput placeholder="Username" />
</mat-form-field>
<!-- </div>
<div class="form-row"> -->
<!-- <i class="material-icons">lock_outline</i> -->
<mat-form-field color="accent">
<input type="password" [(ngModel)]="credential.secret" matInput placeholder="Password" />
</mat-form-field>
<!-- </div>
</div> -->
<div>
<button mat-raised-button color="primary" (click)="nativeLogin()">LOGIN</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- </div>
</div> -->

View File

@ -16,7 +16,7 @@ import { AuthService } from '../../../core/services/auth/auth.service';
export class AdminLoginComponent extends BaseComponent implements OnInit {
public auth2: any;
public credential: Credential;
public credential: Credential;
constructor(
private authService: AuthService,
@ -29,6 +29,10 @@ export class AdminLoginComponent extends BaseComponent implements OnInit {
ngOnInit() {
this.credential = {
username: null,
secret: null
}
}
public nativeLogin() {