this.in_set_backlog = [];
// we keep a couple of global hashes
- // lat_lon --> { marker, <ul> }
- // id --> { <li>, <input> }
- this.by_lat_lon = {};
- this.by_id = {};
+ // lat_lon --> { marker, <ul> }
+ // id --> { <li>, <input> }
+ this.by_lat_lon = {};
+ this.by_id = {};
/* XXX Events */
this.elmt().on('show', this, this.on_show);
var query = manifold.query_store.find_analyzed_query(this.options.query_uuid);
this.object = query.object;
- var keys = manifold.metadata.get_key(this.object);
+ // var keys = manifold.metadata.get_key(this.object);
//
- this.key = (keys && keys.length == 1) ? keys[0] : null;
+ // this.key = (keys && keys.length == 1) ? keys[0] : null;
// xxx temporary hack
// as of nov. 28 2013 we have here this.key='urn', but in any place where
// so for now we force using hrn instead
// as soon as record have their primary key set this line can be removed
// see also same hack in querytable
- this.key= (this.key == 'urn') ? 'hrn' : this.key;
+ //this.key= (this.key == 'urn') ? 'hrn' : this.key;
+ this.key = (this.options.id_key);
+ if (typeof(this.key)=='undefined' || (this.key).startsWith("unknown")) {
+ // if not specified by caller, decide from metadata
+ var keys = manifold.metadata.get_key(this.object);
+ this.key = (keys && keys.length == 1) ? keys[0] : null;
+ }
//// Setup query and record handlers
// this query is the one about the slice itself
var checkbox = $("<input>", {type:'checkbox', checked:checked, class:'geo'});
var id=this.record_id(record);
// use hrn as far as possible for displaying
- var label= ('hrn' in record) ? record.hrn : id;
+ // var label= ('hrn' in record) ? record.hrn : id;
+ var label= (this.key in record) ? record[this.key] : id;
ul.append($("<li>").addClass("geo").append(checkbox).
append($("<span>").addClass("geo").append(label)));
var googlemap=this;
},
warning: function (record,message) {
- try {messages.warning (message+" -- hostname="+record.hostname); }
+ try {messages.warning (message+" -- "+this.key+"="+record[this.key]); }
catch (err) {messages.warning (message); }
},
// retrieve DOM checkbox and make sure it is checked/unchecked
- set_checkbox: function(record, checked) {
+ set_checkbox: function(record, checked) {
var id=this.record_id (record);
if (! id) {
this.warning (record, "googlemap.set_checkbox: record has no id");
return;
}
checkbox.prop('checked',checked);
- }, // set_checkbox
+ }, // set_checkbox
// this record is *in* the slice
new_record: function(record) {
// $(window).unbind('QueryTable');
var query = manifold.query_store.find_analyzed_query(this.options.query_uuid);
- this.method = query.object;
+ this.object = query.object;
// xxx beware that this.key needs to contain a key that all records will have
// in general query_all will return well populated records, but query
// returns records with only the fields displayed on startup.
this.key = (this.options.id_key);
- if (! this.key) {
- // if not specified by caller, decide from metadata
- var keys = manifold.metadata.get_key(this.method);
- this.key = (keys && keys.length == 1) ? keys[0] : null;
+ if (typeof(this.key)=='undefined' || (this.key).startsWith("unknown")) {
+ // if not specified by caller, decide from metadata
+ var keys = manifold.metadata.get_key(this.object);
+ this.key = (keys && keys.length == 1) ? keys[0] : null;
}
if (! this.key) messages.warning("querytable.init could not kind valid key");
-
messages.debug("querytable: key="+this.key);
/* Setup query and record handlers */
}
- if (id === undefined) {
- messages.warning("querytable.set_checkbox record has no id to figure which line to tick");
- return;
- }
+ if (id === undefined) {
+ messages.warning("querytable.set_checkbox record has no id to figure which line to tick");
+ return;
+ }
+ // PB TO CHECK THE RIGHT CHECKBOXES IS HERE... flat_id using \ in the key
+ // need to use escape_id when creating the id of the checkboxes
var checkbox_id = this.flat_id(this.id('checkbox', id));
// function escape_id(myid) is defined in portal/static/js/common.functions.js
checkbox_id = escape_id(checkbox_id);
+ // As we are using [id="x"] syntax, we need to remove the # in the checkbox_id
+ checkbox_id = checkbox_id.replace("#","");
// using dataTables's $ to search also in nodes that are not currently displayed
- var element = this.table.$(checkbox_id);
+ var element = this.table.$('[id="' + checkbox_id + '"]');
if (debug)
messages.debug("set_checkbox checked=" + checked
+ " id=" + checkbox_id + " matches=" + element.length);
var self = e.data;
// XXX this.value = key of object to be added... what about multiple keys ?
- if (debug) messages.debug("querytable click handler checked=" + this.checked + " hrn=" + this.value);
+ if (debug) messages.debug("querytable click handler checked=" + this.checked + " "+this.key+"=" + this.value);
manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, this.value);
//return false; // prevent checkbox to be checked, waiting response from manifold plugin api
def get_or_post (self, request, method):
errors = []
- #authorities_query = Query.get('authority').\
- # select('name', 'authority_hrn')
+ # Using cache manifold-tables to get the list of authorities faster
+ authorities_query = Query.get('authority').select('name', 'authority_hrn')
#onelab_enabled_query = Query.get('local:platform').filter_by('platform', '==', 'ple').filter_by('disabled', '==', 'False')
#onelab_enabled = not not execute_admin_query(request, onelab_enabled_query)
#if onelab_enabled:
if True:
print "ONELAB ENABLED"
- authorities_query = Query.get('ple:authority').select('name', 'authority_hrn').filter_by('authority_hrn', 'included', ['ple.inria', 'ple.upmc', 'ple.ibbtple', 'ple.nitos'])
+ #authorities_query = Query.get('ple:authority').select('name', 'authority_hrn').filter_by('authority_hrn', 'included', ['ple.inria', 'ple.upmc', 'ple.ibbtple', 'ple.nitos'])
+ # Now using Cache
else:
print "FIREXP ENABLED"
class SliceRequestView (LoginRequiredAutoLogoutView):
def authority_hrn_initial (self, request):
- #authorities_query = Query.get('authority').\
- # select('name', 'authority_hrn')
+ # Using cache manifold-tables to get the list of authorities
+ authorities_query = Query.get('authority').\
+ select('name', 'authority_hrn')
#onelab_enabled_query = Query.get('local:platform').filter_by('platform', '==', 'ple-onelab').filter_by('disabled', '==', 'False')
#onelab_enabled = not not execute_admin_query(request, onelab_enabled_query)
#if onelab_enabled:
- authorities_query = Query.get('ple:authority').select('name', 'authority_hrn').filter_by('authority_hrn', 'included', ['ple.inria', 'ple.upmc', 'ple.ibbtple','ple.nitos'])
+ #authorities_query = Query.get('ple:authority').select('name', 'authority_hrn').filter_by('authority_hrn', 'included', ['ple.inria', 'ple.upmc', 'ple.ibbtple','ple.nitos'])
+ # Now using Cache
authorities = execute_admin_query(request, authorities_query)
authorities = sorted(authorities)
main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename)
main_query.select(
'slice_hrn',
- 'resource.hrn', 'resource.hostname', 'resource.type',
+ 'resource.hrn', 'resource.urn', 'resource.hostname', 'resource.type',
'resource.network_hrn',
'lease.urn',
'user.user_hrn',
)
# for internal use in the querytable plugin;
# needs to be a unique column present for each returned record
- main_query_key = 'hrn'
+ #main_query_key = 'hrn'
query_resource_all = Query.get('resource').select(resource_fields)
if do_query_users:
query = sq_resource,
query_all = query_resource_all,
# safer to use 'hrn' as the internal unique key for this plugin
- id_key = main_query_key,
+ #id_key = main_query_key,
checkboxes = True,
datatables_options = {
'iDisplayLength': 25,
return key;
}
+// Adding startsWith & endsWith to the string prototype
+if ( typeof String.prototype.startsWith != 'function' ) {
+ String.prototype.startsWith = function( str ) {
+ return this.substring( 0, str.length ) === str;
+ }
+};
+
+if ( typeof String.prototype.endsWith != 'function' ) {
+ String.prototype.endsWith = function( str ) {
+ return this.substring( this.length - str.length, this.length ) === str;
+ }
+};
+// http://stackoverflow.com/questions/646628/javascript-startswith
+
function arrays_equal(a,b) { return !(a<b || b<a); }
function arrayInArray(elt,tab){