Bug 29859: Use iterator instead of as_list
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / apikeys.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE Asset %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>API Keys &rsaquo; Patrons &rsaquo; Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 </head>
9 <body id="pat_apikeys" class="pat">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'patron-search.inc' %]
12
13 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
14     <ol>
15         <li>
16             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
17         </li>
18         <li>
19             <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
20         </li>
21         <li>
22             <a href="#" aria-current="page">
23                 API Keys for [% INCLUDE 'patron-title.inc' %]
24             </a>
25         </li>
26     </ol>
27 </nav>
28
29 <div class="main container-fluid">
30     <div class="row">
31         <div class="col-sm-10 col-sm-push-2">
32             <main>
33
34                 [% INCLUDE 'members-toolbar.inc' %]
35
36                 <h1>API keys for [% INCLUDE 'patron-title.inc' %]</h1>
37
38             [% IF fresh_api_key %]
39                 [%# A fresh api key was generated, display the secret, only once %]
40                 <div class="rows">
41                     <span class="alert">Make sure to copy your API secret now. You won’t be able to see it again!</span>
42                     <ol>
43                         <li>
44                             <span class="label">Description: </span>
45                             [% fresh_api_key.description | html %]
46                         </li>
47                         <li>
48                             <span class="label">Client ID: </span>
49                             [% fresh_api_key.client_id | html %]
50                         </li>
51                         <li>
52                             <span class="label">Secret: </span>
53                             [% fresh_api_key.plain_text_secret | html %]
54                         </li>
55                     </ol>
56                 </div>
57             [% END %]
58
59                 <form id="add-api-key" action="/cgi-bin/koha/members/apikeys.pl" method="post" style="display:none">
60                     <input type="hidden" name="patron_id" value="[% patron.id | html %]" />
61                     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
62                     <input type="hidden" name="op" value="generate" />
63                     <fieldset class="brief">
64                         <legend>Generate new client id/secret pair</legend>
65                         <ol>
66                             <li>
67                                 <label for="description">Description: </label>
68                                 <input type="text" name="description" />
69                                 <input type="submit" value="Save" />
70                                 <a href="#" class="cancel toggle_element" data-element="#add-api-key">Cancel</a>
71                             </li>
72                         </ol>
73                     </fieldset>
74                 </form>
75
76                 <div id="keys">
77                     [% IF api_keys.count %]
78                         <p>
79                             <button class="btn btn-default toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new client id/key pair</button>
80                         </p>
81                         <table>
82                             <thead>
83                                 <tr>
84                                     <th>Description</th>
85                                     <th>Client ID</th>
86                                     <th>Active</th>
87                                     <th class="noExport">Actions</th>
88                                 </tr>
89                             </thead>
90                             <tbody>
91                                 [% FOREACH key IN api_keys %]
92                                     <tr>
93                                         <td>[% key.description | html %]</td>
94                                         <td>[% key.client_id | html %]</td>
95                                         <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
96                                         <td>
97                                             <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
98                                                 <input type="hidden" name="patron_id" value="[% patron.id | html %]" />
99                                                 <input type="hidden" name="key" value="[% key.id | html %]" />
100                                                 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
101                                                 <input type="hidden" name="op" value="delete" />
102                                                 <button class="btn btn-default btn-xs delete" type="submit"><i class="fa fa-trash"></i> Delete</button>
103                                             </form>
104                                             <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
105                                                 <input type="hidden" name="patron_id" value="[% patron.id | html %]" />
106                                                 <input type="hidden" name="key" value="[% key.id | html %]" />
107                                                 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
108                                                 [% IF key.active %]
109                                                     <input type="hidden" name="op" value="revoke" />
110                                                     <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
111                                                 [% ELSE %]
112                                                     <input type="hidden" name="op" value="activate" />
113                                                     <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-play"></i> Activate</button>
114                                                 [% END %]
115                                             </form>
116                                         </td>
117                                     </tr>
118                                 [% END %]
119                             </tbody>
120                         </table>
121                     [% ELSE %]
122                         <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new client id/secret pair</div>
123                     [% END %]
124                 </div>
125             </main>
126         </div> <!-- /.col-sm-10.col-sm-push-2 -->
127
128         <div class="col-sm-2 col-sm-pull-10">
129             <aside>
130                 [% INCLUDE 'circ-menu.inc' %]
131             </aside>
132         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
133     </div> <!-- /.row -->
134
135
136 [% MACRO jsinclude BLOCK %]
137     [% INCLUDE 'str/members-menu.inc' %]
138     [% Asset.js("js/members-menu.js") | $raw %]
139     <script>
140         $(document).ready(function(){
141             $(".delete").on("click", function(e){
142                 return confirmDelete(_("Are you sure you want to delete this key?"));
143             });
144         });
145     </script>
146 [% END %]
147
148 [% INCLUDE 'intranet-bottom.inc' %]