2020-08-12 00:36:09 +00:00
|
|
|
<ul class="navbar-nav ml-auto">
|
2023-09-24 14:28:23 +00:00
|
|
|
<li class="nav-item dropdown notif-li">
|
|
|
|
<a class="nav-link count-indicator dropdown-toggle" id="notifDropdown" href="#" aria-expanded="false">
|
2023-01-25 22:26:04 +00:00
|
|
|
<i class="fas fa-broadcast-tower
|
2020-09-23 01:42:41 +00:00
|
|
|
{% if data.get('update_available') %}
|
|
|
|
text-danger
|
|
|
|
{% end %}
|
2023-09-01 18:48:20 +00:00
|
|
|
"></i><span id="notif-count" class="badge badge-notify"></span> </a>
|
2023-09-05 00:42:50 +00:00
|
|
|
<div class="dropdown-menu dropdown-menu-right navbar-dropdown notif-div" style="width: 40vw; max-height: 80vh;" aria-labelledby="notifDropdown">
|
2023-09-02 00:38:10 +00:00
|
|
|
<ul style="padding-top: 10px;" id="announcements">
|
2023-09-01 18:48:20 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
2023-01-25 22:26:04 +00:00
|
|
|
</li>
|
2020-12-06 20:42:49 +00:00
|
|
|
|
2023-01-25 22:26:04 +00:00
|
|
|
<li class="nav-item dropdown">
|
2023-09-01 18:48:20 +00:00
|
|
|
<a class="nav-link" href="/panel/panel_config">
|
2023-01-25 22:26:04 +00:00
|
|
|
<i class="fas fa-cogs"></i>
|
|
|
|
</a>
|
|
|
|
</li>
|
2020-12-06 20:42:49 +00:00
|
|
|
|
2023-01-25 22:26:04 +00:00
|
|
|
<li class="nav-item dropdown user-dropdown">
|
|
|
|
<a class="nav-link dropdown-toggle" id="UserDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
|
2023-09-24 14:28:23 +00:00
|
|
|
<img class="img-xs rounded-circle profile-picture" onerror="pfpError(this)" src="{{ data['user_data']['pfp'] }}" alt="Profile image"> </a>
|
2023-01-25 22:26:04 +00:00
|
|
|
<div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="UserDropdown">
|
|
|
|
<div class="dropdown-header text-center">
|
2023-09-24 14:28:23 +00:00
|
|
|
<img class="img-md rounded-circle profile-picture" onerror="pfpError(this)" src="{{ data['user_data']['pfp'] }}" alt="Profile image">
|
2023-01-25 22:26:04 +00:00
|
|
|
<p class="mb-1 mt-3 font-weight-semibold">{{ data['user_data']['username'] }}</p>
|
|
|
|
<p class="font-weight-light text-muted mb-0">Roles: </p>
|
|
|
|
{% for r in data['user_role'] %}
|
|
|
|
<p class="font-weight-light text-muted mb-0">{{ r }}</p>
|
2022-03-13 12:29:26 +00:00
|
|
|
{% end %}
|
2023-01-25 22:26:04 +00:00
|
|
|
{% if data.get('api_key') %}
|
|
|
|
<p class="mt-3">Logged in as API key "{{ data['api_key']['name'] }}"</p>
|
2021-09-14 02:02:57 +00:00
|
|
|
{% end %}
|
2023-01-25 22:26:04 +00:00
|
|
|
<p class="font-weight-light text-muted mb-0">Email: {{ data['user_data']['email'] }}</p>
|
2020-08-12 00:36:09 +00:00
|
|
|
</div>
|
2023-01-25 22:26:04 +00:00
|
|
|
{% if data['user_data']['preparing'] %}
|
2023-09-24 14:28:23 +00:00
|
|
|
<span class="dropdown-item" id="support_progress"><i class="dropdown-item-icon mdi mdi-download-outline text-primary"></i>{{ translate('notify', 'supportLogs',
|
2023-09-01 18:48:20 +00:00
|
|
|
data['lang']) }}<br><br></span>
|
2023-01-25 22:26:04 +00:00
|
|
|
<span class="dropdown-item" id="support_progress">
|
|
|
|
<div class="support_progress" style="height: 15px; width: 100%;">
|
2023-09-24 14:28:23 +00:00
|
|
|
<div class="progress-bar progress-bar-striped progress-bar-animated" id="logs_progress_bar" role="progressbar" style="width:0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
|
2023-01-25 22:26:04 +00:00
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
{% else %}
|
2023-09-24 14:28:23 +00:00
|
|
|
<a class="dropdown-item" id="support_logs"><i class="dropdown-item-icon mdi mdi-download-outline text-primary"></i>{{ translate('notify', 'supportLogs',
|
2023-09-01 18:48:20 +00:00
|
|
|
data['lang']) }}</i></a>
|
2023-01-25 22:26:04 +00:00
|
|
|
{% end %}
|
|
|
|
{% if data['superuser'] %}
|
2023-09-24 14:28:23 +00:00
|
|
|
<a class="dropdown-item" href="/panel/activity_logs"><i class="dropdown-item-icon mdi mdi-calendar-check-outline text-primary"></i>{{ translate('notify',
|
2023-09-01 18:48:20 +00:00
|
|
|
'activityLog', data['lang']) }}</a>
|
2023-01-25 22:26:04 +00:00
|
|
|
{% end %}
|
2023-09-01 18:48:20 +00:00
|
|
|
<a class="dropdown-item" href="/logout"><i class="dropdown-item-icon mdi mdi-power text-primary"></i>{{
|
|
|
|
translate('notify', 'logout', data['lang']) }}</a>
|
2023-01-25 22:26:04 +00:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2023-09-01 18:48:20 +00:00
|
|
|
<style>
|
|
|
|
.badge-notify {
|
|
|
|
background: var(--purple);
|
2023-09-05 03:20:49 +00:00
|
|
|
color: var(--dark);
|
2023-09-01 18:48:20 +00:00
|
|
|
position: absolute;
|
|
|
|
-moz-transform: translate(-70%, -70%);
|
|
|
|
/* For Firefox */
|
|
|
|
-ms-transform: translate(-70%, -70%);
|
|
|
|
/* for IE */
|
|
|
|
-webkit-transform: translate(-70%, -70%);
|
|
|
|
/* For Safari, Chrome, iOS */
|
|
|
|
-o-transform: translate(-70%, -70%);
|
|
|
|
}
|
2022-09-12 19:34:47 +00:00
|
|
|
|
2023-09-01 18:48:20 +00:00
|
|
|
.clear-button:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2023-09-05 00:42:50 +00:00
|
|
|
|
2023-09-24 14:28:23 +00:00
|
|
|
/* Hide scrollbar for Chrome, Safari and Opera */
|
|
|
|
.notif-div::-webkit-scrollbar {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hide scrollbar for IE, Edge and Firefox */
|
|
|
|
.notif-div {
|
|
|
|
-ms-overflow-style: none;
|
|
|
|
/* IE and Edge */
|
|
|
|
scrollbar-width: none;
|
|
|
|
/* Firefox */
|
|
|
|
}
|
2023-09-01 18:48:20 +00:00
|
|
|
</style>
|
2023-01-25 22:26:04 +00:00
|
|
|
<script>
|
|
|
|
function pfpError(image) {
|
2022-09-12 19:34:47 +00:00
|
|
|
image.onerror = "";
|
|
|
|
image.src = "/static/assets/images/faces-clipart/pic-3.png";
|
|
|
|
return true;
|
|
|
|
}
|
2023-09-01 18:48:20 +00:00
|
|
|
function updateAnnouncements(data) {
|
|
|
|
console.log(data)
|
|
|
|
let text = "";
|
2023-09-05 01:14:03 +00:00
|
|
|
for (let value of data) {
|
|
|
|
text += `<li class="card-header header-sm justify-content-between align-items-center" id="${value.id}"><p style="float: right;"><i data-id="${value.id}"class="clear-button fa-regular fa-x"></i></p><a style="color: var(--purple);" href=${value.link} target="_blank"><h6>${value.title}</h6><small><p>${value.date}</p></small><p>${value.desc}</p></li></a>`
|
2023-09-01 18:48:20 +00:00
|
|
|
}
|
|
|
|
if (data.length > 0) {
|
|
|
|
localStorage.setItem("notif-count", data.length);
|
2023-09-24 14:28:23 +00:00
|
|
|
$("#notif-count").show()
|
2023-09-01 18:48:20 +00:00
|
|
|
$("#notif-count").html(data.length);
|
|
|
|
$("#announcements").html(text);
|
|
|
|
} else {
|
2023-09-02 00:38:10 +00:00
|
|
|
$("#announcements").html(`<p style='margin-top: 15px;' class='text-center'><i class="fa fa-bell-slash" aria-hidden="true"></i>
|
|
|
|
</p>`);
|
2023-09-24 14:28:23 +00:00
|
|
|
$("#notif-count").hide()
|
2023-09-01 18:48:20 +00:00
|
|
|
}
|
|
|
|
$(".clear-button").on("click", function (event) {
|
|
|
|
console.log("CLEAR BUTTON")
|
2023-09-24 14:28:23 +00:00
|
|
|
event.stopPropagation();
|
2023-09-01 18:48:20 +00:00
|
|
|
let uuid = event.target.getAttribute("data-id");
|
|
|
|
$(`#${uuid}`).remove();
|
|
|
|
send_clear(uuid);
|
2023-09-05 00:49:55 +00:00
|
|
|
let notif_count = localStorage.getItem("notif-count") - 1;
|
2023-09-01 18:48:20 +00:00
|
|
|
if (notif_count > 0) {
|
|
|
|
localStorage.setItem("notif-count", notif_count);
|
|
|
|
$("#notif-count").html(notif_count);
|
|
|
|
} else {
|
2023-09-02 00:38:10 +00:00
|
|
|
$("#announcements").html(`<p style='margin-top: 15px;' class='text-center'><i class="fa fa-bell-slash" aria-hidden="true"></i>
|
|
|
|
</p>`)
|
2023-09-01 18:48:20 +00:00
|
|
|
$("#notif-count").html("");
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
async function getAnnouncements() {
|
|
|
|
var token = getCookie("_xsrf");
|
|
|
|
let res = await fetch(`/api/v2/crafty/announcements/`, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'X-XSRFToken': token
|
|
|
|
},
|
|
|
|
});
|
|
|
|
let responseData = await res.json();
|
|
|
|
console.log(responseData);
|
2023-10-20 20:36:57 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
getAnnouncements();
|
|
|
|
}, 1800);
|
2023-10-20 20:38:48 +00:00
|
|
|
console.log("Registered annoucement fetch event in 30 minutes.")
|
2023-09-01 18:48:20 +00:00
|
|
|
if (responseData.status === "ok") {
|
|
|
|
updateAnnouncements(responseData.data)
|
|
|
|
} else {
|
|
|
|
updateAnnouncements("<li><p>Trouble Getting Annoucements</p></li>")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function send_clear(uuid) {
|
|
|
|
var token = getCookie("_xsrf");
|
|
|
|
let body = JSON.stringify({ "id": uuid });
|
|
|
|
console.log(body)
|
|
|
|
let res = await fetch(`/api/v2/crafty/announcements/`, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'X-XSRFToken': token,
|
|
|
|
},
|
|
|
|
body: body,
|
|
|
|
});
|
|
|
|
let responseData = await res.json();
|
|
|
|
console.log(responseData);
|
|
|
|
if (responseData.status === "ok") {
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
bootbox.alert(responseData.error)
|
|
|
|
}
|
|
|
|
}
|
2023-09-24 14:28:23 +00:00
|
|
|
|
|
|
|
/* Open / Close with Button */
|
|
|
|
$('li.dropdown.notif-li a').on('click', function (event) {
|
|
|
|
$(this).parent().toggleClass("show");
|
|
|
|
$('div.notif-div').toggleClass("show");
|
|
|
|
if ($('li.dropdown.notif-li a').attr('aria-expanded') === 'false') {
|
|
|
|
$('li.dropdown.notif-li a').attr('aria-expanded', "true");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('li.dropdown.notif-li a').attr('aria-expanded', "false");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Close when clicking ouside */
|
|
|
|
$('body').on('click', function (e) {
|
|
|
|
if (!$('li.dropdown.notif-li').is(e.target) && $('li.dropdown.notif-li').has(e.target).length === 0 && $('show').has(e.target).length === 0) {
|
|
|
|
$('li.notif-li').removeClass("show");
|
|
|
|
$('li.dropdown.notif-li a').attr('aria-expanded', "false");
|
|
|
|
$('div.notif-div').removeClass("show");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-09-01 18:48:20 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
getAnnouncements();
|
|
|
|
})
|
2023-01-25 22:26:04 +00:00
|
|
|
</script>
|