index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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>Control Panel | 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. <style>
  16. body{
  17. background-color:white;
  18. }
  19. .functiontab{
  20. display:none;
  21. }
  22. .menubar{
  23. width: 100%;
  24. padding: 0.4em;
  25. padding-left: 1.2em;
  26. padding-right: 1.2em;
  27. background-color: #f5f5f5;
  28. margin-bottom: 1em;
  29. }
  30. .menubar .logo{
  31. height: 36px;
  32. }
  33. .menubar .item{
  34. display: inline-block;
  35. vertical-align: middle;
  36. }
  37. .wrapper{
  38. display: flex;
  39. flex-wrap: wrap;
  40. }
  41. .toolbar{
  42. width: 240px;
  43. }
  44. .contentWindow{
  45. padding: 1em;
  46. flex: 1;
  47. }
  48. @media screen and (max-width: 530px) {
  49. .toolbar {
  50. display: inline-block;
  51. width: 100%;
  52. margin-bottom: 1em;
  53. }
  54. #mainmenu{
  55. width: calc(100% - 1em);
  56. }
  57. .contentWindow{
  58. display: inline-block;
  59. width: 100%;
  60. }
  61. }
  62. </style>
  63. </head>
  64. <body>
  65. <div class="menubar">
  66. <div class="item">
  67. <img class="logo" src="img/logo.svg">
  68. </div>
  69. <div class="ui right floated buttons" style="padding-top: 2px;">
  70. <button class="ui basic icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  71. </div>
  72. </div>
  73. <div id="errmsg" class="ui red message" style="display: none;"></div>
  74. <div class="wrapper">
  75. <div class="toolbar">
  76. <div id="mainmenu" class="ui secondary vertical pointing menu">
  77. <a class="item active" tag="status">
  78. <i class="info circle icon"></i>Status
  79. </a>
  80. <a class="item" tag="vdir">
  81. <i class="folder icon"></i> Virtual Directory
  82. </a>
  83. <a class="item" tag="subd">
  84. <i class="sitemap icon"></i> Subdomain Proxy
  85. </a>
  86. <a class="item" tag="rules">
  87. <i class="plus square icon"></i> Create Proxy Rules
  88. </a>
  89. <a class="item" tag="setroot">
  90. <i class="home icon"></i> Set Proxy Root
  91. </a>
  92. <div class="ui divider"></div>
  93. <a class="item" tag="cert">
  94. <i class="lock icon"></i> TLS / SSL certificate
  95. </a>
  96. <a class="item" tag="redirectset">
  97. <i class="level up alternate icon"></i> Redirection
  98. </a>
  99. <a class="item" tag="blacklist">
  100. <i class="ban icon"></i> Blacklist
  101. </a>
  102. <!-- Add more components here -->
  103. </div>
  104. </div>
  105. <div class="contentWindow">
  106. <!-- Status Tab -->
  107. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  108. <br><br><div class="ui active centered inline loader"></div>
  109. </div>
  110. <!-- Virtual Directory Tab -->
  111. <div id="vdir" class="functiontab" target="vdir.html"></div>
  112. <!-- Subdomain Proxy -->
  113. <div id="subd" class="functiontab" target="subd.html"></div>
  114. <!-- Create Rules -->
  115. <div id="rules" class="functiontab" target="rules.html"></div>
  116. <!-- Set proxy root -->
  117. <div id="setroot" class="functiontab" target="rproot.html"></div>
  118. <!-- Set TLS cert -->
  119. <div id="cert" class="functiontab" target="cert.html"></div>
  120. <!-- Redirections -->
  121. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  122. <!-- Blacklist -->
  123. <div id="blacklist" class="functiontab" target="blacklist.html"></div>
  124. </div>
  125. </div>
  126. </div>
  127. <br><br>
  128. <div class="ui divider"></div>
  129. <div class="ui container" style="color: grey; font-size: 90%">
  130. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  131. </div>
  132. <br><br>
  133. <script>
  134. $(".year").text(new Date().getFullYear());
  135. /*
  136. Loader function
  137. Load all the components view from the
  138. components/ directory into their corrisponding divs
  139. */
  140. let loadingComponents = 0;
  141. function initTabs(callback=undefined){
  142. $('.functiontab').each(function(){
  143. let loadTarget = $(this).attr("target");
  144. if (loadTarget != undefined){
  145. $(this).load("./components/" + loadTarget, function(){
  146. loadingComponents--;
  147. });
  148. loadingComponents++;
  149. }else{
  150. $(this).html(`<p>Unable to load components for this tab</p>`);
  151. }
  152. })
  153. if (callback != undefined){
  154. waitInit(callback);
  155. }
  156. }
  157. function waitInit(callback = undefined, retryCount = 0){
  158. if (loadingComponents > 0 && retryCount < 5){
  159. setTimeout(function(){
  160. waitInit(callback, retryCount++);
  161. }, 300);
  162. }else if (loadingComponents == 0){
  163. callback();
  164. }else{
  165. alert("Missing component. Please check if your installation is complete.")
  166. }
  167. }
  168. initTabs(function(){
  169. initRPStaste();
  170. if (window.location.hash.length > 1){
  171. let tabID = window.location.hash.substr(1);
  172. openTabById(tabID);
  173. }else{
  174. openTabById("status");
  175. }
  176. $(".ui.dropdown").dropdown();
  177. $(".ui.checkbox").checkbox();
  178. //Click on the current tab
  179. $("#mainmenu").find(".item").each(function(){
  180. $(this).on("click", function(event){
  181. let tabid = $(this).attr("tag");
  182. openTabById(tabid);
  183. });
  184. });
  185. //Initialize all table that is sortable
  186. $('table').tablesort();
  187. });
  188. function logout() {
  189. $.get("/api/auth/logout", function(response) {
  190. if (response === "OK") {
  191. window.location.href = "/";
  192. }
  193. });
  194. }
  195. function getTabButtonById(targetTabId){
  196. let targetTabBtn = undefined;
  197. $("#mainmenu").find(".item").each(function(){
  198. let tabid = $(this).attr("tag");
  199. if (tabid == targetTabId){
  200. targetTabBtn = $(this);
  201. }
  202. });
  203. return targetTabBtn;
  204. }
  205. //Select and open a tab by its tag id
  206. function openTabById(tabID){
  207. let targetBtn = getTabButtonById(tabID);
  208. if (targetBtn == undefined){
  209. alert("Invalid tabid given");
  210. return;
  211. }
  212. $("#mainmenu").find(".item").removeClass("active");
  213. $(targetBtn).addClass("active");
  214. $(".functiontab").hide();
  215. $("#" + tabID).fadeIn('fast');
  216. $('html,body').animate({scrollTop: 0}, 'fast');
  217. window.location.hash = tabID;
  218. }
  219. //Generic functions
  220. function deleteEndpoint(ptype, epoint){
  221. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  222. $.ajax({
  223. url: "./del",
  224. data: {ep: epoint, ptype: ptype},
  225. success: function(){
  226. listVdirs();
  227. listSubd();
  228. }
  229. })
  230. }
  231. }
  232. function setProxyRoot(){
  233. var newpr = $("#proxyRoot").val();
  234. if (newpr.trim() == ""){
  235. $("#proxyRoot").parent().addClass('error');
  236. return
  237. }else{
  238. $("#proxyRoot").parent().removeClass('error');
  239. }
  240. var rootReqTls = $("#rootReqTLS")[0].checked;
  241. //Create the endpoint by calling add
  242. $.ajax({
  243. url: "./add",
  244. data: {"type": "root", tls: rootReqTls, ep: newpr},
  245. success: function(data){
  246. if (data.error != undefined){
  247. alert(data.error);
  248. }else{
  249. //OK
  250. initRootInfo();
  251. $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
  252. }
  253. }
  254. });
  255. }
  256. //Show error message
  257. function errmsg(message){
  258. $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
  259. $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
  260. }
  261. </script>
  262. </body>
  263. </html>