sharelist.html 8.8 KB

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