Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'development' into faults
- Loading branch information
Showing
16 changed files
with
192 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,4 +130,4 @@ | |
} | ||
}, | ||
"defaultProject": "frontend" | ||
} | ||
} |
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
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,17 @@ | ||
export interface GeneratorObject { | ||
gen_id: number; | ||
gen_name: string; | ||
org_id: number; | ||
zip: number; | ||
state: GeneratorState | null; | ||
} | ||
|
||
export interface GeneratorState { | ||
online: boolean; | ||
status: string; | ||
status_code: number; | ||
fault_count: number | null; | ||
fault_codes: Array<number> | null; | ||
ip: string; | ||
} | ||
|
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 |
---|---|---|
@@ -1,23 +1,32 @@ | ||
<div class="container "> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-12 mx-auto mt-4"> | ||
<h4 class="text-center mb-3">Your Generators</h4> | ||
|
||
<form id="visToolbar"> | ||
<div class="text-center mb3"> | ||
<br> | ||
<a> | ||
<a class="text-center"*ngFor="let generator of generators$"> | ||
<a class="btn btn-primary" style="color:white" (click)="goToGenerator(generator.gen_id, generator.org_id, generator.gen_name)">{{ generator.gen_name }}</a> | ||
<p id="genInfo"> | ||
zipcode: {{ generator.zip }} <br> | ||
(insert statistics preview here) | ||
</p> | ||
<br> | ||
</a> | ||
</a> | ||
</div> | ||
</form> | ||
<h4 class="text-center mb-3">Your Generators</h4> | ||
<mat-spinner *ngIf="loading$"></mat-spinner> | ||
<mat-grid-list cols="3" rowHeight="1:1"> | ||
<mat-grid-tile *ngFor="let generator of generators$"> | ||
<mat-card mat-ripple class="generator-card" (click)="goToGenerator(generator)"> | ||
<mat-card-header> | ||
<mat-card-title>{{ generator.gen_name }}</mat-card-title> | ||
<mat-card-subtitle>{{ generator.state.status }}</mat-card-subtitle> | ||
</mat-card-header> | ||
<mat-list *ngIf="generator.state.online"> | ||
<mat-list-item> | ||
<mat-icon matListIcon>error</mat-icon> | ||
<p matLine> | ||
<span> Active Faults: {{ generator.state.fault_count }} </span> | ||
</p> | ||
</mat-list-item> | ||
<mat-list-item> | ||
<mat-icon matListIcon>settings_ethernet</mat-icon> | ||
<p matLine> | ||
<span> IP Address: {{ generator.state.ip }} </span> | ||
</p> | ||
</mat-list-item> | ||
</mat-list> | ||
</mat-card> | ||
</mat-grid-tile> | ||
</mat-grid-list> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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
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 |
---|---|---|
@@ -1,18 +1,50 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import {HttpClient, HttpResponse} from '@angular/common/http'; | ||
import {GeneratorObject, GeneratorState} from '../generator-object'; | ||
import {LoginService} from './login.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class GeneratorService { | ||
|
||
constructor(private http: HttpClient) { } | ||
constructor(private http: HttpClient, private login: LoginService) { } | ||
|
||
getGenerators(token) { | ||
return this.http.get('http://sd5-backend.engr.uconn.edu/user/generators', { | ||
headers: { | ||
Authorization: 'Bearer ' + token | ||
} | ||
getGenerators(token: string): Promise<Array<GeneratorObject>> { | ||
return new Promise<Array<GeneratorObject>>((resolve, reject) => { | ||
this.http.get('http://sd5-backend.engr.uconn.edu/user/generators', { | ||
headers: { | ||
Authorization: 'Bearer ' + token | ||
} | ||
}).subscribe(async (raw_generators: Array<GeneratorObject>) => { | ||
const generators: Array<GeneratorObject> = []; | ||
for (const generator of raw_generators) { | ||
await this.getGeneratorStatus(generator.gen_id, token).then((state: GeneratorState) => { | ||
generator.state = state; | ||
generators.push(generator); | ||
}, (error) => { | ||
reject(error); | ||
}); | ||
} | ||
resolve(generators); | ||
}, (error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
|
||
getGeneratorStatus(gen_id: number, token: string): Promise<GeneratorState> { | ||
return new Promise<GeneratorState>((resolve, reject) => { | ||
this.http.get('http://sd5-backend.engr.uconn.edu/generator/' + gen_id + '/status', { | ||
headers: { | ||
Authorization: 'Bearer ' + token | ||
} | ||
}).subscribe((state: GeneratorState) => { | ||
resolve(state); | ||
}, (error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
|
||
} |
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
Oops, something went wrong.