aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/publish-defect-toastertable.html
blob: c31e3b6a1bff00fd6bdc80760301b78dc139fb0b (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
{% 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">&rarr;</span>
            <li><a href="{% url 'manage' %}">Management</a></li><span class="divider">&rarr;</span>
            <li><a href="{% url 'publish' %}">Publish</a></li><span class="divider">&rarr;</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 %}