Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dmstr/yii2-backend-module
Browse files Browse the repository at this point in the history
…into master
  • Loading branch information
schmunk42 committed Oct 5, 2020
2 parents 62da383 + 25665fc commit 9a7bbcf
Show file tree
Hide file tree
Showing 16 changed files with 437 additions and 103 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"suggest": {
"codemix/yii2-localeurls": "Extended URL manager",
"dmstr/yii2-pages-module": "Menu manager",
"dmstr/yii2-prototype-module": "Content prototyping"
"dmstr/yii2-prototype-module": "Content prototyping",
"dmstr/lajax-yii2-translate-manager-addons": "Translating"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 2 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Module extends \yii\base\Module
*/
public $modulesDashboardBlacklist = [];

public $rbacDiagramExcludeRoles = ['Master'];

/**
* @param $label
*
Expand Down
24 changes: 23 additions & 1 deletion src/assets/backend/less/json-editor.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// json-editor well padding
.well-small {
.well-sm;
}
}

// json-editor Bootstrap 3 fix
div[id$="-container"] div[data-schemaid] {
.form-group {
margin-right: 0px;
margin-left: 0px;
}

h3 {
font-size: 1em;
margin-top: 0.5em;
}
}

div[data-schematype="object"] {
.well;
.well-small;
}



35 changes: 35 additions & 0 deletions src/controllers/CacheController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @link http://www.diemeisterei.de/
* @copyright Copyright (c) 2020 diemeisterei GmbH, Stuttgart
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace dmstr\modules\backend\controllers;


use yii\web\Controller;
use Yii;

class CacheController extends Controller
{
/**
* flush cache
*
* if APCu is used as cache we cannot flush cache from cli command
* see: https://github.com/yiisoft/yii2/issues/8647
*
* @return \yii\web\Response
*/
public function actionFlush()
{
if (\Yii::$app->cache->flush()) {
\Yii::$app->session->addFlash('success', Yii::t('backend-module','Cache cleared'));
} else {
\Yii::$app->session->addFlash('error', Yii::t('backend-module','Cannot clear cache'));
}
return $this->redirect(['default/index']);
}
}
44 changes: 44 additions & 0 deletions src/controllers/ConfigController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php


namespace dmstr\modules\backend\controllers;


use dmstr\helpers\Metadata;
use yii\data\ArrayDataProvider;
use yii\web\Controller;
use Yii;

class ConfigController extends Controller
{
/**
* Application configuration.
*
* @return string
*/
public function actionView()
{
$loadedModules = Metadata::getModules();
$loadedModulesDataProvider = new ArrayDataProvider(['allModels' => $loadedModules]);
$loadedModulesDataProvider->pagination->pageSize = 100;

$components = Yii::$app->getComponents();
ksort($components);
$modules = Yii::$app->getModules();
ksort($modules);
$env = $_ENV;
ksort($env);


return $this->render(
'view',
[
'params' => Yii::$app->params,
'components' => $components,
'modules' => $modules,
'env' => $env,
'loadedModulesDataProvider' => $loadedModulesDataProvider,
]
);
}
}
94 changes: 1 addition & 93 deletions src/controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace dmstr\modules\backend\controllers;

use dmstr\helpers\Metadata;
use dmstr\modules\backend\Module;
use dmstr\widgets\Menu;
use insolita\wgadminlte\InfoBox;
use Yii;
use yii\data\ArrayDataProvider;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\Controller;

/**
Expand Down Expand Up @@ -38,96 +35,6 @@ public function actionIndex()
return $this->render('index', ['items' => $items]);
}

/**
* Application configuration.
*
* @return string
*/
public function actionViewConfig()
{
$loadedModules = Metadata::getModules();
$loadedModulesDataProvider = new ArrayDataProvider(['allModels' => $loadedModules]);
$loadedModulesDataProvider->pagination->pageSize = 100;

$components = Yii::$app->getComponents();
ksort($components);
$modules = Yii::$app->getModules();
ksort($modules);

return $this->render(
'view-config',
[
'params' => Yii::$app->params,
'components' => $components,
'modules' => $modules,
'loadedModulesDataProvider' => $loadedModulesDataProvider,
]
);
}

/**
* @return string
*/
public function actionShowAuth()
{
$allPermissions = Yii::$app->authManager->getPermissions();
$allRoles = Yii::$app->authManager->getRoles();
$userPermissions = [];
$userRoles = [];

foreach ($allPermissions AS $item) {
if (Yii::$app->user->can($item->name)) {
$userPermissions[] = [
'description' => $item->description,
'name' => $item->name,
];
}
}
foreach ($allRoles AS $item) {
if (Yii::$app->user->can($item->name)) {
$userRoles[] = [
'description' => $item->description,
'name' => $item->name,
];
}
}

return $this->render('show-auth',
[
'permissions' => new ArrayDataProvider([
'allModels' => $userPermissions,
'pagination' => [
'pageSize' => 100,
],
]),
'roles' => new ArrayDataProvider([
'allModels' => $userRoles,
'pagination' => [
'pageSize' => 100,
],
]),
]);
}



/**
* flush cache
*
* if APCu is used as cache we cannot flush cache from cli command
* see: https://github.com/yiisoft/yii2/issues/8647
*
* @return \yii\web\Response
*/
public function actionCacheFlush()
{
if (Yii::$app->cache->flush()) {
Yii::$app->session->addFlash('success', Yii::t('backend-module','Cache cleared'));
} else {
Yii::$app->session->addFlash('error', Yii::t('backend-module','Cannot clear cache'));
}
return $this->redirect(!empty(Yii::$app->request->referrer) ? Yii::$app->request->referrer : Url::to(['index']));
}


/**
Expand Down Expand Up @@ -167,4 +74,5 @@ public function renderDashboardMenu($item = [])

return $menuItems;
}

}
Loading

0 comments on commit 9a7bbcf

Please sign in to comment.