statusNew.jsp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
  4. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
  5. <section class="sub-container">
  6. <article class="menu-history">
  7. <ul>
  8. <li><a href="/admin/noticeList.do" class="home">홈</a></li>
  9. <li><a href="/admin/status.do">접속통계</a></li>
  10. </ul>
  11. </article>
  12. <article class="contents-wrap">
  13. <div class="title-box">
  14. <h2 class="h2-title">접속통계</h2>
  15. <p class="title-info">평택시 교통정보센터 <span>관리자</span></p>
  16. </div>
  17. <!--탭버튼-->
  18. <div class="tab-btn">
  19. <p><a href="/admin/noticeList.do">공지사항</a></p>
  20. <p><a href="/admin/popupList.do">팝업창 관리</a></p>
  21. <p><a href="/admin/modiAdmin.do">관리자 정보변경</a></p>
  22. <p><a href="/admin/status.do" class="active">접속통계</a></p>
  23. <p><a href="/admin/logout.do">로그아웃</a></p>
  24. </div>
  25. <!--//탭버튼-->
  26. <div class="area">
  27. <div class="cont_body">
  28. <img alt="loading" src="/images/ajax_loading.gif" id="loading" style="display:none;position:absolute;left:50%;z-index:10"/>
  29. <div class="adminStatsWrap">
  30. <div class="searchBox" style="background: none; border-bottom: none; position: inherit;">
  31. <select title="검색 년도" id="year">
  32. <c:forEach begin="${thisYear-5}" end="${thisYear}" varStatus="status"><option value="<fmt:formatNumber pattern="00" value="${status.current}"/>" <c:if test="${status.current == thisYear}">selected</c:if>>${status.current}년</option>
  33. </c:forEach>
  34. </select>
  35. <select title="검색 월" id="month">
  36. <c:forEach begin="1" end="12" varStatus="status"><option value="<fmt:formatNumber pattern="00" value="${status.current}"/>" <c:if test="${status.current == thisMonth}">selected</c:if>><fmt:formatNumber pattern="00" value="${status.current}"/>월</option>
  37. </c:forEach>
  38. </select>
  39. <select title="검색 일" id="day">
  40. <c:forEach begin="1" end="${lastDate}" varStatus="status"><option value="<fmt:formatNumber pattern="00" value="${status.current}"/>" <c:if test="${status.current == thisDate}">selected</c:if>><fmt:formatNumber pattern="00" value="${status.current}"/>일</option>
  41. </c:forEach>
  42. </select>
  43. <a href="javascript:showStatsList()" class="bt">검색</a>
  44. </div>
  45. <div class="statsList">
  46. <ul class="tabUI f-clear">
  47. <a href="javascript:showStatsList('hhStats')">
  48. <li class="tab1 on" >
  49. 일 통계
  50. </li>
  51. </a>
  52. <a href="javascript:showStatsList('ddStats')">
  53. <li class="tab2">
  54. 월 통계
  55. </li>
  56. </a>
  57. <a href="javascript:showStatsList('mnStats')">
  58. <li class="tab3">
  59. 년 통계
  60. </li>
  61. </a>
  62. </ul>
  63. <table
  64. id="ddStatsTb"
  65. summary="이 표는 접속통계 게시판이며 웹페이지 각 페이지에 대한 일별, 월별, 년별로 접속통계를 보여주는 표입니다.">
  66. <caption>접속 통계</caption>
  67. <colgroup class="colgroup">
  68. <col width="95"/>
  69. <col width="40"/>
  70. <c:forEach begin="1" end="31" varStatus="status">
  71. <col width="25"/>
  72. </c:forEach>
  73. </colgroup>
  74. <thead>
  75. <tr>
  76. <th scope="col">웹페이지/일</th>
  77. <th scope="col">계</th>
  78. <c:forEach begin="1" end="31" varStatus="status">
  79. <th scope="col">${status.current }</th>
  80. </c:forEach>
  81. </tr>
  82. </thead>
  83. <tbody id="ddStats"></tbody>
  84. </table>
  85. <table
  86. id="hhStatsTb"
  87. summary="이 표는 접속통계 게시판이며 웹페이지 각 페이지에 대한 일별, 월별, 년별로 접속통계를 보여주는 표입니다.">
  88. <caption>접속 통계</caption>
  89. <colgroup>
  90. <col width="95"/>
  91. <col width="40"/>
  92. <c:forEach begin="0" end="23" varStatus="status">
  93. <col width="25"/>
  94. </c:forEach>
  95. </colgroup>
  96. <thead>
  97. <tr>
  98. <th scope="col">웹페이지/시</th>
  99. <th scope="col">계</th>
  100. <c:forEach begin="0" end="23" varStatus="status">
  101. <th scope="col">${status.current }</th>
  102. </c:forEach>
  103. </tr>
  104. </thead>
  105. <tbody id="hhStats"></tbody>
  106. </table>
  107. <table
  108. id="mnStatsTb"
  109. summary="이 표는 접속통계 게시판이며 웹페이지 각 페이지에 대한 일별, 월별, 년별로 접속통계를 보여주는 표입니다.">
  110. <caption>접속 통계</caption>
  111. <colgroup>
  112. <col width="95"/>
  113. <col width="40"/>
  114. <c:forEach begin="1" end="12" varStatus="status">
  115. <col width="25"/>
  116. </c:forEach>
  117. </colgroup>
  118. <thead>
  119. <tr>
  120. <th scope="col">웹페이지/월</th>
  121. <th scope="col">계</th>
  122. <c:forEach begin="1" end="12" varStatus="status">
  123. <th scope="col">${status.current }</th>
  124. </c:forEach>
  125. </tr>
  126. </thead>
  127. <tbody id="mnStats"></tbody>
  128. </table>
  129. </div>
  130. </div>
  131. <!-- 그래프 -->
  132. <div>
  133. <article id="highcharts" style="min-width:310px;height:350px;padding:10px;overflow-y:auto;margin:0 auto"></article>
  134. </div>
  135. </div>
  136. </div>
  137. </article>
  138. </section>
  139. <!--//contents-->
  140. <script src="/js/highcharts/highcharts.js" type="text/javascript"></script>
  141. <script src="/js/highcharts/exporting.js" type="text/javascript"></script>
  142. <script type="text/javascript">
  143. const tab1 = $('.tab1');
  144. const tab2 = $('.tab2');
  145. const tab3 = $('.tab3');
  146. showStatsList('hhStats');
  147. var _DateType = null;
  148. function showStatsList(type) {
  149. if (typeof type == 'undefined') {
  150. if(_DateType == null) type = 'hhStats';
  151. else type = _DateType;
  152. }
  153. var date = $('#year').val();
  154. if(type == 'mnStats') {
  155. tab1.removeClass('on');
  156. tab2.removeClass('on');
  157. tab3.addClass('on');
  158. $('#ddStatsTb').hide();
  159. $('#hhStatsTb').hide();
  160. $('#mnStatsTb').show();
  161. $('#year').show();
  162. $('#month').hide();
  163. $('#day').hide();
  164. date = $('#year').val();
  165. }
  166. else if(type == 'ddStats') {
  167. tab1.removeClass('on');
  168. tab2.addClass('on');
  169. tab3.removeClass('on');
  170. $('#mnStatsTb').hide();
  171. $('#hhStatsTb').hide();
  172. $('#ddStatsTb').show();
  173. $('#year').show();
  174. $('#month').show();
  175. $('#day').hide();
  176. date += $('#month').val();
  177. }
  178. else if(type == 'hhStats') {
  179. tab1.addClass('on');
  180. tab2.removeClass('on');
  181. tab3.removeClass('on');
  182. $('#mnStatsTb').hide();
  183. $('#ddStatsTb').hide();
  184. $('#hhStatsTb').show();
  185. $('#year').show();
  186. $('#month').show();
  187. $('#day').show();
  188. date += $('#month').val() + $('#day').val();
  189. }
  190. _DateType = type;
  191. $.ajax({
  192. type:"POST",
  193. url:'/admin/getStatsList.do',
  194. //data: 'dateType='+_DateType+'&date='+date,
  195. data: {"dateType":_DateType, "date": date},
  196. success: function(data) {
  197. var str = '';
  198. if (data.length > 0) {
  199. //el.title : 메인페이지 , el.total_connCnt : 총접속수 , el.statsInArr : 일 ,월,년 각각 통계수
  200. var title;
  201. var statsHour = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23'];
  202. if(_DateType=='ddStats'){
  203. statsHour = ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'];
  204. }else if(_DateType == 'mnStats'){
  205. statsHour = ['1','2','3','4','5','6','7','8','9','10','11','12'];
  206. }
  207. var series = [];
  208. data.forEach(function(el) {
  209. title = el.title;
  210. str += '<tr>';
  211. str += '<td style="text-align:center">'+el.title+'</td>';
  212. str += '<td style="text-align:center">'+el.total_connCnt+'</td>';
  213. el.statsInArr.forEach(function(cnt) {
  214. str += '<td style="text-align:center">'+cnt+'</td>';
  215. });
  216. series.push({name: el.title , data:el.statsInArr});
  217. str += '</tr>';
  218. });
  219. var info='시간';
  220. if(_DateType=='ddStats'){
  221. info = '일';
  222. }else if(_DateType == 'mnStats'){
  223. info = '월';
  224. }
  225. $('#'+type).empty().html(str);
  226. $('#highcharts').show();
  227. drawCharts('홈페이지 접속통계 그래프',
  228. statsHour,
  229. info,
  230. '접속통계',
  231. series
  232. );
  233. }
  234. else {
  235. $('#highcharts').hide();
  236. str += '<tr><td colspan="31" style="text-align:center">데이터가 없습니다.</td></tr>';
  237. $('#'+type).empty().html(str);
  238. }
  239. }, beforeSend: function () {
  240. $('#loading').show();
  241. },
  242. complete: function () {
  243. $('#loading').hide();
  244. },
  245. error: function(e) {
  246. alert('getDayStats ajax error');
  247. }
  248. });
  249. }
  250. function drawCharts(title, xAxis, xTitle, yTitle, series) {
  251. Highcharts.chart('highcharts', {
  252. chart: {
  253. type: 'line'
  254. },
  255. title: {
  256. text: title
  257. },
  258. xAxis: {
  259. categories: xAxis,
  260. title: {
  261. text: xTitle
  262. }
  263. },
  264. yAxis: {
  265. title: {
  266. text: yTitle
  267. }
  268. },
  269. plotOptions: {
  270. line: {
  271. dataLabels: {
  272. enabled: true
  273. },
  274. enableMouseTracking: false
  275. }
  276. },
  277. series: series
  278. });
  279. }
  280. </script>