Add some redirectings for admin panel

This commit is contained in:
gplane 2017-04-27 18:02:05 +08:00
parent 2ca383628e
commit dfbe6400d4
7 changed files with 62 additions and 13 deletions

View File

@ -165,15 +165,25 @@ class AdminController extends Controller
return view('admin.users'); return view('admin.users');
} }
public function getUserData() public function getUserData(Request $request)
{ {
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at']); $users = collect();
if ($request->has('uid')) {
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at'])
->where('uid', intval($request->input('uid')));
} else {
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at']);
}
return Datatables::of($users)->editColumn('email', function ($user) { return Datatables::of($users)->editColumn('email', function ($user) {
return $user->email ?: 'EMPTY'; return $user->email ?: 'EMPTY';
}) })
->setRowId('uid') ->setRowId('uid')
->addColumn('operations', app('user.current')->getPermission()) ->addColumn('operations', app('user.current')->getPermission())
->addColumn('players_count', function ($user) {
return Player::where('uid', $user->uid)->count();
})
->make(true); ->make(true);
} }
@ -188,9 +198,15 @@ class AdminController extends Controller
return view('admin.players'); return view('admin.players');
} }
public function getPlayerData() public function getPlayerData(Request $request)
{ {
$players = Player::select(['pid', 'uid', 'player_name', 'preference', 'tid_steve', 'tid_alex', 'tid_cape', 'last_modified']); $players = collect();
if ($request->has('uid')) {
$players = Player::select(['pid', 'uid', 'player_name', 'preference', 'tid_steve', 'tid_alex', 'tid_cape', 'last_modified'])
->where('uid', intval($request->input('uid')));
} else {
$players = Player::select(['pid', 'uid', 'player_name', 'preference', 'tid_steve', 'tid_alex', 'tid_cape', 'last_modified']);
}
return Datatables::of($players)->setRowId('pid')->make(true); return Datatables::of($players)->setRowId('pid')->make(true);
} }

View File

