Selaa lähdekoodia

Enable download of user credentials.

Closes #529.
Akinori MUSHA 10 vuotta sitten
vanhempi
commit
b8a4c268ce

+ 3 - 1
app/controllers/user_credentials_controller.rb

@@ -8,7 +8,9 @@ class UserCredentialsController < ApplicationController
 
     respond_to do |format|
       format.html
-      format.json { render json: @user_credentials }
+      format.json {
+        send_data Utils.pretty_jsonify(@user_credentials.limit(nil).as_json), disposition: 'attachment'
+      }
     end
   end
 

+ 3 - 2
app/views/user_credentials/index.html.erb

@@ -37,8 +37,9 @@
       <br/>
 
       <div class="btn-group">
-        <%= link_to '<span class="glyphicon glyphicon-plus"></span> New Credential'.html_safe, new_user_credential_path, class: "btn btn-default" %>
+        <%= link_to new_user_credential_path, class: "btn btn-default" do %><span class="glyphicon glyphicon-plus"></span> New Credential<% end %>
+        <%= link_to user_credentials_path(format: :json), class: "btn btn-default" do %><span class="glyphicon glyphicon-download-alt"></span> Download Credentials<% end %>
       </div>
     </div>
   </div>
-</div>
+</div>