Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: simvalery <[email protected]>
  • Loading branch information
simvalery committed Dec 10, 2024
1 parent 9b4ffcf commit 656786b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,16 @@
</div>

<div *ngIf="isDateTime(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="item.control" [item]="item" type="default"
[value]="item.suggest"></date-time-control>
<date-time-control [control]="item.control" [item]="item"></date-time-control>
</div>

<div *ngIf="isDate(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="item.control" [item]="item" [showSeconds]="false" type="default"
[showTime]="false"></date-time-control>
<date-time-control [control]="item.control" [item]="item"
[showSeconds]="false"></date-time-control>
</div>

<div *ngIf="isTime(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="item.control" [item]="item" [showSeconds]="true" [showTime]="true"
type="default"
[timeOnly]="true"></date-time-control>
</div>

Expand Down Expand Up @@ -196,19 +194,18 @@

<div *ngIf="isDateTime(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="listItem.control" [index]="i" [isMany]="true"
[item]="item" type="suggest"
[item]="item"
[value]="item.suggest"></date-time-control>
</div>

<div *ngIf="isDate(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="listItem.control" [isMany]="true" [item]="listItem"
type="suggest"
[showSeconds]="false" [showTime]="false"></date-time-control>
</div>

<div *ngIf="isTime(item)" class="form-field-input guardian-input-container">
<date-time-control [control]="listItem.control" [index]="i" [isMany]="true"
[item]="item" type="suggest"
[item]="item"
[showSeconds]="true" [showTime]="true"
[timeOnly]="true"></date-time-control>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,66 +65,80 @@ export class SentinelHubTypeComponent implements OnInit, OnChanges, AfterViewIni
this.subscription.unsubscribe();
}

private iteration = 0;

ngOnInit(): void {
if (!this.control) {
this.control = new UntypedFormGroup({});
}

this.control.registerControl('layers', new UntypedFormControl('NATURAL-COLOR', Validators.required));
this.control.registerControl('format', new UntypedFormControl('image/jpeg', Validators.required));
this.control.registerControl('maxcc', new UntypedFormControl(30, Validators.required));
this.control.registerControl('width', new UntypedFormControl(512, Validators.required));
this.control.registerControl('height', new UntypedFormControl(512, Validators.required));
this.control.registerControl('maxcc', new UntypedFormControl(undefined, Validators.required));
this.control.registerControl('width', new UntypedFormControl(undefined, Validators.required));
this.control.registerControl('height', new UntypedFormControl(undefined, Validators.required));
this.control.registerControl('bbox', new UntypedFormControl('', Validators.required));
this.control.registerControl('time', new UntypedFormControl(undefined, Validators.required));

this.subscription.add(
this.mapService.getSentinelKey().subscribe(value => {
this.key = value;
if (this.presetDocument) {
this.generateImageLink(this.control.value, true);
this.key = value;
if (this.presetDocument) {
this.generateImageLink(this.control.value, true);
}
}
})
)
)

if (this.presetDocument) {
this.control.patchValue(this.presetDocument);
let [from, to] = this.control.get('time')?.value?.split('/') || [];

const _from = from;
const _to = to;
if (!/(\d+)-(\d+)-(\d+)/.test(_from)) {
from = moment(_from, 'YYYY-MM-DD');
}
if (!/(\d+)-(\d+)-(\d+)/.test(_to)) {
to = moment(_to, 'YYYY-MM-DD');
}
if (/(\d+)/.test(_from)) {
from = moment(parseInt(_from, 10));
}
if (/(\d+)/.test(_to)) {
to = moment(_to);
}
this.datePicker.patchValue({from, to});

}

this.subscription.add(
this.datePicker.valueChanges.subscribe(value => {
if ((typeof value.from?.format === 'function') && (value.to?.format === 'function')) {
this.getControlByName('time').setValue(value.from?.format('YYYY-MM-DD') + '/' + value.to?.format('YYYY-MM-DD'));
if (!value.from || !value.to) {
return;
}
this.getControlByName('time').setValue((value.from + '/' + value.to));
this.getControlByName('time').setValue(value.from?.format('YYYY-MM-DD') + '/' + value.to?.format('YYYY-MM-DD'));
})
);

this.subscription.add(
this.control.valueChanges.subscribe(value => this.generateImageLink(value))
)
);
}

ngAfterViewInit(): void {
console.log(this.presetDocument);
if (this.presetDocument) {
setTimeout(() => {
this.control.patchValue(this.presetDocument);
let [from, to] = this.control.get('time')?.value?.split('/') || [];
console.log({from, to});
if (!/(\d+)-(\d+)-(\d+)/.test(from)) {
from = moment(from).format('YYYY-MM-DD');
}
if (!/(\d+)-(\d+)-(\d+)/.test(to)) {
from = moment(to).format('YYYY-MM-DD');
}
console.log({from, to});
this.datePicker.patchValue({from, to});
this.generateImageLink(this.control.value, true);
}, 200);

}
this.generateImageLink(this.control.value, true);
}

generateImageLink(value: any, skipValidation = false): void {
if (!this.key) {
this.formattedImageLink = '';
if (this.iteration < 10) {
setTimeout(() => {
this.iteration += 1;
this.generateImageLink(value, skipValidation);
});
}
return;
}

Expand Down

0 comments on commit 656786b

Please sign in to comment.