aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/investigation.html
blob: f934d05286a92c5fef54b0b8dc0dbf9465db9972 (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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
{% extends "base.html" %}

{% block extraheadcontent %}
<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;
  }

  /* Define the columns that floats next to each other */
  .column1 {
      float: left;
      width: 280px;
      padding: 10px;
  }
  .column2 {
      float: left;
      width: 150px;
      padding: 10px;
  }

  /* Clear floats after the columns */
  .row:after {
      content: "";
      display: table;
      clear: both;
  }
</style>
{% endblock %}

{% load projecttags %}

{% block title %} {{object.name}} - 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">&rarr;</span>
			<li><a href="{% url 'investigations' %}">Investigations</a></li><span class="divider">&rarr;</span>
			<li>{{object.name}}</li>
		</ul>
	</div>
</div>

<!-- Begin container -->

<div class="row">
  <div class="col-md-12">
    <div class="page-header build-data">
        <span class="srt_h1">Investigation {{object.name}} {% if not object.public %} <font color="red">[PRIVATE]</font> {% endif %}</span>
        {% if request.user.is_creator %}
            <span style="padding-left:30px;"><button id="select-quickedit" class="btn btn-default" type="button">Edit Status...</button></span>
            <span style="padding-left:30px;"><button id="select-notification" class="btn btn-default" type="button">Create Notification ...</button></span>
            <span style="padding-left:30px;"><button id="select-delete" class="btn btn-default" type="button" x-data="{{object.id}}">Delete</button></span>
        {% endif %}
    </div>
  </div>
</div>

<!-- include SRtool Metadata/Notification -->
{% include "srtool_metadata_include.html" with default_category="INVESTIGATION" default_url="investigation" %}

<HR ALIGN="center" WIDTH="100%">

<div class="row" style="padding-left: 25px;">
  <div class="col-md-5">
	<div class="well">
	<h2>Quick Info</h2>
		<dl class="dl-horizontal">
			<dt>Product:</dt>
			<dd><a href="{% url 'product' object.product.id %}">{{object.product.long_name}}</a></dd>

			<dt>Vulnerability:</dt>
			<dd><a href="{% url 'vulnerability' object.vulnerability.id %}">{{object.vulnerability.get_long_name}}</a></dd>
	   </dl>
	</div>
  </div>
</div>

<hr>

<div class="row" style="padding-left: 25px;">
	<h3>Defects
		{% if request.user.is_creator %}
			<button  id="select-attachdefect" class="btn btn-default" type="button">Attach Defect</button>
			<button  id="select-createdefect" class="btn btn-default" type="button">Create Defect</button>
		{% endif %}
	</h3>

	<div id="details-attachdefect" style="display:none; border: 1px solid; padding:20px; width:400px; margin-bottom:25px; margin-left:150px">
		<p><b><label>Select Defect by Key:</label></b>
		<div id="input-attachdefect" style="padding-left: 50px">
			<p><input type="text" id="text-attachdefect" placeholder="Issue Key (ex. {{defect_example}})" size="20">	<button class="execute" id="submit-attachdefect"> Submit </button></p>
		</div>
	</div>

	<div class="col-md-12">
	 <div id="details-defect" style="border: 1px solid Blue; background-color:LightBlue; padding-left: 25px; padding-right: 20px; display:none;">
	  <p><p>
	  <div class="row">
	  <button class="execute" id="submit-createdefect"> Submit New Defect </button>
	  <button id="select-canceldefect"> Cancel </button>
	  </div>
	  <div class="row">
		<div class="column1">
		  <p><b><label id="priority">Set Priority:</label></b>
		  <div id="priority-list" class="scrolling" style="width: 120px;">
			  <div class="checkbox"> <label>
				  <input type="radio" name="priority" value="4" type="checkbox">  P1
			  </label><p></div>
			  <div class="checkbox"> <label>
				  <input type="radio" name="priority" value="3" type="checkbox" checked="yes">  P2
			  </label><p></div>
			  <div class="checkbox"> <label>
				  <input type="radio" name="priority" value="2" type="checkbox">  P3
			  </label><p></div>
			  <div class="checkbox"> <label>
				  <input type="radio" name="priority" value="1" type="checkbox">  P4
			  </label><p></div>
		  </div>
		</div>
		<div class="column2">
		  <p><b><label id="components">Set Components:</label></b>
		  <div id="all-components" class="scrolling" style="width: 150px;">
		  {% for component in components %}
			  <div class="checkbox">
				<label>
				  <input class="checkbox-components" name="{{component}}" type="checkbox">{{component}}
				  {% if "Userspace" == component %}<hr>{% endif %}
				</label>
				<p>
			  </div>
		  {% endfor %}
		  </div>
		</div>
	  </div>
	  Defect Reason: <input type="text" id="input-defect-reason" name="defect-reason" size="20" placeholder="(optional)"> (e.g. "Security Advisory [- REASON -] CVE-2020-1234")
	  <p><p>
      <b><big>Affected Components: </big></b>
      <input type="text" id="input-affected-components" name="components" size="40" value="{{affected_components}}"> (e.g. space-separated list of packages, recipes, sub-system list, applications, )
	  <p><p>
      Found Version: {{found_version}}
	  <p><p>

	 </div>
	</div>

	<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
		<thead>
			<tr>
				<th>Defect</th>
				<th>Summary</th>
				<th>Priority</th>
				<th>Status</th>
				<th>Resolution</th>
				<th>Release Version</th>
				<th>URL</th>
				{% if request.user.is_creator %}
					<th>Manage</th>
				{% endif %}
			</tr>
		</thead>

		{% if object.investigation_to_defect.all %}
		  {% for id in object.investigation_to_defect.all %}
			<tr>
				<td><a href="{% url 'defect' id.defect.id %}">{{id.defect.name}} </a></td>
				<td>{{ id.defect.summary }}</td>
				<td>{{ id.defect.get_priority_text }}</td>
				<td>{{ id.defect.get_status_text }}</td>
				<td>{{ id.defect.get_defect_resolution_text }}</td>
				<td>{{ id.defect.release_version }}</td>
				<td><a href="{{id.defect.url}}" id="dataid_{{id.defect.id}}" target="_blank">{{id.defect.url}}</a></td>
				{% if request.user.is_creator %}
					<td>
						<span class="glyphicon glyphicon-trash detach-defect" id="detach-defect_'+{{id.defect.id}}+'" x-data="{{id.defect.name}}"></span>
					</td>
				{% endif %}
			</tr>
		  {% endfor %}
		{% else %}
			<tr>
				<td>No defects found</td>
			</tr>
		{% endif %}
	</table>
</div>

<div class="row" style="padding-left: 25px;">
	<h3>Comments
		{% if request.user.is_creator %}
			<button id="select-newcomment" class="btn btn-default" type="button">Add comment ...</button>
		{% endif %}
	</h3>

	<div id="input-newcomment" style="padding-left: 50px; display:none;">
		<p><input type="text" id="text-newcomment" size="40">	<button class="execute" id="submit-newcomment"> Submit </button></p>
	</div>

	<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
		<thead>
			<tr>
				<th>Comment</th>
				<th>Date</th>
				<th>Author</th>
				{% if request.user.is_creator %}
					<th>Manage</th>
				{% endif %}
			</tr>
		</thead>

		{% if object.investigation_comments.all %}
		  {% for c in object.investigation_comments.all %}
			<tr>
				<td>{{ c.comment }}</td>
				<td>{{ c.date }}</td>
				<td>{{ c.author }}</td>
				{% if request.user.is_creator or c.author == request.user.username %}
					<td>
						<span id="config_var_entry_'+configvars_sorted[i][2]+'" class="js-config-var-name"></span>
						<span class="glyphicon glyphicon-edit edit-comment" id="affected_edit_'+{{c.id}}+'" x-data="{{c.id}}"></span>
						<span class="glyphicon glyphicon-trash trash-comment" id="comment_trash_'+{{c.id}}+'" x-data="{{c.id}}"></span>
					</td>
				{% endif %}
			</tr>
		  {% endfor %}
		{% else %}
			<tr>
				<td>No comments found</td>
			</tr>
		{% endif %}
	</table>
