summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrashant S2019-07-17 19:16:56 +0530
committerGitHub2019-07-17 19:16:56 +0530
commitbb9ed5af5e0a9737c89f343ea9d65fe77e25da69 (patch)
tree13305a57d18f58d2f2e4df4477830523dc8012e7
parent07ae1bafcc89c187b4471ddcb9fd19bb213d6c87 (diff)
parent76dcbadbf71febe93fb9d2ffd51b2f3ae54233a2 (diff)
downloadR_on_Cloud_Web_Interface-bb9ed5af5e0a9737c89f343ea9d65fe77e25da69.tar.gz
R_on_Cloud_Web_Interface-bb9ed5af5e0a9737c89f343ea9d65fe77e25da69.tar.bz2
R_on_Cloud_Web_Interface-bb9ed5af5e0a9737c89f343ea9d65fe77e25da69.zip
Merge pull request #3 from prashantsinalkar/master
added new config and validation for file select
-rw-r--r--R_on_Cloud/default_config.py3
-rw-r--r--static/website/js/cloud.js54
-rw-r--r--static/website/templates/index.html13
-rw-r--r--website/views.py2
4 files changed, 38 insertions, 34 deletions
diff --git a/R_on_Cloud/default_config.py b/R_on_Cloud/default_config.py
index 6ad9982..15cedcb 100644
--- a/R_on_Cloud/default_config.py
+++ b/R_on_Cloud/default_config.py
@@ -11,8 +11,9 @@ BIN = '/usr/bin/R' # Path of R bin file
API_URL = "http://127.0.0.1:8001/rscript"
API_URL_PLOT = "http://127.0.0.1:8001/file"
+API_URL_UPLOAD = "http://127.0.0.1:8001/upload"
-ALLOWED_HOST_IP = ['Host IP']
+ALLOWED_HOST_IP = ['127.0.0.1']
TORNADO_IP = '0.0.0.0'
TORNADO_PORT = '8000' # default port
diff --git a/static/website/js/cloud.js b/static/website/js/cloud.js
index 7d7d5dd..773a98a 100644
--- a/static/website/js/cloud.js
+++ b/static/website/js/cloud.js
@@ -1006,49 +1006,47 @@ $(document.body).ready(function() {
});
-$(document).on("click", "#fileuploadsubmit", function() {
-
- if(confirm("Uploaded file last only till sesstion. Use direct file name for execution.")){
- var name = doSubmit();
- $("<span>" + name + "</span>").insertAfter("#uploaddataset");
- $("#uploaddatasetModal").modal('hide');
- $("#uploaddataset").hide();
- }
- else{
- return false;
+ $(document).on("click", "#fileuploadsubmit", function() {
+ if( document.getElementById("fileSelect").files.length == 0 ){
+ alert("No files selected");
+ }else{
+ if(confirm("Uploaded file last only till sesstion. Use direct file name for execution.")){
+ var name = doSubmit();
+ $("<span>" + name + "</span>").insertAfter("#uploaddataset");
+ $("#uploaddatasetModal").modal('hide');
+ $("#uploaddataset").hide();
+ }
+ else{
+ return false;
+ }
}
+ });
-
-
-});
-
-$(document).on("click", "#reset", function() {
- if(confirm("Are you sure you want to reset? Reset will clear of your data/uploaded file.")){
- document.location.reload(true);
- }
- else{
- return false;
- }
-});
+ $(document).on("click", "#reset", function() {
+ if(confirm("Are you sure you want to reset? Reset will clear of your data/uploaded file.")){
+ document.location.reload(true);
+ }
+ else{
+ return false;
+ }
+ });
}); //document.readOnly()
function doSubmit(){
// Form Data
var formData = new FormData();
-
var fileSelect = document.getElementById("fileSelect");
if(fileSelect.files && fileSelect.files.length == 1){
var file = fileSelect.files[0]
formData.set("file", file , file.name);
- }
-
- var session_id = document.getElementById("session_id");
+ var session_id = document.getElementById("session_id");
formData.set("session_id", session_id.value)
- // Http Request
+ // Http Request
var request = new XMLHttpRequest();
- request.open('POST', "http://10.101.201.190:8001/upload");
+ request.open('POST', api_url_upload);
request.send(formData);
return (fileSelect.files[0].name);
+ }
}
diff --git a/static/website/templates/index.html b/static/website/templates/index.html
index d34f097..57405b7 100644
--- a/static/website/templates/index.html
+++ b/static/website/templates/index.html
@@ -16,11 +16,14 @@
<meta name="title" content="R computational resource, R high performance computing on demand">
<meta name="description" content="R on Cloud facilitates execution of the codes for particular example(s) online. The results can then be verified with the solved example(s) from the textbook. It is also possible to change the values of the variables and in fact, the code itself, and execute it. In addition to the given examples, one can also copy and paste (or) write a new code in the input box provided and execute the same.">
<meta name="keywords" content="R on cloud,R online execute,R online compiler,R computation,calcul scientifique,numerical computation,R computing online,R calculator">
- <script>
- if('{{ err_msg }}'){
- alert('{{ err_msg }}');
- }
- </script>
+ <script>
+ var api_url_upload = "{{ api_url_upload }}";
+ </script>
+ <script>
+ if('{{ err_msg }}'){
+ alert('{{ err_msg }}');
+ }
+ </script>
</head>
<body>
diff --git a/website/views.py b/website/views.py
index 8d63b28..f7864d1 100644
--- a/website/views.py
+++ b/website/views.py
@@ -3,11 +3,13 @@ from django.http import HttpResponse
from django.template import loader
import requests
import uuid
+from R_on_Cloud.config import (API_URL_UPLOAD)
def index(request):
context = {}
session_id = uuid.uuid4()
context['session_id'] = str(session_id)
+ context['api_url_upload'] = API_URL_UPLOAD
request.session['session_id'] = str(session_id)
template = loader.get_template('index.html')
return HttpResponse(template.render(context, request))