-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show badge progress in badge progress dashboard
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{% extends 'base.html' %} | ||
{%load static %} | ||
{% block css %} | ||
<link href="{% static 'jquery-pagination/pagination.css' %}" rel="stylesheet" type="text/css"> | ||
{% endblock %} | ||
|
||
{% block breadcrumb %} | ||
{% if user.is_authenticated %} | ||
<li class="breadcrumb-item active">{{user.username}}'s Dashboard</li> | ||
<li class="breadcrumb-item active"> | ||
<a href="{% url 'user_insight_dashboard'%}">Badges</a> | ||
</li> | ||
{% endif %} | ||
|
||
|
||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<h1>Badge Progress</h1> | ||
</div> | ||
</div> | ||
|
||
<div class="badge-container"> | ||
|
||
</div> | ||
</div> | ||
|
||
{% endblock %} | ||
|
||
{% block javascript %} | ||
<script src="{% static 'jquery-pagination/pagination.js' %}"></script> | ||
<script> | ||
$.ajax({ | ||
url: '/api/reputation/badges', | ||
type: 'GET', | ||
success: function(communities) { | ||
var badgeContainer = $('.badge-container'); | ||
|
||
for (var i = 0; i < communities.length; i++) { | ||
var rowDiv = $('<div>', { | ||
'class': 'row' | ||
}); | ||
var community = communities[i].community; | ||
rowDiv.append('<h2 style="margin: 5px">' + community.name + '</h2>'); | ||
|
||
var badges = communities[i].badges; | ||
var badgeLevelMapping = { | ||
'1': 'btn-secondary', | ||
'2': 'btn-danger', | ||
'3': 'btn-warning', | ||
'4': 'btn-primary', | ||
'5': 'btn-success' | ||
}; | ||
|
||
for (var j = 0; j < badges.length; j++) { | ||
var badge = badges[j]; | ||
|
||
var colDiv = $('<div>', { | ||
'class': 'col-md-2 text-center', | ||
'css': { | ||
'border': '1px solid grey', | ||
'margin': '5px', | ||
'border-radius': '5px', | ||
'padding': '5px' | ||
} | ||
}); | ||
|
||
colDiv.append(` | ||
<div class="card" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title"> | ||
<span class="btn ${badgeLevelMapping[badge.level]}">${badge.title}</button> | ||
</h5> | ||
<span>Progress: ${Math.round(badge.progress)}%</span> | ||
</div> | ||
</div> | ||
`); | ||
|
||
rowDiv.append(colDiv); | ||
} | ||
|
||
|
||
|
||
|
||
badgeContainer.append(rowDiv); | ||
} | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters