Skip to content

Commit

Permalink
fix: create configurable tab labels
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed Oct 31, 2024
1 parent 1c7eff1 commit 2ae44a7
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 74 deletions.
24 changes: 10 additions & 14 deletions org.opencadc.science-portal.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ org.opencadc.science-portal.sessions.resourceID = ivo://cadc.nrc.ca/skaha
org.opencadc.science-portal.sessions.standard = vos://cadc.nrc.ca~vospace/CADC/std/Proc#sessions-1.0
org.opencadc.science-portal.themeName = canfar

# OIDC Client information
# org.opencadc.science-portal.oidc.clientID = science-portal-oidc-client
# org.opencadc.science-portal.oidc.clientSecret = science-portal-oidc-client-secretpwd
# Comma-delimited array of tab labels to display in the science portal.
# Defaults are "Public" and "Advanced"
org.opencadc.science-portal.tabLabels = Public, Advanced

# The token scopes to ask for.
# org.opencadc.science-portal.oidc.scope = openid profile offline_access
# OIDC properties (if using)
org.opencadc.science-portal.oidc.clientID = my-openid-client
org.opencadc.science-portal.oidc.clientSecret = my-openid-client-secret
org.opencadc.science-portal.oidc.callbackURI = https://example.com/callback
org.opencadc.science-portal.oidc.redirectURI = https://example.com/redirect
org.opencadc.science-portal.oidc.scope = openid profile email

# Where to redirect the user to after successful authentication. Also known as the redirect_uri in OpenID Connect.
# org.opencadc.science-portal.oidc.redirectURI = https://example.com/science-platform/oidc-callback

# Where to send the user after acquiring a token.
# org.opencadc.science-portal.oidc.callbackURI = https://example.com/science-platform

# Uncomment this line and change the text if a message needs to be displayed
# in the banner
# org.opencadc.science-portal.sessions.bannerText = Banner text from properties file
org.opencadc.science-portal.tokenCache.url = redis://redis.example.com:6379
140 changes: 82 additions & 58 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,72 +1,96 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="Science Portal Test App"
content="Web site created using create-react-app"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta name="Pragma" content="no-cache" />
<meta name="Expires" content="0" />

<script type="application/javascript" src="https://www.canfar.net/canfar/javascript/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://www.canfar.net/cadcJS/javascript/cadc.registry-client.js"></script>
<script type="text/javascript" src="canfarRootCopy/cadc.user.js"></script>
<script type="text/javascript" src="https://www.canfar.net/canfar/javascript/cadc.redirect.util.js"></script>
<!-- <base href="${fn:substring(url, 0, fn:length(url) - fn:length(uri))}${req.contextPath}/" />-->

<script type="application/javascript" src="dev/js/science_portal_login.js"></script>
<script type="application/javascript" src="dev/js/science_portal_core.js"></script>
<script type="application/javascript" src="dev/js/science_portal_session.js"></script>
<script type="application/javascript" src="dev/js/science_portal_form.js"></script>
<script type="application/javascript" src="dev/js/science_portal.js"></script>
<!-- Located in ROOT.war -->
<script type="application/javascript" src="https://www.canfar.net/canfar/javascript/jquery-2.2.4.min.js"></script>

<script type="application/javascript" src="./test_config/sp_test_config.js"></script>
<!-- Add Promises if missing/broken. -->
<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.js"></script>
<!-- Found in canfar-root: tomcat(-canfar)/webapps/ROOT unless an absolute URL -->
<script type="text/javascript" src="https://www.canfar.net/cadcJS/javascript/cadc.registry-client.js"></script>
<script type="text/javascript" src="https://www.canfar.net/cadcJS/javascript/org.opencadc.js"></script>
<script type="text/javascript" src="https://www.canfar.net/cadcJS/javascript/cadc.uri.js"></script>
<script type="text/javascript" src="https://www.canfar.net/cadcJS/javascript/cadc.user.js"></script>
<script type="text/javascript" src="https://www.canfar.net/canfar/javascript/cadc.redirect.util.js"></script>

