diff --git a/DashboardsAccess.php b/DashboardsAccess.php
new file mode 100644
index 0000000..4e6545b
--- /dev/null
+++ b/DashboardsAccess.php
@@ -0,0 +1,46 @@
+is('guest')) {
+ return false;
+ }
+
+ return $user->is('admin') || $user->hasRole('dados');
+ }
+
+ public static function userMenuLinkMarkup(string $label = 'Painéis de Dados'): string
+ {
+ return sprintf(
+ '
%s',
+ $label
+ );
+ }
+
+ public static function appendPanelNavItem(array &$navItems, ?object $user, string $label = 'Painéis de Dados'): void
+ {
+ if (!self::userCanAccess($user)) {
+ return;
+ }
+
+ if (!isset($navItems['admin']['items']) || !is_array($navItems['admin']['items'])) {
+ $navItems['admin']['items'] = [];
+ }
+
+ foreach ($navItems['admin']['items'] as $item) {
+ if (($item['route'] ?? null) === 'dashboards') {
+ return;
+ }
+ }
+
+ array_unshift($navItems['admin']['items'], [
+ 'route' => 'dashboards/index',
+ 'icon' => 'dashboard',
+ 'label' => $label,
+ ]);
+ }
+}
diff --git a/DashboardsController.php b/DashboardsController.php
new file mode 100644
index 0000000..344c72a
--- /dev/null
+++ b/DashboardsController.php
@@ -0,0 +1,29 @@
+user->is('guest')) {
+ $this->redirect($app->createUrl('auth'));
+ return;
+ }
+
+ if (!DashboardsAccess::userCanAccess($app->user)) {
+ $this->redirect($app->createUrl('site', 'index'));
+ return;
+ }
+
+ $this->render('index');
+ }
+}
diff --git a/Theme.php b/Theme.php
index 36962a6..ab7abba 100644
--- a/Theme.php
+++ b/Theme.php
@@ -6,6 +6,7 @@
use MapasCulturais\API;
use MapasCulturais\Definitions;
use MapasCulturais\Entities\Agent;
+use MapasCulturais\i;
// class Theme extends \Subsite\Theme {
class Theme extends \MapasCulturais\Themes\BaseV2\Theme
@@ -23,6 +24,7 @@ function __construct($config = [])
parent::__construct($config);
$app->registerController('funarte_search', 'Funarte\SearchController');
$app->registerController('circuitos', 'Funarte\CircuitosController');
+ $app->registerController('dashboards', 'Funarte\DashboardsController');
}
function register()
@@ -103,6 +105,8 @@ function _init()
...$i
];
}
+
+ DashboardsAccess::appendPanelNavItem($nav_items, $app->user, i::__('Painéis de Dados'));
});
/*
@@ -164,7 +168,7 @@ function _init()
$icon['project'] = "ph:pinwheel-fill";
$icon['calendar'] = "bx:calendar";
$icon['map-marker'] = "mdi:map-marker";
-
+
});
}
diff --git a/components/user-menu-dashboards-link/template.php b/components/user-menu-dashboards-link/template.php
new file mode 100644
index 0000000..90b98dc
--- /dev/null
+++ b/components/user-menu-dashboards-link/template.php
@@ -0,0 +1,13 @@
+user;
+
+if (\Funarte\DashboardsAccess::userCanAccess($user)) {
+ echo \Funarte\DashboardsAccess::userMenuLinkMarkup(i::__('Painéis de Dados'));
+}
diff --git a/views/dashboards/index.php b/views/dashboards/index.php
new file mode 100644
index 0000000..f634acc
--- /dev/null
+++ b/views/dashboards/index.php
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+