summaryrefslogtreecommitdiff
path: root/js/codeq/profile.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq/profile.js')
-rw-r--r--js/codeq/profile.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/js/codeq/profile.js b/js/codeq/profile.js
index 2759be3..4723b4a 100644
--- a/js/codeq/profile.js
+++ b/js/codeq/profile.js
@@ -73,9 +73,45 @@
codeq.globalStateMachine.register('profile',{
'enter': function(){
-
$("#screen_profile").css('display', '');
$('#disabled').css('display', 'none');
+ codeq.comms.getUserStat()
+ .then(function (data) {
+ if (data.code !== 0) throw new Error('GetUserStat failed, code: ' + data.code + ', message: ' + data.message);
+ console.log(data);
+ var data = data.stat;
+
+ var columns = ['language', 'problem_group', 'problems_count', 'done', 'in_progress'],
+ labels = ['Language', 'Problem group', 'All', 'Done', 'In progress'];
+
+ var items='<thead><tr>';
+ $.each(labels, function( key, val ) {
+ items+='<th>'+val+'</th>';
+ });
+ items+='</tr></thead>';
+ $.each( data, function( object, row ) {
+ items+='<tr>';
+ if(row['problem_group']) {
+ $.each( columns, function( key, val ) {
+ items+='<td style="white-space: nowrap">'+row[val]||""+'</td>';
+ });
+ }
+ else {
+ $.each( columns, function( key, val ) {
+ items+='<td style="white-space: nowrap"><strong>'+(row[val]==null?'(all)':row[val])+'</strong></td>';
+ });
+ }
+ items+='</td>';
+ });
+
+ $('#table1').html(items)
+
+ })
+ .fail(function (reason) {
+ codeq.log.error('GetUserStat failed: ' + reason, reason);
+ alert('GetUserStat failed: ' + reason);
+ })
+ .done();
},
'exit' : function(){
$("#screen_profile").css('display', 'none');