diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index da6e0e89f..2c61ac8d8 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -5,6 +5,9 @@ use App\Controller\AppController; //use Cake\Routing\Router; use Cake\ORM\TableRegistry; +use Model\Navigation\NaviHierarchy; +use Model\Navigation\NaviHierarchyEntry; + /** * StateUsers Controller * @@ -20,6 +23,11 @@ class DashboardController extends AppController parent::initialize(); //$this->Auth->allow(['add', 'edit']); $this->Auth->allow(['index', 'errorHttpRequest']); + $this->set( + 'naviHierarchy', + (new NaviHierarchy())-> + add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', true)) + ); } /** * Index method diff --git a/src/Controller/StateBalancesController.php b/src/Controller/StateBalancesController.php index f6f6b8118..0a5efc398 100644 --- a/src/Controller/StateBalancesController.php +++ b/src/Controller/StateBalancesController.php @@ -4,6 +4,9 @@ namespace App\Controller; use Cake\ORM\TableRegistry; use App\Controller\AppController; +use Model\Navigation\NaviHierarchy; +use Model\Navigation\NaviHierarchyEntry; + /** * StateBalances Controller * @@ -20,6 +23,12 @@ class StateBalancesController extends AppController //$this->Auth->allow(['add', 'edit']); $this->Auth->allow(['overview', 'overviewGdt']); $this->loadComponent('JsonRequestClient'); + $this->set( + 'naviHierarchy', + (new NaviHierarchy())-> + add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', false))-> + add(new NaviHierarchyEntry(__('Kontoübersicht'), 'StateBalances', 'overview', true)) + ); } /** * Index method @@ -42,8 +51,8 @@ class StateBalancesController extends AppController $this->viewBuilder()->setLayout('frontend'); $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); - if($result !== true) { - return $result; + if ($result !== true) { + return $result; } $user = $session->read('StateUser'); // sendRequestGDT @@ -51,12 +60,12 @@ class StateBalancesController extends AppController //var_dump($user); $gdtSum = 0; - if('admin' === $user['role']) { - $gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi'); + if ('admin' === $user['role']) { + $gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi'); //var_dump($gdtEntries); - if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) { - $gdtSum = intval($gdtEntries['data']['sum']); - } + if ('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) { + $gdtSum = intval($gdtEntries['data']['sum']); + } } // // @@ -75,13 +84,13 @@ class StateBalancesController extends AppController $involvedUserIds = []; - foreach($transferTransactions as $sendCoins) { + foreach ($transferTransactions as $sendCoins) { //var_dump($sendCoins); - if($sendCoins->state_user_id != $user['id']) { - array_push($involvedUserIds, intval($sendCoins->state_user_id)); - } else if($sendCoins->receiver_user_id != $user['id']) { - array_push($involvedUserIds, intval($sendCoins->receiver_user_id)); - } + if ($sendCoins->state_user_id != $user['id']) { + array_push($involvedUserIds, intval($sendCoins->state_user_id)); + } else if ($sendCoins->receiver_user_id != $user['id']) { + array_push($involvedUserIds, intval($sendCoins->receiver_user_id)); + } } /*echo "state user from sendCoins: $sendCoins->state_user_id
"; @@ -101,8 +110,8 @@ class StateBalancesController extends AppController ]); //var_dump($involvedUser->toArray()); $involvedUserIndices = []; - foreach($involvedUser as $involvedUser) { - $involvedUserIndices[$involvedUser->id] = $involvedUser; + foreach ($involvedUser as $involvedUser) { + $involvedUserIndices[$involvedUser->id] = $involvedUser; } // sender or receiver when user has sended money @@ -113,29 +122,29 @@ class StateBalancesController extends AppController // balance $transactions = []; - foreach($creationTransactions as $creation) { + foreach ($creationTransactions as $creation) { //var_dump($creation); - array_push($transactions, [ + array_push($transactions, [ 'name' => 'Gradido Akademie', 'type' => 'creation', 'transaction_id' => $creation->transaction_id, 'date' => $creation->transaction->received, 'balance' => $creation->amount, 'memo' => $creation->transaction->memo - ]); + ]); } - foreach($transferTransactions as $sendCoins) { - $type = ''; - $otherUser = null; - if($sendCoins->state_user_id == $user['id']) { - $type = 'send'; - $otherUser = $involvedUserIndices[$sendCoins->receiver_user_id]; - } else if($sendCoins->receiver_user_id == $user['id']) { - $type = 'receive'; - $otherUser = $involvedUserIndices[$sendCoins->state_user_id]; - } - array_push($transactions, [ + foreach ($transferTransactions as $sendCoins) { + $type = ''; + $otherUser = null; + if ($sendCoins->state_user_id == $user['id']) { + $type = 'send'; + $otherUser = $involvedUserIndices[$sendCoins->receiver_user_id]; + } else if ($sendCoins->receiver_user_id == $user['id']) { + $type = 'receive'; + $otherUser = $involvedUserIndices[$sendCoins->state_user_id]; + } + array_push($transactions, [ 'name' => $otherUser->first_name . ' ' . $otherUser->last_name, 'email' => $otherUser->email, 'type' => $type, @@ -143,7 +152,7 @@ class StateBalancesController extends AppController 'date' => $sendCoins->transaction->received, 'balance' => $sendCoins->amount, 'memo' => $sendCoins->transaction->memo - ]); + ]); } uasort($transactions, array($this, 'sortTransactions')); $this->set('transactions', $transactions); @@ -159,57 +168,55 @@ class StateBalancesController extends AppController $this->viewBuilder()->setLayout('frontend'); $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); - if($result !== true) { - return $result; + if ($result !== true) { + return $result; } $user = $session->read('StateUser'); $requestResult = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'listPerEmailApi'); - if('success' === $requestResult['state'] && 'success' === $requestResult['data']['state']) { + if ('success' === $requestResult['state'] && 'success' === $requestResult['data']['state']) { //var_dump(array_keys($requestResult['data'])); - $ownEntries = $requestResult['data']['ownEntries']; + $ownEntries = $requestResult['data']['ownEntries']; //$gdtEntries = $requestResult['data']['entries']; - $gdtSum = 0; - foreach($ownEntries as $i => $gdtEntry) { - $gdtSum += $gdtEntry['gdt']; - //echo "index: $i
"; - //var_dump($gdtEntry); - - } - if(isset($requestResult['data']['connectEntrys'])) { - $connectEntries = $requestResult['data']['connectEntrys']; - - foreach($connectEntries as $entry) { - //if(!$count) var_dump($entry); - //$count++; - $gdtSum += $entry['connect']['gdt_entry']['gdt']; + $gdtSum = 0; + foreach ($ownEntries as $i => $gdtEntry) { + $gdtSum += $gdtEntry['gdt']; + //echo "index: $i
"; + //var_dump($gdtEntry); + } + if (isset($requestResult['data']['connectEntrys'])) { + $connectEntries = $requestResult['data']['connectEntrys']; + + foreach ($connectEntries as $entry) { + //if(!$count) var_dump($entry); + //$count++; + $gdtSum += $entry['connect']['gdt_entry']['gdt']; + } + $this->set('connectEntries', $connectEntries); } - $this->set('connectEntries', $connectEntries); - } //echo "gdtSum: $gdtSum
"; - $this->set('gdtSum', $gdtSum); - $this->set('ownEntries', $ownEntries); + $this->set('gdtSum', $gdtSum); + $this->set('ownEntries', $ownEntries); - if(isset($requestResult['data']['publishers'])) { - $publishers = $requestResult['data']['publishers']; - $this->set('publishers', $publishers); - } + if (isset($requestResult['data']['publishers'])) { + $publishers = $requestResult['data']['publishers']; + $this->set('publishers', $publishers); + } } else { - $this->Flash->error(__('Fehler beim GDT Server, bitte abwarten oder den Admin benachrichtigen!')); + $this->Flash->error(__('Fehler beim GDT Server, bitte abwarten oder den Admin benachrichtigen!')); } - } - public function sortTransactions($a, $b) { - if ($a['date'] == $b['date']) { - return 0; - } - return ($a['date'] > $b['date']) ? -1 : 1; - + public function sortTransactions($a, $b) + { + if ($a['date'] == $b['date']) { + return 0; + } + return ($a['date'] > $b['date']) ? -1 : 1; } /** diff --git a/src/Controller/TransactionSendCoinsController.php b/src/Controller/TransactionSendCoinsController.php index 598e378cf..3d35d81ea 100644 --- a/src/Controller/TransactionSendCoinsController.php +++ b/src/Controller/TransactionSendCoinsController.php @@ -12,6 +12,9 @@ use Cake\I18n\I18n; use App\Form\TransferForm; use App\Form\TransferRawForm; +use Model\Navigation\NaviHierarchy; +use Model\Navigation\NaviHierarchyEntry; + use Model\Transactions\TransactionTransfer; use Model\Transactions\TransactionBody; use Model\Transactions\Transaction; @@ -25,7 +28,7 @@ use Model\Transactions\Transaction; */ class TransactionSendCoinsController extends AppController { - + public function initialize() { parent::initialize(); @@ -34,8 +37,14 @@ class TransactionSendCoinsController extends AppController //$this->Auth->allow(['add', 'edit']); $this->Auth->allow('create'); $this->Auth->allow('createRaw'); + $this->set( + 'naviHierarchy', + (new NaviHierarchy())-> + add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', false))-> + add(new NaviHierarchyEntry(__('Überweisung'), 'TransactionSendCoins', 'create', true)) + ); } - + /** * Index method * @@ -116,7 +125,7 @@ class TransactionSendCoinsController extends AppController $receiverUsers = $this->TransactionSendCoins->ReceiverUsers->find('list', ['limit' => 200]); $this->set(compact('transactionSendCoin', 'transactions', 'stateUsers', 'receiverUsers')); } - + public function create() { /*$locale = I18n::getLocale(); @@ -136,28 +145,28 @@ class TransactionSendCoinsController extends AppController } $user = $session->read('StateUser'); } - + $transferForm = new TransferForm(); $this->set('transferForm', $transferForm); $this->set('timeUsed', microtime(true) - $startTime); - + if ($this->request->is('post')) { - //$this->Flash->error(__('Wird zurzeit noch entwickelt!')); - + //$this->Flash->error(__('Wird zurzeit noch entwickelt!')); + $requestData = $this->request->getData(); $mode = 'next'; if(isset($requestData['add'])) {$mode = 'add'; } if($transferForm->validate($requestData)) { - + $receiverPubKeyHex = ''; $senderPubKeyHex = $user['public_hex']; $amountCent = $this->GradidoNumber->parseInputNumberToCentNumber($requestData['amount']); - + if(!isset($user['balance']) || $amountCent > $user['balance']) { $this->Flash->error(__('Du hast nicht genug Geld!')); return; } - + $receiverEmail = $requestData['email']; if($receiverEmail === $user['email']) { $this->Flash->error(__('Du kannst dir leider nicht selbst Geld schicken!')); @@ -193,27 +202,27 @@ class TransactionSendCoinsController extends AppController $receiverPubKeyHex = bin2hex(stream_get_contents($receiverUser->public_key)); } //var_dump($sessionStateUser); - + $builderResult = TransactionTransfer::build( - $amountCent, - $requestData['memo'], + $amountCent, + $requestData['memo'], $receiverPubKeyHex, $senderPubKeyHex ); if($builderResult['state'] === 'success') { - + $http = new Client(); try { $loginServer = Configure::read('LoginServer'); $url = $loginServer['host'] . ':' . $loginServer['port']; $session_id = $session->read('session_id'); /* - * + * * $response = $http->post( * 'http://example.com/tasks', * json_encode($data), * ['type' => 'json'] - * ); + * ); */ $response = $http->post($url . '/checkTransaction', json_encode([ 'session_id' => $session_id, @@ -244,43 +253,43 @@ class TransactionSendCoinsController extends AppController $this->Flash->success(__('Transaction submitted for review.')); } } - + } catch(\Exception $e) { $msg = $e->getMessage(); $this->Flash->error(__('error http request: ') . $msg); } - + } else { $this->Flash->error(__('No Valid Receiver Public given: ' . $receiverPubKeyHex)); } - + // */ } else { $this->Flash->error(__('Something was invalid, please try again!')); } } - + $this->set('timeUsed', microtime(true) - $startTime); } - + public function createRaw() { $startTime = microtime(true); $this->viewBuilder()->setLayout('frontend'); - + $transferRawForm = new TransferRawForm(); $this->set('transferRawForm', $transferRawForm); - + if ($this->request->is('post')) { $requestData = $this->request->getData(); if($transferRawForm->validate($requestData)) { $amountCent = $this->GradidoNumber->parseInputNumberToCentNumber($requestData['amount']); $sender = ['priv' => $requestData['sender_privkey_hex'], 'pub' => $requestData['sender_pubkey_hex']]; $reciver = ['pub' => $requestData['receiver_pubkey_hex']]; - + $builderResult = TransactionTransfer::build( - $amountCent, - $requestData['memo'], + $amountCent, + $requestData['memo'], $reciver['pub'], $sender['pub'] ); @@ -299,14 +308,14 @@ class TransactionSendCoinsController extends AppController } else { $this->Flash->error(__('Error building transaction')); } - + } //var_dump($requestData); // //var_dump($data); - + } - + $this->set('timeUsed', microtime(true) - $startTime); } diff --git a/src/Model/Navigation/NaviHierarchy.php b/src/Model/Navigation/NaviHierarchy.php new file mode 100644 index 000000000..5017f8678 --- /dev/null +++ b/src/Model/Navigation/NaviHierarchy.php @@ -0,0 +1,49 @@ + +*/ +class NaviHierarchy implements \Countable +{ + private $hierarchy = []; + + public function add($entry) + { + array_push($this->hierarchy, $entry); + return $this; + } + public function getHierarchy() + { + return $this->hierarchy; + } + public function count() + { + return count($this->hierarchy); + } + public function __toString() + { + $html = ""; + return $html; + } +} diff --git a/src/Model/Navigation/NaviHierarchyEntry.php b/src/Model/Navigation/NaviHierarchyEntry.php new file mode 100644 index 000000000..5256518df --- /dev/null +++ b/src/Model/Navigation/NaviHierarchyEntry.php @@ -0,0 +1,53 @@ + +*/ +class NaviHierarchyEntry +{ + private $name; + private $controller; + private $action; + public function __construct($name, $controller, $action, $isLast) + { + $this->name = $name; + $this->controller = $controller; + $this->action = $action; + $this->isLast = $isLast; + return $this; + } + private function link() + { + $self = $GLOBALS["self"]; + return $self->Html->Link( + '' . $this->name . '', + ['controller' => $this->controller, 'action' => $this->action], + ['class' => "", 'escape' => false] + ); + } + + public function __toString() + { + $str = "isLast){ + $str .= " class='selected'"; + } + $str .= ">"; + $str .= $this->link(); + $str .= ""; + return $str; + } +} diff --git a/src/Template/Element/navi_center.ctp b/src/Template/Element/navi_center.ctp new file mode 100644 index 000000000..d07f44978 --- /dev/null +++ b/src/Template/Element/navi_center.ctp @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/Template/Layout/frontend.ctp b/src/Template/Layout/frontend.ctp index 387409c0d..062ae3844 100644 --- a/src/Template/Layout/frontend.ctp +++ b/src/Template/Layout/frontend.ctp @@ -66,7 +66,7 @@ $GLOBALS["self"] = $this;
fetch('header')): ?>
diff --git a/src/Template/StateBalances/overview.ctp b/src/Template/StateBalances/overview.ctp index dabe2449b..83fa0a967 100644 --- a/src/Template/StateBalances/overview.ctp +++ b/src/Template/StateBalances/overview.ctp @@ -24,12 +24,12 @@ $this->assign('header', $header);
-
-

