Skip to content

Commit

Permalink
Update portal state calls from NVCL component.
Browse files Browse the repository at this point in the history
Code tidying.
  • Loading branch information
stuartwoodman committed Sep 5, 2024
1 parent b4e814a commit e6e13e2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 71 deletions.
3 changes: 1 addition & 2 deletions src/app/menupanel/permanentlink/permanentlink.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class PermanentLinkComponent {
if (this.bShowDialog){
this.generateAnonymousPermanentLink();
}
return;
}

/**
Expand All @@ -55,7 +54,7 @@ export class PermanentLinkComponent {
this.permanentlink = link;
this.shorteningMode = false;
}, () => {
this.permanentlink = "Error on retrieving permanentLink!"
this.permanentlink = "Error retrieving permanentLink."
this.shorteningMode = false;
});

Expand Down
10 changes: 0 additions & 10 deletions src/app/menupanel/search/searchpanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,6 @@ export class SearchPanelComponent implements OnInit {
this.sidebarService.setOpenState(true);
}

/**
* Scroll to the specified layer in sidebar (Featured Layers)
* Note: Unused, was originally for scrolling to layer in Featured Layers when that was part
* of the side-bar. Kept in case we ever want to highlight the browse menu (or similar)
* @param layer the layer
*/
public scrollToLayer(layer: LayerModel) {
this.manageStateService.setLayerToExpand(layer.id);
}

/**
* Check whether layer has been added to the map
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ <h4 class="card-title">Borehole Analytics</h4>
<td>{{status.jobDescription}}</td>
<td>
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" [checked]="status.published" (change)="ChangePublish(status)" >
<input type="checkbox" class="custom-control-input" [checked]="status.published" (change)="changePublish(status)" >
<span class="custom-control-indicator"></span>
</label>
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { environment } from '../../../../environments/environment';
import { saveAs } from 'file-saver';
import { LayerModel } from '@auscope/portal-core-ui';
import { ManageStateService } from '@auscope/portal-core-ui';
import { NVCLBoreholeAnalyticService } from './nvcl.boreholeanalytic.service';
import {
Component,
Expand All @@ -12,6 +11,7 @@ import {
} from '@angular/core';
import { LayerAnalyticInterface } from '../layer.analytic.interface';
import { NgForm } from '@angular/forms';
import { UserStateService } from 'app/services/user/user-state.service';


@Component({
Expand Down Expand Up @@ -52,7 +52,7 @@ export class NVCLBoreholeAnalyticComponent

constructor(
public nvclBoreholeAnalyticService: NVCLBoreholeAnalyticService,
private manageStateService: ManageStateService
private userStateService: UserStateService
) {
this.nvclform = {};
}
Expand Down Expand Up @@ -135,10 +135,10 @@ export class NVCLBoreholeAnalyticComponent
.getNVCLClassifications(algorithmOutputIds)
.subscribe(classifications => {
classifications = classifications.sort((a,b)=> {
var a1 = a.classText.toLowerCase();
var b1 = b.classText.toLowerCase();
return a1<b1 ?-1:a1> b1? 1 :0;
})
const a1 = a.classText.toLowerCase();
const b1 = b.classText.toLowerCase();
return a1 < b1 ? -1 : a1 > b1 ? 1 : 0;
})
this.classifications = classifications;
});
}
Expand All @@ -161,8 +161,7 @@ export class NVCLBoreholeAnalyticComponent
alert('Job has been successfully submitted. The results will be sent to your email.');
this.nvclBoreholeAnalyticService.setUserEmail(this.nvclform.email);
}
},
err => {
}, () => {
alert('Failed on the job submission. Please contact cg-admin@csiro.au for help!');
}
);
Expand All @@ -185,7 +184,8 @@ export class NVCLBoreholeAnalyticComponent
}
});
}
public ChangePublish(status: any) {

public changePublish(status: any) {
const jobid = status.jobid;
const published = status.published;
status.published = !published;
Expand Down Expand Up @@ -215,19 +215,11 @@ export class NVCLBoreholeAnalyticComponent
}

public viewOnMap(jobid: string) {
if (window.confirm('This action will link you to an external URL. Please ensure you have grant access to allow pop up from this domain.')) {
if (window.confirm('This will open a link in a new window. Please ensure you grant access to allow pop ups from this domain.')) {
this.layer.filterCollection.mandatoryFilters[0].value = jobid;
// Make a state object
const state = this.manageStateService.generateOneOffState(
this.layer.id,
this.layer.filterCollection,
[]
);
// Store state object in DB & open up window
const uncompStateStr = JSON.stringify(state);
this.manageStateService.saveStateToDB(uncompStateStr).subscribe((response: any) => {
if (response.success === true) {
window.open(environment.hostUrl + '?state=' + response.id);
this.userStateService.addState("NVCL Job " + jobid, "Result of NVCL job run " + jobid, true, true).subscribe(response => {
if (response !== '') {
window.open(environment.hostUrl + '?state=' + response);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/modalwindow/querier/querier.modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h4 class="alert-heading">Feature Information</h4>
style="position: inherit;padding-top: unset;margin-bottom: 20px;">
<div class="float-left d-none d-md-inline mt-0 w-100">
<div *ngIf="bToClipboard" data-toggle="tooltip" title="Copy to Clipboard"
(click)="CopyToClipboard(currentDoc)" class="btn btn-primary btn-sm">
(click)="copyToClipboard(currentDoc)" class="btn btn-primary btn-sm">
<span><i class="ti-clip"></i>Copy to Clipboard</span>
</div>
</div>
Expand Down
38 changes: 6 additions & 32 deletions src/app/modalwindow/querier/querier.modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable @typescript-eslint/member-ordering */
import { ApplicationRef, ChangeDetectorRef, Component, Inject, OnInit, ElementRef, ViewChild, AfterViewInit, Renderer2 } from '@angular/core';
import { environment } from '../../../environments/environment';
import { config } from '../../../environments/config';
import { ref } from '../../../environments/ref';
import { CsClipboardService, GMLParserService, ManageStateService, Polygon, QuerierInfoModel, RickshawService, UtilitiesService } from '@auscope/portal-core-ui';
import { CsClipboardService, GMLParserService, Polygon, QuerierInfoModel } from '@auscope/portal-core-ui';
import { NVCLService } from './customanalytic/nvcl/nvcl.service';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { FlatTreeControl } from '@angular/cdk/tree';
Expand All @@ -14,7 +13,6 @@ import * as X2JS from 'x2js';
import { DomSanitizer } from '@angular/platform-browser';
import { MSCLService } from '../layeranalytic/mscl/mscl.service';
import { NVCLBoreholeAnalyticService } from '../layeranalytic/nvcl/nvcl.boreholeanalytic.service';
import { saveAs } from 'file-saver';
import { MatDialog } from '@angular/material/dialog';

