Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUS-3836 Fix InfoPanel URLs #199

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
</p>
<p *ngIf="onlineResource.type!='Unsupported' && onlineResource.type!='DOI'">
<span class="label label-default"><b>{{onlineResource.type}}: </b></span>
<a target="_blank" href="{{onlineResource.url}}?service=WMS&request=getCapabilities">{{onlineResource.type}} GetCapabilities Info</a>
<a *ngIf="isGetCapabilitiesType(onlineResource)" target="_blank" href="{{ onlineResourceGetCapabilitiesUrl(onlineResource) }}">{{onlineResource.type}} GetCapabilities Info</a>
<a *ngIf="!isGetCapabilitiesType(onlineResource)" target="_blank" href="{{ onlineResource.url }}">{{onlineResource.type}} Info</a>
</p>
</div>
<p *ngIf="wmsUrl!=undefined">
Expand Down
46 changes: 40 additions & 6 deletions src/app/menupanel/common/infopanel/subpanel/subpanel.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { CSWRecordModel } from '@auscope/portal-core-ui';
import { CSWRecordModel, OnlineResourceModel } from '@auscope/portal-core-ui';
import { LayerModel } from '@auscope/portal-core-ui';
import { LegendService } from '@auscope/portal-core-ui';
import { UtilitiesService } from '@auscope/portal-core-ui';



@Component({
selector: 'info-sub-panel',
templateUrl: './subpanel.component.html',
Expand Down Expand Up @@ -37,25 +36,60 @@ export class InfoPanelSubComponent implements OnChanges {
}
}


/**
* Remove unwanted and empty strings from metadata constraints fields
* @param constraints string array of contraints
* @return string constraints in string format
*/
public cleanConstraints(constraints: string[]) {

let outStr = "";
for (const conStr of constraints) {
if (conStr.indexOf("no conditions apply") < 0 &&
conStr.indexOf("#MD_RestrictionCode") < 0 && conStr.trim() != "") {
if (conStr.indexOf("no conditions apply") < 0 &&
conStr.indexOf("#MD_RestrictionCode") < 0 && conStr.trim() !== "") {
outStr += conStr.trim() + ", ";
}
}
// Remove trailing comma
return outStr.replace(/, $/, "");
}

/**
* Is the OnlineResourceModel of a type that supports GetCapabilities?
*
* @param onlineResource the OnlineResourceModel
* @returns true if OnlineResource is of type WMS, WFS, WCS or CSW
*/
public isGetCapabilitiesType(onlineResource: OnlineResourceModel): boolean {
return onlineResource.type === 'WMS' || onlineResource.type === 'WFS' || onlineResource.type === 'WCS' || onlineResource.type === 'CSW';
}

/**
* Create a WMS/WFS/WCS/CSW GetCapabilities URL from the provided OnlineResource
*
* @param onlineResource the OnlineResourceModel
* @returns a WMS, WFS or WCS GetCapabilities URL as a string
*/
public onlineResourceGetCapabilitiesUrl(onlineResource: OnlineResourceModel): string {
// Determine base path, append mandatory service and request parameters
const paramIndex = onlineResource.url.indexOf('?');
let path = paramIndex !== -1 ? onlineResource.url.substring(0, onlineResource.url.indexOf('?')) : onlineResource.url;
path += '?service=' + onlineResource.type + '&request=GetCapabilities';
// Apend any other non-service or request parameters to path
if (paramIndex !== -1 && onlineResource.url.length > paramIndex + 1) {
const paramString = onlineResource.url.substring(paramIndex + 1, onlineResource.url.length);
const paramArray = paramString.split('&');
for (const keyValueString of paramArray) {
const keyValue = keyValueString.split('=');
if (keyValue.length === 2) {
if (keyValue[0].toLowerCase() !== 'service' && keyValue[0].toLowerCase() !== 'request') {
path += keyValue[0] + '=' + keyValue[1];
}
}
}
}
return path;
}

/**
* Gets called by Angular framework upon any changes
* @param changes object which holds the changes
Expand Down