chapcz/chap-adminlte
Composer 安装命令:
composer create-project chapcz/chap-adminlte
包简介
Administration control
README 文档
README
This extension simplifies the creation of Administration control.
Features:
- Easy install and use
- Included scripts and styles
- Simple use of multiple notification panels
- Translations
- Prepared login control
- PHP 7.2 strict
- PHPStan level 7
- Configurable as Nette extension
- Menu tree configurable in neon (also user restrictions)
Usage
To use this extension, require it in Composer:
composer require chapcz/chap-adminlte
Minimal setup
extensions: admin: Chap\AdminLTE\DI\Extension admin: menu: - name: "Home" link: "Admin:" icon: "fa-files-o" resource: "home" privilege: "view" - name: "Dvaaa" icon: "fa-pie-chart" role: "user" items: - name: Boo link: "Admin:boo" icon: fa-trip - name: Foo link: "Admin:foo" icon: fa-trip items: - name: Hoo link: "Admin:hoo" icon: fa-trip
Example with panels and search callback
Presenter
<?php declare(strict_types=1); namespace Chap\AdminModule\Presenters; use Chap\AdminLTE\AdminControl; use Chap\AdminLTE\IAdminControlFactory; use Chap\AdminLTE\Notifications\MessagePanel; use Chap\AdminLTE\Notifications\NotificationPanel; use Chap\AdminLTE\Notifications\TaskPanel; use Nette\Application\UI\Presenter; use Nette\Application\UI\Form; class AdminPresenter extends Presenter { /** * @var IAdminControlFactory */ private $adminControlFactory; public function __construct(IAdminControlFactory $adminControlFactory) { parent::__construct(); $this->adminControlFactory = $adminControlFactory; } /** * @return AdminControl */ protected function createComponentAdmin(): AdminControl { $admin = $this->adminControlFactory ->create() ->addPanel($this->getExampleNotificationsPanel()) ->addPanel($this->getExampleTasksPanel()) ->addPanel($this->getMessagesPanel()); $admin->onSearch[] = function (Form $form): void { $this->redirect('search', ['word' => $form->getValues()['q']]); }; return $admin; } private function getExampleNotificationsPanel() :NotificationPanel { return (new NotificationPanel()) ->setLinkAll('#') ->setCounter(50) ->setHeaderTitle('%d Notifications') ->addNotification('#', 'Something') ->addNotification('#', 'Something') ->addNotification('#', 'Something') ->addNotification('#', 'Something') ->addNotification('#', 'Something') ->addNotification('#', 'Something') ->addNotification('#', 'Something') ; } private function getMessagesPanel() :MessagePanel { return (new MessagePanel()) ->setLinkAll('#') ->setCounter(2) ->setHeaderTitle('%d messages') ->addMessage('#', 'Hallo', 'world !', '/image/avatar.png', '2 hours ago') ->addMessage('#', 'This', 'is message', '/image/avatar.png', '3 hours ago'); } private function getExampleTasksPanel() :TaskPanel { $panel = (new TaskPanel()) ->setLinkAll('#') ->setCounter(0) ->setHeaderTitle(null); for ($i = 1; $i <= 10; $i++ ) { $panel->addTask('#', 'My task ' . $i, $i*10); } return $panel; } /** * @param $word */ public function actionSearch(string $word): void { $this->flashMessage('Looking for: ' . $word, 'danger'); } }
@layout.latte
{capture $content}{include content}{/capture} {control admin $content, $flashes}
##Modals:
For a tags with modal property will be shown "no-layout" result inside modal window.
<a n:href="edit" class="btn btn-success" modal>Add user</a>
Components:
Lazy screen (shown in demo site):
protected function createComponentSlowScreen(): SlowComponent { return $this->slowComponentFactory->create(); } // Component with slow response (reading remote data, compute something) protected function createComponentSlowScreenLazyLoaded(): LazyScreen { return new LazyScreen(function () { return $this->slowComponentFactory->create(); }); }
Action buttons (shown in demo site):
Sometimes is useful to add some actions related for view (e.g. on product detail edit, send, assign etc.).
public function renderDetail(): void { $this['admin']->addActionButton(Button::builder()->typeWarning() ->link($this->link('this#test'))->faIcon('eye')->build()); $this['admin']->addActionButton(Button::builder()->typeInfo() ->link($this->link('this#test2'))->faIcon('cog')->build()); $this['admin']->addDropdownLink(new DropLink('', 'link')); }
Info-board (shown in demo site):
For dashboard purposes we can show some info boxes with useful information.
protected function createComponentDashBoard(): InfoBoard { return (new InfoBoard()) ->setColSpan(6) ->addBox((new InfoBox()) ->setColor('red') ->setLink('#') ->setIcon('pencil') ->setNumber(1222) ->setProgress(90) ->setText('Pencil text') ) ->addBox((new InfoBox()) ->setColor('green') ->setIcon('globe') ->setText('Globe text') ->setNumber((float) random_int(0, 9999)) ); }
TODO:
- Improve menu control and better authorization for nested items
- More examples
Inspiration
chapcz/chap-adminlte 适用场景与选型建议
chapcz/chap-adminlte 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 146 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 chapcz/chap-adminlte 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chapcz/chap-adminlte 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 146
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-28