Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed titles and multiple generator select issue
  • Loading branch information
rrc12004 committed Apr 15, 2019
1 parent 5ca36ea commit 9ebfbd4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/visualize-all/visualize-all.component.html
Expand Up @@ -17,7 +17,7 @@
<p id="visMessage">Ctrl/Comm+Click to select multiple generators <br> Please select a maximum of 5 generators
</p>
<select id="gen_select" name="generatorSelect" multiple>
<option *ngFor="let generator of generators$" value="{{generator.gen_id}},{{generator.gen_name}}" selected>
<option *ngFor="let generator of generators$" value="{{generator.gen_id}},{{generator.gen_name}}">
{{generator.gen_name}}</option>
</select>
<br><br>
Expand Down
23 changes: 14 additions & 9 deletions src/app/visualize-all/visualize-all.component.ts
Expand Up @@ -8,8 +8,8 @@ import 'rxjs/add/operator/map';
import { $ } from 'protractor';
import * as moment from 'moment';
import { MatDatepickerModule, MatDatepicker } from '@angular/material/datepicker';
import {GeneratorObject} from '../generator-object';
import {LoginService} from '../services/login.service';
import { GeneratorObject } from '../generator-object';
import { LoginService } from '../services/login.service';

@Component({
selector: 'app-visualize-all',
Expand Down Expand Up @@ -52,10 +52,8 @@ export class VisualizeAllComponent implements OnInit {
const genValArray = [];
let genCount;
if (this.count === 0) {
for (const key in this.generators$) {
if (this.generators$.hasOwnProperty(key)) {
genVals.push(this.generators$[key].gen_id + ',' + this.generators$[key].gen_name);
}
if (this.generators$) {
genVals.push(this.generators$[0].gen_id + ',' + this.generators$[0].gen_name);
}
} else {
genVals = Array.prototype.slice.call(document.querySelectorAll('#gen_select option:checked'), 0).map(function (v, i, a) {
Expand All @@ -65,7 +63,11 @@ export class VisualizeAllComponent implements OnInit {
genCount = genVals.length;
this.signal = false;

if (genVals[0] !== '') {
if (genCount === 0 ) {
genVal = 'generator';
this.signal = true;
errorMessage.push(genVal);
} else if (genVals[0] !== '') {
for (let i = 0; i < genVals.length; i++) {
const array = genVals[i].split(',');
const n = 0;
Expand Down Expand Up @@ -112,14 +114,16 @@ export class VisualizeAllComponent implements OnInit {
return v.value;
});
if (dataVals[0] !== '') {
this.laymanDataVal$ = dataVal = dataVals[0] + '';
dataVal = this.data.convertNames(dataVal, 'metric');
dataVal = this.data.convertNames(dataVals[0], 'metric');
} else {
dataVal = 'metric';
errorMessage.push(dataVal);
this.signal = true;
}
}
if (dataVal !== null) {
this.laymanDataVal$ = this.data.convertNames(dataVal, 'layman');
}


if (this.count === 0) {
Expand Down Expand Up @@ -205,6 +209,7 @@ export class VisualizeAllComponent implements OnInit {
if (this.signal === false) {
const labels = [];
const data = [];
console.log(timeStart, timeEnd, funcVal, genVal, dataVal, rangeVal);
try {
this.graphData.getDataForVis(this.jsonToken$, timeStart, timeEnd, funcVal, genVal, dataVal, rangeVal)
.subscribe((graphData) => {
Expand Down
14 changes: 11 additions & 3 deletions src/app/visualize-one/visualize-one.component.ts
Expand Up @@ -74,7 +74,11 @@ export class VisualizeOneComponent implements OnInit {
const dataType = localStorage.getItem('data_type');
let dataVal;
if (this.count === 0) {
dataVal = 'intake.pressure';
if (dataType === null) {
dataVal = 'intake.pressure';
} else {
dataVal = dataType;
}
} else if (dataType === null) {
const dataVals = Array.prototype.slice.call(document.querySelectorAll('#data_select option:checked'), 0).map(function (v, i, a) {
return v.value;
Expand All @@ -94,6 +98,10 @@ export class VisualizeOneComponent implements OnInit {
} else {
dataVal = dataType;
}
if (dataVal !== null) {
this.laymanDataVal$ = this.data.convertNames(dataVal, 'layman');
this.dataType$ = this.laymanDataVal$;
}

let startTime = '';
let endTime = '';
Expand Down Expand Up @@ -227,8 +235,8 @@ export class VisualizeOneComponent implements OnInit {
}

async ngOnInit() {
this.today$ = new Date().toISOString().split('T')[0];
this.count = 0;
const today = new Date().toISOString().split('T')[0];
this.today$ = today;
this.dataNames$ = this.data.getAllNames('layman');
this.jsonToken$ = await this.login.getToken();
const dataType = localStorage.getItem('data_type');
Expand Down

0 comments on commit 9ebfbd4

Please sign in to comment.