This commit is contained in:
2026-04-07 14:50:23 +09:00
commit b4e485502b
4778 changed files with 2017091 additions and 0 deletions

View File

@@ -0,0 +1,451 @@
<template>
<div class="m-0">
<form
class="space-y-8 divide-y divide-gray-200"
@submit.prevent="doUpdate"
>
<div class="space-y-8 divide-y divide-gray-200 sm:space-y-5">
<div
class="divide-y divide-gray-200 pt-0 space-y-6 sm:pt-0 sm:space-y-5"
>
<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>
<img
v-if="inPregressFlag"
width="32"
src="/loading-load-2.gif"
/>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<button
type="button"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="gotoStatistics()"
>
사용 통계
</button>
<button
type="button"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="gotoWordStatistics()"
>
단어 통계
</button>
</div>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="name"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
이름
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<input
id="name"
v-model="name"
type="text"
name="name"
autocomplete="name"
class="max-w-lg block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md"
/>
</div>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="api-key"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
API
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<input
id="api-key"
v-model="apiKey"
type="text"
name="api-key"
autocomplete="api-key"
disabled
class="max-w-lg block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md"
/>
</div>
</div>
<div
class="space-y-6 sm:space-y-5 divide-y divide-gray-200"
>
<div class="pt-6 sm:pt-5">
<div
role="group"
aria-labelledby="label-notifications"
>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-baseline"
>
<div>
<div
id="label-notifications"
class="text-base font-medium text-gray-900 sm:text-sm sm:text-gray-700"
>
필터 단계
</div>
</div>
<div class="sm:col-span-2">
<div class="max-w-lg">
<p class="text-sm text-gray-500">
필터 대상이 되는 단계를
선택합니다. (현재는 최대 필터만
동작)
</p>
<div class="mt-4 space-y-4">
<div class="flex items-center">
<input
id="filter-high"
v-model="level"
value="high"
name="filter-level"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-high"
class="ml-3 block text-sm font-medium text-gray-700"
>
최대 필터
</label>
</div>
<div class="flex items-center">
<input
id="filter-mid"
v-model="level"
value="mid"
name="filter-level"
type="radio"
disabled
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-mid"
class="ml-3 block text-sm font-medium text-gray-700"
>
중간 필터
</label>
</div>
<div class="flex items-center">
<input
id="filter-low"
v-model="level"
value="low"
name="filter-level"
type="radio"
disabled
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-low"
class="ml-3 block text-sm font-medium text-gray-700"
>
가장 가벼운 필터
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="pt-5">
<div class="flex justify-between">
<div>
<button
type="button"
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="doDelete"
>
{{ status == 0 ? '삭제' : '복구' }}
</button>
</div>
<div>
<button
type="button"
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="doCancel"
>
이전화면
</button>
<button
v-if="status == 0"
type="submit"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
저장
</button>
</div>
</div>
</div>
<div class="divide-y divide-gray-200 space-x-8"></div>
</form>
<form
class="space-y-6 pt-8 sm:pt-10 divide-y divide-gray-200"
@submit.prevent="doFilter"
>
<div class="space-y-8 divide-y divide-gray-200 sm:space-y-5">
<div>
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-xl font-semibold text-gray-900">
필터 테스트
</h1>
<p class="mt-2 text-sm text-gray-700">
입력된 문장을 api를 이용해 검사하고 결과를
표시합니다.
</p>
</div>
<img
v-if="inPregressFlag"
width="32"
src="/loading-load-2.gif"
/>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<button
type="submit"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
검사하기
</button>
</div>
</div>
<div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5">
<div>
<fieldset class="mt-4">
<legend class="sr-only">Filter Mode</legend>
<div class="space-y-4">
<div
v-for="notificationMethod in notificationMethods"
:key="notificationMethod.id"
class="flex items-center"
>
<input
:id="notificationMethod.id"
v-model="filterMode"
:value="notificationMethod.id"
name="notification-method"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
:for="notificationMethod.id"
class="ml-3 block text-sm font-medium text-gray-700"
>
{{ notificationMethod.title }}
</label>
</div>
</div>
</fieldset>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="filterText"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
검사할 문장 입력
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<textarea
id="filterText"
v-model="filterText"
name="filterText"
rows="3"
class="max-w-lg shadow-sm block w-full focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border border-gray-300 rounded-md"
/>
<p class="mt-2 text-sm text-gray-500">
필터 테스트를 위한 문장을 입력하고 아래
검사하기 버튼을 누르세요. <br />
(마지막 실행시간
{{ elispe.toFixed(2) }} 밀리초)
</p>
<pre>{{ resultJson }}</pre>
</div>
</div>
</div>
</div>
</div>
<div class="pt-5">
<div class="flex justify-end"></div>
</div>
</form>
</div>
</template>
<script setup lang="ts">
const route = useRoute();
const router = useRouter();
definePageMeta({
middleware: 'check-auth-op',
});
const hero = route.params.hero;
console.log('hero=', hero);
const apiKey = ref('');
const name = ref('');
const level = ref('');
const status = ref(0);
const notificationMethods = [
{
id: 'quick',
title: 'mode = quick. 첫번째 매칭이 발견되면 더 이상 검사하지 않고 바로 결과를 리턴',
},
{ id: 'normal', title: 'mode = normal. 전체를 검사하여 모든 매칭을 리턴' },
{
id: 'filter',
title: 'mode = filter. 전체를 검사하며 모든 매칭을 마스크로 치환한 결과까지 리턴',
},
];
const filterText = ref('테스트할 문장을 여기에 입력해 주세요.');
const filterMode = ref('filter');
const filterCallback = ref('');
const resultJson = ref({});
const elispe = ref(0);
const inPregressFlag = ref(false);
async function doFilter() {
if (inPregressFlag.value == true) {
alert('이전 동작이 아직 진행중입니다.');
return;
}
inPregressFlag.value = true;
const startTime = performance.now();
const responseJson = await _crossCtl.doFilterRaw(apiKey.value, {
text: filterText.value,
mode: filterMode.value,
});
const endTime = performance.now();
inPregressFlag.value = false;
elispe.value = endTime - startTime;
// console.log('responseJson=', responseJson);
const result = responseJson;
resultJson.value = result;
if (responseJson['Status']['Code'] == 2000) {
// alert(result.length + ' match found');
} else {
alert(responseJson['Status']['Message']);
}
}
function gotoStatistics() {
navigateTo('/key/' + hero + '/statistics');
}
function gotoWordStatistics() {
navigateTo('/word/' + hero + '/statistics');
}
const responseJson = await _crossCtl.doComm('local/select', 'key', {
hero: hero,
});
if (responseJson['data'].length == 0) {
_crossCtl.openModal(
'error',
'잘못된 파라메타',
'키 정보를 읽어올 수 없습니다.\n확인 버튼을 누르면 메인 화면으로 돌아갑니다.',
['확인'],
(btnIdx) => {
navigateTo('/');
}
);
} else {
const keyInfo = responseJson['data'][0];
apiKey.value = keyInfo['api_key'];
name.value = keyInfo['name'];
level.value = keyInfo['level'];
status.value = keyInfo['status'];
}
async function doUpdate() {
const responseJson = await _crossCtl.doComm('local/update', 'key', {
hero: hero,
name: name.value,
level: level.value,
status: status.value,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
alert('ok');
} else {
alert(responseJson['responseMessage']);
}
}
async function doDelete() {
if (status.value == 0) {
const responseJson = await _crossCtl.doComm('local/delete', 'key', {
hero: hero,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
status.value = 4;
alert('ok');
} else {
alert(responseJson['responseMessage']);
}
} else {
const responseJson = await _crossCtl.doComm('local/update', 'key', {
hero: hero,
name: name.value,
level: level.value,
revive: true,
status: 0,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
status.value = 0;
alert('ok');
} else {
alert(responseJson['responseMessage']);
}
}
}
async function doCancel() {
router.back();
}
</script>

View File

@@ -0,0 +1,265 @@
<!-- This example requires Tailwind CSS v2.0+ -->
<template>
<div class="pb-8 px-4 sm:px-6 lg:px-8">
<br />
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-xl font-semibold text-gray-900">
API KEY 로그 보기
</h1>
<p class="mt-2 text-sm text-gray-700">
API KEY의 생성, 변경, 삭제 기록을 확인할 있습니다.
</p>
</div>
<!--
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<label for="mobile-search-candidate" class="sr-only"
>Search</label
>
<label for="desktop-search-candidate" class="sr-only"
>Search</label
>
<div class="flex rounded-md shadow-sm">
<div class="relative flex-grow focus-within:z-10">
<div
class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"
>
<MagnifyingGlassCircleIcon
class="h-5 w-5 text-gray-400"
aria-hidden="true"
/>
</div>
<input
id="mobile-search-candidate"
v-model="searchKeyword"
type="text"
name="mobile-search-candidate"
class="focus:ring-indigo-500 focus:border-indigo-500 block w-full rounded-none rounded-l-md pl-10 sm:hidden border-gray-300"
placeholder=""
/>
<input
id="desktop-search-candidate"
v-model="searchKeyword"
type="text"
name="desktop-search-candidate"
class="hidden focus:ring-indigo-500 focus:border-indigo-500 w-full rounded-none rounded-l-md pl-10 sm:block sm:text-sm border-gray-300"
placeholder=""
/>
</div>
<button
type="button"
class="-ml-px relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-r-md text-gray-700 bg-gray-50 hover:bg-gray-100 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500"
@click="doAction('search', searchKeyword)"
>
<span class="ml-2">검색</span>
</button>
</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()"
>&larr;이전 화면으로<span aria-hidden="true"> </span
></a>
</div>
</div>
</template>
<script setup lang="ts">
import {
ChevronDownIcon,
MagnifyingGlassCircleIcon,
} from '@heroicons/vue/24/solid';
import consolaGlobalInstance from 'consola';
const { $dayjs } = useNuxtApp();
const router = useRouter();
definePageMeta({
middleware: 'check-auth-admin',
});
const route = useRoute();
console.log('route.params=', route.params);
const targetName = route.params.hero;
const hero = route.params.uid;
console.log('targetName=', targetName);
console.log('hero=', hero);
let listTarget = 'log:user:active';
const listHeadings = [
{
title: '누가',
class: 'py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6',
key: 'uid',
hiddenInfo: {
headClass: '',
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: '언제',
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 lg:table-cell',
key: 'created',
hiddenInfo: {
headClass: '',
dts: [],
dds: [],
},
subClass: 'hidden px-3 py-4 text-sm text-gray-500 lg:table-cell',
},
{
title: '무엇을',
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
key: 'tag',
hiddenInfo: {
headClass: '',
dts: [],
dds: [],
},
subClass: 'hidden px-3 py-4 text-sm text-gray-500 sm:table-cell',
},
];
const listActions = ['상세보기'];
const actionKey = 'serial';
const listKeys = [
'serial',
'raw',
'level',
'comment',
'status',
'updated',
'created',
];
const listData = ref([]);
const totalPageCount = ref(0);
const currentPageNumber = ref(1);
const pageSize = ref(10);
const recordsTotal = ref(0);
// const order = [{ column: 'serial', dir: 'desc' }];
// const columns = { serial: { data: 'serial' } };
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 == 'uid') {
return '' + targetName + '';
} else if (key == 'status') {
let statusTag = '정상';
switch (val) {
case 0:
statusTag = '정상등록';
break;
case 4:
statusTag = '삭제됨';
break;
default:
statusTag = val;
}
return statusTag;
} else if (key == 'level') {
let levelTag = 'mid';
switch (val) {
case 10:
levelTag = 'high';
break;
case 50:
levelTag = 'mid';
break;
case 100:
levelTag = 'low';
break;
default:
levelTag = val;
}
return levelTag;
} else {
return val;
}
}
function doAction(tag, target) {
console.log('on doAction(), tag=', tag, ', target=', target);
if (tag == '상세보기') {
navigateTo('/admin/user/' + hero + '/history/detail/' + target);
} else if (tag == 'search') {
console.log('search for ', target);
if (target == '') {
listTarget = 'log:user:active';
} else {
listTarget = 'log:user';
// hero = target;
}
refresh();
}
}
function pageMove(targetPageIdex) {
console.log('on pageMove(), targetPageIdex=', targetPageIdex);
currentPageNumber.value = targetPageIdex;
refresh();
}
async function refresh() {
const responseJson = await _crossCtl.doComm('list', listTarget, {
start: (currentPageNumber.value - 1) * pageSize.value,
length: pageSize.value,
hero: hero,
});
console.log('listTarget=', listTarget);
console.log('hero=', hero);
console.log('responseJson=', responseJson);
currentPageNumber.value = responseJson['currentPageNumber'];
totalPageCount.value = responseJson['totalPageCount'];
pageSize.value = parseInt(responseJson['pageSize']);
recordsTotal.value = responseJson['recordsTotal'];
listData.value = responseJson['data'];
}
if (hero != undefined) {
doAction('search', hero);
} else {
refresh();
}
</script>

View File

@@ -0,0 +1,433 @@
<!-- 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>
<select
id="targetTerm"
v-model="targetTerm"
name="targetTerm"
class="mt-0 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
@change="onChange($event)"
>
<option
v-for="term in terms"
:key="term.key"
:selected="term.current"
:value="term.key"
>
<span class="truncate">
{{ term.key }}
</span>
</option>
</select>
</div>
</div>
<Datepicker
v-if="targetTerm == 'month'"
v-model="targetDateMonth"
class="mt-4 sm:mt-0 sm:ml-2 sm:flex-none"
locale="ko"
:year-picker="true"
:format="formatForMonth"
@update:modelValue="handleDate"
></Datepicker>
<Datepicker
v-if="targetTerm == 'day'"
v-model="targetDateDay"
class="mt-4 sm:mt-0 sm:ml-2 sm:flex-none"
locale="ko"
:month-picker="true"
:format="formatForDay"
@update:modelValue="handleDate"
></Datepicker>
<Datepicker
v-if="targetTerm == 'hour'"
v-model="targetDateHour"
class="mt-4 sm:mt-0 sm:ml-2 sm:flex-none"
locale="ko"
:format="formatForHour"
@update:modelValue="handleDate"
></Datepicker>
</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()"
>&larr;이전 화면으로<span aria-hidden="true"> </span
></a>
</div>
</div>
</template>
<script setup lang="ts">
import Datepicker from '@vuepic/vue-datepicker';
import '@vuepic/vue-datepicker/dist/main.css';
const { $dayjs } = useNuxtApp();
const router = useRouter();
const targetDate = ref($dayjs(new Date().toISOString()).format('YYYY'));
const targetDateMonth = ref($dayjs(new Date().toISOString()).format('YYYY'));
const targetDateDay = ref({
month: new Date().getMonth(),
year: new Date().getFullYear,
});
const targetDateHour = ref($dayjs(new Date().toISOString()));
// console.log('huk = ', targetDate.value);
const formatForMonth = (date) => {
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
// return `${year}${(month < 10 ? '0' : '') + month}${(day < 10 ? '0' : '') + day}`;
return `${year}`;
};
const formatForDay = (date) => {
console.log('huk format date = ', date);
// return `${year}${(month < 10 ? '0' : '') + month}${(day < 10 ? '0' : '') + day}`;
return `${date.year}${(date.month + 1 < 10 ? '0' : '') + (date.month + 1)}`;
};
const formatForHour = (date) => {
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
const hour = date.getHours();
return `${year}${(month < 10 ? '0' : '') + month}${
(day < 10 ? '0' : '') + day
}`;
};
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: 'date_tag',
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',
'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' } };
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 {
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', {
start: (currentPageNumber.value - 1) * pageSize.value,
length: pageSize.value,
hero: targetKey.value,
term: targetTerm.value,
// termPrefix: _utils.getDateTimeTag(targetTerm.value.substring(0, 1)),
// termPrefix: _utils.getDateTimeTag('y'),
termPrefix: targetDate.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 terms = ref([]);
const route = useRoute();
const hero = route.params.hero;
const targetTerm = ref('year');
const targetKey = ref('');
const tmpTerms = [
{ current: targetTerm.value == 'year', key: 'year' },
{ current: targetTerm.value == 'month', key: 'month' },
{ current: targetTerm.value == 'day', key: 'day' },
{ current: targetTerm.value == 'hour', key: 'hour' },
];
terms.value = tmpTerms;
const responseJson = await _crossCtl.doComm('local/select', 'key', {
hero: hero,
});
if (responseJson['data'].length == 0) {
_crossCtl.openModal(
'error',
'잘못된 파라메타',
'키 정보를 읽어올 수 없습니다.\n확인 버튼을 누르면 메인 화면으로 돌아갑니다.',
['확인'],
(btnIdx) => {
navigateTo('/');
}
);
} else {
targetKey.value = responseJson['data'][0]['api_key'];
}
function handleDate(date) {
console.log('huk date = ', date);
let result = date;
switch (targetTerm.value) {
case 'year':
result = `${date}`;
break;
case 'month':
result = `${date}`;
break;
case 'day':
result = `${date.year}${
(date.month + 1 < 10 ? '0' : '') + (date.month + 1)
}`;
break;
case 'hour':
result = $dayjs(date).format('YYYYMMDD');
break;
}
targetDate.value = result;
console.log('huk result = ', result);
refresh();
}
function onChange(e) {
console.log('targetTerm.value=', targetTerm.value);
switch (targetTerm.value) {
case 'year':
targetDate.value = $dayjs(new Date().toISOString()).format('YYYY');
break;
case 'month':
targetDate.value = $dayjs(new Date().toISOString()).format('YYYY');
break;
case 'day':
targetDate.value = $dayjs(new Date().toISOString()).format(
'YYYYMM'
);
break;
case 'hour':
targetDate.value = $dayjs(new Date().toISOString()).format(
'YYYYMMDD'
);
break;
}
terms.value = [
{ current: targetTerm.value == 'year', key: 'year' },
{ current: targetTerm.value == 'month', key: 'month' },
{ current: targetTerm.value == 'day', key: 'day' },
{ current: targetTerm.value == 'hour', key: 'hour' },
];
refresh();
}
refresh();
</script>

View File

@@ -0,0 +1,175 @@
<!-- 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">
삭제된 리스트
</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">
<button
type="button"
class="inline-flex mr-3 items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-red-400 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 sm:w-auto"
@click="$router.push('/key/list')"
>
리스트
</button>
</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"></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: 'name',
hiddenInfo: {
headClass: 'font-normal lg:hidden',
dts: [
{ class: 'sr-only', title: '단계' },
{ class: 'sr-only sm:hidden', title: '상태' },
],
dds: [
{ class: 'mt-1 truncate text-gray-700', key: 'level' },
{
class: 'mt-1 truncate text-gray-500 sm:hidden',
key: 'status',
},
],
},
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: '단계',
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 lg:table-cell',
key: 'level',
hiddenInfo: {
headClass: '',
dts: [],
dds: [],
},
subClass: 'hidden px-3 py-4 text-sm text-gray-500 lg:table-cell',
},
{
title: '상태',
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
key: 'status',
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: 'created',
hiddenInfo: {
headClass: '',
dts: [],
dds: [],
},
subClass: 'px-3 py-4 text-sm text-gray-500',
},
];
const listActions = ['상세보기'];
const actionKey = 'serial';
const listKeys = ['serial', 'api_key', 'name', 'level', 'status', 'created'];
const listData = ref([]);
const totalPageCount = ref(0);
const currentPageNumber = ref(1);
const pageSize = ref(10);
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 {
return val;
}
}
function maekNewKey() {
return navigateTo({
path: '/key/new',
query: {},
});
}
function doAction(tag, target) {
console.log('on doAction(), tag=', tag, ', target=', target);
/*
router.push({
name: 'key-edit',
params: { target: target },
});
*/
navigateTo('/key/' + target + '/edit');
}
function pageMove(targetPageIdex) {
console.log('on pageMove(), targetPageIdex=', targetPageIdex);
currentPageNumber.value = targetPageIdex;
refresh();
}
async function refresh() {
if (process.client) {
const responseJson = await _crossCtl.doComm(
'local/list',
'key:deleted',
{
start: (currentPageNumber.value - 1) * pageSize.value,
length: pageSize.value,
}
);
currentPageNumber.value = responseJson['currentPageNumber'];
totalPageCount.value = responseJson['totalPageCount'];
pageSize.value = parseInt(responseJson['pageSize']);
recordsTotal.value = responseJson['recordsTotal'];
listData.value = responseJson['data'];
}
}
refresh();
</script>

