index.html 9.1 KB

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