Skip to content

Commit 86e014e

Browse files
committed
adding superhero problem application
1 parent 6e91410 commit 86e014e

38 files changed

+988
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Thumbs.db
3232
build
3333
dist
3434
temp
35+
tmp
3536
node_modules
3637
bower_components
3738

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* global require, module */
2+
3+
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
4+
5+
module.exports = function(defaults) {
6+
var app = new Angular2App(defaults, {
7+
vendorNpmFiles: []
8+
});
9+
return app.toTree();
10+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"routes": []
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* jshint node: true */
2+
3+
module.exports = function(environment) {
4+
return {
5+
environment: environment,
6+
baseURL: '/',
7+
locationType: 'auto'
8+
};
9+
};
10+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { AmiSuperheroPage } from './app.po';
2+
3+
describe('ami-superhero App', function() {
4+
let page: AmiSuperheroPage;
5+
6+
beforeEach(() => {
7+
page = new AmiSuperheroPage();
8+
})
9+
10+
it('should display message saying app works', () => {
11+
page.navigateTo();
12+
expect(page.getParagraphText()).toEqual('ami-superhero Works!');
13+
});
14+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class AmiSuperheroPage {
2+
navigateTo() {
3+
return browser.get('/');
4+
}
5+
6+
getParagraphText() {
7+
return element(by.css('ami-superhero-app p')).getText();
8+
}
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"declaration": false,
5+
"emitDecoratorMetadata": true,
6+
"experimentalDecorators": true,
7+
"mapRoot": "",
8+
"module": "commonjs",
9+
"moduleResolution": "node",
10+
"noEmitOnError": true,
11+
"noImplicitAny": false,
12+
"rootDir": ".",
13+
"sourceMap": true,
14+
"sourceRoot": "/",
15+
"target": "es5"
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../typings/main.d.ts" />
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*global jasmine, __karma__, window*/
2+
Error.stackTraceLimit = Infinity;
3+
4+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
5+
6+
__karma__.loaded = function () {
7+
};
8+
9+
System.config({
10+
packages: {
11+
'base/dist/app': {
12+
defaultExtension: false,
13+
format: 'register',
14+
map: Object.keys(window.__karma__.files)
15+
.filter(onlyAppFiles)
16+
.reduce(function (pathsMapping, appPath) {
17+
var moduleName = appPath.replace(/^\/base\/dist\/app\//, './').replace(/\.js$/, '');
18+
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath];
19+
return pathsMapping;
20+
}, {})
21+
}
22+
}
23+
});
24+
25+
System.import('angular2/testing').then(function (testing) {
26+
return System.import('angular2/platform/testing/browser').then(function (providers) {
27+
testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS,
28+
providers.TEST_BROWSER_APPLICATION_PROVIDERS);
29+
});
30+
}).then(function () {
31+
return Promise.all(
32+
Object.keys(window.__karma__.files)
33+
.filter(onlySpecFiles)
34+
.map(function (moduleName) {
35+
return System.import(moduleName);
36+
}));
37+
}).then(function () {
38+
__karma__.start();
39+
}, function (error) {
40+
__karma__.error(error.stack || error);
41+
});
42+
43+
function onlyAppFiles(filePath) {
44+
return /^\/base\/dist\/app\/(?!.*\.spec\.js$)([a-z0-9-_\.\/]+)\.js$/.test(filePath);
45+
}
46+
47+
function onlySpecFiles(path) {
48+
return /\.spec\.js$/.test(path);
49+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module.exports = function (config) {
2+
config.set({
3+
basePath: '',
4+
frameworks: ['jasmine'],
5+
plugins: [
6+
require('karma-jasmine'),
7+
require('karma-chrome-launcher')
8+
],
9+
customLaunchers: {
10+
// chrome setup for travis CI using chromium
11+
Chrome_travis_ci: {
12+
base: 'Chrome',
13+
flags: ['--no-sandbox']
14+
}
15+
},
16+
files: [
17+
{ pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true },
18+
{ pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true },
19+
{ pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true },
20+
{ pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true },
21+
{ pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true },
22+
{ pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true },
23+
{ pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true },
24+
{ pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true },
25+
{ pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true },
26+
27+
28+
{ pattern: 'karma-test-shim.js', included: true, watched: true },
29+
30+
// paths loaded via module imports
31+
{ pattern: 'dist/**/*.js', included: false, watched: true },
32+
33+
// paths loaded via Angular's component compiler
34+
// (these paths need to be rewritten, see proxies section)
35+
{ pattern: 'dist/**/*.html', included: false, watched: true },
36+
{ pattern: 'dist/**/*.css', included: false, watched: true },
37+
38+
// paths to support debugging with source maps in dev tools
39+
{ pattern: 'dist/**/*.ts', included: false, watched: false },
40+
{ pattern: 'dist/**/*.js.map', included: false, watched: false }
41+
],
42+
proxies: {
43+
// required for component assets fetched by Angular's compiler
44+
'/app/': '/base/dist/app/'
45+
},
46+
exclude: [],
47+
preprocessors: {},
48+
reporters: ['progress'],
49+
port: 9876,
50+
colors: true,
51+
logLevel: config.LOG_INFO,
52+
autoWatch: true,
53+
browsers: ['Chrome'],
54+
singleRun: false
55+
});
56+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "ami-superhero",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"angular-cli": {},
6+
"scripts": {
7+
"start": "ng server",
8+
"postinstall": "typings install --ambient",
9+
"lint": "tslint \"src/**/*.ts\"",
10+
"format": "clang-format -i -style=file --glob=src/**/*.ts",
11+
"pree2e": "webdriver-manager update",
12+
"e2e": "protractor"
13+
},
14+
"private": true,
15+
"dependencies": {
16+
"angular2": "2.0.0-beta.16",
17+
"es6-shim": "^0.35.0",
18+
"glob": "^7.0.3",
19+
"reflect-metadata": "0.1.2",
20+
"rxjs": "5.0.0-beta.2",
21+
"systemjs": "0.19.20",
22+
"zone.js": "^0.6.12"
23+
},
24+
"devDependencies": {
25+
"angular-cli": "0.0.*",
26+
"clang-format": "^1.0.35",
27+
"codelyzer": "0.0.12",
28+
"ember-cli-inject-live-reload": "^1.4.0",
29+
"jasmine-core": "^2.3.4",
30+
"jasmine-spec-reporter": "^2.4.0",
31+
"karma": "^0.13.15",
32+
"karma-chrome-launcher": "^0.2.1",
33+
"karma-jasmine": "^0.3.6",
34+
"protractor": "^3.0.0",
35+
"ts-node": "^0.5.5",
36+
"tslint": "^3.6.0",
37+
"typescript": "^1.8.7",
38+
"typings": "^0.6.6"
39+
}
40+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*global jasmine */
2+
var SpecReporter = require('jasmine-spec-reporter');
3+
4+
exports.config = {
5+
allScriptsTimeout: 11000,
6+
specs: [
7+
'e2e/**/*.e2e.ts'
8+
],
9+
capabilities: {
10+
'browserName': 'chrome'
11+
},
12+
directConnect: true,
13+
baseUrl: 'http://localhost:4200/',
14+
framework: 'jasmine',
15+
jasmineNodeOpts: {
16+
showColors: true,
17+
defaultTimeoutInterval: 30000,
18+
print: function() {}
19+
},
20+
useAllAngular2AppRoots: true,
21+
beforeLaunch: function() {
22+
require('ts-node').register({
23+
project: 'e2e'
24+
});
25+
},
26+
onPrepare: function() {
27+
jasmine.getEnv().addReporter(new SpecReporter());
28+
}
29+
};

example-apps/ami-superhero/public/.npmignore

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {bootstrap} from 'angular2/platform/browser';
2+
import {AmiSuperheroApp} from './app/ami-superhero';
3+
4+
bootstrap(AmiSuperheroApp, []);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<router-outlet></router-outlet>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// import {describe, it, expect, beforeEachProviders, inject} from 'angular2/testing';
2+
// import {AmiSuperheroApp} from '../app/ami-superhero';
3+
4+
// beforeEachProviders(() => [AmiSuperheroApp]);
5+
6+
// describe('App: AmiSuperhero', () => {
7+
// it('should have the `defaultMeaning` as 42', inject([AmiSuperheroApp], (app: AmiSuperheroApp) => {
8+
// expect(app.defaultMeaning).toBe(42);
9+
// }));
10+
11+
// describe('#meaningOfLife', () => {
12+
// it('should get the meaning of life', inject([AmiSuperheroApp], (app: AmiSuperheroApp) => {
13+
// expect(app.meaningOfLife()).toBe('The meaning of life is 42');
14+
// expect(app.meaningOfLife(22)).toBe('The meaning of life is 22');
15+
// }));
16+
// });
17+
// });
18+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {Component} from 'angular2/core';
2+
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router}
3+
from 'angular2/router';
4+
5+
import {GameService, Player} from './services/game-service';
6+
import HerosService from './services/heros-service';
7+
import VillansService from './services/villans-service';
8+
9+
import Home from './components/home/home';
10+
import About from './components/about/about';
11+
import Game from './components/game/game';
12+
import Scores from './components/scores/scores';
13+
14+
@Component({
15+
selector: 'ami-superhero-app',
16+
providers: [ROUTER_PROVIDERS, HerosService, VillansService, GameService],
17+
// providers: [ROUTER_PROVIDERS],
18+
templateUrl: 'app/ami-superhero.html',
19+
directives: [ROUTER_DIRECTIVES],
20+
pipes: [],
21+
styles: [`
22+
.row {
23+
display: flex;
24+
margin-top: 0.5rem;
25+
}
26+
`]
27+
})
28+
@RouteConfig([
29+
{ path: '/', component: Home, as: 'Home' },
30+
{ path: '/games/:count', component: Game, as: 'Game' },
31+
{ path: '/about', component: About, as: 'About' },
32+
{ path: '/scores/:type', component: Scores, as: 'Scores' },
33+
])
34+
export class AmiSuperheroApp {
35+
constructor(
36+
private router: Router
37+
) { }
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {Component} from 'angular2/core';
2+
3+
@Component({
4+
selector: 'about',
5+
template: 'app/ami-superhero.html'
6+
})
7+
export default class About {
8+
9+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {Component, EventEmitter} from 'angular2/core';
2+
3+
@Component({
4+
selector: 'game-button',
5+
inputs: ['label', 'type'],
6+
outputs: ['onClick'],
7+
styles: [ `
8+
.button {
9+
border: none;
10+
border-radius: 3px;
11+
color: white;
12+
font-weight: bold;
13+
letter-spacing: .2em;
14+
margin-left: 0.5rem;
15+
padding: 1rem;
16+
text-transform: uppercase;
17+
background: #E5373A;
18+
font-size: 20px;
19+
}
20+
.button-green {
21+
background: #009100;
22+
}
23+
`],
24+
template: `
25+
<button
26+
class="button"
27+
[ngClass]="{'button-green': type == true}"
28+
(click)="onClick.emit(type)">
29+
{{label}}
30+
</button>
31+
`
32+
})
33+
export default class GameButton {
34+
onClick = new EventEmitter();
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Component} from 'angular2/core';
2+
3+
@Component({
4+
selector: 'game-title',
5+
inputs: ['title'],
6+
styles: [`
7+
.title {
8+
display: block important;
9+
text-align: center;
10+
margin: 0px;
11+
padding: 0px;
12+
font-weight: 600;
13+
letter-spacing: 0.02em;
14+
font-size: 70px;
15+
padding-top: 30px;
16+
}
17+
`],
18+
template: `
19+
<p class="title">{{title}}</p>
20+
`
21+
})
22+
export default class GameTitle {
23+
}

0 commit comments

Comments
 (0)