View File

@@ -0,0 +1,425 @@
<template>
<div class="m-0">
<form
class="space-y-8 divide-y divide-gray-200"
@submit.prevent="doUpdate"
>
<div class="space-y-8 divide-y divide-gray-200 sm:space-y-5">
<div
class="divide-y divide-gray-200 pt-0 space-y-6 sm:pt-0 sm:space-y-5"
>
<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>
<img
v-if="inPregressFlag"
width="32"
src="/loading-load-2.gif"
/>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<button
type="button"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="gotoStatistics()"
>
통계 보기
</button>
</div>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="name"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
이름
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<input
id="name"
v-model="name"
type="text"
name="name"
autocomplete="name"
class="max-w-lg block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md"
/>
</div>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="api-key"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
API
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<input
id="api-key"
v-model="apiKey"
type="text"
name="api-key"
autocomplete="api-key"
disabled
class="max-w-lg block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md"
/>
</div>
</div>
<div
class="space-y-6 sm:space-y-5 divide-y divide-gray-200"
>
<div class="pt-6 sm:pt-5">
<div
role="group"
aria-labelledby="label-notifications"
>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-baseline"
>
<div>
<div
id="label-notifications"
class="text-base font-medium text-gray-900 sm:text-sm sm:text-gray-700"
>
필터 단계
</div>
</div>
<div class="sm:col-span-2">
<div class="max-w-lg">
<p class="text-sm text-gray-500">
필터 대상이 되는 단계를
선택합니다. (현재는 최대 필터만
동작)
</p>
<div class="mt-4 space-y-4">
<div class="flex items-center">
<input
id="filter-high"
v-model="level"
value="high"
name="filter-level"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-high"
class="ml-3 block text-sm font-medium text-gray-700"
>
최대 필터
</label>
</div>
<div class="flex items-center">
<input
id="filter-mid"
v-model="level"
value="mid"
name="filter-level"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-mid"
class="ml-3 block text-sm font-medium text-gray-700"
>
중간 필터
</label>
</div>
<div class="flex items-center">
<input
id="filter-low"
v-model="level"
value="low"
name="filter-level"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-low"
class="ml-3 block text-sm font-medium text-gray-700"
>
가장 가벼운 필터
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="pt-5">
<div class="flex justify-between">
<div>
<button
type="button"
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="doDelete"
>
{{ status == 0 ? '삭제' : '복구' }}
</button>
</div>
<div>
<button
type="button"
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="doCancel"
>
이전화면
</button>
<button
v-if="status == 0"
type="submit"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
저장
</button>
</div>
</div>
</div>
<div class="divide-y divide-gray-200 space-x-8"></div>
</form>
<form
class="space-y-6 pt-8 sm:pt-10 divide-y divide-gray-200"
@submit.prevent="doFilter"
>
<div class="space-y-8 divide-y divide-gray-200 sm:space-y-5">
<div>
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-xl font-semibold text-gray-900">
필터 테스트
</h1>
<p class="mt-2 text-sm text-gray-700">
입력된 문장을 api를 이용해 검사하고 결과를
표시합니다.
</p>
</div>
<img
v-if="inPregressFlag"
width="32"
src="/loading-load-2.gif"
/>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<button
type="submit"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
검사하기
</button>
</div>
</div>
<div class="mt-6 sm:mt-5 space-y-6 sm:space-y-5">
<div>
<fieldset class="mt-4">
<legend class="sr-only">Filter Mode</legend>
<div class="space-y-4">
<div
v-for="notificationMethod in notificationMethods"
:key="notificationMethod.id"
class="flex items-center"
>
<input
:id="notificationMethod.id"
v-model="filterMode"
:value="notificationMethod.id"
name="notification-method"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
:for="notificationMethod.id"
class="ml-3 block text-sm font-medium text-gray-700"
>
{{ notificationMethod.title }}
</label>
</div>
</div>
</fieldset>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="filterText"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
검사할 문장 입력
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<textarea
id="filterText"
v-model="filterText"
name="filterText"
rows="3"
class="max-w-lg shadow-sm block w-full focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border border-gray-300 rounded-md"
/>
<p class="mt-2 text-sm text-gray-500">
필터 테스트를 위한 문장을 입력하고 아래
검사하기 버튼을 누르세요. <br />
(마지막 실행시간
{{ elispe.toFixed(2) }} 밀리초)
</p>
<pre>{{ resultJson }}</pre>
</div>
</div>
</div>
</div>
</div>
<div class="pt-5">
<div class="flex justify-end"></div>
</div>
</form>
</div>
</template>
<script setup lang="ts">
const route = useRoute();
const router = useRouter();
definePageMeta({
middleware: 'check-auth-op',
});
const hero = route.params.target;
console.log('hero=', hero);
const apiKey = ref('');
const name = ref('');
const level = ref('');
const status = ref(0);
const notificationMethods = [
{
id: 'quick',
title: 'mode = quick. 첫번째 매칭이 발견되면 더 이상 검사하지 않고 바로 결과를 리턴',
},
{ id: 'normal', title: 'mode = normal. 전체를 검사하여 모든 매칭을 리턴' },
{
id: 'filter',
title: 'mode = filter. 전체를 검사하며 모든 매칭을 마스크로 치환한 결과까지 리턴',
},
];
const filterText = ref('테스트할 문장을 여기에 입력해 주세요.');
const filterMode = ref('filter');
const filterCallback = ref('');
const resultJson = ref({});
const elispe = ref(0);
const inPregressFlag = ref(false);
async function doFilter() {
if (inPregressFlag.value == true) {
alert('이전 동작이 아직 진행중입니다.');
return;
}
inPregressFlag.value = true;
const startTime = performance.now();
const responseJson = await _crossCtl.doFilterRaw(apiKey.value, {
text: filterText.value,
mode: filterMode.value,
});
const endTime = performance.now();
inPregressFlag.value = false;
elispe.value = endTime - startTime;
// console.log('responseJson=', responseJson);
const result = responseJson;
resultJson.value = result;
if (responseJson['Status']['Code'] == 2000) {
// alert(result.length + ' match found');
} else {
alert(responseJson['Status']['Message']);
}
}
function gotoStatistics() {
navigateTo('/key/' + hero + '/statistics/year');
}
const responseJson = await _crossCtl.doComm('local/select', 'key', {
hero: hero,
});
const keyInfo = responseJson['data'][0];
apiKey.value = keyInfo['api_key'];
name.value = keyInfo['name'];
level.value = keyInfo['level'];
status.value = keyInfo['status'];
async function doUpdate() {
const responseJson = await _crossCtl.doComm('local/update', 'key', {
hero: hero,
name: name.value,
level: level.value,
status: status.value,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
alert('ok');
} else {
alert(responseJson['responseMessage']);
}
}
async function doDelete() {
if (status.value == 0) {
const responseJson = await _crossCtl.doComm('local/delete', 'key', {
hero: hero,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
status.value = 4;
alert('ok');
} else {
alert(responseJson['responseMessage']);
}
} else {
const responseJson = await _crossCtl.doComm('local/update', 'key', {
hero: hero,
name: name.value,
level: level.value,
status: 0,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
status.value = 0;
alert('ok');
} else {
alert(responseJson['responseMessage']);
}
}
}
async function doCancel() {
router.back();
}
</script>

View File

@@ -0,0 +1,194 @@
<!-- 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"> 리스트</h1>
<p class="mt-2 text-sm text-gray-700">
API 키를 보고 관리할 있습니다. ({{ recordsTotal }} /
{{ limitCount }})
</p>
</div>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<button
type="button"
class="inline-flex mr-3 items-center justify-center rounded-md border border-transparent bg-red-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 sm:w-auto"
@click="$router.push('/key/deleted')"
>
삭제 리스트
</button>
<button
type="button"
class="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto"
@click="maekNewKey"
>
만들기
</button>
</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"></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: 'name',
hiddenInfo: {
headClass: 'font-normal lg:hidden',
dts: [
{ class: 'sr-only', title: '단계' },
{ class: 'sr-only sm:hidden', title: '상태' },
],
dds: [
{ class: 'mt-1 truncate text-gray-700', key: 'level' },
{
class: 'mt-1 truncate text-gray-500 sm:hidden',
key: 'status',
},
],
},
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: '단계',
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 lg:table-cell',
key: 'level',
hiddenInfo: {
headClass: '',
dts: [],
dds: [],
},
subClass: 'hidden px-3 py-4 text-sm text-gray-500 lg:table-cell',
},
{
title: '상태',
class: 'hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 sm:table-cell',
key: 'status',
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: 'created',
hiddenInfo: {
headClass: '',
dts: [],
dds: [],
},
subClass: 'px-3 py-4 text-sm text-gray-500',
},
];
const listActions = ['상세보기'];
const actionKey = 'serial';
const listKeys = ['serial', 'api_key', 'name', 'level', 'status', 'created'];
const listData = ref([]);
const totalPageCount = ref(0);
const currentPageNumber = ref(1);
const pageSize = ref(10);
const recordsTotal = ref(0);
const limitCount = ref(5);
// 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 {
return val;
}
}
function maekNewKey() {
if (recordsTotal.value >= limitCount.value) {
alert(
'키 생성 갯수 제한을 초과 할 수 없습니다. 관리자에게 문의하세요.'
);
} else {
return navigateTo({
path: '/key/new',
query: {},
});
}
}
function doAction(tag, target) {
console.log('on doAction(), tag=', tag, ', target=', target);
/*
router.push({
name: 'key-edit',
params: { target: target },
});
*/
navigateTo('/key/' + target + '/edit');
}
function pageMove(targetPageIdex) {
console.log('on pageMove(), targetPageIdex=', targetPageIdex);
currentPageNumber.value = targetPageIdex;
refresh();
}
async function refresh() {
if (process.client) {
const responseJson = await _crossCtl.doComm(
'local/list',
'key:active',
{
start: (currentPageNumber.value - 1) * pageSize.value,
length: pageSize.value,
}
);
currentPageNumber.value = responseJson['currentPageNumber'];
totalPageCount.value = responseJson['totalPageCount'];
pageSize.value = parseInt(responseJson['pageSize']);
recordsTotal.value = responseJson['recordsTotal'];
listData.value = responseJson['data'];
limitCount.value = responseJson['metaData']['limitCount'];
console.log('listData.value=', listData.value);
}
}
refresh();
</script>

