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