Project

General

Profile

Feature #5953 » fixed-5953-v2.patch

Yuichi HARADA, 2021-03-19 03:24

View differences:

app/views/my/_sidebar.html.erb
21 21
<% if Setting.rest_api_enabled? %>
22 22
<h4><%= l(:label_api_access_key) %></h4>
23 23
<div>
24
  <%= link_to l(:button_show), my_api_key_path, :remote => true %>
25
  <pre id='api-access-key' class='autoscroll'></pre>
24
  <%= link_to l(:button_show), my_api_key_path, :remote => true, :id => 'toggle-api-access-key' %>
25
  <%= link_to_function l(:button_copy), "copyTextToClipboard(getElementById('api-access-key'))",
26
                       :id => 'copy-api-access-key',
27
                       :class => ['icon', 'icon-copy'],
28
                       :style => 'display:none;' %>
29
  <pre id='api-access-key' class='autoscroll' style="display:none;"></pre>
26 30
</div>
27
<%= javascript_tag("$('#api-access-key').hide();") %>
28 31
<p>
29 32
<% if @user.api_token %>
30 33
<%= l(:label_api_access_key_created_on, distance_of_time_in_words(Time.now, @user.api_token.created_on)) %>
app/views/my/show_api_key.js.erb
1
$('#api-access-key').html('<%= escape_javascript @user.api_key %>').toggle();
1
var api_access_key = '<%= escape_javascript @user.api_key %>';
2
$('#api-access-key').html(api_access_key);
3
$('#api-access-key').attr('data-clipboard-text', api_access_key);
4
$('#api-access-key, #copy-api-access-key').toggle();
5
var label_show = '<%= escape_javascript l(:button_show) %>';
6
if($('#toggle-api-access-key').text() == label_show){
7
  $('#toggle-api-access-key').text('<%= escape_javascript l(:button_hide) %>');
8
}
9
else{
10
  $('#toggle-api-access-key').text(label_show);
11
}
public/stylesheets/application.css
111 111
#sidebar a.icon-only:hover {opacity: 1;}
112 112
#sidebar span.icon-warning {margin-left: 5px;}
113 113
#sidebar li input[type=checkbox] {height: 20px;}
114
#sidebar #copy-api-access-key {float:right;}
114 115

  
115 116
#content { flex-grow: 1; background-color: #fff; margin: 0px; padding: 10px 16px 10px 16px; overflow-x: auto;}
116 117
html>body #content { min-height: 600px; }
(3-3/3)