Skip to content

Commit

Permalink
Enhancement: Bug Details Page; Revision 8 (#2355)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithBishal authored Jun 19, 2024
1 parent 61fbbc0 commit 39a41b5
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 265 deletions.
9 changes: 6 additions & 3 deletions blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
UserIssueViewSet,
UserProfileViewSet,
)
from website.views import ( # TODO IssueView,; TODO: REMOVE like_issue2 etc
from website.views import ( # TODO(b) IssueView,; TODO(b): REMOVE like_issue2 etc
AllIssuesView,
CompanySettings,
ContributorStatsView,
Expand Down Expand Up @@ -86,6 +86,7 @@
google_callback,
like_issue2,
like_issue3,
resolve,
select_bid,
submit_pr,
subscribe_to_domains,
Expand Down Expand Up @@ -278,7 +279,7 @@
name="user_profile",
),
path(settings.ADMIN_URL + "/", admin.site.urls),
# TODO: REMOVE after _3 is ready
# TODO(b): REMOVE after _3 is ready
re_path(r"^like_issue/(?P<issue_pk>\d+)/$", website.views.like_issue, name="like_issue"),
re_path(
r"^dislike_issue/(?P<issue_pk>\d+)/$",
Expand All @@ -292,6 +293,8 @@
re_path(r"^like_issue3/(?P<issue_pk>\d+)/$", like_issue3, name="like_issue3"),
re_path(r"^dislike_issue3/(?P<issue_pk>\d+)/$", dislike_issue3, name="dislike_issue3"),
re_path(r"^flag_issue3/(?P<issue_pk>\d+)/$", flag_issue3, name="flag_issue3"),
# TODO(b) track this
re_path(r"^resolve/(?P<id>\w+)/$", resolve, name="resolve"),
re_path(r"^vote_count/(?P<issue_pk>\d+)/$", vote_count, name="vote_count"),
path("domain/<int:pk>/subscribe/", subscribe_to_domains, name="subscribe_to_domains"),
re_path(r"^save_issue/(?P<issue_pk>\d+)/$", website.views.save_issue, name="save_issue"),
Expand Down Expand Up @@ -319,7 +322,7 @@
),
# delete_comment
path("issue2/comment/delete/", website.views.delete_comment, name="delete_comment"),
# TODO: REMOVE after _3 is ready
# TODO(b): REMOVE after _3 is ready
re_path(r"^issue/(?P<slug>\w+)/$", IssueView.as_view(), name="issue_view"),
re_path(r"^issue2/(?P<slug>\w+)/$", IssueView2.as_view(), name="issue_view2"),
re_path(r"^issue3/(?P<slug>\w+)/$", IssueView3.as_view(), name="issue_view3"),
Expand Down
69 changes: 31 additions & 38 deletions website/templates/comments2.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
<footer class="flex justify-between items-center mb-2">
<div class="grid grid-cols-9 items-center justify-between">
<p class="sm:col-start-1 sm:col-span-4 col-span-5 sm:order-1 items-center inline-flex sm:text-3xl text-2xl text-gray-900 ">
{% if comment.author_fk %}
{% if comment.author_fk.user_avatar %}
<img class="sm:mr-2 mr-1 sm:w-12 w-10 sm:h-12 h-10 rounded-full"
src="{{ MEDIA_URL }}{{ comment.author_fk.user_avatar }}"
alt="{{ comment.author }} profile"
Expand Down Expand Up @@ -117,7 +117,7 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
<div class="flex items-center">
<p class="inline-flex items-center mr-3 text-md text-gray-900 ">
<img class="mr-2 w-9 h-9 rounded-full"
src="{{ MEDIA_URL }}{{ user.userprofile.user_avatar }}"
{% if user.userprofile.user_avatar %} src="{{ MEDIA_URL }}{{ user.userprofile.user_avatar }}" {% else %} src="{% static 'images/dummy-user.png' %}" {% endif %}
alt="Michael Gough"
width="36px"
height="36px">
Expand Down Expand Up @@ -176,6 +176,23 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
{% endfor %}
</div>
<script>
function initDropDown(){
document.querySelectorAll("[data-dropdown-toggle]").forEach((toggle) => {

toggle.addEventListener("click", () => {
const { dropdownToggle } = toggle.dataset;
const dropdown = document.getElementById(dropdownToggle);
dropdown.classList.toggle("hidden");
dropdown.classList.toggle("block");
dropdown.style.position = "absolute";
dropdown.style.top = toggle.offsetTop + toggle.offsetHeight + "px";
dropdown.style.left = toggle.offsetLeft - 50 + "px";

});
});
}


function remove_reply(){
document.getElementById("replying_to_cont").remove();
document.getElementById("replying_to_input").value = "";
Expand Down Expand Up @@ -226,18 +243,8 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
},
success: function (data) {
$('#comment_root').replaceWith(data);
document.querySelectorAll("[data-dropdown-toggle]").forEach((toggle) => {
toggle.addEventListener("click", () => {
const { dropdownToggle } = toggle.dataset;
const dropdown = document.getElementById(dropdownToggle);
dropdown.classList.toggle("hidden");
dropdown.classList.toggle("block");
dropdown.style.position = "absolute";
dropdown.style.top = toggle.offsetTop + toggle.offsetHeight + "px";
dropdown.style.left = toggle.offsetLeft - 50 + "px";

});
});
// initDropDown();
location.reload()
},
});
}
Expand All @@ -262,18 +269,8 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
},
success: function (data) {
$('#comment_root').replaceWith(data);
document.querySelectorAll("[data-dropdown-toggle]").forEach((toggle) => {
toggle.addEventListener("click", () => {
const { dropdownToggle } = toggle.dataset;
const dropdown = document.getElementById(dropdownToggle);
dropdown.classList.toggle("hidden");
dropdown.classList.toggle("block");
dropdown.style.position = "absolute";
dropdown.style.top = toggle.offsetTop + toggle.offsetHeight + "px";
dropdown.style.left = toggle.offsetLeft - 50 + "px";

});
});
// initDropDown();
location.reload()
},
});
}
Expand Down Expand Up @@ -326,18 +323,8 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
// Replace the content of #comment_root with the new data
$('#comment_root').replaceWith(data);

