bootflags.html 8.8 KB

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