Skip to content

Commit 80603e9

Browse files
committed
first commit
0 parents  commit 80603e9

File tree

84 files changed

+2797
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+2797
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules/
2+
/dist/
3+
/npm-debug.log
4+
/typings/
5+
/.idea/
6+
/.vscode/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2015-2016 Google, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

app/app.component.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* http://tobiasahlin.com/spinkit/ */
2+
3+
.spinner {
4+
width: 40px;
5+
height: 40px;
6+
background-color: aqua;
7+
8+
margin: 100px auto;
9+
-webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
10+
animation: sk-rotateplane 1.2s infinite ease-in-out;
11+
}
12+
13+
@-webkit-keyframes sk-rotateplane {
14+
0% { -webkit-transform: perspective(120px) }
15+
50% { -webkit-transform: perspective(120px) rotateY(180deg) }
16+
100% { -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) }
17+
}
18+
19+
@keyframes sk-rotateplane {
20+
0% {
21+
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
22+
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
23+
} 50% {
24+
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
25+
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
26+
} 100% {
27+
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
28+
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
29+
}
30+
}

app/app.component.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<nav class="navbar navbar-default">
2+
<ul class="nav navbar-nav">
3+
<li routerLinkActive="active"><a [routerLink]="['/home', {showDetail:false}]" [preserveQueryParams]="true">Home</a></li>
4+
<li routerLinkActive="active"><a [routerLink]="['/flight-booking']" [preserveQueryParams]="true">Book a flight</a></li>
5+
<li routerLinkActive="active"><a [routerLink]="['/bookings']" [preserveQueryParams]="true">Your Bookings</a></li>
6+
<li><a (click)="activateExpertMode()">Activate Expert Mode</a></li>
7+
<li><a (click)="deactivateExpertMode()">Deactivate Expert Mode</a></li>
8+
9+
<li><a [routerLink]="[{outlets: { aux: ['history', {showDetail: true}] }}]">Show History</a></li>
10+
<li><a [routerLink]="[{outlets: { aux: null }}]">Hide History</a></li>
11+
12+
</ul>
13+
</nav>
14+
15+
<div class="container">
16+
17+
<div class="row">
18+
<router-outlet></router-outlet>
19+
</div>
20+
21+
<div class="row">
22+
<router-outlet name="aux"></router-outlet>
23+
</div>
24+
25+
</div>
26+
27+
<div *ngIf="showWaitInfo" style="background-color: black; opacity: 0.3; width:100%; height:100%; left:0px; top:0px; position: absolute;" >
28+
<div class="spinner"></div>
29+
</div>
30+
31+
32+
<!-- Fußzeile -->