export class FileNode {
Expand All @@ -33,10 +31,9 @@ interface FlatNode {
@Component({
selector: 'app-querier-modal-window',
templateUrl: './querier.modal.component.html',
providers: [RickshawService, NVCLBoreholeAnalyticService],
providers: [NVCLBoreholeAnalyticService],
styleUrls: ['../modalwindow.scss', './querier.modal.component.scss']
})

export class QuerierModalComponent implements OnInit, AfterViewInit {
[x: string]: any;
@ViewChild('childElement', { static: false }) childElement: ElementRef;
Expand Down Expand Up @@ -123,12 +120,12 @@ export class QuerierModalComponent implements OnInit, AfterViewInit {
public modalVisible = true;

constructor(public nvclService: NVCLService, public bsModalRef: BsModalRef, public csClipboardService: CsClipboardService,
private manageStateService: ManageStateService, private gmlParserService: GMLParserService,
private gmlParserService: GMLParserService,
private http: HttpClient, @Inject('env') private env, private sanitizer: DomSanitizer,
public nvclBoreholeAnalyticService: NVCLBoreholeAnalyticService,
private changeDetectorRef: ChangeDetectorRef, private appRef: ApplicationRef,
private msclService: MSCLService, private renderer: Renderer2, private elementRef: ElementRef,
private modalService: BsModalService, public dialog: MatDialog, private rickshawService: RickshawService) {
private msclService: MSCLService, private renderer: Renderer2,
private modalService: BsModalService, public dialog: MatDialog) {
this.analyticMap = ref.analytic;
this.flagNVCLAnalytic = false;
this.initialScalarLoad = true;
Expand Down Expand Up @@ -226,34 +223,11 @@ export class QuerierModalComponent implements OnInit, AfterViewInit {
return config.supportOpenInNewWindow.includes(doc.layer.id);
}

public newWindow(doc: QuerierInfoModel) {
const state = _.cloneDeep(this.manageStateService.getState());
const layerid = doc.layer.id;
for (const key in state) {
if (key !== layerid && key !== 'map') {
delete state[key];
}
if (key === layerid) {
state[key].raw = doc.raw;
state[key].onlineResource = doc.onlineResource; // TODO: currentDoc. ???
state[key].gmlid = doc.key;
}
}

// Store state object in DB & open up window
const uncompStateStr = JSON.stringify(state);
this.manageStateService.saveStateToDB(uncompStateStr).subscribe((response: any) => {
if (response.success === true) {
window.open(environment.hostUrl + '?state=' + response.id);
}
});
}

/**
* Copy drawn polygon to clipboard
* @param document polygon as document
*/
public CopyToClipboard(document) {
public copyToClipboard(document) {
const name = document.key;
const doc = document.value;
let polygon: Polygon;
Expand Down
7 changes: 3 additions & 4 deletions src/app/services/user/user-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,16 @@ export class UserStateService {
if (UtilitiesService.isEmpty(this.roiKey))
return;

let strROIs = JSON.stringify(this.roiList);
this.apiService.saveUserParams(this.roiKey,strROIs).subscribe(response => {
});
const strROIs = JSON.stringify(this.roiList);
this.apiService.saveUserParams(this.roiKey, strROIs).subscribe(() => {});
}

/**
* Retrieve a list of ROI associated with the user
* @param user
*/
public updateUserROI(user:User){
let key = 'roiId.'+ user.email;
const key = 'roiId.'+ user.email;
this.roiKey = key.replace(' ','-');
this.apiService.getUserParams(key).subscribe(strROIs => {
if (strROIs) {
Expand Down

0 comments on commit e6e13e2

Please sign in to comment.