fshBridge.html 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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>Reload storage pool is needed for these changes to take effect</p>
  110. </div>
  111. <div class="actions">
  112. <div class="ui basic cancel inverted button" onclick="handleCancel();">
  113. Later
  114. </div>
  115. <div class="ui green ok inverted button" onclick="done();">
  116. <i class="checkmark icon"></i>
  117. Ok
  118. </div>
  119. </div>
  120. </div>
  121. <script>
  122. //Get target fsh uuid and group from hash
  123. var editingStoragePool = "";
  124. var otherPoolConfigMap = {};
  125. $(".ui.dropdown").dropdown();
  126. $(".ui.checkbox").checkbox();
  127. if (window.location.hash.length > 0){
  128. var input = JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
  129. editingStoragePool = input.group;
  130. $("#poolid").text("(" + editingStoragePool + ":/)");
  131. }
  132. initBridgingOptions();
  133. function initBridgingOptions(){
  134. $.get("../../system/storage/pool/list", function(data){
  135. $("#otherPools").html('');
  136. var firstPool = "";
  137. console.log(data);
  138. for (var i = 0; i < data.length; i++){
  139. let thisPool = data[i];
  140. if (thisPool.Owner == "system"){
  141. //Do not allow bridging
  142. continue;
  143. }
  144. if (thisPool.Owner != editingStoragePool){
  145. if (firstPool == ""){
  146. firstPool = JSON.parse(JSON.stringify(thisPool.Owner));
  147. }
  148. if (thisPool.Storages == null || thisPool.Storages.length == 0){
  149. otherPoolConfigMap[thisPool.Owner] = [];
  150. }else{
  151. otherPoolConfigMap[thisPool.Owner] = thisPool.Storages
  152. }
  153. $("#otherPools").append(`<div class="item" data-value="${thisPool.Owner}">${thisPool.Owner}</div>`);
  154. }
  155. }
  156. $("#otherPools").parent().dropdown();
  157. $("#otherPools").parent().dropdown("set selected", firstPool);
  158. loadFSHForPool(firstPool);
  159. });
  160. }
  161. function loadFSHForPool(poolName){
  162. if (otherPoolConfigMap[poolName]){
  163. $("#sourceFSH").html("");
  164. $("#sourceFSH").parent().removeClass('disabled');
  165. var storages = otherPoolConfigMap[poolName];
  166. if (storages.length > 0){
  167. storages.forEach(fsh => {
  168. $("#sourceFSH").append(`<div class="item" data-value="${fsh.UUID}"><i class="grey hdd icon"></i> ${fsh.Name} (${fsh.UUID}:/)</div>`);
  169. });
  170. $("#sourceFSH").parent().dropdown();
  171. $("#sourceFSH").parent().dropdown("set selected", storages[0].UUID);
  172. }else{
  173. //No storage inside
  174. $("#sourceFSH").parent().addClass('disabled');
  175. $("#sourceFSH").append(`<div class="item" data-value="nodisk"><i class="remove icon"></i> No File System Handler in this Storage Pool</div>`);
  176. $("#sourceFSH").parent().dropdown();
  177. $("#sourceFSH").parent().dropdown("set selected", "nodisk");
  178. }
  179. }else{
  180. //Pool not exists
  181. $("#sourceFSH").parent().addClass('disabled');
  182. }
  183. }
  184. function bridgeFSH(){
  185. var currentStoragePool = editingStoragePool;
  186. var selectedSourceFSH = $("#souceFSH").val();
  187. $.ajax({
  188. url: "../../system/storage/pool/bridge",
  189. data: {base: currentStoragePool, fsh: selectedSourceFSH},
  190. success: function(data){
  191. if (data.error !== undefined){
  192. $("#errMsg").text(data.error);
  193. $("#errdialog").stop().finish().slideDown("fast").delay(10000).slideUp("fast");
  194. }else{
  195. //Success
  196. $("#done").modal("show");
  197. $(window).scrollTop(0);
  198. }
  199. }
  200. })
  201. }
  202. function done(){
  203. ao_module_parentCallback(true);
  204. ao_module_close();
  205. }
  206. function handleCancel(){
  207. ao_module_close();
  208. }
  209. </script>
  210. </body>
  211. </html>