Commit f410645402471f70e01867a7d7c76a36b8366277
1 parent
a11f2895d6
Exists in
master
tanggal pada ussd dan sms index
Showing 3 changed files with 11 additions and 4 deletions Inline Diff
lib/modem-dashboard/router-ussd.js
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | const moment = require('moment'); | 3 | const moment = require('moment'); |
4 | const express = require('express'); | 4 | const express = require('express'); |
5 | 5 | ||
6 | const localDb = require('../local-db'); | 6 | const localDb = require('../local-db'); |
7 | 7 | ||
8 | const router = express.Router(); | 8 | const router = express.Router(); |
9 | module.exports = router; | 9 | module.exports = router; |
10 | 10 | ||
11 | function pageIndex(req, res, next) { | 11 | function pageIndex(req, res, next) { |
12 | if (!req.query.input_date) { | ||
13 | req.query.input_date = moment().format('YYYY-MM-DD'); | ||
14 | } | ||
15 | |||
12 | res.render( | 16 | res.render( |
13 | 'ussd.index.html', | 17 | 'ussd.index.html', |
14 | { | 18 | { |
15 | page_title: 'Histori USSD' | 19 | page_title: 'Histori USSD', |
20 | input_date: req.query.input_date | ||
16 | } | 21 | } |
17 | ) | 22 | ) |
18 | } | 23 | } |
19 | 24 | ||
20 | function pageDataTables(req, res, next) { | 25 | function pageDataTables(req, res, next) { |
21 | const db = localDb.getConnection(); | 26 | const db = localDb.getConnection(); |
22 | 27 | ||
23 | const created_date = moment().format('YYYY-MM-DD'); | 28 | const created_date = req.query.input_date || moment().format('YYYY-MM-DD'); |
24 | const query = "SELECT rowid, * FROM ussd WHERE created_date = ? ORDER BY created DESC, rowid DESC"; | 29 | const query = "SELECT rowid, * FROM ussd WHERE created_date = ? ORDER BY created DESC, rowid DESC"; |
25 | db.all(query, created_date, function (err, rows) { | 30 | db.all(query, created_date, function (err, rows) { |
26 | if (err) { | 31 | if (err) { |
27 | res.end("Ada error: " + err); | 32 | res.end("Ada error: " + err); |
28 | return; | 33 | return; |
29 | } | 34 | } |
30 | res.json({data: rows}); | 35 | res.json({data: rows}); |
31 | }); | 36 | }); |
32 | } | 37 | } |
33 | 38 | ||
34 | router.get('/', pageIndex); | 39 | router.get('/', pageIndex); |
35 | router.get('/datatables', pageDataTables); | 40 | router.get('/datatables', pageDataTables); |
36 | 41 |
lib/modem-dashboard/views/date-selector.html
1 | <div class="panel panel-default"> | 1 | <div class="panel panel-default"> |
2 | <div class="panel-body"> | 2 | <div class="panel-body"> |
3 | <form class="form-horizontal"> | 3 | <form class="form-horizontal"> |
4 | <div class="form-group"> | 4 | <div class="form-group"> |
5 | <label for="inputDate" class="col-sm-2 control-label">Tanggal:</label> | 5 | <label for="inputDate" class="col-sm-2 control-label">Tanggal:</label> |
6 | <div class="col-sm-3"> | 6 | <div class="col-sm-3"> |
7 | <input type="date" class="form-control" id="inputDate" placeholder="Tanggal" name="inputDate" value="{{ input_date }}"> | 7 | <input type="date" class="form-control" id="inputDate" placeholder="Tanggal" name="input_date" value="{{ input_date }}"> |
8 | </div> | 8 | </div> |
9 | </div> | 9 | </div> |
10 | 10 | ||
11 | <div class="form-group hidden-print"> | 11 | <div class="form-group hidden-print"> |
12 | <div class="col-sm-offset-2 col-sm-10"> | 12 | <div class="col-sm-offset-2 col-sm-10"> |
13 | <input type="submit" name="submit" value="Submit" class="btn btn-primary"> | 13 | <input type="submit" name="submit" value="Submit" class="btn btn-primary"> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | </form> | 16 | </form> |
17 | </div> | 17 | </div> |
18 | </div> | 18 | </div> |
19 | 19 |
lib/modem-dashboard/views/ussd.index.html
1 | {% extends "template.html" %} | 1 | {% extends "template.html" %} |
2 | 2 | ||
3 | {% block head %} | 3 | {% block head %} |
4 | <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.18/css/dataTables.bootstrap.min.css"> | 4 | <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.18/css/dataTables.bootstrap.min.css"> |
5 | <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script> | 5 | <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script> |
6 | <script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/dataTables.bootstrap.min.js"></script> | 6 | <script type="text/javascript" src="https://cdn.datatables.net/1.10.18/js/dataTables.bootstrap.min.js"></script> |
7 | {% endblock %} | 7 | {% endblock %} |
8 | 8 | ||
9 | {% block content %} | 9 | {% block content %} |
10 | 10 | ||
11 | {% include "date-selector.html" %} | ||
12 | |||
11 | <table id="smsHistory" class="display table table-hover table-striped"> | 13 | <table id="smsHistory" class="display table table-hover table-striped"> |
12 | <thead> | 14 | <thead> |
13 | <tr> | 15 | <tr> |
14 | <th>#</th> | 16 | <th>#</th> |
15 | <th>Tanggal</th> | 17 | <th>Tanggal</th> |
16 | <th>Arah</th> | 18 | <th>Arah</th> |
17 | <th>IMSI Modem</th> | 19 | <th>IMSI Modem</th> |
18 | <th>Pesan</th> | 20 | <th>Pesan</th> |
19 | </tr> | 21 | </tr> |
20 | </thead> | 22 | </thead> |
21 | <tfoot> | 23 | <tfoot> |
22 | <tr> | 24 | <tr> |
23 | <th>#</th> | 25 | <th>#</th> |
24 | <th>Tanggal</th> | 26 | <th>Tanggal</th> |
25 | <th>Arah</th> | 27 | <th>Arah</th> |
26 | <th>IMSI Modem</th> | 28 | <th>IMSI Modem</th> |
27 | <th>Pesan</th> | 29 | <th>Pesan</th> |
28 | </tr> | 30 | </tr> |
29 | </tfoot> | 31 | </tfoot> |
30 | </table> | 32 | </table> |
31 | 33 | ||
32 | <script> | 34 | <script> |
33 | $(document).ready(function() { | 35 | $(document).ready(function() { |
34 | $('#smsHistory').DataTable( { | 36 | $('#smsHistory').DataTable( { |
35 | "ajax": "/ussd/datatables", | 37 | "ajax": "/ussd/datatables?input_date={{ input_date}}", |
36 | "language": { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Indonesian.json" }, | 38 | "language": { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Indonesian.json" }, |
37 | "columns": [ | 39 | "columns": [ |
38 | { "data": "rowid" }, | 40 | { "data": "rowid" }, |
39 | { "data": "created" }, | 41 | { "data": "created" }, |
40 | { "data": "direction" }, | 42 | { "data": "direction" }, |
41 | { "data": "imsi" }, | 43 | { "data": "imsi" }, |
42 | { "data": "msg" } | 44 | { "data": "msg" } |
43 | ], | 45 | ], |
44 | "order": [ | 46 | "order": [ |
45 | [1, "desc"] | 47 | [1, "desc"] |
46 | ], | 48 | ], |
47 | "lengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]] | 49 | "lengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]] |
48 | } ); | 50 | } ); |
49 | } ); | 51 | } ); |
50 | </script> | 52 | </script> |
51 | 53 | ||
52 | {% endblock %} | 54 | {% endblock %} |
53 | 55 |