Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WebVPF committed Nov 15, 2022
1 parent 13c9c03 commit a83b9e3
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 1 deletion.
45 changes: 45 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php namespace WebVPF\DashboardWidgets;

use Backend\Models\UserRole;
use System\Classes\PluginBase;

class Plugin extends PluginBase
{
public function pluginDetails(): array
{
return [
'name' => 'webvpf.dashboardwidgets::lang.plugin.name',
'description' => 'webvpf.dashboardwidgets::lang.plugin.desc',
'author' => 'WebVPF',
'icon' => 'icon-gauge-high',
'homepage' => 'https://github.com/WebVPF/wn-dashboardwidgets-plugin',
];
}

public function registerPermissions(): array
{
return []; // Remove this line to activate

return [
'webvpf.dashboardwidgets.some_permission' => [
'tab' => 'DashboardWidgets',
'label' => 'Some permission',
'roles' => [UserRole::CODE_DEVELOPER, UserRole::CODE_PUBLISHER],
],
];
}

public function registerReportWidgets(): array
{
return [
\WebVPF\DashboardWidgets\ReportWidgets\SystemInfo::class => [
'label' => 'System Info',
'context' => 'dashboard',
// 'permissions' => [
// 'webvpf.dashboardwidgets.widgets.systeminfo',
// ],
],
];
}

}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# wn-dashboardwidgets-plugin
# Dashboard Widgets

## Installing Composer

```bash
composer require webvpf/wn-dashboardwidgets-plugin
```
21 changes: 21 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "webvpf/wn-dashboardwidgets-plugin",
"type": "winter-plugin",
"description": "Dashboard Widgets - plugin for Winter CMS.",
"homepage": "https://github.com/WebVPF/wn-dashboardwidgets-plugin",
"keywords": ["winter cms", "wintercms", "wintercms-plugin"],
"license": "MIT",
"authors": [
{
"name": "WebVPF",
"role": "Author"
}
],
"support": {
"issues": "https://github.com/WebVPF/wn-dashboardwidgets-plugin/issues",
"source": "https://github.com/WebVPF/wn-dashboardwidgets-plugin"
},
"require": {
"composer/installers": "~1.0"
}
}
31 changes: 31 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

return [
'plugin' => [
'name' => 'Виджеты дашборд',
'desc' => 'Виджеты для главной страницы бэкенда.',
],
'sysinfo' => [
'server' => 'Server',
'server_addr' => 'Server IP',
'php' => 'PHP',
'laravel' => 'Laravel',
'twig' => 'Twig',
'db' => 'Database',
'prop' => [
'title_default' => 'System Info',
'server_title' => 'Application server',
'server_desc' => 'Show application server information',
'server_addr_title' => 'Server IP address',
'server_addr_desc' => 'Show server IP address',
'php_title' => 'PHP version',
'php_desc' => 'Show PHP Version',
'laravel_title' => 'Laravel version',
'laravel_desc' => 'Show Laravel framework version',
'twig_title' => 'Twig version',
'twig_desc' => 'Показывать версию шаблонизатора Twig',
'db_title' => 'Database System',
'db_desc' => 'Show database system',
],
],
];
31 changes: 31 additions & 0 deletions lang/ru/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

return [
'plugin' => [
'name' => 'Виджеты дашборд',
'desc' => 'Виджеты для главной страницы бэкенда.',
],
'sysinfo' => [
'server' => 'Сервер',
'server_addr' => 'IP-адрес сервера',
'php' => 'PHP',
'laravel' => 'Laravel',
'twig' => 'Twig',
'db' => 'База данных',
'prop' => [
'title_default' => 'System Info',
'server_title' => 'Сервер приложения',
'server_desc' => 'Показывать информацию о сервере приложения',
'server_addr_title' => 'IP-адрес сервера',
'server_addr_desc' => 'Показывать IP-адрес сервера',
'php_title' => 'Версия PHP',
'php_desc' => 'Показывать версию PHP',
'laravel_title' => 'Версия Laravel',
'laravel_desc' => 'Показывать версию фреймворка Laravel',
'twig_title' => 'Версия Twig',
'twig_desc' => 'Показывать версию шаблонизатора Twig',
'db_title' => 'Система Базы Данных',
'db_desc' => 'Показывать систему базы данных',
],
],
];
31 changes: 31 additions & 0 deletions lang/uk/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

