Updated angular
This commit is contained in:
@ -1,74 +1,81 @@
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {NgModule} from '@angular/core';
|
||||
|
||||
import {AppRoutingModule} from './app-routing.module';
|
||||
import {AppComponent} from './app.component';
|
||||
import {environment} from '../environments/environment';
|
||||
import {AppRoutes} from './app.routes';
|
||||
import {AdminGuard} from './guards/admin.guard';
|
||||
import {GuestGuard} from './guards/guest.guard';
|
||||
import {LoginGuard} from './guards/login.guard';
|
||||
import {MaterialModule} from './material.module';
|
||||
import {AppComponent} from './views/app/app.component';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {
|
||||
MatButtonModule, MatButtonToggleModule,
|
||||
MatCardModule,
|
||||
MatDividerModule, MatFormFieldModule,
|
||||
MatIconModule, MatInputModule,
|
||||
MatListModule, MatProgressSpinnerModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule
|
||||
} from '@angular/material';
|
||||
import {DashboardComponent} from './dashboard/dashboard.component';
|
||||
import {BatteryComponent} from './battery/battery.component';
|
||||
import {WeatherComponent} from './weather/weather.component';
|
||||
import {SecurityComponent} from './security/security.component';
|
||||
import {DashboardComponent} from './views/dashboard/dashboard.component';
|
||||
import {BatteryComponent} from './views/battery/battery.component';
|
||||
import {WeatherComponent} from './views/weather/weather.component';
|
||||
import {SecurityComponent} from './views/security/security.component';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {LoginComponent} from './views/login/login.component';
|
||||
import {ServiceWorkerModule} from '@angular/service-worker';
|
||||
import {RoundPipe} from './round.pipe';
|
||||
import {BatteryWidgetComponent} from './battery/widget/batteryWidget.component';
|
||||
import {WeatherWidgetComponent} from './weather/widget/weatherWidget.component';
|
||||
import {RoundPipe} from './pipes/round.pipe';
|
||||
import {BatteryWidgetComponent} from './components/battery-widget/batteryWidget.component';
|
||||
import {WeatherWidgetComponent} from './components/weather-widget/weatherWidget.component';
|
||||
import {AngularFireAuthModule} from '@angular/fire/auth';
|
||||
import {environment} from '../environments/environment';
|
||||
import {AngularFireModule} from '@angular/fire';
|
||||
import {AngularFirestoreModule} from '@angular/fire/firestore';
|
||||
import {GaugeModule} from 'angular-gauge';
|
||||
import {ChartsModule} from 'ng2-charts';
|
||||
|
||||
const APP_COMPONENTS = [
|
||||
BatteryWidgetComponent,
|
||||
WeatherWidgetComponent
|
||||
];
|
||||
|
||||
const APP_GUARDS = [
|
||||
AdminGuard,
|
||||
GuestGuard,
|
||||
LoginGuard
|
||||
];
|
||||
|
||||
const APP_PIPES = [
|
||||
RoundPipe
|
||||
];
|
||||
|
||||
const APP_VIEWS = [
|
||||
AppComponent,
|
||||
BatteryComponent,
|
||||
DashboardComponent,
|
||||
LoginComponent,
|
||||
SecurityComponent,
|
||||
WeatherComponent
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
BatteryWidgetComponent,
|
||||
DashboardComponent,
|
||||
BatteryComponent,
|
||||
WeatherComponent,
|
||||
SecurityComponent,
|
||||
LoginComponent,
|
||||
RoundPipe,
|
||||
WeatherWidgetComponent
|
||||
APP_COMPONENTS,
|
||||
APP_PIPES,
|
||||
APP_VIEWS
|
||||
],
|
||||
imports: [
|
||||
AngularFireAuthModule,
|
||||
AngularFireModule.initializeApp(environment.firebase),
|
||||
AngularFirestoreModule,
|
||||
AppRoutingModule,
|
||||
AppRoutes,
|
||||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
ChartsModule,
|
||||
FormsModule,
|
||||
GaugeModule.forRoot(),
|
||||
HttpClientModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatCardModule,
|
||||
MatDividerModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatListModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule,
|
||||
MaterialModule,
|
||||
ServiceWorkerModule.register('ngsw-worker.js', {enabled: false}),
|
||||
ServiceWorkerModule.register('ngsw-worker.js', {
|
||||
enabled: environment.production,
|
||||
// Register the ServiceWorker as soon as the app is stable
|
||||
// or after 30 seconds (whichever comes first).
|
||||
registrationStrategy: 'registerWhenStable:30000'
|
||||
}),
|
||||
],
|
||||
providers: [],
|
||||
providers: [APP_GUARDS],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule {
|
||||
}
|
||||
export class AppModule { }
|
||||
|
@ -1,11 +1,11 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {Routes, RouterModule} from '@angular/router';
|
||||
import {DashboardComponent} from './dashboard/dashboard.component';
|
||||
import {WeatherComponent} from './weather/weather.component';
|
||||
import {SecurityComponent} from './security/security.component';
|
||||
import {BatteryComponent} from './battery/battery.component';
|
||||
import {LoginComponent} from './login/login.component';
|
||||
import {LoginGuard} from './login/login.guard';
|
||||
import {DashboardComponent} from './views/dashboard/dashboard.component';
|
||||
import {WeatherComponent} from './views/weather/weather.component';
|
||||
import {SecurityComponent} from './views/security/security.component';
|
||||
import {BatteryComponent} from './views/battery/battery.component';
|
||||
import {LoginComponent} from './views/login/login.component';
|
||||
import {LoginGuard} from './guards/login.guard';
|
||||
|
||||
const routes: Routes = [
|
||||
{path: 'battery', component: BatteryComponent, canActivate: [LoginGuard]},
|
||||
@ -20,4 +20,4 @@ const routes: Routes = [
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
export class AppRoutes { }
|
@ -1,17 +0,0 @@
|
||||
import {CanActivate, Router} from '@angular/router';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {filter, map, tap} from 'rxjs/operators';
|
||||
import {AuthService} from '../auth.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LoginGuard implements CanActivate {
|
||||
|
||||
constructor(private auth: AuthService, private router: Router) {}
|
||||
|
||||
canActivate(): Observable<boolean> {
|
||||
return this.auth.user.pipe(filter((user: any) => user != null), map(user => user && !user.isAnonymous), tap(auth => auth ? null : this.router.navigate(['/login'])));
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {BatteryService} from '../battery.service';
|
||||
import {BatteryService} from '../../services/battery.service';
|
||||
|
||||
@Component({
|
||||
selector: 'battery-widget',
|
@ -1,5 +1,5 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {WeatherService} from '../weather.service';
|
||||
import {WeatherService} from '../../services/weather.service';
|
||||
|
||||
@Component({
|
||||
selector: 'weather-widget',
|
@ -1,15 +1,15 @@
|
||||
import {CanActivate, Router} from '@angular/router';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {filter, map, tap} from 'rxjs/operators';
|
||||
import {AuthService} from '../auth.service';
|
||||
import {filter, map} from 'rxjs/operators';
|
||||
import {AuthService} from '../services/auth.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AdminGuard implements CanActivate {
|
||||
|
||||
constructor(private auth: AuthService, private router: Router) {}
|
||||
constructor(private auth: AuthService) {}
|
||||
|
||||
canActivate(): Observable<boolean> {
|
||||
return this.auth.user.pipe(filter((user: any) => user != null), map(user => user && user.isAdmin));
|
@ -2,7 +2,7 @@ import {CanActivate, Router} from '@angular/router';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {filter, map, tap} from 'rxjs/operators';
|
||||
import {AuthService} from '../auth.service';
|
||||
import {AuthService} from '../services/auth.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
@ -8,10 +8,10 @@ import {AngularFireAuth} from '@angular/fire/auth';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LoginGuard implements CanActivate {
|
||||
loggedIn?;
|
||||
loggedIn?: any;
|
||||
|
||||
constructor(private auth: AngularFireAuth, private router: Router) {
|
||||
this.auth.auth.onAuthStateChanged(user => this.loggedIn = !!user);
|
||||
this.auth.onAuthStateChanged(user => this.loggedIn = !!user);
|
||||
}
|
||||
|
||||
canActivate(): Observable<boolean> {
|
32
src/app/material.module.ts
Normal file
32
src/app/material.module.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {MatButtonToggleModule} from '@angular/material/button-toggle';
|
||||
import {MatCardModule} from '@angular/material/card';
|
||||
import {MatDividerModule} from '@angular/material/divider';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MatIconModule} from '@angular/material/icon';
|
||||
import {MatInputModule} from '@angular/material/input';
|
||||
import {MatListModule} from '@angular/material/list';
|
||||
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
|
||||
import {MatSidenavModule} from '@angular/material/sidenav';
|
||||
import {MatToolbarModule} from '@angular/material/toolbar';
|
||||
|
||||
const MATERIAL_MODULES = [
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatCardModule,
|
||||
MatDividerModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatListModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: MATERIAL_MODULES,
|
||||
exports: MATERIAL_MODULES
|
||||
})
|
||||
export class MaterialModule { }
|
@ -1,4 +1,4 @@
|
||||
export interface Battery {
|
||||
export interface IBattery {
|
||||
ampHours: number;
|
||||
avgCellVoltage: number;
|
||||
capacity: number;
|
@ -1,7 +1,8 @@
|
||||
import {User as FirebaseUser} from "firebase"
|
||||
import {AngularFirestoreDocument} from '@angular/fire/firestore';
|
||||
import firebase from 'firebase';
|
||||
import User = firebase.User;
|
||||
|
||||
export interface User extends FirebaseUser {
|
||||
export interface IUser extends User {
|
||||
ref?: AngularFirestoreDocument;
|
||||
|
||||
isAdmin: boolean;
|
@ -1,4 +1,4 @@
|
||||
export interface Weather {
|
||||
export interface IWeather {
|
||||
cloudCover: number;
|
||||
current: number;
|
||||
date: Date;
|
@ -1,19 +1,18 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import firebase from 'firebase';
|
||||
import {BehaviorSubject, from} from "rxjs";
|
||||
import {AngularFirestore} from "@angular/fire/firestore";
|
||||
import {AngularFireAuth} from "@angular/fire/auth";
|
||||
import {auth} from 'firebase';
|
||||
import {Router} from "@angular/router";
|
||||
import {flatMap, map, skip} from 'rxjs/operators';
|
||||
import {User} from './user';
|
||||
import {IUser} from '../models/user';
|
||||
import GoogleAuthProvider = firebase.auth.GoogleAuthProvider;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class AuthService {
|
||||
readonly collection = 'Users';
|
||||
|
||||
user = new BehaviorSubject<User>(null);
|
||||
user = new BehaviorSubject<IUser>(null);
|
||||
|
||||
constructor(private afAuth: AngularFireAuth, private router: Router, private db: AngularFirestore) {
|
||||
this.afAuth.user.pipe(
|
||||
@ -22,16 +21,16 @@ export class AuthService {
|
||||
let ref = this.db.collection(this.collection).doc(user.uid);
|
||||
return ref.valueChanges().pipe(map(dbUser => Object.assign({ref: ref}, user, dbUser)))
|
||||
})
|
||||
).subscribe(user => this.user.next(<User>user));
|
||||
).subscribe(user => this.user.next(<IUser>user));
|
||||
}
|
||||
|
||||
async loginWithGoogle() {
|
||||
this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider());
|
||||
this.afAuth.signInWithPopup(new GoogleAuthProvider());
|
||||
return this.user.pipe(skip(1));
|
||||
}
|
||||
|
||||
async logout() {
|
||||
await this.afAuth.auth.signOut();
|
||||
await this.afAuth.signOut();
|
||||
return this.router.navigate(['/']);
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AngularFirestore} from '@angular/fire/firestore';
|
||||
import {Battery} from './battery';
|
||||
import {IBattery} from '../models/battery';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BatteryService {
|
||||
data = new BehaviorSubject<Battery[]>([]);
|
||||
last: Battery = <Battery>{};
|
||||
data = new BehaviorSubject<IBattery[]>([]);
|
||||
last: IBattery = <IBattery>{};
|
||||
modules = [];
|
||||
|
||||
get charging() {
|
||||
@ -29,7 +29,7 @@ export class BatteryService {
|
||||
let afterDate = new Date();
|
||||
afterDate.setDate(afterDate.getDate() - 1);
|
||||
|
||||
this.firestore.collection('Battery').doc('170614D').collection<Battery>('data', ref => ref.where('timestamp', '>=', afterDate.getTime()).orderBy('timestamp')).valueChanges().subscribe(data => {
|
||||
this.firestore.collection('Battery').doc('170614D').collection<IBattery>('data', ref => ref.where('timestamp', '>=', afterDate.getTime()).orderBy('timestamp')).valueChanges().subscribe(data => {
|
||||
this.modules = data.reduce((acc: any, row) => {
|
||||
Object.keys(row.modules).forEach(module => {
|
||||
if(!acc[module]) acc[module] = [];
|
@ -2,17 +2,15 @@ import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Subscription, timer} from 'rxjs';
|
||||
import {environment} from '../../environments/environment';
|
||||
import {Weather} from './weather';
|
||||
import {WeatherIcons} from './weatherIcons';
|
||||
import {IWeather} from '../models/weather';
|
||||
import {WeatherIcons} from '../models/weatherIcons';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class WeatherService {
|
||||
locationKey: string;
|
||||
metric = true;
|
||||
sub: Subscription;
|
||||
weather: Weather[] = [];
|
||||
weather: IWeather[] = [];
|
||||
|
||||
get icon() {
|
||||
if(!this.weather.length) return '';
|
@ -1,9 +1,9 @@
|
||||
<mat-toolbar *ngIf="!hide" [@collapseUp]="!hide" [@expandDown]="!hide" class="bg-primary">
|
||||
<mat-icon *ngIf="mobile" class="mr-2" (click)="open = !open">menu</mat-icon>
|
||||
<img src="assets/icon.png" class="mr-2" height="24px" width="auto">
|
||||
<img src="../../../assets/icon.png" class="mr-2" height="24px" width="auto">
|
||||
<span>
|
||||
<span style="font-weight: 500;">Home Front</span>
|
||||
<small class="text-muted ml-2">v{{environment.version}}</small>
|
||||
<small class="text-muted ml-2">v{{version}}</small>
|
||||
</span>
|
||||
</mat-toolbar>
|
||||
<mat-drawer-container class="fill-height" [hasBackdrop]="false">
|
@ -1,12 +1,12 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {BatteryService} from './battery/battery.service';
|
||||
import {BatteryService} from '../../services/battery.service';
|
||||
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
|
||||
import {environment} from '../environments/environment';
|
||||
import {collapseUp, expandDown, routerTransition} from './animations';
|
||||
import {collapseUp, expandDown, routerTransition} from '../../animations';
|
||||
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {WeatherService} from './weather/weather.service';
|
||||
import {WeatherService} from '../../services/weather.service';
|
||||
import {AngularFireAuth} from '@angular/fire/auth';
|
||||
import packageJson from 'package.json';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -18,11 +18,11 @@ export class AppComponent {
|
||||
mobile = true; // Mobile or desktop size
|
||||
noTransition = false; // Stop router transitions
|
||||
open = false; // Side nav open
|
||||
environment = environment; // Environment ref
|
||||
version = packageJson.version;
|
||||
|
||||
constructor(private auth: AngularFireAuth, private router: Router, public batteryService: BatteryService, public weatherService: WeatherService, route: ActivatedRoute, breakpointObserver: BreakpointObserver) {
|
||||
constructor(private auth: AngularFireAuth, private router: Router, private route: ActivatedRoute, public batteryService: BatteryService, public weatherService: WeatherService, breakpointObserver: BreakpointObserver) {
|
||||
router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => {
|
||||
this.hide = !!route.root.firstChild.snapshot.data.hide;
|
||||
this.hide = !!route.root.firstChild?.snapshot.data.hide;
|
||||
this.open = !this.hide && !this.mobile;
|
||||
});
|
||||
|
||||
@ -34,11 +34,11 @@ export class AppComponent {
|
||||
|
||||
async logout() {
|
||||
this.noTransition = true;
|
||||
await this.auth.auth.signOut();
|
||||
await this.auth.signOut();
|
||||
return this.router.navigate(['/login']).then(() => this.noTransition = false);
|
||||
}
|
||||
|
||||
transition(outlet) {
|
||||
transition(outlet: any) {
|
||||
if(!outlet.isActivated || !!outlet.activatedRouteData.noAnimation || this.noTransition) return '';
|
||||
return outlet.activatedRoute;
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
<div class="fill-height p-3" style="background-color: #b52e3c !important; overflow-y: scroll">
|
||||
<!-- Header -->
|
||||
<div class="ml-2 d-flex align-items-center">
|
||||
<div class="d-none d-sm-inline pr-2">
|
||||
<img src="assets/tesla.png" height="85px" width="auto">
|
||||
<div class="d-inline pr-2">
|
||||
<img src="../../../assets/tesla.png" height="85px" width="auto">
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="mb-0">Powerwall: {{batteryService.last.voltage | number : '1.1-1'}} V</h1>
|
||||
@ -9,28 +10,28 @@
|
||||
<h6 class="mb-0">Uptime: {{batteryService.last.uptime}}</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-100 mt-5">
|
||||
<div class="d-inline-block col-12 col-md-3 px-1">
|
||||
<mat-card class="d-inline-block col-6 col-md-12 m-0 m-md-2">
|
||||
<div class="mt-3 d-flex flex-column flex-md-row">
|
||||
<div class="d-flex flex-md-column flex-row flex-wrap">
|
||||
<mat-card style="margin: 10px; min-width: 200px; width: 200px; height: 200px;">
|
||||
<canvas id="netPower" class="w-100"></canvas>
|
||||
<h5 class="text-center text-muted"><strong>Power: </strong>{{batteryService.last.power | number : '1.1-1'}} Watts</h5>
|
||||
<h5 class="text-center text-muted"><strong>Current: </strong>{{batteryService.last.current | number : '1.1-1'}} Amps</h5>
|
||||
</mat-card>
|
||||
<mat-card class="d-inline-block col-6 col-md-12 m-0 m-md-2">
|
||||
<mat-card style="margin: 10px; min-width: 200px; width: 200px; height: 200px;">
|
||||
<mwl-gauge
|
||||
[max]="100"
|
||||
[color]="color"
|
||||
[dialStartAngle]="-90"
|
||||
[dialEndAngle]="-90.001"
|
||||
[value]="(batteryService.last.soc || 0) * 100"
|
||||
[label]="percent"
|
||||
[animated]="true"
|
||||
[animationDuration]="1">
|
||||
[max]="100"
|
||||
[color]="color"
|
||||
[dialStartAngle]="-90"
|
||||
[dialEndAngle]="-90.001"
|
||||
[value]="(batteryService.last.soc || 0) * 100"
|
||||
[label]="percent"
|
||||
[animated]="true"
|
||||
[animationDuration]="1">
|
||||
</mwl-gauge>
|
||||
</mat-card>
|
||||
</div>
|
||||
<div class="d-inline-block col-12 col-md-9 px-1">
|
||||
<mat-card class="h-100">
|
||||
<div class="flex-grow-1" style="overflow: hidden; margin: 10px">
|
||||
<mat-card class="w-100">
|
||||
<canvas baseChart
|
||||
[datasets]="socData"
|
||||
[labels]="socLabels"
|
||||
@ -41,6 +42,7 @@
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Battery Cells -->
|
||||
<div class="d-flex flex-wrap mt-5">
|
||||
<div class="p-2 col-12 col-sm-6 col-lg-3" *ngFor="let battery of batteries; let i = index">
|
||||
<mat-card>
|
@ -1,19 +1,19 @@
|
||||
import {Component, HostListener, OnInit} from '@angular/core';
|
||||
import {BatteryService} from './battery.service';
|
||||
import {AppComponent} from '../app.component';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {BatteryService} from '../../services/battery.service';
|
||||
import {AppComponent} from '../app/app.component';
|
||||
|
||||
declare const Gauge;
|
||||
declare const Gauge: any;
|
||||
|
||||
@Component({
|
||||
selector: 'app-batterys',
|
||||
selector: 'app-batteries',
|
||||
templateUrl: './battery.component.html',
|
||||
styles: [`.selected { background-color: rgba(0, 0, 0, 0.1); }`]
|
||||
})
|
||||
export class BatteryComponent implements OnInit {
|
||||
batteries = [];
|
||||
gauge;
|
||||
socData = [];
|
||||
socLabels = [];
|
||||
batteries: any[] = [];
|
||||
gauge: any;
|
||||
socData: any[] = [];
|
||||
socLabels: string[] = [];
|
||||
socOptions = {
|
||||
responsive: true,
|
||||
scales: {
|
||||
@ -21,15 +21,15 @@ export class BatteryComponent implements OnInit {
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
min: 0,
|
||||
max: 1,
|
||||
max: 1.2,
|
||||
step: 0.1,
|
||||
callback: (label) => this.percent(Math.round(label * 100))
|
||||
callback: (label: any) => this.percent(Math.round(label * 100))
|
||||
}
|
||||
}]
|
||||
},
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
label: (tooltipItem, data) => `SOC: ${this.percent(tooltipItem.yLabel * 100)}`
|
||||
label: (tooltipItem: any) => `SOC: ${this.percent(tooltipItem.yLabel * 100)}`
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -39,7 +39,7 @@ export class BatteryComponent implements OnInit {
|
||||
this.socLabels = data.filter(row => new Date(row.timestamp).getMinutes() % 15 == 0).map(row => this.dateFormat(new Date(row.timestamp)));
|
||||
this.socData = [{label: 'SOC', fill: false, data: data.filter(row => new Date(row.timestamp).getMinutes() % 15 == 0).map(row => row.soc)}];
|
||||
if(this.gauge) this.gauge.set(batteryService.last.power || 0);
|
||||
this.batteries = Object.keys(this.batteryService.modules).map(key => {
|
||||
this.batteries = Object.keys(this.batteryService.modules).map((key: string) => {
|
||||
return {
|
||||
name: `Module ${key}`,
|
||||
negativeTemperature: this.batteryService.modules[key][this.batteryService.modules[key].length - 1].negativeTemperature,
|
||||
@ -51,7 +51,9 @@ export class BatteryComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let canvas = document.getElementById('netPower');
|
||||
const canvas = document.getElementById('netPower');
|
||||
if(!canvas) return;
|
||||
|
||||
canvas.style.height = canvas.style.width;
|
||||
this.gauge = new Gauge(canvas).setOptions({
|
||||
angle: 0.2, // The span of the gauge arc
|
||||
@ -95,7 +97,7 @@ export class BatteryComponent implements OnInit {
|
||||
return '#4f55b6';
|
||||
}
|
||||
|
||||
percent(val) {
|
||||
percent(val: number) {
|
||||
return `${Math.round(val)}%`;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<h1 class="d-inline text-white">Home Front</h1>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<img src="assets/icon-inv.png" width="275px" height="auto">
|
||||
<img src="../../../assets/icon-inv.png" width="275px" height="auto">
|
||||
</div>
|
||||
</div>
|
||||
<div class="off-center" *ngIf="show" [@fadeOut]="true" [@expandDown]="animate">
|
@ -1,8 +1,9 @@
|
||||
import {Component, NgZone, OnInit} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import * as firebase from 'firebase';
|
||||
import {expandDown, fadeIn, fadeOut} from '../animations';
|
||||
import firebase from 'firebase';
|
||||
import {expandDown, fadeIn, fadeOut} from '../../animations';
|
||||
import {AngularFireAuth} from '@angular/fire/auth';
|
||||
import GoogleAuthProvider = firebase.auth.GoogleAuthProvider;
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@ -17,7 +18,7 @@ export class LoginComponent implements OnInit {
|
||||
constructor(private auth: AngularFireAuth, private ngZone: NgZone, public router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.auth.auth.onAuthStateChanged(user => {
|
||||
this.auth.onAuthStateChanged(user => {
|
||||
if(!!user) {
|
||||
this.show = false;
|
||||
setTimeout(() => {
|
||||
@ -31,7 +32,7 @@ export class LoginComponent implements OnInit {
|
||||
|
||||
async login() {
|
||||
this.loading = true;
|
||||
await this.auth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
|
||||
await this.auth.signInWithPopup(new GoogleAuthProvider());
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {WeatherService} from './weather.service';
|
||||
import {WeatherService} from '../../services/weather.service';
|
||||
import {timer} from 'rxjs';
|
||||
import {filter} from 'rxjs/operators';
|
||||
|
||||
@ -29,6 +29,7 @@ export class WeatherComponent implements OnInit {
|
||||
const c = <HTMLCanvasElement>document.getElementById('myCanvas');
|
||||
if (c) {
|
||||
const ctx = c.getContext('2d');
|
||||
if(!ctx) return;
|
||||
|
||||
// All the points in 2D space we care about
|
||||
const width = c.width;
|
@ -1,11 +0,0 @@
|
||||
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
#
|
||||
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
|
||||
|
||||
> 0.5%
|
||||
last 2 versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
not IE 9-11
|
@ -1,13 +1,12 @@
|
||||
export const environment = {
|
||||
accuWeather: 'DktD9hoGvnnylAWDA3p1lVvqPXOAuRZD',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyAs3FvBCADM66wR1-leBz6aIjK1wZfUxRo",
|
||||
authDomain: "homefront-2ccb4.firebaseapp.com",
|
||||
databaseURL: "https://homefront-2ccb4.firebaseio.com",
|
||||
projectId: "homefront-2ccb4",
|
||||
storageBucket: "homefront-2ccb4.appspot.com",
|
||||
messagingSenderId: "482384317544"
|
||||
},
|
||||
production: true,
|
||||
version: require('../../package.json').version
|
||||
accuWeather: 'DktD9hoGvnnylAWDA3p1lVvqPXOAuRZD',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyAs3FvBCADM66wR1-leBz6aIjK1wZfUxRo",
|
||||
authDomain: "homefront-2ccb4.firebaseapp.com",
|
||||
databaseURL: "https://homefront-2ccb4.firebaseio.com",
|
||||
projectId: "homefront-2ccb4",
|
||||
storageBucket: "homefront-2ccb4.appspot.com",
|
||||
messagingSenderId: "482384317544"
|
||||
},
|
||||
production: true
|
||||
};
|
||||
|
@ -1,13 +1,12 @@
|
||||
export const environment = {
|
||||
accuWeather: 'DktD9hoGvnnylAWDA3p1lVvqPXOAuRZD',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyAs3FvBCADM66wR1-leBz6aIjK1wZfUxRo",
|
||||
authDomain: "homefront-2ccb4.firebaseapp.com",
|
||||
databaseURL: "https://homefront-2ccb4.firebaseio.com",
|
||||
projectId: "homefront-2ccb4",
|
||||
storageBucket: "homefront-2ccb4.appspot.com",
|
||||
messagingSenderId: "482384317544"
|
||||
},
|
||||
production: false,
|
||||
version: require('../../package.json').version
|
||||
accuWeather: 'DktD9hoGvnnylAWDA3p1lVvqPXOAuRZD',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyAs3FvBCADM66wR1-leBz6aIjK1wZfUxRo",
|
||||
authDomain: "homefront-2ccb4.firebaseapp.com",
|
||||
databaseURL: "https://homefront-2ccb4.firebaseio.com",
|
||||
projectId: "homefront-2ccb4",
|
||||
storageBucket: "homefront-2ccb4.appspot.com",
|
||||
messagingSenderId: "482384317544"
|
||||
},
|
||||
production: false
|
||||
};
|
||||
|
@ -1,29 +1,31 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Home Front</title>
|
||||
<base href="/">
|
||||
<title>Home Front</title>
|
||||
<base href="/">
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="theme-color" content="#000000">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="assets/icon.png">
|
||||
<link rel="stylesheet" type="text/css" href="assets/bootstrap.min.css">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<link rel="icon" type="image/x-icon" href="assets/icon.png">
|
||||
<link rel="stylesheet" type="text/css" href="assets/bootstrap.min.css">
|
||||
<link rel="manifest" href="src/manifest.json">
|
||||
|
||||
<script src="https://bernii.github.io/gauge.js/dist/gauge.min.js"></script>
|
||||
<script src="https://bernii.github.io/gauge.js/dist/gauge.min.js"></script>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<meta name="theme-color" content="#1976d2">
|
||||
</head>
|
||||
<body style="background-color: #2F323A;">
|
||||
<body style="background-color: #2F323A;" class="mat-typography">
|
||||
<app-root>
|
||||
<div style="position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);">
|
||||
<div class="text-center">
|
||||
<h1 class="d-inline text-white">Home Front</h1>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<img src="assets/icon-inv.png" width="275px" height="auto">
|
||||
</div>
|
||||
<div style="position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);">
|
||||
<div class="text-center">
|
||||
<h1 class="d-inline text-white">Home Front</h1>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<img src="assets/icon-inv.png" width="275px" height="auto">
|
||||
</div>
|
||||
</div>
|
||||
</app-root>
|
||||
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
||||
</body>
|
||||
|
@ -1,31 +0,0 @@
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, '../coverage'),
|
||||
reports: ['html', 'lcovonly'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false
|
||||
});
|
||||
};
|
@ -1,11 +1,12 @@
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
import 'hammerjs';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.error(err));
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
||||
|
@ -18,61 +18,46 @@
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* If the application will be indexed by Google Search, the following is required.
|
||||
* Googlebot uses a renderer based on Chrome 41.
|
||||
* https://developers.google.com/search/docs/guides/rendering
|
||||
**/
|
||||
// import 'core-js/es6/array';
|
||||
|
||||
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
|
||||
* 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 for the Reflect API. */
|
||||
// import 'core-js/es6/reflect';
|
||||
|
||||
/**
|
||||
* Web Animations `@angular/platform-browser/animations`
|
||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||
**/
|
||||
*/
|
||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||
|
||||
/**
|
||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||
* will put import in the top of bundle, so user need to create a separate file
|
||||
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||
* into that file, and then add the following code before importing zone.js.
|
||||
* import './zone-flags';
|
||||
*
|
||||
* The flags allowed in zone-flags.ts are listed here.
|
||||
*
|
||||
* The following flags will work for all browsers.
|
||||
*
|
||||
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
*
|
||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||
*
|
||||
* (window as any).__Zone_enable_cross_context_check = true;
|
||||
*
|
||||
*/
|
||||
|
||||
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
|
||||
/*
|
||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||
*/
|
||||
// (window as any).__Zone_enable_cross_context_check = true;
|
||||
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by default for Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
import 'zone.js'; // Included with Angular CLI.
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
|
115
src/styles.scss
115
src/styles.scss
@ -1,155 +1,158 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
@import url('https://fonts.googleapis.com/css?family=Archivo|Material+Icons');
|
||||
@import url('https://fonts.googleapis.com/css?family=Roboto|Material+Icons');
|
||||
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
|
||||
@import url('https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css');
|
||||
@import url('https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons-wind.min.css');
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
border-radius: 10px;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
border-radius: 10px;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
width: 8px;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius: 4px;
|
||||
background-color: #555;
|
||||
border-radius: 4px;
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
:focus {
|
||||
outline: none !important;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
font-family: 'Archivo', sans-serif;
|
||||
background-color: #2F323A;
|
||||
font-family: 'Archivo', sans-serif;
|
||||
background-color: #2F323A;
|
||||
}
|
||||
|
||||
.bg-primary {
|
||||
background-color: #f8f8f8 !important;
|
||||
background-color: #f8f8f8 !important;
|
||||
}
|
||||
|
||||
.bg-secondary {
|
||||
background-color: #2F323A !important;
|
||||
background-color: #2F323A !important;
|
||||
}
|
||||
|
||||
.center {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.curs-pointer {
|
||||
cursor: pointer;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fill-height {
|
||||
height: calc(100vh - 64px);
|
||||
height: calc(100vh - 64px);
|
||||
}
|
||||
|
||||
.hover:hover {
|
||||
cursor: pointer;
|
||||
background-color: #dddddd !important;
|
||||
cursor: pointer;
|
||||
background-color: #dddddd !important;
|
||||
}
|
||||
|
||||
.flex-basis-0 {
|
||||
flex-basis: 0;
|
||||
flex-basis: 0;
|
||||
}
|
||||
|
||||
.flex-basis-auto {
|
||||
flex-basis: auto;
|
||||
flex-basis: auto;
|
||||
}
|
||||
|
||||
.flex-grow-0 {
|
||||
flex-grow: 0;
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
.flex-grow-1 {
|
||||
flex-grow: 1;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.flex-grow-2 {
|
||||
flex-grow: 2;
|
||||
flex-grow: 2;
|
||||
}
|
||||
|
||||
.flex-grow-3 {
|
||||
flex-grow: 3;
|
||||
flex-grow: 3;
|
||||
}
|
||||
|
||||
.flex-shrink-0 {
|
||||
flex-shrink: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.flex-shrink-1 {
|
||||
flex-shrink: 1;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.mat-divider {
|
||||
color: #9CA4B6 !important;
|
||||
color: #9CA4B6 !important;
|
||||
}
|
||||
|
||||
.mat-form-field label {
|
||||
color: #ffffff !important;
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.mat-list-item {
|
||||
height: auto !important;
|
||||
color: #9CA4B6 !important;
|
||||
height: auto !important;
|
||||
color: #9CA4B6 !important;
|
||||
|
||||
&.active {
|
||||
background-color: #262930 !important;
|
||||
color: #1CA8DD !important;
|
||||
}
|
||||
&.active {
|
||||
background-color: #262930 !important;
|
||||
color: #1CA8DD !important;
|
||||
}
|
||||
}
|
||||
|
||||
.mat-stroked-button:not([disabled]) {
|
||||
border-color: #ffffff !important;
|
||||
border-color: #ffffff !important;
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
vertical-align: middle;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.off-center {
|
||||
position: fixed;
|
||||
left: calc(50% - 75px);
|
||||
top: 75%;
|
||||
position: fixed;
|
||||
left: calc(50% - 75px);
|
||||
top: 75%;
|
||||
}
|
||||
|
||||
.scale-150 {
|
||||
transform: scale(1.5);
|
||||
transform: scale(1.5);
|
||||
}
|
||||
|
||||
.scale-200 {
|
||||
transform: scale(2);
|
||||
transform: scale(2);
|
||||
}
|
||||
|
||||
.scale-300 {
|
||||
transform: scale(3);
|
||||
transform: scale(3);
|
||||
}
|
||||
|
||||
.scale-500 {
|
||||
transform: scale(5);
|
||||
transform: scale(5);
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #7f7f7f !important;
|
||||
color: #7f7f7f !important;
|
||||
}
|
||||
|
||||
@media (max-width: 599px) {
|
||||
.fill-height {
|
||||
height: calc(100vh - 56px);
|
||||
}
|
||||
.fill-height {
|
||||
height: calc(100vh - 56px);
|
||||
}
|
||||
}
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
|
20
src/test.ts
20
src/test.ts
@ -1,20 +0,0 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
// 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);
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/app",
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": [
|
||||
"test.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"test.ts",
|
||||
"polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"**/*.spec.ts",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"directive-selector": [
|
||||
true,
|
||||
"attribute",
|
||||
"app",
|
||||
"camelCase"
|
||||
],
|
||||
"component-selector": [
|
||||
true,
|
||||
"element",
|
||||
"app",
|
||||
"kebab-case"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user