bootflags.html 8.8 KB

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