sharelist.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <html>
  2. <head>
  3. <title locale="title/title">Share Entry List</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../script/semantic/semantic.css">
  7. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  8. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  9. <script type="text/javascript" src="../../script/ao_module.js"></script>
  10. <script type="text/javascript" src="../../script/applocale.js"></script>
  11. <script type="text/javascript" src="../../script/clipboard.min.js"></script>
  12. <style>
  13. </style>
  14. </head>
  15. <body id="filePropertiesWindow">
  16. <br>
  17. <div class="ui container">
  18. <h3 class="ui header">
  19. <i class="share alternate icon"></i>
  20. <div class="content">
  21. <span locale="title/title">Share Entries</span> <span id="vrootname"></span>
  22. <div class="sub header" locale="title/desc">Shared files in this drive</div>
  23. </div>
  24. </h3>
  25. <div class="ui divider"></div>
  26. <div id="succ" style="display:none;" class="ui green message">
  27. <i class="ui checkmark icon"></i> <span id="msg" locale="message/removed">Share Removed</span>
  28. </div>
  29. <div style="max-height: calc(100vh - 120px); overflow-y: auto;">
  30. <table class="ui very basic fluid celled compact table unstackable">
  31. <tbody id="shares">
  32. <tr>
  33. <td>
  34. <h4 class="ui header">
  35. <div class="content">
  36. <span locale="message/noshare/title">No Shares</span>
  37. <div locale="message/noshare/desc" class="sub header">Try select a file using File Manager and right click share</div>
  38. </div>
  39. </h4>
  40. </td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. <br>
  46. </div>
  47. <script>
  48. //Get fsh id from hash if exists
  49. let fshId = "";
  50. if (window.location.hash.length > 1){
  51. var fshIds = window.location.hash.substr(1);
  52. fshIds = JSON.parse(decodeURIComponent(fshIds));
  53. fshId = fshIds[0];
  54. $("#vrootname").text("(" + fshId + ")");
  55. }
  56. applocale.init("../../SystemAO/locale/sharelist.json", function(){
  57. applocale.translate();
  58. listSharedItems();
  59. });
  60. function listSharedItems(){
  61. $("#shares").html("");
  62. $.get("../../system/file_system/share/list?fsh=" + fshId, function(data){
  63. console.log(data);
  64. data.forEach(function(entry){
  65. let filename = entry.FileVirtualPath.split("/").pop();
  66. let port = window.location.port;
  67. if (window.location.port == ""){
  68. port = "";
  69. }
  70. let openShareButton = ` <a title="Open Share" href="/share/${entry.UUID}" target="_blank" class="ui icon basic button"><i class="external icon"></i></a>`;
  71. if (!entry.CanAccess){
  72. openShareButton = "";
  73. }
  74. let openButton = `<button title="Open in File Manager" path="${entry.FileVirtualPath}" isfolder="${entry.IsFolder}" onclick="openThis(this);" class="ui icon basic button"><i class="folder open icon"></i></button>`;
  75. if (!entry.CanOpenInFileManager){
  76. openButton = "";
  77. }
  78. let deleteButton = `<button title="Delete Share" uuid="${entry.UUID}" onclick="deleteShare(this);" class="ui red icon button"><i class="trash icon"></i></button>`;
  79. if (!entry.CanDelete){
  80. deleteButton = "";
  81. }
  82. $("#shares").append(`
  83. <tr>
  84. <td>
  85. <h4 class="ui header">
  86. <div class="content">
  87. <span>${filename} </span>
  88. <div class="sub header">${applocale.getString("item/creator", "Creator: ")} ${entry.Owner} / ${applocale.getString("item/perm", "Permission: ")} ${entry.Permission} / <span class="linkCopier" style="cursor:pointer; color: #3452eb;" title="Copy Link" data-clipboard-text="${window.location.protocol + '//' + window.location.hostname + ":" + port + "/share/" + entry.UUID}"><i class="linkify icon"></i></span>
  89. </div>
  90. </h4>
  91. </td>
  92. <td style="padding-right: 0.6em;">
  93. <div class="ui small vertical buttons">
  94. ${openShareButton}
  95. ${openButton}
  96. ${deleteButton}
  97. </div>
  98. </td>
  99. </tr>`);
  100. });
  101. var clipboard = new ClipboardJS('.linkCopier');
  102. clipboard.on('success', function(e) {
  103. //console.info('Action:', e.action);
  104. // console.info('Text:', e.text);
  105. // console.info('Trigger:', e.trigger);
  106. let originalContent = $(e.trigger).html();
  107. $(e.trigger).html(`<i class="ui green checkmark icon"></i>`);
  108. $(e.trigger).css("pointer-events", "none");
  109. setTimeout(function(){
  110. $(e.trigger).html(originalContent);
  111. $(e.trigger).css("pointer-events", "auto");
  112. }, 1500);
  113. e.clearSelection();
  114. });
  115. if (data.length == 0){
  116. $("#shares").html(`<tr>
  117. <td>
  118. <h4 class="ui header">
  119. <div class="content">
  120. <span locale="message/noshare/title">No Shares</span>
  121. <div locale="message/noshare/desc" class="sub header">Try select a file using File Manager and right click share</div>
  122. </div>
  123. </h4>
  124. </td>
  125. </tr>`);
  126. }
  127. applocale.translate();
  128. });
  129. }
  130. function openThis(object){
  131. var vpath = $(object).attr("path");
  132. var isFolder = $(object).attr("isfolder") == "true";
  133. let openingPath = vpath;
  134. if (isFolder){
  135. ao_module_openPath(vpath);
  136. }else{
  137. let c = vpath.split("/");
  138. let filename = c.pop();
  139. let folderpath = c.join("/");
  140. ao_module_openPath(folderpath, filename);
  141. }
  142. }
  143. function deleteShare(object){
  144. let deleteUUID = $(object).attr("uuid");
  145. if (confirm(applocale.getString("message/delwarning", "All collaborators will lose access to this file via File Share interface. Confirm?"))){
  146. $.ajax({
  147. url: "../../system/file_system/share/delete",
  148. method: "POST",
  149. data: {uuid: deleteUUID},
  150. success: function(data){
  151. console.log(data);
  152. listSharedItems();
  153. $("#succ").stop().finish().slideDown("fast").delay(3000).slideUp("fast");
  154. }
  155. });
  156. }
  157. }
  158. </script>
  159. </body>
  160. </html>