sharelist.html 9.0 KB

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