|
1 | | -{{ $data := "" }} {{ $p := "static/data/csv/keys.csv" }} {{ $excludedColumns := |
2 | | -slice 0 10 11 12 13 14 15 16 17 18 }} {{ if os.FileExists $p }} {{ $opts := dict |
3 | | -"delimiter" "," }} {{ $data = (os.ReadFile $p | transform.Unmarshal $opts) }} {{ |
4 | | -else }} {{ errorf "Unable to get resource %q" $p }} {{ end }} {{ if $data }} {{ |
5 | | -$uniqueCategories := slice }} {{ $stopAddingCategories := false }} {{ range $i, |
6 | | -$header := index $data 1 }} {{ if gt $i 3 }} {{if eq $header "Keychain ID"}} {{ |
7 | | -$stopAddingCategories = true }} {{end}} {{ if not $stopAddingCategories }} {{ if |
8 | | -and (ne (trim $header "") "") (not (in $uniqueCategories $header)) }} {{ |
9 | | -$uniqueCategories = $uniqueCategories | append $header }} {{ end }} {{ end }} {{ |
10 | | -end }} {{end}} {{ range $index, $category := $uniqueCategories }} |
11 | | -<div class="csvtable-div"> |
12 | | - {{ $sectionName := $category | lower }} |
13 | | - {{ $urlPath := "roles" }} |
14 | | - {{ if hasPrefix $sectionName "workspace" }} |
15 | | - {{ $urlPath = "roles/workspace-roles" }} |
16 | | - {{ else if hasPrefix $sectionName "team" }} |
17 | | - {{ $urlPath = "roles/team-roles" }} |
18 | | - {{ else if hasPrefix $sectionName "org" }} |
19 | | - {{ $urlPath = "roles/organization-roles" }} |
20 | | - {{ else if hasPrefix $sectionName "provider" }} |
21 | | - {{ $urlPath = "roles/#provider-admin-role" }} |
22 | | - {{ else }} |
23 | | - {{ $urlPath = print "roles/" $sectionName | urlize }} |
24 | | - {{ end }} |
25 | | - <h2><a href="/cloud/security/{{ $urlPath }}">{{ $category }} Role</a></h2> |
26 | | - <table class="csvtable td-initial"> |
27 | | - <thead> |
28 | | - <tr> |
29 | | - {{ range $i, $col := index $data 1 }} {{ if and (not (in |
30 | | - $excludedColumns $i)) (or (eq $i 0) (ne $i 1) (ne $i 2)) }} {{ if and |
31 | | - (eq $i 1) }} |
32 | | - <th>Permission</th> |
33 | | - {{ else }} {{ if and (eq $i 2) }} |
34 | | - <th>Description</th> |
35 | | - {{ end }}{{ end }} {{ end }} {{ end }} |
36 | | - </tr> |
37 | | - </thead> |
38 | | - <tbody> |
39 | | - {{ range $i, $row := $data }} {{ if gt $i 0 }} {{/* Skip the header row */}} |
40 | | - {{ $hasAccess := false }} {{/* Flag to track if the row has access for the category */}} |
41 | | - {{ $functionValue := "" }} {{/* Variable to hold the Function value */}} |
42 | | - {{ $featureValue := "" }} {{/* Variable to hold the Feature value */}} |
| 1 | +{{ $data := "" }} |
| 2 | +{{ $p := "static/data/csv/keys.csv" }} |
| 3 | +{{ $excludedColumns := slice 0 10 11 12 13 14 15 16 17 18 }} |
43 | 4 |
|
44 | | - {{/* Find the column indices for Category, Function, and Feature */}} |
45 | | - {{ $categoryIndex := -1 }} |
46 | | - {{ $functionIndex := -1 }} |
47 | | - {{ $featureIndex := -1 }} |
48 | | - {{ range $j, $header := index $data 1 }} {{/* Assuming the first row contains headers */}} |
49 | | - {{ if eq $header $category }} {{/* Check if the header matches the current category */}} |
50 | | - {{ $categoryIndex = $j }} |
51 | | - {{ end }} |
52 | | - {{ if eq $header "Function" }} |
53 | | - {{ $functionIndex = $j }} |
54 | | - {{ end }} |
55 | | - {{ if eq $header "Feature" }} |
56 | | - {{ $featureIndex = $j }} |
| 5 | +{{ if os.FileExists $p }} |
| 6 | + {{ $opts := dict "delimiter" "," }} |
| 7 | + {{ $data = (os.ReadFile $p | transform.Unmarshal $opts) }} |
| 8 | +{{ else }} |
| 9 | + {{ errorf "Unable to get resource %q" $p }} |
| 10 | +{{ end }} |
| 11 | + |
| 12 | +{{ if $data }} |
| 13 | + {{ $uniqueCategories := slice }} |
| 14 | + {{ $stopAddingCategories := false }} |
| 15 | + |
| 16 | + {{ range $i, $header := index $data 1 }} |
| 17 | + {{ if gt $i 3 }} |
| 18 | + {{ if eq $header "Keychain ID" }} |
| 19 | + {{ $stopAddingCategories = true }} |
| 20 | + {{ end }} |
| 21 | + |
| 22 | + {{ if not $stopAddingCategories }} |
| 23 | + {{ if and (ne (trim $header "") "") (not (in $uniqueCategories $header)) }} |
| 24 | + {{ $uniqueCategories = $uniqueCategories | append $header }} |
| 25 | + {{ end }} |
| 26 | + {{ end }} |
| 27 | + {{ end }} |
| 28 | + {{ end }} |
| 29 | + |
| 30 | + {{ range $index, $category := $uniqueCategories }} |
| 31 | + <div class="csvtable-div"> |
| 32 | + {{ $sectionName := $category | lower }} |
| 33 | + {{ $urlPath := "roles" }} |
| 34 | + {{ if hasPrefix $sectionName "workspace" }} |
| 35 | + {{ $urlPath = "roles/workspace-roles" }} |
| 36 | + {{ else if hasPrefix $sectionName "team" }} |
| 37 | + {{ $urlPath = "roles/team-roles" }} |
| 38 | + {{ else if hasPrefix $sectionName "org" }} |
| 39 | + {{ $urlPath = "roles/organization-roles" }} |
| 40 | + {{ else if hasPrefix $sectionName "provider" }} |
| 41 | + {{ $urlPath = "roles/#provider-admin-role" }} |
| 42 | + {{ else }} |
| 43 | + {{ $urlPath = print "roles/" $sectionName | urlize }} |
| 44 | + {{ end }} |
| 45 | + <h2><a href="/cloud/security/{{ $urlPath }}">{{ $category }} Role</a></h2> |
| 46 | + <table class="csvtable td-initial"> |
| 47 | + <thead> |
| 48 | + <tr> |
| 49 | + {{ range $i, $col := index $data 1 }} |
| 50 | + {{ if and (not (in $excludedColumns $i)) (or (eq $i 0) (ne $i 1) (ne $i 2)) }} |
| 51 | + {{ if and (eq $i 1) }} |
| 52 | + <th>Permission</th> |
| 53 | + {{ else }} |
| 54 | + {{ if and (eq $i 2) }} |
| 55 | + <th>Description</th> |
| 56 | + {{ end }} |
| 57 | + {{ end }} |
| 58 | + {{ end }} |
| 59 | + {{ end }} |
| 60 | + </tr> |
| 61 | + </thead> |
| 62 | + <tbody> |
| 63 | + {{ range $i, $row := $data }} |
| 64 | + {{ if gt $i 0 }} |
| 65 | + {{/* Skip the header row */}} |
| 66 | + {{ $hasAccess := false }} |
| 67 | + {{/* Flag to track if the row has access for the category */}} |
| 68 | + {{ $functionValue := "" }} |
| 69 | + {{/* Variable to hold the Function value */}} |
| 70 | + {{ $featureValue := "" }} |
| 71 | + {{/* Variable to hold the Feature value */}} |
| 72 | + |
| 73 | + {{/* Find the column indices for Category, Function, and Feature */}} |
| 74 | + {{ $categoryIndex := -1 }} |
| 75 | + {{ $functionIndex := -1 }} |
| 76 | + {{ $featureIndex := -1 }} |
| 77 | + {{ range $j, $header := index $data 1 }} |
| 78 | + {{/* Assuming the first row contains headers */}} |
| 79 | + {{ if eq $header $category }} |
| 80 | + {{/* Check if the header matches the current category */}} |
| 81 | + {{ $categoryIndex = $j }} |
| 82 | + {{ end }} |
| 83 | + {{ if eq $header "Function" }} |
| 84 | + {{ $functionIndex = $j }} |
| 85 | + {{ end }} |
| 86 | + {{ if eq $header "Feature" }} |
| 87 | + {{ $featureIndex = $j }} |
| 88 | + {{ end }} |
| 89 | + {{ end }} |
| 90 | + |
| 91 | + {{/* Check if the row has access for the category */}} |
| 92 | + {{ if and (ge $categoryIndex 0) (or (eq (index $row $categoryIndex) "X") (eq (index $row $categoryIndex) "X*")) }} |
| 93 | + {{ $hasAccess = true }} |
| 94 | + {{ end }} |
| 95 | + {{/* Get the Function and Feature values if the row has access */}} |
| 96 | + {{ if $hasAccess }} |
| 97 | + {{ $functionValue = index $row $functionIndex }} |
| 98 | + {{ $featureValue = index $row $featureIndex }} |
| 99 | + {{ end }} |
| 100 | + |
| 101 | + {{/* Print the row if it has access */}} |
| 102 | + {{ if $hasAccess }} |
| 103 | + <tr> |
| 104 | + <td>{{ $functionValue }} </td> |
| 105 | + <td>{{ $featureValue }}</td> |
| 106 | + </tr> |
| 107 | + {{ end }} |
| 108 | + {{ end }} |
57 | 109 | {{ end }} |
58 | | - {{ end }} |
59 | | - {{/* Check if the row has access for the category */}} |
60 | | - {{ if and (ge $categoryIndex 0) (or (eq (index $row $categoryIndex) "X") (eq (index $row $categoryIndex) "X*")) }} |
61 | | - {{ $hasAccess = true }} |
62 | | - {{ end }} |
63 | | - {{/* Get the Function and Feature values if the row has access */}} |
64 | | - {{ if $hasAccess }} |
65 | | - {{ $functionValue = index $row $functionIndex }} |
66 | | - {{ $featureValue = index $row $featureIndex }} |
67 | | - {{ end }} |
68 | | -{{/* Print the row if it has access */}} |
69 | | - {{ if $hasAccess }} |
70 | | - <tr> |
71 | | - <td>{{ $functionValue }} </td> |
72 | | - <td>{{ $featureValue }}</td> |
73 | | - </tr> |
74 | | - {{end}} |
75 | | - {{ end }} {{ end }} |
76 | | - </tbody> |
77 | | - </table> |
78 | | -</div> |
79 | | -{{ end }} {{ else }} |
80 | | -<p>No data available.</p> |
| 110 | + </tbody> |
| 111 | + </table> |
| 112 | + </div> |
| 113 | + {{ end }} |
| 114 | +{{ else }} |
| 115 | + <p>No data available.</p> |
81 | 116 | {{ end }} |
0 commit comments