aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cve_checker/templates/ck-audit-toastertable.html
blob: a9d4d2270071aec9ba49ddbb7e68e89dbd081d5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
{% 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>
<style>
.column1 {
  float: left;
  width: 40%;
}
.column2 {
  float: left;
  width: 60%;
}
/* Clear floats after the columns */
.row:after {
  content: "";
  display: table;
  clear: both;
}
</style>
{% endblock %}

{% load jobtags %}

{% block title %} CVE Check Packages {% 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">&rarr;</span>
			<li><a href="{% url 'cvechecker_audits' %}">Audits</a></li><span class="divider">&rarr;</span>
			<li>Packages for "{{Ck_Audit.name}}"</li>
		</ul>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
	{% with mru=mru mrj_type=mrj_type %}
	  {% include 'mrj_section.html' %}
	{% endwith %}
	</div>
</div>

<div class="row" style="margin-left:10px;" id="show-settings">
  <div class="column1">
	<h2> Audit Name: <b>"{{Ck_Audit.name}}"</b> </h2>
  </div>
  <div class="column2">
	<h2> YP Release: <b>"{{Ck_Audit.orm_product.long_name}}"</b> </h2>
  </div>
</div>

<!-- <p><b><big>Actions: </big></b> -->

<p><b><big>Actions: </big></b>
	<a class="btn btn-default navbar-btn " id="summary-report" >Summary report</a>
	<a class="btn btn-default navbar-btn " id="vex-report" disabled>VEX</a>
	<a class="btn btn-default navbar-btn " id="edit-cancel" style="display:none" >Cancel</a>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a class="btn btn-default btn-info" disabled>Package View</a>
	<a class="btn btn-default " href="{% url 'cvechecker_audit_cve' Ck_Audit.id %}">CVE View</a>

<!-- Combination javascript plus redirected download for this ToasterTable (no-POST) page -->
<form id="summary-report-form" action="/cve_checker/gen_download_cvechecker_summary/" enctype="multipart/form-data" method="post" >{% csrf_token %}
	<input type="hidden" name="action" value="download">
	<input type="hidden" name="options" value="" id="summary_report_options">
	<input type="hidden" name="audit_id" value="{{Ck_Audit.id}}">
	<button type="submit" form="summary-report-form" value="Submit2" style="display:none" id="download-summary-report">Generate the diff report</button>
</form>

<div id="summary-report-options" style="display:none;padding-left:25px;color:DarkCyan;">
	<br>
	<h4> Select the pages to be included in the report:</h4>
	<input type="checkbox" id="audit-summary" name="audit-summary" value="base-severity" checked>
	<label for="audit-summary">Audit summary</label><br>
	<input type="checkbox" id="package-summary" name="package-summary" value="package-summary" checked>
	<label for="package-summary">Package summary</label><br>
	<input type="checkbox" id="unpatched-summary" name="unpatched-summary" value="unpatched-summary" checked>
	<label for="unpatched-summary">Unpatched summary</label><br>
	<input type="checkbox" id="unpatched-summary-compare" name="unpatched-summary-compare" value="unpatched-summary-compare">
	<label for="unpatched-summary-compare">Unpatched summary with comparibles</label><br>
</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 type="text/javascript">
    $(document).ready(function () {
      var selected_editsettings=false;
      var selected_summary=false;

      var tableElt = $("#{{table_name}}");
      var titleElt = $("[data-role='page-title']");

      tableElt.on("table-done", function (e, total, tableParams) {
        var title = "Audit packages (" + total + ")";

        if (tableParams.search || tableParams.filter) {
          if (total === 0) {
            title = "No packages found";
          }
          else if (total > 0) {
            title = total + " Packages" + (total > 1 ? "s" : '') + " found";
          }
        }

        titleElt.text(title);

		$('.remove-repo-audit').click(function() {
			var result = confirm("Are you sure you want to remove artifact '" + $(this).attr('x-data').split('|')[0] + "'?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'remove-artifact-audit',
					"record_id" : $(this).attr('x-data').split('|')[1],
					});
			}
		});

      });

      function onCommitAjaxSuccess(data, textstatus) {
      	//alert("AJAX RETURN");
        $("#run-audit-analysis").removeAttr("disabled");
      	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
//      	alert("PAGE REFRESH");
      	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,url) {
      	reqdata["Ck_Audit_id"] = {{ Ck_Audit.id }};
      	url = url || "{% url 'xhr_cvechecker_commit' %}";
      	var ajax = $.ajax({
            	type:"POST",
            	data: reqdata,
            	url:url,
            	headers: { 'X-CSRFToken': $.cookie("csrftoken")},
            	success: onCommitAjaxSuccess,
            	error: onCommitAjaxError,
      	});
      }

	  $('#summary-report').click(function() {
	  	if (selected_summary) {
			document.getElementById("summary-report").innerText = "Summary Report";
			document.getElementById('vex-report').style.display = 'inline';
			document.getElementById('edit-cancel').style.display = 'none';
			$("#summary-report-options").slideUp();
			selected_summary=false;
			var options = "";
			if (document.getElementById('audit-summary').checked) {
				options = options + "audit-summary,";
			}
			if (document.getElementById('package-summary').checked) {
				options = options + "package-summary,";
			}
			if (document.getElementById('unpatched-summary').checked) {
				options = options + "unpatched-summary,";
			}
			if (document.getElementById('unpatched-summary-compare').checked) {
				options = options + "unpatched-summary-compare,";
			}
			document.getElementById("summary_report_options").value=options;
			document.getElementById("download-summary-report").click();
	  	} else {
			document.getElementById("summary-report").innerText = "Generate Summary Report";
			document.getElementById("summary-report").style.display = 'inline';
			document.getElementById('vex-report').style.display = 'none';
			document.getElementById('edit-cancel').style.display = 'inline';
			$("#summary-report-options").slideDown();
			selected_summary=true;
	  	}
	  });

	  $('#edit-cancel').click(function() {
			document.getElementById("summary-report").innerText = "Summary Report";
			document.getElementById('vex-report').style.display = 'inline';
			document.getElementById('edit-cancel').style.display = 'none';
			$("#summary-report-options").slideUp();
			selected_summary=false;
	  });

	  $('.submit-downloadattachment').click(function() {
        $("#downloadbanner-"+this.getAttribute("x-data")).submit();
      });

    });
  </script>
{% endblock %}