<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="react-mountpoint"></div>
</body>
<!--[if lt IE 9]><script src="/html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

<script type="application/javascript">
// when the react app has mounted itself (which can be a different point time time
// than document ready,) this function is run to start the Science Portal App
// Using this rather than document.ready because running locally the timing doesn't work
// otherwise
<title>Science Portal</title>
</head>

// NOTE: bannerText can be uncommented and filled in here to test the banner
// NOTE: isDev is required to have authentication be set to true (as there's no local instance of /access
// to properly handle authentication
<body class="theme-src">
<div class="container-fluid fill">
<div class="row fill">
<div role="main" class="col-sm-12 col-md-12 main fill">
<div class="inner fill">
<section id="main_content" class="fill">
<!-- CANFAR React App loads here -->
<div class="science-portal-authenticated">
<div id="sp_listnavbar" class="panel panel-default sp-panel">
<div id="react-mountpoint"></div>
<!-- Content ends -->
</section>
</div>
</div>
</div>
</div>

window.runStartupTasks = () => {
// Set up controller for Science Portal Session Launch page
const launch_js = new cadc.web.science.portal.PortalApp({
baseURL: "https://rc-www.canfar.net",
sessionsResourceID: 'ivo://cadc.nrc.ca/skaha',
//bannerText: "test banner text injected at startup",
contentBase: contentBase,
URLOverrides: devtestSessionURLs,
isDev: true,
registryLocation: devtestSessionURLs.registryClient
})
<!--local files ot pick up-->
<script type="application/javascript" src="dev/js/science_portal_login.js"></script>
<script type="application/javascript" src="dev/js/science_portal_core.js"></script>
<script type="application/javascript" src="dev/js/science_portal_session.js"></script>
<script type="application/javascript" src="dev/js/science_portal_form.js"></script>
<script type="application/javascript" src="dev/js/science_portal.js"></script>
<script type="application/javascript" src="test_config/sp_test_config.js"></script>

launch_js.init()
<script type="application/javascript">
function generateState() {
const length = 16
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
let result = '';
for (let i = length; i > 0; --i) {
result += chars[Math.floor(Math.random() * chars.length)]
}
return result;
}

</script>
const tabLabelArray = ["Test Standard", "Test Advanced"];

window.runStartupTasks = () => {
// Set up controller for Science Portal Session Launch page
const launch_js = new cadc.web.science.portal.PortalApp({
baseURL: window.location.origin,
sessionsResourceID: 'ivo://cadc.nrc.ca/skaha',
sessionsStandardID: 'vos://cadc.nrc.ca~vospace/CADC/std/Proc#sessions-1.0',
themeName: 'src',
tabLabels: tabLabelArray,
bannerText: '',
contentBase: 'dev',
headerURLs: {
"ivo://cadc.nrc.ca/groups": "#",
"ivo://cadc.nrc.ca/search": "#",
"ivo://cadc.nrc.ca/acctupdate": "#",
"ivo://cadc.nrc.ca/passchg": "#",
"ivo://cadc.nrc.ca/cred": "#"
}
})

launch_js.init()
}
</script>

<!-- render the react app last - App.js's render cycle will call window.runStartupTasks() on completion. -->
<!--<script src="${contextPath}/dist/react-app.js"></script>-->

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public String getTokenCacheURLString() {
* @return String array, never null.
*/
public String[] getTabLabels() {
final String[] tabLabelArray = configuration.getStringArray(ConfigurationKey.TAB_LABELS.propertyName);
if (tabLabelArray == null || tabLabelArray.length == 0) {
final String[] tabLabelArray = Arrays.stream(configuration.getString(ConfigurationKey.TAB_LABELS.propertyName).split(","))
.map(String::trim)
.toArray(String[]::new);
if (tabLabelArray.length == 0) {
throw new IllegalStateException("Configuration property " + ConfigurationKey.TAB_LABELS.propertyName + " is missing" + this.filePath);
}

Expand Down

0 comments on commit 2ae44a7

Please sign in to comment.