{% import os %}
{% from xutils import fsutil %}
{% init show_rename_file_link = True %}
{% init get_file_thumbnail = xutils.get_func_by_name("fs.get_file_thumbnail") %}
{% init get_file_download_link = xutils.get_func_by_name("fs.get_file_download_link") %}

{% include common/script/load_select2.html %}

<table class="table row">
    {% for file_info in files %}
        {% set fpath = file_info.realpath %}
        {% set fname = os.path.basename(fpath) %}
        {% set display_name = fsutil.get_display_name(fpath, dirname) %}
        <tr>
            <td>
                <!-- <a href="{{fsutil.get_webpath(fpath)}}">{{display_name}}</a> -->
                <img class="fs-thumbnail x-photo" src="{{get_file_thumbnail(fpath)}}" 
                    data-src="{{get_file_download_link(fpath)}}" title="{{fname}}"/>
            </td>
            <td class="option-td">
                {{xutils.format_file_size(fpath)}}
            </td>
            <td class="option-td">
                <div class="float-right">
                    {% if show_rename_file_link %}
                        <a class="rename-btn" data-name="{{display_name}}">重命名</a>
                    {% end %}
                    <a class="action-link" href="{{get_file_download_link(fpath)}}">下载</a>
                    <a class="action-link" data-url="/fs_upload/file_info?action=edit&file_id={{file_info.id}}" data-title="详细信息" 
                        onclick="xnote.table.handleEditForm(this)">详细信息</a>
                    <a class="action-link danger-link" data-path="{{fpath}}" data-name="{{display_name}}" 
                    onclick="xnote.action.fs.delete(this);">删除</a>
                </div>
            </td>
        </tr>
    {% end %}
</table>

{% include fs/component/script/file_op_script.html %}
