index.html 9.0 KB

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