Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying algorithm version effects to trends-web #2

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
257 changes: 135 additions & 122 deletions app/account/templates/account/admin.html

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions app/account/templates/account/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
<div class="container">
<div class="row">
<div class="main" id="main">
{% block messages %}
<div id="messages-panel">
{% if messages %}
{% for message in messages %}
<div class="alert {{ message.tags }} m-2" id="msg" role="alert">
{{ message }}
</div>
{% endfor %}
{% endif %}
</div>
{% endblock %}
{% block content %}

{% endblock %}
Expand All @@ -36,14 +47,17 @@

<script>
$(document).ready(function () {
setTimeout(function () {
if ($('#msg').length > 0) {
$('#msg').remove();
}
}, 2000);
$("#country").on("change", function () {
$.get("/ajax/regions?country_id=" + $(this).val(), function (response, status) {
$("#region").empty();
$("#region").append(response);
});
});


});
</script>
{% endblock %}
Expand Down
9 changes: 6 additions & 3 deletions app/account/templates/account/edit_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ <h3>Login Information</h3>
processData: false,
contentType: false,
success: function (response) {
showMessage(response.msg, 10000);
showMessage(response.msg, 2000);
},
error: function (response) {
showMessage(response.responseJSON.msg, 2000);
}
});
});
$("#btn_upload_profile_photo").on("click", function () {
Expand All @@ -259,10 +262,10 @@ <h3>Login Information</h3>
contentType: false,
success: function (response) {
$("#profile_photo").attr("src", "/media/" + response.image)
showMessage(response.msg, 10000);
showMessage(response.msg, "success");
},
error: function (response) {
showMessage(response.responseJSON.msg, 10000);
showMessage(response.responseJSON.msg, "danger");
},

});
Expand Down
37 changes: 12 additions & 25 deletions app/account/templates/account/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@

<body>
{% block messages %}
<ul class="messages" id="messages-list">
<div id="messages-panel">
{% if messages %}
{% for message in messages %}
<li>
{% if message.tags %}
<div class="alert alert-{{ message.tags }} msg fade show" role="alert">{{ message }}</div>
{% else %}
<div class="alert alert-info msg fade show" role="alert">{{ message }}</div>
{% endif %}
</li>
<div class="alert {{ message.tags }} m-2" id="msg" role="alert">
{{ message }}
</div>
{% endfor %}
{% endif %}
</ul>
</div>
{% endblock %}
{% include 'header.html' %}
<div class="content">
Expand Down Expand Up @@ -89,6 +85,11 @@ <h2>About</h2>

