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