From 70d59642b1f8ae7d46b69a9b46dbeab069d0a874 Mon Sep 17 00:00:00 2001 From: printempw Date: Fri, 10 Aug 2018 18:14:57 +0800 Subject: [PATCH] Update style of plugin manage page --- app/Http/Controllers/PluginController.php | 19 ++---- resources/assets/src/js/admin/plugins.js | 74 ++++++++++------------- resources/assets/src/stylus/admin.styl | 32 ++++++++++ resources/lang/en/admin.yml | 6 -- resources/lang/en/locale.js | 16 ++--- resources/lang/zh_CN/admin.yml | 12 ---- resources/lang/zh_CN/locale.js | 18 +++--- resources/views/admin/plugins.tpl | 18 +----- 8 files changed, 89 insertions(+), 106 deletions(-) diff --git a/app/Http/Controllers/PluginController.php b/app/Http/Controllers/PluginController.php index 7961220f..a3fde505 100644 --- a/app/Http/Controllers/PluginController.php +++ b/app/Http/Controllers/PluginController.php @@ -98,24 +98,13 @@ class PluginController extends Controller return Datatables::of($installed) ->setRowId('plugin-{{ $name }}') - ->editColumn('title', function ($plugin) { - return trans($plugin->title ?: 'EMPTY'); - }) - ->editColumn('description', function ($plugin) { - return trans($plugin->description ?: 'EMPTY'); - }) - ->editColumn('author', function ($plugin) { - return ['author' => trans($plugin->author ?: 'EMPTY'), 'url' => $plugin->url]; - }) + ->editColumn('title', '{{ trans($title ?: "EMPTY") }}') + ->editColumn('description', '{{ trans($description ?: "EMPTY") }}') + ->addColumn('enabled', function ($plugin) { return $plugin->isEnabled(); }) + ->addColumn('config', function ($plugin) { return $plugin->hasConfigView(); }) ->addColumn('dependencies', function ($plugin) { return $this->getPluginDependencies($plugin); }) - ->addColumn('status', function ($plugin) { - return trans('admin.plugins.status.'.($plugin->isEnabled() ? 'enabled' : 'disabled')); - }) - ->addColumn('operations', function ($plugin) { - return ['enabled' => $plugin->isEnabled(), 'hasConfigView' => $plugin->hasConfigView()]; - }) ->make(true); } diff --git a/resources/assets/src/js/admin/plugins.js b/resources/assets/src/js/admin/plugins.js index ec81872a..43993106 100644 --- a/resources/assets/src/js/admin/plugins.js +++ b/resources/assets/src/js/admin/plugins.js @@ -8,6 +8,7 @@ function initPluginsTable() { $.pluginsTable = $('#plugin-table').DataTable({ columnDefs: pluginsTableColumnDefs, fnDrawCallback: () => $('[data-toggle="tooltip"]').tooltip(), + rowCallback: (row, data) => $(row).addClass(data.enabled ? 'plugin-enabled' : ''), ajax: { url: url('admin/plugins/data'), type: 'POST' @@ -18,27 +19,47 @@ function initPluginsTable() { const pluginsTableColumnDefs = [ { targets: 0, - data: 'title' + data: 'title', + title: trans('admin.pluginTitle'), + width: '10%', + render: (title, type, row) => { + const actions = []; + + if (row.enabled) { + row.config && actions.push(`${ trans('admin.configurePlugin') }`); + actions.push(`${ trans('admin.disablePlugin') }`); + } else { + actions.push( + `${ trans('admin.enablePlugin') }`, + `${ trans('admin.deletePlugin') }` + ); + } + + return ` + ${ title } +
${ actions.join(' | ') }
+ `; + } }, { targets: 1, data: 'description', + title: trans('admin.pluginDescription'), orderable: false, - width: '35%' + render: (description, type, row) => { + return ` +

${ description }

+
+ ${ trans('admin.pluginVersion') } ${ row.version } | + ${ trans('admin.pluginAuthor') } ${ row.author } +
+ `; + } }, { targets: 2, - data: 'author', - render: data => isEmpty(data.url) ? data.author : `${data.author}` - }, - { - targets: 3, - data: 'version', - orderable: false - }, - { - targets: 4, data: 'dependencies', + title: trans('admin.pluginDependencies'), searchable: false, orderable: false, render: data => { @@ -57,35 +78,6 @@ const pluginsTableColumnDefs = [ return result; } - }, - { - targets: 5, - data: 'status' - }, - { - targets: 6, - data: 'operations', - searchable: false, - orderable: false, - render: (data, type, row) => { - let toggleButton, configViewButton; - - if (data.enabled) { - toggleButton = `${trans('admin.disablePlugin')}`; - } else { - toggleButton = `${trans('admin.enablePlugin')}`; - } - - if (data.enabled && data.hasConfigView) { - configViewButton = `${trans('admin.configurePlugin')}`; - } else { - configViewButton = `${trans('admin.configurePlugin')}`; - } - - const deletePluginButton = `${trans('admin.deletePlugin')}`; - - return toggleButton + configViewButton + deletePluginButton; - } } ]; diff --git a/resources/assets/src/stylus/admin.styl b/resources/assets/src/stylus/admin.styl index 8c9d0270..d21400fd 100644 --- a/resources/assets/src/stylus/admin.styl +++ b/resources/assets/src/stylus/admin.styl @@ -45,3 +45,35 @@ td { color: #3c8dbc; } } + +#plugin-table { + .actions { + margin-top: 5px; + color: #ddd; + } + + .plugin-version-author { + color: #777; + font-size: small; + + a { + color: #337ab7; + } + } + + td { + padding: 10px; + } + + td:first-child { + border-left: 3px solid transparent; + } + + .plugin-enabled { + background-color: #f7fcfe; + } + + .plugin-enabled td:first-child { + border-left-color: #3c8dbc; + } +} diff --git a/resources/lang/en/admin.yml b/resources/lang/en/admin.yml index 279eb2fc..9230bddd 100644 --- a/resources/lang/en/admin.yml +++ b/resources/lang/en/admin.yml @@ -98,12 +98,6 @@ customize: black-light: Black Light plugins: - name: Name - description: Description - author: Author - version: Version - dependencies: Dependencies - status: title: Status enabled: Enabled diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js index 9da6e164..a77d3511 100644 --- a/resources/lang/en/locale.js +++ b/resources/lang/en/locale.js @@ -178,16 +178,18 @@ emptyPlayerName: 'Player name cannot be empty.', // Plugins - configurePlugin: 'Configure', - noPluginConfigNotice: 'The plugin has been disabled or no configuration is provided.', - deletePlugin: 'Delete', - noDependencies: 'No Dependencies', - whyDependencies: 'What\'s this?', - statusEnabled: 'Enabled', - statusDisabled: 'Disabled', + pluginTitle: 'Plugin', + pluginAuthor: 'Author', + pluginVersion: 'Version', enablePlugin: 'Enable', disablePlugin: 'Disable', + configurePlugin: 'Configure', + deletePlugin: 'Delete', confirmDeletion: 'Are you sure to delete this plugin?', + pluginDescription: 'Description', + pluginDependencies: 'Dependencies', + noDependencies: 'No Dependencies', + whyDependencies: 'What\'s this?', noDependenciesNotice: 'There is no dependency definition in the plugin. It means that the plugin may be not compatible with the current version of Blessing Skin, and enabling it may cause unexpected problems. Do you really want to enable the plugin?', // Update diff --git a/resources/lang/zh_CN/admin.yml b/resources/lang/zh_CN/admin.yml index b6eb1761..d747f430 100644 --- a/resources/lang/zh_CN/admin.yml +++ b/resources/lang/zh_CN/admin.yml @@ -98,19 +98,7 @@ customize: black-light: 黑色主题 - 白色侧边栏 plugins: - name: 名称 - description: 描述 - author: 作者 - version: 版本 - dependencies: 依赖关系 - - status: - title: 状态 - enabled: 已启用 - disabled: 已禁用 - operations: - title: 操作 enabled: :plugin 已启用 unsatisfied: notice: 无法启用此插件,因为其仍有未满足的依赖关系。请检查以下插件的版本,更新或安装它们: diff --git a/resources/lang/zh_CN/locale.js b/resources/lang/zh_CN/locale.js index a9e9d7fe..f71ba55b 100644 --- a/resources/lang/zh_CN/locale.js +++ b/resources/lang/zh_CN/locale.js @@ -180,16 +180,18 @@ emptyPlayerName: '您还没填写角色名呢', // Plugins - configurePlugin: '插件配置', - noPluginConfigNotice: '插件已被禁用或无配置页', - deletePlugin: '删除插件', + pluginTitle: '插件', + pluginAuthor: '作者', + pluginVersion: '版本', + enablePlugin: '启用', + disablePlugin: '禁用', + configurePlugin: '配置', + deletePlugin: '删除', + confirmDeletion: '真的要删除这个插件吗?', + pluginDescription: '描述', + pluginDependencies: '依赖关系', noDependencies: '无要求', whyDependencies: '为什么会这样?', - statusEnabled: '已启用', - statusDisabled: '已禁用', - enablePlugin: '启用插件', - disablePlugin: '禁用插件', - confirmDeletion: '真的要删除这个插件吗?', noDependenciesNotice: '此插件没有声明任何依赖关系,这代表它有可能并不兼容此版本的 Blessing Skin,请将此插件升级至可能的最新版本。强行启用可能导致无法预料的后果。你确定要启用此插件吗?', // Update diff --git a/resources/views/admin/plugins.tpl b/resources/views/admin/plugins.tpl index 55f9b11a..094986fd 100644 --- a/resources/views/admin/plugins.tpl +++ b/resources/views/admin/plugins.tpl @@ -2,10 +2,6 @@ @section('title', trans('general.plugin-manage')) -@section('style') - -@endsection - @section('content') @@ -28,19 +24,7 @@
- - - - - - - - - - - - -
{{ trans('admin.plugins.name') }}{{ trans('admin.plugins.description') }}{{ trans('admin.plugins.author') }}{{ trans('admin.plugins.version') }}{{ trans('admin.plugins.dependencies') }}{{ trans('admin.plugins.status.title') }}{{ trans('admin.plugins.operations.title') }}
+