Просмотр исходного кода

login has proper indicators

tags/2.037
Patrick Sun 5 лет назад
Родитель
Сommit
e18b3099d4
7 измененных файлов: 61 добавлений и 8 удалений
  1. +16
    -0
      package-lock.json
  2. +1
    -0
      package.json
  3. +4
    -1
      src/app/app.module.ts
  4. +6
    -2
      src/app/auth/auth.component.html
  5. +15
    -2
      src/app/auth/auth.component.ts
  6. +13
    -2
      src/app/auth/dist/auth.component.js
  7. +6
    -1
      src/app/service/auth.service.ts

+ 16
- 0
package-lock.json Просмотреть файл

} }
} }
}, },
"@progress/kendo-angular-notification": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/@progress/kendo-angular-notification/-/kendo-angular-notification-2.1.3.tgz",
"integrity": "sha512-/xr8UCGKFN7Ha0JzMLCBRIj9AyOEyf6WWZrUJJQMEL/3aAnIXkpL90PEQ0vg9bTQvOPVTXk7q1TUBHIsfCjxDg==",
"requires": {
"@progress/kendo-schematics": "^1.0.0",
"tslib": "^1.9.0"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@progress/kendo-angular-pdf-export": { "@progress/kendo-angular-pdf-export": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/@progress/kendo-angular-pdf-export/-/kendo-angular-pdf-export-2.0.4.tgz", "resolved": "https://registry.npmjs.org/@progress/kendo-angular-pdf-export/-/kendo-angular-pdf-export-2.0.4.tgz",

+ 1
- 0
package.json Просмотреть файл

"@progress/kendo-angular-layout": "^5.0.4", "@progress/kendo-angular-layout": "^5.0.4",
"@progress/kendo-angular-menu": "^2.0.4", "@progress/kendo-angular-menu": "^2.0.4",
"@progress/kendo-angular-navigation": "^0.2.0", "@progress/kendo-angular-navigation": "^0.2.0",
"@progress/kendo-angular-notification": "^2.1.3",
"@progress/kendo-angular-pdf-export": "^2.0.0", "@progress/kendo-angular-pdf-export": "^2.0.0",
"@progress/kendo-angular-popup": "^3.0.0", "@progress/kendo-angular-popup": "^3.0.0",
"@progress/kendo-angular-progressbar": "^0.2.3", "@progress/kendo-angular-progressbar": "^0.2.3",

+ 4
- 1
src/app/app.module.ts Просмотреть файл

import { LabelModule } from '@progress/kendo-angular-label'; import { LabelModule } from '@progress/kendo-angular-label';
import { AuthService } from './service/auth.service'; import { AuthService } from './service/auth.service';
import { AuthGuard } from './service/auth-guard.service'; import { AuthGuard } from './service/auth-guard.service';
import { NotificationModule } from '@progress/kendo-angular-notification';







NavigationModule, NavigationModule,
LayoutModule, LayoutModule,
IndicatorsModule, IndicatorsModule,
LabelModule
LabelModule,
NotificationModule
], ],
providers: [MenuService, AuthGuard, AuthService], providers: [MenuService, AuthGuard, AuthService],
bootstrap: [AppComponent] bootstrap: [AppComponent]

+ 6
- 2
src/app/auth/auth.component.html Просмотреть файл

<div class='parent'> <div class='parent'>
<div class="form_login"> <div class="form_login">

<form *ngIf='!loading' class="k-form " [formGroup]="userForm"> <form *ngIf='!loading' class="k-form " [formGroup]="userForm">
<fieldset class="k-form-fieldset"> <fieldset class="k-form-fieldset">
<legend class="k-form-legend">Login to Supercredit</legend> <legend class="k-form-legend">Login to Supercredit</legend>
</fieldset> </fieldset>
</form> </form>


<div *ngIf='loading' style="min-height: 200px;"> auth loading...</div>
<kendo-loader *ngIf='loading'
type="converging-spinner"
themeColor="info"
size="large"
>
</kendo-loader>
</div> </div>
</div> </div>

+ 15
- 2
src/app/auth/auth.component.ts Просмотреть файл

