diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index 10ac828b3b..2685f0ab51 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -22,7 +22,8 @@ try: except ImportError: SEACLOUD_MODE = False -from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, TRAFFIC_STATS_ENABLED +from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, TRAFFIC_STATS_ENABLED, \ + is_pro_version try: from seahub.settings import ENABLE_PUBFILE @@ -85,4 +86,5 @@ def base(request): 'FILE_SERVER_ROOT': file_server_root, 'enable_guest_invitation': ENABLE_GUEST_INVITATION, 'enable_terms_and_conditions': dj_settings.ENABLE_TERMS_AND_CONDITIONS, + 'is_pro': True if is_pro_version() else False, } diff --git a/seahub/templates/js/sysadmin-templates.html b/seahub/templates/js/sysadmin-templates.html index d727dd2581..1141811bee 100644 --- a/seahub/templates/js/sysadmin-templates.html +++ b/seahub/templates/js/sysadmin-templates.html @@ -67,9 +67,11 @@ {% trans "Terms and Conditions" %} {% endif %} + <% if (app.pageOptions.is_pro) { %>
  • {% trans "Admin Logs" %}
  • + <% } %> <% if (cur_tab == 'libraries') { %> @@ -845,11 +847,11 @@ diff --git a/seahub/templates/sysadmin/base.html b/seahub/templates/sysadmin/base.html index 54ef3b1eeb..02a2685bca 100644 --- a/seahub/templates/sysadmin/base.html +++ b/seahub/templates/sysadmin/base.html @@ -73,9 +73,11 @@ {% trans "Terms and Conditions" %} {% endif %} + {% if is_pro %}
  • {% trans "Admin Logs" %}
  • + {% endif %} {% endblock %} diff --git a/static/scripts/common.js b/static/scripts/common.js index e89d4cca50..3a32fe1c5e 100644 --- a/static/scripts/common.js +++ b/static/scripts/common.js @@ -179,7 +179,6 @@ define([ case 'admin-trash-library': return siteRoot + 'api/v2.1/admin/trash-libraries/' + options.repo_id + '/'; case 'admin_shares': return siteRoot + 'api/v2.1/admin/shares/'; case 'sys_group_admin_export_excel': return siteRoot + 'sys/groupadmin/export-excel/'; - case 'admin-logs': return siteRoot + 'api/v2.1/admin/admin-logs/'; } }, diff --git a/static/scripts/sysadmin-app/collection/admin-logs.js b/static/scripts/sysadmin-app/collection/admin-logs.js index 02c8837c58..bbb8265deb 100644 --- a/static/scripts/sysadmin-app/collection/admin-logs.js +++ b/static/scripts/sysadmin-app/collection/admin-logs.js @@ -16,16 +16,15 @@ define([ state: { firstPage: 1, - pageSize: 100, + pageSize: 100 }, - // Setting `null` as the value of any mapping - // will remove it from the query string. + // Setting a parameter mapping value to null removes it from the query string queryParams: { currentPage: "page", pageSize: "per_page", totalPages: null, - totalRecords: null, + totalRecords: null }, parseState: function (resp) { diff --git a/static/scripts/sysadmin-app/views/admin-log.js b/static/scripts/sysadmin-app/views/admin-log.js index adceb41d22..784f2b05e9 100644 --- a/static/scripts/sysadmin-app/views/admin-log.js +++ b/static/scripts/sysadmin-app/views/admin-log.js @@ -21,12 +21,71 @@ define([ }, render: function() { - var data = this.model.toJSON(), - created_at = Moment(data['datetime']); + var data = {'email': this.model.get('email')}, + created_at = Moment(this.model.get('datetime')); data['time'] = created_at.format('LLLL'); data['time_from_now'] = Common.getRelativeTimeStr(created_at); + var detail = this.model.get('detail'); + + var user_url = function(user_id) { + return app.config.siteRoot + 'useradmin/info/' + encodeURIComponent(user_id) + '/'; + }; + + data.admin_user_url = user_url(data.email); + + switch(this.model.get('operation')) { + case 'repo_delete': + data.op_title = gettext("Delete Library"); + data.op_details = gettext("Deleted library {library_name}") + .replace('{library_name}', '' + Common.HTMLescape(detail.name) + ''); + break; + + case 'repo_transfer': + data.op_title = gettext("Transfer Library"); + data.op_details = gettext("Transferred library {library_name} from {user_from} to {user_to}") + .replace('{user_from}', '' + Common.HTMLescape(detail.from) + '') + .replace('{user_to}', '' + Common.HTMLescape(detail.to) + ''); + if (app.pageOptions.is_pro && app.pageOptions.enable_sys_admin_view_repo) { + data.op_details = data.op_details.replace('{library_name}', '' + Common.HTMLescape(detail.name) + ''); + } else { + data.op_details = data.op_details.replace('{library_name}', '' + Common.HTMLescape(detail.name) + ''); + } + break; + + case 'group_create': + data.op_title = gettext("Create Group"); + data.op_details = gettext("Created group {group_name}").replace('{group_name}', '' + Common.HTMLescape(detail.name) + ''); + break; + + case 'group_transfer': + data.op_title = gettext("Transfer Group"); + data.op_details = gettext("Transferred group {group_name} from {user_from} to {user_to}") + .replace('{group_name}', '' + Common.HTMLescape(detail.name) + '') + .replace('{user_from}', '' + Common.HTMLescape(detail.from) + '') + .replace('{user_to}', '' + Common.HTMLescape(detail.to) + ''); + break; + + case 'group_delete': + data.op_title = gettext("Delete Group"); + data.op_details = gettext("Deleted group {group_name}") + .replace('{group_name}', '' + Common.HTMLescape(detail.name) + ''); + break; + + case 'user_add': + data.op_title = gettext("Add User"); + data.op_details = gettext("Added user {user}") + .replace('{user}', '' + Common.HTMLescape(detail.email) + ''); + break; + + case 'user_delete': + data.op_title = gettext("Delete User"); + data.op_details = gettext("Deleted user {user}") + .replace('{user}', '' + Common.HTMLescape(detail.email) + ''); + break; + } + this.$el.html(this.template(data)); return this; diff --git a/static/scripts/sysadmin-app/views/admin-logs.js b/static/scripts/sysadmin-app/views/admin-logs.js index 330bc79e96..35a3d3aa4f 100644 --- a/static/scripts/sysadmin-app/views/admin-logs.js +++ b/static/scripts/sysadmin-app/views/admin-logs.js @@ -129,6 +129,9 @@ define([ err_msg = gettext("Failed. Please check the network."); } Common.feedback(err_msg, 'error'); + }, + complete: function() { + _this.$loadingTip.hide(); } }); }