diff --git a/README.md b/README.md index 3fac21e..cf84b4e 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ An item with no filter value is returned in all cases, and is thus also public. ## Local Development Environment In order to quickly setup a development environment, make use of the `setup_script.sh` script. This will setup the project, initialize and seed the database configurations, import routes and initialize environment config files and generate the keys required. +First clone the Caracal (backup-dev branch), caMicroscope and the Distro repositories and make sure that all of them are in the same parent directory. + Run the script with `./setup_script` or `bash ./setup_script.sh` The script is configured to load a database named "`camic`" from server at "`127.0.0.1`". In order to specify different name and host, simply pass the two while calling the script, like `./setup_script custom_host custom_database_name` + +Run `npm start` to start the application and see it running at `localhost:4010` diff --git a/setup_script.sh b/setup_script.sh index 7b1b049..c90afff 100755 --- a/setup_script.sh +++ b/setup_script.sh @@ -34,6 +34,78 @@ if ! command -v "node" &>/dev/null; then exit fi +### +# check for the existence of required files in the Distro and camicroscope repository +### +echo "Checking for required files" + +#if [[ ! -d ../Distro/db ]] +#then echo "../Distro/db does not exist" +# exit +#fi + +if [[ ! -d ../Distro/config ]] +then echo "../Distro/config does not exist" + exit +fi + +if [[ ! -d ../Distro/jwt_keys ]] +then echo "../Distro/jwt_keys does not exist" + exit +fi + +if [[ ! -d ../caMicroscope ]] +then echo "../caMicroscope does not exist" + exit +fi + +echo "Required files exist." + +echo "Copying files..." + +#if [[ ! -d ../data ]] +#then +# mkdir ../data +# cp -r ../Distro/db ../data/ +#fi + +if [[ ! -d ../config ]] +then + mkdir ../config + cp -r ../Distro/config ../config/ +fi + +if [[ ! -d ./static ]] +then + mkdir ./static + cp ../Distro/config/login.html ./static/login.html +fi + +if [[ ! -d ./keys/jwt_keys ]] +then + cp -r ../Distro/jwt_keys ./keys/ +fi + +if [[ ! -f ./contentSecurityPolicy.json ]] +then + cp ../Distro/config/contentSecurityPolicy.json ./contentSecurityPolicy.json +fi + +if [[ ! -f ./static/additional_links.json ]] +then + cp ../Distro/config/additional_links.json ./static/additional_links.json +fi + +if [[ ! -d ./camicroscope ]] +then + cp -r ../caMicroscope ./camicroscope +fi + +echo "Copying files complete!" + + + + ### ## try connecting to mongodb instance ### diff --git a/static/additional_links.json b/static/additional_links.json new file mode 100644 index 0000000..00f1ad5 --- /dev/null +++ b/static/additional_links.json @@ -0,0 +1,8 @@ +[ + { + "displayName":"Bug Report", + "url":"https://goo.gl/forms/mgyhx4ADH0UuEQJ53", + "icon": "bug_report", + "openInNewTab": true + } +] diff --git a/static/login.html b/static/login.html index 05602aa..ff760a1 100644 --- a/static/login.html +++ b/static/login.html @@ -1,77 +1,159 @@ + - - -
-Sign out - - + + + +
+
+
+

caMicroscope

+
+ -function getUrlParam(name, url) { - if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, '\\$&'); - var regex = new RegExp('[?&#]' + name + '(=([^&#]*)|&|#|$)'), - results = regex.exec(url); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, ' ')); -} +
+

caMicroscope is a tool to view, label, and annotate biomedical images.

+ -function onSignIn(googleUser) { - var id_token = googleUser.getAuthResponse().id_token; - console.info(id_token) - // trade for camic token - var cookie_name = "token" // "token" is expected by elevate router - var base_deployment_url = window.location.toString().split("/").slice(0,-1).join("/") - var redirect_uri = base_deployment_url + "/login.html" - var default_redirect = base_deployment_url + "/apps/table.html" - var state - if (getUrlParam("state")) - { - state = decodeURIComponent(getUrlParam("state")) - } - if (!state){ - state = default_redirect - } +
- if (id_token){ - document.cookie = cookie_name + "=" + id_token; - fetch("./auth/Token/check", - {headers: { - 'Authorization': "Bearer " + id_token - }} - ).then(x=>x.json()).then(x=>{ - console.log("{id provider", id_token) - console.log("{auth service}", x) - if (x.hasOwnProperty('token')){ - document.cookie = cookie_name + "=" + x.token; - window.location = state +
+ +
+ +
+

Please Sign In With Your Google Account

+
+
+
+
+
+ + - + function signOut() { + var auth2 = gapi.auth2.getAuthInstance(); + auth2.signOut().then(function() { + console.log("User signed out."); + }); + } + + function deleteCookies() { + var allcookies = document.cookie.split(";"); + for (var i = 0; i < allcookies.length; i++) { + var cookie = allcookies[i]; + var eqPos = cookie.indexOf("="); + var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie; + document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;"; + } + } + + // google's jwk is here: https://www.googleapis.com/oauth2/v3/certs + function randomString(length) { + var bytes = new Uint8Array(length); + var random = window.crypto.getRandomValues(bytes); + var result = []; + var charset = + "0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~"; + random.forEach(function(c) { + result.push(charset[c % charset.length]); + }); + return result.join(""); + } + + function getUrlParam(name, url) { + if (!url) url = window.location.href; + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&#]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(url); + if (!results) return null; + if (!results[2]) return ""; + return decodeURIComponent(results[2].replace(/\+/g, " ")); + } + + + + + + +