Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
proxyHost () {
// Get a reference of Template instance
const instance = Template.instance();
// Get proxy ID from template instance
const savedProxyId = instance.proxyId;
// Make sure proxy ID exists or calculate it
const proxyId = savedProxyId ? savedProxyId.get() : instance.getProxyId();
// Find the proxy settings
const proxy = Proxies.findOne(proxyId);
if (proxy && proxy.apiUmbrella) {
// Get frontend host from template instance
const frontend = new URI(proxy.apiUmbrella.url);
return frontend.host();
}
return '';
},
oneProxy () {
// focus selection color
var FOCUS_COLOR = "black";
// scatter plot points (circles or squares)
var SCATTER_PLOT_TYPE = "circle";
// variable/metadata inclusion columns
var var_include_columns = null;
var meta_include_columns = null;
// colormap defaults
var cont_colormap = null;
// model id from address bar
var mid = URI(window.location).segment(-1);
// constants for polling timeouts
var ONE_MINUTE = 60000;
var ONE_SECOND = 1000;
// constants for cutting off plot names, slider names
var MAX_PLOT_NAME = 20;
var MAX_SLIDER_NAME = 20;
var MAX_COLOR_NAME = 20;
// constant for maximum number of editable column categories
var MAX_CATS = 50;
// constant for maximum length of freetext in editable column
var MAX_FREETEXT_LEN = 500;
export function loadFeed(feedUrl) {
// decode url in case someone encoded it in a way incompatible with legacy server
const decodedFeedUrl = URI.decode(feedUrl);
const endpoint = new URI(`//${url.legacy}/v1/apps/${appId}/proxy/resources/${FEED_ITEMS}`)
.setQuery({
'filter[url]': decodedFeedUrl,
})
.toString();
const config = {
schema: FEED_ITEMS,
request: {
endpoint,
headers: {
Accept: 'application/vnd.api+json',
},
},
};
return find(config, ext('feedItems'));
couchdb_doc_size: 0,
delta_creation_time: 0,
job_pending_time: 0,
job_running_time: 0,
model_compute_time: 0,
hdf5_footprint: 0,
server_cache_size: 0,
analysis_computation_time:0,
db_creation_time: 0,
model: null
});
$.ajax({
dataType: "json",
type: "GET",
url: URI(api_root + "get-model-statistics/" + component.model._id()),
success: function(result)
{
mapping.fromJS(result, component.details);
},
error: function(request, status, reason_phrase)
{
window.alert("error request:" + request.responseJSON +" status: "+ status + " reason: " + reason_phrase);
console.log("error request:" + request.responseJSON +" status: "+ status + " reason: " + reason_phrase);
}
});
return component;
};
superagent.parse[contentType] = (res, done) => {
//if res is a string, that means we're likely in a browser environment
//and have only been provided the string to parse.
if (typeof(res) === 'string') {
return parseFunction(res);
}
//if we made it this far it's likely Node and have to do more work to parse
let baseUrl = null;
if (res.req && res.req.socket && res.req._headers && res.req._headers.host) {
const protocol = !!res.req.socket.encrypted ? 'https' : 'http';
baseUrl = new Uri({protocol: protocol, hostname: res.req._headers.host}).toString();
baseUrl = new Uri(res.req.path).absoluteTo(baseUrl).toString();
}
res.text = '';
res.setEncoding('utf8');
res.on('data', chunk => {res.text += chunk;});
res.on('end', () => {
let err = null;
let body = null;
try {
let text = res.text && res.text.replace(/^\s*|\s*$/g, '');
body = text && parseFunction(text, baseUrl);
}
catch(e) {
err = e;
}
private packageSearch(options?: {
start?: number;
title?: string;
}): AsyncPage {
const url = new URI(this.urlBuilder.getDataSearchUrl());
const startStart = options.start || 0;
let startIndex = startStart;
return AsyncPage.create(previous => {
if (previous) {
startIndex = previous.nextStart;
if (previous.nextStart === -1) return undefined;
}
return this.requestDataSearchPage(url, startIndex);
});
}
) {
if (!ckanIdOrName)
throw new Error(`Invalid ckanIdOrName ${ckanIdOrName}`);
const orgFullName = await getCkanOrganisationFullNameMagdaId(
ckanIdOrName
);
if (!orgFullName || !orgFullName.trim()) {
showError(res, {
errorCode: 404,
recordType: "ckan-organization-details",
recordId: ckanIdOrName
});
} else {
let uri: any = new URI("/search");
//--- make sure %20 is used instead of +
uri = uri.escapeQuerySpace(false).search({
organisation: orgFullName
});
res.redirect(303, uri.toString());
}
}
getHostname(url) {
return new Uri(url).hostname();
}
export const getURI = () => new URI(window.location.href);