</div>

<div class="row" style="padding-left: 25px;">
	<h3>Attachments
		{% if request.user.is_creator %}
			<a class="btn btn-default navbar-btn " id="select-addattachment">Add attachment ... </a>
		{% endif %}
	</h3>

	<div id="details-addattachment" style="padding-left: 50px; display:none;">
		<p><p>
		<div class="row">
			<form id="uploadbanner" enctype="multipart/form-data" method="post">{% csrf_token %}
				 <input id="fileDescription" name="fileDescription" type="text" placeholder="Enter Description" />
			   <input id="fileUpload" name="fileUpload" type="file" />
				 <input type="hidden" id="action" name="action" value="upload">
			   <input type="submit" value="submit file" id="submit-addattachment" />
			</form>
		</div>
	</div>

	<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
		<thead>
			<tr>
				<th>Comment</th>
				<th>Name</th>
				<th>Size</th>
				<th>Date</th>
				<th>Author</th>
				<th>Manage</th>
			</tr>
		</thead>

		{% if object.investigation_uploads.all %}
		  {% for u in object.investigation_uploads.all %}
		  <tr>
			<td>{{ u.description }}</td>
			<td>{{ u.path|basename }}</td>
			<td>{{ u.size }}</td>
			<td>{{ u.date }}</td>
			<td>{{ u.author }}</td>
			<td>
				<span id="attachment_entry_'+{{u.id}}+'" class="js-config-var-name"></span>
				<form id="downloadbanner-{{forloop.counter}}" enctype="multipart/form-data" method="post" >{% csrf_token %}
					<input type="hidden" id="action" name="action" value="download">
					<input type="hidden" id="record_id" name="record_id" value={{u.id}}>
					<span class="glyphicon glyphicon-download-alt submit-downloadattachment" id="attachment_download_'+{{u.id}}+'" x-data="{{forloop.counter}}"></span>
					{% if request.user.is_creator %}
						<span class="glyphicon glyphicon-trash trash-attachment" id="attachment_trash_'+{{u.id}}+'" x-data="{{u.id}}"></span>
					{% endif %}
				</form>
			</td>
		  </tr>
		  {% endfor %}
		{% else %}
			<tr>
				<td>No comments found</td>
			</tr>
		{% endif %}
	</table>
</div>

<br/>
<hr/>

