changed data display added data segregation code
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -999,6 +999,14 @@
|
|||||||
"tslib": "^1.9.0"
|
"tslib": "^1.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@angular/flex-layout": {
|
||||||
|
"version": "8.0.0-beta.27",
|
||||||
|
"resolved": "https://registry.npmjs.org/@angular/flex-layout/-/flex-layout-8.0.0-beta.27.tgz",
|
||||||
|
"integrity": "sha512-qmpvQPesU4ZQ56IscwgmVRpK2UnyV+gwvXUql7TMv0QV215hLcHczjGsrKkLfW2By5E7XEyDat9br72uVXcPMw==",
|
||||||
|
"requires": {
|
||||||
|
"tslib": "^1.7.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@angular/forms": {
|
"@angular/forms": {
|
||||||
"version": "8.2.10",
|
"version": "8.2.10",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/forms/-/forms-8.2.10.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/forms/-/forms-8.2.10.tgz",
|
||||||
@@ -4994,9 +5002,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"https-proxy-agent": {
|
"https-proxy-agent": {
|
||||||
"version": "2.2.2",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.3.tgz",
|
||||||
"integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==",
|
"integrity": "sha512-Ytgnz23gm2DVftnzqRRz2dOXZbGd2uiajSw/95bPp6v53zPRspQjLm/AfBgqbJ2qfeRXWIOMVLpp86+/5yX39Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"agent-base": "^4.3.0",
|
"agent-base": "^4.3.0",
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "~8.2.0",
|
"@angular/animations": "~8.2.0",
|
||||||
"@angular/cdk": "~8.2.3",
|
"@angular/cdk": "^8.2.3",
|
||||||
"@angular/common": "~8.2.0",
|
"@angular/common": "~8.2.0",
|
||||||
"@angular/compiler": "~8.2.0",
|
"@angular/compiler": "~8.2.0",
|
||||||
"@angular/core": "~8.2.0",
|
"@angular/core": "~8.2.0",
|
||||||
|
"@angular/flex-layout": "^8.0.0-beta.27",
|
||||||
"@angular/forms": "~8.2.0",
|
"@angular/forms": "~8.2.0",
|
||||||
"@angular/material": "^8.2.3",
|
"@angular/material": "^8.2.3",
|
||||||
"@angular/platform-browser": "~8.2.0",
|
"@angular/platform-browser": "~8.2.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
@@ -41,7 +41,8 @@ import { NgxGaugeModule} from 'ngx-gauge';
|
|||||||
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
|
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NgxGaugeModule
|
NgxGaugeModule,
|
||||||
|
FlexLayoutModule
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export class AvatarComponent {
|
|||||||
this.compressor.compress(file).subscribe(
|
this.compressor.compress(file).subscribe(
|
||||||
() => {
|
() => {
|
||||||
const { name, size, type } = file;
|
const { name, size, type } = file;
|
||||||
// console.log('compressed size: ', size);
|
// console.log('compressed size: ', size, name, type);
|
||||||
const fileName = file.name.split('.');
|
const fileName = file.name.split('.');
|
||||||
const fileExt = fileName[fileName.length - 1];
|
const fileExt = fileName[fileName.length - 1];
|
||||||
this.s3ImagePath = `${this.s3ImagePath}/picture.${fileExt}`;
|
this.s3ImagePath = `${this.s3ImagePath}/picture.${fileExt}`;
|
||||||
@@ -114,11 +114,13 @@ export class AvatarComponent {
|
|||||||
})
|
})
|
||||||
.catch( error => {
|
.catch( error => {
|
||||||
this.completeFileUpload(error);
|
this.completeFileUpload(error);
|
||||||
|
console.log('error uploading image');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
completeFileUpload(error?: any) {
|
completeFileUpload(error?: any) {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
console.log('error completeing upload');
|
||||||
return this._setError(error);
|
return this._setError(error);
|
||||||
}
|
}
|
||||||
this.uploading = false;
|
this.uploading = false;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<label>Profile Picture</label>
|
<label>Profile Picture</label>
|
||||||
<app-avatar
|
<app-avatar
|
||||||
[url]="currentAvatarUrl"
|
[url]="currentAvatarUrl"
|
||||||
(loaded)="this.loading.show()"
|
(loaded)="onAvatarUploadStart()"
|
||||||
(uploaded)="onAvatarUploadComplete($event)"
|
(uploaded)="onAvatarUploadComplete($event)"
|
||||||
(removed)="onAvatarRemove()">
|
(removed)="onAvatarRemove()">
|
||||||
</app-avatar>
|
</app-avatar>
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ export class ProfileComponent implements OnInit {
|
|||||||
.then(() => this.router.navigate(['auth/signin']));
|
.then(() => this.router.navigate(['auth/signin']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAvatarUploadStart() {
|
||||||
|
// this.loading.show();
|
||||||
|
// console.log(this.loading);
|
||||||
|
}
|
||||||
onAvatarUploadComplete(data: any) {
|
onAvatarUploadComplete(data: any) {
|
||||||
this.avatar = data.key;
|
this.avatar = data.key;
|
||||||
this.loading.hide();
|
this.loading.hide();
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-raised-button color="primary" (click)="signIn()" [disabled]="!signinForm.valid">Sign In</button>
|
<button mat-raised-button color="primary" (click)="signIn()" [disabled]="!signinForm.valid">Sign In</button>
|
||||||
<p style="text-align:center;">or</p>
|
<!--<p style="text-align:center;">or</p>
|
||||||
<button mat-raised-button color="primary" (click)="signInWithFacebook()">Sign In with Facebook</button><br/><br/>
|
<button mat-raised-button color="primary" (click)="signInWithFacebook()">Sign In with Facebook</button><br/><br/>
|
||||||
<button mat-raised-button color="primary" (click)="signInWithGoogle()">Sign In with Google</button>
|
<button mat-raised-button color="primary" (click)="signInWithGoogle()">Sign In with Google</button> -->
|
||||||
<p>Don't have an account? <a routerLink="/auth/signup">Sign up</a></p>
|
<p>Don't have an account? <a routerLink="/auth/signup">Sign up</a></p>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export class SignInComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async signInWithFacebook() {
|
/* async signInWithFacebook() {
|
||||||
const socialResult = await this.auth.socialSignIn(AuthService.FACEBOOK);
|
const socialResult = await this.auth.socialSignIn(AuthService.FACEBOOK);
|
||||||
console.log('fb Result:', socialResult);
|
console.log('fb Result:', socialResult);
|
||||||
}
|
}
|
||||||
@@ -76,5 +76,5 @@ export class SignInComponent {
|
|||||||
async signInWithGoogle() {
|
async signInWithGoogle() {
|
||||||
const socialResult = await this.auth.socialSignIn(AuthService.GOOGLE);
|
const socialResult = await this.auth.socialSignIn(AuthService.GOOGLE);
|
||||||
console.log('google Result:', socialResult);
|
console.log('google Result:', socialResult);
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,66 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class ="viewer">
|
<div class ="viewer">
|
||||||
<div class="message" >
|
<div class="container" fxLayout="row wrap" fxLayoutGap="10px">Total Flow Rate {{ totalFlowRate }}</div>
|
||||||
<p><span>Location: {{ currentMessage.location.S }}</span></p>
|
<mat-divider ></mat-divider>
|
||||||
<p><span>Company: {{ currentMessage.company.S }}</span></p>
|
<div class="container" fxLayout="row wrap" fxLayoutGap="10px">
|
||||||
<p><span>Field: {{ currentMessage.field.S }}</span></p>
|
<mat-accordion>
|
||||||
|
<mat-expansion-panel *ngFor="let message of serverMessages">
|
||||||
|
<mat-expansion-panel-header>
|
||||||
|
<mat-panel-title>
|
||||||
|
{{ message.location }}
|
||||||
|
</mat-panel-title>
|
||||||
|
<mat-panel-description>
|
||||||
|
{{ message.company }}
|
||||||
|
</mat-panel-description>
|
||||||
|
<mat-panel-description>
|
||||||
|
{{ message.field }}
|
||||||
|
</mat-panel-description>
|
||||||
|
<mat-panel-description>
|
||||||
|
Flow Rate: {{ message.volume_flow }}
|
||||||
|
</mat-panel-description>
|
||||||
|
</mat-expansion-panel-header>
|
||||||
|
<ngx-gauge
|
||||||
|
[type] = "gaugeType"
|
||||||
|
[cap] = "gaugeCap"
|
||||||
|
[value] = "message.volume_flow"
|
||||||
|
[label] = "gaugeLabel"
|
||||||
|
[append] = "gaugeAppendText"
|
||||||
|
[thick] = "gaugeThick"
|
||||||
|
[min] = "gaugeMin"
|
||||||
|
[max] = "gaugeMax"
|
||||||
|
[thresholds] = "gaugeThresholds">
|
||||||
|
</ngx-gauge>
|
||||||
|
<ngx-gauge
|
||||||
|
[type] = "gaugeType"
|
||||||
|
[cap] = "gaugeCap"
|
||||||
|
[value] = "message.current"
|
||||||
|
[label] = "gaugeLabel"
|
||||||
|
[append] = "gaugeAppendText"
|
||||||
|
[thick] = "gaugeThick"
|
||||||
|
[min] = "gaugeMin"
|
||||||
|
[max] = "gaugeMax"
|
||||||
|
[thresholds] = "gaugeThresholds">
|
||||||
|
<ngx-gauge-label>Current</ngx-gauge-label>
|
||||||
|
<ngx-gauge-append>A</ngx-gauge-append>
|
||||||
|
</ngx-gauge>
|
||||||
|
<ngx-gauge
|
||||||
|
[type] = "gaugeType"
|
||||||
|
[cap] = "gaugeCap"
|
||||||
|
[value] = "message.intake_pressure"
|
||||||
|
[label] = "gaugeLabel"
|
||||||
|
[append] = "gaugeAppendText"
|
||||||
|
[thick] = "gaugeThick"
|
||||||
|
[min] = "gaugeMin"
|
||||||
|
[max] = "gaugeMax"
|
||||||
|
[thresholds] = "gaugeThresholds">
|
||||||
|
<ngx-gauge-label>Intake Pressure</ngx-gauge-label>
|
||||||
|
<ngx-gauge-append>PSI</ngx-gauge-append>
|
||||||
|
</ngx-gauge>
|
||||||
|
</mat-expansion-panel>
|
||||||
|
</mat-accordion>
|
||||||
</div>
|
</div>
|
||||||
<ngx-gauge
|
|
||||||
[type] = "gaugeType"
|
|
||||||
[cap] = "gaugeCap"
|
|
||||||
[value] = "gaugeValue"
|
|
||||||
[label] = "gaugeLabel"
|
|
||||||
[append] = "gaugeAppendText"
|
|
||||||
[thick] = "gaugeThick"
|
|
||||||
[min] = "gaugeMin"
|
|
||||||
[max] = "gaugeMax"
|
|
||||||
[thresholds] = "gaugeThresholds">
|
|
||||||
|
|
||||||
</ngx-gauge>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--style="float:left;display:inline-block;height:50px;"-->
|
||||||
|
<!-- [ngStyle]="{'width': 'calc(100% /' + serverMessages.length + ')'}"-->
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.message {
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
@@ -1,7 +1,15 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { WebSocketSubject } from 'rxjs/webSocket';
|
import { WebSocketSubject } from 'rxjs/webSocket';
|
||||||
import Auth from '@aws-amplify/auth';
|
import Auth from '@aws-amplify/auth';
|
||||||
|
|
||||||
|
export class MyJSON {
|
||||||
|
location: '';
|
||||||
|
company: '';
|
||||||
|
volume_flow: 0;
|
||||||
|
field: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
@@ -9,16 +17,15 @@ import Auth from '@aws-amplify/auth';
|
|||||||
styleUrls: ['./home.component.scss']
|
styleUrls: ['./home.component.scss']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class HomeComponent implements OnInit {
|
export class HomeComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
public serverMessages = new Array<JSON>();
|
|
||||||
|
|
||||||
|
public serverMessages = new Array<MyJSON>();
|
||||||
private socket$: WebSocketSubject<any>;
|
private socket$: WebSocketSubject<any>;
|
||||||
private currentMessage = {location: {S: ''}, company: {S: ''}, volume_flow: {N: ''}, field: {S: ''}};
|
private currentMessage = {location: '', company: '', volume_flow: '', field: ''};
|
||||||
private token: string;
|
private totalFlowRate = 0;
|
||||||
gaugeType = 'arch';
|
gaugeType = 'arch';
|
||||||
gaugeCap = 'round';
|
gaugeCap = 'round';
|
||||||
gaugeValue = this.currentMessage.volume_flow.N;
|
gaugeValue = this.currentMessage.volume_flow;
|
||||||
gaugeLabel = 'Volume Flow';
|
gaugeLabel = 'Volume Flow';
|
||||||
gaugeAppendText = 'gpm';
|
gaugeAppendText = 'gpm';
|
||||||
gaugeThick = 10;
|
gaugeThick = 10;
|
||||||
@@ -31,29 +38,64 @@ export class HomeComponent implements OnInit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
Auth.currentSession().then(data => {
|
Auth.currentAuthenticatedUser().then(data => {
|
||||||
console.log(data.getAccessToken().getJwtToken());
|
this.connectWS(data.signInUserSession.accessToken.jwtToken, data.signInUserSession.idToken.payload['cognito:preferred_role'] );
|
||||||
this.token = data.getAccessToken().getJwtToken();
|
this.subscribeWS();
|
||||||
this.connectWS(this.token);
|
this.socket$.next({action: 'getDashboardData', policy: data.signInUserSession.idToken.payload['cognito:preferred_role']});
|
||||||
// this.subscribeWS();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
connectWS(token: string) {
|
ngOnDestroy() {
|
||||||
this.socket$ = new WebSocketSubject('wss://3fseaywb8b.execute-api.us-east-1.amazonaws.com/prototype?token=' + token);
|
this.socket$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
connectWS(token: string, role: string) {
|
||||||
|
this.socket$ = new WebSocketSubject('wss://3fseaywb8b.execute-api.us-east-1.amazonaws.com/prototype?token=' + token +
|
||||||
|
'&role=' + role);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeWS() {
|
subscribeWS() {
|
||||||
this.socket$
|
this.socket$
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(message) => {this.currentMessage = message;
|
(message) => {
|
||||||
this.gaugeValue = parseFloat(this.currentMessage.volume_flow.N).toFixed(2);
|
console.log(message);
|
||||||
}, // this.serverMessages.push(message),
|
if (message instanceof Array) {
|
||||||
|
message.forEach(element => {
|
||||||
|
this.updateList(element);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.updateList(message);
|
||||||
|
}
|
||||||
|
this.totalFlowRate = this.totalFlowRates(0);
|
||||||
|
},
|
||||||
(err) => console.error(err),
|
(err) => console.error(err),
|
||||||
() => console.warn('Completed!')
|
() => console.warn('Completed!')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateList(obj) {
|
||||||
|
const index = this.serverMessages.findIndex((e) => e.location === obj.location);
|
||||||
|
obj.volume_flow = parseFloat(obj.volume_flow).toFixed(2);
|
||||||
|
obj.current = parseFloat(obj.current).toFixed(2);
|
||||||
|
obj.intake_pressure = parseFloat(obj.intake_pressure).toFixed(2);
|
||||||
|
if (index === -1) {
|
||||||
|
this.serverMessages.push(obj);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.serverMessages[index] = obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalFlowRates(temp: number) {
|
||||||
|
temp = 0;
|
||||||
|
this.serverMessages.forEach(element => {
|
||||||
|
temp += Number(element.volume_flow);
|
||||||
|
});
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class LoaderService {
|
|||||||
this.dialogRef = this.dialog.open(LoaderComponent, {
|
this.dialogRef = this.dialog.open(LoaderComponent, {
|
||||||
width: '80%',
|
width: '80%',
|
||||||
data: { message },
|
data: { message },
|
||||||
closeOnNavigation: false
|
closeOnNavigation: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CdkTableModule } from '@angular/cdk/table';
|
import { CdkTableModule } from '@angular/cdk/table';
|
||||||
import { CdkTreeModule } from '@angular/cdk/tree';
|
import { CdkTreeModule } from '@angular/cdk/tree';
|
||||||
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||||
import {
|
import {
|
||||||
MatAutocompleteModule,
|
MatAutocompleteModule,
|
||||||
MatBadgeModule,
|
MatBadgeModule,
|
||||||
@@ -42,6 +43,7 @@ import {
|
|||||||
exports: [
|
exports: [
|
||||||
CdkTableModule,
|
CdkTableModule,
|
||||||
CdkTreeModule,
|
CdkTreeModule,
|
||||||
|
DragDropModule,
|
||||||
MatAutocompleteModule,
|
MatAutocompleteModule,
|
||||||
MatBadgeModule,
|
MatBadgeModule,
|
||||||
MatBottomSheetModule,
|
MatBottomSheetModule,
|
||||||
|
|||||||
Reference in New Issue
Block a user