2024-07-28 20:25:09 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { raidCalculations } from './raid-calculator.service';
|
2024-07-29 19:50:37 +00:00
|
|
|
import { UNIT_BASE, formatBytes } from '@/utils/convert';
|
2024-07-28 20:25:09 +00:00
|
|
|
|
|
|
|
const diskTotal = ref(2);
|
|
|
|
const diskSize = ref(100);
|
2024-07-29 19:50:37 +00:00
|
|
|
const diskUnit = ref(10 ** 9);
|
2024-07-28 20:25:09 +00:00
|
|
|
const raidType = ref('raid_0');
|
|
|
|
const raidInfo = computed(() => raidCalculations[raidType.value].about);
|
|
|
|
const raidRequirements = computed(() => raidCalculations[raidType.value].requirements);
|
|
|
|
const inputsValid = computed(() => validateSetup());
|
|
|
|
|
|
|
|
const calculatedCapacity = computed(() => {
|
2024-07-29 13:52:23 +00:00
|
|
|
return formatBytes(raidCalculations[raidType.value].capacity(diskTotal.value, diskSize.value, diskUnit.value), 2, UNIT_BASE.BASE_10);
|
2024-07-28 20:25:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const calculatedFaultTolerance = computed(() => {
|
|
|
|
return raidCalculations[raidType.value].fault(diskTotal.value, diskSize.value, diskUnit.value);
|
|
|
|
});
|
|
|
|
|
2024-07-29 20:30:31 +00:00
|
|
|
const calculatedSpaceEfficiency = computed(() => {
|
|
|
|
return raidCalculations[raidType.value].efficiency(diskTotal.value);
|
|
|
|
});
|
|
|
|
|
2024-07-29 19:50:37 +00:00
|
|
|
function validateSetup() {
|
2024-07-28 20:25:09 +00:00
|
|
|
// validate the selected RAID type against parameters
|
|
|
|
return raidCalculations[raidType.value].validate(diskTotal.value, diskSize.value);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<c-card>
|
|
|
|
<n-form-item label="Number of disks" label-placement="left" label-width="150" mb-2>
|
|
|
|
<n-input-number v-model:value="diskTotal" max="10000" min="2" placeholder="Number of disks (ex: 2)" w-full />
|
|
|
|
</n-form-item>
|
|
|
|
|
|
|
|
<n-form-item label="Disk size" label-placement="left" label-width="150" mb-2>
|
|
|
|
<n-input-number v-model:value="diskSize" max="10000" min="1" placeholder="Disk size (ex: 100)" w-full />
|
|
|
|
<div flex items-baseline gap-2>
|
|
|
|
<c-select
|
|
|
|
v-model:value="diskUnit"
|
|
|
|
min-w-130px
|
2024-07-29 13:06:42 +00:00
|
|
|
ml-1
|
2024-07-28 20:25:09 +00:00
|
|
|
:options="[
|
2024-07-29 19:50:37 +00:00
|
|
|
{ label: 'MB', value: 10 ** 6 },
|
|
|
|
{ label: 'GB', value: 10 ** 9 },
|
|
|
|
{ label: 'TB', value: 10 ** 12 },
|
|
|
|
{ label: 'PB', value: 10 ** 15 },
|
2024-07-28 20:25:09 +00:00
|
|
|
]"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</n-form-item>
|
|
|
|
<n-form-item label="RAID Type" label-placement="left" label-width="150" mb-2>
|
|
|
|
<c-select
|
|
|
|
v-model:value="raidType"
|
|
|
|
w-full
|
|
|
|
:options="[
|
|
|
|
{ label: 'RAID 0 (stripe)', value: 'raid_0' },
|
|
|
|
{ label: 'RAID 1 (mirror)', value: 'raid_1' },
|
|
|
|
{ label: 'RAID 5 (parity)', value: 'raid_5' },
|
|
|
|
{ label: 'RAID 6 (double parity)', value: 'raid_6' },
|
|
|
|
{ label: 'RAID 10 (mirror + stripe)', value: 'raid_10' },
|
|
|
|
]"
|
|
|
|
/>
|
|
|
|
</n-form-item>
|
2024-07-29 19:50:37 +00:00
|
|
|
<p v-if="!inputsValid" class="raidError">
|
|
|
|
{{ raidRequirements }}
|
|
|
|
</p>
|
|
|
|
<p v-html="raidInfo" />
|
2024-07-28 20:25:09 +00:00
|
|
|
</c-card>
|
|
|
|
<c-card title="Results">
|
2024-07-29 13:32:13 +00:00
|
|
|
<n-table v-if="inputsValid">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2024-07-29 19:50:37 +00:00
|
|
|
<td font-bold width="30%">
|
|
|
|
Capacity
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ calculatedCapacity }}
|
|
|
|
</td>
|
2024-07-29 13:32:13 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2024-07-29 19:50:37 +00:00
|
|
|
<td font-bold width="30%">
|
|
|
|
Fault Tolerance
|
|
|
|
</td>
|
2024-07-29 20:30:31 +00:00
|
|
|
<td>
|
2024-07-29 13:32:13 +00:00
|
|
|
{{ calculatedFaultTolerance }}
|
|
|
|
</td>
|
|
|
|
</tr>
|
2024-07-29 20:30:31 +00:00
|
|
|
<tr>
|
|
|
|
<td font-bold width="30%">
|
|
|
|
Space Efficiency
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ calculatedSpaceEfficiency }}%
|
|
|
|
</td>
|
|
|
|
</tr>
|
2024-07-29 13:32:13 +00:00
|
|
|
</tbody>
|
|
|
|
</n-table>
|
2024-07-28 20:25:09 +00:00
|
|
|
</c-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
.raidError {
|
|
|
|
color: rgb(208, 48, 80)
|
|
|
|
}
|
|
|
|
</style>
|