page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css" ] )
# Execute a Query to delegate credentials if necessary
- sfa_user_query = Query().get('myslice:user').select('user_hrn').filter_by('user_hrn','==','$user_hrn')
- sfa_user_result = execute_query(self.request, sfa_user_query)
+ #sfa_user_query = Query().get('myslice:user').select('user_hrn').filter_by('user_hrn','==','$user_hrn')
+ #sfa_user_result = execute_query(self.request, sfa_user_query)
user_query = Query().get('local:user').select('config','email','status')
user_details = execute_query(self.request, user_query)
for account_detail in account_details:
for platform_detail in platform_details:
# Add reference account to the platforms
- if 'add_'+platform_detail['platform'] in request.POST:
+ if 'add_'+platform_detail['platform'] in request.POST or request.POST['button_value'] == 'add_'+platform_detail['platform']:
platform_id = platform_detail['platform_id']
user_params = {'platform_id': platform_id, 'user_id': user_id, 'auth_type': "reference", 'config': '{"reference_platform": "myslice"}'}
manifold_add_account(request,user_params)
return HttpResponseRedirect("/portal/account/")
# Delete reference account from the platforms
- if 'delete_'+platform_detail['platform'] in request.POST:
+ if 'delete_'+platform_detail['platform'] in request.POST or request.POST['button_value'] == 'delete_'+platform_detail['platform']:
platform_id = platform_detail['platform_id']
user_params = {'user_id':user_id}
manifold_delete_account(request,platform_id, user_id, user_params)
slice_cred.append(value)
# special case: download each slice credentials separately
for i in range(0, len(slice_list)):
- if 'dl_'+slice_list[i] in request.POST:
+ if 'dl_'+slice_list[i] in request.POST or request.POST['button_value'] == 'dl_'+slice_list[i]:
slice_detail = "Slice name: " + slice_list[i] +"\nSlice Credentials: \n"+ slice_cred[i]
response = HttpResponse(slice_detail, content_type='text/plain')
response['Content-Disposition'] = 'attachment; filename="slice_credential.txt"'
auth_cred.append(value)
# special case: download each slice credentials separately
for i in range(0, len(auth_list)):
- if 'dl_'+auth_list[i] in request.POST:
+ if 'dl_'+auth_list[i] in request.POST or request.POST['button_value'] == 'dl_'+auth_list[i]:
auth_detail = "Authority: " + auth_list[i] +"\nAuthority Credentials: \n"+ auth_cred[i]
response = HttpResponse(auth_detail, content_type='text/plain')
response['Content-Disposition'] = 'attachment; filename="auth_credential.txt"'
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
return HttpResponseRedirect("/portal/account/")
- elif 'dl_pubkey' in request.POST:
+ elif 'dl_pubkey' in request.POST or request.POST['button_value'] == 'dl_pubkey':
for account_detail in account_details:
for platform_detail in platform_details:
if platform_detail['platform_id'] == account_detail['platform_id']:
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
return HttpResponseRedirect("/portal/account/")
- elif 'dl_pkey' in request.POST:
+ elif 'dl_pkey' in request.POST or request.POST['button_value'] == 'dl_pkey':
for account_detail in account_details:
for platform_detail in platform_details:
if platform_detail['platform_id'] == account_detail['platform_id']:
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
return HttpResponseRedirect("/portal/account/")
- elif 'delete' in request.POST:
+ elif 'delete' in request.POST or request.POST['button_value'] == 'delete':
for account_detail in account_details:
for platform_detail in platform_details:
if platform_detail['platform_id'] == account_detail['platform_id']:
return HttpResponseRedirect("/portal/account/")
# download identity for jfed
- elif 'dl_identity' in request.POST:
+ elif 'dl_identity' in request.POST or request.POST['button_value'] == 'dl_identity':
for account_detail in account_details:
for platform_detail in platform_details:
if platform_detail['platform_id'] == account_detail['platform_id']:
return HttpResponseRedirect("/portal/account/")
# Download sfi_config
- elif 'dl_sfi_config' in request.POST:
+ elif 'dl_sfi_config' in request.POST or request.POST['button_value'] == 'dl_sfi_config':
platform_detail = get_myslice_platform(request)
platform_config = json.loads(platform_detail['config'])
account_detail = get_myslice_account(request)
return response
#clear all creds
- elif 'clear_cred' in request.POST:
+ elif 'clear_cred' in request.POST or request.POST['button_value'] == 'clear_cred':
try:
result = clear_user_creds(request, user_email)
if result is not None:
return HttpResponseRedirect("/portal/account/")
# Download delegated_user_cred
- elif 'dl_user_cred' in request.POST:
+ elif 'dl_user_cred' in request.POST or request.POST['button_value'] == 'dl_user_cred':
if 'delegated_user_credential' in account_config:
user_cred = account_config['delegated_user_credential']
response = HttpResponse(user_cred, content_type='text/plain')
return HttpResponseRedirect("/portal/account/")
# Download user_cert
- elif 'dl_user_cert' in request.POST:
+ elif 'dl_user_cert' in request.POST or request.POST['button_value'] == 'dl_user_cert':
if 'user_credential' in account_config:
user_cred = account_config['user_credential']
obj_cred = Credential(string=user_cred)
return HttpResponseRedirect("/portal/account/")
# Download user p12 = private_key + Certificate
- elif 'dl_user_p12' in request.POST:
+ elif 'dl_user_p12' in request.POST or request.POST['button_value'] == 'dl_user_p12':
if 'user_credential' in account_config and 'user_private_key' in account_config:
user_cred = account_config['user_credential']
obj_cred = Credential(string=user_cred)
messages.error(request, 'Download error: User private key or credential is not stored in the server')
return HttpResponseRedirect("/portal/account/")
-
-
else:
messages.info(request, 'Under Construction. Please try again later!')
return HttpResponseRedirect("/portal/account/")
-from django.http import HttpResponse
-from manifold.core.query import Query
-from manifoldapi.manifoldapi import execute_query,execute_admin_query
-from portal.models import PendingUser, PendingSlice, PendingAuthority
+from django.http import HttpResponse
+from manifold.core.query import Query
+from manifoldapi.manifoldapi import execute_query,execute_admin_query
+from portal.models import PendingUser, PendingSlice, PendingAuthority
+from unfold.page import Page
+
import json
-from django.contrib.auth.models import User
-from django.contrib.sites.models import Site
-from django.contrib.auth import get_user_model
-from django.template.loader import render_to_string
-from django.core.mail import EmailMultiAlternatives, send_mail
+from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
+from django.contrib.auth import get_user_model
+from django.template.loader import render_to_string
+from django.core.mail import EmailMultiAlternatives, send_mail
-from myslice.theme import ThemeView
-from myslice.configengine import ConfigEngine
+from myslice.theme import ThemeView
+from myslice.configengine import ConfigEngine
theme = ThemeView()
def authority_get_pis(request, authority_hrn):
# REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
- query = Query.get('authority').filter_by('authority_hrn', '==', authority_hrn).select('pi_users')
+ query = Query.get('myslice:authority').filter_by('authority_hrn', '==', authority_hrn).select('pi_users')
results = execute_admin_query(request, query)
print "authority_get_pis = %s" % results
# NOTE: temporarily commented. Because results is giving empty list.
return None
def is_pi(wsgi_request, user_hrn, authority_hrn):
- # XXX could be done in a single query !
-
- # seauthorities from user where user_hrn == "ple.upmc.jordan_auge"
-
- # REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
- query = Query.get('myslice:user').filter_by('user_hrn', '==', user_hrn).select('pi_authorities')
- results = execute_admin_query(wsgi_request, query)
- if not results:
- # XXX Warning ?
- return False
- result = results[0]
- user_authority_hrns = result.get('pi_authorities', [])
- return authority_hrn in user_authority_hrns
+ # authorities from user where user_hrn == "ple.upmc.jordan_auge"
+ print "#### actions.py is_pi authority_hrn = ", authority_hrn
+ try:
+ # CACHE PB with fields
+ page = Page(wsgi_request)
+ metadata = page.get_metadata()
+ user_md = metadata.details_by_object('user')
+ user_fields = [column['name'] for column in user_md['column']]
+
+ # REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
+ query = Query().get('myslice:user').select(user_fields).filter_by('user_hrn','==',user_hrn)
+ #query = Query.get('myslice:user').filter_by('user_hrn', '==', user_hrn).select('pi_authorities')
+ results = execute_query(wsgi_request, query)
+ print "is_pi results = ", results
+ for user_detail in results:
+ if authority_hrn in user_detail['pi_authorities']:
+ return True
+ except Exception,e:
+ print "Exception in actions.py in is_pi %s" % e
+ return False
# SFA get record
# Add User to Slice if we have the user_hrn in pendingslice table
user_hrn = request.get('user_hrn', None)
user_hrns = list([user_hrn]) if user_hrn else list()
-
+
+ # CACHE PB with fields
+ page = Page(wsgi_request)
+ metadata = page.get_metadata()
+ user_md = metadata.details_by_object('user')
+ user_fields = [column['name'] for column in user_md['column']]
+
# REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
- user_query = Query().get('myslice:user').select('user_hrn','user_email').filter_by('user_hrn','==',user_hrn)
+ #user_query = Query().get('myslice:user').select('user_hrn','user_email').filter_by('user_hrn','==',user_hrn)
+ user_query = Query().get('myslice:user').select(user_fields).filter_by('user_hrn','==',user_hrn)
user_details_sfa = execute_admin_query(wsgi_request, user_query)
if not user_details_sfa:
raise Exception, "User %s doesn't exist, validate user before validating slice" % user_hrn
# else:
print "SLICE QUERY"
print "-" * 80
- slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('slices.slice_hrn')
+ slice_query = Query().get('myslice:user').filter_by('user_hrn', '==', '$user_hrn').select('slices.slice_hrn')
page.enqueue_query(slice_query)
page.enqueue_query(testbed_query)
from django.shortcuts import render_to_response
from django.shortcuts import render
+from unfold.page import Page
from unfold.loginrequired import LoginRequiredAutoLogoutView
from manifold.core.query import Query
from ui.topmenu import topmenu_items, the_user
from myslice.configengine import ConfigEngine
-from portal.actions import authority_check_pis
+from portal.actions import is_pi, authority_check_pis
from myslice.theme import ThemeView
import json
if request.user.is_authenticated():
env['person'] = self.request.user
if authority_hrn is None:
- user_query = Query().get('myslice:user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn')
+ # CACHE PB with fields
+ page = Page(wsgi_request)
+ metadata = page.get_metadata()
+ user_md = metadata.details_by_object('user')
+ user_fields = [column['name'] for column in user_md['column']]
+
+ # REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
+ user_query = Query().get('myslice:user').select(user_fields).filter_by('user_hrn','==',user_hrn)
+ #user_query = Query().get('myslice:user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn')
user_details = execute_query(self.request, user_query)
try:
env['user_details'] = user_details[0]
env['project'] = True
env['user_details'] = {'parent_authority': authority_hrn}
-
-
else:
env['person'] = None
-
- pi = authority_check_pis (self.request, str(self.request.user))
+ print "BEFORE ####------#### is_pi"
+ pi = is_pi(self.request, '$user_hrn', env['user_details']['parent_authority'])
+ print "is_pi = ",is_pi
env['theme'] = self.theme
env['section'] = "Institution"
from django.views.generic.base import TemplateView
from unfold.loginrequired import LoginRequiredView
+from unfold.page import Page
+
from django.http import HttpResponse
from django.shortcuts import render
for authority_hrn, credential in config['delegated_authority_credentials'].items():
credential_authorities.add(authority_hrn)
+ # CACHE PB with fields
+ page = Page(wsgi_request)
+ metadata = page.get_metadata()
+ user_md = metadata.details_by_object('user')
+ user_fields = [column['name'] for column in user_md['column']]
+
# ** Where am I a PI **
# For this we need to ask SFA (of all authorities) = PI function
- pi_authorities_query = Query.get('myslice:user').filter_by('user_hrn', '==', '$user_hrn').select('pi_authorities')
+ pi_authorities_query = Query.get('myslice:user').filter_by('user_hrn', '==', '$user_hrn').select(user_fields)
pi_authorities_tmp = execute_query(self.request, pi_authorities_query)
pi_authorities = set()
try:
authorities_query = Query.get('authority').select('name', 'authority_hrn')
authorities = execute_admin_query(wsgi_request, authorities_query)
if authorities is not None:
- authorities = sorted(authorities)
+ authorities = sorted(authorities, key=lambda k: k['authority_hrn'])
+ authorities = sorted(authorities, key=lambda k: k['name'])
# Get user_email (XXX Would deserve to be simplified)
user_query = Query().get('local:user').select('email','config')
#else:
# pi = "is_pi"
- pi = authority_check_pis (wsgi_request, user_email)
+ pi = authority_check_pis (wsgi_request, user_email)
+ print "SLICEREQUESTVIEW.PY ----- pi=",pi
# Page rendering
page = Page(wsgi_request)
if authority_hrn is None:
authority_hrn = wsgi_request.POST.get('org_name', '')
+ # Handle project if used
+ project = wsgi_request.POST.get('project', None)
+ if project is not None:
+ authority_hrn = project
+
slice_request = {
'type' : 'slice',
'id' : None,
$.post("/rest/myslice:user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
if (data.length > 0) {
localStorage.setItem('user', JSON.stringify(data[0]));
+ projects = [];
+ $.each(data[0].pi_authorities, function(idx, auth) {
+ // PI on projects
+ if(auth.split('.').length>2){
+ if($.inArray(auth,projects) == -1){
+ projects.push(auth);
+ }
+ }else if (auth.split('.').length>1){
+ // PI on authorities
+ // What are the projects under this authority?
+ $.post("/rest/myslice:authority/",{'fields':['authority_hrn'],'filters':{'authority_hrn':'CONTAINS'+auth}}, function( data ) {
+ $.each(data, function(idx, project) {
+ console.log(project.authority_hrn);
+ if($.inArray(project.authority_hrn,projects) == -1){
+ projects.push(project.authority_hrn);
+ }
+ });
+ });
+ }else{
+ console.log("admin account - we don't list all from root");
+ }
+ });
+ localStorage.setItem('projects', JSON.stringify(projects));
myslice.loadSlices(data[0].slices);
if(isFunction(fn)){
fn();
}
},
- loadProjects: function(fn) {
- var u = localStorage.getItem('user');
- if (u !== 'undefined') {
- user = JSON.parse(u);
- projects = localStorage.getItem('projects');
- if($.isEmptyObject(projects)){
- if($.isEmptyObject(user) || $.isEmptyObject(user.parent_authority)){
- $.post("/rest/myslice:user/",{'filters':{'user_hrn':'$user_hrn'},'fields':['parent_authority']}, function( data ) {
- parent_authority = data[0].parent_authority;
-
- });
- }else{
- parent_authority = user.parent_authority;
- }
- // REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2
- $.post("/rest/myslice:authority/",{'fields':['authority_hrn'],'filters':{'authority_hrn':'CONTAINS'+parent_authority}}, function( data ) {
- localStorage.setItem('projects', JSON.stringify(data));
- if(isFunction(fn)){
- fn();
- }
- });
- }else{
- if(isFunction(fn)){
- fn();
- }
- }
- }
-
- },
getSlices: function(name) {
drawSlices(slices);
}
{% if theme == "fed4fire" %}
- myslice.loadProjects(function(){
- p = myslice.projects();
+ p = myslice.projects();
+ if(p != null){
drawProjects(p);
- });
+ }
{% endif %}
});
var items = [];
$.each( projects, function(i, val) {
- items.push( "<li><a href=\"/portal/project/"+val.authority_hrn+"\">" + val.authority_hrn + "</a></li>" );
+ items.push( "<li><a href=\"/portal/project/"+val+"\">" + val + "</a></li>" );
});
$("div#home-project-list").html($( "<ul/>", { html: items.join( "" ) }));
$("ul#dropdown-project-list").append(items.join( "" ));
{% endfor %}
</ul>
{% endif %}
+
+<form id="editForm" method="post" action="account_process" enctype="multipart/form-data">
+<input type="text" id="button_value" name="button_value" value="" />
+
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs nav-section">
<div class="col-md-12">
- <form id="editForm" method="post" action="account_process" enctype="multipart/form-data">
{% csrf_token %}
<table class="profile">
<tr>
onclick="return confirm('Are you sure? It will overwrite your current credentials and you have delegate it manually.');"/>
</span>
<div style='display:none;'> <input type='hidden' name='dload' /> </div>
- <button type="submit" name="dl_pubkey" class="btn btn-default btn-xs" title="Download your public key" id="dl_file">
+ <button type="submit" name="dl_pubkey" class="btn btn-default btn-xs" title="Download your public key" id="dl_pubkey" onclick="javascript:document.getElementById('button_value').value='dl_pubkey';">
<span class="glyphicon glyphicon-download"></span> Download
</button>
<button class="btn btn-default btn-xs" id="upload_file" type="button" title="Upload a public key">
{%if 'N/A' not in user_private_key%}
<td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform -->
<td class="value">********<a href="#"></a>
- <button type="submit" name="dl_pkey" class="btn btn-default" title="Download your privaye key" id="dl_pkey">
+ <button type="submit" name="dl_pkey" class="btn btn-default" title="Download your privaye key" id="dl_pkey" value="dl_pkey" onclick="javascript:document.getElementById('button_value').value='dl_pkey';">
<span class="glyphicon glyphicon-download"></span> Download
</button>
<input class="btn btn-danger btn-xs" id="delete" name="delete" type="submit" value="Delete" title="Delete your private key"
- onclick="return confirm('Are you sure? If you do so, you have to delegate your credentials manually.');"/>
+ onclick="javascript:document.getElementById('button_value').value='delete'; return confirm('Are you sure? If you do so, you have to delegate your credentials manually.');"/>
</td>
{%else%}
<td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform -->
<td class="value">********<a href="#"></a>
- <button type="submit" name="dl_pkey" class="btn btn-default disabled" title="Download your privaye key" id="dl_pkey">
+ <button type="submit" name="dl_pkey" class="btn btn-default disabled" title="Download your privaye key" id="dl_pkey" value="dl_pkey">
<span class="glyphicon glyphicon-download"></span> Download
</button>
<input class="btn btn-danger btn-xs disabled" id="delete" name="delete" type="submit" title="Delete your private key" value="Delete" />
<tr class="even" id="sfi_config_row">
<td class="key">sfi_config </td>
<td class="value">use sfi_config file with sfi.py package (pip install sfa)<a href="#"></a>
- <button type="submit" name="dl_sfi_config" class="btn btn-default btn-xs" title="Download your sfi_config" id="dl_sfi_config">
+ <button type="submit" name="dl_sfi_config" class="btn btn-default btn-xs" title="Download your sfi_config" id="dl_sfi_config" value="dl_sfi_config" onclick="javascript:document.getElementById('button_value').value='dl_sfi_config';">
<span class="glyphicon glyphicon-download"></span> Download
</button>
</td>
{%if 'N/A' not in user_private_key%}
<td class="key">Identity</td>
<td>
- <button type="submit" name="dl_identity" class="btn btn-default btn-xs" title="You will require it to use jfed" id="dl_identity">
+ <button type="submit" name="dl_identity" class="btn btn-default btn-xs" title="You will require it to use jfed" id="dl_identity" onclick="javascript:document.getElementById('button_value').value='dl_identity';">
<span class="glyphicon glyphicon-download"></span> Download
</button>
</td>
<tr class="border_bottom">
<td class="odd"> {{ row.cred_exp }} </td>
<td class="odd">
- <button class="btn btn-default btn-xs" name= "dl_user_cred" type="submit" title="Download User Credential">
+ <button class="btn btn-default btn-xs" name= "dl_user_cred" type="submit" title="Download User Credential" onclick="javascript:document.getElementById('button_value').value='dl_user_cred';">
<span class="glyphicon glyphicon-download"></span> Credential
</button>
- <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate">
+ <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate" onclick="javascript:document.getElementById('button_value').value='dl_user_cert';">
<span class="glyphicon glyphicon-download"></span> Certificate
</button>
- <button class="btn btn-default btn-xs" name= "dl_user_p12" type="submit" title="Download User PKCS12">
+ <button class="btn btn-default btn-xs" name= "dl_user_p12" type="submit" title="Download User PKCS12" onclick="javascript:document.getElementById('button_value').value='dl_user_p12';">
<span class="glyphicon glyphicon-download"></span> PKCS p12
</button>
</td>
<td class="odd"> {{ row.slice_name }} </td>
<td class="odd"> {{ row.cred_exp }} </td>
<td class="odd">
- <button class="btn btn-default btn-xs" name= "dl_{{row.slice_name}}" type="submit" title="Download Slice Credentials">
+ <button class="btn btn-default btn-xs" name= "dl_{{row.slice_name}}" type="submit" title="Download Slice Credentials" onclick="javascript:document.getElementById('button_value').value='dl_{{row.slice_name}}';">
<span class="glyphicon glyphicon-download"></span> Download
</button>
</td>
<td class="odd"> {{ row.auth_name }} </td>
<td class="odd"> {{ row.cred_exp }} </td>
<td class="odd">
- <button class="btn btn-default btn-xs" name= "dl_{{row.auth_name}}" type="submit" title="Download Authority Credentials">
+ <button class="btn btn-default btn-xs" name= "dl_{{row.auth_name}}" type="submit" title="Download Authority Credentials" onclick="javascript:document.getElementById('button_value').value='dl_{{row.auth_name}}';">
<span class="glyphicon glyphicon-download"></span> Download
</button>
</td>
</table>
<p></p>
{%if '' not in my_users%}
- <p><button class="btn btn-danger btn-lg btn-block" name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
+ <p><button class="btn btn-danger btn-lg btn-block" name= "clear_cred" type="submit" title="Clear All Credentials" onclick="javascript:document.getElementById('button_value').value='clear_cred';">Clear Credentials</button></p>
{%else%}
<p><button class="btn btn-danger btn-lg btn-block disabled" name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
{%endif%}
<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">
+ <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 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">
+ <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>
</div>
{%endif%}
</div>
-</form>
</div>
+</form>
<script>
$(document).ready(function() {
$('.nav-tabs a').click(function (e) {
{%if 'creds_expired' in user_cred %}
<p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
{%endif%}
- {% if pi %}
<div class="col-md-3">
<h3>
EXPERIMENT
</div>
</div>
</div>
- {%else%}
- <div class="row">
- <div class="col-md-4">
- <h3>
- EXPERIMENT
- </h3>
- <div>
- <a href="#"><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> Request Slice</button>
- </div>
- <div>
- <p><strong>Your slices </strong>
- <span title="A slice is a set of testbed resources on which you can conduct an experiment.
- Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'.
- However, on the Fed4FIRE portal, you will only see slices that you have created through Fed4FIRE. If you have created slices elsewhere,
- those slices will not appear here."
- class="glyphicon glyphicon-info-sign">
- </span>
- </p>
- </div>
- <div>
- <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
- </div>
- {% if pending_slices %}
- <p><strong>Pending slices</strong>
- <span title="Slices that you have requested and are pending for validation by the contact person of your organization."
- class="glyphicon glyphicon-info-sign">
- <ul>
- {% for slices in pending_slices %}
- <li>{{slices}}</li>
- {% endfor %}
- </ul>
- </span>
- </p>
- {%endif%}
- <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');">
- <span class="glyphicon glyphicon-cloud"></span> jFed</a>
- </div>
- <div class="col-md-4">
- <h3>
- SUPPORT
- </h3>
- <div>
- <a href="/portal/support"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a>
- </div>
- <div>
- <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-envelope"></span> Contact</button>
- </div>
- <p></p>
- <div>
- <button id="statbtn" type="button" style="width: 150px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' status</button>
- </div>
- <div>
- <button id="repbtn" type="button" style="width: 170px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' reputation</button>
- </div>
- </div>
-
- <div class="col-md-4">
- <h3>
- ACCOUNT
- </h3>
- <div>
- <a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a>
- </div>
- <div>
- <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
- </div>
- <div>
- {% if person.last_name %}
- {{person.first_name}} {{person.last_name}}<br />
- {% endif %}
- <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
- </div>
- </div>
- </div>
- {%endif%}
</div>
{% else %}
</table>
</div>
- {% if pi %}
<div>
+ {% if pi %}
<button id="createproject" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create project</button>
<button id="deleteprojects" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected projects</button>
{% else %}
slice_row = "<tr id='"+val.slice_hrn+"'>";
slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
- slice_row += "<td><a href='/slice/"+val.slice_hrn+"'>" + val.slice_hrn + "</a></td>";
+
+ // filter links to slices, only those that the user has credentials for
+ s = myslice.user.slices;
+ if(s.length > 0 && $.inArray(val.slice_hrn, myslice.user.slices)!=-1){
+ slice_row += "<td><a href='/slice/"+val.slice_hrn+"'>" + val.slice_hrn + "</a></td>";
+ }else{
+ slice_row += "<td>" + val.slice_hrn + "</td>";
+ }
slice_row += "<td>"+users_length+"</td>";
slice_row += "<td>"+slice_url+"</td>";
//slice_row += "<td>"+nodes_length+"</td>";
});
{% else %}
- $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+ $.post("/rest/myslice:user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
var list_users = [];
var table_users = [];
/* Available fields
console.log(val);
project_row = "<tr id='"+val.authority_hrn+"'>";
project_row += "<td><input type='checkbox' class='project' id='"+val.authority_hrn+"'></td>";
- project_row += "<td><a href='/portal/project/"+val.authority_hrn+"'>"+val.authority_hrn+"</a></td>";
+
+ // filter links to projects, only those that the user has credentials for
+ p = myslice.projects;
+ if(p.length > 0 && $.inArray(val.authority_hrn, p)!=-1){
+ project_row += "<td><a href='/portal/project/"+val.authority_hrn+"'>"+val.authority_hrn+"</a></td>";
+ }else{
+ project_row += "<td>"+val.authority_hrn+"</td>";
+ }
project_row += "</tr>";
table_projects.push(project_row);
});
<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="text" class="form-control" id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;"
+ <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 %}
</div>
<div class="form-group">
Project:
- <select id="projects">
- <option>project A</option>
+ <select id="project" name="project">
</select>
</div>
<div class="form-group">
$("#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 %}
draw_projects(jQuery('.ui-state-focus').html());
},
});
-
+ {% endif %}
});
function draw_projects(authority_hrn){
- $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS'+authority_hrn}}, function( data ) {
-
- var projects = [];
- project_row = "<option value=''> - </option>";
- projects.push(project_row);
-
- $.each( data, function( key, val ) {
- console.log(val);
- project_row = "<option value='"+val.authority_hrn+"'>"+val.authority_hrn+"</option>";
+ var projects = [];
+ project_row = "<option value=''> - </option>";
+ projects.push(project_row);
+
+ if(authority_hrn.length > 0){
+ // Not for root authority
+ if(authority_hrn.split('.').length > 1){
+ $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS'+authority_hrn}}, function( data ) {
+
+ $.each( data, function( key, val ) {
+ project_row = "<option value='"+val.authority_hrn+"'>"+val.authority_hrn+"</option>";
+ projects.push(project_row);
+ });
+ $("#project").html(projects.join( "" ));
+ });
+ }else{
+ $("#project").html(projects.join( "" ));
+ }
+ }else{
+ my_projects = JSON.parse(localStorage.getItem('projects'));
+ $.each( my_projects, function( i, val ) {
+ project_row = "<option value='"+val+"'>"+val+"</option>";
projects.push(project_row);
});
- $("#projects").html(projects.join( "" ));
- });
+ $("#project").html(projects.join( "" ));
+ }
}
</script>
{% endblock %}
<h1>Slice created</h1>
As a manager of your institution, your slice has directly been created directly.
-
+<script>
+$(document).ready(function() {
+ localStorage.clear();
+});
+</script>
{% endblock %}
# ** Where am I a PI **
# For this we need to ask SFA (of all authorities) = PI function
- pi_authorities_query = Query.get('user').filter_by('user_hrn', '==', '$user_hrn').select('pi_authorities')
+ pi_authorities_query = Query.get('myslice:user').filter_by('user_hrn', '==', '$user_hrn').select('pi_authorities')
pi_authorities_tmp = execute_query(self.request, pi_authorities_query)
pi_authorities = set()
try: