shares.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Share Manager</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" >
  7. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  8. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" />
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>
  10. <style>
  11. body{
  12. background-color: rgb(243, 243, 243);
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <br>
  18. <div class="ui container">
  19. <div class="ui segment">
  20. <table class="ui celled striped table">
  21. <thead>
  22. <tr><th colspan="4">
  23. List of shares on this WebStick
  24. </th>
  25. </tr>
  26. </thead>
  27. <tbody id="sharesListTable">
  28. <tr>
  29. <td colspan="4">
  30. <i class="ui loading spinner icon"></i> Loading
  31. </td>
  32. </tr>
  33. </tbody>
  34. </table>
  35. <button onclick="initShareList();" class="ui basic button"><i class="ui green refresh icon"></i>Refresh List</button>
  36. </div>
  37. </div>
  38. <script>
  39. function initShareList(){
  40. $("#sharesListTable").html(`<tr>
  41. <td colspan="4">
  42. <i class="ui loading spinner icon"></i> Loading
  43. </td>
  44. </tr>`);
  45. $.get("/api/share/list", function(data){
  46. if (data.error != undefined){
  47. alert(data.error);
  48. }else{
  49. $("#sharesListTable").html("");
  50. data.forEach(share => {
  51. $("#sharesListTable").append(`<tr>
  52. <td class="collapsing">
  53. <i class="grey file outline icon"></i> ${share.filename}
  54. </td>
  55. <td><i class="yellow folder icon"></i> ${share.filepath}</td>
  56. <td>${share.shareid}</td>
  57. <td class="right aligned collapsing">
  58. <a class="ui basic icon button" href="/share?id=${share.shareid}&download" target="_blank" download="" title="Download"><i class="ui blue download icon"></i></a>
  59. <a class="ui basic icon button" href="/share?id=${share.shareid}" target="_blank" title="Open Share"><i class="ui linkify green icon"></i></a>
  60. <button class="ui basic icon button" onclick="removeShareFromList('${share.filename}', '${share.filepath}', '${share.shareid}');" title="Remove Share"><i class="ui red trash icon"></i></button>
  61. </td>
  62. </tr>`);
  63. });
  64. if (data.length == 0){
  65. $("#sharesListTable").append(`<tr>
  66. <td colspan="4">
  67. <i class="green check circle icon"></i> No shared files on this WebStick
  68. </td>
  69. </tr>`);
  70. }
  71. }
  72. });
  73. }
  74. initShareList();
  75. //Remove a share from the share list
  76. function removeShareFromList(filename, filepath, uuid){
  77. if (confirm("Confirm share for " + filename + " ?")){
  78. $.post("/api/share/del?filename=" + filepath, function(data){
  79. if (data.error != undefined){
  80. alert(data.error);
  81. }else{
  82. initShareList();
  83. }
  84. })
  85. }
  86. }
  87. </script>
  88. </body>
  89. </html>