diff options
Diffstat (limited to 'lib/srtgui/templates/publish-defect-toastertable.html')
-rwxr-xr-x | lib/srtgui/templates/publish-defect-toastertable.html | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/lib/srtgui/templates/publish-defect-toastertable.html b/lib/srtgui/templates/publish-defect-toastertable.html new file mode 100755 index 00000000..c31e3b6a --- /dev/null +++ b/lib/srtgui/templates/publish-defect-toastertable.html @@ -0,0 +1,168 @@ +{% extends 'base.html' %} +{% load static %} + +{% block extraheadcontent %} + <link rel="stylesheet" href="{% static 'css/jquery-ui.min.css' %}" type='text/css'> + <link rel="stylesheet" href="{% static 'css/jquery-ui.structure.min.css' %}" type='text/css'> + <link rel="stylesheet" href="{% static 'css/jquery-ui.theme.min.css' %}" type='text/css'> + <script src="{% static 'js/jquery-ui.min.js' %}"> + </script> +{% endblock %} + +{% block title %} Publish Table via Defects {% endblock %} + +{% block pagecontent %} + +<div class="row"> + <!-- Breadcrumbs --> + <div class="col-md-12"> + <ul class="breadcrumb" id="breadcrumb"> + <li><a href="{% url 'landing' %}">Home</a></li><span class="divider">→</span> + <li><a href="{% url 'manage' %}">Management</a></li><span class="divider">→</span> + <li><a href="{% url 'publish' %}">Publish</a></li><span class="divider">→</span> + <li>Publish Table via Defects</li> + </ul> + </div> +</div> + +<div > <!--class="form-inline" --> + <b><big>Actions: </big></b> + <button id="mark-new" class="btn btn-default" type="button">Mark New</button> + <button id="mark-modified" class="btn btn-default" type="button">Mark Updated</button> + <button id="unmark" class="btn btn-default" type="button">Unmark</button> +</div> + +<div class="row"> + <div class="col-md-12"> + <div class="page-header"> + <h1 class="top-air" data-role="page-title"></h1> + </div> + + {# xhr_table_url is just the current url so leave it blank #} + {% url '' as xhr_table_url %} + {% include 'toastertable.html' %} + </div> +</div> + +<div id="table-loading"> +<h3><font color="blue">[ Table Loading... ]</font></h3> +</div> + + <!-- Javascript support --> + <script> + var selected_notifyedit=false; + + $(document).ready(function () { + var tableElt = $("#{{table_name}}"); + var titleElt = $("[data-role='page-title']"); + + $("#table-loading").slideDown(); + tableElt.on("table-done", function (e, total, tableParams) { + var title = "Publish Table via Defects"; + + if (tableParams.search || tableParams.filter) { + if (total === 0) { + title = "Publish CVEs found"; + } + else if (total > 0) { + title = total + " Publish CVEs via Defect" + (total > 1 ? 's' : '') + " found"; + } + } + + titleElt.text(title); + $("#table-loading").slideUp(); + }); + + function onCommitAjaxSuccess(data, textstatus) { + if (window.console && window.console.log) { + console.log("XHR returned:", data, "(" + textstatus + ")"); + } else { + alert("NO CONSOLE:\n"); + return; + } + if (data.error != "ok") { + alert("error on request:\n" + data.error); + return; + } else if (('results_msg' in data) && ("" != data.results_msg)) { + alert("Results: " + data.results_msg); + } + // reload the page with the updated tables + location.reload(true); + } + + function onCommitAjaxError(jqXHR, textstatus, error) { + console.log("ERROR:"+error+"|"+textstatus); + alert("XHR errored1:\n" + error + "\n(" + textstatus + ")"); + } + + /* ensure cookie exists {% csrf_token %} */ + function postCommitAjaxRequest(reqdata) { + var ajax = $.ajax({ + type:"POST", + data: reqdata, + url:"{% url 'xhr_publish'%}", + headers: { 'X-CSRFToken': $.cookie("csrftoken")}, + success: onCommitAjaxSuccess, + error: onCommitAjaxError, + }) + } + + $('#mark-new').click(function(){ + var defect_list=[]; + $('#publishdefecttable input').each(function(){ + if ($(this).is(':checked')) { + defect_list.push($(this).prop('name')); + } + }); + defect_list = defect_list.join(","); + if ("" == defect_list) { + alert("No Defects were selected"); + return; + } + postCommitAjaxRequest({ + "action" : 'mark-new', + "defects" : defect_list, + }); + }); + + $('#mark-modified').click(function(){ + var defect_list=[]; + $('#publishdefecttable input').each(function(){ + if ($(this).is(':checked')) { + defect_list.push($(this).prop('name')); + } + }); + defect_list = defect_list.join(","); + if ("" == defect_list) { + alert("No Defects were selected"); + return; + } + postCommitAjaxRequest({ + "action" : 'mark-modified', + "defects" : defect_list, + }); + }); + + $('#unmark').click(function(){ + var defect_list=[]; + $('#publishdefecttable input').each(function(){ + if ($(this).is(':checked')) { + defect_list.push($(this).prop('name')); + } + }); + defect_list = defect_list.join(","); + if ("" == defect_list) { + alert("No Defects were selected"); + return; + } + postCommitAjaxRequest({ + "action" : 'unmark', + "defects" : defect_list, + }); + }); + + + }); <!-- $(document).ready() --> + + </script> +{% endblock %} |