Skip to content

Commit

Permalink
Merge pull request #1996 from asfadmin/andy/DS-5552-Multiline-ASF-2
Browse files Browse the repository at this point in the history
Andy/ds 5552 multiline asf 2
  • Loading branch information
artisticlight authored Nov 6, 2024
2 parents 8873340 + 5eb69e5 commit a813530
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 47 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,3 @@ testem.log
.DS_Store
Thumbs.db
local-serve.sh

src/app/components/timeseries-chart/timeseries-chart-abort.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export class SbasSlidersTwoComponent implements OnInit, OnDestroy {
this.daysControl = new UntypedFormControl(this.daysRange, Validators.min(0));

const daysSliderRef = this.makeDaysSlider$(this.temporalFilter);
const tempSlider = daysSliderRef.slider;
// const tempSlider = daysSliderRef.slider;
const daysValues$ = daysSliderRef.daysValues;

this.tempSlider = tempSlider;
// this.tempSlider = tempSlider;

fromEvent(this.meterFilter.nativeElement, 'keyup').pipe(
map((event: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
<app-timeseries-chart
[chartData]="chartData"
[isLoading]="isLoading"></app-timeseries-chart>
<app-timeseries-chart-temporal-slider></app-timeseries-chart-temporal-slider>
<app-timeseries-chart-temporal-slider
[maxRange]="maxRange" ></app-timeseries-chart-temporal-slider>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AppState } from '@store';
import * as uiStore from '@store/ui';
import * as searchStore from '@store/search';
import * as mapStore from '@store/map';
import * as models from '@models';

import { DrawService, MapService, NetcdfService, PointHistoryService, ScreenSizeService, WktService } from '@services';
import { Breakpoints, SearchType, MapInteractionModeType, MapDrawModeType } from '@models';
Expand All @@ -23,6 +24,20 @@ export interface Task {
subtasks?: Task[];
}

export interface PointSeries {
bytes: number;
interferometric_correlation: number;
netcdf_uri: string;
persistent_scatterer_mask: number;
reference_datetime: string;
secondary_datetime: string;
short_wavelength_displacement: number;
temporal_baseline: number;
temporal_coherence: number;
x: number;
y: number;
}

@Component({
selector: 'app-timeseries-results-menu',
templateUrl: './timeseries-results-menu.component.html',
Expand Down Expand Up @@ -52,6 +67,9 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
public pointHistory = [];

public chartData = new Subject<any>;
public maxRange: models.Range<number> = {start: 0, end: 0};
public dataDateMin: Date;
public dataDateMax: Date;
public selectedPoint: number;
// private timeseries_subscription: Subscription;

Expand Down Expand Up @@ -188,15 +206,17 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
}

public updateChart(): void {
let allPointsData = [];
let allPointsData: PointSeries[] = [];
for (const geometry of this.pointHistory) {
this.netcdfService.getTimeSeries(geometry).pipe(first()).subscribe(data => {
console.log('updateChart data', data);
console.log('updateChart geometry', geometry);
allPointsData.push(data);
this.chartData.next(allPointsData);
this.maxRange = this.getMaxRange(allPointsData);
console.log('updateChart dataDateMin, dataDateMax', this.dataDateMin, this.dataDateMax);
console.log('updateChart allPointsData', allPointsData);
})
console.log('updateChart allPointsData', allPointsData);
this.chartData.next(allPointsData);
}
}

Expand All @@ -214,6 +234,29 @@ export class TimeseriesResultsMenuComponent implements OnInit, OnDestroy {
return task.subtasks.some(t => t.checked) && !task.subtasks.every(t => t.checked);
});

public getMaxRange(allSeries: PointSeries[]) {
let minDate = null;
let maxDate = null;
for (let points of allSeries) {
for (let key of Object.keys(points).filter(x => x !== 'mean' && x !== 'aoi')) {
console.log('getMaxRange key', key);
console.log('getMaxRange points[key]', points[key]);
let date = new Date(points[key].secondary_datetime);
console.log('getMaxRange date', date);
if (minDate === null || date < minDate) {
minDate = date;
}
if (maxDate === null || date > maxDate) {
maxDate = date;
}
}
}
let dateRange: models.Range<any> = {start: minDate, end: maxDate};
console.log('getMaxRange dateRange', dateRange);
return dateRange;
}


public updateSeries(checked: boolean, index?: number) {
console.log('updateSeries', checked, index);
this.task.update(task => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<p style="text-align: center">Timeseries Date Slider Goes Here</p>
<div #slider class="slider"></div>
<div class="slider-labels">
<span>2000</span>
<span>2005</span>
<span>2010</span>
<span>2015</span>
<span>2023</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Contenedor principal del slider */
.slider {
margin: 0 auto; /* Centra el slider horizontalmente */
width: 100%; /* Ocupa todo el ancho disponible */
max-width: 95%; /* Opcional: Limita el ancho máximo para que no se extienda demasiado */
box-sizing: border-box;
}

.noUi-connect {
background-color: #007BFF; /* Color principal */
height: 6px; /* Ajusta el grosor de la barra conectada */
}

.noUi-handle {
background-color: #FFFFFF;
border: 2px solid #007BFF; /* Borde que combine con el color principal */
border-radius: 50%; /* Hace que el control sea redondo */
height: 20px;
width: 20px;
}

.noUi-tooltip {
background-color: #333;
color: #fff;
border-radius: 4px;
font-size: 12px;
}

/* Estilos de las etiquetas debajo del slider */
.slider-labels {
display: flex;
justify-content: space-between;
width: 100%; /* Ocupa todo el ancho del slider */
max-width: 95%; /* Limita el ancho para alinearse con el slider */
margin: 10px auto 0; /* Centra y da espacio superior al slider */
box-sizing: border-box;
}

.slider-labels span {
font-size: 12px;
color: #666; /* Color de las etiquetas */
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,131 @@
import { Component } from '@angular/core';
import {Component, ElementRef, ViewChild, OnInit, Input, OnChanges, SimpleChanges} from '@angular/core';
import * as noUiSlider from 'nouislider';
import { Store } from "@ngrx/store";
import { AppState } from "@store";
import * as models from "@models";
import {Observable, Subject} from 'rxjs';
import {UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators} from "@angular/forms";
import * as filtersStore from "@store/filters";
import {SubSink} from "subsink";
import {debounceTime, distinctUntilChanged} from "rxjs/operators";

@Component({
selector: 'app-timeseries-chart-temporal-slider',
standalone: true,
imports: [],
templateUrl: './timeseries-chart-temporal-slider.component.html',
styleUrl: './timeseries-chart-temporal-slider.component.scss'
styleUrls: ['./timeseries-chart-temporal-slider.component.scss']
})
export class TimeseriesChartTemporalSliderComponent {
export class TimeseriesChartTemporalSliderComponent implements OnInit, OnChanges {
@Input() maxRange: models.Range<number> = {start: 0, end: 0};
@ViewChild('slider', { static: true }) sliderRef: ElementRef;

public daysRange: models.Range<number> = {start: 0, end: 0};
public lastRange: models.Range<number> = {start: 0, end: 0};
public daysValues$ = new Subject<number[]>();
public slider;

options: UntypedFormGroup;

daysControl: UntypedFormControl;

private firstLoad = true;
private subs = new SubSink();

constructor(
private store$: Store<AppState>,
fb: UntypedFormBuilder
) {
this.daysControl = new UntypedFormControl(this.daysRange, Validators.min(0));

this.options = fb.group({
days: this.daysControl,
});
}

ngOnInit() {
this.daysControl = new UntypedFormControl(this.daysRange, Validators.min(0));
const daysSliderRef = this.makeDaysSlider(this.sliderRef);
const daysValues$ = daysSliderRef.daysValues;

// this.tempSlider = tempSlider;

this.subs.add(
daysValues$.subscribe(
range => {
console.log(range);
const action = new filtersStore.SetTemporalRange({ start: range[0], end: range[1] });
this.store$.dispatch(action);
}
)
);

this.subs.add(
this.store$.select(filtersStore.getTemporalRange).subscribe(
temp => {
this.daysRange = {start: temp.start, end: temp.end};
if (this.firstLoad) {
this.firstLoad = false;
this.slider.set([temp.start, temp.end]);
}
}
)
);
}

ngOnChanges(changes: SimpleChanges) {
if (changes.maxRange && changes.maxRange.currentValue) {
this.maxRange = changes.maxRange.currentValue;
console.log('changes start time:', this.maxRange.start.valueOf());
console.log('changes end time:', this.maxRange.end.valueOf());
this.daysRange = {start: this.maxRange.start.valueOf(),
end: this.maxRange.end.valueOf()};
if (this.firstLoad) {
this.firstLoad = false;
this.slider.set([this.daysRange.start, this.daysRange.end]);
}
// this.slider.noUiSlider.updateOptions({
// start: [this.maxRange.start.valueOf(), this.maxRange.end.valueOf()],
// range: {
// 'min': this.maxRange.start.valueOf(),
// 'max': this.maxRange.end.valueOf()
// }
}
}

public updateDaysOffset() {
this.options.controls.days.setValue(this.daysRange);
this.daysValues$.next([this.daysRange.start, this.daysRange.end] );
}

public makeDaysSlider(filterRef: ElementRef): {slider: any, daysValues: Observable<number[]>} {
console.log('makeDaysSlider maxRange', this.maxRange);
this.slider = noUiSlider.create(filterRef.nativeElement, {
start: [2000, 2023],
behaviour: 'tap-drag',
tooltips: false,
connect: true,
step: 1,
range: {
'min': 2000,
'max': 2023
}
});

this.slider.on('update', (values, _) => {
this.daysValues$.next(values.map(v => +v));
});

return {
slider: this.slider,
daysValues: this.daysValues$.asObservable().pipe(
debounceTime(500),
distinctUntilChanged()
)
};

}

ngOnDestroy() {
this.subs.unsubscribe();
}
}
Loading

0 comments on commit a813530

Please sign in to comment.