View File

@@ -0,0 +1,206 @@
<!--
This example requires Tailwind CSS v2.0+
This example requires some changes to your config:
```
// tailwind.config.js
module.exports = {
// ...
plugins: [
// ...
require('@tailwindcss/forms'),
],
}
```
-->
<template>
<div class="m-8">
<form
class="space-y-8 divide-y divide-gray-200"
@submit.prevent="doCreate"
>
<div class="space-y-8 divide-y divide-gray-200 sm:space-y-5">
<div
class="divide-y divide-gray-200 pt-8 space-y-6 sm:pt-10 sm:space-y-5"
>
<div>
<h3 class="text-lg leading-6 font-medium text-gray-900">
API 생성
</h3>
<p class="mt-1 max-w-2xl text-sm text-gray-500">
모욕적 언어 필터 서비스 이용에 필요한 새로운 API
키를 만듭니다.
</p>
</div>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"
>
<label
for="first-name"
class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2"
>
이름
</label>
<div class="mt-1 sm:mt-0 sm:col-span-2">
<input
id="first-name"
v-model="name"
type="text"
name="first-name"
autocomplete="given-name"
class="max-w-lg block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md"
/>
</div>
</div>
<div
class="space-y-6 sm:space-y-5 divide-y divide-gray-200"
>
<div class="pt-6 sm:pt-5">
<div
role="group"
aria-labelledby="label-notifications"
>
<div
class="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-baseline"
>
<div>
<div
id="label-notifications"
class="text-base font-medium text-gray-900 sm:text-sm sm:text-gray-700"
>
필터 단계
</div>
</div>
<div class="sm:col-span-2">
<div class="max-w-lg">
<p class="text-sm text-gray-500">
필터 대상이 되는 단계를
선택합니다. (현재는 최대 필터만
동작)
</p>
<div class="mt-4 space-y-4">
<div class="flex items-center">
<input
id="filter-high"
v-model="level"
value="high"
name="filter-level"
type="radio"
class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-high"
class="ml-3 block text-sm font-medium text-gray-700"
>
최대 필터
</label>
</div>
<div class="flex items-center">
<input
id="filter-mid"
v-model="level"
value="mid"
name="filter-level"
type="radio"
disabled
class="opacity-75 focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-mid"
class="opacity-75 ml-3 block text-sm font-medium text-gray-700"
>
중간 필터
</label>
</div>
<div class="flex items-center">
<input
id="filter-low"
v-model="level"
value="low"
name="filter-level"
type="radio"
disabled
class="opacity-75 focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300"
/>
<label
for="filter-low"
class="opacity-75 ml-3 block text-sm font-medium text-gray-700"
>
가장 가벼운 필터
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="pt-5">
<div class="flex justify-end">
<button
type="button"
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
@click="doCancel"
>
취소
</button>
<button
type="submit"
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
만들기
</button>
</div>
</div>
</form>
</div>
</template>
<script setup lang="ts">
const router = useRouter();
definePageMeta({
middleware: 'check-auth-op',
});
const name = ref('');
const level = ref('high');
async function doCancel() {
router.back();
}
watch(level, (newValue, oldValue) => {
console.log('level 의 변이가 감지되었을 때 ', {
newValue,
oldValue,
});
});
async function doCreate() {
const responseJson = await _crossCtl.doComm('local/insert', 'key', {
name: name.value,
level: level.value,
});
console.log('responseJson=', responseJson);
if (responseJson['responseMessage'] == 'ok') {
alert('ok');
router.back();
} else {
if (responseJson['responseMessage'] == 'exceed limit') {
alert(
'키 생성 갯수 제한을 초과 할 수 없습니다. 관리자에게 문의하세요.'
);
} else {
responseJson['responseMessage'];
}
}
}
</script>

