Parcourir la source

Merge branch 'release/v0.1.0'

Jérôme BUISINE il y a 4 ans
Parent
commit
b796880830
6 fichiers modifiés avec 42 ajouts et 12 suppressions
  1. 1 0
      .gitignore
  2. 19 2
      docker-compose.yml
  3. 2 2
      links/templates/links/index.html
  4. 8 3
      links/views.py
  5. 1 1
      static/js/displayLinks.js
  6. 11 4
      static/js/links.js

+ 1 - 0
.gitignore

@@ -108,3 +108,4 @@ links/data
 links/expe
 .vscode
 media
+!media/expe.png

+ 19 - 2
docker-compose.yml

@@ -2,6 +2,14 @@ version: '3'
 
 services:
 
+    mongo:
+        container_name: mongo
+        image: mongo
+        ports:
+           - "27017:27017"
+        networks:
+            - backend
+
     webexpe:
         container_name: sin3dlauncherinst
         image: sin3dlauncher
@@ -10,7 +18,16 @@ services:
             - "./media:/usr/src/app/media" # get access to media files
         ports:
            - "${PORT:-8000}:8000"
-        
+        links:
+            - mongo
         # only comment in case it will be necessary
         environment:
-           WEB_PREFIX_URL: "${WEB_PREFIX_URL:-}"
+           WEB_PREFIX_URL: "${WEB_PREFIX_URL:-}"
+
+        depends_on:
+            - mongo
+        networks:
+            - backend
+
+networks:
+    backend:

+ 2 - 2
links/templates/links/index.html

@@ -3,7 +3,7 @@
 {% load static %}
 
 {% block title %}
-    Links list
+    SIN3D Links
 {% endblock %}
 
 {% block content %}
@@ -42,7 +42,7 @@
                 <div class="form-group">
                     <label for="userId">User ID</label>
                     <input type="text" id="userId" class="form-control" name="userId" placeholder="Enter your user identifier"/>
-                    <div id="userIdFeedback"></div>
+                    <div id="userIdFeedback" style="height:20px;display:block !important;"></div>
                 </div>
 
                 <button id="generateButton" type="button" class="btn btn-success" disabled>Generate</button>

+ 8 - 3
links/views.py

@@ -51,7 +51,7 @@ def load_index(request):
     - experiment identifiers available from configuration
     '''
 
-    data = {}
+    data = get_base_data()
 
     # get all configurations
     configurations = configurations_collection.find()
@@ -69,7 +69,9 @@ def load_index(request):
 
 def check_user_id(request):
 
-    data = {'status': True, 'message': None}
+    data = get_base_data()
+    data['status'] = True
+    data['message'] = None
 
     if request.method == 'POST':
         
@@ -111,7 +113,10 @@ def generate_user_link(request):
     Generate link is possible for user, otherwise send an issue with error code
     '''
 
-    data = {'status': False}
+    data = get_base_data()
+    data['status'] = True
+    data['message'] = None
+    
     # create link and add it to local storage of navigator
     if request.method == 'POST':
 

+ 1 - 1
static/js/displayLinks.js

@@ -44,7 +44,7 @@ async function loadLinks(){
                     <li><p><i class="fa-li fas fa-flask"></i> ' + experimentId + '</p></li> \
                     <li><p><i class="fa-li fas fa-id-badge"></i> '  + userId + '</p></li>\
                     </ul>\
-                    <a href="' + userValue.link + '"><span class="badge badge-primary badge-pill">Launch experiment <i class="fas fa-external-link-alt"></i></span></a>'
+                    <a href="' + userValue.link + '" target="_blank"><span class="badge badge-primary badge-pill">Launch experiment <i class="fas fa-external-link-alt"></i></span></a>'
                     cardBodyList.append(cardBodyItem)
                 }
             }

+ 11 - 4
static/js/links.js

@@ -16,8 +16,10 @@ async function loadExperiment(){
         current_guild_id = urlParams.get('id')
 
         for (let option of guildIdField.options){
+        
             if (option.value == current_guild_id){
                 option.defaultSelected = true
+                guildIdField.disabled = true // lock field by default
             }
         }
     }
@@ -36,14 +38,17 @@ async function searchUserId(){
     let userId = userIdField.value
 
     if (!userId.length){
+        guildIdChanged()
         return
     }
 
     const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]').value
 
     let data = {'guildId': guildId, 'userId': userId}
+
+    // let url = `${BASE}` === '' ? 'check' : `/${BASE}/check`
     
-    fetch('/check', {
+    fetch('check', {
         method: 'POST',
         body: JSON.stringify(data),
         headers: {
@@ -73,7 +78,7 @@ async function searchUserId(){
 async function guildIdChanged(){
     // reinit field if guild value changed
     userIdField.className = 'form-control'
-    userIdFeedback.className = ''
+    userIdFeedback.className = 'valid-feedback'
     userIdFeedback.innerText = ''
     userIdField.value = ''
     generateButton.disabled = true
@@ -89,7 +94,9 @@ async function generateLink(){
 
     let data = {'guildId': guildId, 'userId': userId}
     
-    fetch('/generate', {
+    // let url = `${BASE}` === '' ? 'generate' : `/${BASE}/generate`
+
+    fetch('generate', {
         method: 'POST',
         body: JSON.stringify(data),
         headers: {
@@ -139,7 +146,7 @@ async function generateLink(){
             generateInfo.style.display = 'block'
 
             generateInfo.innerHTML = '<button id="generateInfoClose" type="button" class="close" data-dismiss="alert">&times;</button> \
-            Well done! You successfully generate <a href="' + user_link + '" class="alert-link">your experiment link</a>. \
+            Well done! You successfully generate <a href="' + user_link + '" target="_blank" class="alert-link">your experiment link</a>. \
             <strong>This link is unique and associated with your browser</strong>..'
 
         }else{