mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
add admin role/log feature
This commit is contained in:
@@ -2,16 +2,16 @@ define([
|
||||
'underscore',
|
||||
'backbone.paginator',
|
||||
'common',
|
||||
'sysadmin-app/models/admin-log'
|
||||
], function(_, BackbonePaginator, Common, AdminLogModel) {
|
||||
'sysadmin-app/models/admin-login-log'
|
||||
], function(_, BackbonePaginator, Common, AdminLoginLogModel) {
|
||||
'use strict';
|
||||
|
||||
var AdminLogCollection = Backbone.PageableCollection.extend({
|
||||
var AdminLoginLogCollection = Backbone.PageableCollection.extend({
|
||||
|
||||
model: AdminLogModel,
|
||||
model: AdminLoginLogModel,
|
||||
|
||||
url: function() {
|
||||
return Common.getUrl({name: 'admin-logs'});
|
||||
return Common.getUrl({name: 'admin-login-logs'});
|
||||
},
|
||||
|
||||
state: {
|
||||
@@ -35,5 +35,5 @@ define([
|
||||
return resp.data;
|
||||
}
|
||||
});
|
||||
return AdminLogCollection;
|
||||
return AdminLoginLogCollection;
|
||||
});
|
@@ -0,0 +1,39 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone.paginator',
|
||||
'common',
|
||||
'sysadmin-app/models/admin-operation-log'
|
||||
], function(_, BackbonePaginator, Common, AdminOperationLogModel) {
|
||||
'use strict';
|
||||
|
||||
var AdminOperationLogCollection = Backbone.PageableCollection.extend({
|
||||
|
||||
model: AdminOperationLogModel,
|
||||
|
||||
url: function() {
|
||||
return Common.getUrl({name: 'admin-operation-logs'});
|
||||
},
|
||||
|
||||
state: {
|
||||
firstPage: 1,
|
||||
pageSize: 100
|
||||
},
|
||||
|
||||
// Setting a parameter mapping value to null removes it from the query string
|
||||
queryParams: {
|
||||
currentPage: "page",
|
||||
pageSize: "per_page",
|
||||
totalPages: null,
|
||||
totalRecords: null
|
||||
},
|
||||
|
||||
parseState: function (resp) {
|
||||
return {totalRecords: resp.total_count};
|
||||
},
|
||||
|
||||
parseRecords: function (resp) {
|
||||
return resp.data;
|
||||
}
|
||||
});
|
||||
return AdminOperationLogCollection;
|
||||
});
|
11
static/scripts/sysadmin-app/models/admin-login-log.js
Normal file
11
static/scripts/sysadmin-app/models/admin-login-log.js
Normal file
@@ -0,0 +1,11 @@
|
||||
define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function(_, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var AdminLoginLogModel = Backbone.Model.extend({});
|
||||
|
||||
return AdminLoginLogModel;
|
||||
});
|
@@ -18,13 +18,15 @@ define([
|
||||
'sysadmin-app/views/search-groups',
|
||||
'sysadmin-app/views/group-repos',
|
||||
'sysadmin-app/views/group-members',
|
||||
'sysadmin-app/views/admin-logs',
|
||||
'sysadmin-app/views/admin-operation-logs',
|
||||
'sysadmin-app/views/admin-login-logs',
|
||||
'app/views/account'
|
||||
], function($, Backbone, Common, SideNavView, DashboardView,
|
||||
DesktopDevicesView, MobileDevicesView, DeviceErrorsView,
|
||||
ReposView, SearchReposView, SystemReposView, TrashReposView,
|
||||
SearchTrashReposView, DirView, GroupsView, SearchGroupsView,
|
||||
GroupReposView, GroupMembersView, AdminLogsView, AccountView) {
|
||||
GroupReposView, GroupMembersView, AdminOperationLogsview, AdminLoginLogsView,
|
||||
AccountView) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -46,7 +48,8 @@ define([
|
||||
'groups/:group_id/': 'showGroupLibraries',
|
||||
'groups/:group_id/libs/': 'showGroupLibraries',
|
||||
'groups/:group_id/members/': 'showGroupMembers',
|
||||
'admin-logs/': 'showAdminLogs',
|
||||
'admin-operation-logs/': 'showAdminOperationLogs',
|
||||
'admin-login-logs/': 'showAdminLoginLogs',
|
||||
// Default
|
||||
'*actions': 'showDashboard'
|
||||
},
|
||||
@@ -79,7 +82,8 @@ define([
|
||||
this.groupReposView = new GroupReposView();
|
||||
this.groupMembersView = new GroupMembersView();
|
||||
|
||||
this.adminLogsView = new AdminLogsView();
|
||||
this.adminOperationLogsview = new AdminOperationLogsview();
|
||||
this.adminLoginLogsView = new AdminLoginLogsView();
|
||||
|
||||
app.ui.accountView = this.accountView = new AccountView();
|
||||
|
||||
@@ -96,12 +100,21 @@ define([
|
||||
},
|
||||
|
||||
showDashboard: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_view_system_info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.dashboardView);
|
||||
this.sideNavView.setCurTab('dashboard');
|
||||
this.dashboardView.show();
|
||||
},
|
||||
|
||||
showDesktopDevices: function(current_page) {
|
||||
if (!app.pageOptions.is_default_admin) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
var url = window.location.href;
|
||||
var page = url.match(/.*?page=(\d+)/);
|
||||
if (page) {
|
||||
@@ -115,6 +128,11 @@ define([
|
||||
},
|
||||
|
||||
showMobileDevices: function(current_page) {
|
||||
if (!app.pageOptions.is_default_admin) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
var url = window.location.href;
|
||||
var page = url.match(/.*?page=(\d+)/);
|
||||
if (page) {
|
||||
@@ -128,12 +146,22 @@ define([
|
||||
},
|
||||
|
||||
showDeviceErrors: function() {
|
||||
if (!app.pageOptions.is_default_admin) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.deviceErrorsView);
|
||||
this.sideNavView.setCurTab('devices');
|
||||
this.deviceErrorsView.show();
|
||||
},
|
||||
|
||||
showLibraries: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_library) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
// url_match: null or an array like ["http://127.0.0.1:8000/sysadmin/#libraries/?page=2", "2"]
|
||||
var url_match = location.href.match(/.*?page=(\d+)/);
|
||||
var page = url_match ? url_match[1] : 1; // 1: default
|
||||
@@ -144,6 +172,11 @@ define([
|
||||
},
|
||||
|
||||
showSearchLibraries: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_library) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
// url_match: null or an array
|
||||
var url_match = location.href.match(/.*?name=(.*)&owner=(.*)/); // search by repo_name/owner
|
||||
var repo_name = url_match ? url_match[1] : '';
|
||||
@@ -158,6 +191,11 @@ define([
|
||||
},
|
||||
|
||||
showLibraryDir: function(repo_id, path) {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_library) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path) {
|
||||
path = '/' + path;
|
||||
} else {
|
||||
@@ -169,6 +207,11 @@ define([
|
||||
},
|
||||
|
||||
showSystemLibrary: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_library) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.systemReposView);
|
||||
this.sideNavView.setCurTab('libraries', {'option': 'system'});
|
||||
this.systemReposView.show();
|
||||
@@ -176,6 +219,11 @@ define([
|
||||
|
||||
// show trash libs by page
|
||||
showTrashLibraries: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_library) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
// url_match: null or an array
|
||||
var url_match = location.href.match(/.*?page=(\d+)/);
|
||||
var page = url_match ? url_match[1] : 1; // 1: default
|
||||
@@ -187,6 +235,11 @@ define([
|
||||
|
||||
// search trash libs by owner
|
||||
showSearchTrashLibraries: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_library) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
// url_match: null or an array
|
||||
var url_match = location.href.match(/.*?name=(.*)/); // search by owner
|
||||
var owner = url_match ? url_match[1] : '';
|
||||
@@ -197,6 +250,11 @@ define([
|
||||
},
|
||||
|
||||
showGroups: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_group) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
// url_match: null or an array like ["http://127.0.0.1:8000/sysadmin/#groups/?page=2", "2"]
|
||||
var url_match = location.href.match(/.*?page=(\d+)/);
|
||||
var page = url_match ? url_match[1] : 1; // 1: default
|
||||
@@ -207,6 +265,11 @@ define([
|
||||
},
|
||||
|
||||
showSearchGroups: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_group) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
// url_match: null or an array
|
||||
var url_match = location.href.match(/.*?name=(.*)/); // search by group_name
|
||||
var group_name = url_match ? url_match[1] : '';
|
||||
@@ -219,18 +282,33 @@ define([
|
||||
},
|
||||
|
||||
showGroupLibraries: function(group_id) {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_group) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.groupReposView);
|
||||
this.sideNavView.setCurTab('groups');
|
||||
this.groupReposView.show(group_id);
|
||||
},
|
||||
|
||||
showGroupMembers: function(group_id) {
|
||||
if (!app.pageOptions.admin_permissions.can_manage_group) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.groupMembersView);
|
||||
this.sideNavView.setCurTab('groups');
|
||||
this.groupMembersView.show(group_id);
|
||||
},
|
||||
|
||||
showAdminLogs: function() {
|
||||
showAdminOperationLogs: function() {
|
||||
if (!app.pageOptions.admin_permissions.can_view_admin_log) {
|
||||
this.showDashboard();
|
||||
return false;
|
||||
}
|
||||
|
||||
var url = window.location.href;
|
||||
var page = url.match(/.*?page=(\d+)/);
|
||||
if (page) {
|
||||
@@ -239,9 +317,23 @@ define([
|
||||
var current_page = null;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.adminLogsView);
|
||||
this.switchCurrentView(this.adminOperationLogsview);
|
||||
this.sideNavView.setCurTab('admin-logs');
|
||||
this.adminLogsView.show({'current_page': current_page});
|
||||
this.adminOperationLogsview.show({'current_page': current_page});
|
||||
},
|
||||
|
||||
showAdminLoginLogs: function() {
|
||||
var url = window.location.href;
|
||||
var page = url.match(/.*?page=(\d+)/);
|
||||
if (page) {
|
||||
var current_page = page[1];
|
||||
} else {
|
||||
var current_page = null;
|
||||
}
|
||||
|
||||
this.switchCurrentView(this.adminLoginLogsView);
|
||||
this.sideNavView.setCurTab('admin-logs');
|
||||
this.adminLoginLogsView.show({'current_page': current_page});
|
||||
}
|
||||
|
||||
});
|
||||
|
48
static/scripts/sysadmin-app/views/admin-login-log.js
Normal file
48
static/scripts/sysadmin-app/views/admin-login-log.js
Normal file
@@ -0,0 +1,48 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'moment',
|
||||
'app/views/widgets/hl-item-view'
|
||||
], function($, _, Backbone, Common, Moment, HLItemView) {
|
||||
'use strict';
|
||||
|
||||
var AdminLoginLogView = HLItemView.extend({
|
||||
tagName: 'tr',
|
||||
|
||||
template: _.template($('#admin-login-log-item-tmpl').html()),
|
||||
|
||||
events: {
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
HLItemView.prototype.initialize.call(this);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data = {
|
||||
'email': this.model.get('email'),
|
||||
'login_ip': this.model.get('login_ip'),
|
||||
'login_success': this.model.get('login_success')
|
||||
},
|
||||
login_time = Moment(this.model.get('login_time'));
|
||||
|
||||
data['time'] = login_time.format('LLLL');
|
||||
data['time_from_now'] = Common.getRelativeTimeStr(login_time);
|
||||
|
||||
var user_url = function(user_id) {
|
||||
return app.config.siteRoot + 'useradmin/info/' + encodeURIComponent(user_id) + '/';
|
||||
};
|
||||
|
||||
data.admin_user_url = user_url(data.email);
|
||||
|
||||
this.$el.html(this.template(data));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return AdminLoginLogView;
|
||||
});
|
162
static/scripts/sysadmin-app/views/admin-login-logs.js
Normal file
162
static/scripts/sysadmin-app/views/admin-login-logs.js
Normal file
@@ -0,0 +1,162 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/views/admin-login-log',
|
||||
'sysadmin-app/collection/admin-login-logs'
|
||||
], function($, _, Backbone, Common, AdminLoginLogView, AdminLoginLogCollection) {
|
||||
'use strict';
|
||||
|
||||
var AdminLoginsView = Backbone.View.extend({
|
||||
|
||||
id: 'admin-login-logs',
|
||||
|
||||
template: _.template($("#admin-login-logs-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.adminLoginLogCollection = new AdminLoginLogCollection();
|
||||
this.listenTo(this.adminLoginLogCollection, 'add', this.addOne);
|
||||
this.listenTo(this.adminLoginLogCollection, 'reset', this.reset);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template());
|
||||
|
||||
this.$table = this.$('table');
|
||||
this.$tableBody = $('tbody', this.$table);
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$emptyTip = this.$('.empty-tips');
|
||||
|
||||
this.$jsPrevious = this.$('.js-previous');
|
||||
this.$jsNext = this.$('.js-next');
|
||||
},
|
||||
|
||||
events: {
|
||||
'click #paginator .js-next': 'getNextPage',
|
||||
'click #paginator .js-previous': 'getPreviousPage'
|
||||
},
|
||||
|
||||
getNextPage: function() {
|
||||
this.initPage();
|
||||
this.adminLoginLogCollection.getNextPage({reset: true});
|
||||
return false;
|
||||
},
|
||||
|
||||
getPreviousPage: function() {
|
||||
this.initPage();
|
||||
this.adminLoginLogCollection.getPreviousPage({reset: true});
|
||||
return false;
|
||||
},
|
||||
|
||||
initPage: function() {
|
||||
this.$loadingTip.show();
|
||||
this.$table.hide();
|
||||
this.$tableBody.empty();
|
||||
this.$emptyTip.hide();
|
||||
|
||||
this.$jsNext.hide();
|
||||
this.$jsPrevious.hide();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.detach();
|
||||
this.attached = false;
|
||||
},
|
||||
|
||||
show: function(option) {
|
||||
this.option = option;
|
||||
if (!this.attached) {
|
||||
this.attached = true;
|
||||
$("#right-panel").html(this.$el);
|
||||
}
|
||||
this.getContent();
|
||||
},
|
||||
|
||||
renderPaginator: function() {
|
||||
if (this.adminLoginLogCollection.hasNextPage()) {
|
||||
this.$jsNext.show();
|
||||
} else {
|
||||
this.$jsNext.hide();
|
||||
}
|
||||
|
||||
if (this.adminLoginLogCollection.hasPreviousPage()) {
|
||||
this.$jsPrevious.show();
|
||||
} else {
|
||||
this.$jsPrevious.hide();
|
||||
}
|
||||
},
|
||||
|
||||
getContent: function() {
|
||||
this.initPage();
|
||||
|
||||
var _this = this;
|
||||
var current_page = parseInt(this.option.current_page) || 1;
|
||||
var first_page = parseInt(this.adminLoginLogCollection.state.firstPage);
|
||||
var total_page = parseInt(this.adminLoginLogCollection.state.totalPages);
|
||||
|
||||
// `currentPage` must be firstPage <= currentPage <= totalPages if 1-based.
|
||||
if (first_page <= current_page && current_page <= total_page) {
|
||||
this.adminLoginLogCollection.getPage(current_page).done(function () {
|
||||
_this.$loadingTip.hide();
|
||||
var current_page = _this.adminLoginLogCollection.state.currentPage;
|
||||
app.router.navigate('admin-login-logs/?page=' + current_page);
|
||||
|
||||
if (_this.adminLoginLogCollection.length > 0) {
|
||||
_this.$table.show();
|
||||
} else {
|
||||
_this.$emptyTip.show();
|
||||
}
|
||||
|
||||
_this.renderPaginator();
|
||||
});
|
||||
} else {
|
||||
// always get the first page if not use `getPage` method
|
||||
_this.adminLoginLogCollection.state.currentPage = 1;
|
||||
this.adminLoginLogCollection.fetch({
|
||||
cache: false,
|
||||
reset: true,
|
||||
error: function(collection, response, opts) {
|
||||
var err_msg;
|
||||
if (response.responseText) {
|
||||
if (response['status'] == 401 || response['status'] == 403) {
|
||||
err_msg = gettext("Permission error");
|
||||
} else {
|
||||
err_msg = $.parseJSON(response.responseText).error_msg;
|
||||
}
|
||||
} else {
|
||||
err_msg = gettext("Failed. Please check the network.");
|
||||
}
|
||||
Common.feedback(err_msg, 'error');
|
||||
},
|
||||
complete: function() {
|
||||
_this.$loadingTip.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
addOne: function(login) {
|
||||
var view = new AdminLoginLogView({model: login});
|
||||
this.$tableBody.append(view.render().el);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.$loadingTip.hide();
|
||||
|
||||
var current_page = this.adminLoginLogCollection.state.currentPage;
|
||||
app.router.navigate('admin-login-logs/?page=' + current_page);
|
||||
|
||||
if (this.adminLoginLogCollection.length > 0) {
|
||||
this.adminLoginLogCollection.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
}
|
||||
|
||||
this.renderPaginator();
|
||||
}
|
||||
});
|
||||
return AdminLoginsView;
|
||||
});
|
@@ -3,26 +3,26 @@ define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'sysadmin-app/views/admin-log',
|
||||
'sysadmin-app/collection/admin-logs'
|
||||
], function($, _, Backbone, Common, AdminLogView, AdminLogCollection) {
|
||||
'sysadmin-app/views/admin-operation-log',
|
||||
'sysadmin-app/collection/admin-operation-logs'
|
||||
], function($, _, Backbone, Common, AdminOperationLogView, AdminOperationLogCollection) {
|
||||
'use strict';
|
||||
|
||||
var AdminLogsView = Backbone.View.extend({
|
||||
var AdminOperationLogsView = Backbone.View.extend({
|
||||
|
||||
id: 'admin-logs',
|
||||
|
||||
template: _.template($("#admin-logs-tmpl").html()),
|
||||
template: _.template($("#admin-operation-logs-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.adminLogCollection = new AdminLogCollection();
|
||||
this.listenTo(this.adminLogCollection, 'add', this.addOne);
|
||||
this.listenTo(this.adminLogCollection, 'reset', this.reset);
|
||||
this.adminOperationLogCollection = new AdminOperationLogCollection();
|
||||
this.listenTo(this.adminOperationLogCollection, 'add', this.addOne);
|
||||
this.listenTo(this.adminOperationLogCollection, 'reset', this.reset);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.append(this.template());
|
||||
this.$el.html(this.template());
|
||||
|
||||
this.$table = this.$('table');
|
||||
this.$tableBody = $('tbody', this.$table);
|
||||
@@ -40,13 +40,13 @@ define([
|
||||
|
||||
getNextPage: function() {
|
||||
this.initPage();
|
||||
this.adminLogCollection.getNextPage({reset: true});
|
||||
this.adminOperationLogCollection.getNextPage({reset: true});
|
||||
return false;
|
||||
},
|
||||
|
||||
getPreviousPage: function() {
|
||||
this.initPage();
|
||||
this.adminLogCollection.getPreviousPage({reset: true});
|
||||
this.adminOperationLogCollection.getPreviousPage({reset: true});
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -75,13 +75,13 @@ define([
|
||||
},
|
||||
|
||||
renderPaginator: function() {
|
||||
if (this.adminLogCollection.hasNextPage()) {
|
||||
if (this.adminOperationLogCollection.hasNextPage()) {
|
||||
this.$jsNext.show();
|
||||
} else {
|
||||
this.$jsNext.hide();
|
||||
}
|
||||
|
||||
if (this.adminLogCollection.hasPreviousPage()) {
|
||||
if (this.adminOperationLogCollection.hasPreviousPage()) {
|
||||
this.$jsPrevious.show();
|
||||
} else {
|
||||
this.$jsPrevious.hide();
|
||||
@@ -93,17 +93,17 @@ define([
|
||||
|
||||
var _this = this;
|
||||
var current_page = parseInt(this.option.current_page) || 1;
|
||||
var first_page = parseInt(this.adminLogCollection.state.firstPage);
|
||||
var total_page = parseInt(this.adminLogCollection.state.totalPages);
|
||||
var first_page = parseInt(this.adminOperationLogCollection.state.firstPage);
|
||||
var total_page = parseInt(this.adminOperationLogCollection.state.totalPages);
|
||||
|
||||
// `currentPage` must be firstPage <= currentPage <= totalPages if 1-based.
|
||||
if (first_page <= current_page && current_page <= total_page) {
|
||||
this.adminLogCollection.getPage(current_page).done(function () {
|
||||
this.adminOperationLogCollection.getPage(current_page).done(function () {
|
||||
_this.$loadingTip.hide();
|
||||
var current_page = _this.adminLogCollection.state.currentPage;
|
||||
app.router.navigate('admin-logs/?page=' + current_page);
|
||||
var current_page = _this.adminOperationLogCollection.state.currentPage;
|
||||
app.router.navigate('admin-operation-logs/?page=' + current_page);
|
||||
|
||||
if (_this.adminLogCollection.length > 0) {
|
||||
if (_this.adminOperationLogCollection.length > 0) {
|
||||
_this.$table.show();
|
||||
} else {
|
||||
_this.$emptyTip.show();
|
||||
@@ -113,8 +113,8 @@ define([
|
||||
});
|
||||
} else {
|
||||
// always get the first page if not use `getPage` method
|
||||
_this.adminLogCollection.state.currentPage = 1;
|
||||
this.adminLogCollection.fetch({
|
||||
_this.adminOperationLogCollection.state.currentPage = 1;
|
||||
this.adminOperationLogCollection.fetch({
|
||||
cache: false,
|
||||
reset: true,
|
||||
error: function(collection, response, opts) {
|
||||
@@ -138,18 +138,18 @@ define([
|
||||
},
|
||||
|
||||
addOne: function(log) {
|
||||
var view = new AdminLogView({model: log});
|
||||
var view = new AdminOperationLogView({model: log});
|
||||
this.$tableBody.append(view.render().el);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.$loadingTip.hide();
|
||||
|
||||
var current_page = this.adminLogCollection.state.currentPage;
|
||||
app.router.navigate('admin-logs/?page=' + current_page);
|
||||
var current_page = this.adminOperationLogCollection.state.currentPage;
|
||||
app.router.navigate('admin-operation-logs/?page=' + current_page);
|
||||
|
||||
if (this.adminLogCollection.length > 0) {
|
||||
this.adminLogCollection.each(this.addOne, this);
|
||||
if (this.adminOperationLogCollection.length > 0) {
|
||||
this.adminOperationLogCollection.each(this.addOne, this);
|
||||
this.$table.show();
|
||||
} else {
|
||||
this.$emptyTip.show();
|
||||
@@ -158,5 +158,5 @@ define([
|
||||
this.renderPaginator();
|
||||
}
|
||||
});
|
||||
return AdminLogsView;
|
||||
return AdminOperationLogsView;
|
||||
});
|
Reference in New Issue
Block a user