<script>
$(document).ready(function () {
setTimeout(function () {
if ($('#msg').length > 0) {
$('#msg').remove();
}
}, 2000);

$("#country").on("change", function () {
$.get("/ajax/regions?country_id=" + $(this).val(), function (response, status) {
Expand All @@ -110,24 +111,10 @@ <h2>About</h2>
processData: false,
contentType: false,
success: function (response) {
$("#messages-list").removeClass("msg-white");
$("#messages-list").addClass("msg-dark");
const messages = document.getElementById("messages-list");
messages.innerHTML += response.msg;

$("#messages-list").fadeOut(2000, "swing", function () {
messages.innerHTML = "";
$("#messages-list").show();
$("#messages-list").removeClass("msg-black");
$("#messages-list").addClass("msg-white");
window.location = response.url;
});
showMessage(response.msg, "success");
},
error: function (response) {
$("#alert_error").show();
$("#alert_error").empty();
$("#alert_error").html(response.responseText);
$("#alert_error").fadeOut(2000, "swing", function () { });
showMessage(response.responseJSON.msg, "danger");
}
});

Expand Down
51 changes: 22 additions & 29 deletions app/account/templates/account/list_jobs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load static %}
<table id="jobs_tbl" class="table table-bordered" style="width:100%">
<table id="task_tbl" class="table table-bordered" style="width:100%">
<thead>
<tr>
<th>#</th>
Expand All @@ -14,39 +14,31 @@
{% for job in jobs %}
<tr>
<td>{{forloop.counter}}</td>
<td>{{job.params.task_name}}
{% if job.params.task_name %}
<td>{{job.task_name}}
{% if job.task_name %}
-
{% endif %}
{% if job.results.name %}
{{job.results.name}}
{% if job.uid %}
{{job.uid}}
{% endif %}
</td>
<td>{{job.script.name_readable}}</td>
<td>{{job.status.value}}</td>
<td>{{job.start_date}}</td>
<td>
{% if job.status.value == "FINISHED" %}
<button class="btn btn-danger download-job" job-id="{{job.id}}" title="Download"
style="margin-right: 5px; line-height: 2px; min-width: 10px; width: 20px; height: 20px; padding: 2px; border-radius: 5px;">
<i class="fa fa-arrow-circle-down"></i>
<button class="btn btn-outline-success download-job" job-id="{{job.id}}" title="Download"
style="padding: 0px 10px; min-width: 20px; border-radius: 5px;">
<i class="fa fa-arrow-circle-down"></i> Download
</button>
<a class="btn btn-outline-primary view-job" role="button" job-id="{{job.id}}" title="View"
href="/jobs/{{job.id}}/view"
style="margin-right: 5px; line-height: 2px; min-width: 10px; width: 24px; height: 20px; padding: 2px; border-radius: 5px;">
<i class="fa fa-eye"></i>
href="/job/{{job.id}}/view" style="padding: 0px 10px; min-width: 20px; border-radius: 5px;">
<i class="fa fa-eye"></i>View
</a>
{% endif %}

{% if job.status.value == "RUNNING" or job.status.value == "READY" %}
<button class="btn btn-danger cancel-job" role="button" job-id="{{job.id}}" title="Cancel"
style="margin-right: 5px;line-height: 2px; min-width: 10px; width: 20px; height: 20px; padding: 2px; border-radius: 5px;">
<i class="fa fa-ban"></i>
</button>
{% endif %}
<button class="btn btn-outline-danger delete-job" role="button" job-id="{{job.id}}" title="Delete"
style="line-height: 2px; min-width: 10px; width: 20px; height: 20px; padding: 2px; border-radius: 5px;">
<i class="fa fa-remove delete-job"></i>
style="padding: 0px 10px; min-width: 20px; border-radius: 5px;">
<i class="fa fa-trash delete-job"></i> Delete
</button>
</td>
</tr>
Expand All @@ -57,7 +49,8 @@
<script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
<script>
$(document).ready(function () {
$('#jobs_tbl').on('click', 'button.download-job', function (e) {
$("#task_tbl").DataTable();
$('#task_tbl').on('click', 'button.download-job', function (e) {
let uid = $(this).attr("job-id");
$.get({
url: "/ajax/download/" + uid,
Expand All @@ -69,33 +62,33 @@
delete link;
},
error: function (response) {
showMessage(response.responseJSON.msg, 2000);
showMessage(response.responseJSON.msg, "danger");
}
});
});

$('#jobs_tbl').on('click', 'button.cancel-job', function (e) {
$('#task_tbl').on('click', 'button.cancel-job', function (e) {
let uid = $(this).attr("job-id");
$.get({
url: "/ajax/cancel/" + uid,
success: function (response) {
$("#jobs_tbl").empty();
$("#jobs_tbl").append(response);
$("#nav-job").empty();
$("#nav-job").append(response);
},
});
});

$('#jobs_tbl').on('click', 'button.delete-job', function (e) {
$('#task_tbl').on('click', 'button.delete-job', function (e) {
let uid = $(this).attr("job-id");
console.log(uid);
$.get({
url: "/ajax/delete/" + uid,
success: function (response) {
$("#jobs_tbl").empty();
$("#jobs_tbl").append(response);
$("#nav-job").empty();
$("#nav-job").append(response);
},
error: function (response) {
showMessage(response.responseJSON.msg, 2000);
showMessage(response.responseJSON.msg, "danger");
}
});
});
Expand Down
54 changes: 48 additions & 6 deletions app/account/templates/account/list_users.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load static %}
<table class="table table-hover" style="width:100%" id="users_tbl">
<thead>
<tr>
Expand Down Expand Up @@ -30,20 +31,61 @@
{% endif %}
</td>
<td>
<a class="btn btn-outline-primary" role="button" href="/admin/users/{{profile.user.id}}"
style="margin-right: 5px; line-height: 2px; min-width: 10px; width: 24px; height: 20px; padding: 2px; border-radius: 5px;">
<i class="fa fa-eye"></i>
<a class="btn btn-outline-success" role="button" href="/admin/users/{{profile.user.id}}"
style="padding: 0px 10px; min-width: 20px; border-radius: 5px;">
<i class="fa fa-eye"></i> View
</a>
{% if user.is_superuser %}
<button class="btn btn-outline-danger delete_user" data-bs-toggle="modal" data-bs-target="#confirmModal"
data-id="{{profile.user.id}}" data-name="{{profile.user.first_name}} {{profile.user.last_name}}"
style="margin-right: 5px; line-height: 2px; min-width: 10px; width: 24px; height: 20px; padding: 2px; border-radius: 5px;">
<i class="fa fa-remove"></i>
style="padding: 0px 10px; min-width: 20px; border-radius: 5px;">
<i class="fa fa-trash"></i> Delete
</button>
{% endif %}
</td>

</tr>
{% endfor %}

{% endif %}
</tbody>
</table>
</table>
<script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/dataTables.bootstrap5.min.js' %}"></script>
<script>
$(document).ready(function () {
$("#users_tbl").DataTable();

var id, name;
$('#confirmYes').on("click", function () {
var formData = new FormData();
formData.append("csrfmiddlewaretoken", "{{csrf_token}}");
formData.append("user_id", id);
$.ajax({
url: "/admin/users/delete",
type: "POST",
dataType: "json",
data: formData,
processData: false,
contentType: false,
success: function (response) {
$('#confirmModal').hide();
$("#nav-user").empty();
$("#nav-user").append(response);
},
error: function (response) {
$('#confirmModal').hide();
showMessage(response.responseJSON.msg, "danger");
}
});
});

$('.delete_user').on("click", function () {
id = $(this).attr("data-id");
name = $(this).attr("data-name");
document.getElementById("confirmModalLabel").innerText = "Confirm Dialog - Account Closure";
document.getElementById("confirmMessage").innerText = "Do you want to remove " + name + " ?";
});
});
</script>
19 changes: 0 additions & 19 deletions app/account/templates/account/login-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,6 @@
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12">
{% block messages %}
<ul class="messages" id="messages-list">
{% if messages %}
{% for message in messages %}
<li>
{% if message.tags %}
<div class="alert alert-{{ message.tags }} msg fade show" role="alert">{{ message }}</div>
{% else %}
<div class="alert alert-info msg fade show" role="alert">{{ message }}</div>
{% endif %}
</li>
{% endfor %}
{% endif %}
</ul>
{% endblock %}
</div>
</div>
{% csrf_token %}
<div class="row">
<div class="col-md-12 mb-3">
Expand Down
6 changes: 3 additions & 3 deletions app/account/templates/account/modals/aoi.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ <h5 class="modal-title" id="title">Region of Interest</h5>
} else if ($("#aoi_file").is(":checked")) {
data_file = $("#data_file")[0];
if (data_file == undefined || data_file.files.length == 0) {
showMessage("Input file is required!", 3000);
showMessage("Input file is required!", "danger");
return;
} else {
data_file = data_file.files[0];
Expand Down Expand Up @@ -322,10 +322,10 @@ <h5 class="modal-title" id="title">Region of Interest</h5>
success: function (response) {
$("#aoi_lbl").html(response.name);
$("aoi_id").val(response.id);
showMessage(response.msg, 3000);
showMessage(response.msg, "success");
},
error: function (response) {
showMessage(response.responseJSON.msg, 3000);
showMessage(response.responseJSON.msg, "danger");
}
});
});
Expand Down
Loading