bootflags.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <html>
  2. <head>
  3. <title>Runtime Adjustment</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  7. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  8. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  10. <style>
  11. </style>
  12. </head>
  13. <body>
  14. <div class="ui container">
  15. <div class="ui basic segment">
  16. <h3 class="ui header">
  17. <i class="play icon"></i>
  18. <div class="content">
  19. Runtime Adjustment
  20. <div class="sub header">Update system startup parameters in runtime</div>
  21. </div>
  22. </h3>
  23. <div class="ui divider"></div>
  24. <form id="setupform" class="ui form" onsubmit="handleFormSubmit(event, this);">
  25. <div class="field">
  26. <label>Host Name</label>
  27. <input class="config" type="text" name="Hostname" placeholder="My ArOZ">
  28. </div>
  29. <div class="field">
  30. <label>Max Upload Size (MB)</label>
  31. <input class="config" type="number" name="MaxUploadSize" placeholder="8192">
  32. </div>
  33. <div class="field">
  34. <label>File Upload Buffer (MB)</label>
  35. <input class="config" type="number" name="MaxFileUploadBuff" placeholder="25">
  36. </div>
  37. <div class="field">
  38. <label>File IO Buffer (Bytes, Defailt 1024)</label>
  39. <input class="config" type="number" name="FileIOBuffer" placeholder="1024">
  40. </div>
  41. <div class="field">
  42. <div class="ui toggle checkbox">
  43. <input class="config" type="checkbox" name="DisableIPResolver" tabindex="0">
  44. <label>Disable IP Resolver</label>
  45. <small>Not trying to analysis Client IP address, useful when the server is host under NAT or Reverse Proxy</small>
  46. </div>
  47. </div>
  48. <div class="field">
  49. <div class="ui toggle checkbox">
  50. <input class="config" type="checkbox" name="EnableHomePage" tabindex="0">
  51. <label>Enable Home Page</label>
  52. <small>Allowing users to host their own static webpages</small>
  53. </div>
  54. </div>
  55. <div class="field">
  56. <div class="ui toggle checkbox">
  57. <input class="config" type="checkbox" name="EnableDirListing" tabindex="0">
  58. <label>Enable Directory Listing</label>
  59. <small>Allow listing the contents of a directory if the request URL is a folder</small>
  60. </div>
  61. </div>
  62. <div class="ui divider"></div>
  63. <p>To continue updating your boot configuration, please confirm that: </p>
  64. <div class="field">
  65. <div class="ui checkbox">
  66. <input type="checkbox" tabindex="0" onchange="toggleConfirmBtn(this.checked)">
  67. <label>I know exactly what I am doing</label>
  68. <small>These changes are only applied to current runtime session. If something messed up, you can restart your system for restoring to default value. </small>
  69. </div>
  70. </div>
  71. <button id="confirmbtn" class="ui red disabled button" type="submit">Write to Runtime</button>
  72. </form>
  73. <div class="ui red message" style="display:none;" id="failedmsg">
  74. <div class="header">
  75. <i class="remove icon"></i> Flags Update Failed
  76. </div>
  77. <ul class="list">
  78. <p id="errmsg">Your settings were not applied due to unknown error.</p>
  79. </ul>
  80. </div>
  81. <div id="succmsg" class="ui green message transition" style="display:none;">
  82. <div class="header">
  83. <i class="checkmark icon"></i> Startup paramter Updated
  84. </div>
  85. <ul class="list">
  86. <p>These settings will only be available in current runtime session. Restart your server to restore original settings.</p>
  87. </ul>
  88. </div>
  89. </div>
  90. <br><br>
  91. </div>
  92. <script>
  93. function handleFormSubmit(event, obj){
  94. event.preventDefault();
  95. var result = {};
  96. $(obj).find(".config").each(function(){
  97. var name = $(this).attr("name");
  98. var value = $(this).val();
  99. if ($(this).attr('type') == "checkbox"){
  100. value = $(this)[0].checked
  101. }else if ($(this).attr('type') == "number"){
  102. value = parseInt(value);
  103. }
  104. result[name] = value;
  105. });
  106. //Send the results back to the backend
  107. console.log(result);
  108. $.ajax({
  109. url: "../../system/bootflags",
  110. data: {opr: "set", value: JSON.stringify(result)},
  111. method: "POST",
  112. success: function(data){
  113. if (data.error != undefined){
  114. $("#errmsg").text(data.error);
  115. $("#failedmsg").slideDown("fast").delay(10000).slideUp('fast');
  116. }else{
  117. $("#succmsg").slideDown("fast").delay(3000).slideUp('fast');
  118. }
  119. //Update the list again
  120. initCurrentSettingList();
  121. }
  122. })
  123. }
  124. initCurrentSettingList();
  125. function initCurrentSettingList(){
  126. $.get("../../system/bootflags", function(data){
  127. if (data.errpr !== undefined){
  128. $("#errmsg").text(data.error);
  129. $("#failedmsg").slideDown("fast").delay(10000).slideUp('fast');
  130. }else{
  131. //Load the data
  132. for (var [key, value] of Object.entries(data)) {
  133. var targetInputField = $(`[name ='${key}']`);
  134. if (targetInputField.attr("type") == "text"){
  135. targetInputField.val(value);
  136. }else if (targetInputField.attr("type") == "checkbox"){
  137. targetInputField[0].checked = value;
  138. }else if (targetInputField.attr("type") == "number"){
  139. targetInputField.val(value);
  140. }
  141. }
  142. }
  143. });
  144. }
  145. function toggleConfirmBtn(value){
  146. if (value == true){
  147. $("#confirmbtn").removeClass("disabled");
  148. }else{
  149. $("#confirmbtn").addClass("disabled");
  150. }
  151. }
  152. </script>
  153. </body>
  154. </html>