Überweisungen

- +
+

Überweisungen

+
- - + + diff --git a/webroot/css/grd_styles.css b/webroot/css/grd_styles.css index b345123a2..105ba15d9 100644 --- a/webroot/css/grd_styles.css +++ b/webroot/css/grd_styles.css @@ -447,9 +447,9 @@ justify-content: flex-start; flex-direction: column; overflow: auto; - line-height: 1.5em; - background-color: #f9fafb; width: 100%; + background-color: #f9fafb; + line-height: 1.5em; letter-spacing: 0.03rem; font-family: Roboto, sans-serif; font-weight: 500; @@ -462,31 +462,42 @@ margin: 0 0.25em; margin-bottom: 1em; } + .nav-content-list { + display: flex; + list-style-type: none; + padding: 0; + margin-left: 0.25em; + } + .nav-content-separator { + margin: 0 1em; + } .content-container { background-color: #fff; color: #212529; - padding: 20px 25px 20px; - margin: 1em 0.25em; border-radius: 0.5em; box-shadow: 0 0 10px 0 rgba(183, 192, 206, 0.2); border: 1px solid rgba(238, 238, 238, 0.75); } .info-container { max-width: 70%; + padding: 20px 25px; + margin: 1em 0.25em; } .main-container { max-width: 100%; } .content-region { border-bottom: 1px dashed #F5F5F5; - padding: 1em; + padding: 20px 25px; + margin: 1em 0.25em; } .content-collection { display: flex; - flex-direction: column; + /* flex-direction: column;*/ } .content-item { margin: 0.5em 0; + margin-right: 5em; width: 150px; padding: 1em 2em; } @@ -497,6 +508,26 @@ .info-item { border-left: 2px solid grey; } + .content-list { + width: 100%; + } + .content-list-name { + margin: 0; + padding: 20px 25px; + color: #313131; + } + .content-list-table { + display: block; + width: 100%; + overflow-x: auto; + border-collapse: collapse; + border-spacing: 0; + color: #212529; + } + .content-list-table-header { + background-color: #fafafa; + border-top: 1px solid #f2f4f9; + } .info-item i, .info-item-link, .action-button i, diff --git a/websrc/src/less-files.css b/websrc/src/less-files.css index b345123a2..105ba15d9 100644 --- a/websrc/src/less-files.css +++ b/websrc/src/less-files.css @@ -447,9 +447,9 @@ justify-content: flex-start; flex-direction: column; overflow: auto; - line-height: 1.5em; - background-color: #f9fafb; width: 100%; + background-color: #f9fafb; + line-height: 1.5em; letter-spacing: 0.03rem; font-family: Roboto, sans-serif; font-weight: 500; @@ -462,31 +462,42 @@ margin: 0 0.25em; margin-bottom: 1em; } + .nav-content-list { + display: flex; + list-style-type: none; + padding: 0; + margin-left: 0.25em; + } + .nav-content-separator { + margin: 0 1em; + } .content-container { background-color: #fff; color: #212529; - padding: 20px 25px 20px; - margin: 1em 0.25em; border-radius: 0.5em; box-shadow: 0 0 10px 0 rgba(183, 192, 206, 0.2); border: 1px solid rgba(238, 238, 238, 0.75); } .info-container { max-width: 70%; + padding: 20px 25px; + margin: 1em 0.25em; } .main-container { max-width: 100%; } .content-region { border-bottom: 1px dashed #F5F5F5; - padding: 1em; + padding: 20px 25px; + margin: 1em 0.25em; } .content-collection { display: flex; - flex-direction: column; + /* flex-direction: column;*/ } .content-item { margin: 0.5em 0; + margin-right: 5em; width: 150px; padding: 1em 2em; } @@ -497,6 +508,26 @@ .info-item { border-left: 2px solid grey; } + .content-list { + width: 100%; + } + .content-list-name { + margin: 0; + padding: 20px 25px; + color: #313131; + } + .content-list-table { + display: block; + width: 100%; + overflow-x: auto; + border-collapse: collapse; + border-spacing: 0; + color: #212529; + } + .content-list-table-header { + background-color: #fafafa; + border-top: 1px solid #f2f4f9; + } .info-item i, .info-item-link, .action-button i, diff --git a/websrc/src/less/03-typography.less b/websrc/src/less/03-typography.less index 58979667a..e5afecf94 100644 --- a/websrc/src/less/03-typography.less +++ b/websrc/src/less/03-typography.less @@ -14,6 +14,7 @@ @body-lh: 27px; @content-lh: 1.5em; +@content-letter-spacing: .03rem; @nav-bottom-fs: .9em; @nav-btn-large-fs: 35px; diff --git a/websrc/src/less/10-center.less b/websrc/src/less/10-center.less index 987125f2d..2dffbf9c3 100644 --- a/websrc/src/less/10-center.less +++ b/websrc/src/less/10-center.less @@ -14,10 +14,10 @@ justify-content: flex-start; flex-direction: column; overflow: auto; - line-height: @content-lh; - background-color: @main-background; width: 100%; - letter-spacing: .03rem; + background-color: @main-background; + line-height: @content-lh; + letter-spacing: @content-letter-spacing; font-family: Roboto, sans-serif; font-weight: 500; font-size: 1rem; @@ -38,11 +38,20 @@ margin-bottom: 1em; } + .nav-content-list { + display: flex; + list-style-type: none; + padding: 0; + margin-left: .25em; + } + + .nav-content-separator { + margin: 0 1em; + } + .content-container { background-color: @container-background; color: @container-text; - padding: 20px 25px 20px; - margin: 1em .25em; border-radius: .5em; box-shadow: 0 0 10px 0 @container-shadow; border: 1px solid @container-border; @@ -50,6 +59,8 @@ .info-container { max-width: 70%; + padding: 20px 25px; + margin: 1em .25em; } .main-container { @@ -58,16 +69,17 @@ .content-region { border-bottom: 1px dashed @light; - padding: 1em; + padding: 20px 25px; + margin: 1em .25em; } .content-collection { - display: flex; - flex-direction: column; + display: flex;/* flex-direction: column;*/ } .content-item { margin: .5em 0; + margin-right: 5em; width: 150px; padding: 1em 2em; } @@ -81,8 +93,29 @@ border-left: 2px solid @info-item-border; } - .action-form { + .content-list { + width: 100%; + } + .content-list-name { + margin: 0; + padding: 20px 25px; + color: #313131; + } + .content-list-table { + display: block; + width: 100%; + overflow-x: auto; + border-collapse: collapse; + border-spacing: 0; + color: #212529; + } + .content-list-table-header { + background-color: #fafafa; + border-top: 1px solid #f2f4f9; + } + + .action-form { } .info-item i,