Allow node transfer field to recv more than 1 node (#5220)
This commit is contained in:
committed by
GitHub
parent
0d6bee3a5b
commit
f998a8dca5
@@ -46,20 +46,20 @@
|
|||||||
Node hostnames
|
Node hostnames
|
||||||
<span class="text-brand-red">*</span>
|
<span class="text-brand-red">*</span>
|
||||||
</span>
|
</span>
|
||||||
<span>Add nodes to transfer.</span>
|
<span>Add nodes to transfer (comma or space-separated).</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<input
|
<input
|
||||||
id="node-input"
|
id="node-input"
|
||||||
v-model="nodeInput"
|
v-model="nodeInput"
|
||||||
class="w-40"
|
class="w-64"
|
||||||
type="text"
|
type="text"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
placeholder="us-vin200"
|
placeholder="us-vin200, us-vin201"
|
||||||
@keydown.enter.prevent="addNode"
|
@keydown.enter.prevent="addNodes"
|
||||||
/>
|
/>
|
||||||
<ButtonStyled color="blue" color-fill="text">
|
<ButtonStyled color="blue" color-fill="text">
|
||||||
<button class="shrink-0" @click="addNode">
|
<button class="shrink-0" @click="addNodes">
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
@@ -282,18 +282,37 @@ function hide() {
|
|||||||
modal.value?.hide()
|
modal.value?.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNode() {
|
function addNodes() {
|
||||||
const v = nodeInput.value.trim()
|
const input = nodeInput.value.trim()
|
||||||
if (!v) return
|
if (!input) return
|
||||||
if (!nodeHostnames.value.includes(v)) {
|
|
||||||
|
const nodes = input
|
||||||
|
.split(/[,\s]+/)
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter((s) => s.length > 0)
|
||||||
|
|
||||||
|
const unknownNodes: string[] = []
|
||||||
|
const addedNodes: string[] = []
|
||||||
|
|
||||||
|
for (const v of nodes) {
|
||||||
|
if (!nodeHostnames.value.includes(v)) {
|
||||||
|
unknownNodes.push(v)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!selectedNodes.value.includes(v)) {
|
||||||
|
selectedNodes.value.push(v)
|
||||||
|
addedNodes.push(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unknownNodes.length > 0) {
|
||||||
addNotification({
|
addNotification({
|
||||||
title: 'Unknown node',
|
title: `Unknown node${unknownNodes.length > 1 ? 's' : ''}`,
|
||||||
text: "This hostname doesn't exist",
|
text: unknownNodes.join(', '),
|
||||||
type: 'error',
|
type: 'error',
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if (!selectedNodes.value.includes(v)) selectedNodes.value.push(v)
|
|
||||||
nodeInput.value = ''
|
nodeInput.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user