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
fixes for dev merge
- Loading branch information
Showing
16 changed files
with
209 additions
and
103 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -130,4 +130,4 @@ | ||
} | } | ||
}, | }, | ||
"defaultProject": "frontend" | "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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
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<string>; | |||
status_count: number; | |||
status_codes: Array<string>; | |||
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,23 +1,32 @@ | |||
<div class="container "> | <div class="container"> | ||
<div class="row"> | <div class="row"> | ||
<div class="col-md-12 mx-auto mt-4"> | <div class="col-md-12 mx-auto mt-4"> | ||
<h4 class="text-center mb-3">Your Generators</h4> | <h4 class="text-center mb-3">Your Generators</h4> | ||
|
<mat-spinner *ngIf="loading$"></mat-spinner> | ||
<form id="visToolbar"> | <mat-grid-list cols="3" rowHeight="1:1"> | ||
<div class="text-center mb3"> | <mat-grid-tile *ngFor="let generator of generators$"> | ||
<br> | <mat-card mat-ripple class="generator-card" (click)="goToGenerator(generator)"> | ||
<a> | <mat-card-header> | ||
<a class="text-center"*ngFor="let generator of generators$"> | <mat-card-title>{{ generator.gen_name }}</mat-card-title> | ||
<a class="btn btn-primary" style="color:white" (click)="goToGenerator(generator.gen_id, generator.org_id, generator.gen_name)">{{ generator.gen_name }}</a> | <mat-card-subtitle>{{ generator.state.status }}</mat-card-subtitle> | ||
<p id="genInfo"> | </mat-card-header> | ||
zipcode: {{ generator.zip }} <br> | <mat-list *ngIf="generator.state.online"> | ||
(insert statistics preview here) | <mat-list-item> | ||
</p> | <mat-icon matListIcon>error</mat-icon> | ||
<br> | <p matLine> | ||
</a> | <span> Active Faults: {{ generator.state.fault_count }} </span> | ||
</a> | </p> | ||
</div> | </mat-list-item> | ||
</form> | <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> | ||
</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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,18 +1,50 @@ | |||
import { Injectable } from '@angular/core'; | 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({ | @Injectable({ | ||
providedIn: 'root' | providedIn: 'root' | ||
}) | }) | ||
export class GeneratorService { | export class GeneratorService { | ||
|
|
||
constructor(private http: HttpClient) { } | constructor(private http: HttpClient, private login: LoginService) { } | ||
|
|
||
getGenerators(token) { | getGenerators(token: string): Promise<Array<GeneratorObject>> { | ||
return this.http.get('http://sd5-backend.engr.uconn.edu/user/generators', { | return new Promise<Array<GeneratorObject>>((resolve, reject) => { | ||
headers: { | this.http.get('http://sd5-backend.engr.uconn.edu/user/generators', { | ||
Authorization: 'Bearer ' + token | headers: { | ||
} | Authorization: 'Bearer ' + token | ||
} | |||
}).subscribe(async (raw_generators: Array<GeneratorObject>) => { | |||
const generators: Array<GeneratorObject> = []; | |||
for (const generator of raw_generators) { | |||
await this.getGeneratorState(generator.gen_id, token).then((state: GeneratorState) => { | |||
generator.state = state; | |||
generators.push(generator); | |||
}, (error) => { | |||
reject(error); | |||
}); | |||
} | |||
resolve(generators); | |||
}, (error) => { | |||
reject(error); | |||
}); | |||
}); | }); | ||
} | } | ||
|
|||
getGeneratorState(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 + '/state', { | |||
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.