Skip to content

Commit

Permalink
frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
HHL committed Nov 26, 2018
1 parent 3840040 commit caa9dac
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 54 deletions.
39 changes: 14 additions & 25 deletions Frontend/dist/Frontend/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Frontend/dist/Frontend/main.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<select class="form-control" formControlName="deviceId"
(change)="onChangeSensor($event)">
<option *ngFor="let sensor of sensors; let i = index" [value]="sensor.id">
{{sensor.id}}
{{sensor.name ? sensor.name : sensor.id}}
</option>
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export class EditComponent implements OnInit {
const editedSensor = {
id: formValue.deviceId,
period: formValue.period,
status: this.selectedSensor.status
status: this.selectedSensor.status,
name: !formValue.deviceName || (formValue.deviceName && formValue.deviceName.length === 0)
? null
: formValue.deviceName
};

if (formValue.deviceName) {
editedSensor['name'] = formValue.deviceName;
}
this.sensorService.updateSensors(editedSensor).subscribe(res => {
this.onUpdated.emit(editedSensor);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*ngFor="let device of sensors; let i = index"
[value]="device">
<div class="row">
<div class="col-auto">
<div class="COL-9 description">
{{device.name ? device.name : device.id}}
</div>
<div class="col text-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,10 @@ input[type="time"]:focus {
box-shadow: 0px 0px 1px 3px rgba(68,139,252,1);
}

.description {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}


Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {UpdateSensorsSAction} from 'store/actions/sensors';
})
export class FilterBarComponent implements OnInit {
form: FormGroup;
sensors: Sensor[];
sensors: Sensor[] = [];
@Output() onChangedValue = new EventEmitter();
isLoading: boolean;

Expand Down
34 changes: 13 additions & 21 deletions Frontend/src/app/modules/home/pages/home-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {SensorService} from '../services/sensor.service';
import {Store} from '@ngrx/store';
import * as fromRoot from 'store/reducers';
import {SensorsLoadedFailAction, SensorsLoadedSuccessAction, SensorsLoadingAction} from 'store/actions/sensors';
import {interval} from 'rxjs';
import {flatMap} from 'tslint/lib/utils';
import {tap} from 'rxjs/internal/operators';

@Component({
selector: 'app-homepage',
Expand All @@ -22,9 +25,16 @@ export class HomePageComponent implements OnInit {
}

ngOnInit() {
setTimeout(() => {
this.getAllSensors();
}, 500);
// interval(60 * 60 * 1000)
// .pipe(
// tap(() => {
setTimeout(() => {
this.getAllSensors();
}, 500);
// })
// )
// .subscribe();


}

Expand All @@ -45,29 +55,11 @@ export class HomePageComponent implements OnInit {
}

private getAllSensors() {
// this.isLoading = true;
this.store.dispatch(new SensorsLoadingAction());
// const testData = [
// {
// id: 'test12',
// name: '345',
// period: 456,
// status: SensorStatus.CONNECTED
// },
// {
// id: 'thahah',
// name: 'hoho',
// period: 456,
// status: SensorStatus.DISCONNECTED
// }];
// this.store.dispatch(new SensorsLoadedSuccessAction(testData));
// this.isLoading = false;
this.sensorService.getAllSenors().subscribe(sensorList => {
this.store.dispatch(new SensorsLoadedSuccessAction(sensorList));
// this.isLoading = false;
}, error1 => {
this.store.dispatch(new SensorsLoadedFailAction());
// this.isLoading = false;
});

}
Expand Down

0 comments on commit caa9dac

Please sign in to comment.