index.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. <a class="item" tag="redirectset">
  52. <i class="level up alternate icon"></i> Redirection
  53. </a>
  54. </div>
  55. </div>
  56. <div class="twelve wide column">
  57. <!-- Status Tab -->
  58. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  59. <br><br><div class="ui active centered inline loader"></div>
  60. </div>
  61. <!-- Virtual Directory Tab -->
  62. <div id="vdir" class="functiontab" target="vdir.html"></div>
  63. <!-- Subdomain Proxy -->
  64. <div id="subd" class="functiontab" target="subd.html"></div>
  65. <!-- Create Rules -->
  66. <div id="rules" class="functiontab" target="rules.html"></div>
  67. <!-- Set proxy root -->
  68. <div id="setroot" class="functiontab" target="rproot.html"></div>
  69. <!-- Set TLS cert -->
  70. <div id="cert" class="functiontab" target="cert.html"></div>
  71. <!-- Redirections -->
  72. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  73. </div>
  74. </div>
  75. </div>
  76. <br><br>
  77. <div class="ui divider"></div>
  78. <div class="ui container" style="color: grey; font-size: 90%">
  79. <p>Reverse Proxy Subservice. CopyRight imuslab, Licensed under MIT</p>
  80. </div>
  81. </div>
  82. <br><br>
  83. <script>
  84. /*
  85. Loader function
  86. Load all the components view from the
  87. components/ directory into their corrisponding divs
  88. */
  89. let loadingComponents = 0;
  90. function initTabs(callback=undefined){
  91. $('.functiontab').each(function(){
  92. let loadTarget = $(this).attr("target");
  93. if (loadTarget != undefined){
  94. $(this).load("./components/" + loadTarget, function(){
  95. loadingComponents--;
  96. });
  97. loadingComponents++;
  98. }else{
  99. $(this).html(`<p>Unable to load components for this tab</p>`);
  100. }
  101. })
  102. if (callback != undefined){
  103. waitInit(callback);
  104. }
  105. }
  106. function waitInit(callback = undefined, retryCount = 0){
  107. if (loadingComponents > 0 && retryCount < 5){
  108. setTimeout(function(){
  109. waitInit(callback, retryCount++);
  110. }, 300);
  111. }else if (loadingComponents == 0){
  112. callback();
  113. }else{
  114. alert("Missing component. Please check if your installation is complete.")
  115. }
  116. }
  117. initTabs(function(){
  118. initRPStaste();
  119. if (window.location.hash.length > 1){
  120. let tabID = window.location.hash.substr(1);
  121. openTabById(tabID);
  122. }else{
  123. openTabById("status");
  124. }
  125. $(".ui.dropdown").dropdown();
  126. $(".ui.checkbox").checkbox();
  127. //Click on the current tab
  128. $("#mainmenu").find(".item").each(function(){
  129. $(this).on("click", function(event){
  130. let tabid = $(this).attr("tag");
  131. openTabById(tabid);
  132. });
  133. });
  134. });
  135. function getTabButtonById(targetTabId){
  136. let targetTabBtn = undefined;
  137. $("#mainmenu").find(".item").each(function(){
  138. let tabid = $(this).attr("tag");
  139. if (tabid == targetTabId){
  140. targetTabBtn = $(this);
  141. }
  142. });
  143. return targetTabBtn;
  144. }
  145. //Select and open a tab by its tag id
  146. function openTabById(tabID){
  147. let targetBtn = getTabButtonById(tabID);
  148. if (targetBtn == undefined){
  149. alert("Invalid tabid given");
  150. return;
  151. }
  152. $("#mainmenu").find(".item").removeClass("active");
  153. $(targetBtn).addClass("active");
  154. $(".functiontab").hide();
  155. $("#" + tabID).fadeIn('fast');
  156. $('html,body').animate({scrollTop: 0}, 'fast');
  157. window.location.hash = tabID;
  158. }
  159. //Generic functions
  160. function deleteEndpoint(ptype, epoint){
  161. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  162. $.ajax({
  163. url: "./del",
  164. data: {ep: epoint, ptype: ptype},
  165. success: function(){
  166. listVdirs();
  167. listSubd();
  168. }
  169. })
  170. }
  171. }
  172. function setProxyRoot(){
  173. var newpr = $("#proxyRoot").val();
  174. if (newpr.trim() == ""){
  175. $("#proxyRoot").parent().addClass('error');
  176. return
  177. }else{
  178. $("#proxyRoot").parent().removeClass('error');
  179. }
  180. var rootReqTls = $("#rootReqTLS")[0].checked;
  181. //Create the endpoint by calling add
  182. $.ajax({
  183. url: "./add",
  184. data: {"type": "root", tls: rootReqTls, ep: newpr},
  185. success: function(data){
  186. if (data.error != undefined){
  187. alert(data.error);
  188. }else{
  189. //OK
  190. initRootInfo();
  191. $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
  192. }
  193. }
  194. });
  195. }
  196. //Show error message
  197. function errmsg(message){
  198. $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
  199. $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
  200. }
  201. </script>
  202. </body>
  203. </html>