##// END OF EJS Templates
auth-tokens: improve UI.
marcink -
r3391:d889da9e default
parent child Browse files
Show More

The requested changes are too big and content was truncated. Show full diff

1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,188 +1,190 b''
1 1 <div class="panel panel-default">
2 2 <div class="panel-heading">
3 3 <h3 class="panel-title">${_('Authentication Tokens')}</h3>
4 4 </div>
5 5 <div class="panel-body">
6 6 <div class="apikeys_wrap">
7 7 <p>
8 ${_('Each token can have a role. Token with a role can be used only in given context, '
8 ${_('Authentication tokens can be used to interact with the API, or VCS-over-http. '
9 'Each token can have a role. Token with a role can be used only in given context, '
9 10 'e.g. VCS tokens can be used together with the authtoken auth plugin for git/hg/svn operations only.')}
10 11 </p>
11 12 <table class="rctable auth_tokens">
12 13 <tr>
13 14 <th>${_('Token')}</th>
14 <th>${_('Scope')}</th>
15 15 <th>${_('Description')}</th>
16 16 <th>${_('Role')}</th>
17 <th>${_('Repository Scope')}</th>
17 18 <th>${_('Expiration')}</th>
18 19 <th>${_('Action')}</th>
19 20 </tr>
20 21 %if c.user_auth_tokens:
21 22 %for auth_token in c.user_auth_tokens:
22 <tr class="${'expired' if auth_token.expired else ''}">
23 <tr class="${('expired' if auth_token.expired else '')}">
23 24 <td class="truncate-wrap td-authtoken">
24 25 <div class="user_auth_tokens truncate autoexpand">
25 26 <code>${auth_token.api_key}</code>
26 27 </div>
27 28 </td>
28 <td class="td">${auth_token.scope_humanized}</td>
29 29 <td class="td-wrap">${auth_token.description}</td>
30 30 <td class="td-tags">
31 31 <span class="tag disabled">${auth_token.role_humanized}</span>
32 32 </td>
33 <td class="td">${auth_token.scope_humanized}</td>
33 34 <td class="td-exp">
34 35 %if auth_token.expires == -1:
35 36 ${_('never')}
36 37 %else:
37 38 %if auth_token.expired:
38 39 <span style="text-decoration: line-through">${h.age_component(h.time_to_utcdatetime(auth_token.expires))}</span>
39 40 %else:
40 41 ${h.age_component(h.time_to_utcdatetime(auth_token.expires))}
41 42 %endif
42 43 %endif
43 44 </td>
44 45 <td class="td-action">
45 46 ${h.secure_form(h.route_path('my_account_auth_tokens_delete'), request=request)}
46 47 ${h.hidden('del_auth_token', auth_token.user_api_key_id)}
47 48 <button class="btn btn-link btn-danger" type="submit"
48 49 onclick="return confirm('${_('Confirm to remove this auth token: %s') % auth_token.token_obfuscated}');">
49 50 ${_('Delete')}
50 51 </button>
51 52 ${h.end_form()}
52 53 </td>
53 54 </tr>
54 55 %endfor
55 56 %else:
56 57 <tr><td><div class="ip">${_('No additional auth tokens specified')}</div></td></tr>
57 58 %endif
58 59 </table>
59 60 </div>
60 61
61 62 <div class="user_auth_tokens">
62 63 ${h.secure_form(h.route_path('my_account_auth_tokens_add'), request=request)}
63 64 <div class="form form-vertical">
64 65 <!-- fields -->
65 66 <div class="fields">
66 67 <div class="field">
67 68 <div class="label">
68 69 <label for="new_email">${_('New authentication token')}:</label>
69 70 </div>
70 71 <div class="input">
71 72 ${h.text('description', class_='medium', placeholder=_('Description'))}
72 73 ${h.hidden('lifetime')}
73 74 ${h.select('role', '', c.role_options)}
74 75
75 76 % if c.allow_scoped_tokens:
76 77 ${h.hidden('scope_repo_id')}
77 78 % else:
78 79 ${h.select('scope_repo_id_disabled', '', ['Scopes available in EE edition'], disabled='disabled')}
79 80 % endif
80 81 </div>
81 82 <p class="help-block">
82 83 ${_('Repository scope works only with tokens with VCS type.')}
83 84 </p>
84 85 </div>
85 86 <div class="buttons">
86 87 ${h.submit('save',_('Add'),class_="btn")}
87 88 ${h.reset('reset',_('Reset'),class_="btn")}
88 89 </div>
89 90 </div>
90 91 </div>
91 92 ${h.end_form()}
92 93 </div>
93 94 </div>
94 95 </div>
96
95 97 <script>
96 98 $(document).ready(function(){
97 99
98 100 var select2Options = {
99 101 'containerCssClass': "drop-menu",
100 102 'dropdownCssClass': "drop-menu-dropdown",
101 103 'dropdownAutoWidth': true
102 104 };
103 105 $("#role").select2(select2Options);
104 106
105 107 var preloadData = {
106 108 results: [
107 109 % for entry in c.lifetime_values:
108 110 {id:${entry[0]}, text:"${entry[1]}"}${'' if loop.last else ','}
109 111 % endfor
110 112 ]
111 113 };
112 114
113 115 $("#lifetime").select2({
114 116 containerCssClass: "drop-menu",
115 117 dropdownCssClass: "drop-menu-dropdown",
116 118 dropdownAutoWidth: true,
117 119 data: preloadData,
118 120 placeholder: "${_('Select or enter expiration date')}",
119 121 query: function(query) {
120 122 feedLifetimeOptions(query, preloadData);
121 123 }
122 124 });
123 125
124 126
125 127 var repoFilter = function(data) {
126 128 var results = [];
127 129
128 130 if (!data.results[0]) {
129 131 return data
130 132 }
131 133
132 134 $.each(data.results[0].children, function() {
133 135 // replace name to ID for submision
134 136 this.id = this.repo_id;
135 137 results.push(this);
136 138 });
137 139
138 140 data.results[0].children = results;
139 141 return data;
140 142 };
141 143
142 144 $("#scope_repo_id_disabled").select2(select2Options);
143 145
144 146 var selectVcsScope = function() {
145 147 // select vcs scope and disable input
146 148 $("#role").select2("val", "${c.role_vcs}").trigger('change');
147 149 $("#role").select2("readonly", true)
148 150 };
149 151
150 152 $("#scope_repo_id").select2({
151 153 cachedDataSource: {},
152 154 minimumInputLength: 2,
153 155 placeholder: "${_('repository scope')}",
154 156 dropdownAutoWidth: true,
155 157 containerCssClass: "drop-menu",
156 158 dropdownCssClass: "drop-menu-dropdown",
157 159 formatResult: formatRepoResult,
158 160 query: $.debounce(250, function(query){
159 161 self = this;
160 162 var cacheKey = query.term;
161 163 var cachedData = self.cachedDataSource[cacheKey];
162 164
163 165 if (cachedData) {
164 166 query.callback({results: cachedData.results});
165 167 } else {
166 168 $.ajax({
167 169 url: pyroutes.url('repo_list_data'),
168 170 data: {'query': query.term},
169 171 dataType: 'json',
170 172 type: 'GET',
171 173 success: function(data) {
172 174 data = repoFilter(data);
173 175 self.cachedDataSource[cacheKey] = data;
174 176 query.callback({results: data.results});
175 177 },
176 178 error: function(data, textStatus, errorThrown) {
177 179 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
178 180 }
179 181 })
180 182 }
181 183 })
182 184 });
183 185 $("#scope_repo_id").on('select2-selecting', function(e){
184 186 selectVcsScope()
185 187 });
186 188
187 189 });
188 190 </script>
@@ -1,186 +1,191 b''
1 1 <div class="panel panel-default">
2 2 <div class="panel-heading">
3 3 <h3 class="panel-title">${_('Authentication Tokens')}</h3>
4 4 </div>
5 5 <div class="panel-body">
6 6 <div class="apikeys_wrap">
7 7 <p>
8 ${_('Each token can have a role. Token with a role can be used only in given context, '
8 ${_('Authentication tokens can be used to interact with the API, or VCS-over-http. '
9 'Each token can have a role. Token with a role can be used only in given context, '
9 10 'e.g. VCS tokens can be used together with the authtoken auth plugin for git/hg/svn operations only.')}
10 11 </p>
11 12 <table class="rctable auth_tokens">
12 13 <tr>
13 14 <th>${_('Token')}</th>
14 <th>${_('Scope')}</th>
15 15 <th>${_('Description')}</th>
16 16 <th>${_('Role')}</th>
17 <th>${_('Repository Scope')}</th>
17 18 <th>${_('Expiration')}</th>
18 19 <th>${_('Action')}</th>
19 20 </tr>
20 21 %if c.user_auth_tokens:
21 22 %for auth_token in c.user_auth_tokens:
22 <tr class="${'expired' if auth_token.expired else ''}">
23 <td class="truncate-wrap td-authtoken"><div class="user_auth_tokens truncate autoexpand"><code>${auth_token.api_key}</code></div></td>
24 <td class="td">${auth_token.scope_humanized}</td>
23 <tr class="${('expired' if auth_token.expired else '')}">
24 <td class="truncate-wrap td-authtoken">
25 <div class="user_auth_tokens truncate autoexpand">
26 <code>${auth_token.api_key}</code>
27 </div>
28 </td>
25 29 <td class="td-wrap">${auth_token.description}</td>
26 30 <td class="td-tags">
27 31 <span class="tag disabled">${auth_token.role_humanized}</span>
28 32 </td>
33 <td class="td">${auth_token.scope_humanized}</td>
29 34 <td class="td-exp">
30 35 %if auth_token.expires == -1:
31 36 ${_('never')}
32 37 %else:
33 38 %if auth_token.expired:
34 39 <span style="text-decoration: line-through">${h.age_component(h.time_to_utcdatetime(auth_token.expires))}</span>
35 40 %else:
36 41 ${h.age_component(h.time_to_utcdatetime(auth_token.expires))}
37 42 %endif
38 43 %endif
39 44 </td>
40 45 <td class="td-action">
41 46 ${h.secure_form(h.route_path('edit_user_auth_tokens_delete', user_id=c.user.user_id), request=request)}
42 47 ${h.hidden('del_auth_token', auth_token.user_api_key_id)}
43 48 <button class="btn btn-link btn-danger" type="submit"
44 49 onclick="return confirm('${_('Confirm to remove this auth token: %s') % auth_token.token_obfuscated}');">
45 50 ${_('Delete')}
46 51 </button>
47 52 ${h.end_form()}
48 53 </td>
49 54 </tr>
50 55 %endfor
51 56 %else:
52 57 <tr><td><div class="ip">${_('No additional auth tokens specified')}</div></td></tr>
53 58 %endif
54 59 </table>
55 60 </div>
56 61
57 62 <div class="user_auth_tokens">
58 63 ${h.secure_form(h.route_path('edit_user_auth_tokens_add', user_id=c.user.user_id), request=request)}
59 64 <div class="form form-vertical">
60 65 <!-- fields -->
61 66 <div class="fields">
62 67 <div class="field">
63 68 <div class="label">
64 69 <label for="new_email">${_('New authentication token')}:</label>
65 70 </div>
66 71 <div class="input">
67 72 ${h.text('description', class_='medium', placeholder=_('Description'))}
68 73 ${h.hidden('lifetime')}
69 74 ${h.select('role', '', c.role_options)}
70 75
71 76 % if c.allow_scoped_tokens:
72 77 ${h.hidden('scope_repo_id')}
73 78 % else:
74 79 ${h.select('scope_repo_id_disabled', '', ['Scopes available in EE edition'], disabled='disabled')}
75 80 % endif
76 81 </div>
77 82 <p class="help-block">
78 83 ${_('Repository scope works only with tokens with VCS type.')}
79 84 </p>
80 85 </div>
81 86 <div class="buttons">
82 87 ${h.submit('save',_('Add'),class_="btn")}
83 88 ${h.reset('reset',_('Reset'),class_="btn")}
84 89 </div>
85 90 </div>
86 91 </div>
87 92 ${h.end_form()}
88 93 </div>
89 94 </div>
90 95 </div>
91 96
92 97 <script>
93 98
94 99 $(document).ready(function(){
95 100
96 101 var select2Options = {
97 102 'containerCssClass': "drop-menu",
98 103 'dropdownCssClass': "drop-menu-dropdown",
99 104 'dropdownAutoWidth': true
100 105 };
101 106 $("#role").select2(select2Options);
102 107
103 108 var preloadData = {
104 109 results: [
105 110 % for entry in c.lifetime_values:
106 111 {id:${entry[0]}, text:"${entry[1]}"}${'' if loop.last else ','}
107 112 % endfor
108 113 ]
109 114 };
110 115
111 116 $("#lifetime").select2({
112 117 containerCssClass: "drop-menu",
113 118 dropdownCssClass: "drop-menu-dropdown",
114 119 dropdownAutoWidth: true,
115 120 data: preloadData,
116 121 placeholder: "${_('Select or enter expiration date')}",
117 122 query: function(query) {
118 123 feedLifetimeOptions(query, preloadData);
119 124 }
120 125 });
121 126
122 127
123 128 var repoFilter = function(data) {
124 129 var results = [];
125 130
126 131 if (!data.results[0]) {
127 132 return data
128 133 }
129 134
130 135 $.each(data.results[0].children, function() {
131 136 // replace name to ID for submision
132 137 this.id = this.repo_id;
133 138 results.push(this);
134 139 });
135 140
136 141 data.results[0].children = results;
137 142 return data;
138 143 };
139 144
140 145 $("#scope_repo_id_disabled").select2(select2Options);
141 146
142 147 var selectVcsScope = function() {
143 148 // select vcs scope and disable input
144 149 $("#role").select2("val", "${c.role_vcs}").trigger('change');
145 150 $("#role").select2("readonly", true)
146 151 };
147 152
148 153 $("#scope_repo_id").select2({
149 154 cachedDataSource: {},
150 155 minimumInputLength: 2,
151 156 placeholder: "${_('repository scope')}",
152 157 dropdownAutoWidth: true,
153 158 containerCssClass: "drop-menu",
154 159 dropdownCssClass: "drop-menu-dropdown",
155 160 formatResult: formatRepoResult,
156 161 query: $.debounce(250, function(query){
157 162 self = this;
158 163 var cacheKey = query.term;
159 164 var cachedData = self.cachedDataSource[cacheKey];
160 165
161 166 if (cachedData) {
162 167 query.callback({results: cachedData.results});
163 168 } else {
164 169 $.ajax({
165 170 url: pyroutes.url('repo_list_data'),
166 171 data: {'query': query.term},
167 172 dataType: 'json',
168 173 type: 'GET',
169 174 success: function(data) {
170 175 data = repoFilter(data);
171 176 self.cachedDataSource[cacheKey] = data;
172 177 query.callback({results: data.results});
173 178 },
174 179 error: function(data, textStatus, errorThrown) {
175 180 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
176 181 }
177 182 })
178 183 }
179 184 })
180 185 });
181 186 $("#scope_repo_id").on('select2-selecting', function(e){
182 187 selectVcsScope()
183 188 });
184 189
185 190 });
186 191 </script>
General Comments 0
You need to be logged in to leave comments. Login now