Skip to content

Commit

Permalink
Merge pull request #57 from 4dn-dcic/minor-ui-fix-ingestion-page
Browse files Browse the repository at this point in the history
Minor UI fix ingestion page
  • Loading branch information
dmichaels-harvard authored Dec 14, 2023
2 parents aa3b49d + eb47441 commit 619cac9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ foursight-core
Change Log
----------

5.2.0
=====
* Minor UI fixes to the Ingestion page.
* Changed to NOT get Auth0 info from Portal; see foursight_core/react/api/auth0_config.py/PULL_AUTH0_INFO_FROM_PORTAL.


5.1.0
=====
* New tasks page (initially to kick off Portal reindex and redeploy).
Expand Down
3 changes: 1 addition & 2 deletions foursight_core/react/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def get_redis_handler(self):
# 2023-09-21: Moved this from __init__ to here;
# it speeds up provision/deploy from 4dn-cloud-infra.
try:
redis_url = os.environ['REDIS_HOST']
if redis_url and ("redis://" in redis_url or "rediss://" in redis_url):
if (redis_url := os.environ.get('REDIS_HOST')) and ("redis://" in redis_url or "rediss://" in redis_url):
self._redis = RedisBase(create_redis_client(url=redis_url))
except (redis.exceptions.ConnectionError, redis.exceptions.TimeoutError):
PRINT('Cannot connect to Redis')
Expand Down
15 changes: 9 additions & 6 deletions foursight_core/react/api/auth0_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
logging.basicConfig()
logger = logging.getLogger(__name__)

PULL_AUTH0_INFO_FROM_PORTAL = False

# Class to encapsulate the Auth0 configuration
# parameters from the Portal /auth0_config endpoint,
Expand Down Expand Up @@ -60,16 +61,16 @@ class Auth0Config:
}

def __init__(self, portal_url: str) -> None:
if not portal_url:
if not portal_url and PULL_AUTH0_INFO_FROM_PORTAL:
raise ValueError("Portal URL required for Auth0Config usage.")
self._portal_url = portal_url
self._config_url = f"{portal_url}{'/' if not portal_url.endswith('/') else ''}auth0_config?format=json"
self._portal_config_url = f"{portal_url}{'/' if not portal_url.endswith('/') else ''}auth0_config?format=json"

def get_portal_url(self) -> str:
return self._portal_url

def get_config_url(self) -> str:
return self._config_url
def get_portal_config_url(self) -> str:
return self._portal_config_url

@function_cache(nocache={})
def get_config_data(self) -> dict:
Expand Down Expand Up @@ -114,8 +115,10 @@ def get_config_raw_data(self) -> dict:
"""
Returns raw data (dictionary) from the Auth0 config URL.
"""
if not PULL_AUTH0_INFO_FROM_PORTAL:
return {}
try:
auth0_config_response = requests.get(self.get_config_url()).json() or {}
auth0_config_response = requests.get(self.get_portal_config_url()).json() or {}
allowed_connections = auth0_config_response.get("auth0Options", {}).get("allowedConnections")
if isinstance(allowed_connections, str):
# Slight temporary hack to deal with fact that at some points in
Expand All @@ -124,7 +127,7 @@ def get_config_raw_data(self) -> dict:
auth0_config_response["auth0Options"]["allowedConnections"] = json.loads(allowed_connections)
return auth0_config_response
except Exception as e:
logger.error(f"Exception fetching Auth0 config ({self.get_config_url()}): {get_error_message(e)}")
logger.error(f"Exception fetching Auth0 config ({self.get_portal_config_url()}): {get_error_message(e)}")
return {}

def get_client(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions foursight_core/react/ui/static/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "foursight-core"
version = "5.1.0"
version = "5.2.0"
description = "Serverless Chalice Application for Monitoring"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down
5 changes: 4 additions & 1 deletion react/src/pages/IngestionSubmissionsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ const IngestionSubmissionPage = (props) => {
if (columnData?.endsWith(".json")) return "JSON";
else if (columnData?.endsWith(".txt")) return "Text";
else if (columnData?.endsWith(".xlsx")) return "Excel";
else if (columnData?.endsWith(".xls")) return "Excel";
else if (columnData?.endsWith(".zip")) return "ZIP";
else if (columnData?.endsWith(".tar.gz")) return "Tarball";
else if (columnData?.endsWith(".xlsx.gz")) return "Excel (GZIP)";
else if (columnData?.endsWith(".xlsx.gz")) return "Excel (GZIP)";
else return columnData || "Unknown";
}
},
Expand Down Expand Up @@ -399,7 +402,7 @@ const SummaryRow = ({ summary, uuid, bucket, prestyle }) => {
<ExternalLink href={awsDataLink(bucket, uuid, summary.data?.file)} tooltip="Click to view in AWS S3." />&nbsp;&nbsp;&ndash;&nbsp;&nbsp;<small><i>{summary.data?.file}</i></small><br />
<pre style={prestyle}>
{ showSummary ? <>
{ summary?.data?.summary?.map((item, index) => <React.Fragment key={index}>{index > 0 && <br />}{item.trim()}</React.Fragment>)}
{Yaml.Format(summary?.data?.summary)}
</>:<>
<span onClick={toggleSummary} className="pointer">Click to show ...</span>
</>}
Expand Down

0 comments on commit 619cac9

Please sign in to comment.