first
This commit is contained in:
276
safekiso_admin/pages/key/statistics/detail.vue
Normal file
276
safekiso_admin/pages/key/statistics/detail.vue
Normal file
@@ -0,0 +1,276 @@
|
||||
<!-- This example requires Tailwind CSS v2.0+ -->
|
||||
<template>
|
||||
<div class="pb-8 px-4 sm:px-6 lg:px-8">
|
||||
<div class="sm:flex sm:items-center">
|
||||
<div class="sm:flex-auto">
|
||||
<h1 class="text-xl font-semibold text-gray-900">
|
||||
API 사용량 통계 상세 보기
|
||||
</h1>
|
||||
<p class="mt-2 text-sm text-gray-700">
|
||||
API 키별 사용량 통계를 보여 줍니다. 구분 항목으로 시간별,
|
||||
날짜별, 월별 구분이 가능합니다.
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
|
||||
<div>현재 통계 범위 : {{ targetTerm }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BaseList1
|
||||
:headings="listHeadings"
|
||||
:actions="listActions"
|
||||
:keys="listKeys"
|
||||
:data="listData"
|
||||
:action-key="actionKey"
|
||||
:column-filter="columnFilter"
|
||||
:do-action="doAction"
|
||||
/>
|
||||
|
||||
<BasePagination1
|
||||
:total-page-count="totalPageCount"
|
||||
:current-page-number="currentPageNumber"
|
||||
:page-size="pageSize"
|
||||
:records-total="recordsTotal"
|
||||
:page-move="pageMove"
|
||||
/>
|
||||
|
||||
<div class="p-0 rounded-bl-2xl rounded-br-2xl md:px-0">
|
||||
<a
|
||||
href="javascript:void(0)"
|
||||
class="text-base font-medium text-indigo-700 hover:text-indigo-600"
|
||||
@click="$router.back()"
|
||||
>←이전 화면으로<span aria-hidden="true"> </span
|
||||
></a>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const router = useRouter();
|
||||
|
||||
definePageMeta({
|
||||
middleware: 'check-auth-op',
|
||||
});
|
||||
|
||||
const listHeadings = [
|
||||
{
|
||||
title: '키',
|
||||
class: 'py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6',
|
||||
key: 'api_key',
|
||||
hiddenInfo: {
|
||||
headClass: 'font-normal lg:hidden',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass:
|
||||
'w-full max-w-0 py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:w-auto sm:max-w-none sm:pl-6',
|
||||
},
|
||||
{
|
||||
title: 'total',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 lg:table-cell',
|
||||
key: 'total',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 lg:table-cell',
|
||||
},
|
||||
{
|
||||
title: 'hit',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
|
||||
key: 'hit',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
|
||||
},
|
||||
{
|
||||
title: 'hit_ratio',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
|
||||
key: 'hit_ratio',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
|
||||
},
|
||||
|
||||
{
|
||||
title: 'size',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
|
||||
key: 'size',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
|
||||
},
|
||||
{
|
||||
title: 'size_avg',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
|
||||
key: 'size_avg',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
|
||||
},
|
||||
|
||||
{
|
||||
title: 'ip',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
|
||||
key: 'uniq_ip',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
|
||||
},
|
||||
{
|
||||
title: 'referrer',
|
||||
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
|
||||
key: 'uniq_referrer',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
|
||||
},
|
||||
|
||||
{
|
||||
title: '갱신일',
|
||||
class: 'px-3 py-3.5 text-left text-sm font-semibold text-gray-900',
|
||||
key: 'updated',
|
||||
hiddenInfo: {
|
||||
headClass: '',
|
||||
dts: [],
|
||||
dds: [],
|
||||
},
|
||||
subClass: 'px-3 py-4 text-sm text-gray-500',
|
||||
},
|
||||
];
|
||||
const listActions = [];
|
||||
const actionKey = 'serial';
|
||||
const listKeys = [
|
||||
'serial',
|
||||
'api_key',
|
||||
'date_tag',
|
||||
'total',
|
||||
'hit',
|
||||
'size',
|
||||
'uniq_ip',
|
||||
'uniq_referrer',
|
||||
'updated',
|
||||
];
|
||||
const listData = ref([]);
|
||||
|
||||
const totalPageCount = ref(0);
|
||||
const currentPageNumber = ref(1);
|
||||
const pageSize = ref(26);
|
||||
const recordsTotal = ref(0);
|
||||
// const order = [{ column: 'serial', dir: 'desc' }];
|
||||
// const columns = { serial: { data: 'serial' } };
|
||||
const { $dayjs } = useNuxtApp();
|
||||
function columnFilter(key, val) {
|
||||
// console.log('columnFilter(), key = ', key, ', val = ', val);
|
||||
|
||||
if (key == 'updated' || key == 'created') {
|
||||
return $dayjs(val).format('YY/MM/DD A h:mm:ss');
|
||||
// return $dayjs(val).format('YY/MM/DD');
|
||||
} else if (key == 'size') {
|
||||
return _utils.formatBytes(val, 2);
|
||||
} else if (key == 'api_key') {
|
||||
if (keyNameMap[val] != undefined) {
|
||||
return keyNameMap[val];
|
||||
} else {
|
||||
return 'invailed_key';
|
||||
}
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
function doAction(tag, target) {
|
||||
console.log('on doAction(), tag=', tag, ', target=', target);
|
||||
router.push({
|
||||
name: 'key-edit',
|
||||
params: { target: target },
|
||||
});
|
||||
}
|
||||
|
||||
function pageMove(targetPageIdex) {
|
||||
console.log('on pageMove(), targetPageIdex=', targetPageIdex);
|
||||
currentPageNumber.value = targetPageIdex;
|
||||
refresh();
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
const responseJson = await _crossCtl.doComm(
|
||||
'local/list',
|
||||
'statistics:month',
|
||||
{
|
||||
start: (currentPageNumber.value - 1) * pageSize.value,
|
||||
length: pageSize.value,
|
||||
hero: targetTerm.value,
|
||||
}
|
||||
);
|
||||
|
||||
currentPageNumber.value = responseJson['currentPageNumber'];
|
||||
totalPageCount.value = responseJson['totalPageCount'];
|
||||
pageSize.value = parseInt(responseJson['pageSize']);
|
||||
recordsTotal.value = responseJson['recordsTotal'];
|
||||
|
||||
for (let i = 0; i < responseJson['data'].length; i++) {
|
||||
responseJson['data'][i]['hit_ratio'] =
|
||||
(
|
||||
(responseJson['data'][i]['hit'] /
|
||||
responseJson['data'][i]['total']) *
|
||||
100
|
||||
).toFixed(2) + '%';
|
||||
responseJson['data'][i]['size_avg'] = _utils.formatBytes(
|
||||
responseJson['data'][i]['size'] / responseJson['data'][i]['total'],
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
listData.value = responseJson['data'];
|
||||
|
||||
console.log('listData.value=', listData.value);
|
||||
}
|
||||
|
||||
const targetTerm = ref(_utils.getDateTimeTag('m'));
|
||||
|
||||
const terms = ref([]);
|
||||
|
||||
const keyNameMap = {};
|
||||
|
||||
const responseJson = await _crossCtl.doComm('local/list', 'key', {
|
||||
start: 0,
|
||||
length: -1,
|
||||
});
|
||||
|
||||
const tmpTerms = [];
|
||||
|
||||
for (let i = 0; i < responseJson['data'].length; i++) {
|
||||
keyNameMap[responseJson['data'][i]['api_key']] =
|
||||
responseJson['data'][i]['name'];
|
||||
}
|
||||
|
||||
console.log('tmpTerms=', tmpTerms);
|
||||
terms.value = tmpTerms;
|
||||
|
||||
function onChangeTerm(e) {
|
||||
console.log('targetTerm.value=', targetTerm.value);
|
||||
refresh();
|
||||
}
|
||||
|
||||
refresh();
|
||||
</script>
|
||||
Reference in New Issue
Block a user