index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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: 750px) {
  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="blue info circle icon"></i>Status
  79. </a>
  80. <a class="item" tag="vdir">
  81. <i class="yellow folder icon"></i> Virtual Directory
  82. </a>
  83. <a class="item" tag="subd">
  84. <i class="teal sitemap icon"></i> Subdomain Proxy
  85. </a>
  86. <a class="item" tag="rules">
  87. <i class="brown 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="orange lock icon"></i> TLS / SSL certificate
  95. </a>
  96. <a class="item" tag="redirectset">
  97. <i class="violet level up alternate icon"></i> Redirection
  98. </a>
  99. <a class="item" tag="blacklist">
  100. <i class="red ban icon"></i> Blacklist
  101. </a>
  102. <div class="ui divider"></div>
  103. <a class="item" tag="utils">
  104. <i class="grey paperclip icon"></i> Utilities
  105. </a>
  106. <!-- Add more components here -->
  107. </div>
  108. </div>
  109. <div class="contentWindow">
  110. <!-- Status Tab -->
  111. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  112. <br><br><div class="ui active centered inline loader"></div>
  113. </div>
  114. <!-- Virtual Directory Tab -->
  115. <div id="vdir" class="functiontab" target="vdir.html"></div>
  116. <!-- Subdomain Proxy -->
  117. <div id="subd" class="functiontab" target="subd.html"></div>
  118. <!-- Create Rules -->
  119. <div id="rules" class="functiontab" target="rules.html"></div>
  120. <!-- Set proxy root -->
  121. <div id="setroot" class="functiontab" target="rproot.html"></div>
  122. <!-- Set TLS cert -->
  123. <div id="cert" class="functiontab" target="cert.html"></div>
  124. <!-- Redirections -->
  125. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  126. <!-- Blacklist -->
  127. <div id="blacklist" class="functiontab" target="blacklist.html"></div>
  128. <!-- Utilities -->
  129. <div id="utils" class="functiontab" target="utils.html"></div>
  130. </div>
  131. </div>
  132. </div>
  133. <br><br>
  134. <div class="ui divider"></div>
  135. <div class="ui container" style="color: grey; font-size: 90%">
  136. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  137. </div>
  138. <br><br>
  139. <script>
  140. $(".year").text(new Date().getFullYear());
  141. /*
  142. Loader function
  143. Load all the components view from the
  144. components/ directory into their corrisponding divs
  145. */
  146. let loadingComponents = 0;
  147. function initTabs(callback=undefined){
  148. $('.functiontab').each(function(){
  149. let loadTarget = $(this).attr("target");
  150. if (loadTarget != undefined){
  151. $(this).load("./components/" + loadTarget, function(){
  152. loadingComponents--;
  153. });
  154. loadingComponents++;
  155. }else{
  156. $(this).html(`<p>Unable to load components for this tab</p>`);
  157. }
  158. })
  159. if (callback != undefined){
  160. waitInit(callback);
  161. }
  162. }
  163. function waitInit(callback = undefined, retryCount = 0){
  164. if (loadingComponents > 0 && retryCount < 5){
  165. setTimeout(function(){
  166. waitInit(callback, retryCount++);
  167. }, 300);
  168. }else if (loadingComponents == 0){
  169. callback();
  170. }else{
  171. alert("Missing component. Please check if your installation is complete.")
  172. }
  173. }
  174. initTabs(function(){
  175. initRPStaste();
  176. if (window.location.hash.length > 1){
  177. let tabID = window.location.hash.substr(1);
  178. openTabById(tabID);
  179. }else{
  180. openTabById("status");
  181. }
  182. $(".ui.dropdown").dropdown();
  183. $(".ui.checkbox").checkbox();
  184. //Click on the current tab
  185. $("#mainmenu").find(".item").each(function(){
  186. $(this).on("click", function(event){
  187. let tabid = $(this).attr("tag");
  188. openTabById(tabid);
  189. });
  190. });
  191. //Initialize all table that is sortable
  192. $('table').tablesort();
  193. });
  194. function logout() {
  195. $.get("/api/auth/logout", function(response) {
  196. if (response === "OK") {
  197. window.location.href = "/";
  198. }
  199. });
  200. }
  201. function getTabButtonById(targetTabId){
  202. let targetTabBtn = undefined;
  203. $("#mainmenu").find(".item").each(function(){
  204. let tabid = $(this).attr("tag");
  205. if (tabid == targetTabId){
  206. targetTabBtn = $(this);
  207. }
  208. });
  209. return targetTabBtn;
  210. }
  211. //Select and open a tab by its tag id
  212. function openTabById(tabID){
  213. let targetBtn = getTabButtonById(tabID);
  214. if (targetBtn == undefined){
  215. alert("Invalid tabid given");
  216. return;
  217. }
  218. $("#mainmenu").find(".item").removeClass("active");
  219. $(targetBtn).addClass("active");
  220. $(".functiontab").hide();
  221. $("#" + tabID).fadeIn('fast');
  222. $('html,body').animate({scrollTop: 0}, 'fast');
  223. window.location.hash = tabID;
  224. }
  225. //Generic functions
  226. function deleteEndpoint(ptype, epoint){
  227. if (confirm("Confirm remove proxy for :" + epoint + " (type: " + ptype + ")?")){
  228. $.ajax({
  229. url: "./del",
  230. data: {ep: epoint, ptype: ptype},
  231. success: function(){
  232. listVdirs();
  233. listSubd();
  234. }
  235. })
  236. }
  237. }
  238. function setProxyRoot(){
  239. var newpr = $("#proxyRoot").val();
  240. if (newpr.trim() == ""){
  241. $("#proxyRoot").parent().addClass('error');
  242. return
  243. }else{
  244. $("#proxyRoot").parent().removeClass('error');
  245. }
  246. var rootReqTls = $("#rootReqTLS")[0].checked;
  247. //Create the endpoint by calling add
  248. $.ajax({
  249. url: "./add",
  250. data: {"type": "root", tls: rootReqTls, ep: newpr},
  251. success: function(data){
  252. if (data.error != undefined){
  253. alert(data.error);
  254. }else{
  255. //OK
  256. initRootInfo();
  257. $("#ProxyRootUpdate").stop().slideDown('fast').delay(3000).slideUp('fast');
  258. }
  259. }
  260. });
  261. }
  262. //Show error message
  263. function errmsg(message){
  264. $("#errmsg").html(`<i class="red remove icon"></i> ${message}`);
  265. $("#errmsg").slideDown('fast').delay(5000).slideUp('fast');
  266. }
  267. </script>
  268. </body>
  269. </html>