Skip to content

Commit

Permalink
Merge pull request #456 from AuScope/AUS-4094
Browse files Browse the repository at this point in the history
AUS-4094 view NVCLAnalyticalJob on map.
  • Loading branch information
stuartwoodman authored Nov 13, 2024
2 parents 83cdab5 + c193336 commit 119cdb4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ <h4 class="card-title">Borehole Analytics</h4>
<td>{{status.timeStamp}}</td>
<td>{{status.status}}</td>
<td *ngIf="status.status==='Success'" class="btn-col" style="white-space: nowrap">
<a class="btn btn-purple btn-xs" title="View this job on the map." (click) = "viewOnMap(status.jobid)"><i class="ti-map-alt"></i></a>
<a class="btn btn-light btn-xs" title="Download this job result." (click)="nvclDownload(status.jobid)"><i class="ti-download"></i></a>
<a class="btn btn-light btn-xs" title="Download the TSGMod data for this job. It is only for non-existing scalars, otherwise, the zip file will be empty." (click)="nvclDownloadData(status.jobid)"><i class="ti-zip"></i></a>
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { saveAs } from 'file-saver';
import { LayerModel } from '@auscope/portal-core-ui';
import { NVCLBoreholeAnalyticService } from './nvcl.boreholeanalytic.service';
import {
Component,
Input,
AfterViewInit,
OnInit,
ViewChild
} from '@angular/core';
import { Component, Input, AfterViewInit, OnInit, ViewChild} from '@angular/core';
import { UserStateService } from 'app/services/user/user-state.service';
import { LayerAnalyticInterface } from '../layer.analytic.interface';
import { NgForm } from '@angular/forms';
import { environment } from 'environments/environment';


@Component({
Expand Down Expand Up @@ -48,9 +44,7 @@ export class NVCLBoreholeAnalyticComponent
checkprocess: false
};

constructor(
public nvclBoreholeAnalyticService: NVCLBoreholeAnalyticService
) {
constructor( public nvclBoreholeAnalyticService: NVCLBoreholeAnalyticService, private userStateService: UserStateService ) {
this.nvclform = {};
}

Expand Down Expand Up @@ -192,13 +186,19 @@ export class NVCLBoreholeAnalyticComponent
// console.log('jobid=' + jobid + ' publishStatus=' + response);
});
}

public viewOnMap(jobid: string) {
const me = this;
this.nvclBoreholeAnalyticService.getNVCLGeoJson(jobid).subscribe(results => {
const jsonData = results;
me.nvclBoreholeAnalyticService.addGeoJsonLayer(jobid,jsonData);
});
}
public nvclDownload(jobid: string) {
this.nvclBoreholeAnalyticService
.downloadNVCLJobResult(jobid)
.subscribe(response => {
const blob = new Blob([response], { type: 'application/zip' });
saveAs(blob, 'nvclAnalytical-jobresult-' + jobid + '.zip');
const blob = new Blob([response], { type: 'text/csv' });
saveAs(blob, 'nvclAnalytical-jobresult-' + jobid + '.csv');
this.nvclBoreholeAnalyticService.setUserEmail(this.nvclform.email);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,67 @@
import {throwError as observableThrowError, Observable } from 'rxjs';

import {catchError, map} from 'rxjs/operators';
import { LayerModel } from '@auscope/portal-core-ui';
import { LayerModel, RenderStatusService } from '@auscope/portal-core-ui';
import { LayerHandlerService } from '@auscope/portal-core-ui';
import { Injectable, Inject } from '@angular/core';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { environment } from '../../../../environments/environment';
import {config} from '../../../../environments/config';

import { LOCAL_STORAGE, StorageService } from 'ngx-webstorage-service';
import { LayerManagerService } from 'app/services/ui/layer-manager.service';
import { UILayerModelService } from 'app/services/ui/uilayer-model.service';
import { UILayerModel } from 'app/menupanel/common/model/ui/uilayer.model';

@Injectable()
export class NVCLBoreholeAnalyticService {


constructor(private http: HttpClient, private layerHandlerService: LayerHandlerService, @Inject(LOCAL_STORAGE) private storage: StorageService) {
constructor(private http: HttpClient,
private layerHandlerService: LayerHandlerService,
private layerManagerService: LayerManagerService,
private renderStatusService: RenderStatusService,
private uiLayerModelService: UILayerModelService,
@Inject(LOCAL_STORAGE) private storage: StorageService) {
}
public addGeoJsonLayer(name: string, jsonData: any) {
let layerId = 'GEOJSON_' + name;
if (this.uiLayerModelService.isLayerAdded(layerId)){
alert("This NVCLAnalytical-Job-Result has been added already!");
return;
}
const me = this;
const proxyUrl = "";
let layerRec: LayerModel= null;
// Make a layer model object
layerRec = me.layerHandlerService.makeCustomGEOJSONLayerRecord(name, proxyUrl, jsonData);
layerRec.group = 'geojson-layer';
// Configure layers so it can be added to map
const uiLayerModel = new UILayerModel(layerRec.id, 100, me.renderStatusService.getStatusBSubject(layerRec));
me.uiLayerModelService.setUILayerModel(layerRec.id, uiLayerModel);
me.layerManagerService.addLayer(layerRec, [], null, null);
}

public getNVCLGeoJson(jobId:string): Observable<any> {
let httpParams = new HttpParams();
httpParams = httpParams.append('jobid', jobId);
httpParams = httpParams.append('format', 'json');
return this.http.get(environment.nVCLAnalyticalUrl + 'downloadNVCLJobResult.do', {
params: httpParams
}).pipe(map(response => {
if (response) {
return JSON.stringify(response);
} else {
return observableThrowError('error');
}
}), catchError(
(error: HttpResponse<any>) => {
return observableThrowError(error);
}
), );
}


public getNVCLAlgorithms(): Observable<any> {
let httpParams = new HttpParams();
const nvclUrl = config.nvclUrl;
Expand Down

0 comments on commit 119cdb4

Please sign in to comment.