mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-04 05:06:05 +08:00
Extract variables to utils/unit
Signed-off-by: Andy Lee <andy.lee@suse.com>
(cherry picked from commit 8db4de1c4a)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import UnitInput from '@shell/components/form/UnitInput';
|
||||
import InputOrDisplay from '@shell/components/InputOrDisplay';
|
||||
import { GIBIBYTE } from '../../utils/unit';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditCpuMemory',
|
||||
@@ -30,6 +31,7 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
GIBIBYTE,
|
||||
localCpu: this.cpu,
|
||||
localMemory: this.memory
|
||||
};
|
||||
@@ -63,7 +65,7 @@ export default {
|
||||
if (String(this.localMemory).includes('Gi')) {
|
||||
memory = this.localMemory;
|
||||
} else {
|
||||
memory = `${ this.localMemory }Gi`;
|
||||
memory = `${ this.localMemory }${ GIBIBYTE }`;
|
||||
}
|
||||
if (memory.includes('null')) {
|
||||
memory = null;
|
||||
@@ -113,7 +115,7 @@ export default {
|
||||
:output-modifier="true"
|
||||
:disabled="disabled"
|
||||
required
|
||||
suffix="Gi"
|
||||
:suffix="GIBIBYTE"
|
||||
class="mb-20"
|
||||
@update:value="change"
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import UnitInput from '@shell/components/form/UnitInput';
|
||||
|
||||
import { MEBIBYTE } from '../../utils/unit';
|
||||
export default {
|
||||
name: 'HarvesterReserved',
|
||||
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
},
|
||||
|
||||
data() {
|
||||
return { memory: this.reservedMemory };
|
||||
return { MEBIBYTE, memory: this.reservedMemory };
|
||||
},
|
||||
|
||||
watch: {
|
||||
@@ -47,7 +47,7 @@ export default {
|
||||
:input-exponent="2"
|
||||
:increment="1024"
|
||||
:output-modifier="true"
|
||||
suffix="Mi"
|
||||
:suffix="MEBIBYTE"
|
||||
@update:value="change"
|
||||
/>
|
||||
</template>
|
||||
|
||||
+3
-1
@@ -11,6 +11,7 @@ import { _CREATE } from '@shell/config/query-params';
|
||||
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
|
||||
import { HCI } from '../../../../types';
|
||||
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
|
||||
import { GIBIBYTE } from '../../../../utils/unit';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditExisting',
|
||||
@@ -59,6 +60,7 @@ export default {
|
||||
}
|
||||
|
||||
return {
|
||||
GIBIBYTE,
|
||||
VOLUME_TYPE,
|
||||
InterfaceOption,
|
||||
loading: false,
|
||||
@@ -254,7 +256,7 @@ export default {
|
||||
:label="t('harvester.fields.size')"
|
||||
:mode="mode"
|
||||
:disabled="true"
|
||||
suffix="Gi"
|
||||
:suffix="GIBIBYTE"
|
||||
@update:value="update"
|
||||
/>
|
||||
</InputOrDisplay>
|
||||
|
||||
@@ -12,6 +12,7 @@ import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
|
||||
import { _VIEW } from '@shell/config/query-params';
|
||||
import LabelValue from '@shell/components/LabelValue';
|
||||
import { ucFirst } from '@shell/utils/string';
|
||||
import { GIBIBYTE } from '../../../../utils/unit';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditVMImage',
|
||||
@@ -67,6 +68,7 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
GIBIBYTE,
|
||||
VOLUME_TYPE,
|
||||
InterfaceOption,
|
||||
loading: false,
|
||||
@@ -187,7 +189,7 @@ export default {
|
||||
minExponent: 3,
|
||||
});
|
||||
|
||||
this.value.size = `${ formatSize }Gi`;
|
||||
this.value.size = `${ formatSize }${ GIBIBYTE }`;
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
@@ -229,7 +231,7 @@ export default {
|
||||
if (!isIsoImage) {
|
||||
imageSizeGiB = Math.max(imageSizeGiB, 10);
|
||||
}
|
||||
this.value['size'] = `${ imageSizeGiB }Gi`;
|
||||
this.value['size'] = `${ imageSizeGiB }${ GIBIBYTE }`;
|
||||
}
|
||||
|
||||
this.update();
|
||||
@@ -336,7 +338,7 @@ export default {
|
||||
:mode="mode"
|
||||
:required="validateRequired"
|
||||
:disable="isLonghornV2"
|
||||
suffix="Gi"
|
||||
:suffix="GIBIBYTE"
|
||||
@update:value="update"
|
||||
/>
|
||||
</InputOrDisplay>
|
||||
|
||||
@@ -12,6 +12,7 @@ import LabelValue from '@shell/components/LabelValue';
|
||||
import { ucFirst } from '@shell/utils/string';
|
||||
import { LVM_DRIVER } from '../../../../models/harvester/storage.k8s.io.storageclass';
|
||||
import { DATA_ENGINE_V2 } from '../../../../models/harvester/persistentvolumeclaim';
|
||||
import { GIBIBYTE } from '../../../../utils/unit';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEditVolume',
|
||||
@@ -58,6 +59,7 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
GIBIBYTE,
|
||||
VOLUME_TYPE,
|
||||
InterfaceOption,
|
||||
loading: false,
|
||||
@@ -140,7 +142,7 @@ export default {
|
||||
minExponent: 3,
|
||||
});
|
||||
|
||||
this.value.size = `${ formatSize }Gi`;
|
||||
this.value.size = `${ formatSize }${ GIBIBYTE }`;
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
@@ -258,7 +260,7 @@ export default {
|
||||
:required="validateRequired"
|
||||
:label="t('harvester.fields.size')"
|
||||
:disabled="isLonghornV2"
|
||||
suffix="Gi"
|
||||
:suffix="GIBIBYTE"
|
||||
@update:value="update"
|
||||
/>
|
||||
</InputOrDisplay>
|
||||
|
||||
Reference in New Issue
Block a user