app/app.component.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { Component } from '@angular/core';
2+
import { OAuthService } from 'angular2-oauth2/oauth-service';
3+
import { Router, NavigationStart, NavigationEnd, NavigationCancel, NavigationError } from '@angular/router';
4+
import {LeaveComponentGuard} from "./shared/deactivation/leave-component-guard";
5+
import {CustomReuseStrategy} from "./shared/router/custom-reuse-strategy";
6+
7+
@Component({
8+
selector: 'flight-app',
9+
templateUrl: './app.component.html',
10+
styleUrls: ['./app.component.css']
11+
})
12+
export class AppComponent {
13+
public info: string = 'Welt';
14+
15+
public showWaitInfo: boolean = false;
16+
17+
constructor(private router: Router, private oauthService: OAuthService, private leaveComponentGuard: LeaveComponentGuard ) {
18+
19+
router.events.subscribe(
20+
(event) => {
21+
22+
console.debug('router-event', event);
23+
24+
if (event instanceof NavigationStart) {
25+
this.showWaitInfo = true;
26+
}
27+
if (event instanceof NavigationEnd
28+
|| event instanceof NavigationCancel
29+
|| event instanceof NavigationError) {
30+
this.showWaitInfo = false;
31+
}
32+
33+
}
34+
);
35+
36+
leaveComponentGuard.guardStated.subscribe(_ => {
37+
this.showWaitInfo = false;
38+
});
39+
40+
leaveComponentGuard.guardFinished.subscribe(_ => {
41+
this.showWaitInfo = true;
42+
});
43+
44+
oauthService.loginUrl = '';
45+
46+
47+
this.oauthService.loginUrl = 'https://steyer-identity-server.azurewebsites.net/identity/connect/authorize'; // Id-Provider?
48+
49+
this.oauthService.redirectUri = window.location.origin + '/index.html';
50+
51+
this.oauthService.clientId = 'spa-demo';
52+
53+
this.oauthService.issuer = 'https://steyer-identity-server.azurewebsites.net/identity';
54+
55+
// set the scope for the permissions the client should request
56+
this.oauthService.scope = 'openid profile email voucher';
57+
58+
// set to true, to receive also an id_token via OpenId Connect (OIDC) in addition to the
59+
// OAuth2-based access_token
60+
this.oauthService.oidc = true;
61+
62+
// Use setStorage to use sessionStorage or another implementation of the TS-type Storage
63+
// instead of localStorage
64+
this.oauthService.setStorage(sessionStorage);
65+
66+
// To also enable single-sign-out set the url for your auth-server's logout-endpoint here
67+
this.oauthService.logoutUrl = 'https://steyer-identity-server.azurewebsites.net/identity/connect/endsession?id_token={{id_token}}';
68+
69+
// This method just tries to parse the token within the url when
70+
// the auth-server redirects the user back to the web-app
71+
// It dosn't initiate the login
72+
this.oauthService.tryLogin({});
73+
74+
}
75+
76+
goHome() {
77+
this.router.navigate(['/home']);
78+
}
79+
80+
activateExpertMode() {
81+
let queryParams = {
82+
expertMode: 'true'
83+
};
84+
this.router.navigate([], {queryParams});
85+
}
86+
87+
deactivateExpertMode() {
88+
let queryParams = {
89+
expertMode: 'false'
90+
};
91+
this.router.navigate([], {queryParams});
92+
// , fragment: '123'
93+
94+
}
95+
96+
}
97+
98+
99+

app/app.module.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { AppComponent } from './app.component';
2+
import { NgModule } from '@angular/core';
3+
import { BrowserModule } from '@angular/platform-browser';
4+
import { HttpModule } from '@angular/http';
5+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
6+
import { BASE_URL } from './app.tokens';
7+
import { SharedModule } from './shared/shared.module';
8+
import { AppRouterModule } from './app.routes';
9+
import { HomeComponent } from './home/home.component';
10+
import { FlightHistoryComponent } from './flight-history/flight-history.component';
11+
import { BookingsComponent } from './bookings/bookings.component';
12+
import { FlightBookingModule } from './flight-booking/flight-booking.module';
13+
import { ChatComponent } from './flight-booking/chat/chat.component';
14+
import {RouteReuseStrategy} from "@angular/router";
15+
import {CustomReuseStrategy} from "./shared/router/custom-reuse-strategy";
16+
17+
@NgModule({
18+
imports: [
19+
BrowserModule,
20+
HttpModule,
21+
FormsModule,
22+
ReactiveFormsModule,
23+
SharedModule.forRoot(),
24+
AppRouterModule,
25+
//FlightBookingModule // <-- Würde Lazy Loading verhindern
26+
],
27+
declarations: [
28+
AppComponent,
29+
HomeComponent,
30+
BookingsComponent,
31+
FlightHistoryComponent
32+
],
33+
providers: [
34+
{provide: BASE_URL, useValue: 'http://www.angular.at'},
35+
{provide: RouteReuseStrategy, useClass: CustomReuseStrategy}
36+
],
37+
bootstrap: [
38+
AppComponent
39+
]
40+
})
41+
export class AppModule {
42+
}

