add test page for including vue-based web client

This commit is contained in:
Dario Rekowski on RockPI 2020-11-12 11:46:14 +00:00 committed by Ulf Gebhardt
parent a7bb43c310
commit cecb8b0f5c
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
3 changed files with 24 additions and 1 deletions

View File

@ -110,6 +110,7 @@ Router::scope('/', function (RouteBuilder $routes) {
*/
//$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
$routes->connect('/', ['controller' => 'Dashboard', 'action' => 'index']);
$routes->connect('/client', ['controller' => 'Pages', 'action' => 'display', 'js']);
$routes->connect('/server', ['controller' => 'Dashboard', 'action' => 'serverIndex']);
//$routes->connect('/', 'https://gradido2.dario-rekowski.de/account', array('status' => 303));

View File

@ -46,6 +46,7 @@ class PagesController extends AppController
*/
public function display(...$path)
{
$count = count($path);
if (!$count) {
return $this->redirect('/');
@ -61,7 +62,14 @@ class PagesController extends AppController
if (!empty($path[1])) {
$subpage = $path[1];
}
$this->set(compact('page', 'subpage'));
$session = $this->getRequest()->getSession();
$result = $this->requestLogin();
if($result !== true) {
return $result;
}
$user = $session->read('StateUser');
$login_server_session = $this->request->getCookie('GRADIDO_LOGIN', '');
$this->set(compact('page', 'subpage', 'user', 'login_server_session'));
try {
$this->render(implode('/', $path));

14
src/Template/Pages/js.ctp Normal file
View File

@ -0,0 +1,14 @@
<?php $this->layout = false;?><html>
<head>
<title>Vue Test</title>
<meta charset="UTF-8">
</head>
<body>
<div id="gradido-vue">Wird geladen...</div>
<script type="text/javascript">
csfr = "<?= $this->request->getParam('_csrfToken') ?>";
user = <?= json_encode($user); ?>;
session = <?= $login_server_session ?>;
</script>
</body>
</html>