summaryrefslogtreecommitdiff
path: root/deps/rabbitmq_management/priv/www/js/tmpl/topic-permissions.ejs
blob: 02f54595169f046707daa36bc8ebe07104401ca5 (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
<div class="section">
  <h2>Topic permissions</h2>
  <div class="hider">
    <h3>Current topic permissions</h3>
    <% if (topic_permissions.length > 0) { %>
    <table class="list">
      <thead>
        <tr>
<% if (mode == 'vhost') { %>
          <th>User</th>
<% } else { %>
          <th>Virtual host</th>
<% } %>
          <th>Exchange</th>
          <th>Write regexp</th>
          <th>Read regexp</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
<%
for (var i = 0; i < topic_permissions.length; i++) {
    var permission = topic_permissions[i];
%>
           <tr<%= alt_rows(i)%>>
<% if (mode == 'vhost') { %>
             <td><%= link_user(permission.user) %></td>
<% } else { %>
             <td><%= link_vhost(permission.vhost) %></td>
<% } %>
             <td><%= fmt_exchange(permission.exchange) %></td>
             <td><%= fmt_string(permission.write) %></td>
             <td><%= fmt_string(permission.read) %></td>
             <td class="c">
               <form action="#/topic-permissions" method="delete" class="confirm">
                 <input type="hidden" name="username" value="<%= fmt_string(permission.user) %>"/>
                 <input type="hidden" name="vhost" value="<%= fmt_string(permission.vhost) %>"/>
                 <input type="hidden" name="exchange" value="<%= fmt_exchange_url(permission.exchange) %>"/>
                 <input type="submit" value="Clear"/>
               </form>
             </td>
           </tr>
           <% } %>
      </tbody>
    </table>
    <% } else { %>
      <p>... no topic permissions ...</p>
    <% } %>

<h3>Set topic permission</h3>
    <form action="#/topic-permissions" method="put">
      <table class="form">
        <tr>
<% if (mode == 'vhost') { %>
          <th>User</th>
          <td>
            <input type="hidden" name="vhost" value="<%= fmt_string(parent.name) %>"/>
            <select name="username">
              <% for (var i = 0; i < users.length; i++) { %>
              <option value="<%= fmt_string(users[i].name) %>"><%= fmt_string(users[i].name) %></option>
              <% } %>
            </select>
          </td>
<% } else { %>
          <th><label>Virtual Host:</label></th>
          <td>
            <input type="hidden" name="username" value="<%= fmt_string(parent.name) %>"/>
            <select name="vhost" class="list-exchanges">
              <% for (var i = 0; i < vhosts.length; i++) { %>
              <option value="<%= fmt_string(vhosts[i].name) %>"><%= fmt_string(vhosts[i].name) %></option>
              <% } %>
            </select>
          </td>
<% } %>
        </tr>
        <tr>
          <th><label>Exchange:</label></th>
          <td>
          <div id='list-exchanges'>
            <%= format('list-exchanges', {'exchanges': exchanges}) %>
          </div>
          </td>
        </tr>
        <tr>
          <th><label>Write regexp:</label></th>
          <td><input type="text" name="write" value=".*"/></td>
        </tr>
        <tr>
          <th><label>Read regexp:</label></th>
          <td><input type="text" name="read" value=".*"/></td>
        </tr>
      </table>
      <input type="submit" value="Set topic permission"/>
    </form>
  </div>
</div>