app/app.routes.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {Routes, RouterModule, PreloadAllModules} from "@angular/router";
2+
import {HomeComponent} from "./home/home.component";
3+
import {FlightHistoryComponent} from "./flight-history/flight-history.component";
4+
import {CustomPreloadingStrategy} from "./shared/preload/custom-preloading.strategy";
5+
import {AuthLoadGuard} from "./shared/auth/auth.load.guard";
6+
import {BookingsComponent} from "./bookings/bookings.component";
7+
import {AuthChildGuard} from "./shared/auth/auth.child.guard";
8+
9+
let APP_ROUTES: Routes = [
10+
{
11+
path: '',
12+
redirectTo: 'home',
13+
pathMatch: 'full'
14+
},
15+
{
16+
path: 'home',
17+
component: HomeComponent
18+
},
19+
20+
{
21+
path: 'flight-booking',
22+
loadChildren: './flight-booking/flight-booking.module#FlightBookingModule',
23+
// canLoad: [AuthLoadGuard]
24+
},
25+
26+
{
27+
path: 'bookings',
28+
component: BookingsComponent
29+
},
30+
{
31+
path: 'history',
32+
component: FlightHistoryComponent,
33+
outlet: 'aux'
34+
},
35+
36+
{
37+
path: '**',
38+
redirectTo: 'home'
39+
}
40+
];
41+
42+
export let AppRouterModule = RouterModule.forRoot(APP_ROUTES);
43+
44+
// export let AppRouterModule = RouterModule.forRoot(APP_ROUTES, { useHash: true, enableTracing: true});

app/app.tokens.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { OpaqueToken } from '@angular/core';
2+
3+
export const BASE_URL = new OpaqueToken('BASE_URL');
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ComponentFixture, TestBed, ComponentFixtureAutoDetect } from '@angular/core/testing';
2+
import { By } from '@angular/platform-browser';
3+
4+
import { BookingsComponent } from './bookings.component';
5+
6+
let fixture: ComponentFixture<BookingsComponent>;
7+
let componentTitle: HTMLElement;
8+
let componentInstance: BookingsComponent;
9+
10+
describe('BookingsComponent', () => {
11+
beforeEach(() => {
12+
TestBed.configureTestingModule({
13+
declarations: [BookingsComponent],
14+
providers: [
15+
{provide: ComponentFixtureAutoDetect, useValue: true}
16+
]
17+
});
18+
fixture = TestBed.createComponent(BookingsComponent);
19+
componentTitle = fixture.debugElement.query(By.css('h1')).nativeElement;
20+
componentInstance = fixture.componentInstance;
21+
});
22+
23+
it('should display Bookings title', () => {
24+
expect(componentTitle.textContent).toBe('Bookings');
25+
});
26+
27+
it('should change Bookings title', () => {
28+
componentInstance.title = 'changed title';
29+
fixture.detectChanges();
30+
expect(componentTitle.textContent).toBe('changed title');
31+
});
32+
33+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { By } from '@angular/platform-browser';
3+
4+
import { BookingsComponent } from './bookings.component';
5+
6+
let fixture: ComponentFixture<BookingsComponent>;
7+
let componentTitle: HTMLElement;
8+
let componentInstance: BookingsComponent;
9+
10+
describe('BookingsComponent', () => {
11+
beforeEach(() => {
12+
TestBed.configureTestingModule({
13+
declarations: [BookingsComponent]
14+
});
15+
fixture = TestBed.createComponent(BookingsComponent);
16+
componentTitle = fixture.debugElement.query(By.css('h1')).nativeElement;
17+
componentInstance = fixture.componentInstance;
18+
});
19+
20+
it('should display Bookings title', () => {
21+
expect(componentTitle.textContent).toBe('');
22+
fixture.detectChanges();
23+
expect(componentTitle.textContent).toBe('Bookings');
24+
});
25+
26+
it('should change Bookings title', () => {
27+
componentInstance.title = 'changed title';
28+
fixture.detectChanges();
29+
expect(componentTitle.textContent).toBe('changed title');
30+
});
31+
32+
});

app/bookings/bookings.component.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
template: `
5+
<h1>{{title}}</h1>
6+
7+
<div class="control-group">
8+
<label>Your Passenger Number</label>
9+
<input class="form-control" [(ngModel)]="passengerNumber">
10+
</div>
11+
<p>&nbsp;</p>
12+
<p>&nbsp;</p>
13+
<div>This use case is under construction ...</div>
14+
`
15+
})
16+
export class BookingsComponent {
17+
title = 'Bookings';
18+
passengerNumber: string;
19+
}

app/custom-typings.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// to support require.context
2+
interface NodeRequire {
3+
context: any;
4+
}

app/entities/flight.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface Flight {
2+
id: number; // int + double
3+
from: string;
4+
to: string;
5+
date: string;
6+
// JSON: ISO-String 2016-12-24T17:00:00.000+01:00
7+
}

0 commit comments

Comments
 (0)