Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ import {
} from 'igniteui-angular-charts';
import { timer } from 'rxjs';
import { debounce } from 'rxjs/operators';
import { LocalDataService } from './localData.service';
import { Contract, REGIONS } from './localData/financialData';
import { LocalData } from './local-data';
import { Contract, REGIONS } from './data/financialData';
import { NgIf, NgFor, CurrencyPipe } from '@angular/common';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';

@Component({
providers: [LocalDataService],
providers: [LocalData],
selector: 'app-<%=filePrefix%>',
templateUrl: './<%=filePrefix%>.html',
styleUrl: './<%=filePrefix%>.scss',
Expand Down Expand Up @@ -136,11 +136,11 @@ export class <%=ClassName%> implements OnInit, AfterViewInit, OnDestroy {
private timer: any;
private volumeChanged: any;
constructor(
private localService: LocalDataService,
private localData: LocalData,
private elRef: ElementRef,
private cdr: ChangeDetectorRef) {
this.subscription = this.localService.getData(this.volume);
this.localService.records.subscribe(x => { this.data = x; });
this.subscription = this.localData.getData(this.volume);
this.localData.records.subscribe(x => { this.data = x; });
}

public ngOnInit(): void {
Expand All @@ -166,7 +166,7 @@ export class <%=ClassName%> implements OnInit, AfterViewInit, OnDestroy {
this.volumeChanged = this.volumeSlider.valueChange.pipe(debounce(() => timer(200)));
this.volumeChanged.subscribe(
() => {
this.localService.getData(this.volume);
this.localData.getData(this.volume);
},
(err: string) => console.log('Error: ' + err));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable} from 'rxjs';
import { FinancialData } from './localData/financialData';
import { FinancialData } from './data/financialData';

@Injectable()
export class LocalDataService {
export class LocalData {
public records: Observable<any[]>;
public records$: BehaviorSubject<any[]>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import {
} from '<%=igxPackage%>';
import { timer } from 'rxjs';
import { debounce } from 'rxjs/operators';
import { LocalDataService } from './localData.service';
import { LocalData } from './local-data';
import { ITreeGridAggregation, <%=ClassName%>TreeGridGroupingPipe } from './tree-grid-grouping.pipe';
import { NgIf, CurrencyPipe } from '@angular/common';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';

@Component({
providers: [LocalDataService],
providers: [LocalData],
selector: 'app-<%=filePrefix%>',
templateUrl: './<%=filePrefix%>.html',
styleUrl: './<%=filePrefix%>.scss',
Expand Down Expand Up @@ -140,17 +140,17 @@ export class <%=ClassName%> implements OnInit, AfterViewInit, OnDestroy {
private timer: any;
private volumeChanged: any;

constructor(private zone: NgZone, private localService: LocalDataService, private elRef: ElementRef) {
this.subscription = this.localService.getData(this.volume);
this.localService.records.subscribe((d) => this.data = d);
constructor(private zone: NgZone, private localData: LocalData, private elRef: ElementRef) {
this.subscription = this.localData.getData(this.volume);
this.localData.records.subscribe((d) => this.data = d);
}

public ngOnInit(): void {
this.grid1.sortingExpressions = [{ fieldName: this.groupColumnKey, dir: SortingDirection.Desc }];
this.volumeChanged = this.volumeSlider.valueChange.pipe(debounce(() => timer(200)));
this.volumeChanged.subscribe(
() => {
this.localService.getData(this.volume);
this.localData.getData(this.volume);
},
(err: string) => console.log('Error: ' + err));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BehaviorSubject, Observable} from 'rxjs';
import { FinancialData } from './assets/financialData';

@Injectable()
export class LocalDataService {
export class LocalData {
public records: Observable<any[]>;
public records$: BehaviorSubject<any[]>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { provideRouter } from '@angular/router';

import { environment } from '../environments/environment';
import { routes } from './app.routes';
import { GlobalErrorHandlerService } from './error-routing/error/global-error-handler.service';
import { GlobalErrorHandler } from './error-routing/error/global-error-handler';

export const appConfig: ApplicationConfig = {
providers: [
Expand All @@ -14,6 +14,6 @@ export const appConfig: ApplicationConfig = {
provideRouter(routes),
importProvidersFrom(BrowserModule, HammerModule),
provideAnimations(),
...(environment.production ? [{ provide: ErrorHandler, useClass: GlobalErrorHandlerService }] : [])
...(environment.production ? [{ provide: ErrorHandler, useClass: GlobalErrorHandler }] : [])
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ErrorHandler, Injectable, Injector, NgZone, inject } from '@angular/cor
import { Router } from '@angular/router';

@Injectable()
export class GlobalErrorHandlerService implements ErrorHandler {
export class GlobalErrorHandler implements ErrorHandler {
private injector = inject(Injector);
private zone = inject(NgZone);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from 'igniteui-angular';
import { AppRoutingModule } from './app-routing-module';
import { App } from './app';
import { AuthenticationModule, ExternalAuthService } from './authentication';
import { AuthenticationModule, ExternalAuth } from './authentication';
import { Home } from './home/home';

@NgModule({
Expand All @@ -33,7 +33,7 @@ import { Home } from './home/home';
})
export class AppModule {

constructor(private externalAuthService: ExternalAuthService) {
constructor(private externalAuthService: ExternalAuth) {
/**
* To register a social login, un-comment one or more of the following and add your service provider Client ID.
* See https://github.com/IgniteUI/igniteui-cli/wiki/Angular-Authentication-Project-Template#add-a-third-party-social-provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
IgxRippleModule,
} from '<%=igxPackage%>';

import { AuthenticationModule, ExternalAuthService } from './authentication';
import { AuthenticationModule, ExternalAuth } from './authentication';
import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
Expand All @@ -27,6 +27,6 @@ export const appConfig: ApplicationConfig = {
AuthenticationModule
),
provideAnimations(),
ExternalAuthService
ExternalAuth
]
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { UserService } from './services/user.service';
import { UserStore } from './services/user-store';

@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(private router: Router, private userService: UserService) { }
constructor(private router: Router, private userStore: UserStore) { }

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (this.userService.currentUser) {
if (this.userStore.currentUser) {
return true;
}
this.router.navigate([''], { queryParams: { returnUrl: state.url } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Login } from './login/login';
import { Profile} from './profile/profile';
import { Redirect } from './redirect/redirect';
import { Register } from './register/register';
import { BackendProvider } from './services/fake-backend.service';
import { BackendProvider } from './services/fake-backend';
import { JwtInterceptor } from './services/jwt.interceptor';

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AuthGuard } from './auth.guard';
import { Profile } from './profile/profile';
import { Redirect } from './redirect/redirect';
import { ExternalAuthProvider } from './services/external-auth-configs';
import { ExternalAuthRedirectUrl } from './services/external-auth.service';
import { ExternalAuthRedirectUrl } from './services/external-auth';

const authRoutes: Routes = [
{ path: 'profile', component: Profile, canActivate: [AuthGuard] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export * from './authentication-module';
export * from './models/login';
export * from './models/register-info';
export * from './models/user';
export * from './services/authentication.service';
export * from './services/external-auth.service';
export * from './services/user.service';
export * from './services/authentication';
export * from './services/external-auth';
export * from './services/user-store';
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<button *ngIf="!userService.currentUser" igxRipple="white" igxButton="flat" igxButtonColor="white"
<button *ngIf="!userStore.currentUser" igxRipple="white" igxButton="flat" igxButtonColor="white"
(click)="openDialog()">Log In</button>

<button class="login-button" *ngIf="userService.currentUser" igxRipple="white" igxButton="flat" igxButtonBackground="c"
<button class="login-button" *ngIf="userStore.currentUser" igxRipple="white" igxButton="flat" igxButtonBackground="c"
igxButtonColor="white" [igxToggleAction]="options">
<igx-avatar [initials]="userService.initials ?? ''" [src]="userService.currentUser.picture ?? ''"
<igx-avatar [initials]="userStore.initials ?? ''" [src]="userStore.currentUser.picture ?? ''"
[roundShape]="true" size="small" bgColor="white">
</igx-avatar>
<igx-icon>keyboard_arrow_down</igx-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
IgxToggleModule
} from 'igniteui-angular';
import { LoginDialog } from '../login-dialog/login-dialog';
import { ExternalAuthService } from '../services/external-auth.service';
import { UserService } from '../services/user.service';
import { ExternalAuth } from '../services/external-auth';
import { UserStore } from '../services/user-store';
import { LoginBar } from './login-bar';

@Component({
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('LoginBar', () => {
clearCurrentUser() { return null; }
}

class TestAuthService {
class MockExternalAuth {
logout() { }
}

Expand All @@ -66,8 +66,8 @@ describe('LoginBar', () => {
TestLoginDialog
],
providers: [
{ provide: UserService, useClass: TestUserServSpy },
{ provide: ExternalAuthService, useClass: TestAuthService }
{ provide: UserStore, useClass: TestUserServSpy },
{ provide: ExternalAuth, useClass: MockExternalAuth }
]
})
.compileComponents();
Expand All @@ -87,8 +87,8 @@ describe('LoginBar', () => {
let buttons = fixture.debugElement.queryAll(By.css('button'));
expect(buttons.length).toBe(1);
expect(buttons[0].nativeElement.innerText).toBe('Log In');
const userServ = TestBed.inject(UserService);
spyOnProperty(userServ, 'currentUser', 'get').and.returnValue({
const userStore = TestBed.inject(UserStore);
spyOnProperty(userStore, 'currentUser', 'get').and.returnValue({
picture: 'picture'
});
fixture.detectChanges();
Expand All @@ -110,8 +110,8 @@ describe('LoginBar', () => {
});

it('should open drop down on button click (logged in)', async () => {
const userServ = TestBed.inject(UserService);
spyOnProperty(userServ, 'currentUser', 'get').and.returnValue({
const userStore = TestBed.inject(UserStore);
spyOnProperty(userStore, 'currentUser', 'get').and.returnValue({
picture: 'picture'
});
fixture.detectChanges();
Expand All @@ -123,20 +123,20 @@ describe('LoginBar', () => {
});

it('should handle user menu items', async () => {
const userServ = TestBed.inject(UserService);
const authServ = TestBed.inject(ExternalAuthService);
const userStore = TestBed.inject(UserStore);
const externalAuth = TestBed.inject(ExternalAuth);
const router: Router = TestBed.inject(Router);
spyOn(router, 'navigate');
spyOn(userServ, 'clearCurrentUser');
spyOn(authServ, 'logout');
spyOn(userStore, 'clearCurrentUser');
spyOn(externalAuth, 'logout');

component.igxDropDown.open();
component.igxDropDown.setSelectedItem(0);
expect(router.navigate).toHaveBeenCalledWith(['/profile']);

component.igxDropDown.setSelectedItem(1);
expect(router.navigate).toHaveBeenCalledWith(['/home']);
expect(userServ.clearCurrentUser).toHaveBeenCalled();
expect(authServ.logout).toHaveBeenCalled();
expect(userStore.clearCurrentUser).toHaveBeenCalled();
expect(externalAuth.logout).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { NgIf } from '@angular/common';
import { IgxDropDownComponent, ISelectionEventArgs, IgxRippleDirective, IgxButtonDirective, IgxToggleActionDirective,
IgxAvatarComponent, IgxIconComponent, IgxDropDownItemComponent } from 'igniteui-angular';
import { LoginDialog } from '../login-dialog/login-dialog';
import { ExternalAuthService } from '../services/external-auth.service';
import { UserService } from '../services/user.service';
import { ExternalAuth } from '../services/external-auth';
import { UserStore } from '../services/user-store';

@Component({
selector: 'app-login-bar',
Expand All @@ -23,8 +23,8 @@ export class LoginBar {
igxDropDown!: IgxDropDownComponent;

constructor(
public userService: UserService,
private authService: ExternalAuthService,
public userStore: UserStore,
private externalAuth: ExternalAuth,
private router: Router) {
}

Expand All @@ -34,8 +34,8 @@ export class LoginBar {

handleLogout() {
this.router.navigate(['/home']);
this.userService.clearCurrentUser();
this.authService.logout();
this.userStore.clearCurrentUser();
this.externalAuth.logout();
}

menuSelect(args: ISelectionEventArgs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<button igxButton="raised" type="submit" igxRipple [disabled]="!loginForm.valid">LOG IN</button>
<a id="register" (click)="showRegistrationForm()">Create new account?</a>
</div>
<div class="social-login" *ngIf="authService.hasProvider()">
<button type="button" *ngIf="authService.hasProvider(providers.Facebook)" class="facebook" igxButton="raised"
<div class="social-login" *ngIf="externalAuth.hasProvider()">
<button type="button" *ngIf="externalAuth.hasProvider(providers.Facebook)" class="facebook" igxButton="raised"
(click)="signUpFb()">Sign Up Facebook</button>
<button type="button" *ngIf="authService.hasProvider(providers.Google)" class="google" igxButton="raised"
<button type="button" *ngIf="externalAuth.hasProvider(providers.Google)" class="google" igxButton="raised"
(click)="signUpG()">Sign Up Google</button>
<button type="button" *ngIf="authService.hasProvider(providers.Microsoft)" class="microsoft" igxButton="raised"
<button type="button" *ngIf="externalAuth.hasProvider(providers.Microsoft)" class="microsoft" igxButton="raised"
(click)="signUpMS()">Sign Up Microsoft</button>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { IgxButtonModule, IgxIconModule, IgxInputGroupModule, IgxRippleModule } from 'igniteui-angular';
import { AuthenticationService } from '../services/authentication.service';
import { Authentication } from '../services/authentication';
import { ExternalAuthProvider } from '../services/external-auth-configs';
import { ExternalAuthService } from '../services/external-auth.service';
import { UserService } from '../services/user.service';
import { ExternalAuth } from '../services/external-auth';
import { UserStore } from '../services/user-store';
import { Login } from './login';

const MAIL_GROUP_NAME = 'email';
Expand All @@ -18,18 +18,18 @@ const PASSWORD_GROUP_NAME = 'password';
describe('Login', () => {
let component: Login;
let fixture: ComponentFixture<Login>;
const extAuthSpy = jasmine.createSpyObj('ExternalAuthService', ['login', 'hasProvider']);
const authSpy = jasmine.createSpyObj('AuthenticationService', ['login']);
const userServSpy = jasmine.createSpyObj('UserService', ['setCurrentUser']);
const extAuthSpy = jasmine.createSpyObj('ExternalAuth', ['login', 'hasProvider']);
const authSpy = jasmine.createSpyObj('Authentication', ['login']);
const userServSpy = jasmine.createSpyObj('UserStore', ['setCurrentUser']);

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Login, ReactiveFormsModule, RouterTestingModule, NoopAnimationsModule,
IgxInputGroupModule, IgxButtonModule, IgxIconModule, IgxRippleModule],
providers: [
{ provide: ExternalAuthService, useValue: extAuthSpy },
{ provide: AuthenticationService, useValue: authSpy },
{ provide: UserService, useValue: userServSpy }
{ provide: ExternalAuth, useValue: extAuthSpy },
{ provide: Authentication, useValue: authSpy },
{ provide: UserStore, useValue: userServSpy }
]
})
.compileComponents();
Expand Down
Loading
Loading