-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI improvements and other miscellaneous refactoring.
- Loading branch information
Showing
19 changed files
with
363 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import {ReactAdapterElement} from 'Frontend/generated/flow/ReactAdapter'; | ||
import {effect, signal} from "@vaadin/hilla-react-signals"; | ||
import Markdown from "react-markdown"; | ||
|
||
class MarkdownElement extends ReactAdapterElement { | ||
|
||
markdown = signal(''); | ||
|
||
protected override render() { | ||
// In a React component, we could use the signal value directly, | ||
// but it doesn't trigger an update in the ReactAdapterElement render method. | ||
// Instead, pass the signal value to useState for React. | ||
const [content, setContent] = useState(''); | ||
useEffect(() => effect(() => { | ||
setContent(this.markdown.value); | ||
}), []); | ||
return <Markdown>{content}</Markdown>; | ||
} | ||
} | ||
|
||
customElements.define('markdown-component', MarkdownElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/cftoolsuite/client/RefactorStreamingClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.cftoolsuite.client; | ||
|
||
import org.cftoolsuite.domain.chat.Inquiry; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import reactivefeign.spring.config.ReactiveFeignClient; | ||
import reactor.core.publisher.Flux; | ||
|
||
@ReactiveFeignClient(name="refactor-streaming-service", url="${refactor.service.url}") | ||
public interface RefactorStreamingClient { | ||
|
||
@PostMapping("/api/stream/chat") | ||
public Flux<String> streamResponseToQuestion(@RequestBody Inquiry inquiry); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
src/main/java/org/cftoolsuite/domain/chat/FilterMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.cftoolsuite.domain.chat; | ||
|
||
public record FilterMetadata(String key, Object value) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.cftoolsuite.domain.chat; | ||
|
||
import java.util.List; | ||
|
||
public record Inquiry(String question, List<FilterMetadata> filter) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/main/java/org/cftoolsuite/ui/component/MetadataFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package org.cftoolsuite.ui.component; | ||
|
||
import com.vaadin.flow.component.button.Button; | ||
import com.vaadin.flow.component.customfield.CustomField; | ||
import com.vaadin.flow.component.grid.Grid; | ||
import com.vaadin.flow.component.icon.VaadinIcon; | ||
import com.vaadin.flow.component.orderedlayout.FlexComponent; | ||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.component.textfield.TextField; | ||
import org.cftoolsuite.domain.chat.FilterMetadata; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MetadataFilter extends CustomField<List<FilterMetadata>> { | ||
private final Grid<MetadataEntry> grid; | ||
private final List<MetadataEntry> entries; | ||
private final TextField keyField; | ||
private final TextField valueField; | ||
private final Button addButton; | ||
|
||
public MetadataFilter() { | ||
entries = new ArrayList<>(); | ||
grid = new Grid<>(); | ||
|
||
grid.addColumn(MetadataEntry::getKey).setHeader("Key").setFlexGrow(1); | ||
grid.addColumn(MetadataEntry::getValue).setHeader("Value").setFlexGrow(1); | ||
grid.addComponentColumn(this::createRemoveButton).setWidth("100px").setFlexGrow(0); | ||
|
||
grid.setItems(entries); | ||
|
||
keyField = new TextField("Key"); | ||
valueField = new TextField("Value"); | ||
addButton = new Button("Add", VaadinIcon.PLUS.create()); | ||
addButton.addClickListener(e -> addEntry()); | ||
|
||
HorizontalLayout inputLayout = new HorizontalLayout(keyField, valueField, addButton); | ||
inputLayout.setWidth("100%"); | ||
inputLayout.setAlignItems(FlexComponent.Alignment.END); | ||
|
||
VerticalLayout layout = new VerticalLayout(inputLayout, grid); | ||
layout.setSpacing(false); | ||
layout.setPadding(false); | ||
add(layout); | ||
} | ||
|
||
private Button createRemoveButton(MetadataEntry entry) { | ||
Button removeButton = new Button(VaadinIcon.TRASH.create()); | ||
removeButton.addClickListener(e -> { | ||
entries.remove(entry); | ||
grid.getDataProvider().refreshAll(); | ||
updateValue(); | ||
}); | ||
return removeButton; | ||
} | ||
|
||
private void addEntry() { | ||
String key = keyField.getValue().trim(); | ||
String value = valueField.getValue().trim(); | ||
|
||
if (!key.isEmpty() && !value.isEmpty()) { | ||
entries.add(new MetadataEntry(key, value)); | ||
keyField.clear(); | ||
valueField.clear(); | ||
grid.getDataProvider().refreshAll(); | ||
updateValue(); | ||
} | ||
} | ||
|
||
@Override | ||
protected List<FilterMetadata> generateModelValue() { | ||
if (entries.isEmpty()) { | ||
return null; | ||
} | ||
|
||
List<FilterMetadata> metadata = new ArrayList<>(); | ||
for (MetadataEntry entry : entries) { | ||
metadata.add(new FilterMetadata(entry.getKey(), entry.getValue())); | ||
} | ||
return metadata; | ||
} | ||
|
||
@Override | ||
public void setPresentationValue(List<FilterMetadata> metadata) { | ||
entries.clear(); | ||
if (metadata != null) { | ||
metadata.forEach(fm -> | ||
entries.add(new MetadataEntry(fm.key(), fm.value())) | ||
); | ||
} | ||
grid.getDataProvider().refreshAll(); | ||
} | ||
|
||
private static class MetadataEntry { | ||
private final String key; | ||
private final Object value; | ||
|
||
public MetadataEntry(String key, Object value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
} | ||
} |
Oops, something went wrong.