Skip to content

Commit ecded5a

Browse files
committed
format front code
1 parent a903d5c commit ecded5a

19 files changed

+252
-269
lines changed
+9-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
import { NgModule } from '@angular/core';
2-
import { Routes, RouterModule } from '@angular/router';
3-
import { LoginComponent } from './login/login.component';
4-
import { HelloComponent } from './hello/hello.component';
5-
1+
import { NgModule } from '@angular/core'
2+
import { Routes, RouterModule } from '@angular/router'
3+
import { LoginComponent } from './login/login.component'
4+
import { HelloComponent } from './hello/hello.component'
65

76
const routes: Routes = [
8-
{ path: '', component: LoginComponent},
9-
{ path: 'hello', component: HelloComponent}
10-
];
7+
{ path: '', component: LoginComponent },
8+
{ path: 'hello', component: HelloComponent }
9+
]
1110

1211
@NgModule({
13-
imports: [RouterModule.forRoot(
14-
routes
15-
)],
12+
imports: [RouterModule.forRoot(routes)],
1613
exports: [RouterModule]
1714
})
18-
export class AppRoutingModule { }
15+
export class AppRoutingModule {}
+12-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
import { TestBed, async } from '@angular/core/testing';
2-
import { RouterTestingModule } from '@angular/router/testing';
3-
import { AppComponent } from './app.component';
1+
import { TestBed, async } from '@angular/core/testing'
2+
import { RouterTestingModule } from '@angular/router/testing'
3+
import { AppComponent } from './app.component'
44

55
describe('AppComponent', () => {
66
beforeEach(async(() => {
77
TestBed.configureTestingModule({
8-
imports: [
9-
RouterTestingModule
10-
],
11-
declarations: [
12-
AppComponent
13-
],
14-
}).compileComponents();
15-
}));
8+
imports: [RouterTestingModule],
9+
declarations: [AppComponent]
10+
}).compileComponents()
11+
}))
1612

1713
it('should create the app', () => {
18-
const fixture = TestBed.createComponent(AppComponent);
19-
const app = fixture.debugElement.componentInstance;
20-
expect(app).toBeTruthy();
21-
});
22-
23-
});
14+
const fixture = TestBed.createComponent(AppComponent)
15+
const app = fixture.debugElement.componentInstance
16+
expect(app).toBeTruthy()
17+
})
18+
})

front-end/src/app/app.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Component } from '@angular/core';
1+
import { Component } from '@angular/core'
22

33
@Component({
44
selector: 'app-root',
55
templateUrl: './app.component.html',
66
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent {
9-
title = 'Angular Symfony';
9+
title = 'Angular Symfony'
1010
}

front-end/src/app/app.module.ts

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
import { BrowserModule } from '@angular/platform-browser';
2-
import { NgModule } from '@angular/core';
1+
import { BrowserModule } from '@angular/platform-browser'
2+
import { NgModule } from '@angular/core'
33

4-
import { AppRoutingModule } from './app-routing.module';
5-
import { ReactiveFormsModule } from '@angular/forms';
6-
import { HttpClientModule } from '@angular/common/http';
7-
import { AppComponent } from './app.component';
8-
import { LoginComponent } from './login/login.component';
9-
import { HelloComponent } from './hello/hello.component';
10-
import { httpInterceptorProviders } from './http-interceptor';
4+
import { AppRoutingModule } from './app-routing.module'
5+
import { ReactiveFormsModule } from '@angular/forms'
6+
import { HttpClientModule } from '@angular/common/http'
7+
import { AppComponent } from './app.component'
8+
import { LoginComponent } from './login/login.component'
9+
import { HelloComponent } from './hello/hello.component'
10+
import { httpInterceptorProviders } from './http-interceptor'
1111

1212
@NgModule({
13-
declarations: [
14-
AppComponent,
15-
LoginComponent,
16-
HelloComponent
17-
],
13+
declarations: [AppComponent, LoginComponent, HelloComponent],
1814
imports: [
1915
BrowserModule,
2016
AppRoutingModule,
2117
ReactiveFormsModule,
22-
HttpClientModule,
23-
],
24-
providers: [
25-
httpInterceptorProviders
18+
HttpClientModule
2619
],
20+
providers: [httpInterceptorProviders],
2721
bootstrap: [AppComponent]
2822
})
29-
export class AppModule { }
23+
export class AppModule {}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
import { HttpClientTestingModule } from '@angular/common/http/testing';
3-
import { RouterTestingModule } from '@angular/router/testing';
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing'
2+
import { HttpClientTestingModule } from '@angular/common/http/testing'
3+
import { RouterTestingModule } from '@angular/router/testing'
44

5-
import { HelloComponent } from './hello.component';
5+
import { HelloComponent } from './hello.component'
66

77
describe('HelloComponent', () => {
8-
let component: HelloComponent;
9-
let fixture: ComponentFixture<HelloComponent>;
8+
let component: HelloComponent
9+
let fixture: ComponentFixture<HelloComponent>
1010

1111
beforeEach(async(() => {
1212
TestBed.configureTestingModule({
13-
imports: [
14-
HttpClientTestingModule,
15-
RouterTestingModule,
16-
],
17-
declarations: [ HelloComponent ]
18-
})
19-
.compileComponents();
20-
}));
13+
imports: [HttpClientTestingModule, RouterTestingModule],
14+
declarations: [HelloComponent]
15+
}).compileComponents()
16+
}))
2117

2218
beforeEach(() => {
23-
fixture = TestBed.createComponent(HelloComponent);
24-
component = fixture.componentInstance;
25-
fixture.detectChanges();
26-
});
19+
fixture = TestBed.createComponent(HelloComponent)
20+
component = fixture.componentInstance
21+
fixture.detectChanges()
22+
})
2723

2824
it('should create', () => {
29-
expect(component).toBeTruthy();
30-
});
31-
});
25+
expect(component).toBeTruthy()
26+
})
27+
})
+21-22
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { Observable } from 'rxjs';
1+
import { Component, OnInit } from '@angular/core'
2+
import { Observable } from 'rxjs'
33

4-
import { WSSEService } from '../wsse.service';
5-
import { HttpErrorResponse } from '@angular/common/http';
6-
import { Router } from '@angular/router';
7-
import { TokenService } from '../token.service';
4+
import { WSSEService } from '../wsse.service'
5+
import { HttpErrorResponse } from '@angular/common/http'
6+
import { Router } from '@angular/router'
7+
import { TokenService } from '../token.service'
88

99
@Component({
1010
selector: 'app-hello',
1111
templateUrl: './hello.component.html',
1212
styleUrls: ['./hello.component.css']
1313
})
1414
export class HelloComponent implements OnInit {
15+
$hello: Observable<{ hello?: string }>
16+
helloMessage: string
1517

16-
$hello: Observable<{ hello?: string }>;
17-
helloMessage: string;
18-
19-
constructor(
18+
constructor (
2019
private wsseService: WSSEService,
2120
private tokenService: TokenService,
22-
private router: Router,
23-
) { }
21+
private router: Router
22+
) {}
2423

25-
ngOnInit() {
24+
ngOnInit () {
2625
// Example API call showing an Hello World
27-
this.$hello = this.wsseService.getHello();
26+
this.$hello = this.wsseService.getHello()
2827

2928
this.$hello.subscribe(
3029
// Show API response
3130
({ hello }) => {
32-
console.log(`Received from server ${hello}`);
33-
this.helloMessage = hello;
31+
console.log(`Received from server ${hello}`)
32+
this.helloMessage = hello
3433
},
3534
// Log error message and redirect to login
3635
(error: HttpErrorResponse) => {
37-
console.error(error);
36+
console.error(error)
3837
if (error.status === 401) {
39-
return this.router.navigate(['']);
38+
return this.router.navigate([''])
4039
}
41-
});
40+
}
41+
)
4242
}
4343

