index.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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="stylesheet" href="../script/semantic/semantic.min.css">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <script src="../script/semantic/semantic.min.js"></script>
  12. <title>ArSamba Settings</title>
  13. <style>
  14. body{
  15. background-color:white;
  16. }
  17. .success{
  18. color: #20c942;
  19. }
  20. .failed{
  21. color: #eb4034;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <br>
  27. <div class="ui text container">
  28. <div class="ui header">
  29. <i class="windows icon"></i>
  30. <div class="content">
  31. Samba Settings
  32. <div class="sub header">for arozos systems</div>
  33. </div>
  34. </div>
  35. <p>Account Status: <span id="acstatus" class="failed">Disabled</span></p>
  36. <div id="enableAccount">
  37. <h3>Enable My Samba Account</h3>
  38. <form class="ui form" onsubmit="createAccount(event);">
  39. <div class="fluid field">
  40. <label>Username (Read Only)</label>
  41. <input type="text" id="username" readonly="true">
  42. </div>
  43. <div class="field">
  44. <label>Password</label>
  45. <input type="password" id="pw">
  46. </div>
  47. <div class="field">
  48. <label>Confirm Password</label>
  49. <input type="password" id="rpw">
  50. </div>
  51. <button id="createbtn" class="ui green button" type="submit">Create</button>
  52. </form>
  53. </div>
  54. <div id="disableAccount" style="display:none;">
  55. <h3>Disable My Samba Account</h3>
  56. <p>This operation will remove your samba user account from the system</p>
  57. <button class="ui red button" onclick="removeUser(event)">Disable</button>
  58. </div>
  59. <div id="notSupported" style="display: none;">
  60. <br>
  61. <div class="ui header">
  62. <i class="red remove icon"></i>
  63. <div class="content">
  64. Platform Not Supported
  65. <div class="sub header">Are you using Windows?</div>
  66. </div>
  67. </div>
  68. <p>This setting interface is disabled automatically on not supported platforms.</p>
  69. </div>
  70. <br>
  71. <p>To access yor samba server, use <code id="sambaip"></code> in Windows' File Explorer</p>
  72. <br><br>
  73. <script>
  74. //Do not allow window resize
  75. ao_module_setFixedWindowSize();
  76. //Display the connect info
  77. $("#sambaip").text(`\\\\` + window.location.hostname);
  78. //Get username from system
  79. $.get("../system/users/userinfo", function(data){
  80. var username = data.Username;
  81. $("#username").val(username);
  82. //Get the account status
  83. $.get("./getStatus?username=" + username, function(data){
  84. if (data.error !== undefined){
  85. //Not supported platforms
  86. $("#enableAccount").hide();
  87. $("#disableAccount").hide();
  88. $("#notSupported").show();
  89. }else{
  90. if (data == true){
  91. $("#acstatus").text("Enabled");
  92. $("#acstatus").attr("class","success");
  93. $("#enableAccount").hide();
  94. $("#disableAccount").show();
  95. } else{
  96. $("#acstatus").text("Disabled");
  97. $("#acstatus").attr("class","failed");
  98. $("#enableAccount").show();
  99. $("#disableAccount").hide();
  100. }
  101. }
  102. });
  103. });
  104. function removeUser(e){
  105. //Process the user creation process
  106. $.get("../system/users/userinfo", function(data){
  107. //Get the username
  108. var username = data.Username;
  109. $.ajax({
  110. url: "./remove",
  111. method: "POST",
  112. data: {username: username},
  113. success: function(data){
  114. //Creation succeed. Reload this page
  115. window.location.reload();
  116. }
  117. });
  118. });
  119. }
  120. function createAccount(e){
  121. e.preventDefault();
  122. //Get the userinfo again in case the user has changed name during the setting period
  123. $.get("../system/users/userinfo", function(data){
  124. //Get the username
  125. var username = data.Username;
  126. //Check if the password match
  127. var pw = $("#pw").val();
  128. var rpw = $("#rpw").val();
  129. if (pw == "" || rpw == ""){
  130. alert("Password cannot be empty")
  131. return
  132. }
  133. if (pw != rpw){
  134. //Password not match
  135. $("#rpw").parent().addClass("error");
  136. return
  137. }else{
  138. $("#rpw").parent().removeClass("error");
  139. }
  140. //Process the user creation process
  141. $("#createbtn").addClass("loading");
  142. $.ajax({
  143. url: "./create",
  144. method: "POST",
  145. data: {username: username, password: pw},
  146. success: function(data){
  147. //Creation succeed. Reload this page
  148. $("#createbtn").removeClass("loading");
  149. window.location.reload();
  150. }
  151. });
  152. });
  153. }
  154. </script>
  155. </body>
  156. </html>