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

Sp 3544 #65

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG JAVA_VERSION=11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name Dockerfile.build the accepted standard?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This file is intentionally named differently as it's used to create the build environment. The Science Portal requires Gradle, JDK 11, and NPM, and if you like keeping your desktop clean, then this is used to build an image that can be used to build the Science Portal.

docker run --rm -ti -v $(pwd):/app -w /app image-from-dockerfile-build gradle -i clean build test


FROM gradle:7-jdk${JAVA_VERSION} as builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the FROM directive, some Docker build kits (e.g. Ubuntu 22.04) require ARG JAVA_VERSION, with no value set, to build the Docker image correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, thanks. If one requires the JAVA_VERSION environment variable inside the build, then this is necessary. I just need it to identify the image to use.


RUN apt update \
&& apt install -y rsync xz-utils

ADD https://nodejs.org/dist/v18.18.0/node-v18.18.0-linux-x64.tar.xz /tmp/

RUN cd /tmp/ \
&& tar xvf node-v18.18.0-linux-x64.tar.xz \
&& rsync -arvc node-v18.18.0-linux-x64/* /usr/local/

FROM gradle:7-jdk${JAVA_VERSION}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above: ARG JAVA_VERSION after the FROM directive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, thanks. If one requires the JAVA_VERSION environment variable inside the build, then this is necessary. I just need it to identify the image to use.

COPY --from=builder /usr/local/ /usr/local/
17 changes: 7 additions & 10 deletions public/dev/js/science_portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
// Nothing happens if user is not authenticated, so no other page
// load information is done until this call comes back (see onAuthenticated event below)
// onAuthenticated event triggered if everything is OK.
portalCore.checkAuthentication(_selfPortalApp.isDev)
portalCore.checkAuthentication()
}

function attachListeners() {
Expand Down Expand Up @@ -224,7 +224,7 @@
portalSessions.loadPlatformUsage(_selfPortalApp.handlePlatformUsage)
}

function handleSessionActionError(e, request) {
function handleSessionActionError(_e, request) {
portalCore.setAjaxFail(portalCore.pageSections.sessionList, request)
}

Expand All @@ -247,11 +247,9 @@
}

function populateSessionList(sessionData) {
var $sessionListDiv = $("#sp_session_list")

if (JSON.stringify(sessionData) === "[]") {
// Pass list to the react app portion for rendering
var sessDataObj = {
const sessDataObj = {
"listType" : "empty",
"sessData" : []
}
Expand All @@ -260,13 +258,13 @@

// Build new list
// Assuming a list of sessions is provided, with connect url, name, type
var newSessionList = new Array()
const newSessionList = []
$(sessionData).each(function () {

var mapEntry = portalForm.getMapEntry(this.type)
// Check to see if there are any items in the sessionType_map that
// may override the defaults
var iconSrc= _selfPortalApp.baseURL + "/science-portal/images/"
var iconSrc = _selfPortalApp.baseURL + "/science-portal/images/"
if (mapEntry != null) {
if (typeof mapEntry.portal_icon != "undefined") {
iconSrc += mapEntry.portal_icon
Expand All @@ -281,7 +279,7 @@
}
}

var nextSessionItem = {
const nextSessionItem = {
"id" : this.id,
"name" : this.name,
"status": this.status,
Expand All @@ -308,11 +306,10 @@

// Add to the list
newSessionList.push(nextSessionItem)

})

// Pass list to the react app portion for rendering
var sessDataObj = {
const sessDataObj = {
"listType" : "list",
"sessData" : newSessionList
}
Expand Down
30 changes: 1 addition & 29 deletions public/dev/js/science_portal_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,7 @@

// ------------ Authentication functions ------------

function checkAuthentication(isDev) {
// From cadc.user.js. Listens for when user logs in
// _selfPortalCore.userManager.subscribe(cadc.web.events.onUserLoad,
// function (_event, data) {
// // Check to see if user is logged in or not
// if (typeof(data.error) !== "undefined") {
function checkAuthentication() {
fetch(baseURL + cadc.web.science.portal.core.userInfoEndpoint)
.then((response) => {
if (!response.ok) {
Expand All @@ -377,29 +372,6 @@
}).catch((error) => {
console.warn(error)
})
// hideModal()
// var userState = {
// loginHandler : portalLogin.handleLoginRequest
// }
// _rApp.setNotAuthenticated(userState)
// } else {
// // Don't directly access react app from here so this
// // function can be connected to the portalLogin
// // cadc.web.science.portal.login.events.onAuthenticateOK event as well.
// // That event is fired after the login form is submitted.
// setAuthenticated()
// }
// })

// if (isDev === true) {
// _selfPortalCore.userManager.user = {name: "dev user"}
// setAuthenticated()
// } else {
// // Call the whoami endpoint to get the user details
// // if they are not logged in, same event is thrown, return payload
// // needs to be checked
// _selfPortalCore.userManager.loadCurrent()
// }
}

function setAuthenticated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import ca.nrc.cadc.auth.AuthMethod;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.RegistryClient;
import ca.nrc.cadc.util.StringUtil;
import org.opencadc.scienceportal.ApplicationConfiguration;
import org.opencadc.scienceportal.SciencePortalAuthGetAction;

Expand All @@ -82,7 +83,13 @@ public class GetAction extends SciencePortalAuthGetAction {

@Override
protected String getEndpoint() {
return GetAction.SESSION_ENDPOINT;
final String path = this.syncInput.getPath();
if (StringUtil.hasText(path)) {
final String trimPath = path.trim();
return GetAction.SESSION_ENDPOINT + (trimPath.startsWith("/") ? path : "/" + path);
} else {
return GetAction.SESSION_ENDPOINT;
}
}

@Override
Expand Down
Loading