-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
303 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Hello from {{ name }}!</h1> | ||
<a target="_blank" href="https://angular.dev/overview"> | ||
Learn more about Angular | ||
</a> | ||
|
||
<pre>{{ all$ | async | json }}</pre> |
Empty file.
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,29 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
|
||
describe('AppComponent', () => { | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AppComponent] | ||
}).compileComponents(); | ||
}); | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
it(`should have the 'standalone' title`, () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app.name).toEqual('standalone'); | ||
}); | ||
|
||
it('should render title', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, standalone'); | ||
}); | ||
}); |
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,23 @@ | ||
import { Component } from '@angular/core'; | ||
import { AsyncPipe, JsonPipe } from '@angular/common'; | ||
import { all } from './states/test.selectors'; | ||
import { Store } from '@ngxs/store'; | ||
import { GetAll } from './states/test.actions'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
standalone: true, | ||
imports: [AsyncPipe, JsonPipe], | ||
templateUrl: './app.component.html', | ||
styleUrl: './app.component.scss' | ||
}) | ||
export class AppComponent { | ||
name = 'Angular'; | ||
all$ = this.store.select(all); | ||
|
||
constructor(private store: Store) {} | ||
|
||
ngOnInit() { | ||
this.store.dispatch(new GetAll()); | ||
} | ||
} |
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,30 @@ | ||
import { ApplicationConfig, importProvidersFrom } from '@angular/core'; | ||
import { provideRouter } from '@angular/router'; | ||
|
||
import { routes } from './app.routes'; | ||
import { initializeApp, provideFirebaseApp } from '@angular/fire/app'; | ||
import { getFirestore, provideFirestore } from '@angular/fire/firestore'; | ||
import { NgxsModule } from '@ngxs/store'; | ||
import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin'; | ||
import { environment } from '../environments/environment'; | ||
import { TestState } from './states/test.state'; | ||
import { provideNgxsFirestore } from '@ngxs-labs/firestore-plugin'; | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideRouter(routes), | ||
importProvidersFrom( | ||
provideFirebaseApp(() => initializeApp(environment.firebase)), | ||
provideFirestore(() => getFirestore()), | ||
NgxsModule.forRoot([TestState], { | ||
developmentMode: !environment.production | ||
}), | ||
NgxsLoggerPluginModule.forRoot({ | ||
disabled: environment.production | ||
}) | ||
), | ||
provideNgxsFirestore({ | ||
developmentMode: true | ||
}) | ||
] | ||
}; |
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,3 @@ | ||
import { Routes } from '@angular/router'; | ||
|
||
export const routes: Routes = []; |
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 { Injectable } from '@angular/core'; | ||
import { NgxsFirestore } from '@ngxs-labs/firestore-plugin'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class TestFirestore extends NgxsFirestore<any> { | ||
path = 'test'; | ||
} |
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,8 @@ | ||
export class GetAll { | ||
static readonly type = '[Test] GetAll'; | ||
} | ||
|
||
export class Create { | ||
static readonly type = '[Test] Create'; | ||
constructor(public payload: any) {} | ||
} |
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 @@ | ||
import { createSelector } from '@ngxs/store'; | ||
import { TestState, TestStateModel } from './test.state'; | ||
|
||
export const all = createSelector([TestState], (state: TestStateModel) => { | ||
return state.items; | ||
}); |
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,38 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Action, NgxsOnInit, State, StateContext } from '@ngxs/store'; | ||
import { TestFirestore } from './../services/test.firestore'; | ||
import { Create, GetAll } from './test.actions'; | ||
import { Emitted, NgxsFirestoreConnect, StreamEmitted } from '@ngxs-labs/firestore-plugin'; | ||
|
||
export interface TestStateModel { | ||
items: any[]; | ||
} | ||
|
||
@State<TestStateModel>({ | ||
name: 'test', | ||
defaults: { | ||
items: [] | ||
} | ||
}) | ||
@Injectable() | ||
export class TestState implements NgxsOnInit { | ||
constructor(private testFS: TestFirestore, private ngxsFirestoreConnect: NgxsFirestoreConnect) {} | ||
|
||
ngxsOnInit(ctx: StateContext<TestStateModel>) { | ||
this.ngxsFirestoreConnect.connect(GetAll, { | ||
to: () => this.testFS.collection$() | ||
}); | ||
} | ||
|
||
@Action(StreamEmitted(GetAll)) | ||
getAll(ctx: StateContext<TestStateModel>, { payload }: Emitted<GetAll, any[]>) { | ||
ctx.patchState({ | ||
items: payload || [] | ||
}); | ||
} | ||
|
||
@Action(Create) | ||
async sendMessage(ctx: StateContext<TestStateModel>, { payload }: any) { | ||
return this.testFS.create$(payload); | ||
} | ||
} |
Empty file.
12 changes: 12 additions & 0 deletions
12
integrations/standalone/src/environments/environment.prod.ts
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,12 @@ | ||
export const environment = { | ||
production: true, | ||
firebase: { | ||
apiKey: 'AIzaSyDODLVMuwrvGobMXkI89DktOLgwf0mCM24', | ||
authDomain: 'joaq-lab.firebaseapp.com', | ||
databaseURL: 'https://joaq-lab.firebaseio.com', | ||
projectId: 'joaq-lab', | ||
storageBucket: 'joaq-lab.appspot.com', | ||
messagingSenderId: '794748950011', | ||
appId: '1:794748950011:web:815fe385e7317c11' | ||
} | ||
}; |
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,24 @@ | ||
// This file can be replaced during build by using the `fileReplacements` array. | ||
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. | ||
// The list of file replacements can be found in `angular.json`. | ||
|
||
export const environment = { | ||
production: false, | ||
firebase: { | ||
apiKey: 'AIzaSyDODLVMuwrvGobMXkI89DktOLgwf0mCM24', | ||
authDomain: 'joaq-lab.firebaseapp.com', | ||
databaseURL: 'https://joaq-lab.firebaseio.com', | ||
projectId: 'joaq-lab', | ||
storageBucket: 'joaq-lab.appspot.com', | ||
messagingSenderId: '794748950011', | ||
appId: '1:794748950011:web:815fe385e7317c11' | ||
} | ||
}; | ||
|
||
/* | ||
* In development mode, to ignore zone related error stack frames such as | ||
* `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can | ||
* import the following file, but please comment it out in production mode | ||
* because it will have performance impact when throw error | ||
*/ | ||
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI. |
Binary file not shown.
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Standalone</title> | ||
<base href="/" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
</html> |
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 { bootstrapApplication } from '@angular/platform-browser'; | ||
import { appConfig } from './app/app.config'; | ||
import { AppComponent } from './app/app.component'; | ||
|
||
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err)); |
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 @@ | ||
/* You can add global styles to this file, and also import other style files */ |
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,10 @@ | ||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../out-tsc/app", | ||
"types": [] | ||
}, | ||
"files": ["src/main.ts"], | ||
"include": ["src/**/*.d.ts"] | ||
} |
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,9 @@ | ||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../out-tsc/spec", | ||
"types": ["jasmine"] | ||
}, | ||
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"] | ||
} |