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