Load tag statistics into grid after the profile finished loading
This commit is contained in:
32
app/assets/javascripts/external_users.js
Normal file
32
app/assets/javascripts/external_users.js
Normal file
@@ -0,0 +1,32 @@
|
||||
$(function() {
|
||||
var grid = $('#tag-grid');
|
||||
|
||||
if ($.isController('external_users') && grid.isPresent()) {
|
||||
var spinner = $('#loading');
|
||||
var noElements = $('#no-elements');
|
||||
|
||||
var buildTagContainer = function(tag) {
|
||||
return '\
|
||||
<div class="tag">\
|
||||
<div class="name">' + tag.key + '</div>\
|
||||
<div class="progress">\
|
||||
<div class="progress-bar" role="progressbar" style="width:' + tag.value + '%">' + tag.value + '%</div>\
|
||||
</div>\
|
||||
</div>';
|
||||
};
|
||||
|
||||
var jqxhr = $.ajax(window.location.href + '/tag_statistics', {
|
||||
dataType: 'json',
|
||||
method: 'GET'
|
||||
});
|
||||
jqxhr.done(function(response) {
|
||||
spinner.hide();
|
||||
if (response.length === 0) {
|
||||
noElements.show();
|
||||
} else {
|
||||
var elements = response.map(buildTagContainer);
|
||||
grid.append(elements);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user