2023-04-07 00:18:06 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
2023-05-15 00:41:45 +02:00
|
|
|
<c-input-text
|
|
|
|
v-model:value="macAddress"
|
|
|
|
label="MAC address:"
|
|
|
|
size="large"
|
|
|
|
placeholder="Type a MAC address"
|
|
|
|
clearable
|
|
|
|
autocomplete="off"
|
|
|
|
autocorrect="off"
|
|
|
|
autocapitalize="off"
|
|
|
|
spellcheck="false"
|
|
|
|
:validation-rules="macAddressValidationRules"
|
|
|
|
mb-5
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div mb-5px>Vendor info:</div>
|
|
|
|
<c-card mb-5>
|
|
|
|
<div v-if="details">
|
|
|
|
<div v-for="(detail, index) of details.split('\n')" :key="index">{{ detail }}</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-else italic op-60>Unknown vendor for this address</div>
|
|
|
|
</c-card>
|
|
|
|
|
|
|
|
<div flex justify-center>
|
2023-04-19 22:56:31 +02:00
|
|
|
<c-button :disabled="!details" @click="copy"> Copy vendor info </c-button>
|
2023-05-15 00:41:45 +02:00
|
|
|
</div>
|
2023-04-07 00:18:06 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import db from 'oui/oui.json';
|
2023-05-15 00:41:45 +02:00
|
|
|
import { macAddressValidationRules } from '@/utils/macAddress';
|
2023-04-19 22:56:31 +02:00
|
|
|
import { useCopy } from '@/composable/copy';
|
2023-04-07 00:18:06 +02:00
|
|
|
|
|
|
|
const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '').toUpperCase().substring(0, 6);
|
|
|
|
|
|
|
|
const macAddress = ref('20:37:06:12:34:56');
|
|
|
|
const details = computed<string | undefined>(() => db[getVendorValue(macAddress.value)]);
|
|
|
|
|
2023-04-19 22:56:31 +02:00
|
|
|
const { copy } = useCopy({ source: details, text: 'Vendor info copied to the clipboard' });
|
2023-04-07 00:18:06 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped></style>
|