{% if request.user.is_creator %}
	<div class="row" style="padding-left: 25px;">
		<h3>Change Notifications
			{% if request.user.is_creator %}
				<button id="select-addusernotify" class="btn btn-default" type="button">Add user notification ...</button>
			{% endif %}
		</h3>

		<div id="details-addusernotify" style="padding-left: 50px; display:none;">
	  	<p><p>
	    <button class="execute" id="submit-addusernotify"> Submit </button>
	    <div class="row">
	      <p>
	      <div id="all-users" class="scrolling" style="width: 300px;">
	      {% for user in users %}
	  		<div class="checkbox">
	  		  <label>
	  			<input class="checkbox-users" name="update-users" value="{{user.pk}}" type="checkbox">{{user.name}}
	  		  </label>
	  		  <p>
	  		</div>
	  		{% endfor %}
	      </div>
	    </div>
	  </div>

		<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
			<thead>
				<tr>
					<th>User</th>
					<th>Email</th>
					{% if request.user.is_creator %}
						<th>Manage</th>
					{% endif %}
				</tr>
			</thead>

			{% if object.investigation_notification.all %}
			  {% for u in object.investigation_notification.all %}
				<tr>
					<td>{{ u.user.name }}</td>
					<td>{{ u.user.email }}</td>
					{% if request.user.is_creator or u.user.name == request.user.username %}
						<td>
							<span id="attachment_entry_'+{{u.id}}+'" class="js-config-var-name"></span>
							<span class="glyphicon glyphicon-edit edit-usernotification" id="affected_edit_'+{{u.id}}+'" x-data="{{u.id}}"></span>
							<span class="glyphicon glyphicon-trash trash-usernotification" id="attachment_trash_'+{{u.id}}+'" x-data="{{u.id}}"></span>
						</td>
					{% endif %}
				</tr>
			  {% endfor %}
			{% else %}
				<tr>
					<td>No users found</td>
				</tr>
			{% endif %}
		</table>
	</div>

	<div class="row" style="padding-left: 25px;">
		<h3>User Access
			{% if request.user.is_creator %}
				<button id="select-adduseraccess" class="btn btn-default" type="button">Add user access ...</button>
			{% endif %}
		</h3>

		<div id="details-adduseraccess" style="padding-left: 50px; display:none;">
			<p><p>
			<button class="execute" id="submit-adduseraccess"> Submit </button>
			<div class="row">
				<p>
				<div id="all-users" class="scrolling" style="width: 300px;">
				{% for user in users %}
				<div class="checkbox">
					<label>
					<input class="checkbox-users" name="access-users" value="{{user.pk}}" type="checkbox">{{user.name}}
					</label>
					<p>
				</div>
				{% endfor %}
				</div>
			</div>
		</div>

		<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
			<thead>
				<tr>
					<th>User</th>
					{% if request.user.is_creator %}
						<th>Manage</th>
					{% endif %}
				</tr>
			</thead>

			{% if object.public %}
			<tr>
				<td>All</td>
				<td>
				</td>
			</tr>
			{% endif %}

			{% if object.investigation_users.all %}
			  {% for u in object.investigation_users.all %}
				<tr>
					<td>{{ u.user.name }}</td>
					{% if request.user.is_creator %}
						<td>
							<span id="attachment_entry_'+{{u.id}}+'" class="js-config-var-name"></span>
							<span class="glyphicon glyphicon-edit edit-useraccess" id="affected_edit_'+{{u.id}}+'" x-data="{{u.id}}"></span>
							<span class="glyphicon glyphicon-trash trash-useraccess" id="attachment_trash_'+{{u.id}}+'" x-data="{{u.id}}"></span>
						</td>
					{% endif %}
				</tr>
			  {% endfor %}
			{% else %}
			  {% if not object.public %}
				<tr>
					<td>No users found</td>
				</tr>
			  {% endif %}
			{% endif %}
		</table>
	</div>
{% endif %}

<div class="row" style="padding-left: 25px;">
	<h3>History</h3>
	<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
		<thead>
			<tr>
				<th>Comment</th>
				<th>Date</th>
				<th>Author</th>
			</tr>
		</thead>
		{% if object.investigation_history.all %}
		  {% for c in object.investigation_history.all %}
			<tr>
				<td>{{ c.comment }}</td>
				<td>{{ c.date }}</td>
				<td>{{ c.author }}</td>
			</tr>
		  {% endfor %}
		{% else %}
			<tr>
				<td>No history found</td>
			</tr>
		{% endif %}
	</table>
</div>

<HR ALIGN="center" WIDTH="100%">
Created={{object.srt_created}} Updated={{object.srt_updated}}

