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