diff --git a/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.html b/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.html
index 4261dec207..4782283d49 100644
--- a/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.html
+++ b/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.html
@@ -24,7 +24,7 @@
skip_previous
-
+
{{ this.currentTime | date:'medium'}}
@@ -47,8 +47,8 @@
pause_circle_outline
-
+
{{speedValue}}
-
\ No newline at end of file
+
diff --git a/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.ts b/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.ts
index 7cdcc42eec..c5bc1d61c3 100644
--- a/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.ts
+++ b/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.ts
@@ -14,7 +14,7 @@
/// limitations under the License.
///
-import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
+import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
import { interval } from 'rxjs';
import { filter } from 'rxjs/operators';
import { HistorySelectSettings } from '@app/modules/home/components/widget/lib/maps/map-models';
@@ -24,9 +24,9 @@ import { HistorySelectSettings } from '@app/modules/home/components/widget/lib/m
templateUrl: './history-selector.component.html',
styleUrls: ['./history-selector.component.scss']
})
-export class HistorySelectorComponent implements OnInit, OnChanges {
+export class HistorySelectorComponent implements OnChanges {
- @Input() settings: HistorySelectSettings
+ @Input() settings: HistorySelectSettings;
@Input() minTime: number;
@Input() maxTime: number;
@Input() step = 1000;
@@ -47,9 +47,6 @@ export class HistorySelectorComponent implements OnInit, OnChanges {
constructor(private cd: ChangeDetectorRef) { }
- ngOnInit(): void {
- }
-
ngOnChanges() {
this.maxTimeIndex = Math.ceil((this.maxTime - this.minTime) / this.step);
this.currentTime = this.minTime === Infinity ? null : this.minTime;
@@ -57,34 +54,34 @@ export class HistorySelectorComponent implements OnInit, OnChanges {
play() {
this.playing = true;
- if (!this.interval)
+ if (!this.interval) {
this.interval = interval(1000 / this.speed)
.pipe(
- filter(() => this.playing)).subscribe(() => {
- this.index++;
- this.currentTime = this.minTime + this.index * this.step;
- if (this.index <= this.maxTimeIndex) {
- this.cd.detectChanges();
- this.timeUpdated.emit(this.currentTime);
- }
- else {
- this.interval.complete();
- }
- }, err => {
- console.error(err);
- }, () => {
- this.currentTime = this.index = this.minTimeIndex;
- this.playing = false;
- this.interval = null;
+ filter(() => this.playing)
+ ).subscribe(() => {
+ this.index++;
+ this.currentTime = this.minTime + this.index * this.step;
+ if (this.index <= this.maxTimeIndex) {
this.cd.detectChanges();
- });
+ this.timeUpdated.emit(this.currentTime);
+ } else {
+ this.playing = false;
+ this.interval.complete();
+ this.cd.detectChanges();
+ }
+ }, err => {
+ console.error(err);
+ }, () => {
+ this.interval = null;
+ });
+ }
}
- reeneble() {
- if (this.playing) {
- const position = this.index;
+ reInit() {
+ if (this.interval) {
this.interval.complete();
- this.index = position;
+ }
+ if (this.playing) {
this.play();
}
}
@@ -138,8 +135,9 @@ export class HistorySelectorComponent implements OnInit, OnChanges {
this.pause();
}
- changeIndex() {
- this.currentTime = this.minTime + this.index * this.step;
+ changeIndex(index: number) {
+ this.index = index;
+ this.currentTime = this.minTime + index * this.step;
this.timeUpdated.emit(this.currentTime);
}
}