Skip to content

Commit 135c1df

Browse files
devversionjelbourn
authored andcommitted
build: firebase integration for dashboard (#5182)
* build: firebase integration for dashboard * As part of the initial dashboard setup, this installs Angular Fire and Angular Material in the dashboard. * For testing purposes the list of all payload results will be printed right now. * Address feedback
1 parent 746495a commit 135c1df

File tree

11 files changed

+81
-7
lines changed

11 files changed

+81
-7
lines changed

tools/dashboard/.angular-cli.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"tsconfig": "tsconfig.json",
1818
"prefix": "app",
1919
"styles": [
20-
"styles.css"
20+
"styles.css",
21+
"theme.scss"
2122
],
2223
"scripts": [],
2324
"environmentSource": "environments/environment.ts",

tools/dashboard/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
"@angular/core": "^4.2.2",
1717
"@angular/forms": "^4.2.2",
1818
"@angular/http": "^4.2.2",
19+
"@angular/material": "github:angular/material2-builds",
1920
"@angular/platform-browser": "^4.2.2",
2021
"@angular/platform-browser-dynamic": "^4.2.2",
2122
"@angular/router": "^4.2.2",
23+
"angularfire2": "^4.0.0-rc.1",
2224
"core-js": "^2.4.1",
25+
"firebase": "^4.1.2",
2326
"rxjs": "^5.1.0",
2427
"zone.js": "^0.8.12"
2528
},
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
<h1>Angular Material - Board</h1>
1+
<md-toolbar color="primary">
2+
<span>Angular Material - Board</span>
3+
</md-toolbar>
4+
5+
<p>Payload Test Data</p>
6+
{{ payloads | async | json }}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import {Component} from '@angular/core';
2+
import {AngularFireDatabase, FirebaseListObservable} from 'angularfire2/database';
3+
import {PayloadResult} from './data-definitions';
24

35
@Component({
46
selector: 'dashboard-app',
57
templateUrl: './dashboard-app.html',
68
styleUrls: ['./dashboard-app.css']
79
})
8-
export class DashboardApp {}
10+
export class DashboardApp {
11+
12+
/** Observable that emits all payload results from Firebase. */
13+
payloads: FirebaseListObservable<PayloadResult[]>;
14+
15+
constructor(database: AngularFireDatabase) {
16+
this.payloads = database.list(`payloads`);
17+
}
18+
}
19+

tools/dashboard/src/app/dashboard-module.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
import {BrowserModule} from '@angular/platform-browser';
2+
import {AngularFireModule} from 'angularfire2';
3+
import {AngularFireDatabaseModule} from 'angularfire2/database';
24
import {NgModule} from '@angular/core';
35
import {DashboardApp} from './dashboard-app';
6+
import {environment} from '../environments/environment';
7+
import {MdToolbarModule} from '@angular/material';
8+
9+
@NgModule({
10+
exports: [
11+
MdToolbarModule
12+
]
13+
})
14+
export class DashboardMaterialModule {}
415

516
@NgModule({
617
declarations: [
718
DashboardApp
819
],
920
imports: [
10-
BrowserModule
21+
BrowserModule,
22+
AngularFireModule.initializeApp(environment.firebase),
23+
AngularFireDatabaseModule,
24+
DashboardMaterialModule
1125
],
1226
providers: [],
1327
bootstrap: [DashboardApp]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** Interface that describes the payload results from the Firebase database. */
2+
export interface PayloadResult {
3+
timestamp: number;
4+
// Material bundles
5+
material_umd: string;
6+
material_umd_minified_uglify: string;
7+
material_fesm_2015: string;
8+
material_fesm_2014: string;
9+
// CDK bundles
10+
cdk_umd: string;
11+
cdk_umd_minified_uglify: string;
12+
cdk_fesm_2015: string;
13+
cdk_fesm_2014: string;
14+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {firebaseConfig} from './firebase';
2+
13
export const environment = {
2-
production: true
4+
production: true,
5+
firebase: firebaseConfig
36
};
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {firebaseConfig} from './firebase';
2+
13
export const environment = {
2-
production: false
4+
production: false,
5+
firebase: firebaseConfig
36
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** Shared Firebase configuration that will be used in every environment. */
2+
export const firebaseConfig = {
3+
apiKey: 'AIzaSyCbDnV4udMgMciQ3Sva88Ji1udOIPltDAA',
4+
authDomain: 'material2-board.firebaseapp.com',
5+
databaseURL: 'https://material2-board.firebaseio.com',
6+
projectId: 'material2-board'
7+
};

tools/dashboard/src/styles.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
/* You can add global styles to this file, and also import other style files */
1+
body, html {
2+
margin: 0;
3+
font-family: Roboto, Arial, sans-serif;
4+
}

tools/dashboard/src/theme.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@import '~@angular/material/_theming';
2+
3+
$dashboard-primary: mat-palette($mat-blue);
4+
$dashboard-accent: mat-palette($mat-grey);
5+
$dashboard-light-theme: mat-light-theme($dashboard-primary, $dashboard-accent);
6+
7+
@include mat-core();
8+
9+
// Only include the theme of the components that are used.
10+
@include mat-toolbar-theme($dashboard-light-theme);

0 commit comments

Comments
 (0)