diff options
Diffstat (limited to 'lib/srtgui/templates/publish-select-toastertable.html')
-rw-r--r-- | lib/srtgui/templates/publish-select-toastertable.html | 248 |
1 files changed, 248 insertions, 0 deletions
diff --git a/lib/srtgui/templates/publish-select-toastertable.html b/lib/srtgui/templates/publish-select-toastertable.html new file mode 100644 index 00000000..5a439c63 --- /dev/null +++ b/lib/srtgui/templates/publish-select-toastertable.html @@ -0,0 +1,248 @@ +{% 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> + {% if access.is_creator %}{% else %}<meta http-equiv="refresh" content="0; url=/" />{% endif %} + + <style> + /* Style the execution buttons */ + button.execute { height:50px;width:210px;background-color:#4CAF50;text-align:center; border:2px #f69c55;border-radius: 12px; } + + button:disabled { + cursor: not-allowed; + } + + /* Create two equal columns that floats next to each other */ + .column { + float: left; + width: 350px; + padding: 10px; + } + + /* Clear floats after the columns */ + .row:after { + content: ""; + display: table; + clear: both; + } + </style> + +{% endblock %} + +{% block title %} Publish CVE's - SRTool {% 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 CVE's</li> + </ul> + </div> + </div> + + <div id="change-publish-state" > <!--class="form-inline" --> + <b><big>Actions: </big></b> + <button id="select-these" class="btn btn-default" type="button">Select these</button> + <button id="unselect-these" class="btn btn-default" type="button">Un-select these</button> + <button id="select-publish" class="btn btn-default" type="button">Update ...</button> + <!--<button id="collect-publish" class="btn btn-default" type="button">Collect Publishable CVEs</button> --> + </div> + + <div id="details-publish" style="display:none;"> + <p><p> + <button class="execute" id="submit-publish"> Update Publish CVE State </button> + <p><b><big>New Publish State: </big></b> + <select name="Publish" id="select-publish-state"> + <option value="0" >Unpublished</option> + <option value="1" >Not to be Published</option> + <option value="2" >Published</option> + <option value="3" >Publish Request (New)</option> + <option value="4" >Publish Request (Update)</option> + <option value="5" selected>Publish Submitted</option> + </select> + </div> + + <div class="row"> + <div class="col-md-12"> + <div class="page-header"> + <h1 class="top-air" data-role="page-title"></h1> + </div> + + {% url '' as xhr_table_url %} + {% include 'toastertable.html' %} + </div> + </div> + + <!-- Javascript support --> + <script> + + //# sourceURL=somename.js + + // global variables + var selected_publish=false; + var cve_total=0; + + $(document).ready(function() { + + 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; + } + // 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_cve_publish_commit'%}", + headers: { 'X-CSRFToken': $.cookie("csrftoken")}, + success: onCommitAjaxSuccess, + error: onCommitAjaxError, + }) + } + + function update_publish_status() { + var cve_count = 0; + var cve_checked_count = 0; + $('#selectpublishtable input').each(function(){ + cve_count = cve_count + 1; + if ($(this).is(':checked')) { + cve_checked_count = cve_checked_count + 1; + } + }); + if (cve_total > cve_count) { + document.getElementById("select-these").innerText = "Select "+(cve_count-cve_checked_count)+" unchecked ("+(cve_total-cve_count)+" offpage)"; + } else { + document.getElementById("select-these").innerText = "Select "+(cve_count-cve_checked_count)+" unchecked"; + } + document.getElementById("unselect-these").innerText = "Un-select "+cve_checked_count+" checked"; + if (0 == cve_checked_count) { + //$("#submit-publish").attr("disabled","disabled"); + document.getElementById("submit-publish").disabled = true; + } else { + //$("#submit-publish").removeAttr("disabled"); + document.getElementById("submit-publish").disabled = false; + } + } + + $('#select-these').click(function(){ + $('#selectpublishtable input').each(function(){ + $(this).prop('checked', true); + }); + update_publish_status(); + }); + + $('#unselect-these').click(function(){ + $('#selectpublishtable input').each(function(){ + $(this).prop('checked', false); + }); + update_publish_status(); + }); + + // Open Publish Action + $('#select-publish').click(function(){ + if (selected_publish) { + selected_publish=false; + $("#select-these").removeAttr("disabled"); + $("#unselect-these").removeAttr("disabled"); + $("#details-publish").slideUp(); + } else { + selected_publish=true; + $("#select-these").attr("disabled","disabled"); + $("#unselect-these").attr("disabled","disabled"); + update_publish_status(); + $("#details-publish").slideDown(); + } + }); + + $('#submit-publish').click(function(){ + var cve_list=""; + $('#selectpublishtable input').each(function(){ + if ($(this).is(':checked')) { + cve_list +=$(this).prop('name') + ","; + } + }); + if ("" == cve_list) { + alert("No CVE's were selected"); + return; + } + publish_state=$('#select-publish-state').val(); + postCommitAjaxRequest({ + "publish_state" : publish_state, + "cve_list" : cve_list, + }); + + }); + + // When change in product selections, update labels and enables + $(document).on("change", "#all-products :checkbox", function() { + update_publish_status(); + }); + + // When change in CVE selections, update labels and enables + $(document).on("change", "#selectpublishtable :checkbox", function() { + update_publish_status(); + }); + + + // Standard Toaster Table enablement + + var tableElt = $("#{{table_name}}"); + var titleElt = $("[data-role='page-title']"); + + tableElt.on("table-done", function (e, total, tableParams) { + var title = "Publish CVE's"; + + if (tableParams.search || tableParams.filter) { + if (total === 0) { + title = "No CVE's found"; + } + else if (total > 0) { + title = total + " CVE" + (total > 1 ? "'s" : '') + " found"; + } + } + + titleElt.text(title); + cve_total = total; + update_publish_status(); + + /* Set the report link */ + var record_list="" + $(".name > a").each(function(){ + var this_id=$(this).prop('id'); + if (this_id.startsWith("dataid_")) { + record_list +=this_id.replace(/dataid_/,"") + ","; + } + }); + $('#report_link').attr('href',"{% url 'report' request.resolver_match.url_name %}?record_list="+record_list); + }); + + }); + </script> +{% endblock %} |