View File

@@ -0,0 +1,47 @@
<!-- 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>
</div>
<br />
<nav class="space-y-1" aria-label="Sidebar">
<a
v-for="item in navigation"
:key="item.name"
href="javascript:void(0)"
:class="[
'text-gray-600 hover:bg-gray-100 hover:text-gray-900',
'flex items-center px-3 py-2 text-sm font-medium rounded-md',
]"
:aria-current="'page'"
@click="$router.push(item.href)"
>
<span class="truncate">
{{ item.name }}
</span>
</a>
</nav>
</div>
</template>
<script setup lang="ts">
definePageMeta({
middleware: 'check-auth-op',
});
const navigation = [
{ name: '일별 통계', href: '/key/statistics/daily' },
{ name: '월별 통계', href: '/key/statistics/monthly' },
];
</script>

View 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()"
>&larr;이전 화면으로<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>

View File

@@ -0,0 +1,413 @@
<!-- 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>
<select
id="targetTerm"
v-model="targetTerm"
name="targetTerm"
class="mt-0 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
@change="onChange($event)"
>
<option
v-for="term in terms"
:key="term.key"
:selected="term.current"
:value="term.key"
>
<span class="truncate">
{{ term.key }}
</span>
</option>
</select>
</div>
</div>
<Datepicker
v-if="targetTerm == 'month'"
v-model="targetDateMonth"
class="mt-4 sm:mt-0 sm:ml-2 sm:flex-none"
locale="ko"
:year-picker="true"
:format="formatForMonth"
@update:modelValue="handleDate"
></Datepicker>
<Datepicker
v-if="targetTerm == 'day'"
v-model="targetDateDay"
class="mt-4 sm:mt-0 sm:ml-2 sm:flex-none"
locale="ko"
:month-picker="true"
:format="formatForDay"
@update:modelValue="handleDate"
></Datepicker>
<Datepicker
v-if="targetTerm == 'hour'"
v-model="targetDateHour"
class="mt-4 sm:mt-0 sm:ml-2 sm:flex-none"
locale="ko"
:format="formatForHour"
@update:modelValue="handleDate"
></Datepicker>
</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()"
>&larr;이전 화면으로<span aria-hidden="true"> </span
></a>
</div>
</div>
</template>
<script setup lang="ts">
import Datepicker from '@vuepic/vue-datepicker';
import '@vuepic/vue-datepicker/dist/main.css';
const { $dayjs } = useNuxtApp();
const router = useRouter();
const targetDate = ref($dayjs(new Date().toISOString()).format('YYYY'));
const targetDateMonth = ref($dayjs(new Date().toISOString()).format('YYYY'));
const targetDateDay = ref({
month: new Date().getMonth(),
year: new Date().getFullYear,
});
const targetDateHour = ref($dayjs(new Date().toISOString()));
// console.log('huk = ', targetDate.value);
const formatForMonth = (date) => {
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
// return `${year}${(month < 10 ? '0' : '') + month}${(day < 10 ? '0' : '') + day}`;
return `${year}`;
};
const formatForDay = (date) => {
console.log('huk format date = ', date);
// return `${year}${(month < 10 ? '0' : '') + month}${(day < 10 ? '0' : '') + day}`;
return `${date.year}${(date.month + 1 < 10 ? '0' : '') + (date.month + 1)}`;
};
const formatForHour = (date) => {
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
const hour = date.getHours();
return `${year}${(month < 10 ? '0' : '') + month}${
(day < 10 ? '0' : '') + day
}`;
};
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: 'date_tag',
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',
'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' } };
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 {
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', {
start: (currentPageNumber.value - 1) * pageSize.value,
length: pageSize.value,
term: targetTerm.value,
// termPrefix: _utils.getDateTimeTag(targetTerm.value.substring(0, 1)),
// termPrefix: _utils.getDateTimeTag('y'),
termPrefix: targetDate.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 terms = ref([]);
const route = useRoute();
const hero = route.params.hero;
const targetTerm = ref('month');
const tmpTerms = [
{ current: targetTerm.value == 'year', key: 'year' },
{ current: targetTerm.value == 'month', key: 'month' },
{ current: targetTerm.value == 'day', key: 'day' },
{ current: targetTerm.value == 'hour', key: 'hour' },
];
terms.value = tmpTerms;
function handleDate(date) {
console.log('huk date = ', date);
let result = date;
switch (targetTerm.value) {
case 'year':
result = `${date}`;
break;
case 'month':
result = `${date}`;
break;
case 'day':
result = `${date.year}${
(date.month + 1 < 10 ? '0' : '') + (date.month + 1)
}`;
break;
case 'hour':
result = $dayjs(date).format('YYYYMMDD');
break;
}
targetDate.value = result;
console.log('huk result = ', result);
refresh();
}
function onChange(e) {
console.log('targetTerm.value=', targetTerm.value);
switch (targetTerm.value) {
case 'year':
targetDate.value = $dayjs(new Date().toISOString()).format('YYYY');
break;
case 'month':
targetDate.value = $dayjs(new Date().toISOString()).format('YYYY');
break;
case 'day':
targetDate.value = $dayjs(new Date().toISOString()).format(
'YYYYMM'
);
break;
case 'hour':
targetDate.value = $dayjs(new Date().toISOString()).format(
'YYYYMMDD'
);
break;
}
terms.value = [
{ current: targetTerm.value == 'year', key: 'year' },
{ current: targetTerm.value == 'month', key: 'month' },
{ current: targetTerm.value == 'day', key: 'day' },
{ current: targetTerm.value == 'hour', key: 'hour' },
];
refresh();
}
refresh();
</script>

View File

@@ -0,0 +1,245 @@
<!-- 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>
</div>
<div class="mt-5 bg-gray-100">
<div class="pt-12 sm:pt-16 lg:pt-20">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center">
<h2
class="text-3xl font-extrabold text-gray-900 sm:text-4xl lg:text-5xl"
>
이번달 사용량과 예상 비용
</h2>
<p class="mt-4 text-xl text-gray-600">
페이지를 보고 있는 시점까지 가공된 로그를
기준으로 사용량을 판정하여 비용을 예상해 보여
드립니다.
</p>
</div>
</div>
</div>
<div class="mt-8 bg-white pb-16 sm:mt-12 sm:pb-20 lg:pb-28">
<div class="relative">
<div class="absolute inset-0 h-1/2 bg-gray-100" />
<div
class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"
>
<div
class="max-w-lg mx-auto rounded-lg shadow-lg overflow-hidden lg:max-w-none lg:flex"
>
<div class="flex-1 bg-white px-6 py-8 lg:p-12">
<h3
class="text-2xl font-extrabold text-gray-900 sm:text-3xl"
>
실시간 사용량
</h3>
<ul
role="list"
class="mt-8 space-y-5 lg:space-y-0 lg:grid lg:grid-cols-2 lg:gap-x-8 lg:gap-y-5"
>
<li class="flex items-start lg:col-span-1">
<div class="flex-shrink-0">
<CheckCircleIcon
class="h-5 w-5 text-green-400"
aria-hidden="true"
/>
</div>
<p class="ml-1 text-sm text-gray-700">
호출 :
{{
_utils.formatNumberInBytesStyle(
total,
2
)
}}
</p>
</li>
<li class="flex items-start lg:col-span-1">
<div class="flex-shrink-0">
<CheckCircleIcon
class="h-5 w-5 text-green-400"
aria-hidden="true"
/>
</div>
<p class="ml-3 text-sm text-gray-700">
검출 :
{{
_utils.formatNumberInBytesStyle(
hit,
2
)
}}
</p>
</li>
<li class="flex items-start lg:col-span-1">
<div class="flex-shrink-0">
<CheckCircleIcon
class="h-5 w-5 text-green-400"
aria-hidden="true"
/>
</div>
<p class="ml-1 text-sm text-gray-700">
전송량 :
{{ _utils.formatBytes(size, 2) }}
</p>
</li>
<li class="flex items-start lg:col-span-1">
<div class="flex-shrink-0">
<CheckCircleIcon
class="h-5 w-5 text-green-400"
aria-hidden="true"
/>
</div>
<p class="ml-1 text-sm text-gray-700">
검출율 :
{{
(hitRatio * 100).toFixed(2) +
'%'
}}
</p>
</li>
</ul>
<div class="mt-8">
<ul>
<li
class="flex items-start lg:col-span-1"
>
<div class="flex-shrink-0">
<CheckCircleIcon
class="h-5 w-5 text-green-400"
aria-hidden="true"
/>
</div>
<p
class="ml-1 text-sm text-gray-700"
>
평균 전송량 :
{{
_utils.formatBytes(
avgSize,
2
)
}}
</p>
</li>
</ul>
</div>
</div>
<div
class="py-8 px-6 text-center bg-gray-50 lg:flex-shrink-0 lg:flex lg:flex-col lg:justify-center lg:p-12"
>
<p
class="text-lg leading-6 font-medium text-gray-900"
>
예상 요금
</p>
<div
class="mt-4 flex items-center justify-center text-4xl font-extrabold text-gray-900"
>
<span>
{{
_utils.formatNumberWithComma(
(total - 10 < 0
? 0
: total - 10) * 1
)
}}
</span>
<span
class="ml-3 text-xl font-medium text-gray-500"
>
</span>
</div>
<p class="mt-4 text-sm">
<a
href="javascript:void(0)"
class="font-medium text-gray-500 underline"
@click="navigateTo('/doc/bill')"
>
요금 계산 기준 보기
</a>
</p>
<div class="mt-6"></div>
<div class="mt-4 text-sm"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<nav class="space-y-1" aria-label="Sidebar">
<a
v-for="item in navigation"
:key="item.name"
href="javascript:void(0)"
:class="[
'text-gray-600 hover:bg-gray-100 hover:text-gray-900',
'flex items-center px-3 py-2 text-sm font-medium rounded-md',
]"
:aria-current="'page'"
@click="$router.push(item.href)"
>
<span class="truncate">
{{ item.name }}
</span>
</a>
</nav>
</div>
</template>
<script setup lang="ts">
import { CheckCircleIcon } from '@heroicons/vue/24/solid';
definePageMeta({
middleware: 'check-auth-op',
});
const total = ref(0);
const hit = ref(0);
const size = ref(0);
const hitRatio = ref(0);
const avgSize = ref(0);
const includedFeatures = [
'Private forum access',
'Member resources',
'Entry to annual conference',
'Official member t-shirt',
];
const navigation = [{ name: '상세 통계 보기', href: '/key/statistics/detail' }];
const responseJson = await _crossCtl.doComm('local/list', 'bill:month', {
start: 0,
length: 1,
});
if (responseJson['data'].length == 1) {
total.value = responseJson['data'][0]['total'];
hit.value = responseJson['data'][0]['hit'];
size.value = responseJson['data'][0]['size'];
hitRatio.value =
responseJson['data'][0]['hit'] / responseJson['data'][0]['total'];
avgSize.value =
responseJson['data'][0]['size'] / responseJson['data'][0]['total'];
}
console.log('huk responseJson = ', responseJson);
</script>

View File

@@ -0,0 +1,38 @@
<!-- This example requires Tailwind CSS v2.0+ -->
<template>
<div class="bg-white">
<div class="max-w-7xl mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8">
<div class="text-center">
<h2
class="text-base font-semibold text-indigo-600 tracking-wide uppercase"
>
API
</h2>
<p
class="mt-1 text-4xl font-extrabold text-gray-900 sm:text-5xl sm:tracking-tight lg:text-6xl"
>
필터 테스트
</p>
<p class="max-w-xl mt-5 mx-auto text-xl text-gray-500">
선택된 키의 필터 기능을 테스트 합니다.
<br />
검사할 텍스트
</p>
<br />
있는 페이지 :
<a href="javascript:void(0)" @click="$router.push('/key/list')">
API 리스트
</a>
,
<a href="javascript:void(0)" @click="$router.push('/')"> </a>
</div>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
middleware: 'check-auth-op',
});
</script>