@ -2,7 +2,7 @@
* @Author: printempw * @Author: printempw
* @Date: 2016-07-22 14:02:44 * @Date: 2016-07-22 14:02:44
* @Last Modified by: g-plane * @Last Modified by: g-plane
* @Last Modified time: 2017-04-27 08:46:33 * @Last Modified time: 2017-04-27 17:58:47
*/ */
'use strict'; 'use strict';
@ -25,11 +25,11 @@ $(document).ready(function() {
serverSide: true serverSide: true
}); });
if (window.location.href == url('admin/users')) { if (window.location.href.indexOf(url('admin/users')) >= 0) {
initUsersTable(); initUsersTable();
} else if (window.location.href == url('admin/players')) { } else if (window.location.href.indexOf(url('admin/players')) >= 0) {
initPlayersTable(); initPlayersTable();
} else if (window.location.href == url('admin/plugins/manage')) { } else if (window.location.href.indexOf(url('admin/plugins/manage')) >= 0) {
initPluginsTable(); initPluginsTable();
} }
}); });
@ -552,8 +552,12 @@ function downloadUpdates() {
} }
function initUsersTable() { function initUsersTable() {
let dataUrl = url('admin/user-data');
if (getQueryString('uid')) {
dataUrl += '?uid=' + getQueryString('uid');
}
$('#user-table').DataTable({ $('#user-table').DataTable({
ajax: url('admin/user-data'), ajax: dataUrl,
scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7, scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7,
rowCallback: (row, data) => { rowCallback: (row, data) => {
$(row).attr('id', `user-${data.uid}`); $(row).attr('id', `user-${data.uid}`);
@ -581,6 +585,16 @@ function initUsersTable() {
}, },
{ {
targets: 4, targets: 4,
data: 'players_count',
render: (data, type, row) => {
return `<span title="${trans('admin.doubleClickToSeePlayers')}"
style="cursor: pointer;"
ondblclick="window.location.href = '${url('admin/players?uid=') + row.uid}'"
data-toggle="tooltip" data-placement="top">${data}</span>`;
}
},
{
targets: 5,
data: 'permission', data: 'permission',
render: data => { render: data => {
switch (data) { switch (data) {
@ -596,11 +610,11 @@ function initUsersTable() {
} }
}, },
{ {
targets: 5, targets: 6,
data: 'register_at' data: 'register_at'
}, },
{ {
targets: 6, targets: 7,
data: 'operations', data: 'operations',
searchable: false, searchable: false,
orderable: false, orderable: false,
@ -662,8 +676,12 @@ function initUsersTable() {
} }
function initPlayersTable() { function initPlayersTable() {
let dataUrl = url('admin/player-data');
if (getQueryString('uid')) {
dataUrl += '?uid=' + getQueryString('uid');
}
$('#player-table').DataTable({ $('#player-table').DataTable({
ajax: url('admin/player-data'), ajax: dataUrl,
scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7, scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7,
columnDefs: [ columnDefs: [
{ {
@ -673,7 +691,13 @@ function initPlayersTable() {
}, },
{ {
targets: 1, targets: 1,
data: 'uid' data: 'uid',
render: (data, type, row) => {
return `<span title="${trans('admin.doubleClickToSeeUser')}"
style="cursor: pointer;"
ondblclick="window.location.href = '${url('admin/users?uid=') + row.uid}'"
data-toggle="tooltip" data-placement="top">${data}</span>`;
}
}, },
{ {
targets: 2, targets: 2,

View File

@ -6,6 +6,8 @@ index:
overview: Overview overview: Overview
users: users:
players-count:
title: Players Count
status: status:
title: Status title: Status
normal: Normal normal: Normal

View File

@ -119,6 +119,8 @@
newUserPassword: 'Please enter the new password:', newUserPassword: 'Please enter the new password:',
deleteUserNotice: 'Are you sure to delete this user? It\' permanent.', deleteUserNotice: 'Are you sure to delete this user? It\' permanent.',
scoreTip: 'Press ENTER to submit new score', scoreTip: 'Press ENTER to submit new score',
doubleClickToSeeUser: 'Double click to see info of this user',
doubleClickToSeePlayers: 'Double click to see his/her players',
// Status // Status
banned: 'Banned', banned: 'Banned',

View File

@ -6,6 +6,8 @@ index:
overview: 概览 overview: 概览
users: users:
players-count:
title: 拥有角色数
status: status:
title: 状态 title: 状态
normal: 普通用户 normal: 普通用户

View File

@ -119,6 +119,8 @@
newUserPassword: '请输入新密码:', newUserPassword: '请输入新密码:',
deleteUserNotice: '真的要删除此用户吗?此操作不可恢复', deleteUserNotice: '真的要删除此用户吗?此操作不可恢复',
scoreTip: '输入修改后的积分,回车提交', scoreTip: '输入修改后的积分,回车提交',
doubleClickToSeeUser: '双击可查看该用户的信息',
doubleClickToSeePlayers: '双击可查看该用户的角色',
// Status // Status
banned: '封禁', banned: '封禁',

View File

@ -24,6 +24,7 @@
<th>{{ trans('general.user.email') }}</th> <th>{{ trans('general.user.email') }}</th>
<th>{{ trans('general.user.nickname') }}</th> <th>{{ trans('general.user.nickname') }}</th>
<th>{{ trans('general.user.score') }}</th> <th>{{ trans('general.user.score') }}</th>
<th>{{ trans('admin.users.players-count.title') }}</th>
<th>{{ trans('admin.users.status.title') }}</th> <th>{{ trans('admin.users.status.title') }}</th>
<th>{{ trans('general.user.register-at') }}</th> <th>{{ trans('general.user.register-at') }}</th>
<th>{{ trans('general.operations') }}</th> <th>{{ trans('general.operations') }}</th>