|
@ -71,6 +71,23 @@ public class CrearnuevoTicketView extends VerticalLayout { |
|
|
Button createButton = new Button("Enviar ticket", event -> handleCreateButton(user, tipoTickets, asunto, descripcion)); |
|
|
Button createButton = new Button("Enviar ticket", event -> handleCreateButton(user, tipoTickets, asunto, descripcion)); |
|
|
createButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_LARGE); |
|
|
createButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_LARGE); |
|
|
|
|
|
|
|
|
|
|
|
uploadFile.addSucceededListener(event -> { |
|
|
|
|
|
handleFileUpload(event.getFileName()); |
|
|
|
|
|
createButton.setEnabled(true); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
uploadFile.addFailedListener(event -> { |
|
|
|
|
|
// Habilitar el botón en caso de fallo |
|
|
|
|
|
/* createButton.setEnabled(true);*/ |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
uploadFile.addStartedListener(event -> { |
|
|
|
|
|
createButton.setEnabled(false); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
createButton.setEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Alineacion de los componentes ComboBox Tipos de tickets y Descripcion del tipo de ticket |
|
|
//Alineacion de los componentes ComboBox Tipos de tickets y Descripcion del tipo de ticket |
|
|
HorizontalLayout firstFields = new HorizontalLayout(tipoTickets, ticketTypeDesc); |
|
|
HorizontalLayout firstFields = new HorizontalLayout(tipoTickets, ticketTypeDesc); |
|
@ -94,13 +111,14 @@ public class CrearnuevoTicketView extends VerticalLayout { |
|
|
ticketTypeDesc.getStyle().set("padding", "10px"); |
|
|
ticketTypeDesc.getStyle().set("padding", "10px"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add(new H2("Crear nuevo ticket"), firstFields, fieldsLayout, buttonLayout); |
|
|
add(new H2("Crear nuevo ticket"), firstFields, fieldsLayout, buttonLayout); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Upload createUploadComponent() { |
|
|
private Upload createUploadComponent() { |
|
|
MultiFileMemoryBuffer buffer = new MultiFileMemoryBuffer(); |
|
|
|
|
|
|
|
|
buffer = new MultiFileMemoryBuffer(); |
|
|
Upload uploadFile = new Upload(buffer); |
|
|
Upload uploadFile = new Upload(buffer); |
|
|
uploadFile.setMaxFiles(5); |
|
|
|
|
|
|
|
|
uploadFile.setMaxFiles(3); |
|
|
uploadFile.setDropAllowed(true); |
|
|
uploadFile.setDropAllowed(true); |
|
|
|
|
|
|
|
|
UploadI18N i18N = new UploadI18N(); |
|
|
UploadI18N i18N = new UploadI18N(); |
|
@ -207,7 +225,8 @@ public class CrearnuevoTicketView extends VerticalLayout { |
|
|
issueDetails.put("tracker_id", selectedTrackerId); |
|
|
issueDetails.put("tracker_id", selectedTrackerId); |
|
|
|
|
|
|
|
|
JsonArray uploadsJsonArray = new JsonArray(); |
|
|
JsonArray uploadsJsonArray = new JsonArray(); |
|
|
buffer.getFiles().forEach(fileName -> { |
|
|
|
|
|
|
|
|
if (!buffer.getFiles().isEmpty()) { |
|
|
|
|
|
buffer.getFiles().forEach(fileName -> { |
|
|
try (InputStream inputStream = buffer.getInputStream(fileName)) { |
|
|
try (InputStream inputStream = buffer.getInputStream(fileName)) { |
|
|
byte[] fileContent = inputStream.readAllBytes(); |
|
|
byte[] fileContent = inputStream.readAllBytes(); |
|
|
String fileToken = api.uploadFile(fileContent, fileName); |
|
|
String fileToken = api.uploadFile(fileContent, fileName); |
|
@ -219,8 +238,9 @@ public class CrearnuevoTicketView extends VerticalLayout { |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
Notification.show("Error al cargar el archivo: " + e.getMessage(), 3000, Notification.Position.MIDDLE) |
|
|
Notification.show("Error al cargar el archivo: " + e.getMessage(), 3000, Notification.Position.MIDDLE) |
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
.addThemeVariants(NotificationVariant.LUMO_ERROR); |
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
String response = api.createIssue(issueDetails, uploadsJsonArray, user.getKey()); |
|
|
String response = api.createIssue(issueDetails, uploadsJsonArray, user.getKey()); |
|
|
handleResponse(response, asunto, descripcion, tipoTickets); |
|
|
handleResponse(response, asunto, descripcion, tipoTickets); |
|
|