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