Skip to content

Commit

Permalink
hitide-ui-23: added resolutions to cloud dataset metadata (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: jbyrne <[email protected]>
  • Loading branch information
jbyrne6 and jbyrne authored Aug 7, 2023
1 parent 7ee59e1 commit 0140aae
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 46 deletions.
63 changes: 24 additions & 39 deletions src/hitideConfig.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
var hitideProfileBase = "https://localhost:8443";
var edlBase = "https://uat.urs.earthdata.nasa.gov";
var edlClientId = "dxpH2WeN_f8IpNLgHwplsg";
var l2ssBase = "https://podaac-tools.jpl.nasa.gov";
// var cmrBase = "https://localhost:8443/hitide/api/cmr";
var cmrBase = "https://cmr.uat.earthdata.nasa.gov";
var gtmId = "--";
var hitideProfileOrigin = "https://hitide.profile.podaac.uat.earthdatacloud.nasa.gov/hitide/api";

window.hitideConfig = {
datasetSearchService: l2ssBase + "/l2ss-services/l2ss/dataset/search",
datasetMetadataService: l2ssBase + "/l2ss-services/l2ss/dataset/search",
granuleSearchService: l2ssBase + "/l2ss-services/l2ss/granule/search",
granuleAvailabilityService: l2ssBase + "/l2ss-services/l2ss/granule/availability",
variableService: l2ssBase + "/l2ss-services/l2ss/dataset/variable",
datasetSearchService: "https://podaac-tools.jpl.nasa.gov/l2ss-services/l2ss/dataset/search",
datasetMetadataService: "https://podaac-tools.jpl.nasa.gov/l2ss-services/l2ss/dataset/search",
granuleSearchService: "https://podaac-tools.jpl.nasa.gov/l2ss-services/l2ss/granule/search",
granuleAvailabilityService: "https://podaac-tools.jpl.nasa.gov/l2ss-services/l2ss/granule/availability",
variableService: "https://podaac-tools.jpl.nasa.gov/l2ss-services/l2ss/dataset/variable",
paletteService: "https://hitide.podaac.uat.earthdatacloud.nasa.gov/palettes",

cmrDatasetSearchService: cmrBase + "/search/collections.json?tool_name=HiTIDE",
cmrGranuleSearchService: cmrBase + "/search/granules.umm_json",
cmrGranuleAvailabilityService: cmrBase,
cmrVariableService: calculateCmrGraphqlUrl(cmrBase, hitideProfileBase),
crossOriginCmrCookies: cmrBase.includes(hitideProfileBase),
cmrDatasetSearchService: hitideProfileOrigin + "/cmr/search/collections.json?tool_name=HiTIDE",
cmrGranuleSearchService: hitideProfileOrigin + "/cmr/search/granules.umm_json",
cmrCollectionSearchService: hitideProfileOrigin + "/cmr/search/concepts",
cmrGranuleAvailabilityService: hitideProfileOrigin + "/cmr",
cmrVariableService: hitideProfileOrigin + "/cmr/graphql",
crossOriginCmrCookies: true,

authCodeUrl: edlBase + "/oauth/authorize",
authCodeUrl: "https://uat.urs.earthdata.nasa.gov/oauth/authorize",

loginUrl: hitideProfileBase + "/hitide/api/session/login",
logoutUrl: hitideProfileBase + "/hitide/api/session/logout",
getUserUrl: hitideProfileBase + "/hitide/api/session/user/",
submitJobUrl: hitideProfileBase + "/hitide/api/jobs/submit",
jobStatusUrl: hitideProfileBase + "/hitide/api/jobs/status",
jobHistoryUrl: hitideProfileBase + "/hitide/api/jobs/history",
disableJobUrl: hitideProfileBase + "/hitide/api/jobs/disable",
loginUrl: hitideProfileOrigin + "/session/login",
logoutUrl: hitideProfileOrigin + "/session/logout",
getUserUrl: hitideProfileOrigin + "/session/user/",
submitJobUrl: hitideProfileOrigin + "/jobs/submit",
jobStatusUrl: hitideProfileOrigin + "/jobs/status",
jobHistoryUrl: hitideProfileOrigin + "/jobs/history",
disableJobUrl: hitideProfileOrigin + "/jobs/disable",
crossOriginCookies: true,

paletteService: "palettes",
datasetSearchServiceItemsPerPage: 200,
maxGranulesPerDownload: 999999999,
googleTagManagerId: gtmId,
earthDataAppClientId: edlClientId,
showCloudMigrationDialog: false
};

function calculateCmrGraphqlUrl(cmrBase, hitideProfileBase) {
return (
cmrBase.includes(hitideProfileBase) ? cmrBase + "/graphql" :
cmrBase.includes("uat") ? "https://graphql.uat.earthdata.nasa.gov/api" :
cmrBase.includes("sit") ? "https://graphql.sit.earthdata.nasa.gov/api" :
"https://graphql.earthdata.nasa.gov/api"
);
}
googleTagManagerId: "GTM-M5D83V6",
earthDataAppClientId: "dxpH2WeN_f8IpNLgHwplsg"
};
2 changes: 1 addition & 1 deletion src/jpl/dijit/ui/MetadataDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define([
"dojo/_base/window",
"jpl/config/Config",
"moment/moment",
"jpl/utils/SearchVariables"
"jpl/utils/SearchVariables",
], function(declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, template, css,
VariableListing, DatasetAvailability, domAttr, domConstruct, query, win, Config,
moment, SearchVariables) {
Expand Down
47 changes: 43 additions & 4 deletions src/jpl/utils/SearchDatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ define([
}

return all(promises).then(function(resultsArray) {
var additionalDataPromises = []
additionalDataPromises.push(getAdditionalCmrMetadata(resultsArray[1].response.docs))
return all(additionalDataPromises).then(function() {
return resultsArray
})
}).then(function(resultsArray) {
if(promises.length === 1) {
return resultsArray[0];
}
return combineResults(resultsArray[0], resultsArray[1]);
});
})
}

