mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
update
This commit is contained in:
@@ -6,12 +6,10 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from django.template.defaultfilters import filesizeformat
|
from django.template.defaultfilters import filesizeformat
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from seaserv import ccnet_api, seafile_api, seafserv_threaded_rpc
|
from seaserv import ccnet_api, seafile_api, seafserv_threaded_rpc
|
||||||
|
|
||||||
from seahub.views.ajax import get_related_users_by_org_repo, \
|
|
||||||
get_related_users_by_repo
|
|
||||||
from seahub.signals import repo_deleted
|
|
||||||
from seahub.views import get_system_default_repo_id
|
from seahub.views import get_system_default_repo_id
|
||||||
from seahub.utils import is_org_context
|
from seahub.utils import is_org_context
|
||||||
from seahub.base.accounts import User
|
from seahub.base.accounts import User
|
||||||
@@ -35,6 +33,8 @@ def get_repo_info(repo):
|
|||||||
|
|
||||||
|
|
||||||
class AdminLibraries(APIView):
|
class AdminLibraries(APIView):
|
||||||
|
""" return all libraries
|
||||||
|
"""
|
||||||
|
|
||||||
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||||
throttle_classes = (UserRateThrottle,)
|
throttle_classes = (UserRateThrottle,)
|
||||||
@@ -87,18 +87,9 @@ class AdminLibrary(APIView):
|
|||||||
return Response({'success': True})
|
return Response({'success': True})
|
||||||
|
|
||||||
if get_system_default_repo_id() == repo_id:
|
if get_system_default_repo_id() == repo_id:
|
||||||
error_msg = ('System library can not be deleted.')
|
error_msg = _('System library can not be deleted.')
|
||||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||||
|
|
||||||
if is_org_context(request):
|
|
||||||
org_id = seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id)
|
|
||||||
usernames = get_related_users_by_org_repo(org_id, repo_id)
|
|
||||||
repo_owner = seafile_api.get_org_repo_owner(repo_id)
|
|
||||||
else:
|
|
||||||
org_id = -1
|
|
||||||
usernames = get_related_users_by_repo(repo_id)
|
|
||||||
repo_owner = seafile_api.get_repo_owner(repo_id)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
seafile_api.remove_repo(repo_id)
|
seafile_api.remove_repo(repo_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -106,13 +97,11 @@ class AdminLibrary(APIView):
|
|||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
repo_deleted.send(sender=None, org_id=org_id, usernames=usernames,
|
|
||||||
repo_owner=repo_owner, repo_id=repo_id,
|
|
||||||
repo_name=repo.repo_name)
|
|
||||||
|
|
||||||
return Response({'success': True})
|
return Response({'success': True})
|
||||||
|
|
||||||
def put(self, request, repo_id, format=None):
|
def put(self, request, repo_id, format=None):
|
||||||
|
""" transfer a library
|
||||||
|
"""
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import logging
|
import logging
|
||||||
import time
|
import posixpath
|
||||||
|
|
||||||
from rest_framework.authentication import SessionAuthentication
|
from rest_framework.authentication import SessionAuthentication
|
||||||
from rest_framework.permissions import IsAdminUser
|
from rest_framework.permissions import IsAdminUser
|
||||||
@@ -26,6 +26,22 @@ from seahub.api2.utils import api_error
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def get_dirent_info(dirent):
|
||||||
|
|
||||||
|
if stat.S_ISDIR(dirent.mode):
|
||||||
|
is_file = False
|
||||||
|
else:
|
||||||
|
is_file = True
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
result['is_file'] = is_file
|
||||||
|
result['obj_name'] = dirent.obj_name
|
||||||
|
result['file_size'] = filesizeformat(dirent.size) if is_file else ''
|
||||||
|
result['last_update'] = timestamp_to_isoformat_timestr(dirent.mtime)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class AdminLibraryDirents(APIView):
|
class AdminLibraryDirents(APIView):
|
||||||
|
|
||||||
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||||
@@ -33,6 +49,9 @@ class AdminLibraryDirents(APIView):
|
|||||||
permission_classes = (IsAdminUser,)
|
permission_classes = (IsAdminUser,)
|
||||||
|
|
||||||
def get(self, request, repo_id, format=None):
|
def get(self, request, repo_id, format=None):
|
||||||
|
""" get all file/folder in a library
|
||||||
|
"""
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
@@ -55,7 +74,6 @@ class AdminLibraryDirents(APIView):
|
|||||||
error_msg = 'Folder %s not found.' % parent_dir
|
error_msg = 'Folder %s not found.' % parent_dir
|
||||||
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
||||||
|
|
||||||
# TODO org?
|
|
||||||
if is_org_context(request):
|
if is_org_context(request):
|
||||||
repo_owner = seafile_api.get_org_repo_owner(repo_id)
|
repo_owner = seafile_api.get_org_repo_owner(repo_id)
|
||||||
else:
|
else:
|
||||||
@@ -77,29 +95,15 @@ class AdminLibraryDirents(APIView):
|
|||||||
return_results['dirent_list'] = []
|
return_results['dirent_list'] = []
|
||||||
|
|
||||||
for dirent in dirs:
|
for dirent in dirs:
|
||||||
result = {}
|
dirent_info = get_dirent_info(dirent)
|
||||||
if stat.S_ISDIR(dirent.mode):
|
return_results['dirent_list'].append(dirent_info)
|
||||||
result['is_file'] = False
|
|
||||||
result['obj_name'] = dirent.obj_name
|
|
||||||
result['file_size'] = ''
|
|
||||||
result['last_update'] = timestamp_to_isoformat_timestr(dirent.mtime)
|
|
||||||
else:
|
|
||||||
if repo.version == 0:
|
|
||||||
size = seafile_api.get_file_size(repo.store_id,
|
|
||||||
repo.version, dirent.obj_id)
|
|
||||||
else:
|
|
||||||
size = dirent.size
|
|
||||||
|
|
||||||
result['is_file'] = True
|
|
||||||
result['obj_name'] = dirent.obj_name
|
|
||||||
result['file_size'] = filesizeformat(size)
|
|
||||||
result['last_update'] = timestamp_to_isoformat_timestr(dirent.mtime)
|
|
||||||
|
|
||||||
return_results['dirent_list'].append(result)
|
|
||||||
|
|
||||||
return Response(return_results)
|
return Response(return_results)
|
||||||
|
|
||||||
def post(self, request, repo_id, format=None):
|
def post(self, request, repo_id, format=None):
|
||||||
|
""" create file/folder in a library
|
||||||
|
"""
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
@@ -137,13 +141,11 @@ class AdminLibraryDirents(APIView):
|
|||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
result = {}
|
dirent_path = posixpath.join(parent_dir, obj_name)
|
||||||
result['is_file'] = False
|
dirent = seafile_api.get_dirent_by_path(repo_id, dirent_path)
|
||||||
result['obj_name'] = obj_name
|
dirent_info = get_dirent_info(dirent)
|
||||||
result['file_size'] = filesizeformat(0)
|
|
||||||
result['last_update'] = timestamp_to_isoformat_timestr(time.time())
|
|
||||||
|
|
||||||
return Response(result)
|
return Response(dirent_info)
|
||||||
|
|
||||||
class AdminLibraryDirent(APIView):
|
class AdminLibraryDirent(APIView):
|
||||||
|
|
||||||
@@ -152,6 +154,9 @@ class AdminLibraryDirent(APIView):
|
|||||||
permission_classes = (IsAdminUser,)
|
permission_classes = (IsAdminUser,)
|
||||||
|
|
||||||
def get(self, request, repo_id):
|
def get(self, request, repo_id):
|
||||||
|
""" get info of a single file/folder in a library
|
||||||
|
"""
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
@@ -169,47 +174,39 @@ class AdminLibraryDirent(APIView):
|
|||||||
if path[0] != '/':
|
if path[0] != '/':
|
||||||
path = '/' + path
|
path = '/' + path
|
||||||
|
|
||||||
file_id = None
|
|
||||||
dir_id = None
|
|
||||||
try:
|
try:
|
||||||
file_id = seafile_api.get_file_id_by_path(repo_id, path)
|
dirent = seafile_api.get_dirent_by_path(repo_id, path)
|
||||||
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
|
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
if file_id:
|
if not dirent:
|
||||||
is_file = True
|
error_msg = 'file/folder %s not found.' % path
|
||||||
elif dir_id:
|
|
||||||
is_file = False
|
|
||||||
else:
|
|
||||||
error_msg = 'path %s not found.' % path
|
|
||||||
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
||||||
|
|
||||||
username = request.user.username
|
if stat.S_ISDIR(dirent.mode):
|
||||||
obj_name = os.path.basename(path.rstrip('/'))
|
is_file = False
|
||||||
|
else:
|
||||||
|
is_file = True
|
||||||
|
|
||||||
|
username = request.user.username
|
||||||
if is_file and request.GET.get('dl', '0') == '1':
|
if is_file and request.GET.get('dl', '0') == '1':
|
||||||
|
|
||||||
token = seafile_api.get_fileserver_access_token(repo_id,
|
token = seafile_api.get_fileserver_access_token(repo_id,
|
||||||
file_id, 'download', username, use_onetime=True)
|
dirent.obj_id, 'download', username, use_onetime=True)
|
||||||
dl_url = gen_file_get_url(token, obj_name)
|
dl_url = gen_file_get_url(token, dirent.obj_name)
|
||||||
send_file_access_msg(request, repo, path, 'web')
|
send_file_access_msg(request, repo, path, 'web')
|
||||||
return Response({'download_url': dl_url})
|
return Response({'download_url': dl_url})
|
||||||
|
|
||||||
size = seafile_api.get_file_size(repo.store_id,
|
dirent_info = get_dirent_info(dirent)
|
||||||
repo.version, file_id or dir_id)
|
|
||||||
|
|
||||||
result = {}
|
return Response(dirent_info)
|
||||||
result['is_file'] = is_file
|
|
||||||
result['obj_name'] = obj_name
|
|
||||||
result['file_size'] = filesizeformat(size)
|
|
||||||
# TODO
|
|
||||||
# result['last_update'] = timestamp_to_isoformat_timestr(dirent.mtime)
|
|
||||||
|
|
||||||
return Response(result)
|
|
||||||
|
|
||||||
def delete(self, request, repo_id):
|
def delete(self, request, repo_id):
|
||||||
|
""" delete a single file/folder in a library
|
||||||
|
"""
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
repo = seafile_api.get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
error_msg = 'Library %s not found.' % repo_id
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
|
@@ -25,6 +25,8 @@ class AdminTrashLibraries(APIView):
|
|||||||
permission_classes = (IsAdminUser,)
|
permission_classes = (IsAdminUser,)
|
||||||
|
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
|
""" get all deleted libraries
|
||||||
|
"""
|
||||||
|
|
||||||
repos_all = seafile_api.get_trash_repo_list(-1, -1)
|
repos_all = seafile_api.get_trash_repo_list(-1, -1)
|
||||||
return_results = []
|
return_results = []
|
||||||
@@ -40,6 +42,9 @@ class AdminTrashLibraries(APIView):
|
|||||||
return Response(return_results)
|
return Response(return_results)
|
||||||
|
|
||||||
def delete(self, request, format=None):
|
def delete(self, request, format=None):
|
||||||
|
""" clean all deleted libraries
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
seafile_api.empty_repo_trash()
|
seafile_api.empty_repo_trash()
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
@@ -56,6 +61,9 @@ class AdminTrashLibrary(APIView):
|
|||||||
permission_classes = (IsAdminUser,)
|
permission_classes = (IsAdminUser,)
|
||||||
|
|
||||||
def put(self, request, repo_id, format=None):
|
def put(self, request, repo_id, format=None):
|
||||||
|
""" restore a deleted library
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
seafile_api.restore_repo_from_trash(repo_id)
|
seafile_api.restore_repo_from_trash(repo_id)
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
@@ -66,6 +74,9 @@ class AdminTrashLibrary(APIView):
|
|||||||
return Response({'success': True})
|
return Response({'success': True})
|
||||||
|
|
||||||
def delete(self, request, repo_id, format=None):
|
def delete(self, request, repo_id, format=None):
|
||||||
|
""" permanently delete a deleted library
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
seafile_api.del_repo_from_trash(repo_id)
|
seafile_api.del_repo_from_trash(repo_id)
|
||||||
except SearpcError as e:
|
except SearpcError as e:
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
<script type="text/template" id="side-nav-tmpl">
|
<script type="text/template" id="side-nav-tmpl">
|
||||||
<h3 class="hd">{% trans "System Admin" %}</h3>
|
<h3 class="hd">{% trans "System Admin" %}</h3>
|
||||||
<ul class="side-tabnav-tabs">
|
<ul class="side-tabnav-tabs">
|
||||||
<li class="tab <% if (cur_tab == 'dashboard') { %> tab-cur<% } %>">
|
<li class="tab<% if (cur_tab == 'dashboard') { %> tab-cur<% } %>">
|
||||||
<a href="{{ SITE_ROOT }}sysadmin/#dashboard/"><span class="sf2-icon-wrench"></span>{% trans "Info" %}</a>
|
<a href="{{ SITE_ROOT }}sysadmin/#dashboard/"><span class="sf2-icon-wrench"></span>{% trans "Info" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="tab <% if (cur_tab == 'devices') { %> tab-cur<% } %>">
|
<li class="tab<% if (cur_tab == 'devices') { %> tab-cur<% } %>">
|
||||||
<a href="{{ SITE_ROOT }}sysadmin/#desktop-devices/"><span class="sf2-icon-monitor"></span>{% trans "Devices" %}</a>
|
<a href="{{ SITE_ROOT }}sysadmin/#desktop-devices/"><span class="sf2-icon-monitor"></span>{% trans "Devices" %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% if constance_enabled %}
|
{% if constance_enabled %}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<a href="{% url "sys_settings" %}"><span class="sf2-icon-cog2"></span>{% trans "Settings" %}</a>
|
<a href="{% url "sys_settings" %}"><span class="sf2-icon-cog2"></span>{% trans "Settings" %}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="tab <% if (cur_tab == 'libraries') { %> tab-cur<% } %>">
|
<li class="tab<% if (cur_tab == 'libraries') { %> tab-cur<% } %>">
|
||||||
<a href="{{ SITE_ROOT }}sysadmin/#libraries/"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a>
|
<a href="{{ SITE_ROOT }}sysadmin/#libraries/"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="tab">
|
<li class="tab">
|
||||||
@@ -268,11 +268,11 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="4%"><!--icon--></th>
|
<th width="4%"><!--icon--></th>
|
||||||
<th width="27%">{% trans "Name" %}</th>
|
<th width="34%">{% trans "Name" %}</th>
|
||||||
<th width="10%"></th>
|
<th width="13%">{% trans "Files / Size" %}</th>
|
||||||
<th width="17%">{% trans "Files / Size" %}</th>
|
<th width="19%">ID</th>
|
||||||
<th width="21%">ID</th>
|
<th width="20%">{% trans "Owner" %}</th>
|
||||||
<th width="21%">{% trans "Owner" %}</th>
|
<th width="10%">{% trans "Operations" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -289,12 +289,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="library-item-tmpl">
|
<script type="text/template" id="library-item-tmpl">
|
||||||
<% if (encrypted) { %>
|
<td>
|
||||||
<td><img src="{{MEDIA_URL}}img/sync-folder-encrypt-20.png" title="{% trans "Encrypted"%}" alt="{% trans "directory icon" %}" /></td>
|
<img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
|
||||||
<% } else { %>
|
</td>
|
||||||
<td><img src="{{MEDIA_URL}}img/sync-folder-20.png?" title="{% trans "Read-Write"%}" alt="{% trans "directory icon" %}" /></td>
|
|
||||||
<% } %>
|
|
||||||
|
|
||||||
<% if (name) { %>
|
<% if (name) { %>
|
||||||
<% if (enable_sys_admin_view_repo && is_pro && !encrypted) { %>
|
<% if (enable_sys_admin_view_repo && is_pro && !encrypted) { %>
|
||||||
<td><a href="#libraries/<%- id %>/dirents/"><%- name %></a></td>
|
<td><a href="#libraries/<%- id %>/dirents/"><%- name %></a></td>
|
||||||
@@ -304,19 +301,19 @@
|
|||||||
<% } else { %>
|
<% } else { %>
|
||||||
<td>--</td>
|
<td>--</td>
|
||||||
<% } %>
|
<% } %>
|
||||||
<td>
|
|
||||||
<a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
|
|
||||||
<a href="#" class="sf2-icon-move sf2-x repo-transfer-btn op-icon vh" title="{% trans "Transfer" %}" aria-label="{% trans "Transfer" %}"></a>
|
|
||||||
</td>
|
|
||||||
<td><%- file_count %> / <%- size_formatted %></td>
|
<td><%- file_count %> / <%- size_formatted %></td>
|
||||||
<td style="font-size:11px;"><%- id %></td>
|
<td style="font-size:11px;"><%- id %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if (owner) { %>
|
<% if (owner) { %>
|
||||||
<a href="{{ SITE_ROOT }}useradmin/info/<%- owner %>/"><%- owner %></a>
|
<a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
--
|
--
|
||||||
<% } %>
|
<% } %>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
|
||||||
|
<a href="#" class="sf2-icon-move sf2-x repo-transfer-btn op-icon vh" title="{% trans "Transfer" %}" aria-label="{% trans "Transfer" %}"></a>
|
||||||
|
</td>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="system-library-tmpl">
|
<script type="text/template" id="system-library-tmpl">
|
||||||
@@ -389,9 +386,11 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/template" id="trash-library-item-tmpl">
|
<script type="text/template" id="trash-library-item-tmpl">
|
||||||
<td><img src="{{MEDIA_URL}}img/sync-folder-20.png?t=1387267140" title="{% trans "Read-Write"%}" alt="{% trans "directory icon" %}" /></td>
|
<td>
|
||||||
|
<img src="<%= icon_url %>" title="<%= icon_title %>" alt="<%= icon_title %>" width="24" />
|
||||||
|
</td>
|
||||||
<td><%- name %></td>
|
<td><%- name %></td>
|
||||||
<td><a href="{{ SITE_ROOT }}useradmin/info/<%- owner %>/"><%- owner %></a></td>
|
<td><a href="{{ SITE_ROOT }}useradmin/info/<% print(encodeURIComponent(owner)); %>/"><%- owner %></a></td>
|
||||||
<td><time title='<%- time %>'><%- time_from_now %></time></td>
|
<td><time title='<%- time %>'><%- time_from_now %></time></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
|
<a href="#" class="sf2-icon-delete sf2-x repo-delete-btn op-icon vh" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}"></a>
|
||||||
|
@@ -2,12 +2,12 @@ define([
|
|||||||
'underscore',
|
'underscore',
|
||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'sysadmin-app/models/library-dirent'
|
'sysadmin-app/models/dirent'
|
||||||
], function(_, Backbone, Common, LibraryDirentModel) {
|
], function(_, Backbone, Common, DirentModel) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibraryDirentCollection = Backbone.Collection.extend({
|
var DirentCollection = Backbone.Collection.extend({
|
||||||
model: LibraryDirentModel,
|
model: DirentModel,
|
||||||
parse: function (data) {
|
parse: function (data) {
|
||||||
this.repo_name = data.repo_name;
|
this.repo_name = data.repo_name;
|
||||||
this.repo_id = data.repo_id;
|
this.repo_id = data.repo_id;
|
||||||
@@ -20,5 +20,5 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryDirentCollection;
|
return DirentCollection;
|
||||||
});
|
});
|
@@ -2,12 +2,12 @@ define([
|
|||||||
'underscore',
|
'underscore',
|
||||||
'backbone.paginator',
|
'backbone.paginator',
|
||||||
'common',
|
'common',
|
||||||
'sysadmin-app/models/library'
|
'sysadmin-app/models/repo'
|
||||||
], function(_, BackbonePaginator, Common, LibraryModel) {
|
], function(_, BackbonePaginator, Common, RepoModel) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibraryCollection = Backbone.PageableCollection.extend({
|
var RepoCollection = Backbone.PageableCollection.extend({
|
||||||
model: LibraryModel,
|
model: RepoModel,
|
||||||
state: {pageSize: 100},
|
state: {pageSize: 100},
|
||||||
parseState: function(data) {
|
parseState: function(data) {
|
||||||
return {hasNextPage: data[0].has_next_page, current_page: data[0].current_page};
|
return {hasNextPage: data[0].has_next_page, current_page: data[0].current_page};
|
||||||
@@ -20,5 +20,5 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryCollection;
|
return RepoCollection;
|
||||||
});
|
});
|
@@ -1,17 +0,0 @@
|
|||||||
define([
|
|
||||||
'underscore',
|
|
||||||
'backbone',
|
|
||||||
'common',
|
|
||||||
'sysadmin-app/models/trash-library'
|
|
||||||
], function(_, Backbone, Common, TrashLibraryModel) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var TrashLibraryCollection = Backbone.Collection.extend({
|
|
||||||
model: TrashLibraryModel,
|
|
||||||
url: function () {
|
|
||||||
return Common.getUrl({name: 'admin-trash-libraries'});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return TrashLibraryCollection;
|
|
||||||
});
|
|
17
static/scripts/sysadmin-app/collection/trash-repos.js
Normal file
17
static/scripts/sysadmin-app/collection/trash-repos.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
define([
|
||||||
|
'underscore',
|
||||||
|
'backbone',
|
||||||
|
'common',
|
||||||
|
'sysadmin-app/models/trash-repo'
|
||||||
|
], function(_, Backbone, Common, TrashRepoModel) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var TrashRepoCollection = Backbone.Collection.extend({
|
||||||
|
model: TrashRepoModel,
|
||||||
|
url: function () {
|
||||||
|
return Common.getUrl({name: 'admin-trash-libraries'});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return TrashRepoCollection;
|
||||||
|
});
|
@@ -5,7 +5,7 @@ define([
|
|||||||
], function(_, Backbone, Common) {
|
], function(_, Backbone, Common) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibraryDirentModel = Backbone.Model.extend({
|
var DirentModel = Backbone.Model.extend({
|
||||||
|
|
||||||
// get the absolute path within the library
|
// get the absolute path within the library
|
||||||
getPath: function() {
|
getPath: function() {
|
||||||
@@ -50,5 +50,5 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryDirentModel;
|
return DirentModel;
|
||||||
});
|
});
|
@@ -1,11 +0,0 @@
|
|||||||
define([
|
|
||||||
'underscore',
|
|
||||||
'backbone',
|
|
||||||
'common',
|
|
||||||
], function(_, Backbone, Common) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var LibraryModel = Backbone.Model.extend({});
|
|
||||||
|
|
||||||
return LibraryModel;
|
|
||||||
});
|
|
27
static/scripts/sysadmin-app/models/repo.js
Normal file
27
static/scripts/sysadmin-app/models/repo.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
define([
|
||||||
|
'underscore',
|
||||||
|
'backbone',
|
||||||
|
'common',
|
||||||
|
], function(_, Backbone, Common) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var RepoModel = Backbone.Model.extend({
|
||||||
|
getIconUrl: function(size) {
|
||||||
|
var is_encrypted = this.get('encrypted');
|
||||||
|
return Common.getLibIconUrl(is_encrypted, false, size);
|
||||||
|
},
|
||||||
|
|
||||||
|
getIconTitle: function() {
|
||||||
|
var icon_title = '';
|
||||||
|
if (this.get('encrypted')) {
|
||||||
|
icon_title = gettext("Encrypted library");
|
||||||
|
} else {
|
||||||
|
icon_title = gettext("Read-Write library");
|
||||||
|
}
|
||||||
|
|
||||||
|
return icon_title;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return RepoModel;
|
||||||
|
});
|
@@ -1,11 +0,0 @@
|
|||||||
define([
|
|
||||||
'underscore',
|
|
||||||
'backbone',
|
|
||||||
'common'
|
|
||||||
], function(_, Backbone, Common) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var SystemLibrary = Backbone.Model.extend({});
|
|
||||||
|
|
||||||
return SystemLibrary;
|
|
||||||
});
|
|
@@ -5,7 +5,7 @@ define([
|
|||||||
], function(_, Backbone, Common) {
|
], function(_, Backbone, Common) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var TrashLibrary = Backbone.Model.extend({});
|
var SystemRepo = Backbone.Model.extend({});
|
||||||
|
|
||||||
return TrashLibrary;
|
return SystemRepo;
|
||||||
});
|
});
|
19
static/scripts/sysadmin-app/models/trash-repo.js
Normal file
19
static/scripts/sysadmin-app/models/trash-repo.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
define([
|
||||||
|
'underscore',
|
||||||
|
'backbone',
|
||||||
|
'common'
|
||||||
|
], function(_, Backbone, Common) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var TrashRepo = Backbone.Model.extend({
|
||||||
|
getIconUrl: function(size) {
|
||||||
|
return Common.getLibIconUrl(false, false, size);
|
||||||
|
},
|
||||||
|
|
||||||
|
getIconTitle: function() {
|
||||||
|
return gettext("Read-Write library");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return TrashRepo;
|
||||||
|
});
|
@@ -8,15 +8,15 @@ define([
|
|||||||
'sysadmin-app/views/desktop-devices',
|
'sysadmin-app/views/desktop-devices',
|
||||||
'sysadmin-app/views/mobile-devices',
|
'sysadmin-app/views/mobile-devices',
|
||||||
'sysadmin-app/views/device-errors',
|
'sysadmin-app/views/device-errors',
|
||||||
'sysadmin-app/views/libraries',
|
'sysadmin-app/views/repos',
|
||||||
'sysadmin-app/views/library-dir',
|
'sysadmin-app/views/dir',
|
||||||
'sysadmin-app/views/system-library',
|
'sysadmin-app/views/system-repo',
|
||||||
'sysadmin-app/views/trash-libraries',
|
'sysadmin-app/views/trash-repos',
|
||||||
'app/views/account'
|
'app/views/account'
|
||||||
], function($, Backbone, Common, SideNavView, DashboardView,
|
], function($, Backbone, Common, SideNavView, DashboardView,
|
||||||
DesktopDevicesView, MobileDevicesView, DeviceErrorsView,
|
DesktopDevicesView, MobileDevicesView, DeviceErrorsView,
|
||||||
LibrariesView, LibraryDirView, SystemLibrariesView,
|
ReposView, DirView, SystemReposView,
|
||||||
TrashLibrariesView, AccountView) {
|
TrashReposView, AccountView) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -50,10 +50,10 @@ define([
|
|||||||
this.desktopDevicesView = new DesktopDevicesView();
|
this.desktopDevicesView = new DesktopDevicesView();
|
||||||
this.mobileDevicesView = new MobileDevicesView();
|
this.mobileDevicesView = new MobileDevicesView();
|
||||||
this.deviceErrorsView = new DeviceErrorsView();
|
this.deviceErrorsView = new DeviceErrorsView();
|
||||||
this.librariesView = new LibrariesView();
|
this.reposView = new ReposView();
|
||||||
this.systemLibrariesView = new SystemLibrariesView();
|
this.systemReposView = new SystemReposView();
|
||||||
this.trashLibrariesView = new TrashLibrariesView();
|
this.trashReposView = new TrashReposView();
|
||||||
this.libraryDirView = new LibraryDirView();
|
this.dirView = new DirView();
|
||||||
|
|
||||||
app.ui.accountView = this.accountView = new AccountView();
|
app.ui.accountView = this.accountView = new AccountView();
|
||||||
|
|
||||||
@@ -115,9 +115,9 @@ define([
|
|||||||
} else {
|
} else {
|
||||||
var current_page = null;
|
var current_page = null;
|
||||||
}
|
}
|
||||||
this.switchCurrentView(this.librariesView);
|
this.switchCurrentView(this.reposView);
|
||||||
this.sideNavView.setCurTab('libraries');
|
this.sideNavView.setCurTab('libraries');
|
||||||
this.librariesView.show({'current_page': current_page});
|
this.reposView.show({'current_page': current_page});
|
||||||
},
|
},
|
||||||
|
|
||||||
showLibraryDir: function(repo_id, path) {
|
showLibraryDir: function(repo_id, path) {
|
||||||
@@ -126,21 +126,21 @@ define([
|
|||||||
} else {
|
} else {
|
||||||
path = '/';
|
path = '/';
|
||||||
}
|
}
|
||||||
this.switchCurrentView(this.libraryDirView);
|
this.switchCurrentView(this.dirView);
|
||||||
this.libraryDirView.show(repo_id, path);
|
this.dirView.show(repo_id, path);
|
||||||
this.sideNavView.setCurTab('libraries');
|
this.sideNavView.setCurTab('libraries');
|
||||||
},
|
},
|
||||||
|
|
||||||
showSystemLibrary: function() {
|
showSystemLibrary: function() {
|
||||||
this.switchCurrentView(this.systemLibrariesView);
|
this.switchCurrentView(this.systemReposView);
|
||||||
this.sideNavView.setCurTab('libraries');
|
this.sideNavView.setCurTab('libraries');
|
||||||
this.systemLibrariesView.show();
|
this.systemReposView.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
showTrashLibraries: function() {
|
showTrashLibraries: function() {
|
||||||
this.switchCurrentView(this.trashLibrariesView);
|
this.switchCurrentView(this.trashReposView);
|
||||||
this.sideNavView.setCurTab('libraries');
|
this.sideNavView.setCurTab('libraries');
|
||||||
this.trashLibrariesView.show();
|
this.trashReposView.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -5,8 +5,8 @@ define([
|
|||||||
'common',
|
'common',
|
||||||
'moment',
|
'moment',
|
||||||
'app/views/fileupload',
|
'app/views/fileupload',
|
||||||
'sysadmin-app/views/library-dirent',
|
'sysadmin-app/views/dirent',
|
||||||
'sysadmin-app/collection/library-dirents'
|
'sysadmin-app/collection/dirents'
|
||||||
], function($, _, Backbone, Common, Moment, FileUploadView,
|
], function($, _, Backbone, Common, Moment, FileUploadView,
|
||||||
DirentView, DirentCollection) {
|
DirentView, DirentCollection) {
|
||||||
'use strict';
|
'use strict';
|
@@ -8,7 +8,7 @@ define([
|
|||||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibraryDirentView = HLItemView.extend({
|
var DirentView = HLItemView.extend({
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
template: _.template($('#dirent-item-tmpl').html()),
|
template: _.template($('#dirent-item-tmpl').html()),
|
||||||
@@ -76,5 +76,5 @@ define([
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryDirentView;
|
return DirentView;
|
||||||
});
|
});
|
@@ -11,7 +11,7 @@ define([
|
|||||||
Select2, HLItemView) {
|
Select2, HLItemView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibraryView = HLItemView.extend({
|
var RepoView = HLItemView.extend({
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
template: _.template($('#library-item-tmpl').html()),
|
template: _.template($('#library-item-tmpl').html()),
|
||||||
@@ -107,8 +107,12 @@ define([
|
|||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var data = this.model.toJSON(),
|
var data = this.model.toJSON(),
|
||||||
|
icon_size = Common.isHiDPI() ? 96 : 24,
|
||||||
|
icon_url = this.model.getIconUrl(icon_size),
|
||||||
last_accessed = Moment(data['last_accessed']);
|
last_accessed = Moment(data['last_accessed']);
|
||||||
|
|
||||||
|
data['icon_url'] = icon_url;
|
||||||
|
data['icon_title'] = this.model.getIconTitle();
|
||||||
data['enable_sys_admin_view_repo'] = app.pageOptions.enable_sys_admin_view_repo;
|
data['enable_sys_admin_view_repo'] = app.pageOptions.enable_sys_admin_view_repo;
|
||||||
data['is_pro'] = app.pageOptions.is_pro;
|
data['is_pro'] = app.pageOptions.is_pro;
|
||||||
data['time'] = last_accessed.format('LLLL');
|
data['time'] = last_accessed.format('LLLL');
|
||||||
@@ -121,5 +125,5 @@ define([
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryView;
|
return RepoView;
|
||||||
});
|
});
|
@@ -4,26 +4,26 @@ define([
|
|||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'moment',
|
'moment',
|
||||||
'sysadmin-app/views/library',
|
'sysadmin-app/views/repo',
|
||||||
'sysadmin-app/collection/libraries'
|
'sysadmin-app/collection/repos'
|
||||||
], function($, _, Backbone, Common, Moment, LibraryView, LibraryCollection) {
|
], function($, _, Backbone, Common, Moment, RepoView, RepoCollection) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibrariesView = Backbone.View.extend({
|
var ReposView = Backbone.View.extend({
|
||||||
|
|
||||||
id: 'admin-libraries',
|
id: 'libraries',
|
||||||
|
|
||||||
template: _.template($("#libraries-tmpl").html()),
|
template: _.template($("#libraries-tmpl").html()),
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.libraryCollection = new LibraryCollection();
|
this.repoCollection = new RepoCollection();
|
||||||
this.listenTo(this.libraryCollection, 'add', this.addOne);
|
this.listenTo(this.repoCollection, 'add', this.addOne);
|
||||||
this.listenTo(this.libraryCollection, 'reset', this.reset);
|
this.listenTo(this.repoCollection, 'reset', this.reset);
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var data = {'cur_tab': 'all',};
|
var data = {'cur_tab': 'all'};
|
||||||
this.$el.html(this.template(data));
|
this.$el.html(this.template(data));
|
||||||
this.$table = this.$('table');
|
this.$table = this.$('table');
|
||||||
this.$tableBody = $('tbody', this.$table);
|
this.$tableBody = $('tbody', this.$table);
|
||||||
@@ -49,9 +49,9 @@ define([
|
|||||||
|
|
||||||
getNextPage: function() {
|
getNextPage: function() {
|
||||||
this.initPage();
|
this.initPage();
|
||||||
var current_page = this.libraryCollection.state.current_page;
|
var current_page = this.repoCollection.state.current_page;
|
||||||
if (this.libraryCollection.state.hasNextPage) {
|
if (this.repoCollection.state.hasNextPage) {
|
||||||
this.libraryCollection.getPage(current_page + 1, {
|
this.repoCollection.getPage(current_page + 1, {
|
||||||
reset: true
|
reset: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -61,9 +61,9 @@ define([
|
|||||||
|
|
||||||
getPreviousPage: function() {
|
getPreviousPage: function() {
|
||||||
this.initPage();
|
this.initPage();
|
||||||
var current_page = this.libraryCollection.state.current_page;
|
var current_page = this.repoCollection.state.current_page;
|
||||||
if ( current_page > 1) {
|
if ( current_page > 1) {
|
||||||
this.libraryCollection.getPage(current_page - 1, {
|
this.repoCollection.getPage(current_page - 1, {
|
||||||
reset: true
|
reset: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ define([
|
|||||||
var _this = this,
|
var _this = this,
|
||||||
current_page = this.option.current_page || 1;
|
current_page = this.option.current_page || 1;
|
||||||
|
|
||||||
this.libraryCollection.fetch({
|
this.repoCollection.fetch({
|
||||||
data: {'page': current_page},
|
data: {'page': current_page},
|
||||||
cache: false, // for IE
|
cache: false, // for IE
|
||||||
reset: true,
|
reset: true,
|
||||||
@@ -110,13 +110,13 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
var length = this.libraryCollection.length,
|
var length = this.repoCollection.length,
|
||||||
current_page = this.libraryCollection.state.current_page;
|
current_page = this.repoCollection.state.current_page;
|
||||||
|
|
||||||
this.$loadingTip.hide();
|
this.$loadingTip.hide();
|
||||||
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
this.libraryCollection.each(this.addOne, this);
|
this.repoCollection.each(this.addOne, this);
|
||||||
this.$table.show();
|
this.$table.show();
|
||||||
this.renderPaginator();
|
this.renderPaginator();
|
||||||
} else {
|
} else {
|
||||||
@@ -127,13 +127,13 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderPaginator: function() {
|
renderPaginator: function() {
|
||||||
if (this.libraryCollection.state.hasNextPage) {
|
if (this.repoCollection.state.hasNextPage) {
|
||||||
this.$jsNext.show();
|
this.$jsNext.show();
|
||||||
} else {
|
} else {
|
||||||
this.$jsNext.hide();
|
this.$jsNext.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
var current_page = this.libraryCollection.state.current_page;
|
var current_page = this.repoCollection.state.current_page;
|
||||||
if (current_page > 1) {
|
if (current_page > 1) {
|
||||||
this.$jsPrevious.show();
|
this.$jsPrevious.show();
|
||||||
} else {
|
} else {
|
||||||
@@ -142,11 +142,11 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
addOne: function(library) {
|
addOne: function(library) {
|
||||||
var view = new LibraryView({model: library});
|
var view = new RepoView({model: library});
|
||||||
this.$tableBody.append(view.render().el);
|
this.$tableBody.append(view.render().el);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibrariesView;
|
return ReposView;
|
||||||
|
|
||||||
});
|
});
|
@@ -3,19 +3,19 @@ define([
|
|||||||
'underscore',
|
'underscore',
|
||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'sysadmin-app/models/system-library'
|
'sysadmin-app/models/system-repo'
|
||||||
], function($, _, Backbone, Common, SystemLibrary) {
|
], function($, _, Backbone, Common, SystemRepo) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var SystemLibraryView = Backbone.View.extend({
|
var SystemRepoView = Backbone.View.extend({
|
||||||
|
|
||||||
id: "admin-system-library",
|
id: "system-library",
|
||||||
|
|
||||||
template: _.template($("#system-library-tmpl").html()),
|
template: _.template($("#system-library-tmpl").html()),
|
||||||
itemTemplate: _.template($("#system-library-item-tmpl").html()),
|
itemTemplate: _.template($("#system-library-item-tmpl").html()),
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.systemLibrary = new SystemLibrary();
|
this.systemRepo = new SystemRepo();
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ define([
|
|||||||
this.initPage();
|
this.initPage();
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
this.systemLibrary.fetch({
|
this.systemRepo.fetch({
|
||||||
url: Common.getUrl({name: 'admin-system-library'}),
|
url: Common.getUrl({name: 'admin-system-library'}),
|
||||||
cache: false, // for IE
|
cache: false, // for IE
|
||||||
reset: true,
|
reset: true,
|
||||||
@@ -71,11 +71,11 @@ define([
|
|||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
this.$loadingTip.hide();
|
this.$loadingTip.hide();
|
||||||
this.$tableBody.html(this.itemTemplate(this.systemLibrary.toJSON()));
|
this.$tableBody.html(this.itemTemplate(this.systemRepo.toJSON()));
|
||||||
this.$table.show();
|
this.$table.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return SystemLibraryView;
|
return SystemRepoView;
|
||||||
});
|
});
|
@@ -8,7 +8,7 @@ define([
|
|||||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var LibraryView = HLItemView.extend({
|
var TrashRepoView = HLItemView.extend({
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
template: _.template($('#trash-library-item-tmpl').html()),
|
template: _.template($('#trash-library-item-tmpl').html()),
|
||||||
@@ -60,8 +60,12 @@ define([
|
|||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var data = this.model.toJSON(),
|
var data = this.model.toJSON(),
|
||||||
|
icon_size = Common.isHiDPI() ? 96 : 24,
|
||||||
|
icon_url = this.model.getIconUrl(icon_size),
|
||||||
delete_time = Moment(data['delete_time']);
|
delete_time = Moment(data['delete_time']);
|
||||||
|
|
||||||
|
data['icon_url'] = icon_url;
|
||||||
|
data['icon_title'] = this.model.getIconTitle();
|
||||||
data['time'] = delete_time.format('LLLL');
|
data['time'] = delete_time.format('LLLL');
|
||||||
data['time_from_now'] = Common.getRelativeTimeStr(delete_time);
|
data['time_from_now'] = Common.getRelativeTimeStr(delete_time);
|
||||||
|
|
||||||
@@ -72,5 +76,5 @@ define([
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return LibraryView;
|
return TrashRepoView;
|
||||||
});
|
});
|
@@ -4,22 +4,22 @@ define([
|
|||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'moment',
|
'moment',
|
||||||
'sysadmin-app/views/trash-library',
|
'sysadmin-app/views/trash-repo',
|
||||||
'sysadmin-app/collection/trash-libraries'
|
'sysadmin-app/collection/trash-repos'
|
||||||
], function($, _, Backbone, Common, Moment, TrashLibraryView,
|
], function($, _, Backbone, Common, Moment, TrashRepoView,
|
||||||
TrashLibraryCollection) {
|
TrashRepoCollection) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var TrashLibrariesView = Backbone.View.extend({
|
var TrashReposView = Backbone.View.extend({
|
||||||
|
|
||||||
id: 'admin-trash-libraries',
|
id: 'trash-libraries',
|
||||||
|
|
||||||
template: _.template($("#trash-libraries-tmpl").html()),
|
template: _.template($("#trash-libraries-tmpl").html()),
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.trashLibraryCollection = new TrashLibraryCollection();
|
this.trashRepoCollection = new TrashRepoCollection();
|
||||||
this.listenTo(this.trashLibraryCollection, 'add', this.addOne);
|
this.listenTo(this.trashRepoCollection, 'add', this.addOne);
|
||||||
this.listenTo(this.trashLibraryCollection, 'reset', this.reset);
|
this.listenTo(this.trashRepoCollection, 'reset', this.reset);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
@@ -75,7 +75,7 @@ define([
|
|||||||
this.initPage();
|
this.initPage();
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
this.trashLibraryCollection.fetch({
|
this.trashRepoCollection.fetch({
|
||||||
data: {},
|
data: {},
|
||||||
cache: false, // for IE
|
cache: false, // for IE
|
||||||
reset: true,
|
reset: true,
|
||||||
@@ -96,12 +96,12 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
var length = this.trashLibraryCollection.length;
|
var length = this.trashRepoCollection.length;
|
||||||
|
|
||||||
this.$loadingTip.hide();
|
this.$loadingTip.hide();
|
||||||
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
this.trashLibraryCollection.each(this.addOne, this);
|
this.trashRepoCollection.each(this.addOne, this);
|
||||||
this.$table.show();
|
this.$table.show();
|
||||||
} else {
|
} else {
|
||||||
this.$emptyTip.show();
|
this.$emptyTip.show();
|
||||||
@@ -109,11 +109,11 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
addOne: function(library) {
|
addOne: function(library) {
|
||||||
var view = new TrashLibraryView({model: library});
|
var view = new TrashRepoView({model: library});
|
||||||
this.$tableBody.append(view.render().el);
|
this.$tableBody.append(view.render().el);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return TrashLibrariesView;
|
return TrashReposView;
|
||||||
|
|
||||||
});
|
});
|
Reference in New Issue
Block a user