_record_equals: function(self, other, key_fields)
{
+ if ((typeof self === "string") && (typeof other === "string")) {
+ return self == other;
+ }
for (var i=0; i < key_fields.length; i++) {
var this_value = self[key_fields[i]];
var other_value = other[key_fields[i]];
// you can also call spin_presets() yourself and tweak what you need to, like topmenuvalidation does
spin: function (message) {
if (!message) {
- message = 'Please be patient, this can take a few seconds.';
+ message = 'Please be patient, this can take a minute or two.';
}
$('div.loading').fadeIn('fast');
$('div.loading').find('.message').text(message);
(r'^update/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.update.dispatch'),
(r'^create/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.create.dispatch'),
(r'^delete/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.delete.dispatch'),
+ (r'^credentials/(?P<action>[^/]+)/?$', 'rest.credentials.dispatch'),
#
+ # REST monitoring
+ #(r'^monitor/sfa/getversion/?$', 'rest.monitor.sfaGetVersion'),
#
#(r'^view/?', include('view.urls')),
#(r'^list/slices', 'view.list.slices')
bAutoWidth: true,
});
- //this.elmt('update').click(this, this.do_ok);
- //this.elmt('refresh').click(this, this.do_cancel);
+ this.elmt('close').click(this, this.do_close);
+ //this.elmt('apply_cancel').click(this, this.do_cancel);
- this.elmt('apply').on('shown.bs.modal', function() {
+ this.elmt('apply__window').on('shown.bs.modal', function() {
self.do_update();
})
clear: function()
{
-
},
find_row: function(value)
var username = this.options.username;
- this.spin();
console.log("do_update in progress");
manifold.raise_event(this.options.query_uuid, RUN_UPDATE);
},
- do_ok: function(e)
+ do_close: function(e)
{
- throw 'queryupdater.do_reset Not implemented';
+ var self = e.data;
+ self.table.fnClearTable();
},
+ // Not used today
do_cancel: function(e)
{
throw 'queryupdater.do_clear_annotations Not implemented';
on_query_in_progress: function()
{
- this.spin();
},
on_query_done: function()
{
this.populate_table();
- this.unspin();
},
// D : Data present
on_clear_records: function()
{
+ $('#applyloading').hide();
this.clear();
},
on_query_done: function()
{
- this.unspin();
+ $('#applyloading').hide();
},
// PC : Pending changes
<div id={{ domid }}>
<!-- Modal - columns selector -->
- <div class="modal fade" id="{{domid}}__apply" tabindex="-1" role="dialog" aria-labelledby="{{domid}}__apply__label" aria-hidden="true">
+ <div class="modal fade" id="{{domid}}__apply__window" tabindex="-1" role="dialog" aria-labelledby="{{domid}}__apply__label" aria-hidden="true">
<div class="modal-dialog modal-dialog-large">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title" id="{{domid}}__apply__label">Applying pending changes...</h4>
+ <h4 class="modal-title" id="{{domid}}__apply__label">
+ Applying pending changes...
+
+ <img id="applyloading" src="/static/img/loading.gif" />
+ </h4>
+ <div>
+ Please be patient, this operation can take a minute or two.
+ </div>
</div>
<div class="modal-body">
<div class='resources-selected-spacer'>
-->
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ <button id="{{domid}}__close" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
<!-- Button toolbar -->
- <button class="btn btn-onelab btn-sm" data-toggle="modal" data-target="#{{domid}}__apply">Apply</button>
- <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#{{domid}}__cancel">Cancel</button>
+ <button class="btn btn-onelab btn-sm" id="{{domid}}__apply" data-toggle="modal" data-target="#{{domid}}__apply__window">Apply</button>
+ <!-- <button class="btn btn-default btn-sm" id="{{domid}}__cancel">Cancel</button> -->
</div>
data = {
state: STATE_SET,
key : null,
- op : this.checked ? SET_ADD : SET_REMOVED,
+ op : this.checked ? STATE_SET_ADD : STATE_SET_REMOVE,
value: id
}
manifold.raise_event(self.options.query_uuid, FIELD_STATE_CHANGED, data);
}\r
\r
#scheduler-reservation-table tbody tr td.free:hover ,#scheduler-reservation-table tbody tr td.selected, #scheduler-reservation-table tbody tr td.selected_tmp {\r
- background: #25BA25;\r
+ background: #26c9e2;\r
}\r
\r
td.no-image {\r
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6c9e2', endColorstr='#e0e0e0',GradientType=1 ); /* IE6-9 */\r
\r
padding: 3px 0 3px 30px;\r
- width: 150px;\r
+ width: 250px;\r
}\r
\r
.legend ol li.free{\r
+ background: #FFFFFF;\r
\r
}\r
.legend ol li.pendingin{\r
background: #25BA25;\r
}\r
\r
+.legend ol li.disabled {\r
+ background: url("../img/forbidden.png") no-repeat scroll 2px 50% #FFFFFF;\r
+}\r
+\r
/* latest stuff */\r
.sliderContainer {\r
margin-left: -15px;\r
<div class="legend">\r
<ol>\r
<li class="free">Free</li>\r
- <li class="pendingin">Pending selected</li>\r
- <li class="pendingout">Pending deselected</li>\r
- <li class="selected">Selected</li>\r
- <li class="closed">Reserved</li>\r
+ <li class="selected">Reserved</li>\r
+ <li class="pendingin">Reservation pending</li>\r
+ <li class="pendingout">Reservation cancellation pending</li>\r
+ <li class="closed">Unavailable</li>\r
+ <li class="disabled">Forbidden</li>\r
<li class="maintenance">Maintenance</li>\r
</ol>\r
</div>\r
#
from manifold.core.query import Query
from manifoldapi.manifoldapi import execute_query
-from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user
+from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user, clear_user_creds
#
from unfold.page import Page
from ui.topmenu import topmenu_items_live, the_user
# getting the user_id from the session
for user_detail in user_details:
user_id = user_detail['user_id']
+ user_email = user_detail['email']
for account_detail in account_details:
for platform_detail in platform_details:
#clear all creds
elif 'clear_cred' in request.POST:
- for account_detail in account_details:
- for platform_detail in platform_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'myslice' in platform_detail['platform']:
- account_config = json.loads(account_detail['config'])
- user_cred = account_config.get('delegated_user_credential','N/A')
- if 'N/A' not in user_cred:
- user_hrn = account_config.get('user_hrn','N/A')
- user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
- user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
- updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
- user_params = { 'config': updated_config}
- manifold_update_account(request,user_id, user_params)
- messages.success(request, 'All Credentials cleared')
- return HttpResponseRedirect("/portal/account/")
- else:
- messages.error(request, 'Delete error: Credentials are not stored in the server')
- return HttpResponseRedirect("/portal/account/")
- else:
+ try:
+ result = clear_user_creds(request, user_email)
+ if result is not None:
+ messages.success(request, 'All Credentials cleared')
+ else:
+ messages.error(request, 'Delete error: Credentials are not stored in the server')
+ except Exception,e:
+ print "Exception in accountview.py in clear_user_creds %s" % e
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
- return HttpResponseRedirect("/portal/account/")
-
+ return HttpResponseRedirect("/portal/account/")
# Download delegated_user_cred
elif 'dl_user_cred' in request.POST:
results = execute_admin_query(request, query)
return [result['user_email'] for result in results]
+#clear user credentials
+def clear_user_creds(request, user_email):
+ try:
+ user_query = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config')
+ user_details = execute_admin_query(request, user_query)
+
+ # getting the user_id from the session
+ for user_detail in user_details:
+ user_id = user_detail['user_id']
+ user_email = user_detail['email']
+
+ account_query = Query().get('local:account').filter_by('user_id', '==', user_id).select('user_id','platform_id','auth_type','config')
+ account_details = execute_admin_query(request, account_query)
+
+ platform_query = Query().get('local:platform').select('platform_id','platform')
+ platform_details = execute_admin_query(request, platform_query)
+
+ for account_detail in account_details:
+ for platform_detail in platform_details:
+ if platform_detail['platform_id'] == account_detail['platform_id']:
+ if 'myslice' in platform_detail['platform']:
+ account_config = json.loads(account_detail['config'])
+ user_cred = account_config.get('delegated_user_credential','N/A')
+ if 'N/A' not in user_cred:
+ user_hrn = account_config.get('user_hrn','N/A')
+ user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
+ user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
+ updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
+ user_params = { 'config': updated_config}
+ manifold_update_account(request, user_id,user_params)
+ return user_email
+ else:
+ return None
+
+ except Exception,e:
+ print "Exception in actions.py in clear_user_creds %s" % e
+ return None
+
def is_pi(wsgi_request, user_hrn, authority_hrn):
# XXX could be done in a single query !
def get (self, request, state=None):
env = self.default_env()
+ acc_auth_cred={}
if request.user.is_authenticated():
## check user is pi or not
platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
# XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page
platform_details = execute_query(self.request, platform_query)
account_details = execute_query(self.request, account_query)
- if platform_details:
- for platform_detail in platform_details:
- for account_detail in account_details:
+ for platform_detail in platform_details:
+ for account_detail in account_details:
+ if 'platform_id' in platform_detail:
if platform_detail['platform_id'] == account_detail['platform_id']:
if 'config' in account_detail and account_detail['config'] is not '':
account_config = json.loads(account_detail['config'])
errors.append('First Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
if (re.search(r'^[\w+\s.@+-]+$', reg_lname) == None):
errors.append('Last Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
+ if (re.search(r'^[A-Za-z0-9_ ]*$', reg_site_name) == None):
+ errors.append('Name of organization may contain only letters, numbers, and underscore.')
+ if (re.search(r'^[A-Za-z ]*$', reg_address_city) == None):
+ errors.append('City may contain only letters.')
+ if (re.search(r'^[A-Za-z ]*$', reg_address_country) == None):
+ errors.append('Country may contain only letters.')
+ if (re.search(r'^[A-Za-z0-9]*$', reg_site_abbreviated_name) == None):
+ errors.append('Shortname may contain only letters and numbers')
+ if (re.search(r'^[0-9]*$', reg_phone) == None):
+ errors.append('Phone number may contain only numbers.')
#if (re.search(r'^\w+$', reg_site_authority) == None):
# errors.append('Site Authority may contain only letters or numbers.')
# checking in django_db !!
return HttpResponseRedirect(redirect_url)
else:
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
- return HttpResponseRedirect("/portal/account/")
+ return HttpResponseRedirect(redirect_url)
elif 'dl_pubkey' in request.POST:
for account_detail in account_details:
else:
messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
- return HttpResponseRedirect("/portal/account/")
+ return HttpResponseRedirect(redirect_url)
# elif 'delete' in request.POST:
# for account_detail in account_details:
user_params = { 'config': updated_config}
manifold_update_account(request, user_id,user_params)
messages.success(request, 'All Credentials cleared')
- return HttpResponseRedirect("/portal/account/")
+ return HttpResponseRedirect(redirect_url)
else:
messages.error(request, 'Delete error: Credentials are not stored in the server')
return HttpResponseRedirect(redirect_url)
from manifold.core.query import Query
from manifoldapi.manifoldapi import execute_admin_query, execute_query
-from portal.actions import is_pi, create_slice, create_pending_slice
+from portal.actions import is_pi, create_slice, create_pending_slice, clear_user_creds
#from portal.forms import SliceRequestForm
from unfold.loginrequired import LoginRequiredAutoLogoutView
from ui.topmenu import topmenu_items_live, the_user
if is_pi(wsgi_request, user_hrn, authority_hrn):
# PIs can directly create slices in their own authority...
create_slice(wsgi_request, slice_request)
+ clear_user_creds(wsgi_request, user_email)
self.template_name = 'slice-request-done-view.html'
else:
# Otherwise a wsgi_request is sent to the PI
{% endblock %}
{% endblock container %}
<div class="loading">
- <div class="row">
- <div class="col-xs-11">Loading...</div>
- <div class="col-xs-1"><img src="{{ STATIC_URL }}/img/loading.gif" /></div>
- </div>
- <div class="row">
- <div class="col-xs-12 message"></div>
- </div>
+ <div><img src="{{ STATIC_URL }}/img/loading.gif" /> Loading...</div>
+ <div> </div>
+ <div class="message"></div>
</div>
</body>
</html>
<!-- XXX TODO: for the moment only PIs have access to Update but users that have slice credentials should also have access to that -->
- {% if 'is_pi' in pi %}
<button id="addusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Update users</button>
- {%endif%}
</div>
--- /dev/null
+from django.http import HttpResponse
+from portal.actions import clear_user_creds
+import json
+
+def dispatch(request, action):
+
+ if (action == 'clear') :
+ res=[]
+ emails = request.POST.getlist('emails[]')
+ if emails :
+ for email in emails :
+ try :
+ res.append(clear_user_creds(request, email))
+ except :
+ pass
+
+ if not res :
+ ret = { "ret" : 1, "emails" : res }
+ else :
+ ret = { "ret" : 0 }
+
+ return HttpResponse(json.dumps(ret), content_type="application/json")