44-
onGoBack() {
45-
return this.router.navigate(['']);
44+
onGoBack () {
45+
return this.router.navigate([''])
4646
}
47-
4847
}
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { HTTP_INTERCEPTORS } from '@angular/common/http';
1+
import { HTTP_INTERCEPTORS } from '@angular/common/http'
22

3-
import { WSSEInterceptor } from './wsse-interceptor';
3+
import { WSSEInterceptor } from './wsse-interceptor'
44

55
/** Http interceptor providers in outside-in order */
66
export const httpInterceptorProviders = [
7-
{ provide: HTTP_INTERCEPTORS, useClass: WSSEInterceptor, multi: true },
8-
];
7+
{ provide: HTTP_INTERCEPTORS, useClass: WSSEInterceptor, multi: true }
8+
]
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import { TokenService } from '../token.service';
2-
import { Injectable } from '@angular/core';
3-
import { HttpInterceptor, HttpRequest, HttpHandler } from '@angular/common/http';
1+
import { TokenService } from '../token.service'
2+
import { Injectable } from '@angular/core'
3+
import { HttpInterceptor, HttpRequest, HttpHandler } from '@angular/common/http'
44

55
@Injectable()
66
export class WSSEInterceptor implements HttpInterceptor {
7+
constructor (private tokenService: TokenService) {}
78

8-
constructor(private tokenService: TokenService) {}
9-
10-
intercept(req: HttpRequest<any>, next: HttpHandler) {
11-
let authToken = this.tokenService.getAuthorizationToken();
9+
intercept (req: HttpRequest<any>, next: HttpHandler) {
10+
let authToken = this.tokenService.getAuthorizationToken()
1211

1312
if (authToken) {
1413
// Clone the request and replace the original headers with
15-
// cloned headers, updated with the authorization.
14+
// cloned headers, updated with the authorization.
1615
const authReq = req.clone({
1716
headers: req.headers.set('X-WSSE', authToken)
18-
});
17+
})
1918
// send cloned request with header to the next handler.
20-
return next.handle(authReq);
19+
return next.handle(authReq)
2120
} else {
2221
// otherwise send request without token
23-
return next.handle(req);
22+
return next.handle(req)
2423
}
2524
}
26-
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { async, ComponentFixture, TestBed } from "@angular/core/testing";
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing'
22

3-
import { LoginComponent } from "./login.component";
4-
import { ReactiveFormsModule } from "@angular/forms";
5-
import { HttpClientTestingModule } from "@angular/common/http/testing";
6-
import { RouterTestingModule } from "@angular/router/testing";
3+
import { LoginComponent } from './login.component'
4+
import { ReactiveFormsModule } from '@angular/forms'
5+
import { HttpClientTestingModule } from '@angular/common/http/testing'
6+
import { RouterTestingModule } from '@angular/router/testing'
77

8-
describe("LoginComponent", () => {
9-
let component: LoginComponent;
10-
let fixture: ComponentFixture<LoginComponent>;
8+
describe('LoginComponent', () => {
9+
let component: LoginComponent
10+
let fixture: ComponentFixture<LoginComponent>
1111

1212
beforeEach(async(() => {
1313
TestBed.configureTestingModule({
@@ -17,16 +17,16 @@ describe("LoginComponent", () => {
1717
RouterTestingModule
1818
],
1919
declarations: [LoginComponent]
20-
}).compileComponents();
21-
}));
20+
}).compileComponents()
21+
}))
2222

2323
beforeEach(() => {
24-
fixture = TestBed.createComponent(LoginComponent);
25-
component = fixture.componentInstance;
26-
fixture.detectChanges();
27-
});
24+
fixture = TestBed.createComponent(LoginComponent)
25+
component = fixture.componentInstance
26+
fixture.detectChanges()
27+
})
2828

29-
it("should create", () => {
30-
expect(component).toBeTruthy();
31-
});
32-
});
29+
it('should create', () => {
30+
expect(component).toBeTruthy()
31+
})
32+
})

0 commit comments

Comments
 (0)