vdir.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <div class="standardContainer">
  2. <div class="ui basic segment">
  3. <h2>Virtual Directory</h2>
  4. <p>A virtual directory is a consolidated view of multiple directories that provides a unified entry point for users to access disparate sources.</p>
  5. </div>
  6. <div class="ui stackable grid">
  7. <div class="six wide column">
  8. <h4>Select a Target Host / Site</h4>
  9. <p>Attach Virtual Directory routing rule to root proxy router</p>
  10. <div class="ui checkbox">
  11. <input type="checkbox" id="useRootProxyRouterForVdir" onchange="handleVdirAttachTargetChange(this);">
  12. <label>Use Root Proxy Router<br>
  13. <small>Only applicable when Default Site is set to "Reverse Proxy" mode</small></label>
  14. </div>
  15. <div class="ui horizontal divider">OR</div>
  16. <p>Create Virtual Directory routing in existing host / routing rule entries</p>
  17. <div class="ui fluid search selection dropdown">
  18. <input type="hidden" id="vdirBaseRoutingRule" name="vdirBaseRoutingRule" onchange="handleVdirAttachTargetChange();">
  19. <i class="dropdown icon"></i>
  20. <div class="default text">Select a host to edit</div>
  21. <div class="menu" id="hostDomainList">
  22. </div>
  23. </div>
  24. </div>
  25. <div class="ten wide column">
  26. <h4>Virtual Directory Routing Rules</h4>
  27. <p>The following are the list of Virtual Directories currently handled by the host router above</p>
  28. <div style="width: 100%; overflow-x: auto; margin-bottom: 1em;">
  29. <table class="ui celled sortable basic unstackable compact table">
  30. <thead>
  31. <tr>
  32. <th>Virtual Directory</th>
  33. <th>Proxy To</th>
  34. <th>Basic Auth</th>
  35. <th class="no-sort" style="min-width: 7.2em;">Actions</th>
  36. </tr>
  37. </thead>
  38. <tbody id="vdirList">
  39. <tr>
  40. <td data-label=""><button class="ui circular mini red basic button"><i class="remove icon"></i> Remove Proxy</button></td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. <button class="ui icon right floated basic button" onclick="listVdirs();"><i class="green refresh icon"></i> Refresh</button>
  46. </div>
  47. </div>
  48. <br><br>
  49. </div>
  50. <script>
  51. //Virtual directories functions
  52. //Initialize the list of hosts that can be used to attach vdirs config
  53. function initVdirList(){
  54. //Load the hosts into the dropdown
  55. $("#hostDomainList").html("");
  56. $.get("/api/proxy/list?type=host", function(data){
  57. if (data.error != undefined){
  58. msgbox(data.error, false);
  59. }else{
  60. if (data.length == 0){
  61. //No hosts found
  62. }else{
  63. data.forEach(proxyEndpoint => {
  64. let domain = proxyEndpoint.RootOrMatchingDomain;
  65. $("#hostDomainList").append(`<div class="item" data-value="${domain}">${domain}</div>`);
  66. });
  67. //Update the dropdown events
  68. $("#vdirBaseRoutingRule").parent().dropdown();
  69. }
  70. }
  71. });
  72. }
  73. function handleVdirAttachTargetChange(targetCheckbox=undefined){
  74. if (targetCheckbox != undefined && targetCheckbox.checked){
  75. $("#vdirBaseRoutingRule").parent().addClass("disabled");
  76. //Load the vdir list for root
  77. loadVdirList("root");
  78. }else{
  79. $("#vdirBaseRoutingRule").parent().removeClass("disabled");
  80. let selectedEndpointRule = $("#vdirBaseRoutingRule").val();
  81. if (selectedEndpointRule != ""){
  82. loadVdirList(selectedEndpointRule);
  83. }
  84. }
  85. }
  86. function loadVdirList(endpoint){
  87. alert("Loading endpoint " + endpoint)
  88. if (endpoint == "root"){
  89. //Load root endpoint vdir list
  90. }else{
  91. //Load target endpoint list
  92. }
  93. }
  94. /*
  95. function listVdirs(){
  96. $.get("/api/proxy/list?type=vdir", function(data){
  97. $("#vdirList").html(``);
  98. if (data.error !== undefined){
  99. $("#vdirList").append(`<tr>
  100. <td data-label="" colspan="3"><i class="remove icon"></i> ${data.error}</td>
  101. </tr>`);
  102. }else if (data.length == 0){
  103. $("#vdirList").append(`<tr>
  104. <td data-label="" colspan="3"><i class="checkmark icon"></i> No Virtual Directory Record</td>
  105. </tr>`);
  106. }else{
  107. data.forEach(vdir => {
  108. let tlsIcon = "";
  109. let vdirData = encodeURIComponent(JSON.stringify(vdir));
  110. if (vdir.RequireTLS){
  111. tlsIcon = `<i class="green lock icon" title="TLS Mode"></i>`;
  112. if (vdir.SkipCertValidations){
  113. tlsIcon = `<i class="yellow lock icon" title="TLS/SSL mode without verification"></i>`
  114. }
  115. }
  116. let tlsVerificationField = "";
  117. if (vdir.RequireTLS){
  118. tlsVerificationField = !vdir.SkipCertValidations?`<i class="ui green check icon"></i>`:`<i class="ui yellow exclamation circle icon" title="TLS/SSL Verification will be skipped on this host"></i>`
  119. }else{
  120. tlsVerificationField = "N/A"
  121. }
  122. $("#vdirList").append(`<tr eptuuid="${vdir.RootOrMatchingDomain}" payload="${vdirData}" class="vdirEntry">
  123. <td data-label="" editable="false">${vdir.RootOrMatchingDomain}</td>
  124. <td data-label="" editable="true" datatype="domain">${vdir.Domain} ${tlsIcon}</td>
  125. <td data-label="" editable="true" datatype="basicauth">${vdir.RequireBasicAuth?`<i class="ui green check icon"></i>`:`<i class="ui grey remove icon"></i>`}</td>
  126. <td class="center aligned" editable="true" datatype="action" data-label="">
  127. <button class="ui circular mini basic icon button editBtn" onclick='editEndpoint("vdir","${vdir.RootOrMatchingDomain}")'><i class="edit icon"></i></button>
  128. <button class="ui circular mini red basic icon button" onclick='deleteEndpoint("vdir","${vdir.RootOrMatchingDomain}")'><i class="trash icon"></i></button>
  129. </td>
  130. </tr>`);
  131. });
  132. }
  133. });
  134. }
  135. */
  136. //Bind on tab switch events
  137. tabSwitchEventBind["vdir"] = function(){
  138. initVdirList();
  139. }
  140. </script>