Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.44 KB | None | 0 0
  1. @(utilisateur: Utilisateur, users: List[UserEspaceClient])
  2.  
  3. <html>
  4. <head>
  5. <title>Somovers</title>
  6. <meta charset="utf-8" />
  7. <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.ico")">
  8. @views.html.css(request.path())
  9.  
  10. @views.html.javascript(request.path(),utilisateur)
  11.  
  12. <style>
  13. #DataTables_Table_0_filter{
  14. position: relative;
  15. }
  16. #dataLoading{
  17. position: absolute;
  18. left: 0;
  19. right: 0;
  20. margin: 0 auto;
  21. top: 0;
  22. text-align: center;
  23. z-index: 100;
  24. color: white;
  25. font-weight: bold;
  26. }
  27. </style>
  28. <script>
  29. window.alert = function(e){console.log(e);};
  30. var mytable;
  31. var storedUser = [];
  32. var orderSort='desc';
  33. var loading;
  34. var ONCE = false;
  35.  
  36. var interv = setInterval(function(){
  37. if($('.treeview-table tbody tr').length == 10 && !ONCE){
  38.  
  39. if($("#orderSort").length){
  40. orderSort='asc';
  41. }
  42. $('.treeview-table tfoot th').each( function () {
  43. var title = $(this).text();
  44. $(this).html( '<input type="text" class="colfilter" placeholder="'+title+'" />' );
  45. } );
  46.  
  47. /*
  48. * DATATABLE CREATION
  49. */
  50. mytable = $('.treeview-table').DataTable({
  51. "language": {
  52. "url": "//cdn.datatables.net/plug-ins/1.10.9/i18n/French.json"
  53. },
  54. lengthMenu: [[10, 25, 50, 100],['10', '25', '50', '100']],
  55. dom: 'flrtipl',
  56. buttons: [
  57. 'copyHtml5',
  58. 'excelHtml5',
  59. 'csvHtml5',
  60. 'pdfHtml5'
  61. ],
  62. "order": [[ 0, orderSort ]],
  63. "initComplete" : function(){
  64. mytable.columns().every( function () {
  65. var that = this;
  66.  
  67. // Apply the search
  68. $( 'input.colfilter', this.footer() ).on( 'keyup change', function () {
  69.  
  70. if ( that.search() !== this.value ) {
  71. that
  72. .search( this.value)
  73. .draw();
  74. }
  75. });
  76.  
  77. if(!ONCE){
  78. ONCE = true;
  79.  
  80. $('#DataTables_Table_0_filter').append('<p id="dataLoading">Données en cours de chargement <span>.</span></p>');
  81.  
  82. loading = setInterval(function(){
  83. if($(' #dataLoading span').html().length < 3){
  84. $(' #dataLoading span').html($(' #dataLoading span').html()+'.');
  85. }
  86. else{
  87. $(' #dataLoading span').html('');
  88. }
  89. },500);
  90. }
  91.  
  92. });
  93. },
  94. stateSave: true
  95. });
  96. /*
  97. * END OF DATATABLE CREATION
  98. */
  99.  
  100. clearInterval(interv);
  101.  
  102. setTimeout(function(){
  103. var json=$("#DataTables_Table_0").DataTable().state();
  104. //console.log(json.columns[0].search.search);
  105. var index=0;
  106. $("table").find("tfoot").find("input").each(function(){
  107. this.value=json.columns[index].search.search;
  108. index++
  109. });
  110. index=0;
  111. }, 1000);
  112.  
  113. while(storedUser.length > 0){
  114. mytable.row.add(storedUser[0]);
  115. storedUser.shift();
  116. }
  117. mytable.order(0,orderSort).draw();
  118.  
  119.  
  120. }
  121. },200);
  122.  
  123. </script>
  124. <!--[if gte IE 9]>
  125. <style type="text/css">
  126. .gradient {
  127. filter: none;
  128. }
  129. </style>
  130. <![endif]-->
  131. @helper.javascriptRouter("jsRoutes")(
  132. routes.javascript.SendEmail.sendLogin,
  133. routes.javascript.UsersEspaceClient.getHistorique
  134. )
  135. </head>
  136. <body>
  137. <header class="topbar">
  138. @views.html.menu(utilisateur)
  139. </header>
  140. <div class="container-fluid">
  141. <div class="row">
  142. <div class="col-md-12">
  143. <a class="btn btn-warning retour" href="@routes.Application.index()">Retour</a>
  144. <h1>Liste des utilisateurs de l'espace client</h1>
  145. <input type="hidden" id="orderSort" value="asc" />
  146. <table class="table table-bordered table-grey treeview-table">
  147. <thead>
  148. <tr>
  149. <th>Nom</th>
  150. <th>Login</th>
  151. <th></th>
  152. </tr>
  153. </thead>
  154. <tfoot>
  155. <tr>
  156. <th>Nom</th>
  157. <th>Login</th>
  158. <th></th>
  159. </tr>
  160. </tfoot>
  161. <tbody>
  162. @users.map { unUser =>
  163. @if(users.indexOf(unUser)<10){
  164. <tr>
  165. <td>@unUser.login</td>
  166. <td><i>@if(unUser.actif){Actif}else{Inactif}</i> <a href="/changeActivityEspace/@unUser.login"><span class="glyphicon glyphicon-refresh"></span></a></td>
  167. <td style="width: 40px;" >
  168. <a href="@routes.UsersEspaceClient.edit(unUser.login)"><i class="glyphicon glyphicon-edit"></i></a>
  169. <a data-login="@unUser.login" class="btn btn-primary sendmail"><i class="glyphicon glyphicon-envelope" style="color:white"></i></a>
  170. <a data-id="@unUser.id" class="history"><i class="fa fa-history"></i></a><br/><span class="resultmail"></span>
  171. </td>
  172. </tr>
  173. }else{
  174. <script>
  175. if(typeof mytable != "undefined"){
  176. mytable.row.add($(`<tr>
  177. <td>@unUser.login</td>
  178. <td><i>@if(unUser.actif){Actif}else{Inactif}</i> <a href="/changeActivityEspace/@unUser.login"><span class="glyphicon glyphicon-refresh"></span></a></td>
  179. <td style="width: 40px;" >
  180. <a href="@routes.UsersEspaceClient.edit(unUser.login)"><i class="glyphicon glyphicon-edit"></i></a>
  181. <a data-login="@unUser.login" class="btn btn-primary sendmail"><i class="glyphicon glyphicon-envelope" style="color:white"></i></a>
  182. <a data-id="@unUser.id" class="history"><i class="fa fa-history"></i></a><br/><span class="resultmail"></span>
  183. </td>
  184. </tr>`));
  185. @if(users.indexOf(unUser) % 500 == 0 || users.indexOf(unUser) == users.size() - 1){
  186. mytable.sort(0,orderSort).draw();
  187. }
  188. }else{
  189. storedUser.push($(`<tr>
  190. <td>@unUser.login</td>
  191. <td><i>@if(unUser.actif){Actif}else{Inactif}</i> <a href="/changeActivityEspace/@unUser.login"><span class="glyphicon glyphicon-refresh"></span></a></td>
  192. <td style="width: 40px;" >
  193. <a href="@routes.UsersEspaceClient.edit(unUser.login)"><i class="glyphicon glyphicon-edit"></i></a>
  194. <a data-login="@unUser.login" class="btn btn-primary sendmail"><i class="glyphicon glyphicon-envelope" style="color:white"></i></a>
  195. <a data-id="@unUser.id" class="history"><i class="fa fa-history"></i></a><br/><span class="resultmail"></span>
  196. </td>
  197. </tr>`));
  198. }
  199.  
  200.  
  201. </script>
  202. }
  203. }
  204. </tbody>
  205. </table>
  206. <script>
  207. clearInterval(loading);
  208. $('#dataLoading').remove();
  209. $(document).ready(function(){
  210. setTimeout(function(){
  211. clearInterval(loading);
  212. $('#dataLoading').remove();
  213. },200)
  214.  
  215. });
  216. </script>
  217. </div>
  218. </div>
  219. </div>
  220.  
  221.  
  222. <div id="historique" class="modal fade" data-keyboard="false" data-backdrop="static" role="dialog">
  223. <div id="modalAide" class="modal-dialog" style="width:fit-content">
  224. <div class="modal-content">
  225. <div class="modal-header">
  226. <button type="button" class="close" id="fermer" data-dismiss="modal">&times;</button>
  227. <h4 class="modal-title">Historique de <i id="identifiant"></i></h4>
  228. </div>
  229. <div class="modal-body">
  230. <table class="table">
  231. <thead>
  232. <tr>
  233. <th>action</th><th>adresse ip</th><th>date</th>
  234. </tr>
  235. </thead>
  236. <tbody id="bodyhistorique">
  237.  
  238. </tbody>
  239. </table>
  240. </div>
  241. <div class="modal-footer">
  242. </div>
  243. </div>
  244. </div>
  245. </div>
  246.  
  247.  
  248. <footer>
  249. @views.html.footer(utilisateur)
  250. </footer>
  251. <script>
  252.  
  253.  
  254.  
  255. $(".sendmail").click(function(){
  256. var parent=$(this).parent();
  257. var ajaxCallBack = {
  258. data : "login="+$(this).attr("data-login"),
  259. dataType: "json",
  260. type: "POST",
  261. success : function(data) {
  262. parent.find(".resultmail").html("les identifiants ont bien été envoyés");
  263. setTimeout(function(){
  264. parent.find(".resultmail").empty();
  265. }, 3000);
  266. },
  267. error : function(error) {
  268. parent.find(".resultmail").html("les identifiants n'ont pas pu être envoyés");
  269. setTimeout(function(){
  270. parent.find(".resultmail").empty();
  271. }, 3000);
  272. }
  273. }
  274. jsRoutes.controllers.SendEmail.sendLogin().ajax(ajaxCallBack);
  275. });
  276.  
  277. $(".history").click(function(){
  278. var ajaxCallBack = {
  279. data : "id="+$(this).attr("data-id"),
  280. dataType: "json",
  281. type: "GET",
  282. success : function(data) {
  283. $("#identifiant").html(data.login);
  284. for(var i=0;i<data.historique.length;i++){
  285. var date=new Date(data.historique[i].dateAction)
  286. var datestring=date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear();
  287. var tr="<tr><td>"+data.historique[i].libelle+"</td><td>"+data.historique[i].ip+"</td><td>"+datestring+"</td></tr>";
  288. $("#bodyhistorique").append(tr);
  289. }
  290. $("#historique").modal("show");
  291. },
  292. error : function(error) {
  293. console.log(error);
  294. }
  295. }
  296. jsRoutes.controllers.UsersEspaceClient.getHistorique().ajax(ajaxCallBack);
  297. })
  298.  
  299. </script>
  300. </body>
  301. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement