| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /*eslint-disable no-unused-vars*/
- $('#myTabs a').click(function (e) {
- e.preventDefault();
- $(this).tab('show');
- });
- var revokeDevice = function (key) {
- $.ajax({
- type: 'post',
- url: urls.revokeRecord,
- data: {'key': key},
- success: function () {
- var table = $('#trustedDevicesTable').DataTable();
- table
- .rows($('#' + key).parents('tr'))
- .remove()
- .draw();
- },
- error: function () {
- //console.log('Could not remove record');
- }
- });
- };
- var trustedDevices = (function () {
- var getData = function () {
- $.getJSON(urls.getRecords, function (data) {
- trustedDevicesTable(data);
- });
- };
- var trustedDevicesTable = function (jsonData) {
- var t = $('#trustedDevicesTable').DataTable({
- 'order': [[2, 'desc']],
- columnDefs: [
- {'width': '20%', 'targets': 0},
- {'width': '10%', 'targets': 1},
- {'width': '60%', 'targets': 2},
- {'width': '10%', 'targets': 3},
- {'width': '30%', 'targets': 4}
- ]
- });
- for (var i = 0; i < jsonData.length; i++) {
- var rec = jsonData[i];
- t.row.add([
- rec.name,
- rec.principal,
- new Date(rec.date),
- rec.geography,
- '<button id=\'' + rec.key + '\' class=\'btn btn-sm btn-danger\' type=\'button\' value=\'ALL\' onclick=\'revokeDevice("' + rec.key + '")\'>Revoke</button>'
- ]).draw(false);
- }
- };
- // initialization *******
- (function init() {
- getData();
- })();
- })();
|