123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- /**
- * admin/access
- */
- var mcare_admin_access = function(){
- //상속
- mcare_admin.call(this);
-
- var self = this;
- //변수설정
- var $search = $("#search"),
- $endDate = $("#endDate"),
- $selectOption = $("#select-option"),
- $strDate = $("#strDate"),
- $grid = $("#grid"),
- $chart = $("#chart"),
- $crudServiceBaseUrl = contextPath + "/admin/stats";
-
- /**
- * 초기화
- */
- this.init = function(){
- initDatePicker();
- initDropDownList();
- initGrid();
- addEvent();
- };
- /**
- * 이벤트 등록
- */
- var addEvent = function(){
- $search.on("click", function(e){
- self.search( dataSource, false );
- });
- };
- /**
- * datepicker 초기화
- */
- var initDatePicker = function(){
- self.datePicker( $endDate, $strDate, $selectOption );
- };
- /**
- * 검색 조건 드롭다운 초기화
- */
- var initDropDownList = function(){
- self.dropDownList( $selectOption );
- };
-
- /**
- * 데이터 소스 설정
- */
- var setDataSource = function(){
-
- var dataSource = new kendo.data.DataSource({
- transport: {
- read: {
- url: $crudServiceBaseUrl + "/getAccessList.json",
- method: "post",
- dataType: "json",
- contentType: "application/json"
- },
- parameterMap: getParameterMap
- },
- schema: {
- data : getSchemaData
- },
- change: function(e) {
- // update chart
- },
- pageSize: 20
- });
- /**
- * 파라미터 맵 설정
- */
- function getParameterMap( options, operation ){
- var param = $.extend(true, {}, options, {
- strDate : new Date( self.getStartDatePickerValue() ).setHours(0, 0, 0, 0),
- endDate : new Date( +self.getEndDatePickerValue()).setHours(0, 0, 0, 0),
- }, null);
- return self.util.stringifyJson( param );
- };
- /**
- * 데이터 소스 스키마 설정
- */
- function getSchemaData(e){
- if( e.msg !== undefined ){
- alert(e.msg);
- return [];
- }
- var aggAccessList = e.aggMenuList;
- var totalCount = 0;
- for( var n = 0 ; n < aggAccessList.length ; n ++ ) {
- totalCount += aggAccessList[n].hitCnt;
- }
-
- var param = [];
- for( var n = 0, size = aggAccessList.length ; n < size ; n ++ ) {
- var cnt = aggAccessList[n].hitCnt/totalCount*100,
- str_per = ( Math.round(cnt*1000) ) / 1000;
- param.push({
- "pageOrd" : n+1,
- "menuId" : aggAccessList[n].menuId,
- "menuName" : aggAccessList[n].menuName,
- "reqUriAddr" : aggAccessList[n].reqUriAddr,
- "hitCnt" : aggAccessList[n].hitCnt,
- "percentage" : str_per
- });
- }
-
- return param;
- };
-
- return dataSource;
- };
- var dataSource = setDataSource();
- /**
- * 그리드 초기화
- */
- var initGrid = function(){
- // 그리드 옵션
- var option = {
- dataSource: dataSource,
- pageable: true,
- resizable: true,
- sortable: true,
- selectable: true,
- height : 460,
- columns : [
- {
- field : "pageOrd",
- title : "No.",
- width: 80,
- template: "#:data.pageOrd#",
- attributes: {
- "class": "table-cell",
- style: "text-align: center;"
- }
- },
- {
- field : "menuName",
- title : "메뉴 이름",
- width: 100,
- attributes: {
- "class": "table-cell",
- style: "text-align: left;"
- }
- },
- {
- field : "menuId",
- title : "메뉴 아이디",
- width: 100,
- attributes: {
- "class": "table-cell",
- style: "text-align: left;"
- }
- },
- {
- field : "hitCnt",
- title : "페이지 뷰",
- width: 100,
- template: "#= kendo.toString(data.hitCnt,'n0')# 건",
- attributes: {
- "class": "table-cell",
- style: "text-align: center;"
- }
- },
- {
- field : "percentage",
- title : "비율",
- width: 100,
- template: "#:data.percentage# %",
- attributes: {
- "class": "table-cell",
- style: "text-align: center;"
- }
- },
- {
- field : "reqUriAddr",
- title : "요청 URI",
- width: 200,
- attributes: {
- "class": "table-cell",
- style: "text-align: left;"
- }
- }
- ]
- };
- // 그리드 초기화
- self.grid( $grid, option );
- };
-
- };
|