access.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /**
  2. * admin/access
  3. */
  4. var mcare_admin_access = function(){
  5. //상속
  6. mcare_admin.call(this);
  7. var self = this;
  8. //변수설정
  9. var $search = $("#search"),
  10. $endDate = $("#endDate"),
  11. $selectOption = $("#select-option"),
  12. $strDate = $("#strDate"),
  13. $grid = $("#grid"),
  14. $chart = $("#chart"),
  15. $crudServiceBaseUrl = contextPath + "/admin/stats";
  16. /**
  17. * 초기화
  18. */
  19. this.init = function(){
  20. initDatePicker();
  21. initDropDownList();
  22. initGrid();
  23. addEvent();
  24. };
  25. /**
  26. * 이벤트 등록
  27. */
  28. var addEvent = function(){
  29. $search.on("click", function(e){
  30. self.search( dataSource, false );
  31. });
  32. };
  33. /**
  34. * datepicker 초기화
  35. */
  36. var initDatePicker = function(){
  37. self.datePicker( $endDate, $strDate, $selectOption );
  38. };
  39. /**
  40. * 검색 조건 드롭다운 초기화
  41. */
  42. var initDropDownList = function(){
  43. self.dropDownList( $selectOption );
  44. };
  45. /**
  46. * 데이터 소스 설정
  47. */
  48. var setDataSource = function(){
  49. var dataSource = new kendo.data.DataSource({
  50. transport: {
  51. read: {
  52. url: $crudServiceBaseUrl + "/getAccessList.json",
  53. method: "post",
  54. dataType: "json",
  55. contentType: "application/json"
  56. },
  57. parameterMap: getParameterMap
  58. },
  59. schema: {
  60. data : getSchemaData
  61. },
  62. change: function(e) {
  63. // update chart
  64. },
  65. pageSize: 20
  66. });
  67. /**
  68. * 파라미터 맵 설정
  69. */
  70. function getParameterMap( options, operation ){
  71. var param = $.extend(true, {}, options, {
  72. strDate : new Date( self.getStartDatePickerValue() ).setHours(0, 0, 0, 0),
  73. endDate : new Date( +self.getEndDatePickerValue()).setHours(0, 0, 0, 0),
  74. }, null);
  75. return self.util.stringifyJson( param );
  76. };
  77. /**
  78. * 데이터 소스 스키마 설정
  79. */
  80. function getSchemaData(e){
  81. if( e.msg !== undefined ){
  82. alert(e.msg);
  83. return [];
  84. }
  85. var aggAccessList = e.aggMenuList;
  86. var totalCount = 0;
  87. for( var n = 0 ; n < aggAccessList.length ; n ++ ) {
  88. totalCount += aggAccessList[n].hitCnt;
  89. }
  90. var param = [];
  91. for( var n = 0, size = aggAccessList.length ; n < size ; n ++ ) {
  92. var cnt = aggAccessList[n].hitCnt/totalCount*100,
  93. str_per = ( Math.round(cnt*1000) ) / 1000;
  94. param.push({
  95. "pageOrd" : n+1,
  96. "menuId" : aggAccessList[n].menuId,
  97. "menuName" : aggAccessList[n].menuName,
  98. "reqUriAddr" : aggAccessList[n].reqUriAddr,
  99. "hitCnt" : aggAccessList[n].hitCnt,
  100. "percentage" : str_per
  101. });
  102. }
  103. return param;
  104. };
  105. return dataSource;
  106. };
  107. var dataSource = setDataSource();
  108. /**
  109. * 그리드 초기화
  110. */
  111. var initGrid = function(){
  112. // 그리드 옵션
  113. var option = {
  114. dataSource: dataSource,
  115. pageable: true,
  116. resizable: true,
  117. sortable: true,
  118. selectable: true,
  119. height : 460,
  120. columns : [
  121. {
  122. field : "pageOrd",
  123. title : "No.",
  124. width: 80,
  125. template: "#:data.pageOrd#",
  126. attributes: {
  127. "class": "table-cell",
  128. style: "text-align: center;"
  129. }
  130. },
  131. {
  132. field : "menuName",
  133. title : "메뉴 이름",
  134. width: 100,
  135. attributes: {
  136. "class": "table-cell",
  137. style: "text-align: left;"
  138. }
  139. },
  140. {
  141. field : "menuId",
  142. title : "메뉴 아이디",
  143. width: 100,
  144. attributes: {
  145. "class": "table-cell",
  146. style: "text-align: left;"
  147. }
  148. },
  149. {
  150. field : "hitCnt",
  151. title : "페이지 뷰",
  152. width: 100,
  153. template: "#= kendo.toString(data.hitCnt,'n0')# 건",
  154. attributes: {
  155. "class": "table-cell",
  156. style: "text-align: center;"
  157. }
  158. },
  159. {
  160. field : "percentage",
  161. title : "비율",
  162. width: 100,
  163. template: "#:data.percentage# %",
  164. attributes: {
  165. "class": "table-cell",
  166. style: "text-align: center;"
  167. }
  168. },
  169. {
  170. field : "reqUriAddr",
  171. title : "요청 URI",
  172. width: 200,
  173. attributes: {
  174. "class": "table-cell",
  175. style: "text-align: left;"
  176. }
  177. }
  178. ]
  179. };
  180. // 그리드 초기화
  181. self.grid( $grid, option );
  182. };
  183. };