Skip to content

Commit

Permalink
🌟feat: support link filter
Browse files Browse the repository at this point in the history
  • Loading branch information
blinko-space committed Nov 10, 2024
1 parent ca47f1c commit 9a5aac6
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 16 deletions.
5 changes: 4 additions & 1 deletion public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"reviewed": "Überprüft",
"created-in": "Erstellt in",
"set-as-public": "Als öffentlich festlegen",
"unset-as-public": "Nicht als öffentlich gekennzeichnet"
"unset-as-public": "Nicht als öffentlich gekennzeichnet",
"no-tag": "Keine Markierung",
"with-link": "Mit Link",
"has-file": "Hat Datei"
}
5 changes: 4 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"cancel-top": "Cancel Top",
"created-in": "Created in",
"set-as-public": "Set as Public",
"unset-as-public": "Unset as Public"
"unset-as-public": "Unset as Public",
"with-link": "With Link",
"no-tag": "No Tag",
"has-file": "Has File"
}
5 changes: 4 additions & 1 deletion public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"insert-sandpack": "Insertar saco de arena",
"created-in": "Creado en",
"set-as-public": "Establecer como público",
"unset-as-public": "Desactivado como Público"
"unset-as-public": "Desactivado como Público",
"no-tag": "Sin etiqueta",
"with-link": "Con enlace",
"has-file": "Tiene archivo"
}
5 changes: 4 additions & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"reviewed": "Examiné",
"created-in": "Créé en",
"set-as-public": "Définir comme public",
"unset-as-public": "Non défini comme public"
"unset-as-public": "Non défini comme public",
"no-tag": "Pas d'étiquette",
"with-link": "Avec lien",
"has-file": "A le fichier"
}
5 changes: 4 additions & 1 deletion public/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"the-two-passwords-are-inconsistent": "2つのパスワードは矛盾している",
"created-in": "で作成された。",
"set-as-public": "公開設定",
"unset-as-public": "公開未設定"
"unset-as-public": "公開未設定",
"no-tag": "タグなし",
"with-link": "リンク付き",
"has-file": "ファイル"
}
5 changes: 4 additions & 1 deletion public/locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@
"upload-file": "파일 업로드",
"your-changes-have-been-saved": "변경 사항이 저장되었습니다!",
"created-in": "에 생성됨",
"unset-as-public": "공개로 설정 해제"
"unset-as-public": "공개로 설정 해제",
"no-tag": "태그 없음",
"with-link": "링크 사용",
"has-file": "파일 있음"
}
5 changes: 4 additions & 1 deletion public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@
"detail": "Detalhes",
"created-in": "Criado em",
"set-as-public": "Definir como público",
"unset-as-public": "Não definido como público"
"unset-as-public": "Não definido como público",
"no-tag": "Sem etiqueta",
"with-link": "Com ligação",
"has-file": "Tem ficheiro"
}
5 changes: 4 additions & 1 deletion public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"model-provider": "Поставщик моделей",
"created-in": "Создан в",
"set-as-public": "Установить как общедоступный",
"unset-as-public": "Не установлен как общественный"
"unset-as-public": "Не установлен как общественный",
"no-tag": "Без бирки",
"with-link": "Со ссылкой",
"has-file": "Имеет файл"
}
5 changes: 4 additions & 1 deletion public/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@
"save": "保存",
"created-in": "创建于",
"set-as-public": "设置为公开",
"unset-as-public": "取消公开"
"unset-as-public": "取消公开",
"no-tag": "无标签",
"with-link": "带链接",
"has-file": "有文件"
}
4 changes: 3 additions & 1 deletion public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@
"save": "保存",
"created-in": "创建于",
"set-as-public": "设置为公开",
"unset-as-public": "取消公开"
"unset-as-public": "取消公开",
"with-link": "带链接",
"has-file": "有文件"
}
11 changes: 9 additions & 2 deletions src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,24 @@ export const CommonLayout = observer(({
</PopoverTrigger>
<PopoverContent>
<div className="p-2 flex gap-2">
<Link href='/all?withLink=true' onClick={() => blinkoStore.forceQuery++}>
<Card shadow="none" className="hover:shadow cursor-pointer p-2 flex flex-col items-center text-desc border">
<Icon icon="ri:link" width="24" height="24" />
<div className="text-sm">{t('with-link')}</div>
</Card>
</Link>

<Link href='/all?withoutTag=true' onClick={() => blinkoStore.forceQuery++}>
<Card shadow="none" className="hover:shadow cursor-pointer p-2 flex flex-col items-center text-desc border">
<Icon icon="majesticons:tag-off-line" width="24" height="24" />
<div className="text-sm" >No Tag</div>
<div className="text-sm" >{t('no-tag')}</div>
</Card>
</Link>

<Link href='/all?withFile=true' onClick={() => blinkoStore.forceQuery++}>
<Card shadow="none" className="hover:shadow cursor-pointer p-2 flex flex-col items-center text-desc border">
<Icon icon="ic:round-attachment" width="24" height="24" />
<div className="text-sm">Has File</div>
<div className="text-sm">{t('has-file')}</div>
</Card>
</Link>
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/server/routers/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const noteRouter = router({
isRecycle: z.boolean().default(false).optional(),
searchText: z.string().default('').optional(),
withoutTag: z.boolean().default(false).optional(),
withFile: z.boolean().default(false).optional()
withFile: z.boolean().default(false).optional(),
withLink: z.boolean().default(false).optional(),
}))
.output(z.array(notesSchema.merge(
z.object({
Expand All @@ -38,7 +39,7 @@ export const noteRouter = router({
}))
))
.mutation(async function ({ input }) {
const { tagId, type, isArchived, isRecycle, searchText, page, size, orderBy, withFile, withoutTag } = input
const { tagId, type, isArchived, isRecycle, searchText, page, size, orderBy, withFile, withoutTag, withLink } = input
let where: Prisma.notesWhereInput = { isArchived, isRecycle }
if (tagId) {
const tags = await prisma.tagsToNote.findMany({ where: { tagId } })
Expand All @@ -53,6 +54,12 @@ export const noteRouter = router({
if (withoutTag) {
where.tags = { none: {} }
}
if (withLink) {
where.OR = [
{ content: { contains: 'http://', mode: 'insensitive' } },
{ content: { contains: 'https://', mode: 'insensitive' } }
];
}
if (type != -1) { where.type = type }
return await prisma.notes.findMany({
where,
Expand Down
9 changes: 7 additions & 2 deletions src/store/blinkoStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export class BlinkoStore implements Store {
tagId: null as number | null,
searchText: "",
withoutTag: false,
withFile: false
withFile: false,
withLink: false
}
noteTypeDefault: NoteType = NoteType.BLINKO
currentCommonFilter: filterType | null = null
Expand Down Expand Up @@ -202,14 +203,15 @@ export class BlinkoStore implements Store {
}

useQuery(router) {
const { tagId, withoutTag, withFile } = router.query;
const { tagId, withoutTag, withFile, withLink } = router.query;
useEffect(() => {
if (!router.isReady) return
this.noteListFilterConfig.type = NoteType.BLINKO
this.noteTypeDefault = NoteType.BLINKO
this.noteListFilterConfig.tagId = null
this.noteListFilterConfig.isArchived = false
this.noteListFilterConfig.withoutTag = false
this.noteListFilterConfig.withLink = false
this.noteListFilterConfig.withFile = false

if (router.pathname == '/notes') {
Expand All @@ -222,6 +224,9 @@ export class BlinkoStore implements Store {
if (withoutTag) {
this.noteListFilterConfig.withoutTag = true
}
if (withLink) {
this.noteListFilterConfig.withLink = true
}
if (withFile) {
this.noteListFilterConfig.withFile = true
}
Expand Down

0 comments on commit 9a5aac6

Please sign in to comment.