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
import { Router } from '@angular/router'; | |
import { ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild, Input } from '@angular/core'; | |
import * as $ from 'jquery'; // ToDo: Get rid of jQuery to comply with Angular Universal. Or just don't server-render the frame, cause what's the point anyway. | |
import { Observable } from 'rxjs/Observable'; | |
import { Subscription } from 'rxjs/Subscription'; | |
import { StateService } from '../../state/state.service'; | |
import * as nodeUrl from 'url'; | |
@Component({ | |
selector: 'm-frame', | |
template: ` |
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
import { Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef, OnDestroy } from '@angular/core'; | |
import { StateService } from '../../state/state.service'; | |
import { ActivatedRoute, Router } from '@angular/router'; | |
import { FrameComponent } from '../../shared/frame/frame.component'; | |
import { Subscription } from 'rxjs/Subscription'; | |
import { FrameService } from '../../services/frame.service'; | |
@Component({ | |
selector: 'm-dash', | |
template: ` | |
<router-outlet *ngIf="!frameSrc"></router-outlet> |
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
import { Injectable, EventEmitter } from '@angular/core'; | |
import { Subject } from 'rxjs/Subject'; | |
import { Router } from '@angular/router'; | |
@Injectable() | |
export class FrameService { | |
constructor(private router: Router) { } | |
public srcChange: Subject<string> = new Subject<string>(); | |
public frameClosed: EventEmitter<any> = new EventEmitter<any>(); | |
public set src(url: string) { | |
if (!url) { |
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
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const hash = fs.readdirSync(path.resolve(__dirname, './functions/dist-server')) | |
.filter(file => file.startsWith('main')) | |
.pop() | |
.split('.')[1]; | |
const mainBundle = path.resolve(__dirname, `./functions/dist-server/main.${hash}.bundle.js`); | |
fs.readFile(mainBundle, 'utf-8', (err, data) => { | |
if (err) { return console.log('Error reading file:', 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
// ... pass this to Express or firebase functions.https.onRequest: | |
function universal(req, res) { | |
renderModuleFactory(AppServerModuleNgFactory, { | |
document: index, | |
url: req.path || '/', | |
extraProviders: [ | |
{ provide: 'firebaseAdmin', useValue: admin } | |
] | |
}) | |
.then(function (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
// Use this instead of AngularfireDatabase in your ServerDatabaseService | |
import { Injectable, Inject, NgZone } from '@angular/core'; | |
@Injectable() | |
export class FirebaseAdminService { | |
constructor( | |
@Inject('firebaseAdmin') private admin, // An initialized instance of firebase-admin, provided from the outside | |
private zone: NgZone | |
) { } | |
public snapshot(path, query): Promise<any> { | |
let timeout = setTimeout(() => { // Give time for socket to return something before Universal exits. |
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
import { MockAppComponent } from './mock-app.component'; | |
import { NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { SharedModule } from '../../shared/shared.module'; | |
import { AuthService } from '../../models/auth/auth.service'; | |
import { PromptService } from '../../components/prompt/prompt.service'; | |
import { BaseModelService } from '../../models/base-model.service'; | |
import { CookieService } from 'ng2-cookies'; | |
import { ChartService } from '../../models/chart-data/chart.service'; |