document.querySelectorAll("[data-dropdown-toggle]").forEach((toggle) => {
toggle.addEventListener("click", () => {
const { dropdownToggle } = toggle.dataset;
const dropdown = document.getElementById(dropdownToggle);
dropdown.classList.toggle("hidden");
dropdown.classList.toggle("block");
dropdown.style.position = "absolute";
dropdown.style.top = toggle.offsetTop + toggle.offsetHeight + "px";
dropdown.style.left = toggle.offsetLeft - 50 + "px";

});
});
// initDropDown();
location.reload()
},
});
}
Expand All @@ -358,6 +345,12 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen

// setInterval(get_comments, 10000);

$(document).ready(function(){
// bind event handlers when the page loads.
initDropDown();
});



</script>
</section>
19 changes: 17 additions & 2 deletions website/templates/includes/_like_dislike_share.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44">
<ul class="py-2 m-2 rounded text-gray-700"
aria-labelledby="dropdownDefaultButton">
<span class="md:hidden flex flex-col">{% include "./_like_dislike_widget.html" %}</span>
<span class="md:hidden flex flex-col">{% include "./_like_dislike_widget.html" with device="mobile" %}</span>
<li>
<a href="https://twitter.com/intent/tweet?text=Bug Found on @{{ object.domain_title }} - {{ object.description }} Report: https://{% env 'FQDN' %}/issue/{{ object.id }}"
target="_blank"
Expand All @@ -39,7 +39,7 @@
{% endif %}
</ul>
</div>
<span class="max-sm:hidden">{% include "./_like_dislike_widget.html" %}</span>
<span class="max-sm:hidden">{% include "./_like_dislike_widget.html" with device="desktop" %}</span>
<script>
function copyClipboard() {
var textToCopy = "Bug Found on @{{ object.domain_title }} - {{ object.description }} Report: https://{% env 'FQDN' %}/issue/{{ object.id }}";
Expand Down Expand Up @@ -161,4 +161,19 @@

// Attach the click event handler
$('body').on('click', '.bookmark', bookmark_handler);
async function resolveIssue(){
var id = {{object.pk}};

const request = await fetch(`/resolve/${id}/`)
window.location.reload();
if(request.status == 200){
const jsonData = await request.json();
console.log(jsonData["issue_status"])
}else if (request.status == 403){
$.notify("Permission Denied", {
style: "custom",
className: "danger"
});
}
}
</script>
Loading

0 comments on commit 39a41b5

Please sign in to comment.