file-manager/app/views/admin/file_managers/_file.html.erb

95 lines
3.8 KiB
Plaintext

<h3><%= generate_breadcrumb %></h3>
<section id="file_manager_section">
<span class="btn-wrapper">
<% if !@upload_item.is_trash && @all_uploads && @all_uploads.count > 1 %>
<%= link_to "javascript:void(0)", class: 'delete_file', data: { "tmp-confirm"=> "Are you sure you want to delete `#{URI.decode(@relative_path) + ' - Version ' + @active_version.to_s}`?", "link"=> admin_file_manager_path(@upload_item.id, :type=> 'upload'), "version"=> @active_version } do %>
<%= fa_icon 'trash' %> <%= t("file_manager.delete") %>
<% end %>
<% end %>
<%= link_to "/xhr/file_manager_download?id=#{@upload_item.id}", class: 'download' do %>
<%= fa_icon 'download' %> Download
<% end %>
<% if !@upload_item.is_trash %>
<% if !@is_img && !@too_big && !@unknown_encoding %>
<%= link_to "javascript:void(0)", class: 'edit' do %>
<%= fa_icon 'edit' %> Edit
<% end %>
<%= link_to "javascript:void(0)", class: 'save hide', data: {id: @upload_item.id.to_s} do %>
<%= fa_icon 'save' %> Save
<% end %>
<% end %>
<div class="dropup upload-button">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<i class="icon-upload-alt icon-white"></i><%= t('file_manager.upload') %>
<span class="caret"></span>
</button>
<div class="dropdown-menu upload-box">
<form action="<%= upload_file_admin_file_manager_path(@upload_item.id) %>" method="post" enctype="multipart/form-data" class="upload_form">
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<input type="file" name="file" >
<input type="hidden" name="url" value="<%= request.fullpath %>">
<input type="hidden" name="type" value="update">
<button class="btn btn-primary" type="submit"><%= t(:submit) %></button>
</form>
</div>
</div>
<% end %>
</span>
<% if @all_uploads && @all_uploads.count > 1 %>
<ul class="tab_nav custom_tabs" style="clear: left;">
<% @all_uploads.each do |r| %>
<li class="<%= 'active' if r.version == @active_version %>"><a title="Version <%= r.version %> (<%= r.created_at.strftime('%Y/%m/%d %H:%M') %>)" class="change_version" data-version="<%= r.version %>" data-id="<%= r.id.to_s %>">Version <%= r.version %></a></li>
<% end %>
</ul>
<% end %>
<div style="clear: both;">
<% if @is_img %>
<div style="clear: both;"></div>
<img src="/xhr/file_manager_download?id=<%=@id%>" />
<% elsif File.extname(@upload_item.path) == '.pdf' %>
<iframe src="/xhr/file_manager_download?id=<%=@id%>&preview=true" style="width: 100%; height: 100vw;" />
<% elsif @too_big %>
<pre><%= @file %></pre>
<% else %>
<textarea class="edit-area hide"></textarea>
<pre><%= @file %></pre>
<% end %>
</div>
<script>
window.recycle_bin_text = "<%=t('file_manager.recycle_bin')%>";
window.current_path = "<%= @relative_path %>"
<% if @only_select_folder %>
window.only_select_folder = true;
<% end %>
<% if @setting %>
window.explorer_setting_id = "<%= @setting.id %>";
<% end %>
<% unless @disable_path_traversal %>
window.path_mode = "params";
window.use_params_request = true;
<% end %>
if (typeof(FormData) != typeof(undefined)) {
$('.upload_form').submit(function(evt){
evt.preventDefault();
var formData = new FormData(this);
formData.append('remote', true);
$.ajax({
url: $(this).attr('action'),
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
enctype: 'multipart/form-data',
processData: false,
success: function (data) {
reload_page(undefined, false, {"file_id": data.id});
}
});
return false;
});
}
</script>
</section>