diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
index 8ded24b4..7970bf91 100644
--- a/app/Http/Controllers/AdminController.php
+++ b/app/Http/Controllers/AdminController.php
@@ -169,21 +169,11 @@ class AdminController extends Controller
{
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at']);
- $permissionTextMap = [
- User::BANNED => trans('admin.users.status.banned'),
- User::NORMAL => trans('admin.users.status.normal'),
- User::ADMIN => trans('admin.users.status.admin'),
- User::SUPER_ADMIN => trans('admin.users.status.super-admin')
- ];
-
return Datatables::of($users)->editColumn('email', function ($user) {
return $user->email ?: 'EMPTY';
- })->editColumn('permission', function ($user) use ($permissionTextMap) {
- return array_get($permissionTextMap, $user->permission);
})
->setRowId('uid')
- ->editColumn('score', 'vendor.admin-operations.users.score')
- ->addColumn('operations', 'vendor.admin-operations.users.operations')
+ ->addColumn('operations', app('user.current')->getPermission())
->make(true);
}
@@ -202,11 +192,7 @@ class AdminController extends Controller
{
$players = Player::select(['pid', 'uid', 'player_name', 'preference', 'tid_steve', 'tid_alex', 'tid_cape', 'last_modified']);
- return Datatables::of($players)->editColumn('preference', 'vendor.admin-operations.players.preference')
- ->setRowId('pid')
- ->addColumn('previews', 'vendor.admin-operations.players.previews')
- ->addColumn('operations', 'vendor.admin-operations.players.operations')
- ->make(true);
+ return Datatables::of($players)->setRowId('pid')->make(true);
}
/**
diff --git a/app/Http/Controllers/PluginController.php b/app/Http/Controllers/PluginController.php
index ce96c470..21545ea0 100644
--- a/app/Http/Controllers/PluginController.php
+++ b/app/Http/Controllers/PluginController.php
@@ -75,13 +75,13 @@ class PluginController extends Controller
return trans($plugin->description);
})
->editColumn('author', function ($plugin) {
- return "".trans($plugin->author)."";
+ return ['author' => trans($plugin->author), 'url' => $plugin->url];
})
->addColumn('status', function ($plugin) {
return trans('admin.plugins.status.'.($plugin->isEnabled() ? 'enabled' : 'disabled'));
})
->addColumn('operations', function ($plugin) {
- return view('vendor.admin-operations.plugins.operations', compact('plugin'));
+ return ['enabled' => $plugin->isEnabled(), 'hasConfigView' => $plugin->hasConfigView()];
})
->make(true);
}
diff --git a/resources/assets/src/scripts/admin.js b/resources/assets/src/scripts/admin.js
index 3a9ce350..f31ae36b 100644
--- a/resources/assets/src/scripts/admin.js
+++ b/resources/assets/src/scripts/admin.js
@@ -11,6 +11,23 @@ $(document).ready(function() {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue'
});
+
+ $.extend(true, $.fn.dataTable.defaults, {
+ language: trans('vendor.datatables'),
+ scrollX: true,
+ pageLength: 25,
+ autoWidth: false,
+ processing: true,
+ serverSide: true
+ });
+
+ if (window.location.pathname.includes('admin/users')) {
+ initUsersTable();
+ } else if (window.location.pathname.includes('admin/players')) {
+ initPlayersTable();
+ } else if (window.location.pathname.includes('admin/plugins/manage')) {
+ initPluginsTable();
+ }
});
$('#layout-skins-list [data-skin]').click(function(e) {
@@ -191,7 +208,7 @@ $('body').on('keypress', '.score', function(event){
}
});
-$('body').on('change', '#preference', function() {
+function changePreference() {
$.ajax({
type: "POST",
url: "./players?action=preference",
@@ -206,9 +223,9 @@ $('body').on('change', '#preference', function() {
},
error: showAjaxError
});
-});
+}
-function changeTexture(pid) {
+function changeTexture(pid, playerName) {
let dom = `
@@ -223,8 +240,6 @@ function changeTexture(pid) {
`;
- let playerName = $('#'+pid).find('#player-name').text();
-
showModal(dom, trans('admin.changePlayerTexture', {'player': playerName}), 'default', {
callback: `ajaxChangeTexture(${pid})`
});
@@ -453,3 +468,248 @@ function downloadUpdates() {
.fail(showAjaxError);
}
+
+function initUsersTable() {
+ const rootPath = /(^https?:.*)\/admin\/users/.exec(window.location.href)[1];
+ $('#user-table').DataTable({
+ ajax: `${rootPath}/admin/user-data`,
+ scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7,
+ columnDefs: [
+ {
+ targets: 0,
+ data: 'uid',
+ width: '1%'
+ },
+ {
+ targets: 1,
+ data: 'email'
+ },
+ {
+ targets: 2,
+ data: 'nickname'
+ },
+ {
+ targets: 3,
+ data: 'score',
+ render: data => {
+ return ``;
+ }
+ },
+ {
+ targets: 4,
+ data: 'permission',
+ render: data => {
+ switch (data) {
+ case -1:
+ return trans('admin.banned');
+ case 0:
+ return trans('admin.normal');
+ case 1:
+ return trans('admin.admin');
+ case 2:
+ return trans('admin.superAdmin');
+ }
+ }
+ },
+ {
+ targets: 5,
+ data: 'register_at'
+ },
+ {
+ targets: 6,
+ data: 'operations',
+ searchable: false,
+ orderable: false,
+ render: (data, type, row) => {
+ let operationsHtml, adminOption = '', bannedOption = '', deleteUserButton;
+ if (row.permission !== 2) {
+ if (data === 2) {
+ if (row.permission === 1) {
+ adminOption = `
+ ${trans('admin.unsetAdmin')}`;
+ } else {
+ adminOption = `
+ ${trans('admin.setAdmin')}`;
+ }
+ }
+ if (row.permission === -1) {
+ bannedOption = `
+ ${trans('admin.ban')}`;
+ } else {
+ bannedOption = `
+ ${trans('admin.unban')}`;
+ }
+ }
+
+ if (data === 2) {
+ if (row.permission === 2) {
+ deleteUserButton = `
+ ${trans('admin.deleteUser')}`;
+ } else {
+ deleteUserButton = `
+ ${trans('admin.deleteUser')}`;
+ }
+ } else {
+ if (row.permission === 1 || row.permission === 2) {
+ deleteUserButton = `
+ ${trans('admin.deleteUser')}`;
+ } else {
+ deleteUserButton = `
+ ${trans('admin.deleteUser')}`;
+ }
+ }
+
+ return `
+
+
+
+
+ ${deleteUserButton}`;
+ }
+ }
+ ]
+ });
+}
+
+function initPlayersTable() {
+ const rootPath = /(^https?:.*)\/admin\/players/.exec(window.location.href)[1];
+ $('#player-table').DataTable({
+ ajax: `${rootPath}/admin/player-data`,
+ scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7,
+ columnDefs: [
+ {
+ targets: 0,
+ data: 'pid',
+ width: '1%'
+ },
+ {
+ targets: 1,
+ data: 'uid'
+ },
+ {
+ targets: 2,
+ data: 'player_name'
+ },
+ {
+ targets: 3,
+ data: 'preference',
+ render: data => {
+ return `
+ `;
+ }
+ },
+ {
+ targets: 4,
+ searchable: false,
+ orderable: false,
+ render: (data, type, row) => {
+ let html = { steve: '', alex: '', cape: '' };
+ ['steve', 'alex', 'cape'].forEach(textureType => {
+ if (row['tid_' + textureType] === 0) {
+ html[textureType] = `
`;
+ } else {
+ html[textureType] = `
+
+
+ `;
+ }
+ });
+ return html.steve + html.alex + html.cape;
+ }
+ },
+ {
+ targets: 5,
+ data: 'last_modified'
+ },
+ {
+ targets: 6,
+ searchable: false,
+ orderable: false,
+ render: (data, type, row) => {
+ return `
+
+
+
+
+ ${trans('admin.deletePlayer')}`;
+ }
+ }
+ ]
+ });
+}
+
+function initPluginsTable() {
+ const rootPath = /(^https?:.*)\/admin\/plugins\/manage/.exec(window.location.href)[1];
+ $('#plugin-table').DataTable({
+ ajax: `${rootPath}/admin/plugins/data`,
+ columnDefs: [
+ {
+ targets: 0,
+ data: 'title'
+ },
+ {
+ targets: 1,
+ data: 'description',
+ width: '35%'
+ },
+ {
+ targets: 2,
+ data: 'author',
+ render: data => {
+ if (data.url === '' || data.url === null) {
+ return data.author;
+ } else {
+ return `${data.author}`;
+ }
+ }
+ },
+ {
+ targets: 3,
+ data: 'version'
+ },
+ {
+ targets: 4,
+ data: 'status'
+ },
+ {
+ targets: 5,
+ data: 'operations',
+ searchable: false,
+ orderable: false,
+ render: (data, type, row) => {
+ let switchEnableButton, configViewButton, deletePluginButton;
+ if (data.enabled) {
+ switchEnableButton = `
+ ${trans('admin.disablePlugin')}`;
+ } else {
+ switchEnableButton = `
+ ${trans('admin.enablePlugin')}`;
+ }
+ if (data.enabled && data.hasConfigView) {
+ configViewButton = `
+ ${trans('admin.configurePlugin')}`;
+ } else {
+ configViewButton = `
+ ${trans('admin.configurePlugin')}`;
+ }
+ deletePluginButton = `
+ ${trans('admin.deletePlugin')}`;
+ return switchEnableButton + configViewButton + deletePluginButton;
+ }
+ }
+ ]
+ });
+}
diff --git a/resources/lang/en/admin.yml b/resources/lang/en/admin.yml
index 36b101f2..88286d49 100644
--- a/resources/lang/en/admin.yml
+++ b/resources/lang/en/admin.yml
@@ -12,8 +12,6 @@ users:
banned: Banned
admin: Admin
super-admin: Super Admin
- score:
- tip: Press enter to submit new score
operations:
title: Operations
non-existent: No such user.
@@ -100,12 +98,6 @@ plugins:
operations:
title: Operations
- disable: Disable
- enable: Enable
- configure: Configure
- no-config-notice: The plugin has been disabled or no configuration is provided.
- delete: Delete
-
enabled: :plugin has been enabled.
disabled: :plugin has been disabled.
deleted: The plugin was deleted successfully.
diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js
index 1a337a90..b1f0b7ca 100644
--- a/resources/lang/en/locale.js
+++ b/resources/lang/en/locale.js
@@ -95,38 +95,52 @@
emptyDeletePassword: 'Please enter the current password:'
},
admin: {
- // Change User Profile
- newUserEmail: 'Please enter the new email:',
- newUserNickname: 'Please enter the new nickname:',
- newUserPassword: 'Please enter the new password:',
- deleteUserNotice: 'Are you sure to delete this user? It\' permanent.',
- changePlayerOwner: 'Please enter the id of user which this player should be transferred to:',
- deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.',
+ operationsTitle: 'Operations',
- // Status
- banned: 'Banned',
- normal: 'Normal',
- admin: 'Admin',
-
- // Operations
+ // Users
ban: 'Ban',
unban: 'Unban',
setAdmin: 'Set as admin',
unsetAdmin: 'Remove admin',
+ deleteUser: 'Delete User',
+ cannotDeleteAdmin: 'You can\'t delete admins.',
+ cannotDeleteSuperAdmin: 'You can\'t delete super admin in this way',
+ changeEmail: 'Edit Email',
+ changeNickName: 'Edit Nickname',
+ changePassword: 'Edit Password',
+ newUserEmail: 'Please enter the new email:',
+ newUserNickname: 'Please enter the new nickname:',
+ newUserPassword: 'Please enter the new password:',
+ deleteUserNotice: 'Are you sure to delete this user? It\' permanent.',
+ scoreTip: 'Press ENTER to submit new score',
- // Change Player Texture
+ // Status
+ banned: 'Banned',
+ normal: 'Normal',
+ admin: 'Admin',
+ superAdmin: 'Super Admin',
+
+ // Players
textureType: 'Texture Type',
skin: 'Skin (:model Model)',
cape: 'Cape',
pid: 'Texture ID',
pidNotice: 'Please enter the tid of texture',
changePlayerTexture: 'Change textures of :player',
+ changeTexture: 'Change Textures',
+ changeOwner: 'Change Owner',
+ deletePlayer: 'Delete',
+ changePlayerOwner: 'Please enter the id of user which this player should be transferred to:',
+ deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.',
// Index
textureUploads: 'Texture Uploads',
userRegistration: 'User Registration',
// Plugins
+ configurePlugin: 'Configure',
+ noPluginConfigNotice: 'The plugin has been disabled or no configuration is provided.',
+ deletePlugin: 'Delete',
statusEnabled: 'Enabled',
statusDisabled: 'Disabled',
enablePlugin: 'Enable',
diff --git a/resources/lang/zh_CN/admin.yml b/resources/lang/zh_CN/admin.yml
index 1f4e4372..63e4ab0c 100644
--- a/resources/lang/zh_CN/admin.yml
+++ b/resources/lang/zh_CN/admin.yml
@@ -12,8 +12,6 @@ users:
banned: 封禁
admin: 管理员
super-admin: 超级管理员
- score:
- tip: 输入修改后的积分,回车提交
operations:
title: 更多操作
non-existent: 用户不存在
@@ -100,12 +98,6 @@ plugins:
operations:
title: 操作
- disable: 禁用插件
- enable: 启用插件
- configure: 插件配置
- no-config-notice: 插件已被禁用或无配置页
- delete: 删除插件
-
enabled: :plugin 已启用
disabled: :plugin 已禁用
deleted: 插件已被成功删除
diff --git a/resources/lang/zh_CN/locale.js b/resources/lang/zh_CN/locale.js
index 334d212d..832b554b 100644
--- a/resources/lang/zh_CN/locale.js
+++ b/resources/lang/zh_CN/locale.js
@@ -95,38 +95,52 @@
emptyDeletePassword: '请先输入当前用户密码'
},
admin: {
- // Change User Profile
- newUserEmail: '请输入新邮箱:',
- newUserNickname: '请输入新昵称:',
- newUserPassword: '请输入新密码:',
- deleteUserNotice: '真的要删除此用户吗?此操作不可恢复',
- changePlayerOwner: '请输入此角色要让渡至的用户 UID:',
- deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
+ operationsTitle: '更多操作',
- // Status
- banned: '封禁',
- normal: '正常',
- admin: '管理员',
-
- // Operations
+ // Users
ban: '封禁',
unban: '解封',
setAdmin: '设为管理员',
unsetAdmin: '解除管理员',
+ deleteUser: '删除用户',
+ cannotDeleteAdmin: '你不能删除管理员账号哦',
+ cannotDeleteSuperAdmin: '超级管理员账号不能被这样删除的啦',
+ changeEmail: '修改邮箱',
+ changeNickName: '修改昵称',
+ changePassword: '更改密码',
+ newUserEmail: '请输入新邮箱:',
+ newUserNickname: '请输入新昵称:',
+ newUserPassword: '请输入新密码:',
+ deleteUserNotice: '真的要删除此用户吗?此操作不可恢复',
+ scoreTip: '输入修改后的积分,回车提交',
- // Change Player Texture
+ // Status
+ banned: '封禁',
+ normal: '普通用户',
+ admin: '管理员',
+ superAdmin: '超级管理员',
+
+ // Players
textureType: '材质类型',
skin: '皮肤(:model 模型)',
cape: '披风',
pid: '材质 ID',
pidNotice: '输入要更换的材质的 TID',
changePlayerTexture: '更换角色 :player 的材质',
+ changeTexture: '更换材质',
+ changeOwner: '更换角色拥有者',
+ deletePlayer: '删除角色',
+ changePlayerOwner: '请输入此角色要让渡至的用户 UID:',
+ deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复',
// Index
textureUploads: '材质上传',
userRegistration: '用户注册',
// Plugins
+ configurePlugin: '插件配置',
+ noPluginConfigNotice: '插件已被禁用或无配置页',
+ deletePlugin: '删除插件',
statusEnabled: '已启用',
statusDisabled: '已禁用',
enablePlugin: '启用插件',
diff --git a/resources/views/admin/players.tpl b/resources/views/admin/players.tpl
index c5820b7b..d9c62853 100644
--- a/resources/views/admin/players.tpl
+++ b/resources/views/admin/players.tpl
@@ -43,26 +43,5 @@
$(document).ready(function() {
$('.box-body').css('min-height', $('.content-wrapper').height() - $('.content-header').outerHeight() - 120);
});
-
-$('#player-table').DataTable({
- language: trans('vendor.datatables'),
- scrollX: true,
- autoWidth: false,
- processing: true,
- serverSide: true,
- ajax: '{{ url("admin/player-data") }}',
- createdRow: function (row, data, index) {
- $('td', row).eq(2).attr('id', 'player-name');
- },
- columns: [
- {data: 'pid', 'width': '1%'},
- {data: 'uid'},
- {data: 'player_name'},
- {data: 'preference'},
- {data: 'previews', searchable: false, orderable: false},
- {data: 'last_modified'},
- {data: 'operations', searchable: false, orderable: false}
- ]
-});
@endsection
diff --git a/resources/views/admin/plugins.tpl b/resources/views/admin/plugins.tpl
index 1c4a5bd7..8b5e4304 100644
--- a/resources/views/admin/plugins.tpl
+++ b/resources/views/admin/plugins.tpl
@@ -47,32 +47,3 @@
@endsection
-
-@section('script')
-
-@endsection
diff --git a/resources/views/admin/users.tpl b/resources/views/admin/users.tpl
index 64b23e22..d9006d0e 100644
--- a/resources/views/admin/users.tpl
+++ b/resources/views/admin/users.tpl
@@ -42,28 +42,5 @@
$(document).ready(function() {
$('.box-body').css('min-height', $('.content-wrapper').height() - $('.content-header').outerHeight() - 120);
});
-
-$('#user-table').DataTable({
- language: trans('vendor.datatables'),
- scrollX: true,
- autoWidth: false,
- processing: true,
- serverSide: true,
- ajax: '{{ url("admin/user-data") }}',
- createdRow: function (row, data, index) {
- $('td', row).eq(1).attr('id', 'email');
- $('td', row).eq(2).attr('id', 'nickname');
- $('td', row).eq(4).attr('id', 'permission');
- },
- columns: [
- {data: 'uid', 'width': '1%'},
- {data: 'email'},
- {data: 'nickname'},
- {data: 'score'},
- {data: 'permission'},
- {data: 'register_at'},
- {data: 'operations', searchable: false, orderable: false}
- ]
-});
@endsection
diff --git a/resources/views/vendor/admin-operations/players/operations.tpl b/resources/views/vendor/admin-operations/players/operations.tpl
deleted file mode 100644
index 8dbf4e60..00000000
--- a/resources/views/vendor/admin-operations/players/operations.tpl
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-{{ trans('admin.players.delete.delete') }}
diff --git a/resources/views/vendor/admin-operations/players/preference.tpl b/resources/views/vendor/admin-operations/players/preference.tpl
deleted file mode 100644
index a5330e12..00000000
--- a/resources/views/vendor/admin-operations/players/preference.tpl
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/resources/views/vendor/admin-operations/players/previews.tpl b/resources/views/vendor/admin-operations/players/previews.tpl
deleted file mode 100644
index e975ef46..00000000
--- a/resources/views/vendor/admin-operations/players/previews.tpl
+++ /dev/null
@@ -1,23 +0,0 @@
-@if ($tid_steve == '0')
-
-@else
-
-
-
-@endif
-
-@if ($tid_alex == '0')
-
-@else
-
-
-
-@endif
-
-@if ($tid_cape == '0')
-
-@else
-
-
-
-@endif
diff --git a/resources/views/vendor/admin-operations/plugins/operations.tpl b/resources/views/vendor/admin-operations/plugins/operations.tpl
deleted file mode 100644
index 6dba4c18..00000000
--- a/resources/views/vendor/admin-operations/plugins/operations.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
-@if ($plugin->isEnabled())
-{{ trans('admin.plugins.operations.disable') }}
-@else
-{{ trans('admin.plugins.operations.enable') }}
-@endif
-
-@if ($plugin->isEnabled() && $plugin->hasConfigView())
-{{ trans('admin.plugins.operations.configure') }}
-@else
-{{ trans('admin.plugins.operations.configure') }}
-@endif
-
-{{ trans('admin.plugins.operations.delete') }}
diff --git a/resources/views/vendor/admin-operations/users/operations.tpl b/resources/views/vendor/admin-operations/users/operations.tpl
deleted file mode 100644
index 29e714e3..00000000
--- a/resources/views/vendor/admin-operations/users/operations.tpl
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-{{-- If current user is super admin --}}
-@if (app('user.current')->getPermission() == User::SUPER_ADMIN)
-
- @if ($permission == "2")
- {{ trans('admin.users.operations.delete.delete') }}
- @else
- {{ trans('admin.users.operations.delete.delete') }}
- @endif
-
-@else
- @if ($permission == "1" || $permission == "2")
- {{ trans('admin.users.operations.delete.delete') }}
- @else
- {{ trans('admin.users.operations.delete.delete') }}
- @endif
-
-@endif
diff --git a/resources/views/vendor/admin-operations/users/score.tpl b/resources/views/vendor/admin-operations/users/score.tpl
deleted file mode 100644
index 312643da..00000000
--- a/resources/views/vendor/admin-operations/users/score.tpl
+++ /dev/null
@@ -1 +0,0 @@
-