From f47b9ed446a97ca40b0ef5d99babcc62a9ef2cca Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 17:58:02 +0100 Subject: [PATCH 01/13] Firebase Angular TodoMVC added --- examples/firebase-angular2/.angular-cli.json | 57 ++++++++ examples/firebase-angular2/.editorconfig | 13 ++ examples/firebase-angular2/README.md | 38 +++++ .../firebase-angular2/e2e/app.e2e-spec.ts | 14 ++ examples/firebase-angular2/e2e/app.po.ts | 11 ++ .../firebase-angular2/e2e/tsconfig.e2e.json | 12 ++ examples/firebase-angular2/karma.conf.js | 33 +++++ examples/firebase-angular2/package.json | 53 +++++++ examples/firebase-angular2/protractor.conf.js | 28 ++++ .../src/app/app-routing.module.ts | 15 ++ .../src/app/app.component.html | 6 + .../src/app/app.component.ts | 11 ++ .../firebase-angular2/src/app/app.module.ts | 40 ++++++ .../todo-footer/todo-footer.component.html | 15 ++ .../todo-footer/todo-footer.component.ts | 52 +++++++ .../todo-header/todo-header.component.html | 4 + .../todo-header/todo-header.component.ts | 26 ++++ .../todo-item/todo-item.component.html | 9 ++ .../todo-item/todo-item.component.ts | 54 +++++++ .../todo-list/todo-list.component.html | 11 ++ .../todo-list/todo-list.component.ts | 50 +++++++ .../src/app/models/todo.model.ts | 9 ++ .../src/app/pipes/trim.pipe.ts | 12 ++ .../src/app/services/todo-store.service.ts | 101 +++++++++++++ .../firebase-angular2/src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 11 ++ .../src/environments/environment.ts | 16 +++ examples/firebase-angular2/src/favicon.ico | Bin 0 -> 5430 bytes examples/firebase-angular2/src/index.html | 17 +++ examples/firebase-angular2/src/main.ts | 11 ++ examples/firebase-angular2/src/polyfills.ts | 73 ++++++++++ examples/firebase-angular2/src/styles.css | 3 + examples/firebase-angular2/src/test.ts | 32 +++++ .../firebase-angular2/src/tsconfig.app.json | 13 ++ .../firebase-angular2/src/tsconfig.spec.json | 20 +++ examples/firebase-angular2/src/typings.d.ts | 5 + examples/firebase-angular2/tsconfig.json | 20 +++ examples/firebase-angular2/tslint.json | 135 ++++++++++++++++++ 38 files changed, 1030 insertions(+) create mode 100644 examples/firebase-angular2/.angular-cli.json create mode 100644 examples/firebase-angular2/.editorconfig create mode 100644 examples/firebase-angular2/README.md create mode 100644 examples/firebase-angular2/e2e/app.e2e-spec.ts create mode 100644 examples/firebase-angular2/e2e/app.po.ts create mode 100644 examples/firebase-angular2/e2e/tsconfig.e2e.json create mode 100644 examples/firebase-angular2/karma.conf.js create mode 100644 examples/firebase-angular2/package.json create mode 100644 examples/firebase-angular2/protractor.conf.js create mode 100644 examples/firebase-angular2/src/app/app-routing.module.ts create mode 100644 examples/firebase-angular2/src/app/app.component.html create mode 100644 examples/firebase-angular2/src/app/app.component.ts create mode 100644 examples/firebase-angular2/src/app/app.module.ts create mode 100644 examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.html create mode 100644 examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.ts create mode 100644 examples/firebase-angular2/src/app/components/todo-header/todo-header.component.html create mode 100644 examples/firebase-angular2/src/app/components/todo-header/todo-header.component.ts create mode 100644 examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html create mode 100644 examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts create mode 100644 examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html create mode 100644 examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts create mode 100644 examples/firebase-angular2/src/app/models/todo.model.ts create mode 100644 examples/firebase-angular2/src/app/pipes/trim.pipe.ts create mode 100644 examples/firebase-angular2/src/app/services/todo-store.service.ts create mode 100644 examples/firebase-angular2/src/assets/.gitkeep create mode 100644 examples/firebase-angular2/src/environments/environment.prod.ts create mode 100644 examples/firebase-angular2/src/environments/environment.ts create mode 100644 examples/firebase-angular2/src/favicon.ico create mode 100644 examples/firebase-angular2/src/index.html create mode 100644 examples/firebase-angular2/src/main.ts create mode 100644 examples/firebase-angular2/src/polyfills.ts create mode 100644 examples/firebase-angular2/src/styles.css create mode 100644 examples/firebase-angular2/src/test.ts create mode 100644 examples/firebase-angular2/src/tsconfig.app.json create mode 100644 examples/firebase-angular2/src/tsconfig.spec.json create mode 100644 examples/firebase-angular2/src/typings.d.ts create mode 100644 examples/firebase-angular2/tsconfig.json create mode 100644 examples/firebase-angular2/tslint.json diff --git a/examples/firebase-angular2/.angular-cli.json b/examples/firebase-angular2/.angular-cli.json new file mode 100644 index 0000000000..f9e933f490 --- /dev/null +++ b/examples/firebase-angular2/.angular-cli.json @@ -0,0 +1,57 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "project": { + "name": "firebase-angular2" + }, + "apps": [ + { + "root": "src", + "outDir": "dist", + "assets": [ + "assets", + "favicon.ico" + ], + "index": "index.html", + "main": "main.ts", + "polyfills": "polyfills.ts", + "test": "test.ts", + "tsconfig": "tsconfig.app.json", + "testTsconfig": "tsconfig.spec.json", + "prefix": "app", + "styles": [ + "styles.css" + ], + "scripts": [], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + } + ], + "e2e": { + "protractor": { + "config": "./protractor.conf.js" + } + }, + "lint": [ + { + "project": "src/tsconfig.app.json" + }, + { + "project": "src/tsconfig.spec.json" + }, + { + "project": "e2e/tsconfig.e2e.json" + } + ], + "test": { + "karma": { + "config": "./karma.conf.js" + } + }, + "defaults": { + "styleExt": "css", + "component": {} + } +} diff --git a/examples/firebase-angular2/.editorconfig b/examples/firebase-angular2/.editorconfig new file mode 100644 index 0000000000..6e87a003da --- /dev/null +++ b/examples/firebase-angular2/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/examples/firebase-angular2/README.md b/examples/firebase-angular2/README.md new file mode 100644 index 0000000000..a2d02471bc --- /dev/null +++ b/examples/firebase-angular2/README.md @@ -0,0 +1,38 @@ +# Firebase Angular2 • [TodoMVC](http://todomvc.com) + +> Official description of the framework (from its website) + + +## Resources + +- [Website]() +- [Documentation]() +- [Used by]() +- [Blog]() +- [FAQ]() + +### Articles + +- [Interesting article]() + +### Support + +#### Firebase + +* [Firebase on StackOverflow](http://stackoverflow.com/questions/tagged/firebase) +* [Google Groups mailing list](https://groups.google.com/forum/?fromgroups#!forum/firebase-talk) +* [Firebase on Twitter](https://twitter.com/Firebase) +* [Firebase on Facebook](https://facebook.com/Firebase) +* [Firebase on Google +](https://plus.google.com/115330003035930967645/posts) + +*Let us [know](https://github.com/tastejs/todomvc/issues) if you discover anything worth sharing.* + + +## Implementation + +How was the app created? Anything worth sharing about the process of creating the app? Any spec violations? + + +## Credit + +Created by [Pablo Albaladejo](https://github.com/pablo-albaladejo) diff --git a/examples/firebase-angular2/e2e/app.e2e-spec.ts b/examples/firebase-angular2/e2e/app.e2e-spec.ts new file mode 100644 index 0000000000..200b682463 --- /dev/null +++ b/examples/firebase-angular2/e2e/app.e2e-spec.ts @@ -0,0 +1,14 @@ +import { FirebaseAngular2Page } from './app.po'; + +describe('firebase-angular2 App', () => { + let page: FirebaseAngular2Page; + + beforeEach(() => { + page = new FirebaseAngular2Page(); + }); + + it('should display welcome message', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('Welcome to app!!'); + }); +}); diff --git a/examples/firebase-angular2/e2e/app.po.ts b/examples/firebase-angular2/e2e/app.po.ts new file mode 100644 index 0000000000..37794ec9c9 --- /dev/null +++ b/examples/firebase-angular2/e2e/app.po.ts @@ -0,0 +1,11 @@ +import { browser, by, element } from 'protractor'; + +export class FirebaseAngular2Page { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/examples/firebase-angular2/e2e/tsconfig.e2e.json b/examples/firebase-angular2/e2e/tsconfig.e2e.json new file mode 100644 index 0000000000..e2a9a2fc77 --- /dev/null +++ b/examples/firebase-angular2/e2e/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "node" + ] + } +} diff --git a/examples/firebase-angular2/karma.conf.js b/examples/firebase-angular2/karma.conf.js new file mode 100644 index 0000000000..4d9ab9d948 --- /dev/null +++ b/examples/firebase-angular2/karma.conf.js @@ -0,0 +1,33 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/0.13/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client:{ + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + reports: [ 'html', 'lcovonly' ], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/examples/firebase-angular2/package.json b/examples/firebase-angular2/package.json new file mode 100644 index 0000000000..4bd78c170d --- /dev/null +++ b/examples/firebase-angular2/package.json @@ -0,0 +1,53 @@ +{ + "name": "firebase-angular2", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "^4.0.0", + "@angular/common": "^4.0.0", + "@angular/compiler": "^4.0.0", + "@angular/core": "^4.0.0", + "@angular/forms": "^4.0.0", + "@angular/http": "^4.0.0", + "@angular/platform-browser": "^4.0.0", + "@angular/platform-browser-dynamic": "^4.0.0", + "@angular/router": "^4.0.0", + "angularfire2": "5.0.0-rc.3", + "core-js": "^2.4.1", + "enhanced-resolve": "3.3.0", + "firebase": "4.7.0", + "rxjs": "^5.1.0", + "todomvc-app-css": "^2.0.0", + "todomvc-common": "^1.0.1", + "zone.js": "^0.8.4" + }, + "devDependencies": { + "@angular/cli": "1.1.2", + "@angular/compiler-cli": "^4.0.0", + "@angular/language-service": "^4.0.0", + "@types/jasmine": "2.5.45", + "@types/node": "~6.0.60", + "codelyzer": "~3.0.1", + "jasmine-core": "~2.6.2", + "jasmine-spec-reporter": "~4.1.0", + "karma": "~1.7.0", + "karma-chrome-launcher": "~2.1.1", + "karma-cli": "~1.0.1", + "karma-jasmine": "~1.1.0", + "karma-jasmine-html-reporter": "^0.2.2", + "karma-coverage-istanbul-reporter": "^1.2.1", + "protractor": "~5.1.2", + "ts-node": "~3.0.4", + "tslint": "~5.3.2", + "typescript": "~2.3.3" + } +} \ No newline at end of file diff --git a/examples/firebase-angular2/protractor.conf.js b/examples/firebase-angular2/protractor.conf.js new file mode 100644 index 0000000000..7ee3b5ee86 --- /dev/null +++ b/examples/firebase-angular2/protractor.conf.js @@ -0,0 +1,28 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/examples/firebase-angular2/src/app/app-routing.module.ts b/examples/firebase-angular2/src/app/app-routing.module.ts new file mode 100644 index 0000000000..2b437ab324 --- /dev/null +++ b/examples/firebase-angular2/src/app/app-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +import { TodoListComponent } from './components/todo-list/todo-list.component'; + +export let routes = [ + { path: '', component: TodoListComponent, pathMatch: 'full' }, + { path: ':status', component: TodoListComponent } + ]; + +@NgModule({ + imports: [ RouterModule.forRoot(routes) ], + exports: [ RouterModule ] +}) +export class AppRoutingModule {} \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/app.component.html b/examples/firebase-angular2/src/app/app.component.html new file mode 100644 index 0000000000..0554152432 --- /dev/null +++ b/examples/firebase-angular2/src/app/app.component.html @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/app.component.ts b/examples/firebase-angular2/src/app/app.component.ts new file mode 100644 index 0000000000..d0324693e4 --- /dev/null +++ b/examples/firebase-angular2/src/app/app.component.ts @@ -0,0 +1,11 @@ +import { Component } from '@angular/core'; + +import 'rxjs/Rx'; + +@Component({ + selector: 'todo-app', + templateUrl: './app.component.html', +}) +export class AppComponent { + title = 'app'; +} diff --git a/examples/firebase-angular2/src/app/app.module.ts b/examples/firebase-angular2/src/app/app.module.ts new file mode 100644 index 0000000000..c582742191 --- /dev/null +++ b/examples/firebase-angular2/src/app/app.module.ts @@ -0,0 +1,40 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +import { AngularFireModule } from 'angularfire2'; +import { AngularFireDatabase } from 'angularfire2/database'; +import { environment } from '../environments/environment'; + +import { AppRoutingModule } from './app-routing.module'; + +import { AppComponent } from './app.component'; +import { TodoListComponent } from './components/todo-list/todo-list.component'; +import { TodoHeaderComponent } from './components/todo-header/todo-header.component'; +import { TodoItemComponent } from './components/todo-item/todo-item.component'; +import { TodoFooterComponent } from './components/todo-footer/todo-footer.component'; + +import { TodoStoreService } from './services/todo-store.service'; + +import { TrimPipe } from './pipes/trim.pipe'; + + +@NgModule({ + declarations: [ + AppComponent, + TodoListComponent, + TodoHeaderComponent, + TodoItemComponent, + TodoFooterComponent, + TrimPipe, + ], + imports: [ + FormsModule, + AppRoutingModule, + BrowserModule, + AngularFireModule.initializeApp(environment.firebase) + ], + providers: [AngularFireDatabase, TodoStoreService], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.html b/examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.html new file mode 100644 index 0000000000..d9372ddf1b --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.html @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.ts b/examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.ts new file mode 100644 index 0000000000..67bc19cf9a --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-footer/todo-footer.component.ts @@ -0,0 +1,52 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { TodoStoreService } from '../../services/todo-store.service'; + +@Component({ + selector: 'todo-footer', + templateUrl: './todo-footer.component.html', +}) +export class TodoFooterComponent implements OnInit { + + currentStatus = ''; + + counter: Number; + remainingCount: Number; + hasCompleted: Boolean; + + constructor( + private todoStore: TodoStoreService, + private route: ActivatedRoute) { + } + + ngOnInit() { + + //for css links + this.route.params + .map(params => params.status) + .subscribe((status) => { + this.currentStatus = status || ''; + }); + + //gobal list size + this.todoStore.getCount().subscribe(value => { + this.counter = value; + }); + + //remaining list size + this.todoStore.getRemainingCount().subscribe(value => { + this.remainingCount = value; + }); + + //has completed items + this.todoStore.hasCompleted().subscribe(value => { + this.hasCompleted = value; + }); + } + + removeCompleted() { + this.todoStore.removeCompleted(); + } + +} diff --git a/examples/firebase-angular2/src/app/components/todo-header/todo-header.component.html b/examples/firebase-angular2/src/app/components/todo-header/todo-header.component.html new file mode 100644 index 0000000000..3405336b5b --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-header/todo-header.component.html @@ -0,0 +1,4 @@ +
+

