Skip to content

Commit

Permalink
Reorganise app
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandSchtroumpf committed Jun 28, 2019
1 parent 465bfad commit 2ff686c
Show file tree
Hide file tree
Showing 40 changed files with 392 additions and 261 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
Expand Down
24 changes: 24 additions & 0 deletions doc/collection/service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# CollectionService
The `CollectionService` provides all the CRUD methods needed to interact with Firestore. There is to type of operation :
- Sync : listen on changes from your collection.
- Write : update the collection.

```
```

## Sync
Collection Service provides methods to subscribe on changes from Firestore.


```
```

## Write

### Add
Add a new document in your collection :
```
```
50 changes: 35 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"@datorama/akita": "^4.1.0",
"@datorama/akita": "^4.1.1",
"firebase": ">= 5.5.7 <7",
"hammerjs": "^2.0.8",
"rxjs": "~6.4.0",
Expand Down
31 changes: 0 additions & 31 deletions src/app/app.component.spec.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component } from '@angular/core';

@Component({
selector: 'app-root',
template: '<router-outlet></router-outlet>',
styleUrls: ['./app.component.scss']
template: '<router-outlet></router-outlet>'
})
export class AppComponent {}
34 changes: 18 additions & 16 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,41 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AkitaNgDevtools } from '@datorama/akita-ngdevtools';
import { environment } from '../environments/environment';

import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { HomeComponent } from './home/home.component';
import { RouterModule } from '@angular/router';
import { ListComponent } from './list/list.component';
import { TodoGuard } from './state/todo.guard';

@NgModule({
declarations: [AppComponent, HomeComponent, ListComponent],
declarations: [AppComponent, HomeComponent],
imports: [
BrowserModule,
RouterModule.forRoot([
{ path: '', component: HomeComponent },
{ path: 'todos', component: ListComponent, canActivate: [TodoGuard], canDeactivate: [TodoGuard] }
]),
BrowserAnimationsModule,
// Material
MatSnackBarModule,
// Angular Firebase
AngularFireModule.initializeApp({
apiKey: 'AIzaSyALX_NJPnLEWHgVQTGxZAYbUuMQTesRElw',
authDomain: 'akita-ng-fire-f56e0.firebaseapp.com',
databaseURL: 'https://akita-ng-fire-f56e0.firebaseio.com',
projectId: 'akita-ng-fire-f56e0',
storageBucket: 'akita-ng-fire-f56e0.appspot.com',
authDomain: 'akita-firebase-f56e0.firebaseapp.com',
databaseURL: 'https://akita-firebase-f56e0.firebaseio.com',
projectId: 'akita-firebase-f56e0',
storageBucket: 'akita-firebase-f56e0.appspot.com',
messagingSenderId: '677510358740',
appId: '1:677510358740:web:f91dfbb55eb630b2'
}),
AngularFirestoreModule,
environment.production ? [] : AkitaNgDevtools.forRoot(),
BrowserAnimationsModule,
MatSnackBarModule
// Routers
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{
path: 'movies',
loadChildren: () => import('./collection/movie.module').then(m => m.MovieModule)
}
]),
],
providers: [],
bootstrap: [AppComponent]
Expand Down
4 changes: 4 additions & 0 deletions src/app/collection/+state/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './movie.model';
export * from './movie.query';
export * from './movie.service';
export * from './movie.store';
14 changes: 14 additions & 0 deletions src/app/collection/+state/movie.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export interface Movie {
id: string;
title: string;
description: string;
}

/**
* A factory function that creates Movie
*/
export function createMovie(params: Partial<Movie>) {
return {

} as Movie;
}
12 changes: 12 additions & 0 deletions src/app/collection/+state/movie.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Injectable } from '@angular/core';
import { QueryEntity } from '@datorama/akita';
import { MovieStore, MovieState } from './movie.store';

@Injectable({ providedIn: 'root' })
export class MovieQuery extends QueryEntity<MovieState> {

constructor(protected store: MovieStore) {
super(store);
}

}
14 changes: 14 additions & 0 deletions src/app/collection/+state/movie.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Injectable } from '@angular/core';
import { MovieStore, MovieState } from './movie.store';
import { AngularFirestore } from '@angular/fire/firestore';
import { CollectionConfig, CollectionService } from 'akita-ng-fire';

@Injectable({ providedIn: 'root' })
@CollectionConfig({ path: 'movies' })
export class MovieService extends CollectionService<MovieState> {

constructor(db: AngularFirestore, store: MovieStore) {
super(db, store);
}

}
Loading

0 comments on commit 2ff686c

Please sign in to comment.