bfg-common 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/vm/actions/add/Add.vue +1 -1
- package/components/common/vm/actions/add/FolderTreeView.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/CustomizeHardware.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/CoresPerSocket.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/Cpu.vue +371 -368
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/CpuModel.vue +2 -2
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/MaxCpu.vue +105 -99
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/shares/Shares.vue +155 -151
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/Limit.vue +214 -210
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/Memory.vue +282 -278
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/Location.vue +10 -10
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +10 -6
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/cache/Cache.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/limitIops/LimitIops.vue +7 -3
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/provisioning/Provisioning.vue +2 -2
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newNetwork/Location.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +256 -252
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newNetwork/adapterType/AdapterType.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newNetwork/macAddress/MacAddress.vue +6 -6
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/newUsbController/NewUsbController.vue +3 -3
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/reservation/Reservation.vue +231 -228
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/videoCard/TotalVideoMemory.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/videoCard/VideoCard.vue +173 -169
- package/components/common/vm/actions/add/customizeHardware/virtualHardware/videoCard/numberDisplays/NumberDisplays.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/Vmoptions.vue +145 -141
- package/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/BootOptions.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/firmware/Firmware.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/RemoteConsoleOptions.vue +230 -226
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/imgCompression/ImgCompression.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/jpegCompression/JpegCompression.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/mouseMode/MouseMode.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/streamingMode/StreamingMode.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/type/Type.vue +1 -1
- package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/zlibCompression/ZlibCompression.vue +1 -1
- package/components/common/vm/actions/add/select/compatibility/Compatibility.vue +6 -6
- package/components/common/vm/actions/add/select/os/os.vue +7 -7
- package/package.json +1 -1
|
@@ -152,7 +152,7 @@ watch(
|
|
|
152
152
|
}
|
|
153
153
|
)
|
|
154
154
|
|
|
155
|
-
const passthroughHostCpuLocal = computed({
|
|
155
|
+
const passthroughHostCpuLocal = computed<boolean>({
|
|
156
156
|
get() {
|
|
157
157
|
return props.passthroughHostCpu
|
|
158
158
|
},
|
|
@@ -160,7 +160,7 @@ const passthroughHostCpuLocal = computed({
|
|
|
160
160
|
emits('update:passthrough-host-cpu', newValue)
|
|
161
161
|
},
|
|
162
162
|
})
|
|
163
|
-
const hostModelCpuLocal = computed({
|
|
163
|
+
const hostModelCpuLocal = computed<boolean>({
|
|
164
164
|
get() {
|
|
165
165
|
return props.hostModelCpu
|
|
166
166
|
},
|
|
@@ -1,99 +1,105 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="">
|
|
3
|
-
<atoms-stack-block :has-children="false">
|
|
4
|
-
<template #stackBlockKey>
|
|
5
|
-
{{ localization.maxCpu }}
|
|
6
|
-
</template>
|
|
7
|
-
<template #stackBlockContent>
|
|
8
|
-
<div class="flex-align-center">
|
|
9
|
-
<atoms-tooltip-error
|
|
10
|
-
:has-error="!!maxVcpusLocalAndApiErrorsTexts"
|
|
11
|
-
selector="#vm-wizard-max-vcpus-field input"
|
|
12
|
-
@remove="emits('remove-error-by-title', 'cpu.max_vcpus')"
|
|
13
|
-
>
|
|
14
|
-
<template #elem>
|
|
15
|
-
<atoms-combobox
|
|
16
|
-
id="vm-wizard-max-vcpus-field"
|
|
17
|
-
v-model.number="selectedMaxCpuLocal"
|
|
18
|
-
:items="cpuOptions"
|
|
19
|
-
:disabled="props.disabled"
|
|
20
|
-
@click.stop
|
|
21
|
-
/>
|
|
22
|
-
</template>
|
|
23
|
-
<template #content>{{ maxVcpusLocalAndApiErrorsTexts }}</template>
|
|
24
|
-
</atoms-tooltip-error>
|
|
25
|
-
</div>
|
|
26
|
-
</template>
|
|
27
|
-
</atoms-stack-block>
|
|
28
|
-
</div>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script setup lang="ts">
|
|
32
|
-
import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
|
|
33
|
-
import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const props = defineProps<{
|
|
37
|
-
cpuOptions: UI_I_OptionItem[]
|
|
38
|
-
selectedMaxCpu: number
|
|
39
|
-
disabled: boolean
|
|
40
|
-
errorValidationFields: UI_I_ErrorValidationField<string>[]
|
|
41
|
-
}>()
|
|
42
|
-
const emits = defineEmits<{
|
|
43
|
-
(event: 'update:selected-max-cpu', value: number): void
|
|
44
|
-
(event: 'invalid', value: boolean): void
|
|
45
|
-
(event: 'remove-error-by-title', value: string): void
|
|
46
|
-
}>()
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (localError && apiError) result = localError
|
|
89
|
-
if (!localError && apiError) result = apiError
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="">
|
|
3
|
+
<atoms-stack-block :has-children="false">
|
|
4
|
+
<template #stackBlockKey>
|
|
5
|
+
{{ localization.maxCpu }}
|
|
6
|
+
</template>
|
|
7
|
+
<template #stackBlockContent>
|
|
8
|
+
<div class="flex-align-center">
|
|
9
|
+
<atoms-tooltip-error
|
|
10
|
+
:has-error="!!maxVcpusLocalAndApiErrorsTexts"
|
|
11
|
+
selector="#vm-wizard-max-vcpus-field input"
|
|
12
|
+
@remove="emits('remove-error-by-title', 'cpu.max_vcpus')"
|
|
13
|
+
>
|
|
14
|
+
<template #elem>
|
|
15
|
+
<atoms-combobox
|
|
16
|
+
id="vm-wizard-max-vcpus-field"
|
|
17
|
+
v-model.number="selectedMaxCpuLocal"
|
|
18
|
+
:items="cpuOptions"
|
|
19
|
+
:disabled="props.disabled"
|
|
20
|
+
@click.stop
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
<template #content>{{ maxVcpusLocalAndApiErrorsTexts }}</template>
|
|
24
|
+
</atoms-tooltip-error>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
</atoms-stack-block>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
|
|
33
|
+
import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
|
|
34
|
+
import { UI_I_Localization } from '~/models/interfaces'
|
|
35
|
+
|
|
36
|
+
const props = defineProps<{
|
|
37
|
+
cpuOptions: UI_I_OptionItem[]
|
|
38
|
+
selectedMaxCpu: number
|
|
39
|
+
disabled: boolean
|
|
40
|
+
errorValidationFields: UI_I_ErrorValidationField<string>[]
|
|
41
|
+
}>()
|
|
42
|
+
const emits = defineEmits<{
|
|
43
|
+
(event: 'update:selected-max-cpu', value: number): void
|
|
44
|
+
(event: 'invalid', value: boolean): void
|
|
45
|
+
(event: 'remove-error-by-title', value: string): void
|
|
46
|
+
}>()
|
|
47
|
+
|
|
48
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
49
|
+
|
|
50
|
+
const selectedMaxCpuLocal = computed<number>({
|
|
51
|
+
get() {
|
|
52
|
+
return props.selectedMaxCpu
|
|
53
|
+
},
|
|
54
|
+
set(newValue) {
|
|
55
|
+
emits('update:selected-max-cpu', newValue)
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const apiErrorLocal = computed<string>(() => {
|
|
60
|
+
return (
|
|
61
|
+
props.errorValidationFields?.find(
|
|
62
|
+
(message) => message.field === 'cpu.max_vcpus'
|
|
63
|
+
)?.error_message || ''
|
|
64
|
+
)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const errorTextLocal = computed<string>(() => {
|
|
68
|
+
const validValue = /^\d+(\.\d+)?$/.test(selectedMaxCpuLocal.value + '')
|
|
69
|
+
if (!validValue) {
|
|
70
|
+
return localization.value.inputContainsInvalidCharacters
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const min = props.cpuOptions[0].value
|
|
74
|
+
const max = props.cpuOptions[1].value
|
|
75
|
+
if (selectedMaxCpuLocal.value < min || selectedMaxCpuLocal.value > max) {
|
|
76
|
+
return localization.value.memoryMustBe
|
|
77
|
+
.replace('{0}', min)
|
|
78
|
+
.replace('{1}', max)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return ''
|
|
82
|
+
})
|
|
83
|
+
const maxVcpusLocalAndApiErrorsTexts = computed<string>(() => {
|
|
84
|
+
const localError = errorTextLocal.value
|
|
85
|
+
const apiError = apiErrorLocal.value
|
|
86
|
+
|
|
87
|
+
let result = ''
|
|
88
|
+
if (localError && !apiError) result = localError
|
|
89
|
+
if (!localError && !apiError) result = apiError
|
|
90
|
+
if (localError && apiError) result = localError + ', ' + apiError
|
|
91
|
+
if (!localError && apiError) result = apiError
|
|
92
|
+
|
|
93
|
+
return result
|
|
94
|
+
})
|
|
95
|
+
const isInvalid = computed<boolean>(() => !!errorTextLocal.value)
|
|
96
|
+
watch(
|
|
97
|
+
isInvalid,
|
|
98
|
+
(newValue) => {
|
|
99
|
+
emits('invalid', newValue)
|
|
100
|
+
},
|
|
101
|
+
{ immediate: true }
|
|
102
|
+
)
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style scoped></style>
|
package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/shares/Shares.vue
CHANGED
|
@@ -1,151 +1,155 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="">
|
|
3
|
-
<atoms-stack-block :has-children="false">
|
|
4
|
-
<template #stackBlockKey>
|
|
5
|
-
{{ localization.shares }}
|
|
6
|
-
</template>
|
|
7
|
-
<template #stackBlockContent>
|
|
8
|
-
<div class="flex-align-center">
|
|
9
|
-
<div class="select">
|
|
10
|
-
<select
|
|
11
|
-
id="vm-wizard-cpu-shares-type-select"
|
|
12
|
-
v-model="sharesTypeLocal"
|
|
13
|
-
:disabled="props.disabled"
|
|
14
|
-
@change="onChangeSharesType"
|
|
15
|
-
>
|
|
16
|
-
<option
|
|
17
|
-
v-for="(item, key) in sharesTypeOptions"
|
|
18
|
-
:key="key"
|
|
19
|
-
:value="item.value"
|
|
20
|
-
>
|
|
21
|
-
{{ item.text }}
|
|
22
|
-
</option>
|
|
23
|
-
</select>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="tooltip-top-left combobox-container flex-align-center">
|
|
26
|
-
<atoms-tooltip-error
|
|
27
|
-
:has-error="!!sharesLocalAndApiErrorsTexts"
|
|
28
|
-
selector="#vm-wizard-shares-field input"
|
|
29
|
-
@remove="onRemoveValidationError"
|
|
30
|
-
>
|
|
31
|
-
<template #elem>
|
|
32
|
-
<atoms-combobox
|
|
33
|
-
id="vm-wizard-shares-field"
|
|
34
|
-
v-model="sharesLocal"
|
|
35
|
-
:items="sharesOptions"
|
|
36
|
-
:disabled="isDisabledShares"
|
|
37
|
-
@click.stop
|
|
38
|
-
/>
|
|
39
|
-
</template>
|
|
40
|
-
<template #content>{{ sharesLocalAndApiErrorsTexts }}</template>
|
|
41
|
-
</atoms-tooltip-error>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
</template>
|
|
45
|
-
</atoms-stack-block>
|
|
46
|
-
</div>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script setup lang="ts">
|
|
50
|
-
import {
|
|
51
|
-
sharesTypeOptionsFunc,
|
|
52
|
-
sharesOptionsFunc,
|
|
53
|
-
} from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/shares/config/options'
|
|
54
|
-
import { UI_I_Localization, UI_I_HTMLSelectElement } from '~/models/interfaces'
|
|
55
|
-
import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
|
|
56
|
-
import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
|
|
57
|
-
|
|
58
|
-
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
59
|
-
|
|
60
|
-
const props = defineProps<{
|
|
61
|
-
shares: string
|
|
62
|
-
sharesType: string
|
|
63
|
-
disabled: boolean
|
|
64
|
-
errorValidationFields: UI_I_ErrorValidationField<string>[]
|
|
65
|
-
}>()
|
|
66
|
-
const emits = defineEmits<{
|
|
67
|
-
(event: 'update:shares', value: string): void
|
|
68
|
-
(event: 'update:shares-type', value: string): void
|
|
69
|
-
(event: 'invalid', value: boolean): void
|
|
70
|
-
(event: 'remove-error-by-title', value: string): void
|
|
71
|
-
}>()
|
|
72
|
-
|
|
73
|
-
const apiErrorLocal = computed<string>(() => {
|
|
74
|
-
return (
|
|
75
|
-
props.errorValidationFields?.find(
|
|
76
|
-
(message) => message.field === 'cpu.shares'
|
|
77
|
-
)?.error_message || ''
|
|
78
|
-
)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const maxShares = 100_000
|
|
82
|
-
const sharesOptions = computed(() => {
|
|
83
|
-
return sharesOptionsFunc(localization.value, maxShares)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const sharesTypeOptions = ref<UI_I_OptionItem[]>(
|
|
87
|
-
sharesTypeOptionsFunc(localization.value)
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
const isDisabledShares = computed<boolean>(
|
|
91
|
-
() => sharesTypeLocal.value !== '0' || props.disabled
|
|
92
|
-
)
|
|
93
|
-
const sharesLocal = computed<string>({
|
|
94
|
-
get() {
|
|
95
|
-
return props.shares
|
|
96
|
-
},
|
|
97
|
-
set(newValue) {
|
|
98
|
-
emits('update:shares', newValue)
|
|
99
|
-
},
|
|
100
|
-
})
|
|
101
|
-
const sharesTypeLocal = computed<string>({
|
|
102
|
-
get() {
|
|
103
|
-
return props.sharesType
|
|
104
|
-
},
|
|
105
|
-
set(newValue) {
|
|
106
|
-
emits('update:shares-type', newValue)
|
|
107
|
-
},
|
|
108
|
-
})
|
|
109
|
-
const onChangeSharesType = (event: UI_I_HTMLSelectElement): void => {
|
|
110
|
-
const value = event.target.value
|
|
111
|
-
if (value === '0') return
|
|
112
|
-
sharesLocal.value = event.target.value
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const sharesErrorLocalText = computed<string>(() => {
|
|
116
|
-
if (+sharesLocal.value < 0 || +sharesLocal.value > maxShares) {
|
|
117
|
-
return localization.value.sharesMustBe
|
|
118
|
-
.replace('{0}', '0')
|
|
119
|
-
.replace('{1}', maxShares + '')
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const validValue = /^\d+(\.\d+)?$/.test(sharesLocal.value + '')
|
|
123
|
-
if (!validValue) {
|
|
124
|
-
return localization.value.inputContainsInvalidCharacters
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return ''
|
|
128
|
-
})
|
|
129
|
-
const sharesInvalid = computed<boolean>(() => !!sharesErrorLocalText.value)
|
|
130
|
-
watch(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="">
|
|
3
|
+
<atoms-stack-block :has-children="false">
|
|
4
|
+
<template #stackBlockKey>
|
|
5
|
+
{{ localization.shares }}
|
|
6
|
+
</template>
|
|
7
|
+
<template #stackBlockContent>
|
|
8
|
+
<div class="flex-align-center">
|
|
9
|
+
<div class="select">
|
|
10
|
+
<select
|
|
11
|
+
id="vm-wizard-cpu-shares-type-select"
|
|
12
|
+
v-model="sharesTypeLocal"
|
|
13
|
+
:disabled="props.disabled"
|
|
14
|
+
@change="onChangeSharesType"
|
|
15
|
+
>
|
|
16
|
+
<option
|
|
17
|
+
v-for="(item, key) in sharesTypeOptions"
|
|
18
|
+
:key="key"
|
|
19
|
+
:value="item.value"
|
|
20
|
+
>
|
|
21
|
+
{{ item.text }}
|
|
22
|
+
</option>
|
|
23
|
+
</select>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="tooltip-top-left combobox-container flex-align-center">
|
|
26
|
+
<atoms-tooltip-error
|
|
27
|
+
:has-error="!!sharesLocalAndApiErrorsTexts"
|
|
28
|
+
selector="#vm-wizard-shares-field input"
|
|
29
|
+
@remove="onRemoveValidationError"
|
|
30
|
+
>
|
|
31
|
+
<template #elem>
|
|
32
|
+
<atoms-combobox
|
|
33
|
+
id="vm-wizard-shares-field"
|
|
34
|
+
v-model="sharesLocal"
|
|
35
|
+
:items="sharesOptions"
|
|
36
|
+
:disabled="isDisabledShares"
|
|
37
|
+
@click.stop
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
40
|
+
<template #content>{{ sharesLocalAndApiErrorsTexts }}</template>
|
|
41
|
+
</atoms-tooltip-error>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
</atoms-stack-block>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import {
|
|
51
|
+
sharesTypeOptionsFunc,
|
|
52
|
+
sharesOptionsFunc,
|
|
53
|
+
} from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/shares/config/options'
|
|
54
|
+
import { UI_I_Localization, UI_I_HTMLSelectElement } from '~/models/interfaces'
|
|
55
|
+
import { UI_I_ErrorValidationField } from '~/models/store/interfaces'
|
|
56
|
+
import { UI_I_OptionItem } from '~/components/atoms/models/interfaces'
|
|
57
|
+
|
|
58
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
59
|
+
|
|
60
|
+
const props = defineProps<{
|
|
61
|
+
shares: string
|
|
62
|
+
sharesType: string
|
|
63
|
+
disabled: boolean
|
|
64
|
+
errorValidationFields: UI_I_ErrorValidationField<string>[]
|
|
65
|
+
}>()
|
|
66
|
+
const emits = defineEmits<{
|
|
67
|
+
(event: 'update:shares', value: string): void
|
|
68
|
+
(event: 'update:shares-type', value: string): void
|
|
69
|
+
(event: 'invalid', value: boolean): void
|
|
70
|
+
(event: 'remove-error-by-title', value: string): void
|
|
71
|
+
}>()
|
|
72
|
+
|
|
73
|
+
const apiErrorLocal = computed<string>(() => {
|
|
74
|
+
return (
|
|
75
|
+
props.errorValidationFields?.find(
|
|
76
|
+
(message) => message.field === 'cpu.shares'
|
|
77
|
+
)?.error_message || ''
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const maxShares = 100_000
|
|
82
|
+
const sharesOptions = computed(() => {
|
|
83
|
+
return sharesOptionsFunc(localization.value, maxShares)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const sharesTypeOptions = ref<UI_I_OptionItem[]>(
|
|
87
|
+
sharesTypeOptionsFunc(localization.value)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const isDisabledShares = computed<boolean>(
|
|
91
|
+
() => sharesTypeLocal.value !== '0' || props.disabled
|
|
92
|
+
)
|
|
93
|
+
const sharesLocal = computed<string>({
|
|
94
|
+
get() {
|
|
95
|
+
return props.shares
|
|
96
|
+
},
|
|
97
|
+
set(newValue) {
|
|
98
|
+
emits('update:shares', newValue)
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
const sharesTypeLocal = computed<string>({
|
|
102
|
+
get() {
|
|
103
|
+
return props.sharesType
|
|
104
|
+
},
|
|
105
|
+
set(newValue) {
|
|
106
|
+
emits('update:shares-type', newValue)
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
const onChangeSharesType = (event: UI_I_HTMLSelectElement): void => {
|
|
110
|
+
const value = event.target.value
|
|
111
|
+
if (value === '0') return
|
|
112
|
+
sharesLocal.value = event.target.value
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const sharesErrorLocalText = computed<string>(() => {
|
|
116
|
+
if (+sharesLocal.value < 0 || +sharesLocal.value > maxShares) {
|
|
117
|
+
return localization.value.sharesMustBe
|
|
118
|
+
.replace('{0}', '0')
|
|
119
|
+
.replace('{1}', maxShares + '')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const validValue = /^\d+(\.\d+)?$/.test(sharesLocal.value + '')
|
|
123
|
+
if (!validValue) {
|
|
124
|
+
return localization.value.inputContainsInvalidCharacters
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return ''
|
|
128
|
+
})
|
|
129
|
+
const sharesInvalid = computed<boolean>(() => !!sharesErrorLocalText.value)
|
|
130
|
+
watch(
|
|
131
|
+
sharesInvalid,
|
|
132
|
+
(newValue) => {
|
|
133
|
+
emits('invalid', newValue)
|
|
134
|
+
},
|
|
135
|
+
{ immediate: true }
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
const sharesLocalAndApiErrorsTexts = computed<string>(() => {
|
|
139
|
+
const localError = sharesErrorLocalText.value
|
|
140
|
+
const apiError = apiErrorLocal.value
|
|
141
|
+
|
|
142
|
+
let result = ''
|
|
143
|
+
if (localError && !apiError) result = localError
|
|
144
|
+
if (localError && apiError) result = localError + ', ' + apiError
|
|
145
|
+
if (!localError) result = apiError
|
|
146
|
+
|
|
147
|
+
return result
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
const onRemoveValidationError = (): void => {
|
|
151
|
+
emits('remove-error-by-title', 'cpu.shares')
|
|
152
|
+
}
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<style scoped></style>
|