todos

+ +
\ No newline at end of file diff --git a/examples/firebase-angular2/src/app/components/todo-header/todo-header.component.ts b/examples/firebase-angular2/src/app/components/todo-header/todo-header.component.ts new file mode 100644 index 0000000000..0695dd4652 --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-header/todo-header.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; + +import { TodoStoreService } from '../../services/todo-store.service'; +import { TodoModel } from 'app/models/todo.model'; + +@Component({ + selector: 'todo-header', + templateUrl: './todo-header.component.html', +}) +export class TodoHeaderComponent implements OnInit { + + newTodo = ''; + + constructor(private todoStore: TodoStoreService) { } + + ngOnInit() { + } + + addTodo() { + if (this.newTodo.trim().length) { + this.todoStore.add(new TodoModel(this.newTodo)); + this.newTodo = ''; + } + } + +} diff --git a/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html b/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html new file mode 100644 index 0000000000..af54074aa7 --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html @@ -0,0 +1,9 @@ +
  • +
    + + + +
    + +
  • \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts b/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts new file mode 100644 index 0000000000..91cdbd0c38 --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts @@ -0,0 +1,54 @@ +import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core'; + +@Component({ + selector: 'todo-item', + templateUrl: './todo-item.component.html', +}) +export class TodoItemComponent implements OnInit { + + @Input() todo; + + @Output() itemModified = new EventEmitter(); + + @Output() itemRemoved = new EventEmitter(); + + editing = false; + + constructor() { } + + ngOnInit() { + } + + cancelEditing() { + this.editing = false; + } + + stopEditing(editedTitle) { + this.todo.title = editedTitle.value; + this.editing = false; + + if (this.todo.title.length === 0) { + this.remove(); + } else { + this.update(); + } + } + + edit() { + this.editing = true; + } + + toggleCompletion() { + this.todo.completed = !this.todo.completed; + this.update(); + } + + remove() { + this.itemRemoved.next(this.todo.uid); + } + + update() { + this.todo.title = this.todo.title.trim(); + this.itemModified.next(this.todo); + } +} diff --git a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html new file mode 100644 index 0000000000..0f37e30cfd --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html @@ -0,0 +1,11 @@ +
    + +
    + + +
      + +
    +
    + +
    \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts new file mode 100644 index 0000000000..02d5c4f6c5 --- /dev/null +++ b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts @@ -0,0 +1,50 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { TodoStoreService } from '../../services/todo-store.service'; + +@Component({ + selector: 'todo-list', + templateUrl: './todo-list.component.html', +}) +export class TodoListComponent implements OnInit { + + todos; + allCompleted; + + constructor( + private todoStore: TodoStoreService, + private route: ActivatedRoute) { + + this.todoStore.getAllCompleted().subscribe(value => { + this.allCompleted = value; + }); + } + + ngOnInit() { + this.route.params + .map(params => params.status) + .subscribe((status) => { + this.getTodos(status); + }); + } + + getTodos(status){ + this.todoStore.getTodos(status).subscribe(items => { + this.todos = items; + }); + } + + remove(uid) { + this.todoStore.remove(uid); + } + + update(todo) { + this.todoStore.update(todo); + } + + setAllTo(toggleAll) { + this.todoStore.setAllTo(toggleAll.checked); + } + +} \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/models/todo.model.ts b/examples/firebase-angular2/src/app/models/todo.model.ts new file mode 100644 index 0000000000..2429ffe64d --- /dev/null +++ b/examples/firebase-angular2/src/app/models/todo.model.ts @@ -0,0 +1,9 @@ +export class TodoModel { + completed = false; + title = ""; + + constructor(title){ + this.title = title.trim(); + this.completed = false; + } +} diff --git a/examples/firebase-angular2/src/app/pipes/trim.pipe.ts b/examples/firebase-angular2/src/app/pipes/trim.pipe.ts new file mode 100644 index 0000000000..25fcd5d54e --- /dev/null +++ b/examples/firebase-angular2/src/app/pipes/trim.pipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'trim' +}) +export class TrimPipe implements PipeTransform { + + transform(value: any, args?: any): any { + return value.trim(); + } + +} \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/services/todo-store.service.ts b/examples/firebase-angular2/src/app/services/todo-store.service.ts new file mode 100644 index 0000000000..467f7f9509 --- /dev/null +++ b/examples/firebase-angular2/src/app/services/todo-store.service.ts @@ -0,0 +1,101 @@ +import { Injectable } from '@angular/core'; + +import { AngularFireDatabase, AngularFireList } from 'angularfire2/database'; +import { Observable } from 'rxjs/Observable'; + +import { TodoModel } from '../models/todo.model'; +import { forEach } from '@angular/router/src/utils/collection'; + +@Injectable() +export class TodoStoreService { + + todos: AngularFireList; + + constructor(db: AngularFireDatabase) { + this.todos = db.list('todos'); + } + + add(todo) { + this.todos.push(todo); + } + + update(todo) { + this.todos.set(todo.uid,todo); + } + + remove(uid) { + this.todos.remove(uid); + } + + getTodos(status?): Observable { + let result = this.todos.snapshotChanges() + // Use snapshotChanges().map() to store the key + .map(changes => { + return changes.map(c => ({ uid: c.payload.key, ...c.payload.val() })); + }); + + return this.filterByStatus(status, result); + } + + filterByStatus(status, result) { + if (status !== undefined) { + status = status === "completed" ? true : false; + result = result.map(changes => { + return changes.filter((todo) => todo.completed === status); + }); + } + return result; + } + + setAllTo(completed: Boolean) { + this.getTodos().first().subscribe(todos => { + todos.forEach(todo => { + if(todo.completed != completed){ + todo.completed = completed; + this.update(todo); + } + }); + }); + } + + removeCompleted() { + this.getTodos("completed").first().subscribe(items => { + items.forEach(item => { + this.remove(item.uid); + }); + }); + } + + getCount(): Observable { + return new Observable(observer => { + this.getTodos().subscribe(items =>{ + observer.next(items.length); + }); + }); + } + + getRemainingCount(): Observable { + return new Observable(observer => { + this.getTodos().subscribe(items =>{ + observer.next(items.filter(x => x.completed == false).length); + }); + }); + } + + hasCompleted(): Observable { + return new Observable(observer => { + this.getTodos().subscribe(items =>{ + observer.next(items.filter(x => x.completed == true).length > 0); + }); + }); + } + + getAllCompleted(): Observable { + return new Observable(observer => { + this.getTodos().subscribe(items =>{ + observer.next(items.filter(x => x.completed == false).length == 0); + }); + }); + } + +} \ No newline at end of file diff --git a/examples/firebase-angular2/src/assets/.gitkeep b/examples/firebase-angular2/src/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/firebase-angular2/src/environments/environment.prod.ts b/examples/firebase-angular2/src/environments/environment.prod.ts new file mode 100644 index 0000000000..edd771d92a --- /dev/null +++ b/examples/firebase-angular2/src/environments/environment.prod.ts @@ -0,0 +1,11 @@ +export const environment = { + production: true, + firebase: { + apiKey: "AIzaSyCGT_vBssIZWS2jrfCeQycd-GkF5orYjK8", + authDomain: "todos-5d5f6.firebaseapp.com", + databaseURL: "https://todos-5d5f6.firebaseio.com", + projectId: "todos-5d5f6", + storageBucket: "", + messagingSenderId: "827290518638" + } +}; diff --git a/examples/firebase-angular2/src/environments/environment.ts b/examples/firebase-angular2/src/environments/environment.ts new file mode 100644 index 0000000000..ee71b42af5 --- /dev/null +++ b/examples/firebase-angular2/src/environments/environment.ts @@ -0,0 +1,16 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false, + firebase: { + apiKey: "AIzaSyCGT_vBssIZWS2jrfCeQycd-GkF5orYjK8", + authDomain: "todos-5d5f6.firebaseapp.com", + databaseURL: "https://todos-5d5f6.firebaseio.com", + projectId: "todos-5d5f6", + storageBucket: "", + messagingSenderId: "827290518638" + } +}; diff --git a/examples/firebase-angular2/src/favicon.ico b/examples/firebase-angular2/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8081c7ceaf2be08bf59010158c586170d9d2d517 GIT binary patch literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- + + + + + Angular 5 • TodoMVC + + + + + + + + + + + \ No newline at end of file diff --git a/examples/firebase-angular2/src/main.ts b/examples/firebase-angular2/src/main.ts new file mode 100644 index 0000000000..a9ca1caf8c --- /dev/null +++ b/examples/firebase-angular2/src/main.ts @@ -0,0 +1,11 @@ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/examples/firebase-angular2/src/polyfills.ts b/examples/firebase-angular2/src/polyfills.ts new file mode 100644 index 0000000000..fd01cc9f1d --- /dev/null +++ b/examples/firebase-angular2/src/polyfills.ts @@ -0,0 +1,73 @@ +/** + * This file includes polyfills needed by Angular and is loaded before the app. + * You can add your own extra polyfills to this file. + * + * This file is divided into 2 sections: + * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. + * 2. Application imports. Files imported after ZoneJS that should be loaded before your main + * file. + * + * The current setup is for so-called "evergreen" browsers; the last versions of browsers that + * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), + * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. + * + * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE9, IE10 and IE11 requires all of the following polyfills. **/ +// import 'core-js/es6/symbol'; +// import 'core-js/es6/object'; +// import 'core-js/es6/function'; +// import 'core-js/es6/parse-int'; +// import 'core-js/es6/parse-float'; +// import 'core-js/es6/number'; +// import 'core-js/es6/math'; +// import 'core-js/es6/string'; +// import 'core-js/es6/date'; +// import 'core-js/es6/array'; +// import 'core-js/es6/regexp'; +// import 'core-js/es6/map'; +// import 'core-js/es6/weak-map'; +// import 'core-js/es6/set'; + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** IE10 and IE11 requires the following to support `@angular/animation`. */ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + +/** Evergreen browsers require these. **/ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + + +/** ALL Firefox browsers require the following to support `@angular/animation`. **/ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + + +/*************************************************************************************************** + * Zone JS is required by Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + + + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ + +/** + * Date, currency, decimal and percent pipes. + * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 + */ +// import 'intl'; // Run `npm install --save intl`. +/** + * Need to import at least one locale-data with intl. + */ +// import 'intl/locale-data/jsonp/en'; diff --git a/examples/firebase-angular2/src/styles.css b/examples/firebase-angular2/src/styles.css new file mode 100644 index 0000000000..a961c3ad3e --- /dev/null +++ b/examples/firebase-angular2/src/styles.css @@ -0,0 +1,3 @@ +/* You can add global styles to this file, and also import other style files */ +@import url("../node_modules/todomvc-common/base.css"); +@import url("../node_modules/todomvc-app-css/index.css"); \ No newline at end of file diff --git a/examples/firebase-angular2/src/test.ts b/examples/firebase-angular2/src/test.ts new file mode 100644 index 0000000000..cd612eeb0e --- /dev/null +++ b/examples/firebase-angular2/src/test.ts @@ -0,0 +1,32 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/long-stack-trace-zone'; +import 'zone.js/dist/proxy.js'; +import 'zone.js/dist/sync-test'; +import 'zone.js/dist/jasmine-patch'; +import 'zone.js/dist/async-test'; +import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. +declare const __karma__: any; +declare const require: any; + +// Prevent Karma from running prematurely. +__karma__.loaded = function () {}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/examples/firebase-angular2/src/tsconfig.app.json b/examples/firebase-angular2/src/tsconfig.app.json new file mode 100644 index 0000000000..5e2507db58 --- /dev/null +++ b/examples/firebase-angular2/src/tsconfig.app.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "es2015", + "baseUrl": "", + "types": [] + }, + "exclude": [ + "test.ts", + "**/*.spec.ts" + ] +} diff --git a/examples/firebase-angular2/src/tsconfig.spec.json b/examples/firebase-angular2/src/tsconfig.spec.json new file mode 100644 index 0000000000..510e3f1fda --- /dev/null +++ b/examples/firebase-angular2/src/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "module": "commonjs", + "target": "es5", + "baseUrl": "", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/examples/firebase-angular2/src/typings.d.ts b/examples/firebase-angular2/src/typings.d.ts new file mode 100644 index 0000000000..ef5c7bd620 --- /dev/null +++ b/examples/firebase-angular2/src/typings.d.ts @@ -0,0 +1,5 @@ +/* SystemJS module definition */ +declare var module: NodeModule; +interface NodeModule { + id: string; +} diff --git a/examples/firebase-angular2/tsconfig.json b/examples/firebase-angular2/tsconfig.json new file mode 100644 index 0000000000..a35a8ee3a4 --- /dev/null +++ b/examples/firebase-angular2/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "baseUrl": "src", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es5", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2016", + "dom" + ] + } +} diff --git a/examples/firebase-angular2/tslint.json b/examples/firebase-angular2/tslint.json new file mode 100644 index 0000000000..dd117b3871 --- /dev/null +++ b/examples/firebase-angular2/tslint.json @@ -0,0 +1,135 @@ +{ + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "import-blacklist": [ + true, + "rxjs" + ], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true + } +} From 3540cb201a4e8749d7fbc3f36198bca6f11c4227 Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 18:50:43 +0100 Subject: [PATCH 02/13] Indentation fix for examples/firebase-angular2/karma.conf.js file --- examples/firebase-angular2/karma.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/firebase-angular2/karma.conf.js b/examples/firebase-angular2/karma.conf.js index 4d9ab9d948..34cc2aa568 100644 --- a/examples/firebase-angular2/karma.conf.js +++ b/examples/firebase-angular2/karma.conf.js @@ -12,11 +12,11 @@ module.exports = function (config) { require('karma-coverage-istanbul-reporter'), require('@angular/cli/plugins/karma') ], - client:{ + client: { clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { - reports: [ 'html', 'lcovonly' ], + reports: ['html', 'lcovonly'], fixWebpackSourcePaths: true }, angularCli: { From ac85dd48cf4abf55ad8f8982b33dbec2a3d924ff Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 18:58:02 +0100 Subject: [PATCH 03/13] Indentation fix for examples/firebase-angular2/karma.conf.js file --- examples/firebase-angular2/karma.conf.js | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/firebase-angular2/karma.conf.js b/examples/firebase-angular2/karma.conf.js index 34cc2aa568..fd1b7484f0 100644 --- a/examples/firebase-angular2/karma.conf.js +++ b/examples/firebase-angular2/karma.conf.js @@ -2,32 +2,32 @@ // https://karma-runner.github.io/0.13/config/configuration-file.html module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular/cli'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular/cli/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - reports: ['html', 'lcovonly'], - fixWebpackSourcePaths: true - }, - angularCli: { - environment: 'dev' - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false - }); + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + reports: ['html', 'lcovonly'], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); }; From 8114b4795403dba167bcb665cfa51f19545564fd Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 19:10:10 +0100 Subject: [PATCH 04/13] Indentation fix for examples/firebase-angular2/karma.conf.js file --- examples/firebase-angular2/karma.conf.js | 56 ++++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/firebase-angular2/karma.conf.js b/examples/firebase-angular2/karma.conf.js index fd1b7484f0..a584ea1389 100644 --- a/examples/firebase-angular2/karma.conf.js +++ b/examples/firebase-angular2/karma.conf.js @@ -2,32 +2,32 @@ // https://karma-runner.github.io/0.13/config/configuration-file.html module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular/cli'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular/cli/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - reports: ['html', 'lcovonly'], - fixWebpackSourcePaths: true - }, - angularCli: { - environment: 'dev' - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false - }); + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + reports: ['html', 'lcovonly'], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); }; From ba0218e2c955929ee21f94253129f9952bdf2b33 Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 19:21:56 +0100 Subject: [PATCH 05/13] Indentation fix for examples/firebase-angular2/karma.conf.js file --- examples/firebase-angular2/karma.conf.js | 52 ++++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/firebase-angular2/karma.conf.js b/examples/firebase-angular2/karma.conf.js index a584ea1389..c796a4daf5 100644 --- a/examples/firebase-angular2/karma.conf.js +++ b/examples/firebase-angular2/karma.conf.js @@ -3,31 +3,31 @@ module.exports = function (config) { config.set({ - basePath: '', - frameworks: ['jasmine', '@angular/cli'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular/cli/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - reports: ['html', 'lcovonly'], - fixWebpackSourcePaths: true - }, - angularCli: { - environment: 'dev' - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + reports: ['html', 'lcovonly'], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false }); }; From eea9ac2f9621b36227e247974d14a76a521320ed Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 19:27:11 +0100 Subject: [PATCH 06/13] Indentation fix for examples/firebase-angular2/karma.conf.js file --- examples/firebase-angular2/karma.conf.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/firebase-angular2/karma.conf.js b/examples/firebase-angular2/karma.conf.js index c796a4daf5..5458de84f9 100644 --- a/examples/firebase-angular2/karma.conf.js +++ b/examples/firebase-angular2/karma.conf.js @@ -13,14 +13,14 @@ module.exports = function (config) { require('@angular/cli/plugins/karma') ], client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser + clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { - reports: ['html', 'lcovonly'], - fixWebpackSourcePaths: true + reports: ['html', 'lcovonly'], + fixWebpackSourcePaths: true }, angularCli: { - environment: 'dev' + environment: 'dev' }, reporters: ['progress', 'kjhtml'], port: 9876, From e189ae9f262dace540c36fa1b902354f6d0e43ff Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 19:29:25 +0100 Subject: [PATCH 07/13] Indentation fix for examples/firebase-angular2/protractor.conf.js file --- examples/firebase-angular2/protractor.conf.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/firebase-angular2/protractor.conf.js b/examples/firebase-angular2/protractor.conf.js index 7ee3b5ee86..39fc324cbc 100644 --- a/examples/firebase-angular2/protractor.conf.js +++ b/examples/firebase-angular2/protractor.conf.js @@ -4,25 +4,25 @@ const { SpecReporter } = require('jasmine-spec-reporter'); exports.config = { - allScriptsTimeout: 11000, - specs: [ - './e2e/**/*.e2e-spec.ts' - ], - capabilities: { - 'browserName': 'chrome' - }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - onPrepare() { - require('ts-node').register({ - project: 'e2e/tsconfig.e2e.json' - }); - jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } }; From 05d7753ac0923ba6fc07e5944af6bda114ba1f0e Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Sun, 24 Dec 2017 19:33:18 +0100 Subject: [PATCH 08/13] Indentation fix for examples/firebase-angular2/protractor.conf.js file --- examples/firebase-angular2/protractor.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/firebase-angular2/protractor.conf.js b/examples/firebase-angular2/protractor.conf.js index 39fc324cbc..5abe4d330a 100644 --- a/examples/firebase-angular2/protractor.conf.js +++ b/examples/firebase-angular2/protractor.conf.js @@ -9,7 +9,7 @@ exports.config = { './e2e/**/*.e2e-spec.ts' ], capabilities: { - 'browserName': 'chrome' + browserName: 'chrome' }, directConnect: true, baseUrl: 'http://localhost:4200/', @@ -17,7 +17,7 @@ exports.config = { jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, - print: function() {} + print: function () {} }, onPrepare() { require('ts-node').register({ From b031dc8eec2e81f925e45528b53d264f03e9e480 Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Mon, 25 Dec 2017 00:00:14 +0100 Subject: [PATCH 09/13] todo-item removed in order to fit css tests --- .../todo-item/todo-item.component.html | 9 ---- .../todo-item/todo-item.component.ts | 54 ------------------- .../todo-list/todo-list.component.html | 18 +++++-- .../todo-list/todo-list.component.ts | 11 ++-- 4 files changed, 22 insertions(+), 70 deletions(-) delete mode 100644 examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html delete mode 100644 examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts diff --git a/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html b/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html deleted file mode 100644 index af54074aa7..0000000000 --- a/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
  • -
    - - - -
    - -
  • \ No newline at end of file diff --git a/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts b/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts deleted file mode 100644 index 91cdbd0c38..0000000000 --- a/examples/firebase-angular2/src/app/components/todo-item/todo-item.component.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core'; - -@Component({ - selector: 'todo-item', - templateUrl: './todo-item.component.html', -}) -export class TodoItemComponent implements OnInit { - - @Input() todo; - - @Output() itemModified = new EventEmitter(); - - @Output() itemRemoved = new EventEmitter(); - - editing = false; - - constructor() { } - - ngOnInit() { - } - - cancelEditing() { - this.editing = false; - } - - stopEditing(editedTitle) { - this.todo.title = editedTitle.value; - this.editing = false; - - if (this.todo.title.length === 0) { - this.remove(); - } else { - this.update(); - } - } - - edit() { - this.editing = true; - } - - toggleCompletion() { - this.todo.completed = !this.todo.completed; - this.update(); - } - - remove() { - this.itemRemoved.next(this.todo.uid); - } - - update() { - this.todo.title = this.todo.title.trim(); - this.itemModified.next(this.todo); - } -} diff --git a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html index 0f37e30cfd..f92a806659 100644 --- a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html +++ b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html @@ -1,10 +1,20 @@ -
    +
    -
    +
    -
      - +
        + +
      • +
        + + + +
        + +
      • +
    diff --git a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts index 02d5c4f6c5..f7a3cd4736 100644 --- a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts +++ b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.ts @@ -35,8 +35,8 @@ export class TodoListComponent implements OnInit { }); } - remove(uid) { - this.todoStore.remove(uid); + remove(todo) { + this.todoStore.remove(todo.uid); } update(todo) { @@ -45,6 +45,11 @@ export class TodoListComponent implements OnInit { setAllTo(toggleAll) { this.todoStore.setAllTo(toggleAll.checked); - } + } + + toggleCompletion(todo) { + todo.completed = !todo.completed; + this.update(todo); + } } \ No newline at end of file From 200be25af88342ef7a2bd7965aefa900175c8a97 Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Mon, 25 Dec 2017 01:01:33 +0100 Subject: [PATCH 10/13] Fix for examples/firebase-angular2/protractor.conf.js file directConnect: true --- examples/firebase-angular2/protractor.conf.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/firebase-angular2/protractor.conf.js b/examples/firebase-angular2/protractor.conf.js index 5abe4d330a..88c9e3852d 100644 --- a/examples/firebase-angular2/protractor.conf.js +++ b/examples/firebase-angular2/protractor.conf.js @@ -11,7 +11,6 @@ exports.config = { capabilities: { browserName: 'chrome' }, - directConnect: true, baseUrl: 'http://localhost:4200/', framework: 'jasmine', jasmineNodeOpts: { From 8acb4ae3b263379471976b55c53fe8fc7eefdb79 Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Mon, 25 Dec 2017 01:05:09 +0100 Subject: [PATCH 11/13] Fix for examples/firebase-angular2/protractor.conf.js file --- examples/firebase-angular2/protractor.conf.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/firebase-angular2/protractor.conf.js b/examples/firebase-angular2/protractor.conf.js index 88c9e3852d..64c04a53ee 100644 --- a/examples/firebase-angular2/protractor.conf.js +++ b/examples/firebase-angular2/protractor.conf.js @@ -8,9 +8,6 @@ exports.config = { specs: [ './e2e/**/*.e2e-spec.ts' ], - capabilities: { - browserName: 'chrome' - }, baseUrl: 'http://localhost:4200/', framework: 'jasmine', jasmineNodeOpts: { From 7ce9d6d067a0c0972444db12ae15e7e2e7fcba1e Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Mon, 25 Dec 2017 21:38:32 +0100 Subject: [PATCH 12/13] Mark all fixed --- .../app/components/todo-list/todo-list.component.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html index f92a806659..47d1bbaaca 100644 --- a/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html +++ b/examples/firebase-angular2/src/app/components/todo-list/todo-list.component.html @@ -1,10 +1,13 @@
    - - + +
    + + +
    +
      -
    • From c54385233def2eddf662159f5e01cb2871ed56cd Mon Sep 17 00:00:00 2001 From: Pablo Albaladejo Date: Mon, 25 Dec 2017 21:39:10 +0100 Subject: [PATCH 13/13] Project structure fixed --- examples/firebase-angular2/protractor.conf.js | 4 ++++ examples/firebase-angular2/src/app/app.module.ts | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/firebase-angular2/protractor.conf.js b/examples/firebase-angular2/protractor.conf.js index 64c04a53ee..5abe4d330a 100644 --- a/examples/firebase-angular2/protractor.conf.js +++ b/examples/firebase-angular2/protractor.conf.js @@ -8,6 +8,10 @@ exports.config = { specs: [ './e2e/**/*.e2e-spec.ts' ], + capabilities: { + browserName: 'chrome' + }, + directConnect: true, baseUrl: 'http://localhost:4200/', framework: 'jasmine', jasmineNodeOpts: { diff --git a/examples/firebase-angular2/src/app/app.module.ts b/examples/firebase-angular2/src/app/app.module.ts index c582742191..36864b0797 100644 --- a/examples/firebase-angular2/src/app/app.module.ts +++ b/examples/firebase-angular2/src/app/app.module.ts @@ -11,7 +11,6 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { TodoListComponent } from './components/todo-list/todo-list.component'; import { TodoHeaderComponent } from './components/todo-header/todo-header.component'; -import { TodoItemComponent } from './components/todo-item/todo-item.component'; import { TodoFooterComponent } from './components/todo-footer/todo-footer.component'; import { TodoStoreService } from './services/todo-store.service'; @@ -24,7 +23,6 @@ import { TrimPipe } from './pipes/trim.pipe'; AppComponent, TodoListComponent, TodoHeaderComponent, - TodoItemComponent, TodoFooterComponent, TrimPipe, ],