Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: 1000TurquoisePogs <sgrady@rocketsoftware.com>
  • Loading branch information
1000TurquoisePogs committed Dec 5, 2018
0 parents commit c708462
Show file tree
Hide file tree
Showing 13 changed files with 456 additions and 0 deletions.
71 changes: 71 additions & 0 deletions README.md
@@ -0,0 +1,71 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.# Installation Guide to the Zoe Jupyter App

This jupyter app supports either jupyter lab or jupyter notebook for use in the zLUX MVD.
To install this app first untar the *jupytar.tar.gz* file using **tar -xzf jupytar.tar.gz** .


## Setting up the Jupyter Server and Config Directory

Then, set up and start the jupyter notebook server. To do this one needs to run
**openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem**

See http://jupyter-notebook.readthedocs.io/en/stable/public_server.html for more details.

The *JUPYTER_CONFIG_DIR* needs to be set to the .jupyter directory serving the notebook.
i.e. **JUPYTER_CONFIG_DIR=/u/test_user/.jupyter**
**export JUPYTER_CONFIG_DIR**
This allows the *.jupyter* directory to be set for all users using this app.

Now run **jupyter notebook --certfile=/path/to/certfile --keyfile=/path/to/keyfile --ip=host name --tornado_settings={'headers': {'Content-Security-Policy': "frame-ancestors localhost 'self' "}}**

Alternatively, ** jupyter notebook --generate-config ** can be used to generate a jupyter notebook configuration directory and files, and all the specified parameters can be changed within jupyter_notebook_config.py.

Set the JUP_SERVER environment variable to the given link. This could also be an https link to
a jupyter lab setup.

The final environment variable that needs to be set is ZOE.
This variable should be set to the directory that contains all of the plugins for the MVD.
i.e *~/testing/zlux*

To finally install the plugin run **./initialize.sh** and the plugin should be installed to the MVD.

## Browser
Currently Google Chrome supports this application, however, there is a chrome extension called Ignore-xframe-headers that needs to be installed.
Microsoft Edge should work without any extensions, however, it does not always.

### Bugs and Quirks
Depending on the browser being used, this application may not worked. It is recommended to use Chrome or Edge.
When using Chrome, the extension X-frame-options needs to be enabled.

Sometimes the jupyter notebook/jupyter lab link must be opened within a browser prior to it displaying in the application.


BUGS TO FIX

- The terminal -
Not too certain how to fix this. The Jupyter object in the frontend extensions has a web socket service (wss) link
that can be found. Potentially changing this might allow a USS terminal to be embedded.

### Developer Knowledge

Probably need to use jupyter notebook frontend extensions to communicate between the jupyter notebook
and other apps.
http://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html

Might need to somehow proxy the jupyter notebook to be available on the same host and port as the MVD in order to allow for upwards and downwards communication from the Jupyter notebook to the application in which the iframe is embedded.



This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.
23 changes: 23 additions & 0 deletions custom/custom.js
@@ -0,0 +1,23 @@

/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/
define(['base/js/namespace'], funtion(Jupyter){
Jupyter._target='self';
});

/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/
37 changes: 37 additions & 0 deletions doc/dev/resources.txt
@@ -0,0 +1,37 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.
Potential Structures of Plugins

1. Angular App
Tabs
Iframe for Jupyter Notebook

2. Make Two apps

Angular App
Iframe for Jupyter Notebook

Angular App
Tabs with other apps as content

How to make jupyter notebook only open in within one page.
http://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/JavaScript%20Notebook%20Extensions.html

Creating frontend extensions to the jupyter notebook. This is needed to listen for events within the created
iframe.
http://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html



This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.
69 changes: 69 additions & 0 deletions initialize.sh
@@ -0,0 +1,69 @@
#!/bin/sh
# This program and the accompanying materials are
# made available under the terms of the Eclipse Public License v2.0 which accompanies
# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.

echo "The script starts now"

echo "Hi, $USER!"

# Checking if the environment variable JUPYTER_CONFIG_DIR is set
if [[ -z "${JUPYTER_CONFIG_DIR}" ]]; then

CDIR=$(jupyter --config-dir)
echo "Custom files being placed into the jupyter --config-dir directory, which is: $CDIR"

# Checking if a custom.js file already exists
if [ -r "$CDIR/custom/custom.js" ]
then
# Saves current custom.js in a backup file, and then replaces with custom.js of this project.
touch custom.js
cp "$CDIR/custom/custom.js" "$CDIR/custom/custom-backup.js"
echo "Creating backup of existing custom.js file."
else
# Places custom.js file into appropriate folder.
cp custom.js "$CDIR/custom/custom.js"
echo "Copying the custom.js file into $CDIR"
fi

# Replace the SERVER
if [ -z $JUP_SERVER ]; then
echo "Please set JUP_SERVER to the appropriate jupyter server link."
else
echo "Setting the server to $JUP_SERVER"
sed -r -e "s|iframe src=\".*\"|iframe src=\"$JUP_SERVER\"|" web/html/index.html > web/html/index_tmp.html
cp web/html/index_tmp.html web/html/index.html
rm web/html/index_tmp.html

