Browse Source

Se añadio una etiqueta que muestra la descripcion del ticket cuando se selecciona un tipo

pull/1/head
parent
commit
8ba8b77563
4 changed files with 48 additions and 23 deletions
  1. +29
    -15
      src/main/java/mx/gob/jumapacelaya/api/RedmineClient.java
  2. +1
    -1
      src/main/java/mx/gob/jumapacelaya/models/Ticket.java
  3. +14
    -3
      src/main/java/mx/gob/jumapacelaya/views/crearnuevoticket/CrearnuevoTicketView.java
  4. +4
    -4
      src/main/resources/application.properties

+ 29
- 15
src/main/java/mx/gob/jumapacelaya/api/RedmineClient.java View File

@ -152,18 +152,9 @@ public class RedmineClient {
}
}
// Verifica y obtiene el autor
Ticket.User author = null;
if (issue.has("author") && !issue.get("author").isJsonNull()) {
JsonObject authorJson = issue.getAsJsonObject("author");
if (authorJson.has("name") && !authorJson.get("name").isJsonNull()) {
String username = authorJson.get("name").getAsString();
author = new Ticket.User(username);
}
}
// Agrega el ticket a la lista
tickets.add(new Ticket(id, subject, description, status, date != null ? date.toString() : "", author));
tickets.add(new Ticket(id, subject, description, status, date != null ? date.toString() : ""));
}
} else {
System.out.println("La respuesta JSON no contiene la clave 'issues'");
@ -338,8 +329,8 @@ public class RedmineClient {
}
public Map<String, String> getTicketTypes() {
Map<String, String> ticketTypes = new HashMap<>();
public Map<String, TicketType> getTicketTypes() {
Map<String, TicketType> ticketTypes = new HashMap<>();
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(REDMINE_URL + "/trackers.json"))
@ -361,18 +352,41 @@ public class RedmineClient {
}
private Map<String, String> parseTicketTypes(String json) {
Map<String, String> ticketMap = new HashMap<>();
private Map<String, TicketType> parseTicketTypes(String json) {
Map<String, TicketType> ticketMap = new HashMap<>();
JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();
jsonObject.getAsJsonArray("trackers").forEach(trackerElement -> {
JsonObject tracker = trackerElement.getAsJsonObject();
String name = tracker.get("name").getAsString();
String id = tracker.get("id").getAsString();
ticketMap.put(name, id);
String description = tracker.has("description") && !tracker.get("description").isJsonNull() ? tracker.get("description").getAsString() : "Descripcion no disponible";
ticketMap.put(name, new TicketType(id, description));
});
return ticketMap;
}
public static class TicketType {
private final String id;
private final String description;
public TicketType(String id, String description) {
this.id = id;
this.description = description;
}
public String getId() {
return id;
}
public String getDescription() {
return description;
}
public String getTicketTypeDescription(String type, Map<String, TicketType> ticketTypes) {
return ticketTypes.getOrDefault(type, new TicketType("N/A", "Descripción no disponible para este tipo de ticket")).getDescription();
}
}
public static RedmineUser createRedmineUser(String username, String firstname, String lastname, String mail) {
HttpClient client = HttpClient.newHttpClient();


+ 1
- 1
src/main/java/mx/gob/jumapacelaya/models/Ticket.java View File

@ -16,7 +16,7 @@ public class Ticket {
private User author;
public Ticket(int id, String subject, String description, String status, String dateCreate, User author) {
public Ticket(int id, String subject, String description, String status, String dateCreate) {
this.id = id;
this.subject = subject;
this.description = description;


+ 14
- 3
src/main/java/mx/gob/jumapacelaya/views/crearnuevoticket/CrearnuevoTicketView.java View File

@ -7,6 +7,7 @@ import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
@ -43,12 +44,14 @@ public class CrearnuevoTicketView extends VerticalLayout {
private MultiFileMemoryBuffer buffer;
private Upload uploadFile;
private String selectedTrackerId;
private Span ticketTypeDesc;
public CrearnuevoTicketView(RedmineClient api, UserService service) {
this.api = api;
this.userService = service;
this.buffer = new MultiFileMemoryBuffer();
this.uploadFile = createUploadComponent();
this.ticketTypeDesc = new Span();
RedmineUser user = userService.getRedmineUser();
@ -66,7 +69,7 @@ public class CrearnuevoTicketView extends VerticalLayout {
Button createButton = new Button("Enviar ticket", event -> handleCreateButton(user, tipoTickets, asunto, descripcion));
createButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_LARGE);
VerticalLayout fieldsLayout = new VerticalLayout(descripcion, uploadFile);
VerticalLayout fieldsLayout = new VerticalLayout(descripcion, uploadFile, ticketTypeDesc);
fieldsLayout.setAlignItems(Alignment.CENTER);
HorizontalLayout firstFields = new HorizontalLayout(tipoTickets, asunto);
VerticalLayout buttonLayout = new VerticalLayout(createButton);
@ -110,7 +113,7 @@ public class CrearnuevoTicketView extends VerticalLayout {
ComboBox<String> tipoTickets = new ComboBox<>("Tipo de ticket");
tipoTickets.setPlaceholder("Seleccione un tipo de ticket");
Map<String, String> ticketTypesMap = api.getTicketTypes();
Map<String, RedmineClient.TicketType> ticketTypesMap = api.getTicketTypes();
Set<String> ticketTypesSet = Set.of("Acceso/Permiso/Bajas", "Soporte de Software", "Capacitacion de Software",
"Configuracion de Software", "Digitalizacion GIS", "Documento", "Funcionalidad", "Reporte",
"Soporte o Mantenimiento");
@ -118,7 +121,13 @@ public class CrearnuevoTicketView extends VerticalLayout {
.filter(ticketTypesSet::contains)
.collect(Collectors.toList());
tipoTickets.setItems(filteredTicketTypes);
tipoTickets.addValueChangeListener(event -> selectedTrackerId = ticketTypesMap.get(event.getValue()));
tipoTickets.addValueChangeListener(event -> {
String selectedType = event.getValue();
RedmineClient.TicketType ticketType = ticketTypesMap.get(selectedType);
ticketTypeDesc.setText(ticketType != null ? ticketType.getDescription() : "Descripcion no disponible para este tipo de ticket");
selectedTrackerId = ticketType != null ? ticketType.getId() : null;
});
return tipoTickets;
}
@ -135,6 +144,7 @@ public class CrearnuevoTicketView extends VerticalLayout {
return textArea;
}
private void handleFileUpload(String fileName) {
try (InputStream inputStream = buffer.getInputStream(fileName);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
@ -218,6 +228,7 @@ public class CrearnuevoTicketView extends VerticalLayout {
asunto.clear();
descripcion.clear();
tipoTickets.clear();
ticketTypeDesc.setText("");
asunto.setInvalid(false);
descripcion.setInvalid(false);


+ 4
- 4
src/main/resources/application.properties View File

@ -18,13 +18,13 @@ spring.ldap.password=Dr3na%134$4guA
########PRODUCTIVO#################################
redmine.url=https://proyman.jumapacelaya.gob.mx/
redmine.api_key=9cc9e89cbbf08a6252045d56bd3d3ffec90adbad
#redmine.url=https://proyman.jumapacelaya.gob.mx/
#redmine.api_key=9cc9e89cbbf08a6252045d56bd3d3ffec90adbad
########LOCAL######################################
#redmine.url=http://localhost:3000
#redmine.api_key=9cc9e89cbbf08a6252045d56bd3d3ffec90adbad
redmine.url=http://localhost:3000
redmine.api_key=9cc9e89cbbf08a6252045d56bd3d3ffec90adbad
###CONFIGURACION DEL TAMANO MAXIMO PERMITIDO PARA ARCHIVOS###


Loading…
Cancel
Save