user_accounts.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>KTVManager</title>
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  8. <link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css">
  9. <link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.dataTables.min.css">
  10. <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
  11. </head>
  12. <body>
  13. <!-- Navbar -->
  14. <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  15. <a class="navbar-brand" href="/">KTVManager</a>
  16. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
  17. <span class="navbar-toggler-icon"></span>
  18. </button>
  19. <div class="collapse navbar-collapse" id="navbarNav">
  20. <ul class="navbar-nav ml-auto">
  21. <li class="nav-item"><a class="nav-link" href="/">Home</a></li>
  22. <li class="nav-item"><a class="nav-link" href="/accounts">Accounts</a></li>
  23. <li class="nav-item"><a class="nav-link" href="/urls">URLs</a></li>
  24. </ul>
  25. </div>
  26. </nav>
  27. <!-- Sub-navigation for Accounts -->
  28. <div class="bg-light py-2">
  29. <div class="container">
  30. <ul class="nav nav-pills">
  31. <li class="nav-item">
  32. <a class="nav-link active" href="/accounts">List Accounts</a>
  33. </li>
  34. <li class="nav-item">
  35. <a class="nav-link" href="/accounts/add">Add Account</a>
  36. </li>
  37. </ul>
  38. </div>
  39. </div>
  40. <!-- Main Content -->
  41. <main div class="container mt-5">
  42. <h2>{{ username }}'s Accounts</h2>
  43. <div class="table-responsive">
  44. <table class="table table-striped" id="accountsTable">
  45. <thead>
  46. <tr>
  47. <!-- <th>#</th> -->
  48. <th>Username</th>
  49. <th>Stream</th>
  50. <th>Stream URL</th>
  51. <th>Expiry Date</th>
  52. <th>Password</th>
  53. <th>Actions</th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. {% for account in user_accounts %}
  58. <tr>
  59. <!-- <td>{{ loop.index }}</td> -->
  60. <td>{{ account.username }}</td>
  61. <td>{{ account.stream }}</td>
  62. <td><a href="{{ account.streamURL }}" target="_blank">{{ account.streamURL }}</a></td>
  63. <td>{{ account.expiaryDate_rendered }}</td>
  64. <td>{{ account.password }}</td>
  65. <td>
  66. <form action="/accounts/delete" method="POST" style="display:inline;">
  67. <input type="hidden" name="stream" value="{{ account.stream }}">
  68. <input type="hidden" name="username" value="{{ account.username }}">
  69. <button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this account?');">
  70. Delete
  71. </button>
  72. </form>
  73. </td>
  74. </tr>
  75. {% endfor %}
  76. </tbody>
  77. </table>
  78. </div>
  79. </div>
  80. </main>
  81. <footer class="bg-dark text-white text-center py-3 mt-5">
  82. <p></p>
  83. </footer>
  84. <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  85. <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.0.7/dist/umd/popper.min.js"></script>
  86. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  87. <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
  88. <script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
  89. <script>
  90. $(document).ready(function() {
  91. // Extend DataTables date sorting for DD/MM/YYYY format
  92. $.fn.dataTable.ext.type.order['date-eu-pre'] = function(data) {
  93. const parts = data.split('/');
  94. // Check if the data is in the correct format before processing
  95. if (parts.length === 3) {
  96. return new Date(parts[2], parts[1] - 1, parts[0]).getTime();
  97. }
  98. return data; // return as is if the format is unexpected
  99. };
  100. // Initialize DataTable with custom sorting and default ordering by Expiry Date
  101. $('#accountsTable').DataTable({
  102. "searching": true,
  103. "ordering": true,
  104. "responsive": true,
  105. "order": [[3, 'asc']], // Default order by Expiry Date column in ascending order
  106. "columnDefs": [
  107. { "type": "date-eu", "targets": 3 } // Use custom date-eu type for the date column
  108. ]
  109. });
  110. });
  111. </script>
  112. </body>
  113. </html>