Added ID filter to LangFlow
This commit is contained in:
parent
95ef164f83
commit
12d6b4746a
5 changed files with 48 additions and 8 deletions
|
|
@ -102,6 +102,7 @@ async def share_component(
|
||||||
|
|
||||||
@router.get("/components/", response_model=ListComponentResponseModel)
|
@router.get("/components/", response_model=ListComponentResponseModel)
|
||||||
async def get_components(
|
async def get_components(
|
||||||
|
component_id: Annotated[Optional[str], Query()] = None,
|
||||||
search: Annotated[Optional[str], Query()] = None,
|
search: Annotated[Optional[str], Query()] = None,
|
||||||
private: Annotated[Optional[bool], Query()] = None,
|
private: Annotated[Optional[bool], Query()] = None,
|
||||||
is_component: Annotated[Optional[bool], Query()] = None,
|
is_component: Annotated[Optional[bool], Query()] = None,
|
||||||
|
|
@ -117,6 +118,7 @@ async def get_components(
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
return await store_service.get_list_component_response_model(
|
return await store_service.get_list_component_response_model(
|
||||||
|
component_id=component_id,
|
||||||
search=search,
|
search=search,
|
||||||
private=private,
|
private=private,
|
||||||
is_component=is_component,
|
is_component=is_component,
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ class StoreService(Service):
|
||||||
|
|
||||||
def build_filter_conditions(
|
def build_filter_conditions(
|
||||||
self,
|
self,
|
||||||
|
component_id: Optional[str] = None,
|
||||||
search: Optional[str] = None,
|
search: Optional[str] = None,
|
||||||
private: Optional[bool] = None,
|
private: Optional[bool] = None,
|
||||||
tags: Optional[List[str]] = None,
|
tags: Optional[List[str]] = None,
|
||||||
|
|
@ -191,7 +192,8 @@ class StoreService(Service):
|
||||||
if tags:
|
if tags:
|
||||||
tags_filter = self.build_tags_filter(tags)
|
tags_filter = self.build_tags_filter(tags)
|
||||||
filter_conditions.append(tags_filter)
|
filter_conditions.append(tags_filter)
|
||||||
|
if component_id is not None:
|
||||||
|
filter_conditions.append({"id": {"_eq": component_id}})
|
||||||
if is_component is not None:
|
if is_component is not None:
|
||||||
filter_conditions.append({"is_component": {"_eq": is_component}})
|
filter_conditions.append({"is_component": {"_eq": is_component}})
|
||||||
if liked and store_api_Key:
|
if liked and store_api_Key:
|
||||||
|
|
@ -412,6 +414,7 @@ class StoreService(Service):
|
||||||
|
|
||||||
async def get_list_component_response_model(
|
async def get_list_component_response_model(
|
||||||
self,
|
self,
|
||||||
|
component_id: Optional[str] = None,
|
||||||
search: Optional[str] = None,
|
search: Optional[str] = None,
|
||||||
private: Optional[bool] = None,
|
private: Optional[bool] = None,
|
||||||
tags: Optional[List[str]] = None,
|
tags: Optional[List[str]] = None,
|
||||||
|
|
@ -426,6 +429,7 @@ class StoreService(Service):
|
||||||
):
|
):
|
||||||
async with user_data_context(api_key=store_api_key, store_service=self):
|
async with user_data_context(api_key=store_api_key, store_service=self):
|
||||||
filter_conditions: List[Dict[str, Any]] = self.build_filter_conditions(
|
filter_conditions: List[Dict[str, Any]] = self.build_filter_conditions(
|
||||||
|
component_id=component_id,
|
||||||
search=search,
|
search=search,
|
||||||
private=private,
|
private=private,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
|
|
|
||||||
|
|
@ -594,6 +594,7 @@ export async function getFlowsStore(): Promise<AxiosResponse<FlowType[]>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getStoreComponents({
|
export async function getStoreComponents({
|
||||||
|
component_id = null,
|
||||||
page = 1,
|
page = 1,
|
||||||
limit = 9999999,
|
limit = 9999999,
|
||||||
is_component = null,
|
is_component = null,
|
||||||
|
|
@ -605,6 +606,7 @@ export async function getStoreComponents({
|
||||||
filterByUser = null,
|
filterByUser = null,
|
||||||
fields = null,
|
fields = null,
|
||||||
}: {
|
}: {
|
||||||
|
component_id?: string | null;
|
||||||
page?: number;
|
page?: number;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
is_component?: boolean | null;
|
is_component?: boolean | null;
|
||||||
|
|
@ -619,6 +621,9 @@ export async function getStoreComponents({
|
||||||
try {
|
try {
|
||||||
let url = `${BASE_URL_API}store/components/`;
|
let url = `${BASE_URL_API}store/components/`;
|
||||||
const queryParams: any = [];
|
const queryParams: any = [];
|
||||||
|
if (component_id !== undefined && component_id !== null) {
|
||||||
|
queryParams.push(`component_id=${component_id}`);
|
||||||
|
}
|
||||||
if (search !== undefined && search !== null) {
|
if (search !== undefined && search !== null) {
|
||||||
queryParams.push(`search=${search}`);
|
queryParams.push(`search=${search}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,9 @@ import { SkeletonCardComponent } from "../../components/skeletonCardComponent";
|
||||||
import { Button } from "../../components/ui/button";
|
import { Button } from "../../components/ui/button";
|
||||||
import { Input } from "../../components/ui/input";
|
import { Input } from "../../components/ui/input";
|
||||||
|
|
||||||
|
import { Link, useParams } from "react-router-dom";
|
||||||
import { TagsSelector } from "../../components/tagsSelectorComponent";
|
import { TagsSelector } from "../../components/tagsSelectorComponent";
|
||||||
|
import { Badge } from "../../components/ui/badge";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|
@ -27,6 +29,7 @@ import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
|
||||||
import { storeComponent } from "../../types/store";
|
import { storeComponent } from "../../types/store";
|
||||||
import { cn } from "../../utils/utils";
|
import { cn } from "../../utils/utils";
|
||||||
export default function StorePage(): JSX.Element {
|
export default function StorePage(): JSX.Element {
|
||||||
|
const { id } = useParams();
|
||||||
const { validApiKey, setValidApiKey, hasApiKey, loadingApiKey } =
|
const { validApiKey, setValidApiKey, hasApiKey, loadingApiKey } =
|
||||||
useContext(StoreContext);
|
useContext(StoreContext);
|
||||||
const { apiKey } = useContext(AuthContext);
|
const { apiKey } = useContext(AuthContext);
|
||||||
|
|
@ -85,6 +88,7 @@ export default function StorePage(): JSX.Element {
|
||||||
apiKey,
|
apiKey,
|
||||||
searchNow,
|
searchNow,
|
||||||
loadingApiKey,
|
loadingApiKey,
|
||||||
|
id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function handleGetTags() {
|
function handleGetTags() {
|
||||||
|
|
@ -104,6 +108,7 @@ export default function StorePage(): JSX.Element {
|
||||||
if (!hasApiKey || loadingApiKey) return;
|
if (!hasApiKey || loadingApiKey) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
getStoreComponents({
|
getStoreComponents({
|
||||||
|
component_id: id,
|
||||||
page: pageIndex,
|
page: pageIndex,
|
||||||
limit: pageSize,
|
limit: pageSize,
|
||||||
is_component:
|
is_component:
|
||||||
|
|
@ -275,13 +280,27 @@ export default function StorePage(): JSX.Element {
|
||||||
</SelectGroup>
|
</SelectGroup>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<TagsSelector
|
{id === undefined ? (
|
||||||
tags={tags}
|
<TagsSelector
|
||||||
loadingTags={loadingTags}
|
tags={tags}
|
||||||
disabled={loading}
|
loadingTags={loadingTags}
|
||||||
selectedTags={filteredCategories}
|
disabled={loading}
|
||||||
setSelectedTags={setFilterCategories}
|
selectedTags={filteredCategories}
|
||||||
/>
|
setSelectedTags={setFilterCategories}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Badge
|
||||||
|
key="id"
|
||||||
|
variant="outline"
|
||||||
|
size="sq"
|
||||||
|
className="gap-2 bg-beta-foreground text-background hover:bg-beta-foreground"
|
||||||
|
>
|
||||||
|
<Link to={"/store"} className="cursor-pointer">
|
||||||
|
<IconComponent name="X" className="h-4 w-4" />
|
||||||
|
</Link>
|
||||||
|
{id}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end justify-between">
|
<div className="flex items-end justify-between">
|
||||||
<span className="px-0.5 text-sm text-muted-foreground">
|
<span className="px-0.5 text-sm text-muted-foreground">
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,16 @@ const Router = () => {
|
||||||
</ProtectedRoute>
|
</ProtectedRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="/store/:id/"
|
||||||
|
element={
|
||||||
|
<ProtectedRoute>
|
||||||
|
<StoreGuard>
|
||||||
|
<StorePage />
|
||||||
|
</StoreGuard>
|
||||||
|
</ProtectedRoute>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<Route path="/flow/:id/">
|
<Route path="/flow/:id/">
|
||||||
<Route
|
<Route
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue