| ) | ) | ||||
| parser.add_argument("name", type=str, location="args", required=False) | parser.add_argument("name", type=str, location="args", required=False) | ||||
| parser.add_argument("tag_ids", type=uuid_list, location="args", required=False) | parser.add_argument("tag_ids", type=uuid_list, location="args", required=False) | ||||
| parser.add_argument("is_created_by_me", type=inputs.boolean, location="args", required=False) | |||||
| args = parser.parse_args() | args = parser.parse_args() | ||||
| # get app list | # get app list | ||||
| app_service = AppService() | app_service = AppService() | ||||
| app_pagination = app_service.get_paginate_apps(current_user.current_tenant_id, args) | |||||
| app_pagination = app_service.get_paginate_apps(current_user.id, current_user.current_tenant_id, args) | |||||
| if not app_pagination: | if not app_pagination: | ||||
| return {"data": [], "total": 0, "page": 1, "limit": 20, "has_more": False} | return {"data": [], "total": 0, "page": 1, "limit": 20, "has_more": False} | ||||
| class AppService: | class AppService: | ||||
| def get_paginate_apps(self, tenant_id: str, args: dict) -> Pagination | None: | |||||
| def get_paginate_apps(self, user_id: str, tenant_id: str, args: dict) -> Pagination | None: | |||||
| """ | """ | ||||
| Get app list with pagination | Get app list with pagination | ||||
| :param user_id: user id | |||||
| :param tenant_id: tenant id | :param tenant_id: tenant id | ||||
| :param args: request args | :param args: request args | ||||
| :return: | :return: | ||||
| elif args["mode"] == "channel": | elif args["mode"] == "channel": | ||||
| filters.append(App.mode == AppMode.CHANNEL.value) | filters.append(App.mode == AppMode.CHANNEL.value) | ||||
| if args.get("is_created_by_me", False): | |||||
| filters.append(App.created_by == user_id) | |||||
| if args.get("name"): | if args.get("name"): | ||||
| name = args["name"][:30] | name = args["name"][:30] | ||||
| filters.append(App.name.ilike(f"%{name}%")) | filters.append(App.name.ilike(f"%{name}%")) |
| import { useStore as useTagStore } from '@/app/components/base/tag-management/store' | import { useStore as useTagStore } from '@/app/components/base/tag-management/store' | ||||
| import TagManagementModal from '@/app/components/base/tag-management' | import TagManagementModal from '@/app/components/base/tag-management' | ||||
| import TagFilter from '@/app/components/base/tag-management/filter' | import TagFilter from '@/app/components/base/tag-management/filter' | ||||
| import CheckboxWithLabel from '@/app/components/datasets/create/website/base/checkbox-with-label' | |||||
| const getKey = ( | const getKey = ( | ||||
| pageIndex: number, | pageIndex: number, | ||||
| previousPageData: AppListResponse, | previousPageData: AppListResponse, | ||||
| activeTab: string, | activeTab: string, | ||||
| isCreatedByMe: boolean, | |||||
| tags: string[], | tags: string[], | ||||
| keywords: string, | keywords: string, | ||||
| ) => { | ) => { | ||||
| if (!pageIndex || previousPageData.has_more) { | if (!pageIndex || previousPageData.has_more) { | ||||
| const params: any = { url: 'apps', params: { page: pageIndex + 1, limit: 30, name: keywords } } | |||||
| const params: any = { url: 'apps', params: { page: pageIndex + 1, limit: 30, name: keywords, is_created_by_me: isCreatedByMe } } | |||||
| if (activeTab !== 'all') | if (activeTab !== 'all') | ||||
| params.params.mode = activeTab | params.params.mode = activeTab | ||||
| defaultTab: 'all', | defaultTab: 'all', | ||||
| }) | }) | ||||
| const { query: { tagIDs = [], keywords = '' }, setQuery } = useAppsQueryState() | const { query: { tagIDs = [], keywords = '' }, setQuery } = useAppsQueryState() | ||||
| const [isCreatedByMe, setIsCreatedByMe] = useState(false) | |||||
| const [tagFilterValue, setTagFilterValue] = useState<string[]>(tagIDs) | const [tagFilterValue, setTagFilterValue] = useState<string[]>(tagIDs) | ||||
| const [searchKeywords, setSearchKeywords] = useState(keywords) | const [searchKeywords, setSearchKeywords] = useState(keywords) | ||||
| const setKeywords = useCallback((keywords: string) => { | const setKeywords = useCallback((keywords: string) => { | ||||
| }, [setQuery]) | }, [setQuery]) | ||||
| const { data, isLoading, setSize, mutate } = useSWRInfinite( | const { data, isLoading, setSize, mutate } = useSWRInfinite( | ||||
| (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, tagIDs, searchKeywords), | |||||
| (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, isCreatedByMe, tagIDs, searchKeywords), | |||||
| fetchAppList, | fetchAppList, | ||||
| { revalidateFirstPage: true }, | { revalidateFirstPage: true }, | ||||
| ) | ) | ||||
| options={options} | options={options} | ||||
| /> | /> | ||||
| <div className='flex items-center gap-2'> | <div className='flex items-center gap-2'> | ||||
| <CheckboxWithLabel | |||||
| className='mr-2' | |||||
| label={t('app.showMyCreatedAppsOnly')} | |||||
| isChecked={isCreatedByMe} | |||||
| onChange={() => setIsCreatedByMe(!isCreatedByMe)} | |||||
| /> | |||||
| <TagFilter type='app' value={tagFilterValue} onChange={handleTagsChange} /> | <TagFilter type='app' value={tagFilterValue} onChange={handleTagsChange} /> | ||||
| <Input | <Input | ||||
| showLeftIcon | showLeftIcon |
| byCategories: 'NACH KATEGORIEN', | byCategories: 'NACH KATEGORIEN', | ||||
| searchAllTemplate: 'Alle Vorlagen durchsuchen...', | searchAllTemplate: 'Alle Vorlagen durchsuchen...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Nur meine erstellten Apps anzeigen', | |||||
| } | } | ||||
| export default translation | export default translation |
| removeConfirmContent: 'The current configuration is in use, removing it will turn off the Tracing feature.', | removeConfirmContent: 'The current configuration is in use, removing it will turn off the Tracing feature.', | ||||
| }, | }, | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Created by me', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'POR CATEGORÍAS', | byCategories: 'POR CATEGORÍAS', | ||||
| searchAllTemplate: 'Buscar todas las plantillas...', | searchAllTemplate: 'Buscar todas las plantillas...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Mostrar solo mis aplicaciones creadas', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'بر اساس دسته بندی ها', | byCategories: 'بر اساس دسته بندی ها', | ||||
| searchAllTemplate: 'همه قالب ها را جستجو کنید...', | searchAllTemplate: 'همه قالب ها را جستجو کنید...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'فقط برنامههای ایجاد شده توسط من را نشان بده', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'PAR CATÉGORIES', | byCategories: 'PAR CATÉGORIES', | ||||
| searchAllTemplate: 'Rechercher dans tous les modèles...', | searchAllTemplate: 'Rechercher dans tous les modèles...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Afficher uniquement mes applications créées', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'श्रेणियों द्वारा', | byCategories: 'श्रेणियों द्वारा', | ||||
| searchAllTemplate: 'सभी टेम्पलेट्स खोजें...', | searchAllTemplate: 'सभी टेम्पलेट्स खोजें...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'केवल मेरे बनाए गए ऐप्स दिखाएं', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'PER CATEGORIE', | byCategories: 'PER CATEGORIE', | ||||
| searchAllTemplate: 'Cerca in tutti i modelli...', | searchAllTemplate: 'Cerca in tutti i modelli...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Mostra solo le mie app create', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'カテゴリ別', | byCategories: 'カテゴリ別', | ||||
| searchAllTemplate: 'すべてのテンプレートを検索...', | searchAllTemplate: 'すべてのテンプレートを検索...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: '自分が作成したアプリ', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: '카테고리별', | byCategories: '카테고리별', | ||||
| searchAllTemplate: '모든 템플릿 검색...', | searchAllTemplate: '모든 템플릿 검색...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: '내가 만든 앱만 보기', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'Przeszukaj wszystkie szablony...', | searchAllTemplate: 'Przeszukaj wszystkie szablony...', | ||||
| byCategories: 'WEDŁUG KATEGORII', | byCategories: 'WEDŁUG KATEGORII', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Pokaż tylko moje utworzone aplikacje', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'Pesquisar todos os modelos...', | searchAllTemplate: 'Pesquisar todos os modelos...', | ||||
| byCategories: 'POR CATEGORIAS', | byCategories: 'POR CATEGORIAS', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Mostrar apenas meus aplicativos criados', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'Căutați toate șabloanele...', | searchAllTemplate: 'Căutați toate șabloanele...', | ||||
| byCategories: 'DUPĂ CATEGORII', | byCategories: 'DUPĂ CATEGORII', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Afișează doar aplicațiile create de mine', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'Поиск по всем шаблонам...', | searchAllTemplate: 'Поиск по всем шаблонам...', | ||||
| byCategories: 'ПО КАТЕГОРИЯМ', | byCategories: 'ПО КАТЕГОРИЯМ', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Показать только созданные мной приложения', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'PO KATEGORIJAH', | byCategories: 'PO KATEGORIJAH', | ||||
| searchAllTemplate: 'Preišči vse predloge ...', | searchAllTemplate: 'Preišči vse predloge ...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Prikaži samo aplikacije, ki sem jih ustvaril', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'ค้นหาเทมเพลตทั้งหมด...', | searchAllTemplate: 'ค้นหาเทมเพลตทั้งหมด...', | ||||
| byCategories: 'ตามหมวดหมู่', | byCategories: 'ตามหมวดหมู่', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'แสดงเฉพาะแอปที่ฉันสร้าง', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'Tüm şablonlarda ara...', | searchAllTemplate: 'Tüm şablonlarda ara...', | ||||
| byCategories: 'KATEGORILERE GÖRE', | byCategories: 'KATEGORILERE GÖRE', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Sadece oluşturduğum uygulamaları göster', | |||||
| } | } | ||||
| export default translation | export default translation |
| byCategories: 'ЗА КАТЕГОРІЯМИ', | byCategories: 'ЗА КАТЕГОРІЯМИ', | ||||
| searchAllTemplate: 'Пошук по всіх шаблонах...', | searchAllTemplate: 'Пошук по всіх шаблонах...', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Показати лише створені мною додатки', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: 'Tìm kiếm tất cả các mẫu...', | searchAllTemplate: 'Tìm kiếm tất cả các mẫu...', | ||||
| byCategories: 'THEO DANH MỤC', | byCategories: 'THEO DANH MỤC', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: 'Chỉ hiển thị ứng dụng do tôi tạo', | |||||
| } | } | ||||
| export default translation | export default translation |
| }, | }, | ||||
| }, | }, | ||||
| openInExplore: '在“探索”中打开', | openInExplore: '在“探索”中打开', | ||||
| showMyCreatedAppsOnly: '我创建的', | |||||
| } | } | ||||
| export default translation | export default translation |
| searchAllTemplate: '搜尋所有樣本...', | searchAllTemplate: '搜尋所有樣本...', | ||||
| byCategories: '按類別', | byCategories: '按類別', | ||||
| }, | }, | ||||
| showMyCreatedAppsOnly: '我创建的', | |||||
| } | } | ||||
| export default translation | export default translation |