From 0936a31568d99ecba9908572f0fcccb84cae7c57 Mon Sep 17 00:00:00 2001 From: Lingbo Jiang Date: Tue, 12 Nov 2024 20:58:38 +1100 Subject: [PATCH 1/2] AUS-4094 view NVCLAnalyticalJob on map. download NVCLAnalyticalJob result as csv. --- .../nvcl/nvcl.boreholeanalytic.component.html | 1 + .../nvcl/nvcl.boreholeanalytic.component.ts | 26 +++++------ .../nvcl/nvcl.boreholeanalytic.service.ts | 44 ++++++++++++++++++- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.html b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.html index d155aeff1..ba25f7d3a 100644 --- a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.html +++ b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.html @@ -218,6 +218,7 @@

Borehole Analytics

{{status.timeStamp}} {{status.status}} + diff --git a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.ts b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.ts index 80c84c90e..bfcea0b63 100644 --- a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.ts +++ b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.component.ts @@ -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({ @@ -48,9 +44,7 @@ export class NVCLBoreholeAnalyticComponent checkprocess: false }; - constructor( - public nvclBoreholeAnalyticService: NVCLBoreholeAnalyticService - ) { + constructor( public nvclBoreholeAnalyticService: NVCLBoreholeAnalyticService, private userStateService: UserStateService ) { this.nvclform = {}; } @@ -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); }); } diff --git a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts index f439a3263..68cbc6497 100644 --- a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts +++ b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts @@ -2,7 +2,7 @@ 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'; @@ -10,14 +10,54 @@ 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) { + 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 { + 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) => { + return observableThrowError(error); + } + ), ); + } + public getNVCLAlgorithms(): Observable { let httpParams = new HttpParams(); From c1933364c599ceee1a9df4e4fb60d4730e6eb437 Mon Sep 17 00:00:00 2001 From: Lingbo Jiang Date: Wed, 13 Nov 2024 12:41:20 +1100 Subject: [PATCH 2/2] AUS-4094 Fixed duplicated adding GeoJsonLayers. --- .../layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts index 68cbc6497..6caafc8e4 100644 --- a/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts +++ b/src/app/modalwindow/layeranalytic/nvcl/nvcl.boreholeanalytic.service.ts @@ -24,9 +24,13 @@ export class NVCLBoreholeAnalyticService { 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;