gadjo: add progressive rendering of publik menu (#7996)
This commit is contained in:
parent
2b77f08c17
commit
de36956369
|
@ -1,5 +1,12 @@
|
|||
$(function() {
|
||||
$(document).on('publik:environment-loaded', function(event, services) {
|
||||
/* empty all apps cells */
|
||||
var service_ids = Array('authentic', 'wcs', 'combo', 'passerelle', 'hobo');
|
||||
$(service_ids).each(function(index, service_id) {
|
||||
$('#portal-agent-content div.services-' + service_id + ' ul.apps').empty();
|
||||
});
|
||||
$('#portal-agent-content div.services ul.apps').empty();
|
||||
/* and fill them with current services */
|
||||
$(services.services).each(function(index, element) {
|
||||
var $content = $('#portal-agent-content div.services-' + element.service_id);
|
||||
if ($content.length === 0) {
|
||||
|
|
|
@ -3,21 +3,12 @@ GADJO_DEFAULT_SIDEPAGE_STATUS = 'expanded';
|
|||
$(function() {
|
||||
var all_done = false;
|
||||
|
||||
function check_all_done() {
|
||||
var local_done = true;
|
||||
$(COMBO_KNOWN_SERVICES).each(function(index, service) {
|
||||
if (service.data === undefined) {
|
||||
local_done = false;
|
||||
}
|
||||
});
|
||||
all_done = local_done;
|
||||
if (all_done) {
|
||||
function update_publik_menu() {
|
||||
window.sessionStorage.hobo_environment = JSON.stringify(COMBO_KNOWN_SERVICES);
|
||||
window.sessionStorage.hobo_environment_timestamp = Date.now();
|
||||
create_menu_items();
|
||||
$(document).trigger('publik:environment-loaded', {services: COMBO_KNOWN_SERVICES});
|
||||
}
|
||||
}
|
||||
|
||||
function create_menu_items() {
|
||||
$('#sidepage-menu').remove();
|
||||
|
@ -71,7 +62,7 @@ $(function() {
|
|||
$(COMBO_KNOWN_SERVICES).each(function(index, element) {
|
||||
if (element.backoffice_menu_url === null) {
|
||||
element.data = Array();
|
||||
check_all_done();
|
||||
update_publik_menu();
|
||||
return;
|
||||
}
|
||||
if (element.service_id === 'wcs' && element.uniq === false) {
|
||||
|
@ -82,7 +73,7 @@ $(function() {
|
|||
if (that_hostname != this_hostname) {
|
||||
look_for_wcs = true;
|
||||
element.data = Array();
|
||||
check_all_done();
|
||||
update_publik_menu();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -96,8 +87,8 @@ $(function() {
|
|||
async: true,
|
||||
dataType: 'jsonp',
|
||||
crossDomain: true,
|
||||
success: function(data) { element.data = data; check_all_done(); },
|
||||
error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); }
|
||||
success: function(data) { element.data = data; update_publik_menu(); },
|
||||
error: function(error) { console.log('bouh', error); element.data = Array(); update_publik_menu(); }
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -129,8 +120,8 @@ $(function() {
|
|||
async: true,
|
||||
dataType: 'jsonp',
|
||||
crossDomain: true,
|
||||
success: function(data) { element.data = data; check_all_done(); },
|
||||
error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); }
|
||||
success: function(data) { element.data = data; update_publik_menu(); },
|
||||
error: function(error) { console.log('bouh', error); element.data = Array(); update_publik_menu(); }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue