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