Added locking bucket in registering
This commit is contained in:
parent
31c3be649d
commit
ca84959c83
@ -3,6 +3,7 @@ package ru.dragonestia.loadbalancer.web.component;
|
|||||||
import com.vaadin.flow.component.Unit;
|
import com.vaadin.flow.component.Unit;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.button.ButtonVariant;
|
import com.vaadin.flow.component.button.ButtonVariant;
|
||||||
|
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||||
import com.vaadin.flow.component.details.Details;
|
import com.vaadin.flow.component.details.Details;
|
||||||
import com.vaadin.flow.component.html.H2;
|
import com.vaadin.flow.component.html.H2;
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
@ -24,6 +25,7 @@ public class RegisterBucket extends Details {
|
|||||||
private final Function<Bucket, Response> onSubmit;
|
private final Function<Bucket, Response> onSubmit;
|
||||||
private final TextField identifierField;
|
private final TextField identifierField;
|
||||||
private final TextArea payloadField;
|
private final TextArea payloadField;
|
||||||
|
private final Checkbox lockedField;
|
||||||
|
|
||||||
public RegisterBucket(Node node, Function<Bucket, Response> onSubmit) {
|
public RegisterBucket(Node node, Function<Bucket, Response> onSubmit) {
|
||||||
super(new H2("Register bucket"));
|
super(new H2("Register bucket"));
|
||||||
@ -34,6 +36,7 @@ public class RegisterBucket extends Details {
|
|||||||
layout.add(createNodeIdentifierField());
|
layout.add(createNodeIdentifierField());
|
||||||
layout.add(identifierField = createBucketIdentifierField());
|
layout.add(identifierField = createBucketIdentifierField());
|
||||||
layout.add(payloadField = createPayloadField());
|
layout.add(payloadField = createPayloadField());
|
||||||
|
layout.add(lockedField = createLockedField());
|
||||||
layout.add(createSubmitButton());
|
layout.add(createSubmitButton());
|
||||||
|
|
||||||
add(layout);
|
add(layout);
|
||||||
@ -67,6 +70,12 @@ public class RegisterBucket extends Details {
|
|||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Checkbox createLockedField() {
|
||||||
|
var field = new Checkbox("Locked");
|
||||||
|
field.setValue(false);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
private Button createSubmitButton() {
|
private Button createSubmitButton() {
|
||||||
var button = new Button("Register");
|
var button = new Button("Register");
|
||||||
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||||
@ -77,6 +86,7 @@ public class RegisterBucket extends Details {
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
identifierField.clear();
|
identifierField.clear();
|
||||||
payloadField.clear();
|
payloadField.clear();
|
||||||
|
lockedField.setValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable String validateForm(String identifier) {
|
private @Nullable String validateForm(String identifier) {
|
||||||
@ -102,6 +112,7 @@ public class RegisterBucket extends Details {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var bucket = Bucket.create(nodeIdentifier, node, SlotLimit.unlimited(), payloadField.getValue());
|
var bucket = Bucket.create(nodeIdentifier, node, SlotLimit.unlimited(), payloadField.getValue());
|
||||||
|
bucket.setLocked(lockedField.getValue());
|
||||||
var response = onSubmit.apply(bucket);
|
var response = onSubmit.apply(bucket);
|
||||||
clear();
|
clear();
|
||||||
if (response.error()) {
|
if (response.error()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user