Browse Source

* abp-loading-directive added to button with other styles.

pull/15344/head
ozermzn 4 years ago
parent
commit
f8a3d9a4ee
  1. 13
      npm/ng-packs/apps/dev-app/src/app/home/home.component.html
  2. 16
      npm/ng-packs/apps/dev-app/src/app/home/home.component.ts
  3. 3
      npm/ng-packs/apps/dev-app/src/app/home/home.module.ts

13
npm/ng-packs/apps/dev-app/src/app/home/home.component.html

@ -12,19 +12,14 @@
<button <button
*ngIf="!hasLoggedIn" *ngIf="!hasLoggedIn"
[disabled]="isLog"
(click)="login()" (click)="login()"
[disabled]="isLog"
class="px-4 btn btn-primary ml-1" class="px-4 btn btn-primary ml-1"
role="button" role="button"
> >
<i class="fa fa-sign-in"></i> {{ 'AbpAccount::Login' | abpLocalization }} <div class="d-flex">
<div <div><i class="fa fa-sign-in"></i> {{ 'AbpAccount::Login' | abpLocalization }}</div>
*ngIf="isLog" <div [abpLoading]="isLog" class="" style="margin-bottom: 13px; margin-left: 7px"></div>
style="width: 17px; height: 17px"
class="spinner-border text-light ms-2"
role="status"
>
<span class="visually-hidden">Loading...</span>
</div> </div>
</button> </button>
</div> </div>

16
npm/ng-packs/apps/dev-app/src/app/home/home.component.ts

@ -1,24 +1,32 @@
import { AuthService } from '@abp/ng.core'; import { AuthService } from '@abp/ng.core';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { OAuthService } from 'angular-oauth2-oidc'; import { Router } from '@angular/router';
import { timeInterval } from 'rxjs';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.component.html', templateUrl: './home.component.html',
}) })
export class HomeComponent { export class HomeComponent {
//for disabled button and abp loading spinner
isLog: boolean = false; isLog: boolean = false;
get hasLoggedIn(): boolean { get hasLoggedIn(): boolean {
return this.authService.isAuthenticated; return this.authService.isAuthenticated;
} }
constructor(private authService: AuthService) {} constructor(private authService: AuthService, private router: Router) {
// this.router.events.subscribe(event => {
// if (event instanceof NavigationStart) {
// console.log(event);
// }
// });
}
login() { login() {
//when clicked button spinner and disabled will be active
this.isLog = true; this.isLog = true;
setTimeout(data => { setTimeout(a => {
this.authService.navigateToLogin(); this.authService.navigateToLogin();
//all functions is over here
this.isLog = false; this.isLog = false;
}, 1000); }, 1000);
} }

3
npm/ng-packs/apps/dev-app/src/app/home/home.module.ts

@ -2,9 +2,10 @@ import { NgModule } from '@angular/core';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
import { HomeRoutingModule } from './home-routing.module'; import { HomeRoutingModule } from './home-routing.module';
import { HomeComponent } from './home.component'; import { HomeComponent } from './home.component';
import { LoadingDirective, ThemeSharedModule } from '@abp/ng.theme.shared';
@NgModule({ @NgModule({
declarations: [HomeComponent], declarations: [HomeComponent],
imports: [SharedModule, HomeRoutingModule], imports: [SharedModule, HomeRoutingModule, ThemeSharedModule],
}) })
export class HomeModule {} export class HomeModule {}

Loading…
Cancel
Save