PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/md-ui/src/main/webapp/WEB-INF/views/users.jsp

https://gitlab.com/kingofhappy/openbdre
JavaServer Pages | 278 lines | 257 code | 15 blank | 6 comment | 0 complexity | 230a863b52e98656576176dbae2097a8 MD5 | raw file
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  6. <title>Bigdata Ready Enterprise</title>
  7. <script>
  8. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  9. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  10. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  11. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  12. //Please replace with your own analytics id
  13. ga('create', 'UA-72345517-1', 'auto');
  14. ga('send', 'pageview');
  15. </script>
  16. <!-- Include one of jTable styles. -->
  17. <link href="../css/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  18. <link href="../css/jtables-bdre.css" rel="stylesheet" type="text/css" />
  19. <link href="../css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
  20. <!-- Include jTable script file. -->
  21. <script src="../js/jquery.min.js" type="text/javascript"></script>
  22. <script src="../js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>
  23. <script src="../js/jquery.jtable.js" type="text/javascript"></script>
  24. <script type="text/javascript">
  25. $(document).ready(function () {
  26. $('#Container').jtable({
  27. title: 'Users List',
  28. paging: true,
  29. pageSize: 10,
  30. sorting: true,
  31. selecting: true, //Enable selecting
  32. multiselect: false, //Allow multiple selecting
  33. selectOnRowClick: true, //Enable this to only select using checkboxes
  34. openChildAsAccordion: true,
  35. actions: {
  36. listAction: function (postData, jtParams) {
  37. console.log(postData);
  38. return $.Deferred(function ($dfd) {
  39. $.ajax({
  40. url: '/mdrest/users?page=' + jtParams.jtStartIndex + '&size='+jtParams.jtPageSize,
  41. type: 'GET',
  42. data: postData,
  43. dataType: 'json',
  44. success: function (data) {
  45. $dfd.resolve(data);
  46. },
  47. error: function () {
  48. $dfd.reject();
  49. }
  50. });
  51. });
  52. },
  53. createAction: function (postData) {
  54. console.log(postData);
  55. return $.Deferred(function ($dfd) {
  56. $.ajax({
  57. url: '/mdrest/users',
  58. type: 'PUT',
  59. data: postData,
  60. dataType: 'json',
  61. success: function (data) {
  62. $dfd.resolve(data);
  63. },
  64. error: function () {
  65. $dfd.reject();
  66. }
  67. });
  68. });
  69. },
  70. updateAction: function (postData) {
  71. console.log(postData);
  72. return $.Deferred(function ($dfd) {
  73. $.ajax({
  74. url: '/mdrest/users',
  75. type: 'POST',
  76. data: postData,
  77. dataType: 'json',
  78. success: function (data) {
  79. $dfd.resolve(data);
  80. },
  81. error: function () {
  82. $dfd.reject();
  83. }
  84. });
  85. });
  86. },
  87. deleteAction: function (item) {
  88. console.log(item);
  89. return $.Deferred(function ($dfd) {
  90. $.ajax({
  91. url: '/mdrest/users/' + item.username,
  92. type: 'DELETE',
  93. data: item,
  94. dataType: 'json',
  95. success: function (data) {
  96. $dfd.resolve(data);
  97. },
  98. error: function () {
  99. $dfd.reject();
  100. }
  101. });
  102. });
  103. }
  104. },
  105. fields: {
  106. UserRoles: {                    
  107. width: '5%',
  108. sorting: false,
  109. edit: false,
  110. create: false,
  111. listClass: 'bdre-jtable-button',
  112.                     display: function (item) {                         //Create an image that will be used to open child table
  113.                         
  114. var $img = $('<img src="../css/images/three-bar.png" title="User roles info" />');                         //Open child table when user clicks the image
  115.                         
  116. $img.click(function () {                            
  117. $('#Container').jtable('openChildTable',                                     
  118. $img.closest('tr'),                                      {                                        
  119. title: ' Roles of ' + item.record.username,
  120.                                         actions: {                                        
  121. listAction: function (postData) {
  122. return $.Deferred(function ($dfd) {
  123. console.log(item);
  124. $.ajax({
  125. url: '/mdrest/userroles/' + item.record.username,
  126. type: 'GET',
  127. data: item,
  128. dataType: 'json',
  129. success: function (data) {
  130. $dfd.resolve(data);
  131. },
  132. error: function () {
  133. $dfd.reject();
  134. }
  135. });
  136. ;
  137. });
  138. },
  139.     deleteAction: function (postData) {
  140. console.log(postData.processId);
  141. return $.Deferred(function ($dfd) {
  142. $.ajax({
  143. url: '/mdrest/userroles/' + postData.userRoleId,
  144. type: 'DELETE',
  145. data: item,
  146. dataType: 'json',
  147. success: function (data) {
  148. $dfd.resolve(data);
  149. },
  150. error: function () {
  151. $dfd.reject();
  152. }
  153. });
  154. });
  155. },
  156. updateAction: function (postData) {
  157. console.log(postData);
  158. return $.Deferred(function ($dfd) {
  159. $.ajax({
  160. url: '/mdrest/userroles',
  161. type: 'POST',
  162. data: postData,
  163. dataType: 'json',
  164. success: function (data) {
  165. console.log(data);
  166. $dfd.resolve(data);
  167. },
  168. error: function () {
  169. $dfd.reject();
  170. }
  171. });
  172. });
  173. },
  174. createAction: function (postData) {
  175. console.log(postData);
  176. return $.Deferred(function ($dfd) {
  177. $.ajax({
  178. url: '/mdrest/userroles',
  179. type: 'PUT',
  180. data: postData,
  181. dataType: 'json',
  182. success: function (data) {
  183. $dfd.resolve(data);
  184. },
  185. error: function () {
  186. $dfd.reject();
  187. }
  188. });
  189. });
  190. }
  191. },
  192.     fields: {    
  193.                        
  194. userRoleId: {
  195. key: true,
  196. width: '5%',
  197. list: false,
  198. create: false,
  199. title: 'User Role Id'
  200. },
  201. username: {
  202. type: 'hidden',
  203. defaultValue: item.record.username,
  204. },
  205. role: {
  206. title: 'Role',
  207. type: 'combobox',
  208. options: {'ROLE_ADMIN': 'Administrator', 'ROLE_USER': 'Application Developer', 'ROLE_READONLY': 'Readonly User'}
  209. },
  210. }
  211. },
  212. function (data) { //opened handler
  213.                                         
  214. data.childTable.jtable('load');                                    
  215. });                        
  216. });                         //Return image to show on the person row
  217.                         
  218. return $img;                    
  219. }                
  220. },
  221. username: {
  222. key: true,
  223. list: true,
  224. create: true,
  225. edit: false,
  226. title: 'Username'
  227. },
  228. password: {
  229. list: false,
  230. create: true,
  231. edit: true,
  232. type: 'password',
  233. title: 'Password'
  234. },
  235. enabled: {
  236. title: 'Enabled',
  237. type: "radiobutton",
  238. edit: true,
  239. options: {
  240. "1": "true",
  241. "0": "false"
  242. },
  243. }
  244. },
  245. selectionChanged: function () {
  246. //Get all selected rows
  247. var $selectedRows = $('#Container').jtable('selectedRows');
  248. // $selectedRows.each(function() {
  249. // var record = $(this).data('record');
  250. // alert('Username: ' + record.username);
  251. // });
  252. }
  253. });
  254. $('#Container').jtable('load');
  255. });
  256. </script>
  257. </head>
  258. <body>
  259. <section style="width:100%;text-align:center;">
  260. <div id="Container"></div>
  261. </section>
  262. </body>
  263. </html>