Commit d05bdbd3f4739cb9fedd5b508400f306822e7afa
1 parent
8d57793ce9
Exists in
master
Perbaikan data stock kosong
Showing 2 changed files with 16 additions and 2 deletions Side-by-side Diff
lib/modem-dashboard/router-stocks.js
... | ... | @@ -7,12 +7,21 @@ module.exports = router; |
7 | 7 | const matrix = require('komodo-sdk/matrix'); |
8 | 8 | |
9 | 9 | function pageIndex(req, res, next) { |
10 | - let stocks_array; | |
11 | 10 | |
12 | 11 | if (!matrix || !matrix.stock || (typeof matrix.stock !== 'object')) { |
13 | - stocks_array = null; | |
12 | + res.render( | |
13 | + 'stocks.html', | |
14 | + { | |
15 | + page_title: 'Stock', | |
16 | + stocks_array: null | |
17 | + } | |
18 | + ) | |
19 | + return; | |
14 | 20 | } |
15 | 21 | |
22 | + let stocks_array = []; | |
23 | + | |
24 | + | |
16 | 25 | for (let key in matrix.stock) { |
17 | 26 | if (matrix.stock.hasOwnProperty(key)) { |
18 | 27 | stocks_array.push({ |
lib/modem-dashboard/views/stocks.html
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | {% block content %} |
4 | 4 | |
5 | +{% if stocks_array %} | |
5 | 6 | <table id="stocks" class="table table-hover table-striped"> |
6 | 7 | {% for stock in stocks_array %} |
7 | 8 | <tr> |
... | ... | @@ -11,4 +12,8 @@ |
11 | 12 | {% endfor %} |
12 | 13 | </table> |
13 | 14 | |
15 | +{% else %} | |
16 | + Data tidak tersedia | |
17 | +{% endif %} | |
18 | + | |
14 | 19 | {% endblock %} |