Skip to content
Snippets Groups Projects
Commit b3b027ef authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

Merge branch 'ssdm-11506-improve-initial-loading-time-of-ng-ui' into master

parents b0da72c7 bb4427a2
No related branches found
No related tags found
No related merge requests found
Showing
with 30603 additions and 19 deletions
config.bundle.*
openbis.bundle.*
\ No newline at end of file
......@@ -5,11 +5,12 @@ buildscript {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'
}
}
plugins {
id "com.moowork.node" version "1.2.0"
}
apply plugin: "com.moowork.node"
configure(allprojects) {
apply plugin:'base'
......
......@@ -36,7 +36,7 @@
}
</script>
<script
src="/openbis/resources/api/v3/config.js"
src="/openbis/resources/api/v3/config.bundle.js"
onerror="loadError()"
></script>
<script src="/openbis/resources/api/v3/require.js"></script>
......
......@@ -36,19 +36,23 @@ function* init() {
let sessionToken = cookie.read(cookie.OPENBIS_COOKIE)
if (sessionToken) {
openbis.useSession(sessionToken)
let sessionInformation = yield call([
openbis,
openbis.getSessionInformation
])
if (sessionInformation) {
yield put(
actions.setSession({
sessionToken: sessionToken,
userName: sessionInformation.userName
})
)
} else {
try {
openbis.useSession(sessionToken)
let sessionInformation = yield call([
openbis,
openbis.getSessionInformation
])
if (sessionInformation) {
yield put(
actions.setSession({
sessionToken: sessionToken,
userName: sessionInformation.userName
})
)
} else {
openbis.useSession(null)
}
} catch (e) {
openbis.useSession(null)
}
}
......
/targets
/bin
/build/
/node/
/.idea/
*.iml
*.eml
\ No newline at end of file
......@@ -6,12 +6,14 @@ buildscript {
dependencies {
classpath 'apache:commons-codec:1.10',
'owasp:dependency-check-gradle:3.1.2',
'paleozogt:symzip-plugin:0.10.1'
'paleozogt:symzip-plugin:0.10.1',
'com.moowork.gradle:gradle-node-plugin:1.2.0'
}
}
apply plugin: org.owasp.dependencycheck.gradle.DependencyCheckPlugin
apply plugin: "org.paleozogt.symzip"
apply plugin: "com.moowork.node"
dependencyCheck {
failBuildOnCVSS = 7 // 0 - 4 = low, 4 - 7 = medium, 7 - 9 = high, 9-10 = critical
......@@ -185,7 +187,21 @@ task untarGwt(type: Copy) {
into gwtBuildDir
}
task copyOpenbisStaticResources(type: Copy, dependsOn: untarGwt) {
node {
download = true
version = '10.22.0'
workDir = file("${projectDir}/node/nodejs")
nodeModulesDir = file("${projectDir}")
}
task bundleOpenbisStaticResources(type: Exec) {
dependsOn 'untarGwt'
dependsOn 'npmInstall'
commandLine 'bash', '-c', "${projectDir}/resource/js/v3/build.sh"
}
task copyOpenbisStaticResources(type: Copy) {
dependsOn 'bundleOpenbisStaticResources'
from "${project(':openbis').projectDir}/source/java/ch/systemsx/cisd/openbis/public"
into gwtModuleBuildDir
}
......
{
"name": "dummy-package-json",
"version": "0.0.1",
"description": "This configuration file is required by NodeJS gradle plugin which is used to bundle all JS files together",
"scripts": {},
"devDependencies": {},
"dependencies": {}
}
temp
\ No newline at end of file
#!/bin/bash
pushd $(dirname $0) > /dev/null
OPENBIS_STANDARD_TECHNOLOGIES_DIR=../../..
OPENBIS_DIR=../../../../openbis
CURRENT_DIR=$(pwd)
TEMP_DIR=${CURRENT_DIR}/temp
V3_DIR=$OPENBIS_DIR/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3
# create an empty temporary folder
rm -rvf $TEMP_DIR
mkdir -p $TEMP_DIR
# create a list of all *.js files from chosen V3 folders
cd $V3_DIR
find ./as ./dss ./util -name "*.js" | sed 's/^.\//"/g' | sed 's/.js$/",/g' > $TEMP_DIR/files.js
# create config files from their templates by replacing '__FILES__' with a content of 'files.js'
cd $CURRENT_DIR
cat r.config.template.js | sed -e '\|__FILES__|{' -e "r $TEMP_DIR/files.js" -e 'd' -e '}' > $TEMP_DIR/r.config.js
cat config.bundle.template.js | sed -e '\|__FILES__|{' -e "r $TEMP_DIR/files.js" -e 'd' -e '}' > $TEMP_DIR/config.bundle.js
cat config.bundle.min.template.js | sed -e '\|__FILES__|{' -e "r $TEMP_DIR/files.js" -e 'd' -e '}' > $TEMP_DIR/config.bundle.min.js
# create a JS bundle using NodeJS binary installed by NodeJS gradle plugin
$OPENBIS_STANDARD_TECHNOLOGIES_DIR/node/nodejs/node-*/bin/node r.js -o $TEMP_DIR/r.config.js baseUrl=$V3_DIR optimize=none out=$TEMP_DIR/openbis.bundle.js
$OPENBIS_STANDARD_TECHNOLOGIES_DIR/node/nodejs/node-*/bin/node r.js -o $TEMP_DIR/r.config.js baseUrl=$V3_DIR optimize=uglify out=$TEMP_DIR/openbis.bundle.min.js
# copy relevant files to the V3 public folder
cp $TEMP_DIR/config.bundle.js $TEMP_DIR/config.bundle.min.js $TEMP_DIR/openbis.bundle.js $TEMP_DIR/openbis.bundle.min.js $V3_DIR
popd > /dev/null
\ No newline at end of file
var require = (function () {
var getBaseUrl = function () {
// To find where the V3 API has been loaded from we scan the script tags until finding this file
// This way is possible to load the V3 API from a separate domain
var scripts = document.getElementsByTagName('script')
var baseUrl = null
for (var sIdx = 0; sIdx < scripts.length; sIdx++) {
var src = scripts[sIdx].src
var substringEnd = -1
if ((substringEnd = src.indexOf('/api/v3/config.bundle.min.js')) > -1) {
baseUrl = src.substring(0, substringEnd + '/api/v3'.length)
}
}
return baseUrl
}
return {
baseUrl: getBaseUrl(),
bundles: {
'openbis.bundle.min': [
'jquery',
'stjs',
'underscore',
'moment',
'openbis',
//
__FILES__
//
]
}
}
})()
var require = (function () {
var getBaseUrl = function () {
// To find where the V3 API has been loaded from we scan the script tags until finding this file
// This way is possible to load the V3 API from a separate domain
var scripts = document.getElementsByTagName('script')
var baseUrl = null
for (var sIdx = 0; sIdx < scripts.length; sIdx++) {
var src = scripts[sIdx].src
var substringEnd = -1
if ((substringEnd = src.indexOf('/api/v3/config.bundle.js')) > -1) {
baseUrl = src.substring(0, substringEnd + '/api/v3'.length)
}
}
return baseUrl
}
return {
baseUrl: getBaseUrl(),
bundles: {
'openbis.bundle': [
'jquery',
'stjs',
'underscore',
'moment',
'openbis',
//
__FILES__
//
]
}
}
})()
({
include: [
'openbis',
//
__FILES__
//
],
paths: {
jquery: 'lib/jquery/js/jquery',
stjs: 'lib/stjs/js/stjs',
underscore: 'lib/underscore/js/underscore',
moment: 'lib/moment/js/moment'
},
shim: {
stjs: {
exports: 'stjs',
deps: ['underscore']
},
underscore: {
exports: '_'
}
}
})
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment