diff --git a/lib/modem-dashboard/router-stocks.js b/lib/modem-dashboard/router-stocks.js index af17674..b15c8ea 100644 --- a/lib/modem-dashboard/router-stocks.js +++ b/lib/modem-dashboard/router-stocks.js @@ -7,12 +7,21 @@ module.exports = router; const matrix = require('komodo-sdk/matrix'); function pageIndex(req, res, next) { - let stocks_array; if (!matrix || !matrix.stock || (typeof matrix.stock !== 'object')) { - stocks_array = null; + res.render( + 'stocks.html', + { + page_title: 'Stock', + stocks_array: null + } + ) + return; } + let stocks_array = []; + + for (let key in matrix.stock) { if (matrix.stock.hasOwnProperty(key)) { stocks_array.push({ diff --git a/lib/modem-dashboard/views/stocks.html b/lib/modem-dashboard/views/stocks.html index 5c5ad04..4ac654f 100644 --- a/lib/modem-dashboard/views/stocks.html +++ b/lib/modem-dashboard/views/stocks.html @@ -2,6 +2,7 @@ {% block content %} +{% if stocks_array %} <table id="stocks" class="table table-hover table-striped"> {% for stock in stocks_array %} <tr> @@ -11,4 +12,8 @@ {% endfor %} </table> +{% else %} + Data tidak tersedia +{% endif %} + {% endblock %}