-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial Angular Playground functionality
- Loading branch information
Dan Wahlin
authored and
Dan Wahlin
committed
Nov 21, 2017
1 parent
5a891a4
commit bcfd4e5
Showing
13 changed files
with
198 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# NPM | ||
node_modules | ||
npm-debug.log | ||
sandboxes.ts | ||
|
||
# Code Editor Settings | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ | |
"**/config/*.js": { | ||
"when": "$(basename).js.map" | ||
} | ||
}, | ||
"typescript.check.tscVersion": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"sourceRoot": "./src", | ||
"angularCli": { | ||
"appName": "playground" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { sandboxOf } from 'angular-playground'; | ||
import { AboutComponent } from './about.component'; | ||
|
||
export default sandboxOf(AboutComponent) | ||
.add('About Component', { | ||
template: `<cm-about>Hey playground!</cm-about>` | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { sandboxOf } from 'angular-playground'; | ||
import { SharedModule } from '../shared/shared.module'; | ||
import { CoreModule } from '../core/core.module'; | ||
import { DataService } from '../core/services/data.service'; | ||
import { CustomerDetailsComponent } from './customer-details.component'; | ||
import { MockDataService, MockActivatedRoute, getActivatedRouteWithParent } from '../shared/mocks'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
const sandboxConfig = { | ||
imports: [ SharedModule, CoreModule ], | ||
providers: [ | ||
{ provide: DataService, useClass: MockDataService }, | ||
{ provide: ActivatedRoute, useFactory: () => { | ||
let route = getActivatedRouteWithParent([{ id: '1' }]); | ||
return route; | ||
}} | ||
], | ||
label: 'Customer Details Component' | ||
}; | ||
|
||
export default sandboxOf(CustomerDetailsComponent, sandboxConfig) | ||
.add('With a Customer', { | ||
template: `<cm-customer-details></cm-customer-details>` | ||
}) | ||
.add('Without a Customer', { | ||
template: `<cm-customer-details></cm-customer-details>`, | ||
providers: [ | ||
{ provide: ActivatedRoute, useFactory: () => { | ||
let route = getActivatedRouteWithParent([{ id: null }]); | ||
return route; | ||
}} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { sandboxOf } from 'angular-playground'; | ||
import { SharedModule } from '../shared/shared.module'; | ||
import { CoreModule } from '../core/core.module'; | ||
import { DataService } from '../core/services/data.service'; | ||
import { CustomerOrdersComponent } from './customer-orders.component'; | ||
import { MockDataService, MockActivatedRoute, getActivatedRouteWithParent } from '../shared/mocks'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
const sandboxConfig = { | ||
imports: [ SharedModule, CoreModule ], | ||
providers: [ | ||
{ provide: DataService, useClass: MockDataService }, | ||
{ provide: ActivatedRoute, useFactory: () => { | ||
let route = getActivatedRouteWithParent([{ id: '1' }]); | ||
return route; | ||
}} | ||
], | ||
label: 'Customer Orders Component' | ||
}; | ||
|
||
export default sandboxOf(CustomerOrdersComponent, sandboxConfig) | ||
.add('With Orders', { | ||
template: `<cm-customer-orders></cm-customer-orders>` | ||
}) | ||
.add('Without Orders', { | ||
template: `<cm-customer-orders></cm-customer-orders>`, | ||
providers: [ { provide: ActivatedRoute, useFactory: () => { | ||
let route = getActivatedRouteWithParent([{ id: null }]); | ||
return route; | ||
}}] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ActivatedRouteSnapshot, ActivatedRoute, UrlSegment, Params, Data, Route, ParamMap } from "@angular/router"; | ||
import { Observable } from "rxjs/Observable"; | ||
import { Type } from "@angular/core"; | ||
import { ICustomer } from "./interfaces"; | ||
|
||
export class MockDataService { | ||
getCustomer(id: number) : Observable<ICustomer> { | ||
console.log(id); | ||
if (id === 1) { | ||
return Observable.of({ | ||
"id": 1, | ||
"firstName": "ted", | ||
"lastName": "james", | ||
"gender": "male", | ||
"address": "1234 Anywhere St.", | ||
"city": " Phoenix ", | ||
"state": { | ||
"abbreviation": "AZ", | ||
"name": "Arizona" | ||
}, | ||
"orders": [ | ||
{"productName": "Basketball", "itemCost": 7.99}, | ||
{"productName": "Shoes", "itemCost": 199.99} | ||
], | ||
"latitude": 33.299, | ||
"longitude": -111.963 | ||
}); | ||
} | ||
else { | ||
return Observable.of(null); | ||
} | ||
} | ||
} | ||
|
||
export class MockActivatedRoute implements ActivatedRoute { | ||
snapshot : ActivatedRouteSnapshot; | ||
url : Observable<UrlSegment[]>; | ||
params : Observable<Params>; | ||
queryParams : Observable<Params>; | ||
fragment : Observable<string>; | ||
data : Observable<Data>; | ||
outlet : string; | ||
component : Type<any>|string; | ||
routeConfig : Route; | ||
root : ActivatedRoute; | ||
parent : ActivatedRoute; | ||
firstChild : ActivatedRoute; | ||
children : ActivatedRoute[]; | ||
pathFromRoot : ActivatedRoute[]; | ||
paramMap: Observable<ParamMap>; | ||
queryParamMap: Observable<ParamMap>; | ||
toString() : string{ | ||
return ""; | ||
}; | ||
} | ||
|
||
export function getActivatedRouteWithParent(params: any[]) { | ||
const route = new MockActivatedRoute(); | ||
route.parent = new MockActivatedRoute(); | ||
if (params) { | ||
for (const param of params) { | ||
//var keyNames = Object.keys(param); | ||
route.parent.params = Observable.of(param); | ||
} | ||
} | ||
|
||
return route; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { initializePlayground, PlaygroundModule } from 'angular-playground'; | ||
|
||
initializePlayground('cm-app-component'); | ||
platformBrowserDynamic().bootstrapModule(PlaygroundModule); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters