Skip to content

Commit 4598eba

Browse files
committed
feat(new tool): MAC Address Converter
1 parent 80e46c9 commit 4598eba

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

components.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ declare module '@vue/runtime-core' {
9191
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
9292
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
9393
IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default']
94-
IconMdiArrowRight: typeof import('~icons/mdi/arrow-right')['default']
9594
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
9695
IconMdiCamera: typeof import('~icons/mdi/camera')['default']
9796
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
@@ -128,6 +127,7 @@ declare module '@vue/runtime-core' {
128127
ListConverter: typeof import('./src/tools/list-converter/list-converter.vue')['default']
129128
LocaleSelector: typeof import('./src/modules/i18n/components/locale-selector.vue')['default']
130129
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
130+
MacAddressConverter: typeof import('./src/tools/mac-address-converter/mac-address-converter.vue')['default']
131131
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
132132
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
133133
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
@@ -171,8 +171,6 @@ declare module '@vue/runtime-core' {
171171
NTable: typeof import('naive-ui')['NTable']
172172
NTag: typeof import('naive-ui')['NTag']
173173
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
174-
NUpload: typeof import('naive-ui')['NUpload']
175-
NUploadDragger: typeof import('naive-ui')['NUploadDragger']
176174
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
177175
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
178176
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']

src/tools/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { tool as base64FileConverter } from './base64-file-converter';
22
import { tool as base64StringConverter } from './base64-string-converter';
33
import { tool as basicAuthGenerator } from './basic-auth-generator';
4+
import { tool as macAddressConverter } from './mac-address-converter';
45
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
56
import { tool as numeronymGenerator } from './numeronym-generator';
67
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -143,7 +144,15 @@ export const toolsByCategory: ToolCategory[] = [
143144
},
144145
{
145146
name: 'Network',
146-
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
147+
components: [
148+
ipv4SubnetCalculator,
149+
ipv4AddressConverter,
150+
ipv4RangeExpander,
151+
macAddressLookup,
152+
macAddressGenerator,
153+
macAddressConverter,
154+
ipv6UlaGenerator,
155+
],
147156
},
148157
{
149158
name: 'Math',
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Devices } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Mac address converter',
6+
path: '/mac-address-converter',
7+
description: 'Change the format of a MAC address and chose between different formats',
8+
keywords: [
9+
'converter',
10+
'mac',
11+
'address',
12+
'format',
13+
],
14+
component: () => import('./mac-address-converter.vue'),
15+
icon: Devices,
16+
});
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<script setup lang="ts">
2+
import InputCopyable from '../../components/InputCopyable.vue';
3+
4+
function convertMac(mac: string, group: number = 2, char: string = ':'): string {
5+
mac = mac.replace(/[\W_]+/g, '');
6+
return mac.match(new RegExp(`.{1,${group}}`, 'g'))!.join(char);
7+
}
8+
9+
const input = ref('AA:BB:CC:DD:EE:FF');
10+
11+
const formats = computed(() => [
12+
{
13+
label: 'Canonical IETF Format:',
14+
value: convertMac(input.value.toLocaleLowerCase()),
15+
},
16+
{
17+
label: 'Canonical Format:',
18+
value: convertMac(input.value, 2, '.'),
19+
},
20+
{
21+
label: 'Canonical IEEE Format:',
22+
value: convertMac(input.value.toLocaleUpperCase(), 2, '-'),
23+
},
24+
{
25+
label: 'Cisco:',
26+
value: convertMac(input.value.toLocaleLowerCase(), 4, '.'),
27+
},
28+
]);
29+
30+
const inputLabelAlignmentConfig = {
31+
labelPosition: 'left',
32+
labelWidth: '120px',
33+
labelAlign: 'right',
34+
};
35+
</script>
36+
37+
<template>
38+
<c-card>
39+
<c-input-text
40+
v-model:value="input"
41+
label="MAC address:"
42+
size="large"
43+
placeholder="Type a MAC address"
44+
clearable
45+
autocomplete="off"
46+
autocorrect="off"
47+
autocapitalize="off"
48+
spellcheck="false"
49+
mb-5
50+
/>
51+
52+
<div my-16px divider />
53+
54+
<InputCopyable
55+
v-for="format in formats"
56+
:key="format.label"
57+
:value="format.value"
58+
:label="format.label"
59+
v-bind="inputLabelAlignmentConfig"
60+
mb-1
61+
/>
62+
</c-card>
63+
</template>

0 commit comments

Comments
 (0)