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

Private harbor fix #74

Merged
merged 12 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# tags with and without build number so operators use the versioned
# tag but we always keep a timestamped tag in case a semantic tag gets
# replaced accidentally
VER=0.2.8
VER=0.3.0
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")"
unset VER
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ repositories {
dependencies {
implementation 'com.opencsv:opencsv:[5.1,6.0)'
implementation 'commons-net:commons-net:3.9.0'
implementation 'org.apache.commons:commons-configuration2:2.10.1'
implementation 'org.apache.commons:commons-configuration2:[2.11.0,3.0.0)'
implementation 'org.opencadc:cadc-access-control-identity:[1.1.0,)'
implementation 'org.opencadc:cadc-gms:[1.0.12,2.0)'
implementation 'org.opencadc:cadc-log:[1.1.5,)'
implementation 'org.opencadc:cadc-rest:[1.3.9,)'
implementation 'org.opencadc:cadc-util:[1.6,)'
implementation 'org.opencadc:cadc-web-token:[1.1.1,2.0.0)'

runtimeOnly 'commons-io:commons-io:[2.17.0,3.0.0)'
runtimeOnly 'javax.servlet.jsp.jstl:jstl-api:1.2'
runtimeOnly 'javax.servlet:jstl:1.2'
runtimeOnly 'jstl:jstl:[1.0,)'
runtimeOnly 'org.apache.taglibs:taglibs-standard-impl:1.2.5'

testImplementation 'junit:junit:[4.12,5.0)'
testImplementation 'org.mockito:mockito-core:[5.14.0,6.0.0)'
}

sourceCompatibility = '1.8'
Expand Down
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
844 changes: 452 additions & 392 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-canfar-core",
"version": "1.0.1",
"version": "1.1.0",
"private": true,
"dependencies": {
"@babel/core": "^7.12.13",
Expand All @@ -20,6 +20,7 @@
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-tabs": "^6.0.2",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down Expand Up @@ -47,7 +48,7 @@
]
},
"devDependencies": {
"webpack": "^5.75.0",
"webpack": "^5.94.0",
"webpack-cli": "^5.0.0"
}
}
35 changes: 29 additions & 6 deletions public/dev/js/science_portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
inputs.reactApp = _reactApp
_reactApp.setThemeName(inputs.themeName)
_reactApp.setHeaderURLs(inputs.headerURLs)
if (inputs.tabLabels) {
_reactApp.setTabLabels(inputs.tabLabels)
}

var portalCore = new cadc.web.science.portal.core.PortalCore(inputs)
var portalSessions = new cadc.web.science.portal.session.PortalSession(inputs)
Expand Down Expand Up @@ -396,10 +399,10 @@
event.preventDefault()
portalCore.clearAjaxAlert(portalCore.pageSections.form)

var _prunedFormData = new FormData();
const _prunedFormData = new FormData();

for (var i=0; i< event.target.length; i++) {
var currentValue = event.target[i]
for (let i= 0; i < event.target.length; i++) {
const currentValue = event.target[i];
_prunedFormData.append(currentValue.name, currentValue.value)
console.log(currentValue.name + ": " + currentValue.value)
}
Expand All @@ -418,9 +421,9 @@
}

function postSessionRequestAjax(serviceURL, sessionData) {
var portalLogin = new cadc.web.science.portal.login.PortalLogin({reactApp: _reactApp})
const portalLogin = new cadc.web.science.portal.login.PortalLogin({reactApp: _reactApp});
return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest()
const request = new XMLHttpRequest();

// "load" is the XMLHttpRequest "finished" event
request.addEventListener(
Expand All @@ -435,7 +438,7 @@
reject(request)
} else if (request.status === 401) {
portalCore.hideModal()
var userState = {
const userState = {
loginHandler : portalLogin.handleLoginRequest
}
_reactApp.setNotAuthenticated(userState)
Expand All @@ -447,7 +450,27 @@
// Note: SameSite cookie header isn't set with this method,
// may cause problems with Chrome and other browsers? Feb 2021
request.withCredentials = true

request.open("POST", serviceURL)

// Request headers can only be set after the request is open.
const secretFieldName = "registryAuthSecret"
const secretHeader = "x-registry-secret"
const usernameHeader = "x-registry-username"
if (sessionData.has(secretFieldName)) {
const secret = sessionData.get(secretFieldName)
const username = sessionData.get("registryAuthUsername")
if (secret) {
request.setRequestHeader(secretHeader, secret)
}

if (username) {
request.setRequestHeader(usernameHeader, username)
}

sessionData.delete(secretFieldName)
}

request.send(sessionData)
}) // end Promise

Expand Down
26 changes: 11 additions & 15 deletions public/dev/js/science_portal_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
* @constructor
*/
function PortalForm() {
var _selfPortalForm = this
const _selfPortalForm = this

this._imageData = new Array()
this._imageData = []
this._contextData = {}
this._sessionTypeList = null
this._sessionTypeMap = {}
Expand Down Expand Up @@ -98,8 +98,8 @@
_selfPortalForm._sessionTypeMap = jsonData

// Build session type list
var tempTypeList = new Array()
for (var i = 0; i < _selfPortalForm._sessionTypeMap.session_types.length; i++) {
const tempTypeList = [];
for (let i = 0; i < _selfPortalForm._sessionTypeMap.session_types.length; i++) {
// each entry has id, type, digest, only 'id' is needed
tempTypeList.push( _selfPortalForm._sessionTypeMap.session_types[i].name)
}
Expand All @@ -116,7 +116,7 @@
}

function getMapEntry(sessionName) {
for (var i = 0; i < _selfPortalForm._sessionTypeMap.session_types.length; i++) {
for (let i = 0; i < _selfPortalForm._sessionTypeMap.session_types.length; i++) {
if (_selfPortalForm._sessionTypeMap.session_types[i].name === sessionName) {
return _selfPortalForm._sessionTypeMap.session_types[i]
}
Expand All @@ -125,29 +125,25 @@
}

function isTypeInList(imageTypes) {
var isInList = (element) => imageTypes.includes(element)
var typeIndex = _selfPortalForm._sessionTypeList.findIndex(isInList)
if (typeIndex === -1) {
return false
} else {
return true
}
const isInList = (element) => imageTypes.includes(element)
const typeIndex = _selfPortalForm._sessionTypeList.findIndex(isInList)
return typeIndex !== -1;
}


// --------------- Image list functions

function getFullImageList() {
var fullListURL = _selfPortalForm.sessionURLs.images
const fullListURL = _selfPortalForm.sessionURLs.images;
Promise.resolve(_getAjaxData(fullListURL))
.then(function (imageList) {

// init the image list structure to simplify the loop below
_selfPortalForm._imageData = {}
for (var j=0; j<_selfPortalForm._sessionTypeList.length; j++) {
_selfPortalForm._imageData[_selfPortalForm._sessionTypeList[j]] = {
"imageList": new Array(),
"imageDisplayList": new Array()
"imageList": [],
"imageDisplayList": []
}
}

Expand Down
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>
Loading
Loading