diff --git a/components/ContainerResourceLimit.vue b/components/ContainerResourceLimit.vue index 2bbbb2703a..2278c208cc 100644 --- a/components/ContainerResourceLimit.vue +++ b/components/ContainerResourceLimit.vue @@ -3,6 +3,7 @@ import isEmpty from 'lodash/isEmpty'; import UnitInput from '@/components/form/UnitInput'; import { CONTAINER_DEFAULT_RESOURCE_LIMIT } from '@/config/labels-annotations'; import { cleanUp } from '@/utils/object'; +import { _VIEW } from '@/config/query-params'; export default { components: { UnitInput }, @@ -42,7 +43,7 @@ export default { } = this.value; return { - limitsCpu, limitsMemory, requestsCpu, requestsMemory + limitsCpu, limitsMemory, requestsCpu, requestsMemory, viewMode: _VIEW }; }, diff --git a/components/form/UnitInput.vue b/components/form/UnitInput.vue index 737368e0fe..b7fab718fe 100644 --- a/components/form/UnitInput.vue +++ b/components/form/UnitInput.vue @@ -56,7 +56,7 @@ export default { default: null, }, - // LabeledInput props vv + // LabeledInput props mode: { type: String, default: _EDIT diff --git a/edit/autoscaling.horizontalpodautoscaler/metric-target.vue b/edit/autoscaling.horizontalpodautoscaler/metric-target.vue index 16405bc0ad..74e038d675 100644 --- a/edit/autoscaling.horizontalpodautoscaler/metric-target.vue +++ b/edit/autoscaling.horizontalpodautoscaler/metric-target.vue @@ -40,7 +40,6 @@ export default { value: 'AverageValue', specKey: 'averageValue', validTypes: ['resource', 'pod', 'object', 'external'], - default: '80', }, { label: this.t('hpa.metricTarget.utilization.label'), @@ -54,7 +53,6 @@ export default { value: 'Value', specKey: 'value', validTypes: ['object', 'external'], - default: '80', }, ]; @@ -74,6 +72,7 @@ export default { watch: { resourceName(newRn, _oldRn) { + // debugger; const { value: { type: metricType }, targetTypes, @@ -90,10 +89,11 @@ export default { } this.$set(this.value, match?.specKey, nueDefault); - this.quantity = match?.default ?? null; + this.quantity = nueDefault; }, 'value.type'(targetType, oldType) { + // debugger; const { targetTypes, resourceName } = this; const toDelete = findBy(targetTypes, { value: oldType }); const nue = findBy(targetTypes, { value: targetType }); @@ -110,7 +110,7 @@ export default { delete this.value[toDelete.specKey]; this.$set(this.value, nue?.specKey, nueDefault); - this.quantity = nue?.default ?? null; + this.quantity = nueDefault; }, }, @@ -138,20 +138,10 @@ export default { return quantity; }, updateQuantityValue(val) { - switch (this.value.type) { - case 'Value': + if (this.value?.type === 'Value') { this.$set(this.value, 'value', val); - break; - case 'AverageValue': - default: - if (this.resourceName === 'cpu') { - this.$set(this.value, 'averageValue', `${ val }m`); - } else if (this.resourceName === 'memory') { - this.$set(this.value, 'averageValue', `${ val }Mi`); - } else { - this.$set(this.value, 'averageValue', val); - } - break; + } else { + this.$set(this.value, 'averageValue', val); } }, }, diff --git a/edit/harvesterhci.io.volume.vue b/edit/harvesterhci.io.volume.vue index c914e113d0..9191497fb3 100644 --- a/edit/harvesterhci.io.volume.vue +++ b/edit/harvesterhci.io.volume.vue @@ -11,7 +11,6 @@ import { HCI } from '@/config/types'; import { sortBy } from '@/utils/sort'; import { InterfaceOption } from '@/config/harvester-map'; import { _CREATE } from '@/config/query-params'; -import { formatSi, parseSi } from '@/utils/units'; import CreateEditView from '@/mixins/create-edit-view'; import { HCI as HCI_ANNOTATIONS } from '@/config/labels-annotations'; @@ -39,7 +38,7 @@ export default { this.value.spec.accessModes = ['ReadWriteMany']; } - const storage = this.getSize(this.value.spec.resources.requests.storage); + const storage = this.value?.spec?.resources?.requests?.storage || null; const imageId = get(this.value, `metadata.annotations."${ HCI_ANNOTATIONS.IMAGE_ID }"`); const source = !imageId ? 'blank' : 'url'; @@ -107,7 +106,7 @@ export default { const spec = { ...this.value.spec, - resources: { requests: { storage: `${ this.storage }Gi` } }, + resources: { requests: { storage: this.storage } }, storageClassName }; @@ -116,20 +115,6 @@ export default { this.$set(this.value, 'spec', spec); }, - getSize(storage, addSuffix = false) { - if (!storage) { - return null; - } - - const kibUnitSize = parseSi(storage); - - return formatSi(kibUnitSize, { - addSuffix, - increment: 1024, - minExponent: 3, - maxExponent: 3 - }); - } } }; @@ -174,7 +159,9 @@ export default {