-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathview_project.html
More file actions
1996 lines (1931 loc) · 133 KB
/
view_project.html
File metadata and controls
1996 lines (1931 loc) · 133 KB
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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{% extends "layouts/sidebar-nav.html" %}
{% import "helpers/snippets.html" as snippet with context %}
{% block before_head %}
{{ super() }}
{% import "helpers/src_macros.html" as macro %}
{{ macro.filehelper(datatables=True,select2=True,apex=True,editor=True,mentions=True) }}
<style>
.breadcrumbs>ul>li+:before {
margin-top: 5px;
}
</style>
{% endblock %}
{%block header%}{%endblock%}
{%block page_header%}{%endblock%}
{%block tenant_btn%}{%endblock%}
{%set is_auditor = project.has_auditor(current_user)%}
{%block content%}
<div class="grid grid-cols-9 gap-8">
<div class="col-span-9">
<div class="lg:flex lg:items-center lg:justify-between">
<div class="min-w-0 flex-1">
<div class="breadcrumbs text-2xl font-bold sm:tracking-tight py-0">
<ul>
<li><a>Home</a></li>
<li><a href="{{url_for("main.projects")}}">Projects</a></li>
<li><a class="capitalize" href="{{url_for("main.view_project",pid=project.id)}}">{{project.name}}</a></li>
<li>
<select class="select text-2xl font-bold text-primary sm:tracking-tight pl-0 focus:border-transparent focus:outline-none tab-select hover:text-secondary">
<option selected value="summary">Summary</option>
<option value="controls">Controls</option>
<option value="policies">Policies</option>
<option value="evidence">Evidence</option>
<option value="matrix">Resp. Matrix</option>
<option value="scratchpad">Scratchpad</option>
<option value="comments">Comments</option>
<option value="report">Report</option>
<option value="findings">Findings</option>
<option value="integrations">Integrations</option>
<option value="settings">Settings</option>
</select>
</li>
</ul>
</div>
</div>
<div class="flex">
<span class="ml-3 hidden sm:block">
<div class="tooltip tooltip-left" data-tip="Generate PDF report"><button class="btn btn-ghost border border-base-300 btn-sm" @click="createReport">Generate Report</button></div>
</span>
<span class="ml-3 hidden sm:block">
<div class="tooltip tooltip-left" data-tip="Refresh data from Server"><button class="format-btn btn btn-sm btn-primary reload-button">Refresh Data</button></div>
</span>
</div>
</div>
<div class="flex flex-row border-b border-base-300 py-3">
<div class="flex gap-x-1 py-1 pr-1 tooltip" data-tip="Framework">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184" /></svg>
<span class="text-sm font-medium uppercase">{{project.framework.name}}</span>
</div>
<div class="flex gap-x-1 py-1 px-1 tooltip" data-tip="Completion">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z" /></svg>
<span class="text-sm font-medium">{{project.progress("complete")}}%</span>
</div>
<div class="flex gap-x-1 py-1 px-1 tooltip" :class="{'hidden': isSidebarOpen}" data-tip="Start Date">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5m-9-6h.008v.008H12v-.008zM12 15h.008v.008H12V15zm0 2.25h.008v.008H12v-.008zM9.75 15h.008v.008H9.75V15zm0 2.25h.008v.008H9.75v-.008zM7.5 15h.008v.008H7.5V15zm0 2.25h.008v.008H7.5v-.008zm6.75-4.5h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V15zm0 2.25h.008v.008h-.008v-.008zm2.25-4.5h.008v.008H16.5v-.008zm0 2.25h.008v.008H16.5V15z" /></svg>
<span class="text-sm font-medium">{{project.simple(project.date_added)}}</span>
</div>
{%if is_auditor%}
<div class="flex gap-x-1 py-1 px-1">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" /></svg>
<span class="text-sm font-medium">Auditor</span>
</div>
{%endif%}
<div class="divider divider-horizontal mx-0"></div>
<div class="flex space-x-2 tabs">
{%for tab in ["summary","controls","policies","evidence","matrix","scratchpad","comments","settings"]%}
<span @click="changeTab('{{tab}}')" id="tab-{{tab}}" class="cursor-pointer rounded-md py-1 px-4 text-sm font-medium hover:bg-base-200 capitalize">{{tab}}</span>
{%endfor%}
<div class="dropdown mb-[2px]">
<label tabindex="0" class="m-1 cursor-pointer rounded-md py-1 px-4 text-sm font-medium hover:bg-base-200">More</label>
<ul tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52">
{%for tab in ["report","findings","integrations"]%}
<li><span @click="changeTab('{{tab}}')" id="tab-{{tab}}" class="cursor-pointer rounded-md py-1 px-4 text-sm font-medium hover:bg-base-200 capitalize">{{tab}}</span></li>
{%endfor%}
</ul>
</div>
</div>
</div>
<div class="flex flex-row rounded-md border-b border-r border-l border-base-300 p-3">
<div class="flex gap-x-1 py-1 tooltip font-medium text-sm" data-tip="Quick filters for the controls" :class="{'hidden': isSidebarOpen}">
Quick Filters
</div>
<div class="divider divider-horizontal mx-0" :class="{'hidden': isSidebarOpen}"></div>
<div class="flex gap-x-4 tabs">
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&owner={{current_user.email}}">Controls I Own</a>
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&operator={{current_user.email}}">Controls I Operate</a>
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=12">InfoSec: Not Started</a>
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=13">InfoSec: In Progress</a>
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=14">InfoSec: Action</a>
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=15">Auditor: Ready for Auditor</a>
<a class="btn btn-xs btn-ghost border border-base-300" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=16">Complete</a>
</div>
</div>
</div>
</div>
<div id="page-div">
<div class="grid grid-cols-9 gap-4" id="alert-div"></div>
<div class="grid grid-cols-9 gap-4" id="summary-div"></div>
<div class="grid grid-cols-9 gap-4 mt-4 pb-10" id="card-div">
<div class="col-span-9 mx-auto mt-10"><div class="justify-center flex" role="status"><svg aria-hidden="true" class="mr-2 w-8 h-8 animate-spin fill-blue-600 text-gray-200" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg><span class="sr-only">Loading...</span></div></div>
</div>
</div>
</div>
<input type="checkbox" id="memberModal" class="modal-toggle" />
<div class="modal">
<div class="modal-box w-8/12 max-w-4xl">
<label for="memberModal" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<div id="memberModalBody">
<div class="grid grid-cols-6 gap-6"><div class="col-span-6"><label class="block font-medium mb-2">Add Members to Project</label><select class="input-members w-full" name="members[]" multiple="multiple"/></select></div></div>
</div>
<div class="modal-action">
<button @click="addMembers" class="btn btn-primary">Save</button>
</div>
</div>
</div>
<input type="checkbox" id="ownerModal" class="modal-toggle" />
<div class="modal">
<div class="modal-box">
<label for="ownerModal" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<div id="ownerModalBody"></div>
<div class="modal-action">
<button data-id="" class="btn btn-primary save-owner-btn">Save</button>
</div>
</div>
</div>
<input type="checkbox" id="ownerPolicyModal" class="modal-toggle" />
<div class="modal">
<div class="modal-box">
<label for="ownerPolicyModal" class="btn btn-sm btn-circle absolute right-2 top-2">✕</label>
<div id="ownerPolicyModalBody"></div>
<div class="modal-action">
<button data-id="" class="btn btn-primary save-policy-owner-btn">Save</button>
</div>
</div>
</div>
<input type="checkbox" id="control-modal" class="modal-toggle" />
<label for="control-modal" class="modal cursor-pointer">
<label class="modal-box relative w-11/12 max-w-5xl" for="">
<div class="flex justify-between">
<div>
<h2 id="control-modal-title" class="card-title mb-2 capitalize"></h2>
</div>
<div>
<span id="control-modal-date" class="text-xs">?</span>
</div>
</div>
<div class="grid grid-cols-6 gap-4">
<div class="col-span-6" id="applicable-control"></div>
<div class="col-span-3">
<div class="card border border-base-300">
<div class="card-body p-5">
<div class="card-title justify-between">
<h2 class="card-title text-lg">Complete</h2>
<div id="complete-modal-icon"></div>
</div>
</div>
</div>
</div>
<div class="col-span-3">
<div class="card border border-base-300">
<div class="card-body p-5">
<div class="card-title justify-between">
<h2 class="card-title text-lg">Applicable</h2>
<div id="applicable-modal-icon"></div>
</div>
</div>
</div>
</div>
<div class="col-span-4">
<div class="overflow-hidden shadow sm:rounded-lg"><div class="px-4 py-5 sm:px-6"><h3 class="text-lg font-medium leading-6">Control Details</h3></div><div class="border-t border-base-300"><dl id="control-modal-details"></dl></div></div>
</div>
<div class="col-span-2 m-auto flex flex-col">
<div class="mx-auto" id="control-modal-completion"></div>
<div class="mx-auto mt-2 text-sm font-semibold">Progress of control</div>
</div>
</div>
<div class="modal-action">
<a id="view-control" href="" class="btn btn-primary">View</a>
</div>
</label>
</label>
<input type="checkbox" id="policy-modal" class="modal-toggle" />
<label for="policy-modal" class="modal cursor-pointer">
<label class="modal-box relative w-11/12 max-w-5xl" for="">
<div class="flex justify-between">
<div>
<p class="font-semibold text-primary text-sm" id="policy-subtitle"></p>
<h2 class="card-title mb-5">Policy</h2>
</div>
<div>
<span class="text-xs" id="policy-date"></span>
</div>
</div>
<div class="grid grid-cols-6 gap-6">
<div class="col-span-6 sm:col-span-3">
<label class="block text-sm font-medium mb-2">Name</label>
<span id="tenant-select-div" class=""></span>
</div>
<div class="col-span-6 sm:col-span-3">
<label class="block text-sm font-medium mb-2"></label>
<span id="framework-select-div" class=""></span>
</div>
</div>
<div class="modal-action">
<a id="view-policy" href="#" class="btn btn-primary">View</a>
</div>
</label>
</label>
<input type="checkbox" id="owner-modal" class="modal-toggle" />
<label for="owner-modal" class="modal cursor-pointer">
<label class="modal-box relative w-11/12 max-w-5xl" for="">
<div class="flex justify-between">
<div>
<p class="font-semibold text-primary text-sm"></p>
<h2 id="owner-modal-title" class="card-title mb-5">Owner</h2>
</div>
</div>
<div class="grid grid-cols-6 gap-6">
<div class="col-span-6">
<div class="">
<table class="table w-full">
<!-- head -->
<thead>
<tr>
<th class="w-1"></th>
<th>Name</th>
<th class="w-1">View</th>
</tr>
</thead>
<tbody id="owner-modal-body"></tbody>
</table>
</div>
</div>
</div>
</label>
</label>
<input type="checkbox" id="operator-modal" class="modal-toggle" />
<label for="operator-modal" class="modal cursor-pointer">
<label class="modal-box relative w-11/12 max-w-5xl" for="">
<div class="flex justify-between">
<div>
<p class="font-semibold text-primary text-sm"></p>
<h2 id="operator-modal-title" class="card-title mb-5">Operator</h2>
</div>
</div>
<div class="grid grid-cols-6 gap-6">
<div class="col-span-6">
<div class="">
<table class="table w-full">
<!-- head -->
<thead>
<tr>
<th class="w-1"></th>
<th>Name</th>
<th class="w-1">View</th>
</tr>
</thead>
<tbody id="operator-modal-body"></tbody>
</table>
</div>
</div>
</div>
</label>
</label>
{%endblock%}
{%block extrajs%}
<script>
function loadUsers(reload=false) {
var users = localStorage.getItem("tenant-users-{{project.tenant_id}}");
if (reload || !users) {
console.log("Pulling users from API")
$.ajax({
type: "GET",
url: `/api/v1//tenants/{{project.tenant_id}}/users`,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
localStorage.setItem('tenant-users-{{project.tenant_id}}', JSON.stringify(data));
},
error: function(errMsg) {
toast(errMsg["responseJSON"]["message"],"error")
return(errMsg);
}
})
}
}
</script>
<script>
function populateOwnerModal(id, owner, operator){
$("#ownerModalBody").html('<div class="col-span-9 mx-auto mt-10"><div class="justify-center flex" role="status"><svg aria-hidden="true" class="mr-2 w-8 h-8 animate-spin fill-blue-600 text-gray-200" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg><span class="sr-only">Loading...</span></div></div>')
document.getElementById('ownerModal').checked = true;
var users = JSON.parse(localStorage.getItem("tenant-users-{{project.tenant_id}}"));
$(".save-owner-btn").data("id", id)
ownerSelect = '<label class="block text-sm font-medium mb-2">Owner of the Control</label><select class="select select-md w-full max-w-xs select-bordered owner-id"><option value="empty">Select an Owner</option>'
for(var user in users) {
if (users[user].email === owner) {
ownerSelect+=`<option value="${users[user].id}" selected>${users[user].email}</option>`
} else {
ownerSelect+=`<option value="${users[user].id}">${users[user].email}</option>`
}
}
ownerSelect+='</select>'
operatorSelect = '<label class="block text-sm font-medium mb-2 mt-5">Operator of the Control</label><select class="select select-md w-full max-w-xs select-bordered operator-id"><option value="empty">Select an Operator</option>'
for(var user in users) {
if (users[user].email === operator) {
operatorSelect+=`<option value="${users[user].id}" selected>${users[user].email}</option>`
} else {
operatorSelect+=`<option value="${users[user].id}">${users[user].email}</option>`
}
}
operatorSelect+='</select>'
$("#ownerModalBody").html(ownerSelect);
$("#ownerModalBody").append(operatorSelect);
}
function populatePolicyModal(id, email, owner=true){
$("#ownerPolicyModalBody").html('<div class="col-span-9 mx-auto mt-10"><div class="justify-center flex" role="status"><svg aria-hidden="true" class="mr-2 w-8 h-8 animate-spin fill-blue-600 text-gray-200" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg><span class="sr-only">Loading...</span></div></div>')
document.getElementById('ownerPolicyModal').checked = true;
var users = JSON.parse(localStorage.getItem("tenant-users-{{project.tenant_id}}"));
$(".save-policy-owner-btn").data("id", id)
$(".save-policy-owner-btn").data("type", owner?"owner":"reviewer")
if (owner) {
ownerSelect = '<label class="block text-sm font-medium mb-2">Owner of the Policy</label><select class="select select-md w-full max-w-xs select-bordered owner-policy-id"><option value="empty">Select an Owner</option>'
} else {
ownerSelect = '<label class="block text-sm font-medium mb-2">Reviewer of the Policy</label><select class="select select-md w-full max-w-xs select-bordered owner-policy-id"><option value="empty">Select an Reviewer</option>'
}
for(var user in users) {
if (users[user].email === email) {
ownerSelect+=`<option value="${users[user].id}" selected>${users[user].email}</option>`
} else {
ownerSelect+=`<option value="${users[user].id}">${users[user].email}</option>`
}
}
$("#ownerPolicyModalBody").html(ownerSelect);
}
</script>
<script>
function saveScratchPad(showToast=true) {
var data = {"data":tinymce.get("scratchpad-editor").getContent()}
$.ajax({
type: "PUT",
url: `/api/v1/projects/{{project.id}}/scratchpad`,
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
$("#save-notes-btn").html("Save")
$("#save-notes-btn").removeClass("btn-warning")
$("#save-notes-btn").addClass("btn-primary")
return(data)
},
error: function(errMsg) {
// we autosave when a user clicks away but some users
// dont have access to save, so we hide the error
if (showToast) {
toast(errMsg["responseJSON"]["message"],"error")
}
return(errMsg);
}
})
}
function createReport() {
toast("Working on it...", "warning")
$.ajax({
type: "POST",
url: `/api/v1/projects/{{project.id}}/reports`,
contentType: "application/json; charset=utf-8",
success: function(data){
toast("Generated report")
window.open(`/projects/{{project.id}}/reports/${data.name}`, '_blank').focus();
return(data)
},
error: function(errMsg) {
toast("Hmm.. we were unable to create a report","error")
return(errMsg);
}
})
}
function blurOwnerFilter(e) {
var owner = e.target.value;
var operator = $('.operator-filter').val();
var filter = $('.controls-filter').val();
var grouping = $('.grouping-filter').val();
var queryParams = new URLSearchParams(window.location.search);
queryParams.set("filter", filter);
queryParams.set("grouping", grouping);
if (owner) {
queryParams.set("owner", owner);
} else {
queryParams.delete("owner");
}
if (operator) {
queryParams.set("operator", operator);
} else {
queryParams.delete("operator");
}
history.replaceState(null, null, "?"+queryParams.toString());
if (grouping === "subcontrols") {
loadControls()
} else {
loadControls(reload=true)
}
}
function blurOperatorFilter(e) {
var operator = e.target.value;
var owner = $('.owner-filter').val();
var filter = $('.controls-filter').val();
var grouping = $('.grouping-filter').val();
var queryParams = new URLSearchParams(window.location.search);
queryParams.set("filter", filter);
queryParams.set("grouping", grouping);
if (owner) {
queryParams.set("owner", owner);
} else {
queryParams.delete("owner");
}
if (operator) {
queryParams.set("operator", operator);
} else {
queryParams.delete("operator");
}
history.replaceState(null, null, "?"+queryParams.toString());
if (grouping === "subcontrols") {
loadControls()
} else {
loadControls(reload=true)
}
}
$(document).on('change', '.controls-filter', function() {
var filter = $(this).val();
var grouping = $('.grouping-filter').val();
var queryParams = new URLSearchParams(window.location.search);
queryParams.set("filter", filter);
queryParams.set("grouping", grouping);
history.replaceState(null, null, "?"+queryParams.toString());
if (grouping === "subcontrols") {
loadControls()
} else {
loadControls(reload=true)
}
});
$(document).on('change', '.grouping-filter', function() {
var grouping = $(this).val();
var filter = "1";
var queryParams = new URLSearchParams(window.location.search);
queryParams.set("grouping", grouping);
queryParams.set("filter", filter);
//queryParams.delete("filter");
history.replaceState(null, null, "?"+queryParams.toString());
loadControls(reload=true)
});
function changeTab(tab) {
$(".tabs span").removeClass("bg-base-200");
$(`#tab-${tab}`).addClass("bg-base-200")
loadPageElements(tab)
}
$(document).on('change', '.tab-select', function() {
var tab = $(this).val();
$(".tabs span").removeClass("bg-base-200");
$(`#tab-${tab}`).addClass("bg-base-200")
loadPageElements(tab)
});
$(document).on('click', '.reload-button', function() {
localStorage.removeItem("project-controls-{{project.uuid}}")
localStorage.removeItem("tenant-users-{{project.tenant_id}}")
var tab = $(".tab-select").val();
loadUsers(reload=true)
loadPageElements(tab)
});
$(document).on('click', '.remove-control-filter', function() {
var queryParams = new URLSearchParams(window.location.search);
queryParams.delete("grouping")
queryParams.delete("filter")
queryParams.delete("owner")
queryParams.delete("operator")
history.replaceState(null, null, "?"+queryParams.toString());
loadControls(reload=true)
});
function toggleScratchPad(e=false) {
if (!e || !e.target.checked) {
$(".tox-editor-header").addClass("invisible")
$(".tox-editor-header").addClass("!h-0")
tinymce.activeEditor.mode.set("readonly");
} else {
$(".tox-editor-header").removeClass("invisible")
$(".tox-editor-header").removeClass("!h-0")
tinymce.activeEditor.mode.set("design");
}
}
function loadScratchPad() {
{%if is_auditor and not project.can_auditor_read_scratchpad%}
toast("You lack permissions to view the scratchpad.","warning")
$("#card-div").html('<div class="col-span-9 mx-auto mt-10 flex flex-row">Insufficient Permissions<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 ml-2"><path stroke-linecap="round" stroke-linejoin="round" d="M15.182 16.318A4.486 4.486 0 0012.016 15a4.486 4.486 0 00-3.198 1.318M21 12a9 9 0 11-18 0 9 9 0 0118 0zM9.75 9.75c0 .414-.168.75-.375.75S9 10.164 9 9.75 9.168 9 9.375 9s.375.336.375.75zm-.375 0h.008v.015h-.008V9.75zm5.625 0c0 .414-.168.75-.375.75s-.375-.336-.375-.75.168-.75.375-.75.375.336.375.75zm-.375 0h.008v.015h-.008V9.75z" /></svg></div>')
return
{%endif%}
$("#card-div").html('<div class="col-span-9 mx-auto mt-10"><div class="justify-center flex" role="status"><svg aria-hidden="true" class="mr-2 w-8 h-8 animate-spin fill-blue-600 text-gray-200" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg><span class="sr-only">Loading...</span></div></div>')
$.ajax({
type: "GET",
url: "/api/v1/projects/{{project.id}}/scratchpad",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
$("#card-div").html(`<div class="col-span-9">
<div class="mb-4 justify-between flex">
<div>
<h1 class="text-2xl font-bold">Scratchpad</h1>
<p class="text-sm">Use this place to document any details about the project or general notes and updates. {%if project.can_auditor_read_scratchpad%}The auditor <b>can read</b> the scratchpad.{%else%} The auditor <b>can not read</b> the scratchpad.{%endif%}</p>
</div>
<div class="gap-x-2 flex flex-row">
{%if not is_auditor or project.can_auditor_write_scratchpad%}<div class="mt-1"><input @change="toggleScratchPad" type="checkbox" class="toggle toggle-primary"/></div>{%endif%}
<button id="save-notes-btn" @click="saveScratchPad" class="btn btn-primary btn-sm">Save</button>
</div>
</div>
<div id="scratchpad-editor" class="w-full">${data["notes"] || ""}</div>
</div>`);
tinymce.remove('#scratchpad-editor');
var contextEditor = tinymce.init({
//skin: 'snow',
//icons: 'thin',
//content_style: 'body { margin: 2rem 10%; }',
setup: (editor) => {
editor.on('init', (e) => {
$(".tox-editor-header").addClass("invisible")
$(".tox-editor-header").addClass("!h-0")
});
editor.on('keyup', (e) => {
$("#save-notes-btn").html("Please Save")
$("#save-notes-btn").removeClass("btn-primary")
$("#save-notes-btn").addClass("btn-warning")
});
},
selector: '#scratchpad-editor',
statusbar: false,
promotion: false,
readonly: true,
{%if is_auditor and not project.can_auditor_write_scratchpad%}
menubar: false,
toolbar: false,
{%else%}
plugins: "preview fullscreen searchreplace table codesample lists advlist variable link",
toolbar1: "bold italic strikethrough forecolor backcolor | fontfamily fontsize blocks | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat undo redo"
{%endif%}
});
},
error: function(errMsg) {
toast(errMsg["responseJSON"]["message"],"error")
}
})
}
function addCommentToDiv(comment) {
user_id = {{current_user.id}};
if (user_id === comment.author_id) {
delete_str = `<div class="dropdown dropdown-end"><label tabindex="0" class="btn btn-sm btn-ghost"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z"></path></svg></label><ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52 text-error"><li><a @click="deleteComment(${comment.id})">Delete</a></li></ul></div>`
} else {
delete_str = ""
}
var record = `
<article id="comment-${comment.id}" class="py-6 mb-6 rounded-lg border-b border-base-200">
<footer class="flex justify-between items-center mb-2">
<div class="flex items-center text-sm">
<div class="avatar placeholder mr-2"><div class="bg-neutral-focus text-neutral-content rounded-full w-6"><span class="text-xs uppercase">${comment.author_email[0]}</span></div></div>${comment.author_email}
<p class="inline-flex items-center mr-3 text-sm"></p>
<p class="text-xs font-semibold"><time pubdate="">${comment.date_added}</time></p>
</div>${delete_str}
</footer>
<p class="">${comment.message}</p>
</article>
`
$("#comments").prepend(record)
}
function deleteComment(id) {
$.ajax({
type: "DELETE",
url: `/api/v1/projects/{{project.id}}/comments/${id}`,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
$(`#comment-${id}`).remove()
toast("Deleted comment")
return(data)
},
error: function(errMsg) {
return(errMsg);
}
})
}
function saveComment(e) {
var value = document.getElementById("comment").value;
if (!value) {
return
}
$.ajax({
type: "POST",
url: `/api/v1/projects/{{project.id}}/comments`,
data: JSON.stringify({"data":value}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
addCommentToDiv(data)
document.getElementById("comment").value = ""
toast("Added comment")
loadComments()
return(data)
},
error: function(errMsg) {
toast(errMsg["responseJSON"]["message"],"error")
return(errMsg);
}
})
}
function loadReport() {
$("#card-div").html('<div class="col-span-9 mx-auto mt-10 flex flex-row">Coming Soon!</div>');
return
}
function loadComments() {
{%if is_auditor and not project.can_auditor_read_comments%}
toast("You lack permissions to view the comments.","warning")
$("#card-div").html('<div class="col-span-9 mx-auto mt-10 flex flex-row">Insufficient Permissions<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 ml-2"><path stroke-linecap="round" stroke-linejoin="round" d="M15.182 16.318A4.486 4.486 0 0012.016 15a4.486 4.486 0 00-3.198 1.318M21 12a9 9 0 11-18 0 9 9 0 0118 0zM9.75 9.75c0 .414-.168.75-.375.75S9 10.164 9 9.75 9.168 9 9.375 9s.375.336.375.75zm-.375 0h.008v.015h-.008V9.75zm5.625 0c0 .414-.168.75-.375.75s-.375-.336-.375-.75.168-.75.375-.75.375.336.375.75zm-.375 0h.008v.015h-.008V9.75z" /></svg></div>')
return
{%endif%}
$("#card-div").html('<div class="col-span-9 mx-auto mt-10"><div class="justify-center flex" role="status"><svg aria-hidden="true" class="mr-2 w-8 h-8 animate-spin fill-blue-600 text-gray-200" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg><span class="sr-only">Loading...</span></div></div>')
$.ajax({
type: "GET",
url: "/api/v1/projects/{{project.id}}/comments",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
$("#card-div").html(`<div class="col-span-9">
<div class="mb-4 justify-between flex">
<div>
<h1 class="text-2xl font-bold">Comments<span id="comment-count" class="ml-2"></span></h1>
<p class="text-sm">Comments are used to discuss generals topics about the project. {%if project.can_auditor_read_comments%}The auditor <b>can read</b> the comments.{%else%} The auditor <b>can not read</b> the comments.{%endif%}</p>
</div>
{%if not auditor or project.project.can_auditor_write_comments%}
<div class="my-auto flex justify-between gap-x-2">
<button @click="saveComment" class="btn btn-sm btn-primary">Send</button>
</div>
{%endif%}
</div>
<div class="mb-5">
<textarea id="comment" rows="4" class="textarea textarea-bordered w-full text-sm" placeholder="Write a comment..." required=""></textarea>
<div class=" h-[calc(100vh-500px)] overflow-auto px-3" id="comments"></div>
</div>
</div>`)
$("#comments").html("")
$("#comment-count").html(`(${data.length})`)
if (data) {
$("#comments-title").html(`(${data.length})`)
}
for (var comment in data) {
addCommentToDiv(data[comment])
}
mention_options = [];
var users = JSON.parse(localStorage.getItem("tenant-users-{{project.tenant_id}}"));
for(user in users) {
mention_options.push({key:users[user].email, value:users[user].username})
}
var tribute = new Tribute({values:mention_options});
tribute.attach(document.getElementById("comment"));
},
error: function(errMsg) {
toast(errMsg["responseJSON"]["message"],"error")
}
})
}
function loadSummary() {
$("#summary-div").html("");
var url = new URL(location.protocol + '//' + location.host + "/api/v1/projects/{{project.id}}?review-summary=true");
var summary_alert = `
<div class="alert alert-primary shadow-sm border border-base-300 rounded-md">
<div>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current flex-shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span>Get started by <a class="underline text-primary" href="{{url_for("main.view_project",pid=project.id,tab='controls')}}">viewing the controls in your project.</a> Add members & auditors to your project under <a class="underline text-primary" href="{{url_for("main.view_project",pid=project.id,tab='settings')}}">settings.</a> You can also view the responsibilities for each control <a class="underline text-primary" href="{{url_for("main.view_project",pid=project.id,tab='matrix')}}">under the matrix.</a> </span>
</div>
</div>
`
$("#card-div").html('<div class="col-span-9 mx-auto mt-10"><div class="justify-center flex" role="status"><svg aria-hidden="true" class="mr-2 w-8 h-8 animate-spin fill-blue-600 text-gray-200" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg><span class="sr-only">Loading...</span></div></div>')
$.ajax({
type: "GET",
url: url.toString(),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){
$("#card-div").html("");
var complete_options = {
series: [100-data.completion_progress,data.completion_progress],
legend: {
show: false
},
dataLabels: {
enabled: false
},
chart: {
type: 'donut',
height: 200
//redrawOnParentResize: true
},
plotOptions: {
pie: {
donut: {
labels: {
show: true,
value:{
offsetY: -8,
color:'#6b6a6e'
},
total: {
show: true,
label: '',
formatter: () => `${data.completion_progress}%`
}
}
}
}
},
labels: ['Uncomplete', 'Complete'],
fill:{colors:['#f3f4f6', '#4ade80']},
responsive: [{
breakpoint: 300,
options: {
chart: {
width: 100
}
}
}]
};
var implemented_options = {
series: [100-data.implemented_progress,data.implemented_progress],
legend: {
show: false
},
dataLabels: {
enabled: false
},
chart: {
type: 'donut',
height: 200
//redrawOnParentResize: true
},
plotOptions: {
pie: {
donut: {
labels: {
show: true,
value:{
offsetY: -8,
color:'#6b6a6e'
},
total: {
show: true,
label: '',
formatter: () => `${data.implemented_progress}%`
}
}
}
}
},
labels: ['Uncomplete', 'Complete'],
fill:{colors:['#f3f4f6', '#4ade80']},
responsive: [{
breakpoint: 300,
options: {
chart: {
width: 100
}
}
}]
};
var evidence_options = {
series: [100-data.evidence_progress,data.evidence_progress],
legend: {
show: false
},
dataLabels: {
enabled: false
},
chart: {
type: 'donut',
height: 200
//redrawOnParentResize: true
},
plotOptions: {
pie: {
donut: {
labels: {
show: true,
value:{
offsetY: -8,
color:'#6b6a6e'
},
total: {
show: true,
label: '',
formatter: () => `${data.evidence_progress}%`
}
}
}
}
},
labels: ['Uncomplete', 'Complete'],
fill:{colors:['#f3f4f6', '#4ade80']},
responsive: [{
breakpoint: 300,
options: {
chart: {
width: 100
}
}
}]
};
if (data.review_summary["total"]) {
var review_complete = Number(parseFloat(((data.review_summary["complete"]||0)/data.review_summary["total"])*100).toFixed(2));
} else {
var review_complete = 0;
}
var review_options = {
series: [100-review_complete,review_complete],
legend: {
show: false
},
dataLabels: {
enabled: false
},
chart: {
type: 'donut',
height: 200
//redrawOnParentResize: true
},
plotOptions: {
pie: {
donut: {
labels: {
show: true,
value:{
offsetY: -8,
color:'#6b6a6e'
},
total: {
show: true,
label: '',
formatter: () => `${review_complete}%`
}
}
}
}
},
labels: ['Uncomplete', 'Complete'],
fill:{colors:['#f3f4f6', '#4ade80']},
responsive: [{
breakpoint: 300,
options: {
chart: {
width: 100
}
}
}]
};
$("#card-div").append(`<div class="col-span-9 mb-2">${summary_alert}</div>`)
$("#card-div").append(`<div class="grid grid-cols-8 col-span-full gap-x-4">
<div class="col-span-2"><div class="card border border-base-300"><div class="p-5"><h2 class="card-title capitalize text-lg"><div class="tooltip" data-tip="Progress of your project completion">Complete Progress</div></h2><div class="text-center"><div id="complete-progress"></div></div></div></div></div>
<div class="col-span-2"><div class="card border border-base-300"><div class="p-5"><h2 class="card-title capitalize text-lg"><div class="tooltip" data-tip="Progress of controls that are implemented">Implemented Progress</div></h2><div class="text-center"><div id="implemented-progress"></div></div></div></div></div>
<div class="col-span-2"><div class="card border border-base-300"><div class="p-5"><h2 class="card-title capitalize text-lg"><div class="tooltip" data-tip="Progress of evidence collected for controls">Evidence Progress</div></h2><div class="text-center"><div id="evidence-progress"></div></div></div></div></div>
<div class="col-span-2"><div class="card border border-base-300"><div class="p-5"><h2 class="card-title capitalize text-lg"><div class="tooltip" data-tip="Progress between InfoSec and Auditor">Review Progress</div></h2><div class="text-center"><div id="review-progress"></div></div></div></div></div>
</div>`)
var auditor_alert = "";
if (data.auditors === undefined || data.auditors.length == 0) {
var auditor_alert = `<div class="alert shadow-sm mb-2"><div><span>Please <a class="underline text-primary" href="/projects/{{project.id}}?tab=settings">add an auditor</a> to your project.</span></div></div>`;
}
$("#card-div").append(`<div class="grid grid-cols-6 col-span-full gap-x-4">
<div class="col-span-3">
<div class="card border border-base-300">
<div class="card-body">
<div class="card-title mb-4 justify-between">
<h2 class="card-title">InfoSec Summary</h2>
<div>
<a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls" class="btn btn-sm btn-ghost border border-base-300">View Controls<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 ml-2"><path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" /></svg></a>
</div>
</div>
<div class="font-medium text-md">
<div class="overflow-x-auto">
<table class="table w-full">
<thead>
<tr>
<th>Metric</th>
<th># of Controls</th>
<th>View</th>
</tr>
</thead>
<tbody>
<tr>
<td><div class="tooltip tooltip-right" data-tip="Control has not been started">Not Started</div></td>
<td>${data.review_summary["not started"]||0}</td>
<td><a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=12" class="btn btn-sm btn-ghost"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75" /></svg></a></td>
</tr>
<tr>
<td><div class="tooltip tooltip-right" data-tip="InfoSec team is working on the control">InfoSec Action</div></td>
<td>${data.review_summary["infosec action"]||0}</td>
<td><a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=13" class="btn btn-sm btn-ghost"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75" /></svg></a></td>
</tr>
<tr>
<td><div class="tooltip tooltip-right" data-tip="Auditor says that Action is required from you">Action Required</div></td>
<td>${data.review_summary["action required"]||0}</td>
<td><a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=14" class="btn btn-sm btn-ghost"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75" /></svg></a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-span-3">
<div class="card border border-base-300">
<div class="card-body">
<div class="card-title mb-4 justify-between">
<h2 class="card-title">Auditor Summary</h2>
<div>
<a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls" class="btn btn-sm btn-ghost border border-base-300">View Controls<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 ml-2"><path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" /></svg></a>
</div>
</div>
${auditor_alert}
<div class="font-medium text-md">
<div class="overflow-x-auto">
<table class="table w-full">
<thead>
<tr>
<th>Metric</th>
<th># of Controls</th>
<th>View</th>
</tr>
</thead>
<tbody>
<tr>
<td><div class="tooltip tooltip-right" data-tip="Control is waiting for the auditor to review">Ready for Auditor</div></td>
<td>${data.review_summary["ready for auditor"]||0}</div></td>
<td><a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=15" class="btn btn-sm btn-ghost"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75" /></svg></a></td>
</tr>
<tr>
<td><div class="tooltip tooltip-right" data-tip="Auditor has marked the review as complete">Complete</div></td>
<td>${data.review_summary["complete"]||0}</td>
<td><a target="_blank" rel="noopener noreferrer" href="/projects/{{project.id}}?tab=controls&grouping=subcontrols&filter=16" class="btn btn-sm btn-ghost"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75" /></svg></a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>`);
$("#card-div").append(`
<div class="col-span-9"><div class="overflow-hidden shadow sm:rounded-lg border border-base-200"><div class="px-4 py-6 sm:px-6"><h3 class="text-lg font-medium leading-6">Project Details</h3><p class="mt-1 max-w-2xl text-sm">Overview of your project details and status</p></div><div class="border-t border-base-300"><div class="grid grid-cols-9 px-6 py-5 gap-y-8">
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Name</strong><span class="text-sm capitalize">${data.name}</span></div></div>
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Tenant</strong><span class="text-sm capitalize">${data.tenant}</span></div></div>
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Framework</strong><a href="/frameworks/${data.framework}" class="text-sm uppercase text-primary bg-base-200 rounded-full py-1 px-3 w-fit">${data.framework}</a></div></div>
<div class="col-span-9"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Description</strong><span class="text-sm rounded-md border border-base-200 p-4 mt-2">${data.description}</span></div></div>
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Owner</strong><span class="text-sm">${data.owner}</span></div></div>
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Controls</strong><span class="text-sm">${data.total_controls}</span></div></div>
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Policies</strong><span class="text-sm">${data.total_policies}</span></div></div>
<div class="col-span-3"><div class="flex flex-col"><strong class="font-semibold text-primary text-sm">Creation</strong><span class="text-sm">${data.date_added}</span></div></div>
</div></div></div></div>`);
$("#project-details").append(`<div class="px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"><dt class="text-sm font-medium">Name</dt><dd class="mt-1 text-sm sm:col-span-2 sm:mt-0">${data.name}</dd></div>`)