Skip to content

Commit 59ec6d3

Browse files
authored
feat(AoT): ✨ ✨ added initial AoT support any many other things (#151)
* wip - aot upgrade currently facing issues like angular/angular-cli#5802 cannot find browser-app.module.ngfactory * feat(AoT): ✨ ✨ added initial AoT support any many other things Added Bootstrap with SCSS / SASS support Added ng2-bootstrap Passing Server originURL so that URLs can use it (when 4.1 comes out with HttpInterceptors this will be even easier to do) ✨ AoT added ! for prod (npm run build:aot) - Still need to test this for Azure deployments etc Removed es6-shim added core-js
1 parent 372ceeb commit 59ec6d3

Some content is hidden

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

48 files changed

+91996
-368
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
*.userprefs
1414

1515
# yarn
16-
.yarn.lock
16+
yarn.lock
17+
18+
npm-debug.log.*
1719

1820
# Build results
1921
[Dd]ebug/

Asp2017.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<!-- Files not to publish (note that the 'dist' subfolders are re-added below) -->
2121
<Content Remove="Client\**" />
2222
</ItemGroup>
23+
<ItemGroup>
24+
<Content Include="Client\tsconfig.browser.json" />
25+
<Content Include="Client\tsconfig.server.aot.json" />
26+
<Content Include="Client\tsconfig.server.json" />
27+
</ItemGroup>
2328
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
2429
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2530
<Exec Command="npm install" />

Client/app/app.component.css

Whitespace-only changes.

Client/app/app.component.scss

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
/* Import Bootstrap & Fonts */
3+
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';
4+
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
5+
6+
7+
/* *** Overall APP Styling can go here ***
8+
--------------------------------------------
9+
Note: This Component has ViewEncapsulation.None so the styles will bleed out
10+
11+
*/
12+
13+
body { background: #f1f1f1; line-height: 18px; }
14+
ul { padding: 10px 25px; }
15+
ul li { padding: 5px 0; }
16+
17+
h1 { border-bottom: 5px #4189C7 solid; }
18+
h1, h2, h3 { padding: 10px 0; }
19+
20+
blockquote { margin: 25px 10px; padding: 10px 35px 10px 10px; border-left: 10px #158a15 solid; background: #edffed; }
21+
blockquote a, blockquote a:hover { color: #068006; }

Client/app/app.component.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID } from '@angular/core';
1+
import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID } from '@angular/core';
22
import { Router, NavigationEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router';
33
import { Meta, Title, DOCUMENT, MetaDefinition } from '@angular/platform-browser';
44
import { Subscription } from 'rxjs/Subscription';
@@ -8,7 +8,8 @@ import { LinkService } from './shared/link.service';
88
@Component({
99
selector: 'app',
1010
templateUrl: './app.component.html',
11-
styleUrls: ['./app.component.css']
11+
styleUrls: ['./app.component.scss'],
12+
encapsulation: ViewEncapsulation.None
1213
})
1314
export class AppComponent implements OnInit, OnDestroy {
1415

@@ -17,16 +18,14 @@ export class AppComponent implements OnInit, OnDestroy {
1718
// If no Title is provided, we'll use a default one before the dash(-)
1819
private defaultPageTitle: string = 'My App';
1920

20-
private sub: Subscription;
21-
private isServer: boolean = isPlatformServer(this.platform_id);
21+
private routerSub$: Subscription;
2222

2323
constructor(
24-
public router: Router,
25-
public activatedRoute: ActivatedRoute,
24+
private router: Router,
25+
private activatedRoute: ActivatedRoute,
2626
private title: Title,
2727
private meta: Meta,
28-
private linkService: LinkService,
29-
@Inject(PLATFORM_ID) private platform_id
28+
private linkService: LinkService
3029
) { }
3130

3231
ngOnInit() {
@@ -37,12 +36,12 @@ export class AppComponent implements OnInit, OnDestroy {
3736

3837
ngOnDestroy() {
3938
// Subscription clean-up
40-
this.sub.unsubscribe();
39+
this.routerSub$.unsubscribe();
4140
}
4241

4342
private _changeTitleOnNavigation() {
4443

45-
this.sub = this.router.events
44+
this.routerSub$ = this.router.events
4645
.filter(event => event instanceof NavigationEnd)
4746
.map(() => this.activatedRoute)
4847
.map(route => {

Client/app/app.module.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { RouterModule } from '@angular/router';
33
import { CommonModule } from '@angular/common';
44
import { HttpModule } from '@angular/http';
55
import { FormsModule } from '@angular/forms';
66

7+
import { Ng2BootstrapModule } from 'ng2-bootstrap';
8+
79
import { AppComponent } from './app.component';
810
import { NavMenuComponent } from './components/navmenu/navmenu.component';
911
import { HomeComponent } from './containers/home/home.component';
1012
import { UsersComponent } from './containers/users/users.component';
1113
import { CounterComponent } from './containers/counter/counter.component';
1214
import { ChatComponent } from './containers/chat/chat.component';
15+
import { Ng2BootstrapComponent } from './containers/ng2-bootstrap-demo/ng2bootstrap.component';
1316

1417
import { LinkService } from './shared/link.service';
1518
import { ConnectionResolver } from './shared/route.resolver';
@@ -21,12 +24,15 @@ import { ConnectionResolver } from './shared/route.resolver';
2124
CounterComponent,
2225
UsersComponent,
2326
HomeComponent,
24-
ChatComponent
27+
ChatComponent,
28+
Ng2BootstrapComponent
2529
],
2630
imports: [
2731
CommonModule,
2832
HttpModule,
2933
FormsModule,
34+
Ng2BootstrapModule.forRoot(), // You could also split this up if you don't want the Entire Module imported
35+
3036
// App Routing
3137
RouterModule.forRoot([
3238
{
@@ -86,6 +92,18 @@ import { ConnectionResolver } from './shared/route.resolver';
8692
]
8793
}
8894
},
95+
{
96+
path: 'ng2-bootstrap', component: Ng2BootstrapComponent,
97+
data: {
98+
title: 'Ng2-bootstrap demo!!',
99+
meta: [{ name: 'description', content: 'This is an Demo Bootstrap page Description!' }],
100+
links: [
101+
{ rel: 'canonical', href: 'http://blogs.example.com/bootstrap/something' },
102+
{ rel: 'alternate', hreflang: 'es', href: 'http://es.example.com/bootstrap-demo' }
103+
]
104+
}
105+
},
106+
89107
// All else fails - go home!
90108
{ path: '**', redirectTo: 'home' }
91109
])

Client/app/browser-app.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export function createConfig(): SignalRConfiguration {
2828
BrowserAnimationsModule,
2929
// Our Common AppModule
3030
AppModule,
31-
32-
SignalRModule.forRoot(() => createConfig())
31+
32+
SignalRModule.forRoot(createConfig)
3333
],
3434
providers: [
3535
{
@@ -39,5 +39,5 @@ export function createConfig(): SignalRConfiguration {
3939
}
4040
]
4141
})
42-
export class AppBrowserModule {
42+
export class BrowserAppModule {
4343
}

Client/app/components/navmenu/navmenu.component.html

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class='main-nav'>
1+
<div class='main-nav'>
22
<div class='navbar'>
33
<div class='navbar-header'>
44
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'>
@@ -24,9 +24,14 @@
2424
</li>
2525
<li [routerLinkActive]="['link-active']">
2626
<a [routerLink]="['/users']">
27-
<span class='glyphicon glyphicon-user'></span> Users
27+
<span class='glyphicon glyphicon-user'></span> REST API Demo
2828
</a>
2929
</li>
30+
<li [routerLinkActive]="['link-active']">
31+
<a [routerLink]="['/ng2-bootstrap']">
32+
<span class='glyphicon glyphicon-user'></span> ng2-Bootstrap demo
33+
</a>
34+
</li>
3035
<!--<li [routerLinkActive]="['link-active']">
3136
<a [routerLink]="['/chat']">
3237
<span class='glyphicon glyphicon-comment'></span> Chat

Client/app/containers/chat/chat.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ <h2>SignalR chat example</h2>
1313
<!--<span chatMessage="chat-img pull-left">
1414
<img src="http://placehold.it/50/55C1E7/fff&text=U" alt="User Avatar" class="img-circle" />
1515
</span>-->
16+
1617
<div class="chat-body clearfix">
1718
<div class="header">
1819
<strong class="primary-font">{{message.user}}</strong>

Client/app/containers/chat/chat.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, Inject } from '@angular/core';
1+
import { Component, OnInit, Inject } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
33

44
import { SignalR, BroadcastEventListener, SignalRConnection } from 'ng2-signalr';

Client/app/containers/counter/counter.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../../../../node_modules/@types/jasmine/index.d.ts" />
1+
/// <reference path="../../../../node_modules/@types/jasmine/index.d.ts" />
22
import { assert } from 'chai';
33
import { CounterComponent } from './counter.component';
44
import { TestBed, async, ComponentFixture } from '@angular/core/testing';

Client/app/containers/fetchdata/fetchdata.component.ts

-51
This file was deleted.

Client/app/containers/home/home.component.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+

22
<h1>{{ title }}</h1>
33

44
<blockquote>
@@ -14,13 +14,13 @@ <h1>{{ title }}</h1>
1414
<div class="col-lg-6">
1515
<h2>What does this Starter offer? </h2>
1616
<ul>
17-
<li>ASP.NET Core 1.0 :: ( Visual Studio 2017 )</li>
17+
<li>ASP.NET Core 1.1 :: ( Visual Studio 2017 )</li>
1818
<li>
1919
Angular 4.* front-end UI framework
2020
<ul>
2121
<li>Angular **platform-server** (Universal moved into Core here) - server-side rendering for SEO, deep-linking, and incredible performance.</li>
22-
<li>HMR State Management - Don't lose your applications state during HMR!</li>
23-
<li>AoT (Ahead-of-time) production compilation for even faster prod builds.</li>
22+
<!--<li>HMR State Management - Don't lose your applications state during HMR!</li>-->
23+
<li>AoT (Ahead-of-time) production compilation for even faster Prod builds.</li>
2424
</ul>
2525
</li>
2626
<li>
@@ -36,7 +36,7 @@ <h2>What does this Starter offer? </h2>
3636
Webpack 2
3737
<ul>
3838
<!--<li>TS2 aware path support</li>-->
39-
<li>Hot Module Reloading/Replacement for an amazing dev experience.</li>
39+
<li>Hot Module Reloading/Replacement for an amazing development experience.</li>
4040
<li>Tree-shaking</li>
4141
</ul>
4242
</li>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<h1>Ng2-bootstrap Demo:</h1>
2+
3+
<blockquote>
4+
<strong>Here we're using Bootstrap via <a href="https://github.com/valor-software/ng2-bootstrap">ng2-bootstrap</a>, which can even be rendered on the server!</strong>
5+
<br>
6+
</blockquote>
7+
8+
<hr>
9+
<br><br>
10+
11+
<h3>Bootstrap Accordion demo:</h3>
12+
13+
<p>
14+
<button type="button" class="btn btn-primary btn-sm"
15+
(click)="group.isOpen = !group.isOpen">
16+
Toggle last panel
17+
</button>
18+
<button type="button" class="btn btn-primary btn-sm"
19+
(click)="status.isFirstDisabled = ! status.isFirstDisabled">
20+
Enable / Disable first panel
21+
</button>
22+
</p>
23+
24+
<div class="checkbox">
25+
<label>
26+
<input type="checkbox" [(ngModel)]="oneAtATime">
27+
Open only one at a time
28+
</label>
29+
</div>
30+
31+
32+
<accordion [closeOthers]="oneAtATime">
33+
<accordion-group heading="Static Header, initially expanded"
34+
[isOpen]="status.isFirstOpen"
35+
[isDisabled]="status.isFirstDisabled">
36+
This content is straight in the template.
37+
</accordion-group>
38+
<accordion-group *ngFor="let group of groups" [heading]="group.title">
39+
{{ group?.content }}
40+
</accordion-group>
41+
<accordion-group heading="Dynamic Body Content">
42+
<p>The body of the accordion group grows to fit the contents</p>
43+
<button type="button" class="btn btn-primary btn-sm" (click)="addItem()">Add Item</button>
44+
<div *ngFor="let item of items">{{item}}</div>
45+
</accordion-group>
46+
<accordion-group #group [isOpen]="status.open">
47+
<div accordion-heading>
48+
I can have markup, too!
49+
<i class="pull-right glyphicon"
50+
[ngClass]="{'glyphicon-chevron-down': group?.isOpen, 'glyphicon-chevron-right': !group?.isOpen}"></i>
51+
</div>
52+
This is just some content to illustrate fancy headings.
53+
</accordion-group>
54+
</accordion>

0 commit comments

Comments
 (0)