pubreg.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <html>
  2. <head>
  3. <title>Public Registry Settings</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. <!-- <script type="text/javascript" src="../../script/ao_module.js"></script> -->
  10. </head>
  11. <body>
  12. <div class="ui container">
  13. <div class="ui basic segment">
  14. <div class="ui header">
  15. <i class="key icon"></i>
  16. <div class="content">
  17. Public Registry
  18. <div class="sub header">Allow public to register an account on this system</div>
  19. </div>
  20. </div>
  21. </div>
  22. <div id="succdialog" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i> Registry Setting Updated</div>
  23. <div id="errdialog" style="display:none;" class="ui red inverted segment">Update Failed: <span id="errmsg"></span></div>
  24. <form class="ui form" onsubmit="handleFormSubmit(event);">
  25. <div class="ui segment">
  26. <div class="field">
  27. <div class="ui toggle checkbox">
  28. <input type="checkbox" id="enableReg" tabindex="0" class="hidden">
  29. <label>Enable Public Account Registry</label>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="field">
  34. <label>Default Permission Group for New User</label>
  35. <div class="ui fluid search selection dropdown">
  36. <input type="hidden" name="pg" id="pg">
  37. <i class="dropdown icon"></i>
  38. <div class="default text">Select Permission Group</div>
  39. <div id="pglist" class="menu">
  40. </div>
  41. </div>
  42. </div>
  43. <div class="ui blue button" tabindex="0" onclick="handleFormSubmit(event);">Update</div>
  44. </form>
  45. <div class="ui divider"></div>
  46. <div class="ui basic segment">
  47. <h4>Registered User List</h4>
  48. <a class="ui green right floated button" href="../../system/register/listUserEmails?csv=true" target="_blank">Download as CSV</a>
  49. <p>A list of registered users. Be noted that the user registration information will not be deleted when a user account is deregistered. The status of the user account status will be shown in the "Still Registered" collum.</p>
  50. </div>
  51. <table class="ui celled table">
  52. <thead>
  53. <tr><th>Username</th>
  54. <th>Email</th>
  55. <th>Still Registered</th>
  56. </tr></thead>
  57. <tbody id="userlist">
  58. </tbody>
  59. </table>
  60. <br>
  61. <button class="ui blue button" onclick="initUserRegisterInfoList();"><i class="refresh icon"></i>Refresh Table</button>
  62. <button class="ui right floated red button" onclick="clearUnregisteredUserInfo();"><i class="remove icon"></i> Clear Unregistered Users Information</button>
  63. <br><br><br>
  64. </div>
  65. <script>
  66. $(".ui.checkbox").checkbox();
  67. initRegStatus();
  68. function initRegStatus(){
  69. $.get("../../system/register/getAllowRegistry", function(data){
  70. if (data == true){
  71. $("#enableReg").parent().checkbox("check");
  72. }
  73. });
  74. $.get("../../system/permission/listgroup", function(data){
  75. if (data.error !== undefined){
  76. alert(data.error);
  77. }else{
  78. $("#pglist").html("");
  79. data.forEach(gp => {
  80. $("#pglist").append(`<div class="item" data-value="${gp}">${gp}</div>`);
  81. })
  82. }
  83. $(".ui.dropdown").dropdown();
  84. //Get the current default group
  85. $.get("../../system/register/setDefaultGroup?get=true", function(data){
  86. $("#pglist").parent().dropdown("set selected",data);
  87. });
  88. });
  89. }
  90. function handleFormSubmit(e){
  91. e.preventDefault();
  92. var pg = $("#pg").val();
  93. var regEnabled = $("#enableReg")[0].checked;
  94. $.ajax({
  95. url: "../../system/register/setDefaultGroup",
  96. data: {"defaultGroup": pg},
  97. success: function(data){
  98. if (data.error !== undefined){
  99. showErrorMessage(data.error);
  100. }else{
  101. showSuccessMessage();
  102. }
  103. },
  104. error: function(){
  105. showErrorMessage("Server Communication Error");
  106. }
  107. });
  108. $.ajax({
  109. url: "../../system/register/setAllowRegistry",
  110. data: {"allow": regEnabled},
  111. success: function(data){
  112. if (data.error !== undefined){
  113. showErrorMessage(data.error);
  114. }else{
  115. showSuccessMessage();
  116. }
  117. },
  118. error: function(){
  119. showErrorMessage("Server Communication Error");
  120. }
  121. });
  122. }
  123. function showSuccessMessage(){
  124. $("#succdialog").stop().finish().slideDown('fast').delay(3000).slideUp('fast');
  125. }
  126. function showErrorMessage(err){
  127. $("#errmsg").text(err);
  128. $("#errdialog").stop().finish().slideDown('fast').delay(3000).slideUp('fast');
  129. }
  130. initUserRegisterInfoList();
  131. function initUserRegisterInfoList(){
  132. $("#userlist").html("");
  133. $.get("../../system/register/listUserEmails", function(data){
  134. if (data.error !== undefined){
  135. alert(data.error)
  136. }else{
  137. data.forEach(userinfo => {
  138. var icon = "green checkmark icon";
  139. if (userinfo[2] == false){
  140. icon = "red remove icon"
  141. }
  142. $("#userlist").append(`<tr>
  143. <td>${userinfo[0]}</td>
  144. <td><a href="mailto:${userinfo[1]}">${userinfo[1]}</a></td>
  145. <td><i class="${icon}"></i></td>
  146. </tr>`);
  147. });
  148. if (data.length == 0){
  149. $("#userlist").append(`<tr><td col="3"><i class="remove icon"></i> There is no user register record in the database.</td></tr>`);
  150. }
  151. }
  152. })
  153. }
  154. //Remove all unregistered user information
  155. function clearUnregisteredUserInfo(){
  156. if (confirm("Confirm Removing ALL UNREGISTERED USERS INFORMATION?")){
  157. $.get("../../system/register/cleanUserRegisterInfo", function(data){
  158. initUserRegisterInfoList();
  159. });
  160. }
  161. }
  162. </script>
  163. </body>
  164. </html>