index.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="icon" type="image/png" href="img/small_icon.png"/>
  9. <link rel="stylesheet" href="script/semantic/semantic.min.css">
  10. <script src="script/jquery-3.6.0.min.js"></script>
  11. <script src="../script/ao_module.js"></script>
  12. <script src="script/semantic/semantic.min.js"></script>
  13. <title>Reverse Proxy</title>
  14. <style>
  15. body{
  16. background-color:white;
  17. }
  18. .functiontab{
  19. display:none;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <br>
  25. <div class="ui container">
  26. <h3><img class="ui middle aligned mini image" src="img/small_icon.png" style="margin-right:1em;"> Reverse Proxy Settings</h3>
  27. <div class="ui divider"></div>
  28. <div id="errmsg" class="ui red message" style="display: none;"></div>
  29. <div class="ui stackable grid">
  30. <div class="four wide column">
  31. <div id="mainmenu" class="ui secondary vertical pointing menu">
  32. <a class="item active" tag="status">
  33. <i class="info circle icon"></i>Status
  34. </a>
  35. <a class="item" tag="vdir">
  36. <i class="folder icon"></i> Virtual Directory
  37. </a>
  38. <a class="item" tag="subd">
  39. <i class="sitemap icon"></i> Subdomain Proxy
  40. </a>
  41. <a class="item" tag="rules">
  42. <i class="plus square icon"></i> Create Proxy Rules
  43. </a>
  44. <a class="item" tag="setroot">
  45. <i class="home icon"></i> Set Proxy Root
  46. </a>
  47. <div class="ui divider"></div>
  48. <a class="item" tag="cert">
  49. <i class="lock icon"></i> TLS / SSL certificate
  50. </a>
  51. </div>
  52. </div>
  53. <div class="twelve wide column">
  54. <!-- Status Tab -->
  55. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  56. <br><br><div class="ui active centered inline loader"></div>
  57. </div>
  58. <!-- Virtual Directory Tab -->
  59. <div id="vdir" class="functiontab" target="vdir.html"></div>
  60. <!-- Subdomain Proxy -->
  61. <div id="subd" class="functiontab" target="subd.html"></div>
  62. <!-- Create Rules -->
  63. <div id="rules" class="functiontab" target="rules.html"></div>
  64. <!-- Set proxy root -->
  65. <div id="setroot" class="functiontab" target="rproot.html"></div>
  66. <!-- Set TLS cert -->
  67. <div id="cert" class="functiontab" target="cert.html"></div>
  68. </div>
  69. </div>
  70. </div>
  71. <br><br>
  72. <div class="ui divider"></div>
  73. <div class="ui container" style="color: grey; font-size: 90%">
  74. <p>Reverse Proxy Subservice. CopyRight imuslab, Licensed under MIT</p>
  75. </div>
  76. </div>
  77. <br><br>
  78. <script>
  79. /*
  80. Loader function
  81. Load all the components view from the
  82. components/ directory into their corrisponding divs
  83. */
  84. let loadingComponents = 0;
  85. function initTabs(callback=undefined){
  86. $('.functiontab').each(function(){
  87. let loadTarget = $(this).attr("target");
  88. if (loadTarget != undefined){
  89. $(this).load("./components/" + loadTarget, function(){
  90. loadingComponents--;
  91. });
  92. loadingComponents++;
  93. }else{
  94. $(this).html(`<p>Unable to load components for this tab</p>`);
  95. }
  96. })
  97. if (callback != undefined){
  98. waitInit(callback);
  99. }
  100. }
  101. function waitInit(callback = undefined, retryCount = 0){
  102. if (loadingComponents > 0 && retryCount < 5){
  103. setTimeout(function(){
  104. waitInit(callback, retryCount++);
  105. }, 300);
  106. }else if (loadingComponents == 0){
  107. callback();
  108. }else{
  109. alert("Missing component. Please check if your installation is complete.")
  110. }
  111. }
  112. initTabs(function(){
  113. initRPStaste();
  114. if (window.location.hash.length > 1){
  115. let tabID = window.location.hash.substr(1);
  116. openTabById(tabID);
  117. }else{
  118. openTabById("status");
  119. }
  120. $(".ui.dropdown").dropdown();
  121. $(".ui.checkbox").checkbox();
  122. //Click on the current tab
  123. $("#mainmenu").find(".item").each(function(){
  124. $(this).on("click", function(event){
  125. let tabid = $(this).attr("tag");
  126. openTabById(tabid);
  127. });
  128. });
  129. });
  130. function getTabButtonById(targetTabId){
  131. let targetTabBtn = undefined;
  132. $("#mainmenu").find(".item").each(function(){
  133. let tabid = $(this).attr("tag");
  134. if (tabid == targetTabId){
  135. targetTabBtn = $(this);
  136. }
  137. });
  138. return targetTabBtn;
  139. }
  140. //Select and open a tab by its tag id
  141. function openTabById(tabID){
  142. let targetBtn = getTabButtonById(tabID);
  143. if (targetBtn == undefined){
  144. alert("Invalid tabid given");
  145. return;
  146. }
  147. $("#mainmenu").find(".item").removeClass("active");
  148. $(targetBtn).addClass("active");
  149. $(".functiontab").hide();
  150. $("#" + tabID).fadeIn('fast');
  151. window.location.hash = tabID;
  152. }
  153. //Generic functions
  154. function deleteEndpoint(ptype, epoint){
  155. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  156. $.ajax({
  157. url: "./del",
  158. data: {ep: epoint, ptype: ptype},
  159. success: function(){
  160. listVdirs();
  161. listSubd();
  162. }
  163. })
  164. }
  165. }
  166. function setProxyRoot(){
  167. var newpr = $("#proxyRoot").val();
  168. if (newpr.trim() == ""){
  169. $("#proxyRoot").parent().addClass('error');
  170. return
  171. }else{
  172. $("#proxyRoot").parent().removeClass('error');
  173. }
  174. var rootReqTls = $("#rootReqTLS")[0].checked;
  175. //Create the endpoint by calling add
  176. $.ajax({
  177. url: "./add",
  178. data: {"type": "root", tls: rootReqTls, ep: newpr},
  179. success: function(data){
  180. if (data.error != undefined){
  181. alert(data.error);
  182. }else{
  183. //OK
  184. initRootInfo();
  185. $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
  186. }
  187. }
  188. });
  189. }
  190. //Show error message
  191. function errmsg(message){
  192. $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
  193. $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
  194. }
  195. </script>
  196. </body>
  197. </html>