index.jsp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="utf-8"%>
  3. <%@ taglib prefix="tag" tagdir="/WEB-INF/tags" %>
  4. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  5. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
  6. <c:set var="req" value="${pageContext.request}" />
  7. <c:set var="url">${req.requestURL}</c:set>
  8. <c:set var="base" value="${fn:substring(url, 0, fn:length(url) - fn:length(req.requestURI))}${req.contextPath}/" />
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <tag:head title="Accueil" />
  13. </head>
  14. <body class="grey lighten-3">
  15. <!-- Header -->
  16. <tag:header />
  17. <!-- Main -->
  18. <main class="container">
  19. <div class="row">
  20. <div class="col s12 center-align">
  21. <h3>Dashboard</h3>
  22. </div>
  23. </div>
  24. <div class="row">
  25. <div class="col m12 l8 offset-l2">
  26. <canvas id="chart1"></canvas>
  27. </div>
  28. </div>
  29. <div class="row">
  30. <div class="col m12 l8 offset-l2">
  31. <canvas id="chart2"></canvas>
  32. </div>
  33. </div>
  34. <div class="row mtop-2">
  35. <div class="col m12 l6">
  36. <canvas id="chart3"></canvas>
  37. </div>
  38. <div class="col m12 l6">
  39. <canvas id="chart4"></canvas>
  40. </div>
  41. </div>
  42. </main>
  43. <!-- Footer -->
  44. <tag:footer />
  45. <!-- Loader -->
  46. <tag:loader name="loader" />
  47. <!-- Script -->
  48. <tag:script />
  49. <script type="text/javascript" src="js/chart.min.js"></script>
  50. <script type="text/javascript" src="js/generate-chart.js"></script>
  51. <script type="text/javascript">
  52. function weekChart(id, callback = null) {
  53. $.ajax({
  54. type: "GET",
  55. url: "${base}api/frequentation/stats/week",
  56. error: () => {
  57. console.error("Impossible de charger ageChart");
  58. if (callback != null) {
  59. callback();
  60. }
  61. },
  62. success: (result) => {
  63. const data = result.data;
  64. generateBarChart(
  65. document.getElementById(id),
  66. data.title,
  67. ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"],
  68. data.stats
  69. );
  70. if (callback != null) {
  71. callback();
  72. }
  73. },
  74. });
  75. };
  76. function ageChart(id, callback = null) {
  77. $.ajax({
  78. type: "GET",
  79. url: "${base}api/frequentation/stats/age",
  80. error: () => {
  81. console.error("Impossible de charger ageChart");
  82. if (callback != null) {
  83. callback();
  84. }
  85. },
  86. success: (result) => {
  87. const data = result.data;
  88. generateBarChart(
  89. document.getElementById(id),
  90. data.title,
  91. data.labels,
  92. data.stats
  93. );
  94. if (callback != null) {
  95. callback();
  96. }
  97. },
  98. });
  99. };
  100. function espaceWeekChart(id, callback = null) {
  101. $.ajax({
  102. type: "GET",
  103. url: "${base}api/frequentation/stats/espace/week",
  104. error: () => {
  105. console.error("Impossible de charger ageChart");
  106. if (callback != null) {
  107. callback();
  108. }
  109. },
  110. success: (result) => {
  111. const data = result.data;
  112. generateBarChart(
  113. document.getElementById(id),
  114. data.title,
  115. data.labels,
  116. data.stats
  117. );
  118. if (callback != null) {
  119. callback();
  120. }
  121. },
  122. });
  123. };
  124. function espaceMonthChart(id, callback = null) {
  125. $.ajax({
  126. type: "GET",
  127. url: "${base}api/frequentation/stats/espace/month",
  128. error: () => {
  129. console.error("Impossible de charger ageChart");
  130. if (callback != null) {
  131. callback();
  132. }
  133. },
  134. success: (result) => {
  135. const data = result.data;
  136. generateBarChart(
  137. document.getElementById(id),
  138. data.title,
  139. data.labels,
  140. data.stats
  141. );
  142. if (callback != null) {
  143. callback();
  144. }
  145. },
  146. });
  147. };
  148. $(document).ready(() => {
  149. const loader = M.Modal.getInstance($('#loader'));
  150. loader.open();
  151. weekChart("chart1", () => {
  152. ageChart("chart2", () => {
  153. espaceWeekChart("chart3", () => {
  154. espaceMonthChart("chart4", () => {
  155. loader.close();
  156. })
  157. })
  158. });
  159. })
  160. });
  161. </script>
  162. </body>
  163. </html>