index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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/semantic/semantic.min.js"></script>
  13. <script src="script/tablesort.js"></script>
  14. <script src="script/countryCode.js"></script>
  15. <script src="script/chart.js"></script>
  16. <script src="script/utils.js"></script>
  17. <link rel="stylesheet" href="main.css">
  18. </head>
  19. <body>
  20. <div class="menubar">
  21. <div class="item">
  22. <img class="logo" src="img/logo.svg">
  23. </div>
  24. <div class="ui right floated buttons menutoggle" style="padding-top: 2px;">
  25. <button class="ui basic icon button" onclick="$('.toolbar').fadeToggle('fast');"><i class="content icon"></i></button>
  26. </div>
  27. <div class="ui right floated buttons" style="padding-top: 2px; padding-right: 0.4em;">
  28. <button class="ui basic white icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  29. </div>
  30. <!-- <div class="ui right floated buttons" style="padding-top: 2px;">
  31. <button id="themeColorButton" class="ui icon button" onclick="toggleTheme();"><i class="sun icon"></i></button>
  32. </div> -->
  33. </div>
  34. <div class="wrapper">
  35. <div class="toolbar">
  36. <div id="mainmenu" class="ui secondary vertical menu">
  37. <a class="item active" tag="status">
  38. <i class="simplistic info circle icon"></i>Status
  39. </a>
  40. <a class="item" tag="setroot">
  41. <i class="simplistic home icon"></i> Default Site
  42. </a>
  43. <div class="ui divider menudivider">Reverse Proxy</div>
  44. <a class="item" tag="httprp">
  45. <i class="simplistic sitemap icon"></i> HTTP Proxy
  46. </a>
  47. <a class="item" tag="vdir">
  48. <i class="simplistic folder icon"></i> Virtual Directory
  49. </a>
  50. <a class="item" tag="rules">
  51. <i class="simplistic plus square icon"></i> Create Proxy Rules
  52. </a>
  53. <a class="item" tag="streamproxy">
  54. <i class="simplistic exchange icon"></i> Stream Proxy
  55. </a>
  56. <div class="ui divider menudivider">Access & Connections</div>
  57. <a class="item" tag="redirectset">
  58. <i class="simplistic level up alternate icon"></i> Redirection
  59. </a>
  60. <a class="item" tag="access">
  61. <i class="simplistic ban icon"></i> Access Control
  62. </a>
  63. <a class="item" tag="gan">
  64. <i class="simplistic globe icon"></i> Global Area Network
  65. </a>
  66. <div class="ui divider menudivider">Security</div>
  67. <a class="item" tag="cert">
  68. <i class="simplistic lock icon"></i> TLS / SSL certificates
  69. </a>
  70. <a class="item" tag="sso">
  71. <i class="simplistic user circle icon"></i> SSO / Oauth
  72. </a>
  73. <div class="ui divider menudivider">Others</div>
  74. <a class="item" tag="webserv">
  75. <i class="simplistic globe icon"></i> Static Web Server
  76. </a>
  77. <a class="item" tag="utm">
  78. <i class="simplistic time icon"></i> Uptime Monitor
  79. </a>
  80. <a class="item" tag="networktool">
  81. <i class="simplistic terminal icon"></i> Network Tools
  82. </a>
  83. <a class="item" tag="stats">
  84. <i class="simplistic database icon"></i> Statistical Analysis
  85. </a>
  86. <a class="item" tag="utils">
  87. <i class="simplistic paperclip icon"></i> Utilities
  88. </a>
  89. <!-- Add more components here -->
  90. </div>
  91. </div>
  92. <div class="contentWindow">
  93. <!-- Status Tab -->
  94. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  95. <br><br><div class="ui active centered inline loader"></div>
  96. </div>
  97. <!-- Virtual Directory Tab -->
  98. <div id="vdir" class="functiontab" target="vdir.html"></div>
  99. <!-- Subdomain Proxy -->
  100. <div id="httprp" class="functiontab" target="httprp.html"></div>
  101. <!-- Create Rules -->
  102. <div id="rules" class="functiontab" target="rules.html"></div>
  103. <!-- Set proxy root -->
  104. <div id="setroot" class="functiontab" target="rproot.html"></div>
  105. <!-- Set TLS cert -->
  106. <div id="cert" class="functiontab" target="cert.html"></div>
  107. <!-- Redirections -->
  108. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  109. <!-- Blacklist -->
  110. <div id="access" class="functiontab" target="access.html"></div>
  111. <!-- Global Area Networking -->
  112. <div id="gan" class="functiontab" target="gan.html"></div>
  113. <!-- SSO / Oauth services -->
  114. <div id="sso" class="functiontab" target="sso.html"></div>
  115. <!-- TCP Proxy -->
  116. <div id="streamproxy" class="functiontab" target="streamprox.html"></div>
  117. <!-- Web Server -->
  118. <div id="webserv" class="functiontab" target="webserv.html"></div>
  119. <!-- Up Time Monitor -->
  120. <div id="utm" class="functiontab" target="uptime.html"></div>
  121. <!-- Network Tools -->
  122. <div id="networktool" class="functiontab" target="networktools.html"></div>
  123. <!-- Statistic Tools -->
  124. <div id="stats" class="functiontab" target="stats.html"></div>
  125. <!-- Utilities -->
  126. <div id="utils" class="functiontab" target="utils.html"></div>
  127. </div>
  128. </div>
  129. </div>
  130. <div class="sideWrapper" style="display:none;">
  131. <div class="fadingBackground" onclick="hideSideWrapper();"></div>
  132. <div class="content">
  133. <div class="sideWrapperMenu"></div>
  134. <iframe src="snippet/placeholder.html"></iframe>
  135. </div>
  136. </div>
  137. <br><br>
  138. <div class="ui divider"></div>
  139. <div class="ui container" style="color: grey; font-size: 90%">
  140. <p><a href="https://zoraxy.arozos.com" target="_blank">Zoraxy</a> <span class="zrversion"></span> © 2021 - <span class="year"></span> tobychui. Licensed under AGPL</p>
  141. </div>
  142. <div id="messageBox" class="ui green floating big compact message">
  143. <p><i class="green check circle icon"></i> There are no messages</p>
  144. </div>
  145. <div id="confirmBox" style="display:none;">
  146. <div class="ui top attached progress">
  147. <div class="bar" style="width: 100%; min-width: 0px;"></div>
  148. </div>
  149. <div class="confirmBoxBody">
  150. <button class="ui red basic mini circular icon right floated button" style="margin-left: 0.4em;"><i class="ui times icon"></i></button>
  151. <button class="ui green basic mini circular icon right floated button"><i class="ui check icon"></i></button>
  152. <div class="questionToConfirm">Confirm Exit?</div>
  153. </div>
  154. </div>
  155. <br><br>
  156. <script>
  157. $(".year").text(new Date().getFullYear());
  158. /*
  159. Loader function
  160. Load all the components view from the
  161. components/ directory into their corrisponding divs
  162. */
  163. let loadingComponents = 0;
  164. function initTabs(callback=undefined){
  165. $('.functiontab').each(function(){
  166. let loadTarget = $(this).attr("target");
  167. if (loadTarget != undefined){
  168. $(this).load("./components/" + loadTarget, function(){
  169. loadingComponents--;
  170. });
  171. loadingComponents++;
  172. }else{
  173. $(this).html(`<p>Unable to load components for this tab</p>`);
  174. }
  175. })
  176. if (callback != undefined){
  177. waitInit(callback);
  178. }
  179. }
  180. function waitInit(callback = undefined, retryCount = 0){
  181. if (loadingComponents > 0 && retryCount < 5){
  182. setTimeout(function(){
  183. waitInit(callback, retryCount++);
  184. }, 300);
  185. }else if (loadingComponents == 0){
  186. callback();
  187. }else{
  188. alert("Missing component. Please check if your installation is complete.")
  189. }
  190. }
  191. initTabs(function(){
  192. initRPStaste();
  193. if (window.location.hash.length > 1){
  194. let tabID = window.location.hash.substr(1);
  195. openTabById(tabID);
  196. }else{
  197. openTabById("status");
  198. }
  199. $(".ui.dropdown").dropdown();
  200. $(".ui.checkbox").checkbox();
  201. //Click on the current tab
  202. $("#mainmenu").find(".item").each(function(){
  203. $(this).on("click", function(event){
  204. let tabid = $(this).attr("tag");
  205. openTabById(tabid);
  206. });
  207. });
  208. //Initialize all table that is sortable
  209. $('table').tablesort();
  210. });
  211. function logout() {
  212. $.get("/api/auth/logout", function(response) {
  213. if (response === "OK") {
  214. setTimeout(function(){
  215. window.location.href = "/login.html";
  216. }, 300);
  217. }
  218. });
  219. }
  220. function toggleTheme(){
  221. if ($("body").hasClass("darkTheme")){
  222. $("body").removeClass("darkTheme")
  223. $("#themeColorButton").html(`<i class="ui moon icon"></i>`);
  224. }else{
  225. $("body").addClass("darkTheme");
  226. $("#themeColorButton").html(`<i class="ui sun icon"></i>`);
  227. }
  228. }
  229. function getTabButtonById(targetTabId){
  230. let targetTabBtn = undefined;
  231. $("#mainmenu").find(".item").each(function(){
  232. let tabid = $(this).attr("tag");
  233. if (tabid == targetTabId){
  234. targetTabBtn = $(this);
  235. }
  236. });
  237. return targetTabBtn;
  238. }
  239. //Select and open a tab by its tag id
  240. let tabSwitchEventBind = {}; //Bind event to tab switch by tabid
  241. function openTabById(tabID){
  242. let targetBtn = getTabButtonById(tabID);
  243. if (targetBtn == undefined){
  244. alert("Invalid tabid given");
  245. return;
  246. }
  247. if (window.innerWidth < 750){
  248. //RWD mode, hide toolbar
  249. $(".toolbar").fadeOut('fast');
  250. }
  251. $("#mainmenu").find(".item").removeClass("active");
  252. $(targetBtn).addClass("active");
  253. $(".functiontab").hide();
  254. $("#" + tabID).fadeIn('fast', function(){
  255. setTimeout(function(){
  256. if (tabSwitchEventBind[tabID]){
  257. tabSwitchEventBind[tabID]();
  258. }
  259. },100)
  260. });
  261. $('html,body').animate({scrollTop: 0}, 'fast');
  262. window.location.hash = tabID;
  263. }
  264. $(window).on("resize", function(){
  265. if (window.innerWidth >= 750 && $(".toolbar").is(":visible") == false){
  266. $(".toolbar").show();
  267. }
  268. });
  269. function msgbox(message, succ=true, delayDuration=3000){
  270. let icon = `<i class="ui info circle icon"></i>`;
  271. if (succ){
  272. $("#messageBox").attr("class", "ui green floating compact message")
  273. icon = `<i class="ui green circle check icon"></i>`;
  274. }else{
  275. message = message.capitalize();
  276. $("#messageBox").attr("class", "ui red floating compact message")
  277. icon = `<i class="ui red circle times icon"></i>`;
  278. }
  279. $("#messageBox").html(`${icon} ${message}`);
  280. $("#messageBox").stop().finish().fadeIn("fast").delay(delayDuration).fadeOut("fast");
  281. }
  282. function confirmBox(question_to_confirm, callback, delaytime=15) {
  283. var progressBar = $("#confirmBox .bar");
  284. var questionElement = $("#confirmBox .questionToConfirm");
  285. //Just to make sure there are no animation runnings
  286. progressBar.stop();
  287. // Update the question to confirm
  288. questionElement.text(question_to_confirm);
  289. // Start the progress bar animation
  290. progressBar.css("width", "100%");
  291. progressBar.animate({ width: "0%", easing: "linear" }, delaytime * 1000, function() {
  292. // Animation complete, invoke the callback with undefined
  293. callback(undefined);
  294. //Unset the event listener
  295. $("#confirmBox .ui.green.button").off("click");
  296. // Hide the confirm box
  297. $("#confirmBox").hide();
  298. });
  299. // Bind click event to "Yes" button
  300. $("#confirmBox .ui.green.button").on("click", function() {
  301. // Stop the progress bar animation
  302. progressBar.stop();
  303. // Invoke the callback with true
  304. callback(true);
  305. // Hide the confirm box
  306. $("#confirmBox").hide();
  307. //Unset the event listener
  308. $("#confirmBox .ui.green.button").off("click");
  309. });
  310. // Bind click event to "No" button
  311. $("#confirmBox .ui.red.button").on("click", function() {
  312. // Stop the progress bar animation
  313. progressBar.stop();
  314. // Invoke the callback with false
  315. callback(false);
  316. // Hide the confirm box
  317. $("#confirmBox").hide();
  318. //Unset the event listener
  319. $("#confirmBox .ui.red.button").off("click");
  320. });
  321. // Show the confirm box
  322. $("#confirmBox").show().transition('jiggle');
  323. }
  324. /*
  325. Toggles for side wrapper
  326. */
  327. function showSideWrapper(scriptpath=""){
  328. if (scriptpath != ""){
  329. $(".sideWrapper iframe").attr("src", scriptpath);
  330. }
  331. if ($(".sideWrapper .content").transition("is animating") || $(".sideWrapper .content").transition("is visible")){
  332. return
  333. }
  334. $(".sideWrapper").show();
  335. $(".sideWrapper .fadingBackground").fadeIn("fast");
  336. $(".sideWrapper .content").transition('slide left in', 300);
  337. $("body").css("overflow", "hidden");
  338. }
  339. function hideSideWrapper(discardFrameContent = false){
  340. if (discardFrameContent){
  341. $(".sideWrapper iframe").attr("src", "snippet/placeholder.html");
  342. }
  343. if ($(".sideWrapper .content").transition("is animating") || !$(".sideWrapper .content").transition("is visible")){
  344. return
  345. }
  346. $(".sideWrapper .content").transition('slide left out', 300, function(){
  347. $(".sideWrapper .fadingBackground").fadeOut("fast", function(){
  348. $(".sideWrapper").hide();
  349. });
  350. });
  351. $("body").css("overflow", "auto");
  352. }
  353. </script>
  354. </body>
  355. </html>