Skip to content

Commit

Permalink
Fix issue with Passive Seismic dataselect downloads being unavailable.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwoodman committed Aug 22, 2024
1 parent 3e7829f commit 24c6d3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 36 deletions.
32 changes: 17 additions & 15 deletions src/app/menupanel/common/downloadpanel/downloadpanel.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ <h5><span class="badge badge-secondary d-inline ml-5 line-height-1-8">South: {{

<!-- Draw bounds/polygon -->
<div class="d-inline-block">
<button *ngIf="!bbox && (!irisDownloadListOption || (irisDownloadListOption && irisDownloadListOption.displayBbox)) " type="button" title="Draw bounding box"
class="btn btn-primary btn-xs" [disabled]="downloadStarted || download4pStarted || download4PolygonKMLStarted || drawBoundsStarted || drawPolygonStarted" (click)="drawBounds()">
<button *ngIf="!bbox" type="button" class="btn btn-primary btn-xs" (click)="drawBounds()"
[title]="irisDownloadListOption?.selectedserviceType === 'Dataselect' ? 'Draw bounding box' : 'Bounding box disabled for Dataselect'"
[disabled]="downloadStarted || download4pStarted || download4PolygonKMLStarted || drawBoundsStarted || drawPolygonStarted || irisDownloadListOption?.selectedserviceType === 'Dataselect'">
<i class="fa fa-edit"></i>&nbsp;Draw Bounds
</button>
<button *ngIf="bbox && (!irisDownloadListOption || (irisDownloadListOption && irisDownloadListOption.displayBbox))" type="button" title="Remove bounds"
<button *ngIf="bbox" type="button" title="Remove bounds"
class="btn btn-danger btn-xs" [disabled]="downloadStarted || download4pStarted || download4PolygonKMLStarted || drawBoundsStarted || drawPolygonStarted" (click)="clearBounds()">
<i class="fa fa-refresh fa-sm"></i>&nbsp;Clear Bounds
</button>
Expand All @@ -90,7 +91,8 @@ <h5><span class="badge badge-secondary d-inline ml-5 line-height-1-8">South: {{

<!-- Download options for bounds, polygon or all (if irisDownloadListOption) -->
<div *ngIf="downloadButtonEnabled()" class="d-inline-block" ngbDropdown>
<button type="button" class="btn btn-primary btn-xs" [disabled]="drawBoundsStarted || downloadStarted || download4pStarted || download4PolygonKMLStarted" title="Download data" ngbDropdownToggle>
<button type="button" class="btn btn-primary btn-xs" title="Download data" ngbDropdownToggle
[disabled]="drawBoundsStarted || downloadStarted || download4pStarted || download4PolygonKMLStarted">
<i *ngIf="downloadStarted || download4pStarted || download4PolygonKMLStarted" class="fa fa-spinner fa-spin fa-fw"></i>
<i *ngIf="!downloadStarted && !download4pStarted && !download4PolygonKML" class="fa fa-cloud-download"></i>&nbsp;Download
</button>
Expand All @@ -113,18 +115,18 @@ <h5><span class="badge badge-secondary d-inline ml-5 line-height-1-8">South: {{

<div [hidden]='!isWCSDownloadSupported' class="form-group">
<div *ngIf="!bbox&&drawBoundsStarted===false">
<div class="alert alert-warning fade show">
<i class="ti-bell float-left"></i>
<p>Select an area to download <span *ngIf="downloadSizeLimit > 0">not exceeding {{downloadSizeLimit}} m<sup>2</sup>.</span></p>
</div>
<div class="alert alert-warning fade show">
<i class="ti-bell float-left"></i>
<p>Select an area to download <span *ngIf="downloadSizeLimit > 0">not exceeding {{downloadSizeLimit}} m<sup>2</sup>.</span></p>
</div>
</div>
<div *ngIf="drawBoundsStarted===true">
<div class="alert alert-primary fade show">
<i class="ti-bell float-left"></i>
<p>Click on the map to draw bounding box.</p>
</div>
<div class="alert alert-primary fade show">
<i class="ti-bell float-left"></i>
<p>Click on the map to draw bounding box.</p>
</div>
</div>
<div *ngIf="bbox && (!irisDownloadListOption || (irisDownloadListOption && irisDownloadListOption.displayBbox))" class="container">
<div *ngIf="bbox" class="container">
<div class="standard-title row">
<h4><span>Bounding Box</span></h4>
</div>
Expand Down Expand Up @@ -166,9 +168,9 @@ <h5><span class="badge badge-secondary d-inline ml-5 line-height-1-8">South: {{b

<!-- Bounding box download -->
<div style="display:flex;">
<button *ngIf="!bbox && (!irisDownloadListOption || (irisDownloadListOption && irisDownloadListOption.displayBbox)) " type="button" title="Draw bounding box"
<button *ngIf="!bbox" type="button" title="Draw bounding box"
class="btn btn-primary btn-xs" [disabled]="downloadStarted || drawBoundsStarted" (click)="drawBounds()"><i class="fa fa-edit"></i>&nbsp;Draw Bounds</button>
<button *ngIf="bbox && (!irisDownloadListOption || (irisDownloadListOption && irisDownloadListOption.displayBbox))" type="button" title="Remove bounds"
<button *ngIf="bbox" type="button" title="Remove bounds"
class="btn btn-danger btn-xs" [disabled]="downloadStarted" (click)="clearBounds()"><i class="fa fa-refresh"></i>&nbsp;Clear Bounds</button>
<button type="button" class="btn btn-primary btn-xs" style="margin-left:auto;width:9rem;" [disabled]="!bbox || downloadStarted" title="Download data for bounding box" (click)="download()">
<i *ngIf="downloadStarted" class="fa fa-spinner fa-spin fa-fw"></i><i *ngIf="!downloadStarted" class="fa fa-cloud-download"></i>&nbsp;Download
Expand Down
30 changes: 9 additions & 21 deletions src/app/menupanel/common/downloadpanel/downloadpanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,8 @@ export class DownloadPanelComponent implements OnInit {
* Use the rules present in the button options to determine if download button should be enabled
*/
downloadButtonEnabled(): boolean {
if (this.bbox || (this.bbox && this.irisDownloadListOption) ||
(this.polygonFilter && this.isPolygonSupportedLayer) ||
((this.bbox || this.polygonFilter) && this.isWCSDownloadSupported) ||
this.isTsgDownloadAvailable) {
if (this.bbox || this.isTsgDownloadAvailable || this.irisDownloadListOption ||
(this.polygonFilter && (this.isPolygonSupportedLayer || this.isWCSDownloadSupported))) {
return true;
}
return false;
Expand Down Expand Up @@ -470,21 +468,13 @@ export class DownloadPanelComponent implements OnInit {

// Download IRIS datasets by constructing a data download URL. User can select the either Dataselect or Station
} else if (this.irisDownloadListOption) {
// IRIS requires a bbox be present
if (!this.bbox) {
alert('Cannot download. Make sure you select a bounding box.');
return;
}
this.downloadStarted = true;

let start = (this.irisDownloadListOption.dateFrom !== null && this.irisDownloadListOption.dateFrom !== '') ? new Date(new Date(this.irisDownloadListOption.dateFrom)).toISOString().substring(0, 10) : null;
let end = (this.irisDownloadListOption.dateToTo !== null && this.irisDownloadListOption.dateTo !== '') ? new Date(new Date(this.irisDownloadListOption.dateTo)).toISOString().substring(0, 10) : null;

let station = this.SELECT_ALL_CODE;
station = !this.irisDownloadListOption.selectedStations.includes(this.SELECT_ALL_CODE) ? this.irisDownloadListOption.selectedStations.join(",") : this.SELECT_ALL_CODE;
const start = (this.irisDownloadListOption.dateFrom !== null && this.irisDownloadListOption.dateFrom !== '') ? new Date(new Date(this.irisDownloadListOption.dateFrom)).toISOString().substring(0, 10) : null;
const end = (this.irisDownloadListOption.dateToTo !== null && this.irisDownloadListOption.dateTo !== '') ? new Date(new Date(this.irisDownloadListOption.dateTo)).toISOString().substring(0, 10) : null;

let channel = this.SELECT_ALL_CODE;
channel = !this.irisDownloadListOption.selectedChannels.includes(this.SELECT_ALL_CHANNEL) ? this.irisDownloadListOption.selectedChannels.join(",") : this.SELECT_ALL_CODE;
const station = !this.irisDownloadListOption.selectedStations.includes(this.SELECT_ALL_CODE) ? this.irisDownloadListOption.selectedStations.join(",") : this.SELECT_ALL_CODE;
const channel = !this.irisDownloadListOption.selectedChannels.includes(this.SELECT_ALL_CHANNEL) ? this.irisDownloadListOption.selectedChannels.join(",") : this.SELECT_ALL_CODE;

if (this.irisDownloadListOption.selectedserviceType === 'Station') {
observableResponse = this.downloadIrisService.downloadIRISStation(this.layer, this.bbox, station, channel, start, end);
Expand Down Expand Up @@ -513,17 +503,15 @@ export class DownloadPanelComponent implements OnInit {
this.downloadStarted = false;
if (UtilitiesService.isEmpty(err.message)) {
alert('An error has occurred whilst attempting to download. Please contact cg-admin@csiro.au');
} else if (err.status === 413 && this.irisDownloadListOption) {
alert('An error has occurred whilst attempting to download. (Request entity is too large, please reduce the size by limiting the stations, channels, or time period.) Please contact cg-admin@csiro.au');
} else {
if (err.status === 413 && this.irisDownloadListOption) {
alert('An error has occurred whilst attempting to download. (Request entity is too large, please reduce the size by limiting the stations, channels, or time period.) Please contact cg-admin@csiro.au');
} else {
alert('There is an error, when downloading (' + this.layer.name + ') layer at location (' +
'eLongitude:' + Math.floor(this.bbox.eastBoundLongitude)
+ ' nLatitude: ' + Math.floor(this.bbox.northBoundLatitude)
+ ' sLatitude:' + Math.floor(this.bbox.southBoundLatitude)
+ ' wLongitude:' + Math.floor(this.bbox.westBoundLongitude)
+ '). Detail of the error: (' + err.message + ')');
}
}
});
}
Expand Down Expand Up @@ -791,7 +779,7 @@ export class DownloadPanelComponent implements OnInit {
// Update the to/from and start/end dates according to the channels selected
let newStartDate = stations[0].startDate;
let newEndDate = stations[0].endDate;
for (let station of stations) {
for (const station of stations) {
newStartDate = station.startDate < newStartDate ? station.startDate : newStartDate;
newEndDate = station.endDate > newEndDate ? station.endDate : newEndDate;
}
Expand Down

0 comments on commit 24c6d3d

Please sign in to comment.