it-tools/src/tools/mac-address-lookup/mac-address-lookup.vue
Corentin THOMASSET 86e964a274
fix(copy): prevent shorthand copy if source is present in useCopy (#559)
* fix(copy): prevent shorthand copy if source is present in useCopy

* refactor(copy): normalized copy usage
2023-08-09 22:07:44 +00:00

51 lines
1.3 KiB
Vue

<script setup lang="ts">
import db from 'oui/oui.json';
import { macAddressValidationRules } from '@/utils/macAddress';
import { useCopy } from '@/composable/copy';
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)]);
const { copy } = useCopy({ source: details, text: 'Vendor info copied to the clipboard' });
</script>
<template>
<div>
<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>
<c-button :disabled="!details" @click="copy()">
Copy vendor info
</c-button>
</div>
</div>
</template>