Skip to content

Commit cb35e89

Browse files
author
kei5uke
committed
fix: flabor -> machine_type
1 parent 535478b commit cb35e89

5 files changed

Lines changed: 53 additions & 86 deletions

File tree

docs/.vitepress/theme/components/price-estimator/LabCard.vue

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ let editingComputeItem: ComputeUnit | null = null
1717
1818
const computeHeaders = ref<DataTableHeader[]>([
1919
{ title: "Name", align: "start", sortable: true, key: "name" },
20-
{ title: "Machine type", align: "start", sortable: true, key: "flavor" },
20+
{ title: "Machine type", align: "start", sortable: true, key: "machine_type" },
2121
{ title: "CPU cores", align: "start", sortable: true, key: "core_count" },
2222
{ title: "Memory [GB]", align: "start", sortable: true, key: "ram" },
2323
{ title: "GPU", align: "start", sortable: true, key: "gpu" },
24-
{ title: "Type", align: "start", sortable: true, key: "type" },
24+
{ title: "Subscription", align: "start", sortable: true, key: "subscription" },
2525
{ title: "Price / month", align: "start", sortable: true, key: "monthlyPrice" },
2626
{ title: "Price / year", align: "start", sortable: true, key: "yearlyPrice" },
2727
{ title: "Actions", key: "actions", align: "end", sortable: false },
@@ -57,18 +57,14 @@ const storageLabSum = computed(() => {
5757
})
5858
5959
const LabSum = computed(() => {
60-
return (
61-
computeLabSum.value.yearlyCostTotal +
62-
storageLabSum.value.HDD.yearlyCostTotal +
63-
storageLabSum.value.NVME.yearlyCostTotal
64-
)
60+
return computeLabSum.value.yearlyCostTotal + storageLabSum.value.HDD.yearlyCostTotal + storageLabSum.value.NVME.yearlyCostTotal
6561
})
6662
6763
const localTitle = ref(props.lab.title)
6864
6965
watch(
7066
() => props.lab.title,
71-
val => {
67+
(val) => {
7268
localTitle.value = val
7369
},
7470
)
@@ -148,13 +144,7 @@ const removeStorageById = (storageId: number) => {
148144
<v-card flat>
149145
<v-card-title>Compute</v-card-title>
150146

151-
<v-data-table-virtual
152-
:items="selectedCompute"
153-
:headers="computeHeaders"
154-
hide-default-footer
155-
hover
156-
item-value="id"
157-
>
147+
<v-data-table-virtual :items="selectedCompute" :headers="computeHeaders" hide-default-footer hover item-value="id">
158148
<template v-slot:item.monthlyPrice="{ item }">
159149
{{ item.monthlyPrice.toFixed(2) + " kr" }}
160150
</template>
@@ -163,18 +153,8 @@ const removeStorageById = (storageId: number) => {
163153
</template>
164154
<template v-slot:item.actions="{ item }">
165155
<div class="d-flex ga-2 justify-end">
166-
<v-icon
167-
color="medium-emphasis"
168-
icon="mdi-pencil"
169-
size="small"
170-
@click="editCompute(selectedCompute.find(c => c.id === item.id)!)"
171-
></v-icon>
172-
<v-icon
173-
color="medium-emphasis"
174-
icon="mdi-delete"
175-
size="small"
176-
@click="removeComputeById(item.id)"
177-
></v-icon>
156+
<v-icon color="medium-emphasis" icon="mdi-pencil" size="small" @click="editCompute(selectedCompute.find((c) => c.id === item.id)!)"></v-icon>
157+
<v-icon color="medium-emphasis" icon="mdi-delete" size="small" @click="removeComputeById(item.id)"></v-icon>
178158
</div>
179159
</template>
180160

@@ -229,18 +209,8 @@ const removeStorageById = (storageId: number) => {
229209
</template>
230210
<template v-slot:item.actions="{ item }">
231211
<div class="d-flex ga-2 justify-end">
232-
<v-icon
233-
color="medium-emphasis"
234-
icon="mdi-pencil"
235-
size="small"
236-
@click="editStorage(selectedStorage.find(s => s.id === item.id)!)"
237-
></v-icon>
238-
<v-icon
239-
color="medium-emphasis"
240-
icon="mdi-delete"
241-
size="small"
242-
@click="removeStorageById(item.id)"
243-
></v-icon>
212+
<v-icon color="medium-emphasis" icon="mdi-pencil" size="small" @click="editStorage(selectedStorage.find((s) => s.id === item.id)!)"></v-icon>
213+
<v-icon color="medium-emphasis" icon="mdi-delete" size="small" @click="removeStorageById(item.id)"></v-icon>
244214
</div>
245215
</template>
246216

@@ -290,22 +260,11 @@ const removeStorageById = (storageId: number) => {
290260
</v-sheet>
291261

292262
<v-dialog v-model="isComputeModalOpen" max-width="600px" min-width="600px">
293-
<MachineModal
294-
:lab-id="lab.id"
295-
:compute-id="lab.selectedCompute.length"
296-
:edit-data="editingComputeItem"
297-
@close="closeComputeModal"
298-
@open-snackbar="openSnackbar"
299-
/>
263+
<MachineModal :lab-id="lab.id" :compute-id="lab.selectedCompute.length" :edit-data="editingComputeItem" @close="closeComputeModal" @open-snackbar="openSnackbar" />
300264
</v-dialog>
301265

302266
<v-dialog v-model="isStorageModalOpen" max-width="600px" min-width="600px">
303-
<StorageModal
304-
:lab-id="lab.id"
305-
:storage-id="lab.selectedStorage.length"
306-
:edit-data="editingStorageItem"
307-
@close="closeStorageModal"
308-
/>
267+
<StorageModal :lab-id="lab.id" :storage-id="lab.selectedStorage.length" :edit-data="editingStorageItem" @close="closeStorageModal" />
309268
</v-dialog>
310269

311270
<v-snackbar v-model="snackbar.show">{{ snackbar.message }}</v-snackbar>

docs/.vitepress/theme/components/price-estimator/LabModal.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const emit = defineEmits<{
1010
const formData = ref({
1111
name: "",
1212
subscription: "1Y",
13-
machineFlavor: "default.c1",
13+
machineType: "default.c1",
1414
machineSubscription: "COMMITMENT_1Y",
1515
hddSize: 1,
1616
nvmeSize: 0,
@@ -32,15 +32,15 @@ const machineSubscriptions = [
3232
{ title: "Commitment - 3 Years", value: "COMMITMENT_3Y" },
3333
]
3434
35-
const machineFlavors = computed(() => {
35+
const machineType = computed(() => {
3636
return priceEstimatorStore.catalogue.machinePrices
3737
})
3838
3939
const save = () => {
4040
priceEstimatorStore.addLab({
4141
name: formData.value.name,
4242
subscription: formData.value.subscription,
43-
machineType: formData.value.machineFlavor,
43+
machineType: formData.value.machineType,
4444
machineSubscription: formData.value.machineSubscription,
4545
hddSize: Number(formData.value.hddSize),
4646
nvmeSize: Number(formData.value.nvmeSize),
@@ -68,7 +68,7 @@ onMounted(() => {
6868
</v-col>
6969

7070
<v-col cols="12">
71-
<v-autocomplete v-model="formData.machineFlavor" :items="machineFlavors" label="Default Home Machine" variant="outlined" item-title="title" item-value="value">
71+
<v-autocomplete v-model="formData.machineType" :items="machineType" label="Default Home Machine" variant="outlined" item-title="title" item-value="value">
7272
<template #item="{ item, props }">
7373
<VDivider v-if="'divider' in item.raw" />
7474
<VListSubheader v-else-if="'header' in item.raw" :title="item.raw.header" />

docs/.vitepress/theme/components/price-estimator/MachineModal.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const getGpuPriceMonth = computed((): string | number => {
7474
return yearlyGpu ? Number(yearlyGpu / 12).toFixed(2) : 0
7575
})
7676
77-
const getFlavors = computed((): MachineType[] => {
77+
const getMachineType = computed((): MachineType[] => {
7878
if (!formData.value.subscription) {
7979
return []
8080
}
@@ -107,14 +107,14 @@ const save = () => {
107107
.split(" / ")
108108
const core_count = parseInt(machinetitle[0].split(" ")[0])
109109
const ram = parseInt(machinetitle[1].split(" ")[0])
110-
const flavorWithGpu = formData.value.machine_type
110+
const machineWithGpu = formData.value.machine_type
111111
const subscription = formData.value.subscription
112112
const gpu = formData.value.gpu
113113
114114
if (props.editData) {
115115
priceEstimatorStore.editComputeInLab(props.labId, props.editData.id, {
116116
name: name!,
117-
machine_type: flavorWithGpu,
117+
machine_type: machineWithGpu,
118118
core_count: core_count,
119119
ram: ram,
120120
subscription: subscription!,
@@ -124,7 +124,7 @@ const save = () => {
124124
// Add new compute
125125
priceEstimatorStore.addComputeToLab(props.labId, {
126126
name: name!,
127-
machine_type: flavorWithGpu!,
127+
machine_type: machineWithGpu!,
128128
core_count: core_count,
129129
ram: ram,
130130
subscription: subscription!,
@@ -172,7 +172,15 @@ onMounted(() => {
172172
</v-autocomplete>
173173
</v-col>
174174
<v-col cols="12">
175-
<v-autocomplete v-model="formData.machine_type" :items="getFlavors" label="Machine type" variant="outlined" required :disabled="!formData.subscription" width="100%">
175+
<v-autocomplete
176+
v-model="formData.machine_type"
177+
:items="getMachineType"
178+
label="Machine type"
179+
variant="outlined"
180+
required
181+
:disabled="!formData.subscription"
182+
width="100%"
183+
>
176184
<template #item="{ item, props }">
177185
<VDivider v-if="'divider' in item.raw" />
178186
<VListSubheader v-else-if="'header' in item.raw" :title="item.raw.header" />

docs/.vitepress/theme/components/price-estimator/stores/priceEstimatorStore.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,36 +406,36 @@ export const priceEstimatorStore = reactive({
406406

407407
/* Compute helpers */
408408

409-
getComputePriceFromCatalogue(flavor: string, type: string, gpuFlavor?: string) {
409+
getComputePriceFromCatalogue(machineType: string, type: string, machineWithGpu?: string) {
410410
let totalYearlyPrice = 0
411411
let totalMonthlyPrice = 0
412-
let mainFlavorPrice: number | undefined
412+
let mainMachineTypePrice: number | undefined
413413
let gpuYearly: number | undefined
414414

415415
if (type.includes("COMMITMENT")) {
416416
if (type === "COMMITMENT_3Y") {
417-
const found3Y = this.catalogue.computePrices.find((p) => p["service.unit"] === flavor && p["service.level"] === "COMMITMENT" && p["service.commitment"] === "3Y")
417+
const found3Y = this.catalogue.computePrices.find((p) => p["service.unit"] === machineType && p["service.level"] === "COMMITMENT" && p["service.commitment"] === "3Y")
418418
if (found3Y) {
419-
mainFlavorPrice = found3Y["price.nok.ex.vat"] / 3
419+
mainMachineTypePrice = found3Y["price.nok.ex.vat"] / 3
420420
}
421421
} else {
422-
mainFlavorPrice = this.catalogue.computePrices.find((p) => p["service.unit"] === flavor && p["service.level"] === "COMMITMENT" && p["service.commitment"] === "1Y")?.[
423-
"price.nok.ex.vat"
424-
]
422+
mainMachineTypePrice = this.catalogue.computePrices.find(
423+
(p) => p["service.unit"] === machineType && p["service.level"] === "COMMITMENT" && p["service.commitment"] === "1Y",
424+
)?.["price.nok.ex.vat"]
425425
}
426426
} else {
427-
const foundPrice = this.catalogue.computePrices.find((p) => p["service.unit"] === flavor && p["service.level"] === type)
428-
mainFlavorPrice = foundPrice?.["price.nok.ex.vat"]
427+
const foundPrice = this.catalogue.computePrices.find((p) => p["service.unit"] === machineType && p["service.level"] === type)
428+
mainMachineTypePrice = foundPrice?.["price.nok.ex.vat"]
429429
}
430430

431-
if (mainFlavorPrice) {
432-
totalYearlyPrice += mainFlavorPrice
431+
if (mainMachineTypePrice) {
432+
totalYearlyPrice += mainMachineTypePrice
433433
}
434434

435435
totalMonthlyPrice = Number(totalYearlyPrice / 12)
436436

437-
if (gpuFlavor) {
438-
const gpuPrice = this.catalogue.gpuPrices.find((p) => p["service.unit"] === gpuFlavor && p["service.level"] === "ONDEMAND")
437+
if (machineWithGpu) {
438+
const gpuPrice = this.catalogue.gpuPrices.find((p) => p["service.unit"] === machineWithGpu && p["service.level"] === "ONDEMAND")
439439
if (gpuPrice) {
440440
gpuYearly = gpuPrice["price.nok.ex.vat"]
441441
totalYearlyPrice += gpuYearly

tests/PriceEstimator.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ vi.mock("../docs/.vitepress/theme/components/price-estimator/api/pricesApi.js",
7979
default: {
8080
getPriceList: vi.fn().mockResolvedValue(mockPriceList),
8181
getAvailableGPUS: vi.fn().mockResolvedValue([]),
82-
getMachineFlavors: vi.fn().mockResolvedValue([
82+
getMachineTypes: vi.fn().mockResolvedValue([
8383
{
8484
value: "default.c1",
8585
title: "Default - 4 cores / 8 GB",
@@ -302,7 +302,7 @@ describe("PriceEstimator", () => {
302302
priceEstimatorStore.addLab({
303303
name: "Lab 1",
304304
subscription: "1Y",
305-
machineFlavor: "default.c1",
305+
machineType: "default.c1",
306306
machineSubscription: "COMMITMENT_1Y",
307307
hddSize: 1,
308308
nvmeSize: 0,
@@ -313,7 +313,7 @@ describe("PriceEstimator", () => {
313313
priceEstimatorStore.addLab({
314314
name: "Lab 2",
315315
subscription: "1Y",
316-
machineFlavor: "default.c1",
316+
machineType: "default.c1",
317317
machineSubscription: "COMMITMENT_1Y",
318318
hddSize: 1,
319319
nvmeSize: 0,
@@ -326,15 +326,15 @@ describe("PriceEstimator", () => {
326326
priceEstimatorStore.addLab({
327327
name: "Lab 1",
328328
subscription: "1Y",
329-
machineFlavor: "default.c1",
329+
machineType: "default.c1",
330330
machineSubscription: "COMMITMENT_1Y",
331331
hddSize: 1,
332332
nvmeSize: 0,
333333
})
334334
priceEstimatorStore.addLab({
335335
name: "Lab 2",
336336
subscription: "1Y",
337-
machineFlavor: "default.c1",
337+
machineType: "default.c1",
338338
machineSubscription: "COMMITMENT_1Y",
339339
hddSize: 1,
340340
nvmeSize: 0,
@@ -343,7 +343,7 @@ describe("PriceEstimator", () => {
343343
priceEstimatorStore.addLab({
344344
name: "Lab 3",
345345
subscription: "1Y",
346-
machineFlavor: "default.c1",
346+
machineType: "default.c1",
347347
machineSubscription: "COMMITMENT_1Y",
348348
hddSize: 1,
349349
nvmeSize: 0,
@@ -362,7 +362,7 @@ describe("PriceEstimator", () => {
362362
priceEstimatorStore.addLab({
363363
name: "Lab 1",
364364
subscription: "1Y",
365-
machineFlavor: "default.c1",
365+
machineType: "default.c1",
366366
machineSubscription: "COMMITMENT_1Y",
367367
hddSize: 1,
368368
nvmeSize: 0,
@@ -392,7 +392,7 @@ describe("PriceEstimator", () => {
392392
priceEstimatorStore.addLab({
393393
name: "Lab 1",
394394
subscription: "1Y",
395-
machineFlavor: "default.c1",
395+
machineType: "default.c1",
396396
machineSubscription: "COMMITMENT_1Y",
397397
hddSize: 1,
398398
nvmeSize: 0,
@@ -423,7 +423,7 @@ describe("PriceEstimator", () => {
423423
priceEstimatorStore.addLab({
424424
name: "Lab 1",
425425
subscription: "1Y",
426-
machineFlavor: "default.c1",
426+
machineType: "default.c1",
427427
machineSubscription: "COMMITMENT_1Y",
428428
hddSize: 1,
429429
nvmeSize: 0,
@@ -453,7 +453,7 @@ describe("PriceEstimator", () => {
453453
priceEstimatorStore.addLab({
454454
name: "Lab 1",
455455
subscription: "1Y",
456-
machineFlavor: "default.c1",
456+
machineType: "default.c1",
457457
machineSubscription: "COMMITMENT_1Y",
458458
hddSize: 1,
459459
nvmeSize: 0,
@@ -485,7 +485,7 @@ describe("PriceEstimator", () => {
485485
priceEstimatorStore.addLab({
486486
name: "Lab 1",
487487
subscription: "1Y",
488-
machineFlavor: "default.c1",
488+
machineType: "default.c1",
489489
machineSubscription: "COMMITMENT_1Y",
490490
hddSize: 1,
491491
nvmeSize: 0,
@@ -512,7 +512,7 @@ describe("PriceEstimator", () => {
512512
priceEstimatorStore.addLab({
513513
name: "Lab 2",
514514
subscription: "1Y",
515-
machineFlavor: "default.c1",
515+
machineType: "default.c1",
516516
machineSubscription: "COMMITMENT_1Y",
517517
hddSize: 1,
518518
nvmeSize: 0,

0 commit comments

Comments
 (0)