From: Javier Garcia Date: Thu, 17 Sep 2015 08:33:58 +0000 (+0200) Subject: Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=f53df6493de6aa133220ea102b1ce42a3df87d11;hp=-c Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab --- f53df6493de6aa133220ea102b1ce42a3df87d11 diff --combined manifoldapi/static/js/manifold.js index 7b2d54c1,f8d299a1..5b5e6afb --- a/manifoldapi/static/js/manifold.js +++ b/manifoldapi/static/js/manifold.js @@@ -516,7 -516,7 +516,7 @@@ function QueryStore() this.recount = function(query_uuid) { var query_ext; - var is_reserved, is_pending, in_set, is_unconfigured; + var is_reserved, is_pending, in_set, is_unconfigured, is_unavailable, is_available; query_ext = manifold.query_store.find_analyzed_query_ext(query_uuid); query_ext.num_pending = 0; @@@ -525,6 -525,8 +525,8 @@@ this.iter_records(query_uuid, function(record_key, record) { var record_state = manifold.query_store.get_record_state(query_uuid, record_key, STATE_SET); var record_warnings = manifold.query_store.get_record_state(query_uuid, record_key, STATE_WARNINGS); + is_unavailable = (record.available == 'false'); + is_available = (record.available == 'true'); is_reserved = (record_state == STATE_SET_IN) || (record_state == STATE_SET_OUT_PENDING) @@@ -564,7 -566,7 +566,7 @@@ // Adapted from querytable._querytable_filter() this.iter_records(query_uuid, function(record_key, record) { - var is_reserved, is_pending, in_set, is_unconfigured; + var is_reserved, is_pending, in_set, is_unconfigured, is_unavailable, is_available; /* By default, a record is visible unless a filter says the opposite */ var visible = true; @@@ -572,6 -574,9 +574,9 @@@ var record_state = manifold.query_store.get_record_state(query_uuid, record_key, STATE_SET); var record_warnings = manifold.query_store.get_record_state(query_uuid, record_key, STATE_WARNINGS); + is_unavailable = (record.available == 'false'); + is_available = (record.available == 'true'); + is_reserved = (record_state == STATE_SET_IN) || (record_state == STATE_SET_OUT_PENDING) || (record_state == STATE_SET_IN_SUCCESS) @@@ -610,6 -615,12 +615,12 @@@ // false => ~ break visible = is_reserved; return visible; + case 'available': + visible = is_available; + return visible; + case 'unavailable': + visible = is_unavailable; + return visible; case 'unconfigured': visible = is_unconfigured; return visible; @@@ -1085,7 -1096,7 +1096,7 @@@ var manifold = * \param array results results corresponding to query */ publish_result: function(query, result) { - if (typeof result === 'undefined') + if (result == null || typeof result === 'undefined') result = []; // NEW PLUGIN API @@@ -1116,29 -1127,31 +1127,31 @@@ }, store_records: function(query, records) { - // Store records - var query_ext = manifold.query_store.find_analyzed_query_ext(query.query_uuid); - if (query_ext.set_query_ext) { - // We have a domain query - // The results are stored in the corresponding set_query - manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records); - - } else if (query_ext.domain_query_ext) { - // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key - // Has it a domain query, and has it completed ? - $.each(records, function(i, record) { - var key = manifold.metadata.get_key(query.object); - if ( typeof record === "string" ){ - var record_key = record; - }else{ - var record_key = manifold.record_get_value(record, key); - } - manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_SET, STATE_SET_IN); - }); + if(records != null && records.length != 0){ + // Store records + var query_ext = manifold.query_store.find_analyzed_query_ext(query.query_uuid); + if (query_ext.set_query_ext) { + // We have a domain query + // The results are stored in the corresponding set_query + manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records); + + } else if (query_ext.domain_query_ext) { + // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key + // Has it a domain query, and has it completed ? + $.each(records, function(i, record) { + var key = manifold.metadata.get_key(query.object); + if ( typeof record === "string" ){ + var record_key = record; + }else{ + var record_key = manifold.record_get_value(record, key); + } + manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_SET, STATE_SET_IN); + }); - } else { - // We have a normal query - manifold.query_store.set_records(query.query_uuid, records, STATE_SET_IN); + } else { + // We have a normal query + manifold.query_store.set_records(query.query_uuid, records, STATE_SET_IN); + } } }, @@@ -1690,8 -1703,6 +1703,8 @@@ case TYPE_LIST_OF_VALUES query = query_ext.query; + var testbeds_with_sla = localStorage.getItem("sla_testbeds").split(","); + switch(query.object) { case 'resource': @@@ -1737,9 -1748,9 +1750,9 @@@ } } - /*var urn_regexp = /\+(.*?)\+/; + var urn_regexp = /\+(.*?)\+/; var testbed_urn = urn_regexp.exec(record.urn)[1]; - var has_sla = $.inArray(testbed_urn, localStorage.getItem("sla_testbeds").split(",")) != -1; + var has_sla = $.inArray(testbed_urn, testbeds_with_sla) != -1; if (has_sla) { // var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS); @@@ -1750,7 -1761,7 +1763,7 @@@ } else { delete warnings[CONSTRAINT_SLA]; } - }*/ + } manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_WARNINGS, warnings); // Signal the change to plugins (even if the constraint does not apply, so that the plugin can display a checkmark)