<script>
	var selected_newcomment=false;
	var selected_addusernotify=false;
	var selected_adduseraccess=false;
	var selected_addattachment=false;
	var selected_attachdefect=false;
	var selected_detachdefect=false;

    var selected_quickedit=false;
    var selected_notifyedit=false;

	$(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) {
			reqdata["investigation_id"] = {{ object.id }}
			var ajax = $.ajax({
					type:"POST",
					data: reqdata,
					url:"{% url 'xhr_investigation_commit' %}",
					headers: { 'X-CSRFToken': $.cookie("csrftoken")},
					success: onCommitAjaxSuccess,
					error: onCommitAjaxError,
			});
		}

		/* Defect management */

		$('#select-attachdefect').click(function(){
			if (selected_attachdefect) {
				selected_attachdefect=false;
				$("#details-attachdefect").slideUp();
			} else {
				if (selected_detachdefect) {
					selected_detachdefect = false;
				}
				selected_attachdefect=true;
				$("#details-detachdefect").slideUp();
				$("#details-attachdefect").slideDown();
			}
		})

		$('#select-detachdefect').click(function(){
			if (selected_detachdefect) {
				selected_detachdefect=false;
				$("#details-detachdefect").slideUp();
			} else {
				if (selected_attachdefect) {
					selected_attachdefect = false;
				}
				selected_detachdefect=true;
				$("#details-detachdefect").slideDown();
				$("#details-attachdefect").slideUp();
			}
		})

		// Open Create-Defect Action
		$('#select-createdefect').click(function(){
			$("#details-defect").slideDown();
		});
		$('#select-canceldefect').click(function(){
			$("#details-defect").slideUp();
		});

		$('#submit-createdefect').click(function(){
			var component_list=[];
			$('#all-components input:checked').each(function(){
			  component_list.push($(this).attr('name'));
			});
			/* components are space delimited */
			component_list = component_list.join(" ");
			var priority=0
			$('#priority-list input:checked').each(function(){
			  priority = $(this).attr('value');
			});
			postCommitAjaxRequest({
				"action" : 'submit-createdefect',
				"defect_reason" : $("#input-defect-reason").val(),
				"affected_components" : $("#input-affected-components").val(),
				"components": component_list,
				"priority": priority,
			});
		})

		$('#submit-attachdefect').click(function(){
			var query=$('#text-attachdefect').val().trim()
			if (query=="") {
				alert("No defect given");
				return;
			}
			postCommitAjaxRequest({
				"action" : 'submit-attachdefect',
				"query" : query,
			});
		});

		$('.detach-defect').click(function(){
		 	var defect_name = $(this).attr('x-data');
			var result = confirm("Are you sure you want to detach " + defect_name + "?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'submit-detachdefect',
					"defect" : defect_name,
					});
			}
		});


		/* Comment management */

		$('#select-newcomment').click(function(){
			if (selected_newcomment) {
				selected_newcomment=false;
				$("#input-newcomment").slideUp();
			} else {
				selected_newcomment=true;
				$("#input-newcomment").slideDown();
			}
		});

		$('#submit-newcomment').click(function(){
			var comment=$('#text-newcomment').val().trim()
			if (comment=="") {
				alert("No comment was written");
				return;
			}
			postCommitAjaxRequest({
				"action" : 'submit-newcomment',
				"comment" : comment,
			})
		});

		$('.trash-comment').click(function(){
			var result = confirm("Are you sure?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'submit-trashcomment',
					"record_id" : $(this).attr('x-data'),
					});
			}
		});

		/* Attachement management */

		$('#select-addattachment').click(function() {
			if (selected_addattachment) {
				selected_addattachment=false;
				$("#details-addattachment").slideUp();
			} else {
				selected_addattachment=true;
				$("#details-addattachment").slideDown();
			}
		});

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

		$('.trash-attachment').click(function() {
			var result = confirm("Are you sure?");
			if (result){
				postCommitAjaxRequest({
					"action"	:	'submit-trashattachment',
					"record_id" : $(this).attr('x-data'),
				});
			}
		});

		/* User notify management */

		$('#select-addusernotify').click(function(){
		  if (selected_addusernotify) {
			selected_addusernotify=false;
			$("#details-addusernotify").slideUp();
		  } else {
			selected_addusernotify=true;
			$("#details-addusernotify").slideDown();
		  }
		});

		$('#submit-addusernotify').click(function(){
		  var user_list=[];
		  $('input[name="update-users"]').each(function(){
			if ($(this).is(':checked')) {
			  user_list.push($(this).prop('value'));
			}
		  });
          user_list = user_list.join(",");
		  if ("" == user_list) {
			alert("No users were selected");
			return;
		  }
		  postCommitAjaxRequest({
			"action" : 'submit-addusernotify',
			"users" : user_list,
			});
		});

		$('.trash-usernotification').click(function(){
			var result = confirm("Are you sure?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'submit-trashusernotification',
					"record_id" : $(this).attr('x-data'),
					});
			}
		});

		/* User access management */

		$('#select-adduseraccess').click(function(){
			if (selected_adduseraccess) {
				selected_adduseraccess=false;
				$("#details-adduseraccess").slideUp();
			} else {
				selected_adduseraccess=true;
				$("#details-adduseraccess").slideDown();
			}
		});

		$('#submit-adduseraccess').click(function(){
			var user_list=[];
		    $('input[name="access-users"]').each(function(){
				if ($(this).is(':checked')) {
					user_list.push($(this).prop('value'));
				}
			});
            user_list = user_list.join(",");
			if ("" == user_list) {
				alert("No users were selected");
				return;
			}
			postCommitAjaxRequest({
				"action" : 'submit-adduseraccess',
				"users" : user_list,
				});
		});

		$('.trash-useraccess').click(function(){
			var result = confirm("Are you sure?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'submit-trashuseraccess',
					"record_id" : $(this).attr('x-data'),
					});
			}
		});

		$('#select-quickedit').click(function(){
			if (selected_quickedit) {
				selected_quickedit=false;
				$("#details-quickedit").slideUp();
				$("#display-status").slideDown();
                document.getElementById("select-quickedit").innerText = "Edit status...";
                $("#select-quickedit").removeClass("blueborder");
			} else {
				selected_quickedit=true;
				$("#display-status").slideUp();
				$("#details-quickedit").slideDown();
                document.getElementById("select-quickedit").innerText = "Close edit status...";
                $("#select-quickedit").addClass("blueborder");
                document.getElementById("select-status-state").focus();
			}
		});

		$('#submit-quickedit').click(function(){
			var note=$('#text-note').val().trim()
			var private_note=$('#text-private-note').val().trim()
            var tags=$('#text-tags').val().trim();
            var priority=$('#select-priority-state').val();
            var status=$('#select-status-state').val();
            var outcome=$('#select-outcome-state').val();
			postCommitAjaxRequest({
                "action"        : 'submit-quickedit',
                "priority"      : priority,
                "status"        : status,
                "note"          : note,
                "private_note"  : private_note,
                "tags"          : tags,
                "outcome"       : outcome,
				});
		});

        $('#select-notification').click(function(){
            if (selected_notifyedit) {
                selected_notifyedit=false;
                $("#details-notify-edit").slideUp();
				$("#display-status").slideDown();
                document.getElementById("select-notification").innerText = "Create Notification ...";
                $("#select-notification").removeClass("blueborder");
            } else {
                selected_notifyedit=true;
				$("#display-status").slideUp();
                $("#details-notify-edit").slideDown();
                document.getElementById("select-notification").innerText = "Close notification";
                $("#select-notification").addClass("blueborder");
                document.getElementById("select-category-notify").focus();
            }
        });

        $('#submit-notification').click(function(){
            var category=$('#select-category-notify').val();
            var priority=$('#select-priority-notify').val();
            var note=$('#notification-note').val().trim();
            var url=$('#notification-url').val().trim();
			var user_list=[];
			$('input[name="notification-users"]').each(function(){
				if ($(this).is(':checked')) {
					user_list.push($(this).prop('value'));
				}
			});
            user_list = user_list.join(",");
			if ("" == user_list) {
				alert("No users were selected");
				return;
			}
            postCommitAjaxRequest({
                "action"        : 'submit-notification',
                "category"      : category,
                "priority"      : priority,
                "note"          : note,
                "url"           : url,
                "users"         : user_list,
                });
        });

        $('#select-delete').click(function(){
 			var result = confirm("Are you sure?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'submit-trashinvestigation',
					"record_id" : $(this).attr('x-data'),
					});
			}
        });



		/* Set the report link */
		$('#report_link').attr('href',"{% url 'report' request.resolver_match.url_name %}?record_list={{object.id}}");
	});
</script>

{% endblock %}