function combineResults(first, second) {
Expand Down Expand Up @@ -72,7 +78,7 @@ define([
/////////////////////////////////////////////////////////////////////
function searchCmr(options) {
var url = constructCmrUrl(options);

// console.log(url)
return request(url, {
handleAs: 'json',
headers: {
Expand All @@ -90,7 +96,7 @@ define([
facet_fields: facets
}
};
});
})
}

function constructCmrUrl(options) {
Expand Down Expand Up @@ -148,6 +154,38 @@ define([
return datasets;
}

function getCmrSpatialExtent(datasetObject){
var conceptId = datasetObject["Dataset-PersistentId"]
var url = config.hitide.externalConfigurables.cmrVariableService;
var customQuery = "{\n collection (conceptId: \"" + conceptId + "\") {\n spatialExtent \n} \n}"

return request.post(url, {
handleAs: 'json',
withCredentials: config.hitide.externalConfigurables.crossOriginCmrCookies,
headers: { "X-Requested-With": null, "Content-Type": "application/json" },
data: JSON.stringify({ query: customQuery })
}).then(function(response) {
var resolutionAndCoordinateSystemObject = response.data.collection.spatialExtent.horizontalSpatialDomain.resolutionAndCoordinateSystem
if (resolutionAndCoordinateSystemObject) {
var resolutionObject = resolutionAndCoordinateSystemObject.horizontalDataResolution.genericResolutions[0]
if (resolutionObject) {
datasetObject["Dataset-AcrossTrackResolution"] = resolutionObject.xDimension
datasetObject["Dataset-AlongTrackResolution"] = resolutionObject.yDimension
}
}
return datasetObject
})
}

function getAdditionalCmrMetadata(collectionObjectArray) {
var promises = collectionObjectArray.map(function(collectionObject) {
return getCmrSpatialExtent(collectionObject)
})
return all(promises).then(function(resolvedPromises) {
return resolvedPromises
})
}

function extractCmrFacets(response) {
var preFacets = response.feed.facets;

Expand Down Expand Up @@ -185,6 +223,7 @@ define([
"X-Requested-With": null
}
}).then(function(response) {
// console.log(response)
return processL2ssResponse(response);
});

Expand All @@ -196,7 +235,7 @@ define([
facet[i] += PODAAC_LABEL;
}
});

// console.log(response)
return response;
}

Expand Down
7 changes: 5 additions & 2 deletions src/jpl/utils/SearchVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ define([
});
}

function searchCmr(dataset) {
function searchCmr(dataset, customQuery) {
// This function uses the cmr graphql api, since this allows getting
// all the variable names for a collection in one request
var url = config.hitide.externalConfigurables.cmrVariableService;

var templateQuery = "{\n collection (conceptId:\"{COLLECTION_ID}\") {\n shortName\n variables {\n items {\n name\n }\n }\n }\n}"

var query = templateQuery.replace("{COLLECTION_ID}", dataset['Dataset-PersistentId']);
if (customQuery) {
query = customQuery
}

return request.post(url, {
handleAs: 'json',
Expand All @@ -68,7 +72,6 @@ define([
});
}


return {
search: search
};
Expand Down

0 comments on commit 0140aae

Please sign in to comment.