Skip to content

Commit

Permalink
Merge pull request #61 from opencadc/SP-3544
Browse files Browse the repository at this point in the history
Sp 3544
  • Loading branch information
at88mph authored Jun 28, 2024
2 parents 434e669 + 42bbe23 commit d2b46d5
Show file tree
Hide file tree
Showing 35 changed files with 2,179 additions and 259 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/gradle-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Build Science Portal

on:
push:
pull_request:

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'

# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0

- name: Build with Gradle Wrapper
run: ./gradlew clean build test

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0
# with:
# gradle-version: '8.5'
#
# - name: Build with Gradle 8.5
# run: gradle build

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## Feb 9, 2023
## Oct 23, 2023

### 3.5
- Add OpenID Connect capabilities
- Add themes to support SRC (`src`) and CANFAR (`canfar`)
- Add local endpoints to remove risk of CORS

### 3.3
Supporting Changes
(none)
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM images.opencadc.org/library/cadc-tomcat:1

COPY build/libs/science-portal.war /usr/share/tomcat/webapps/
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

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

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 --from=builder /usr/local/ /usr/local/
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# CANFAR Science Portal
### V 3.3
##### Feb 9, 2023
### V 3.5
##### Oct 23, 2023

UI for accessing and managing Jupyterlab notebooks, carta, desktop and other interactive sessions that back onto CANFAR resources.
UI for accessing and managing JupyterLab notebooks, Carta, Desktop and other interactive sessions that back onto CANFAR resources.

Platform Load information is available, including current CPU usage and counts of running instances.

Expand All @@ -15,6 +15,10 @@ allowing the amount of memory and number of cores you designate to be used to po
## Endpoint locations
All endpoints require authentication with CANFAR, and authorization to access Skaha resource allocations.

### OIDC configuration
The Science Portal UI is now configurable to work with an OpenID Connect provider. See the
`oidc` settings in the [org.opencadc.science-portal.properties](./org.opencadc.science-portal.properties) file.

### Science Portal URL
https://www.canfar.net/science-portal

Expand Down
10 changes: 8 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## deployable containers have a semantic and build tag
# semantic version tag: major.minor
# version tag: major.minor.patch
# build version tag: timestamp
TAGS="1.0.1 $(date -u +"%Y%m%dT%H%M%S")"
#
# 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.3
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")"
unset VER
18 changes: 10 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ plugins {
}

node {
version = '14.15.5'
version = '18.18.0'
}

repositories {
mavenLocal()
mavenCentral()
maven {
url = 'https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/m2repo'
}
}


dependencies {
implementation 'org.opencadc:cadc-util:[1.6,)'
implementation 'org.apache.commons:commons-configuration2:2.3'
implementation 'commons-net:commons-net:3.6'
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.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 'javax.servlet.jsp.jstl:jstl-api:1.2'
runtimeOnly 'javax.servlet:jstl:1.2'
Expand All @@ -44,7 +46,7 @@ war {
}
}

archiveName = 'science-portal.war'
archiveName 'science-portal.war'
}

task buildReactApp(type: NodeTask, dependsOn: 'npmInstall') {
Expand Down
16 changes: 15 additions & 1 deletion org.opencadc.science-portal.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Properties required for interacting with session service

org.opencadc.science-portal.sessions.resourceID = ivo://cadc.nrc.ca/skaha
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

# The token scopes to ask for.
# org.opencadc.science-portal.oidc.scope = openid profile offline_access

# 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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 29 additions & 20 deletions public/dev/js/science_portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,22 @@
* }
*/
function PortalApp(inputs) {
var _reactApp = window.SciencePortalApp
const _reactApp = window.SciencePortalApp

const _selfPortalApp = this

this.baseURL = inputs.baseURL

inputs.headerURLs.baseURLCanfar = inputs.baseURL

inputs.reactApp = _reactApp
_reactApp.setThemeName(inputs.themeName)
_reactApp.setHeaderURLs(inputs.headerURLs)

var portalCore = new cadc.web.science.portal.core.PortalCore(inputs)
var portalSessions = new cadc.web.science.portal.session.PortalSession(inputs)
var portalForm = new cadc.web.science.portal.form.PortalForm(inputs)

var _selfPortalApp = this

this.baseURL = inputs.baseURL

// This folder is the location of config json and other assets
// Variable to support the dev and dist environments
var contentBase = inputs.contentBase
Expand All @@ -67,11 +72,11 @@

function init() {
attachListeners()
portalForm.setContentBase(contentBase)

// loads from session_type_map_en.json.
// Timing issues can occur on very fast systems, so this issues it's own
// event when finished to control when the next stage of portal initialization occurs
portalCore.setHeaderURLs()
portalForm.setContentBase(contentBase)
portalForm.loadSessionTypeMap()
portalCore.setPageState("all", "primary", true, "")
}
Expand All @@ -91,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 All @@ -101,14 +106,14 @@

// Data Flow/javascript object listeners
// portalCore listeners
portalCore.subscribe(portalCore, cadc.web.science.portal.core.events.onAuthenticated, function (e, data) {
portalCore.subscribe(portalCore, cadc.web.science.portal.core.events.onAuthenticated, (_e, data) => {
// onServiceURLOK comes from here
// Contacts the registry to discover where the sessions web service is,
// builds endpoints used to manage sessions, get session, context, image lists, etc.
portalCore.init(URLOverrides)
portalCore.init(URLOverrides, data.accessToken)
})

portalCore.subscribe(portalCore, cadc.web.science.portal.core.events.onServiceURLOK, function (e, data) {
portalCore.subscribe(portalCore, cadc.web.science.portal.core.events.onServiceURLOK, (_e, data) => {
portalSessions.setServiceURLs(portalCore.sessionServiceURLs)
portalForm.setServiceURLs(portalCore.sessionServiceURLs)

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

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

Expand All @@ -242,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 @@ -255,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 @@ -276,7 +279,7 @@
}
}

var nextSessionItem = {
const nextSessionItem = {
"id" : this.id,
"name" : this.name,
"status": this.status,
Expand All @@ -303,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 Expand Up @@ -416,6 +418,7 @@
}

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

Expand All @@ -430,6 +433,12 @@
resolve({"name": sessionData.get("name"), "type": sessionData.get("type")})
} else if (request.status === 400) {
reject(request)
} else if (request.status === 401) {
portalCore.hideModal()
var userState = {
loginHandler : portalLogin.handleLoginRequest
}
_reactApp.setNotAuthenticated(userState)
}
},
false
Expand Down
Loading

0 comments on commit d2b46d5

Please sign in to comment.