From 67e6abf27e553add32d5eef956ab47dbf672c466 Mon Sep 17 00:00:00 2001 From: Yasin Rahman <mohammed-yasin.rahman@lip6.fr> Date: Fri, 10 Apr 2015 17:17:37 +0200 Subject: [PATCH] Several modifications in fed4fire UI + Slice creation is restricted under projects only --- portal/projectrequestview.py | 5 ++ portal/slicerequestview.py | 15 +++- portal/static/js/my_account.edit_profile.js | 4 +- .../fed4fire/fed4fire_account-view.html | 48 ----------- .../fed4fire/fed4fire_home-view.html | 34 ++++++-- .../fed4fire_projectrequest_view.html | 67 ++++++++-------- .../fed4fire/fed4fire_slicerequest_view.html | 79 ++++--------------- 7 files changed, 92 insertions(+), 160 deletions(-) diff --git a/portal/projectrequestview.py b/portal/projectrequestview.py index 64dcbde1..ac3cf9ab 100644 --- a/portal/projectrequestview.py +++ b/portal/projectrequestview.py @@ -122,6 +122,11 @@ class ProjectRequestView(LoginRequiredAutoLogoutView, ThemeView): # What kind of project name is valid? if (post['project_name'] is None or post['project_name'] == ''): errors.append('Project name is mandatory') + + # max project_name length is 10 + if (len(post['project_name']) >10): + errors.append('Project name can be maximum 10 characters long') + if not errors: logger.info("is_pi on auth_hrn = {}".format(user_authority)) diff --git a/portal/slicerequestview.py b/portal/slicerequestview.py index b7be0a88..5a72007a 100644 --- a/portal/slicerequestview.py +++ b/portal/slicerequestview.py @@ -19,6 +19,7 @@ from myslice.theme import ThemeView from myslice.settings import logger import activity.user +theme = ThemeView() class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView): template_name = 'slicerequest_view.html' @@ -150,9 +151,17 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView): if (re.search(r'^[A-Za-z0-9_]*$', slice_name) == None): errors.append('Slice name may contain only letters, numbers, and underscore.') - organization = slice_request['organization'] - if (organization is None or organization == ''): - errors.append('Organization is mandatory') + organization = slice_request['organization'] + if theme.theme == 'fed4fire': + if (organization is None or organization == ''): + errors.append('Selecting project is mandatory') + else: + if (organization is None or organization == ''): + errors.append('Organization is mandatory') + + slice_length= len(slice_request['slice_name']) + if slice_length >19: + errors.append('Slice name can be maximum 19 characters long') diff --git a/portal/static/js/my_account.edit_profile.js b/portal/static/js/my_account.edit_profile.js index f98427e9..026321f2 100644 --- a/portal/static/js/my_account.edit_profile.js +++ b/portal/static/js/my_account.edit_profile.js @@ -136,7 +136,7 @@ jQuery(document).ready(function(){ jQuery("#upload_file").click(function(){ jQuery("#span_upload").show(); - jQuery("#dl_file").hide(); + jQuery("#dl_pubkey").hide(); jQuery("#upload_file").hide(); jQuery("#keyval").hide(); // enforcing when one edit is clicked the rest will not work at same time @@ -157,7 +157,7 @@ jQuery(document).ready(function(){ jQuery("#span_upload").hide(); jQuery("#keyval").show(); - jQuery("#dl_file").show(); + jQuery("#dl_pubkey").show(); jQuery("#upload_file").show(); }); }); diff --git a/portal/templates/fed4fire/fed4fire_account-view.html b/portal/templates/fed4fire/fed4fire_account-view.html index 985974fb..b71f3da8 100644 --- a/portal/templates/fed4fire/fed4fire_account-view.html +++ b/portal/templates/fed4fire/fed4fire_account-view.html @@ -33,7 +33,6 @@ <ul class="nav nav-tabs nav-section"> <li class="active"><a href="#profile">User Profile</a></li> <li><a href="#account">Account</a></li> - <li><a href="#access">Testbed Access</a></li> </ul> </div> </div> @@ -301,55 +300,8 @@ {%endif%} </div> </div> - - - <div class="tab-pane row" id="access"> - <div class="col-md-12"> - - <h3>Testbed Access <small>Reference Accounts in the following testbeds</small></h3> - <table class="mytable table table-bordered table-hover"> - <tr class="odd"> - <th>Platform</th> - <th>Account Type</th> - <th>Reference to</th> - <th>Remove Account</th> - </tr> - {% for row in ref_acc %} - <tr class="border_bottom"> - <td class="odd"> {{ row.platform_name }} </td> - <td class="odd"> {{ row.account_type }} </td> - <td class="odd"> {{ row.account_reference }} </td> - <td class="odd"> - <button class="btn btn-danger" name="delete_{{row.platform_name}}" type="submit" title="Delete account from this platform" onclick="javascript:document.getElementById('button_value').value='delete_{{row.platform_name}}';"> - <span class="glyphicon glyphicon-minus"></span> - </button> - </td> - </tr> - {%endfor%} - </table> - - - <h3>Add reference account to the following testbeds</h3> - <table class="mytable table table-bordered table-hover"> - <tr class="odd"> - <th>Platforms</th> - <th>Add Account</th> - </tr> - {% for platform in platform_list %} - <tr class="border_bottom"> - <td class="odd"> {{ platform.platform_no_access }} </td> - <td class="odd"> - <button class="btn btn-success btn-sm" name= "add_{{platform.platform_no_access}}" type="submit" title="Add account to this platform" onclick="javascript:document.getElementById('button_value').value='add_{{platform.platform_no_access}}';"> - <span class="glyphicon glyphicon-plus"></span> - </button> - </td> - </tr> - {%endfor%} - </table> - </div> {%endif%} </div> -</div> </form> <script> diff --git a/portal/templates/fed4fire/fed4fire_home-view.html b/portal/templates/fed4fire/fed4fire_home-view.html index 5d632b6d..53f353c2 100644 --- a/portal/templates/fed4fire/fed4fire_home-view.html +++ b/portal/templates/fed4fire/fed4fire_home-view.html @@ -6,6 +6,12 @@ {% widget '_widget-news.html' %} </div> --> {% if username %} +{% block head %} +<script type="text/javascript" src="https://java.com/js/dtjava.js"/> +<script type="text/javascript"> +</script> +{% endblock head %} + {% widget "_widget-no_credentials.html" %} <div class="container dashboard"> <div class="row"> @@ -20,10 +26,10 @@ EXPERIMENT </h3> <div> - <a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a> + <a href="/portal/slice_request"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a> </div> <div> - <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Slice</button> + <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button> </div> <div> <p><strong>Your slices </strong> @@ -40,10 +46,9 @@ <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div> </div> <h3 title="Some tools do their own slice creation and management.">Experiment now</h3> - <a class="btn btn-primary" style="width: 150px;" - href='http://jfed.iminds.be/releases/5.4-dev/r2289/webstart/experimenter/jfed-experimenter.jnlp' - title="Click here to start your experiment with jFed" - onclick="return launchApplication('http://jfed.iminds.be/releases/5.4-dev/r2289/webstart/experimenter/jfed-experimenter.jnlp');"> + <a class="btn btn-primary" id="webstart-button" style="width: 150px;" + href='http://jfed.iminds.be/releases/5.4-dev/r2314/webstart/experimenter/jfed-experimenter.jnlp' + title="Click here to start your experiment with jFed"> <span class="glyphicon glyphicon-cloud"></span> jFed</a> </div> <div class="col-md-3"> @@ -52,7 +57,7 @@ <a href="/portal/institution"><img src="{{ STATIC_URL }}img/icon_authority_color.png" alt="" /></a> </div> <div> - <button id="projectrequestbtn" type="button" class="btn btn-default" style="width:165px;"><span class="glyphicon glyphicon-plus"></span> Join Project</button> + <button id="projectrequestbtn" type="button" class="btn btn-default" style="width:165px;"><span class="glyphicon glyphicon-plus"></span> Create/Join project</button> </div> <div> <button id="validaterequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Validate Requests</button> @@ -136,6 +141,17 @@ <script type="text/javascript"> $(document).ready(function() { + $('#webstart-button').click(function(){ + var platform8 = new dtjava.Platform({javafx: '8+', jvm: '1.8+'}); + var config = { + java8_jnlp: 'http://jfed.iminds.be/releases/5.4-dev/r2314/webstart/experimenter/jfed-experimenter.jnlp', + java7_jnlp: 'http://jfed.iminds.be/releases/r2269/webstart/experimenter/jfed-experimenter.jnlp' + }; + var certkey = "{{jfed_identity}}"; + + dtjava.launch({url: config.java8_jnlp, params: {'login-certificate-string' : certkey } } , platform8, {}); + //launchjFed(); + }); {%if 'no_creds' in user_cred or 'creds_expired' in user_cred %} localStorage.clear(); $.post("/cache/clear/", function( data ) { @@ -173,7 +189,8 @@ }); </script> -<!--for jfed tool--> +<!-- +for jfed tool <script type="text/javascript" src="{{STATIC_URL}}js/fed4fire_dtjava_orig.js"></script> <script> function launchApplication(jnlpfile) { @@ -188,6 +205,7 @@ return false; } </script> +--> {# widget "_widget-monitor.html" #} {# widget "_widget-stats-top-slices.html" #} diff --git a/portal/templates/fed4fire/fed4fire_projectrequest_view.html b/portal/templates/fed4fire/fed4fire_projectrequest_view.html index d0021525..be597501 100644 --- a/portal/templates/fed4fire/fed4fire_projectrequest_view.html +++ b/portal/templates/fed4fire/fed4fire_projectrequest_view.html @@ -10,8 +10,8 @@ <div class="row"> <div class="col-md-12"> <ul class="nav nav-tabs nav-section"> - <li class="active"><a href="#existing">Join existing Project</a></li> - <li><a href="#new">Create new Project</a></li> + <li class="active"><a href="#new">Create new Project</a></li> + <li><a href="#existing">Join existing Project</a></li> </ul> </div> @@ -30,39 +30,8 @@ {% endif %} <div class="container tab-content"> - - <div class="tab-pane active" id="existing"> - <div class="row"> - <div class="col-md-6"> - <h3>Join an existing Project</h3> - </div> - <div class="col-md-6"> - <h3>List of projects you are part of</h3> - </div> - </div> - <div class="row"> - <div class="col-md-6"> - <form role="form" method="post" action="/portal/project_request"> - {% csrf_token %} - <div id="project_loading" style="display:inline;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading projects" /></div> - <select id="projects" name="project_name" style="display:none;"></select> <div style="display:none;" id="projects_button"><input type="submit" id="join" name="join" value="Join" class="btn"/></div> - </form> - </div> - <div class="col-md-6"> - <table class="table project-list"> - {% for pending in pending_projects %} - <tr><td>(PENDING) {{ pending.project_name }}</td><td>{{ pending.authority_hrn }}</td><td>{{ pending.created|date:"d/m/Y" }}</td></tr> - {% endfor %} - {% for pending in pending_join_projects %} - <tr><td>(PENDING JOIN) {{ pending.project_name }}</td><td> </td><td>{{ pending.created|date:"d/m/Y" }}</td></tr> - {% endfor %} - </table> - </div> - </div> - </div> - - <div class="tab-pane" id="new"> + <div class="tab-pane active" id="new"> <div class="row"> <div class="col-md-12"> <h3>Create a new Project</h3> @@ -102,6 +71,36 @@ </div> </div> + <div class="tab-pane" id="existing"> + <div class="row"> + <div class="col-md-6"> + <h3>Join an existing Project</h3> + </div> + <div class="col-md-6"> + <h3>List of projects you are part of</h3> + </div> + </div> + <div class="row"> + <div class="col-md-6"> + <form role="form" method="post" action="/portal/project_request"> + {% csrf_token %} + <div id="project_loading" style="display:inline;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading projects" /></div> + <select id="projects" name="project_name" style="display:none;"></select> <div style="display:none;" id="projects_button"><input type="submit" id="join" name="join" value="Join" class="btn"/></div> + </form> + </div> + <div class="col-md-6"> + <table class="table project-list"> + {% for pending in pending_projects %} + <tr><td>(PENDING) {{ pending.project_name }}</td><td>{{ pending.authority_hrn }}</td><td>{{ pending.created|date:"d/m/Y" }}</td></tr> + {% endfor %} + {% for pending in pending_join_projects %} + <tr><td>(PENDING JOIN) {{ pending.project_name }}</td><td> </td><td>{{ pending.created|date:"d/m/Y" }}</td></tr> + {% endfor %} + + </table> + </div> + </div> + </div> </div> <script> diff --git a/portal/templates/fed4fire/fed4fire_slicerequest_view.html b/portal/templates/fed4fire/fed4fire_slicerequest_view.html index 7bcd56de..063a9f83 100644 --- a/portal/templates/fed4fire/fed4fire_slicerequest_view.html +++ b/portal/templates/fed4fire/fed4fire_slicerequest_view.html @@ -34,24 +34,10 @@ title="Please enter a name for your slice"required="required"> </div> <div class="form-group"> - {% if pi %} - <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization" - title="An authority responsible for vetting your slice" required="required"> - {% else %} - <input type="hidden" class="form-control" id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;" - title="An authority responsible for vetting your slice" required="required" readonly> - <span style="float:left;">Authority: </span> - <div id="authority_display"> - <img src="{{ STATIC_URL }}img/loading.gif" alt="Loading authority" /> - </div> - {% endif %} + <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Project" + title="Select a project under which you want to create your slice" required="required"> </div> <div class="form-group"> - Project: <div id="project_loading" style="display:inline;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading projects" /></div> - <select id="project" name="project" style="display:none;"> - </select> - </div> - <div class="form-group"> <input type="text" class="form-control" name="url" id="url" style="width:300px" placeholder="Experiment URL (if one exists)" title="Please provide the url of your experiment if you have one." value="{{url}}"> </div> @@ -71,58 +57,21 @@ <script> jQuery(document).ready(function(){ - - $("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) { - var jsonData = JSON.parse(data); - $(this).attr("value", jsonData[0]['parent_authority']); - {% if pi %} - draw_projects(jsonData[0]['parent_authority']); - {% else %} - $('#authority_display').html(jsonData[0]['parent_authority']); - draw_projects(''); - {% endif %} - }); - - {% if pi %} - $("#authority_hrn").val("{{authority_name}}"); - var availableTags = [ - {% if authorities %} - {% for authority in authorities %} - {% if authority.name %} - {value:"{{ authority.name }}",label:"{{authority.name}}"}, - // to show only full name - {% else %} - {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"}, - {% endif %} - {% endfor %} - {% else %} - {value:"",label:"No authority found !!!"} - {% endif %} - ]; - // sorting the list - availableTags.sort(function(a,b){ - var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase(); - if (nameA < nameB) { - return -1; - } - if (nameA > nameB) { - return 1; - } - return 0; - }); + var myprojects = JSON.parse(localStorage.getItem('projects')); $( "#authority_hrn" ).autocomplete({ - source: availableTags, - minLength: 0, - select: function( event, ui ) { - $("#project").hide(); - $("#project_loading").css('display', 'inline-block'); - draw_projects(jQuery('.ui-state-focus').html()); - }, + source: myprojects, + change: function (event, ui) { + if(!ui.item){ + //http://api.jqueryui.com/autocomplete/#event-change - + // The item selected from the menu, if any. Otherwise the property is null + //so clear the item for force selection + $("#authority_hrn").val(""); + } + } }); - {% endif %} }); -function draw_projects(authority_hrn){ +/*function draw_projects(authority_hrn){ var projects = []; project_row = "<option value=''> - </option>"; @@ -152,7 +101,7 @@ function draw_projects(authority_hrn){ } $("#project").show(); $("#project_loading").hide(); -} +}*/ </script> {% endblock %} -- 2.47.0