1
1
<script setup lang="ts">
2
2
import { formatDuration , intervalToDuration } from ' date-fns' ;
3
- import { type AllSupportedUnits , type BitsUnits , displayStorageAndRateUnits } from ' ../data-storage-unit-converter/data-storage-unit-converter.service' ;
4
- import { amountTransferable , neededRate , transferTimeSeconds } from ' ./data-transfer-rate-converter.service' ;
3
+ import { type AllSupportedUnits , displayStorageAndRateUnits } from ' ../data-storage-unit-converter/data-storage-unit-converter.service' ;
4
+ import { amountTransferable , transferSpeedRate , transferTimeSeconds } from ' ./data-transfer-rate-converter.service' ;
5
5
6
6
const allStorateUnits = [
7
7
{ value: ' B' , label: ' Bytes (B)' },
@@ -35,6 +35,8 @@ const allBitsUnits = [
35
35
{ value: ' Yb' , label: ' Yottabits (Ybit)' },
36
36
];
37
37
38
+ const allRateUnits = [... allBitsUnits , ... allStorateUnits ];
39
+
38
40
function convertToTimeDisplay(seconds : number ) {
39
41
if (seconds === 0 ) {
40
42
return ' 0' ;
@@ -59,15 +61,15 @@ const transferTimeOutput = computed(() => {
59
61
dataSize: Number (transferTimeInput .value .dataSize ),
60
62
dataSizeUnit: transferTimeInput .value .dataSizeUnit as AllSupportedUnits ,
61
63
bitRate: Number (transferTimeInput .value .bitRate ),
62
- bitRateUnit: transferTimeInput .value .bitRateUnit as BitsUnits ,
64
+ bitRateUnit: transferTimeInput .value .bitRateUnit as AllSupportedUnits ,
63
65
}));
64
66
}
65
67
catch (e : any ) {
66
68
return e .toString ();
67
69
}
68
70
});
69
71
70
- const neededRateInput = ref <{
72
+ const transferSpeedRateInput = ref <{
71
73
dataSize: string
72
74
dataSizeUnit: string
73
75
hours: number
@@ -82,18 +84,18 @@ const neededRateInput = ref<{
82
84
seconds: 0 ,
83
85
bitRateUnit: ' Mb' ,
84
86
});
85
- const neededRateOutput = computed (() => {
87
+ const transferSpeedRateOutput = computed (() => {
86
88
try {
87
89
return displayStorageAndRateUnits ({
88
- unit: neededRateInput .value .bitRateUnit as BitsUnits ,
90
+ unit: transferSpeedRateInput .value .bitRateUnit as AllSupportedUnits ,
89
91
appendUnit: true ,
90
- value: neededRate ({
91
- dataSize: Number (neededRateInput .value .dataSize ),
92
- dataSizeUnit: neededRateInput .value .dataSizeUnit as AllSupportedUnits ,
93
- hours: neededRateInput .value .hours ,
94
- minutes: neededRateInput .value .minutes ,
95
- seconds: neededRateInput .value .seconds ,
96
- bitRateUnit: neededRateInput .value .bitRateUnit as BitsUnits ,
92
+ value: transferSpeedRate ({
93
+ dataSize: Number (transferSpeedRateInput .value .dataSize ),
94
+ dataSizeUnit: transferSpeedRateInput .value .dataSizeUnit as AllSupportedUnits ,
95
+ hours: transferSpeedRateInput .value .hours ,
96
+ minutes: transferSpeedRateInput .value .minutes ,
97
+ seconds: transferSpeedRateInput .value .seconds ,
98
+ bitRateUnit: transferSpeedRateInput .value .bitRateUnit as AllSupportedUnits ,
97
99
}),
98
100
});
99
101
}
@@ -124,7 +126,7 @@ const amountTransferableOutput = computed(() => {
124
126
appendUnit: true ,
125
127
value: amountTransferable ({
126
128
bitRate: Number (amountTransferableInput .value .bitRate ),
127
- bitRateUnit: amountTransferableInput .value .bitRateUnit as BitsUnits ,
129
+ bitRateUnit: amountTransferableInput .value .bitRateUnit as AllSupportedUnits ,
128
130
hours: amountTransferableInput .value .hours ,
129
131
minutes: amountTransferableInput .value .minutes ,
130
132
seconds: amountTransferableInput .value .seconds ,
@@ -157,7 +159,7 @@ const amountTransferableOutput = computed(() => {
157
159
<c-select
158
160
v-model:value =" transferTimeInput.bitRateUnit"
159
161
searchable
160
- :options =" allBitsUnits "
162
+ :options =" allRateUnits "
161
163
placeholder =" Select a bit rate unit"
162
164
ml-1
163
165
/>
@@ -171,35 +173,35 @@ const amountTransferableOutput = computed(() => {
171
173
placeholder =" Transfer time will be here..."
172
174
/>
173
175
</c-card >
174
- <c-card title =" Needed Bit Rate" mb-2 >
176
+ <c-card title =" Transfer Bit Rate/Speed " mb-2 >
175
177
<n-form-item label =" Data Size:" label-placement =" left" >
176
- <n-input v-model:value =" neededRateInput .dataSize" placeholder =" Data Size..." :min =" 0" w-full />
178
+ <n-input v-model:value =" transferSpeedRateInput .dataSize" placeholder =" Data Size..." :min =" 0" w-full />
177
179
<c-select
178
- v-model:value =" neededRateInput .dataSizeUnit"
180
+ v-model:value =" transferSpeedRateInput .dataSizeUnit"
179
181
:options =" allStorateUnits"
180
182
placeholder =" Select a storage unit"
181
183
ml-1
182
184
/>
183
185
</n-form-item >
184
186
185
187
<n-form-item label =" Duration (h/m/s):" label-placement =" left" >
186
- <n-input-number v-model:value =" neededRateInput .hours" mr-1 placeholder =" Hours" :min =" 0" w-full />
187
- <n-input-number v-model:value =" neededRateInput .minutes" mr-1 placeholder =" Minutes" :min =" 0" w-full />
188
- <n-input-number v-model:value =" neededRateInput .seconds" mr-1 placeholder =" Seconds" :min =" 0" w-full />
188
+ <n-input-number v-model:value =" transferSpeedRateInput .hours" mr-1 placeholder =" Hours" :min =" 0" w-full />
189
+ <n-input-number v-model:value =" transferSpeedRateInput .minutes" mr-1 placeholder =" Minutes" :min =" 0" w-full />
190
+ <n-input-number v-model:value =" transferSpeedRateInput .seconds" mr-1 placeholder =" Seconds" :min =" 0" w-full />
189
191
</n-form-item >
190
192
191
193
<n-divider />
192
194
193
195
<div flex items-baseline gap-2 >
194
196
<InputCopyable
195
- label =" Needed Bit Rate:"
197
+ label =" Transfer Bit Rate/Speed :"
196
198
label-position =" left"
197
- :value =" neededRateOutput "
198
- placeholder =" Needed Bit Rate will be here..."
199
+ :value =" transferSpeedRateOutput "
200
+ placeholder =" Bit Rate will be here..."
199
201
/>
200
202
<c-select
201
- v-model:value =" transferTimeInput .bitRateUnit"
202
- :options =" allBitsUnits "
203
+ v-model:value =" transferSpeedRateInput .bitRateUnit"
204
+ :options =" allRateUnits "
203
205
placeholder =" Select a bit rate unit"
204
206
ml-1
205
207
/>
@@ -210,7 +212,7 @@ const amountTransferableOutput = computed(() => {
210
212
<n-input v-model:value =" amountTransferableInput.bitRate" placeholder =" Bit Rate..." :min =" 0" w-full />
211
213
<c-select
212
214
v-model:value =" amountTransferableInput.bitRateUnit"
213
- :options =" allBitsUnits "
215
+ :options =" allRateUnits "
214
216
placeholder =" Select a bit rate unit"
215
217
ml-1
216
218
/>
0 commit comments