import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms'; import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { NotificationService } from '@progress/kendo-angular-notification';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { AuthService } from '../service/auth.service'; import { AuthService } from '../service/auth.service';


email: new FormControl('email@email.com', Validators.email) email: new FormControl('email@email.com', Validators.email)
}); });


constructor(private authService: AuthService, private rounter: Router) { }
constructor(private authService: AuthService, private rounter: Router, private notificationService: NotificationService) { }


ngOnInit(): void { ngOnInit(): void {
this.loginSub = this.authService.loginSuccess.subscribe( this.loginSub = this.authService.loginSuccess.subscribe(
if (ok) if (ok)
this.rounter.navigate(["/dashboard"]); this.rounter.navigate(["/dashboard"]);
else else
alert('fuck this is wrong');
this.show();
} }
); );
} }
this.authService.login(this.userForm.value.email, this.userForm.value.password); this.authService.login(this.userForm.value.email, this.userForm.value.password);


} }


public show(): void {
this.notificationService.show({
content: 'Your loggin is failed, please try again.',
cssClass: 'button-notification',
animation: { type: 'slide', duration: 400 },
position: { horizontal: 'center', vertical: 'bottom' },
type: { style: 'error', icon: true },
closable: true
});
}
} }

+ 13
- 2
src/app/auth/dist/auth.component.js Просмотреть файл

var core_1 = require("@angular/core"); var core_1 = require("@angular/core");
var forms_1 = require("@angular/forms"); var forms_1 = require("@angular/forms");
var AuthComponent = /** @class */ (function () { var AuthComponent = /** @class */ (function () {
function AuthComponent(authService, rounter) {
function AuthComponent(authService, rounter, notificationService) {
this.authService = authService; this.authService = authService;
this.rounter = rounter; this.rounter = rounter;
this.notificationService = notificationService;
this.userForm = new forms_1.FormGroup({ this.userForm = new forms_1.FormGroup({
password: new forms_1.FormControl('abcdefg', [forms_1.Validators.minLength(3), forms_1.Validators.maxLength(20)]), password: new forms_1.FormControl('abcdefg', [forms_1.Validators.minLength(3), forms_1.Validators.maxLength(20)]),
email: new forms_1.FormControl('email@email.com', forms_1.Validators.email) email: new forms_1.FormControl('email@email.com', forms_1.Validators.email)
if (ok) if (ok)
_this.rounter.navigate(["/dashboard"]); _this.rounter.navigate(["/dashboard"]);
else else
alert('fuck this is wrong');
_this.show();
}); });
}; };
AuthComponent.prototype.ngOnDestroy = function () { AuthComponent.prototype.ngOnDestroy = function () {
this.loading = true; this.loading = true;
this.authService.login(this.userForm.value.email, this.userForm.value.password); this.authService.login(this.userForm.value.email, this.userForm.value.password);
}; };
AuthComponent.prototype.show = function () {
this.notificationService.show({
content: 'Your loggin is failed, please try again.',
cssClass: 'button-notification',
animation: { type: 'slide', duration: 400 },
position: { horizontal: 'center', vertical: 'bottom' },
type: { style: 'error', icon: true },
closable: true
});
};
AuthComponent = __decorate([ AuthComponent = __decorate([
core_1.Component({ core_1.Component({
selector: 'app-auth', selector: 'app-auth',

+ 6
- 1
src/app/service/auth.service.ts Просмотреть файл

import { EventEmitter, Injectable } from '@angular/core'; import { EventEmitter, Injectable } from '@angular/core';
import { BooleanFilterComponent } from '@progress/kendo-angular-grid';
import { NotificationService } from '@progress/kendo-angular-notification';


@Injectable() @Injectable()
export class AuthService { export class AuthService {
private loggedIn: boolean = false; private loggedIn: boolean = false;
loginSuccess = new EventEmitter <any>(); loginSuccess = new EventEmitter <any>();


isAuthenticated() { isAuthenticated() {
return this.loggedIn; return this.loggedIn;
} }
logout() { logout() {
this.loggedIn = false; this.loggedIn = false;
} }



} }

Загрузка…
Отмена
Сохранить