index.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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><br>
  71. <script>
  72. //Do not allow window resize
  73. ao_module_setFixedWindowSize();
  74. //Get username from system
  75. $.get("../system/users/userinfo", function(data){
  76. var username = data.Username;
  77. $("#username").val(username);
  78. //Get the account status
  79. $.get("./getStatus?username=" + username, function(data){
  80. if (data.error !== undefined){
  81. //Not supported platforms
  82. $("#enableAccount").hide();
  83. $("#disableAccount").hide();
  84. $("#notSupported").show();
  85. }else{
  86. if (data == true){
  87. $("#acstatus").text("Enabled");
  88. $("#acstatus").attr("class","success");
  89. $("#enableAccount").hide();
  90. $("#disableAccount").show();
  91. } else{
  92. $("#acstatus").text("Disabled");
  93. $("#acstatus").attr("class","failed");
  94. $("#enableAccount").show();
  95. $("#disableAccount").hide();
  96. }
  97. }
  98. });
  99. });
  100. function removeUser(e){
  101. //Process the user creation process
  102. $.get("../system/users/userinfo", function(data){
  103. //Get the username
  104. var username = data.Username;
  105. $.ajax({
  106. url: "./remove",
  107. method: "POST",
  108. data: {username: username},
  109. success: function(data){
  110. //Creation succeed. Reload this page
  111. window.location.reload();
  112. }
  113. });
  114. });
  115. }
  116. function createAccount(e){
  117. e.preventDefault();
  118. //Get the userinfo again in case the user has changed name during the setting period
  119. $.get("../system/users/userinfo", function(data){
  120. //Get the username
  121. var username = data.Username;
  122. //Check if the password match
  123. var pw = $("#pw").val();
  124. var rpw = $("#rpw").val();
  125. if (pw == "" || rpw == ""){
  126. alert("Password cannot be empty")
  127. return
  128. }
  129. if (pw != rpw){
  130. //Password not match
  131. $("#rpw").parent().addClass("error");
  132. return
  133. }else{
  134. $("#rpw").parent().removeClass("error");
  135. }
  136. //Process the user creation process
  137. $("#createbtn").addClass("loading");
  138. $.ajax({
  139. url: "./create",
  140. method: "POST",
  141. data: {username: username, password: pw},
  142. success: function(data){
  143. //Creation succeed. Reload this page
  144. $("#createbtn").removeClass("loading");
  145. window.location.reload();
  146. }
  147. });
  148. });
  149. }
  150. </script>
  151. </body>
  152. </html>