fshBridge.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  6. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  7. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  8. <script type="text/javascript" src="../../script/ao_module.js"></script>
  9. <title>Storage Pool Editor</title>
  10. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  11. <style>
  12. body{
  13. background-color:white;
  14. }
  15. .themebackground{
  16. background-color:#242424 !important;
  17. color:white !important;
  18. background-image: url("img/slate.png") !important;
  19. background-repeat: no-repeat !important;
  20. background-attachment: fixed !important;
  21. height:100px;
  22. border: 0px solid transparent !important;
  23. padding:24px !important;
  24. }
  25. .fshList{
  26. max-height: 300px;
  27. overflow-y: auto;
  28. }
  29. .controls{
  30. position: absolute;
  31. top: 12px;
  32. right: 12px;
  33. }
  34. a{
  35. cursor: pointer;
  36. }
  37. .backuponly{
  38. display:none;
  39. }
  40. .backgroundIcon{
  41. position: fixed;
  42. bottom: 0px;
  43. right: 0px;
  44. opacity: 0.3;
  45. margin-right: -3em;
  46. margin-bottom: -5em;
  47. z-index: -99;
  48. pointer-events: none;
  49. user-select: none;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <div class="backgroundIcon">
  55. <img class="ui medium image" src="../../img/system/drive-bridge.svg">
  56. </div>
  57. <br>
  58. <div class="ui container">
  59. <h3 class="ui header">
  60. <img src="../../img/system/drive-bridge.svg">
  61. <div class="content">
  62. <span>Bridge File System Handler </span><span id="poolid"></span>
  63. <div class="sub header">Share Storage across Storage Pools</div>
  64. </div>
  65. </h3>
  66. <div class="ui divider"></div>
  67. <div class="ui text segment">
  68. <p><i class="ui info blue circle icon"></i> Bridge a File System Handler (FSH) from other Storage Pool to this pool.
  69. The bridged FSH will implements the same permission and hierarchy as its source pool</p>
  70. <p><b>Notes: All users that has access to this storage pool will be able to access the newly bridged File System Handler</b></p>
  71. </div>
  72. <div id="errdialog" class="ui red message" style="display:none;">
  73. <i class="ui red remove icon"></i> <span id="errMsg">Unknown Error Occured</span>
  74. </div>
  75. <div class="ui form">
  76. <p>Source File System Handler</p>
  77. <div class="field">
  78. <label>Storage Pool from Permission Group</label>
  79. <div class="ui selection dropdown">
  80. <input id="bridgeTargetPool" type="hidden" name="sourcePool" value="" onchange="loadFSHForPool(this.value);">
  81. <i class="dropdown icon"></i>
  82. <div class="default text"></div>
  83. <div id="otherPools" class="menu">
  84. </div>
  85. </div>
  86. </div>
  87. <div class="field">
  88. <label>Target File System Handler</label>
  89. <div class="ui selection dropdown">
  90. <input id="souceFSH" type="hidden" name="souceFSH" value="">
  91. <i class="dropdown icon"></i>
  92. <div class="default text"></div>
  93. <div id="sourceFSH" class="menu">
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <br>
  99. <div class="ui right floated buttons">
  100. <button class="ui green button" onclick="bridgeFSH();">Bridge Handler to Pool</button>
  101. <button class="ui button" onclick="handleCancel();"></i>Close</button>
  102. </div>
  103. <div id="done" class="ui basic modal">
  104. <div class="ui icon header">
  105. <i class="green checkmark icon"></i>
  106. File System Handler Bridged
  107. </div>
  108. <div class="content">
  109. <p>Click OK to exit the handler bridging utility.</p>
  110. </div>
  111. <div class="actions">
  112. <div class="ui green ok inverted button" onclick="done();">
  113. <i class="checkmark icon"></i>
  114. OK
  115. </div>
  116. </div>
  117. </div>
  118. <script>
  119. //Get target fsh uuid and group from hash
  120. var editingStoragePool = "";
  121. var otherPoolConfigMap = {};
  122. $(".ui.dropdown").dropdown();
  123. $(".ui.checkbox").checkbox();
  124. if (window.location.hash.length > 0){
  125. var input = JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
  126. editingStoragePool = input.group;
  127. $("#poolid").text("(" + editingStoragePool + ")");
  128. }
  129. initBridgingOptions();
  130. function initBridgingOptions(){
  131. $.get("../../system/storage/pool/list", function(data){
  132. $("#otherPools").html('');
  133. var firstPool = "";
  134. console.log(data);
  135. for (var i = 0; i < data.length; i++){
  136. let thisPool = data[i];
  137. if (thisPool.Owner == "system"){
  138. //Do not allow bridging
  139. continue;
  140. }
  141. if (thisPool.Owner != editingStoragePool){
  142. if (firstPool == ""){
  143. firstPool = JSON.parse(JSON.stringify(thisPool.Owner));
  144. }
  145. if (thisPool.Storages == null || thisPool.Storages.length == 0){
  146. otherPoolConfigMap[thisPool.Owner] = [];
  147. }else{
  148. otherPoolConfigMap[thisPool.Owner] = thisPool.Storages
  149. }
  150. $("#otherPools").append(`<div class="item" data-value="${thisPool.Owner}">${thisPool.Owner}</div>`);
  151. }
  152. }
  153. $("#otherPools").parent().dropdown();
  154. $("#otherPools").parent().dropdown("set selected", firstPool);
  155. loadFSHForPool(firstPool);
  156. });
  157. }
  158. function loadFSHForPool(poolName){
  159. if (otherPoolConfigMap[poolName]){
  160. $("#sourceFSH").html("");
  161. $("#sourceFSH").parent().removeClass('disabled');
  162. var storages = otherPoolConfigMap[poolName];
  163. if (storages.length > 0){
  164. storages.forEach(fsh => {
  165. $("#sourceFSH").append(`<div class="item" data-value="${fsh.UUID}"><i class="grey hdd icon"></i> ${fsh.Name} (${fsh.UUID}:/)</div>`);
  166. });
  167. $("#sourceFSH").parent().dropdown();
  168. $("#sourceFSH").parent().dropdown("set selected", storages[0].UUID);
  169. }else{
  170. //No storage inside
  171. $("#sourceFSH").parent().addClass('disabled');
  172. $("#sourceFSH").append(`<div class="item" data-value="nodisk"><i class="remove icon"></i> No File System Handler in this Storage Pool</div>`);
  173. $("#sourceFSH").parent().dropdown();
  174. $("#sourceFSH").parent().dropdown("set selected", "nodisk");
  175. }
  176. }else{
  177. //Pool not exists
  178. $("#sourceFSH").parent().addClass('disabled');
  179. }
  180. }
  181. function bridgeFSH(){
  182. var currentStoragePool = editingStoragePool;
  183. var selectedSourceFSH = $("#souceFSH").val();
  184. $.ajax({
  185. url: "../../system/storage/pool/bridge",
  186. data: {base: currentStoragePool, fsh: selectedSourceFSH},
  187. success: function(data){
  188. if (data.error !== undefined){
  189. $("#errMsg").text(data.error);
  190. $("#errdialog").stop().finish().slideDown("fast").delay(10000).slideUp("fast");
  191. }else{
  192. //Success
  193. $("#done").modal("show");
  194. $(window).scrollTop(0);
  195. }
  196. }
  197. })
  198. }
  199. function done(){
  200. ao_module_parentCallback(true);
  201. ao_module_close();
  202. }
  203. function handleCancel(){
  204. ao_module_close();
  205. }
  206. </script>
  207. </body>
  208. </html>