return [
'plugin' => [
'name' => 'Віджети дашборд',
'desc' => 'Віджети для головної сторінки бекенду.',
],
'sysinfo' => [
'server' => 'Сервер',
'server_addr' => 'IP-адреса сервера',
'php' => 'PHP',
'laravel' => 'Laravel',
'twig' => 'Twig',
'db' => 'База даних',
'prop' => [
'title_default' => 'System Info',
'server_title' => 'Сервер додатка',
'server_desc' => 'Показувати інформацію про сервер додатка',
'server_addr_title' => 'IP-адреса сервера',
'server_addr_desc' => 'Показувати IP-адресу сервера',
'php_title' => 'Версія PHP',
'php_desc' => 'Показувати версію PHP',
'laravel_title' => 'Версія Laravel',
'laravel_desc' => 'Показувати версію фреймворка Laravel',
'twig_title' => 'Версія Twig',
'twig_desc' => 'Показувати версію шаблонізатора Twig',
'db_title' => 'Система бази даних',
'db_desc' => 'Показувати систему бази даних',
],
],
];
86 changes: 86 additions & 0 deletions reportwidgets/SystemInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php namespace WebVPF\DashboardWidgets\ReportWidgets;

use Backend\Classes\ReportWidgetBase;
use Exception;

class SystemInfo extends ReportWidgetBase
{
protected $defaultAlias = 'SystemInfoReportWidget';

public function defineProperties(): array
{
return [
'title' => [
'title' => 'backend::lang.dashboard.widget_title_label',
'default' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.title_default',
'type' => 'string',
'validationPattern' => '^.+$',
'validationMessage' => 'backend::lang.dashboard.widget_title_error',
],
'server' => [
'title' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.server_title',
'description' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.server_desc',
'type' => 'checkbox',
'default' => true,
],
'server_addr' => [
'title' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.server_addr_title',
'description' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.server_addr_desc',
'type' => 'checkbox',
'default' => true,
],
'php' => [
'title' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.php_title',
'description' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.php_desc',
'type' => 'checkbox',
'default' => true,
],
'laravel' => [
'title' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.laravel_title',
'description' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.laravel_desc',
'type' => 'checkbox',
'default' => true,
],
'twig' => [
'title' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.twig_title',
'description' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.twig_desc',
'type' => 'checkbox',
'default' => true,
],
'db' => [
'title' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.db_title',
'description' => 'webvpf.dashboardwidgets::lang.sysinfo.prop.db_desc',
'type' => 'checkbox',
'default' => true,
],
];
}

/**
* Renders the widget's primary contents.
*/
public function render(): string
{
try {
$this->prepareVars();
} catch (Exception $ex) {
$this->vars['error'] = $ex->getMessage();
}

return $this->makePartial('systeminfo');
}

/**
* Prepares the report widget view data
*/
public function prepareVars()
{
$this->vars['system_info'] = [
'server' => explode("/", $_SERVER['SERVER_SOFTWARE'])[0],
'php' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION,
'laravel' => \Illuminate\Foundation\Application::VERSION,
'twig' => \Twig\Environment::VERSION,
];
}

}
42 changes: 42 additions & 0 deletions reportwidgets/systeminfo/partials/_systeminfo.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div class="report-widget">
<h3><?= e(trans($this->property('title'))) ?></h3>

<?php if (!isset($error)): ?>
<div class="control-status-list">
<ul>
<li>
<span class="status-icon" style="background: #00f"><i class="icon-server"></i></span>
<span class="status-text"><?= e(trans('webvpf.dashboardwidgets::lang.sysinfo.server')) ?></span>
<span class="status-label primary"><?= $system_info['server'] ?></span>
</li>
<li>
<span class="status-icon" style="background: #000"><i class="icon-location-crosshairs"></i></span>
<span class="status-text"><?= e(trans('webvpf.dashboardwidgets::lang.sysinfo.server_addr')) ?></span>
<span class="status-label primary"><?= $_SERVER['SERVER_ADDR'] ?></span>
</li>
<li>
<span class="status-icon" style="background: #7377ad"><i class="icon-brands icon-php"></i></span>
<span class="status-text">PHP</span>
<span class="status-label primary"><?= $system_info['php'] ?></span>
</li>
<li>
<span class="status-icon" style="background: #ff2d20"><i class="icon-brands icon-laravel"></i></span>
<span class="status-text"><?= e(trans('webvpf.dashboardwidgets::lang.sysinfo.laravel')) ?></span>
<span class="status-label primary"><?= $system_info['laravel'] ?></span>
</li>
<li>
<span class="status-icon" style="background: #bacf29"><i class="icon-pagelines"></i></span>
<span class="status-text"><?= e(trans('webvpf.dashboardwidgets::lang.sysinfo.twig')) ?></span>
<span class="status-label primary"><?= $system_info['twig'] ?></span>
</li>
<li>
<span class="status-icon" style="background: #9400d3"><i class="icon-database"></i></span>
<span class="status-text"><?= e(trans('webvpf.dashboardwidgets::lang.sysinfo.db')) ?></span>
<span class="status-label primary"><?= config('database.default') ?></span>
</li>
</ul>
</div>
<?php else: ?>
<p class="flash-message static warning"><?= e($error) ?></p>
<?php endif ?>
</div>
1 change: 1 addition & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1: First version of DashboardWidgets

0 comments on commit a83b9e3

Please sign in to comment.