echo "Updated the server in the jupyter application."
fi

# Copy the appropriate files to their correct locations.

if [ -d $ZOE ]; then
# Copying the app to the folder
cp -R -p pluginDefinition.json $ZOE/jupyter-app/pluginDefinition.json
cp -R -p web $ZOE/jupyter-app/web
cp -R -p org.zowe.zlux.jupyter-app.json $ZOE/zlux-example-server/plugins/org.zowe.zlux.jupyter-app.json
cp -R -p update_server.sh $ZOE/jupyter-app/update_server.sh

cd $ZOE/zlux-build
ant deploy
else
echo "Please set ZOE to an appropriate directory."
fi
else
echo "Please set JUPYTER_CONFIG_DIR to the appropriate .jupyter directory"
fi

# This program and the accompanying materials are
# made available under the terms of the Eclipse Public License v2.0 which accompanies
# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.
4 changes: 4 additions & 0 deletions org.zowe.zlux.jupyter-app.json
@@ -0,0 +1,4 @@
{
"identifier": "org.zowe.zlux.jupyter-app",
"pluginLocation": "../../jupyter-app"
}
25 changes: 25 additions & 0 deletions pluginDefinition.json
@@ -0,0 +1,25 @@
{
"identifier": "org.zowe.zlux.jupyter-app",
"apiVersion": "1.0",
"pluginVersion": "1.0",
"pluginType": "application",
"webContent": {
"framework": "iframe",
"launchDefinition": {
"pluginShortNameKey": "jupyterapp",
"pluginShortNameDefault": "jupyter",
"imageSrc": "assets/icon.png"
},
"descriptionKey": "Jupyter Notebook App embedded using Iframe",
"descriptionDefault": "Jupyter Notebook App embedded using Iframe",
"startingPage": "html/index.html",
"isSingleWindowApp": true,
"defaultWindowStyle": {
"width": 1400,
"height": 700,
"x": 50,
"y": 50
}
},
"dataServices": []
}
24 changes: 24 additions & 0 deletions update_server.sh
@@ -0,0 +1,24 @@
#!/bin/sh
# This program and the accompanying materials are
# made available under the terms of the Eclipse Public License v2.0 which accompanies
# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.
if [ -z $JUP_SERVER ]; then
echo "Please set JUP_SERVER to the appropriate jupyter server link"
else
echo "Setting the server to $JUP_SERVER"
sed -r -e "s|iframe src=\".*\"|iframe src=\"$JUP_SERVER\"|" web/html/index.html > web/html/index_tmp.html
cp web/html/index_tmp.html web/html/index.html
rm web/html/index_tmp.html
echo "Successfully updated the server in the jupyter application"

# This program and the accompanying materials are
# made available under the terms of the Eclipse Public License v2.0 which accompanies
# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
#
# SPDX-License-Identifier: EPL-2.0
#
# Copyright Contributors to the Zowe Project.
Binary file added web/assets/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions web/css/iframe.css
@@ -0,0 +1,34 @@

/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

.iframe-font {
font-family: sans-serif;
font-size: 4.0em;
}

#jup1 {
height: 99%;
width: 100%;
overflow: auto;
align-self: auto;
}



/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/
60 changes: 60 additions & 0 deletions web/html/index.html
@@ -0,0 +1,60 @@

<!--
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
-->

<html>
<head>
<title>Jupyter Notebook App</title>
<meta charset = "UTF-8">
<meta name = "viewport" content = "width=device-width">
<meta name = "referrer" content = "origin-when-cross-origin">
<base target = "_self">

<!-- Add the CSS stylesheet to format the iframe -->
<link rel="stylesheet" href="../css/iframe.css">

<!-- Adding the main.js file to the backend of this iframe -->
<script type="text/javascript" src="../js/main.js"></script>

</head>

<body>

<!-- iFrame containing the Jupyter Notebook application to display in the mvd -->
<iframe src="PLEASE REPLACE WITH ACTUAL JUPYTER URL/USE initialize.sh"
class = "frame1"
id = "jup1"
scrolling = "no"
initial-scale = 2.0
name = "jup_frame1" title = "Jupyter Mainframe"
frameborder = "1">
</iframe>

<script type="text/javascript">

// Use parent to access other applications
//console.log("THIS IS THE PARENT ")
//console.log(parent);

</script>

</body>
</html>

<!--
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
-->

23 changes: 23 additions & 0 deletions web/html/notes.txt
@@ -0,0 +1,23 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.June 11th, 2018
jupyter notebook --NotebookApp.tornado_settings='{"headers":{"Content-Security-Policy":"frame-ancestors self http://localhost:9000; report-uri /api/security/csp-report" }}'
try messing with the tornado_settings to remove the frame ancestors self error.

Refused to display (some link)
in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

New server with SSL and set tornado settings


This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html

SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.

0 comments on commit c708462

Please sign in to comment.