Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
image-board-svelte
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Trirst
image-board-svelte
Commits
7eb85ba7
Commit
7eb85ba7
authored
Oct 17, 2021
by
Trirst
Browse files
Options
Downloads
Patches
Plain Diff
Search images by tags
parent
3f72218e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/routes/Tag.svelte
+41
-15
41 additions, 15 deletions
src/routes/Tag.svelte
with
41 additions
and
15 deletions
src/routes/Tag.svelte
+
41
−
15
View file @
7eb85ba7
<script>
<script>
import
ImageList
from
"
@/lib/ImageList.svelte
"
;
import
{
fetchAPI
}
from
"
@/static/js/helper
"
;
import
{
fetchAPI
}
from
"
@/static/js/helper
"
;
import
{
paths
}
from
"
@/static/js/paths
"
;
import
{
paths
}
from
"
@/static/js/paths
"
;
import
{
user
}
from
"
@/stores
"
;
import
{
user
}
from
"
@/stores
"
;
...
@@ -14,6 +15,8 @@
...
@@ -14,6 +15,8 @@
let
tag
=
""
;
let
tag
=
""
;
let
tagType
=
tagTypes
[
0
];
let
tagType
=
tagTypes
[
0
];
$
:
validTag
=
checkTag
(
tag
);
$
:
validTag
=
checkTag
(
tag
);
let
searchTags
=
""
;
let
searchedSnowflakes
=
[];
function
putTag
()
{
function
putTag
()
{
const
options
=
{
const
options
=
{
...
@@ -47,9 +50,18 @@
...
@@ -47,9 +50,18 @@
const
regex
=
/^
[
a-z0-9()_-
]
*$/g
;
const
regex
=
/^
[
a-z0-9()_-
]
*$/g
;
return
!
tag
.
match
(
regex
)
||
tag
.
length
>
128
;
return
!
tag
.
match
(
regex
)
||
tag
.
length
>
128
;
}
}
async
function
searchImagesByTags
()
{
searchedSnowflakes
=
(
await
fetchAPI
(
paths
.
SearchField
(
parseSearchTags
(
searchTags
))))
||
[];
}
function
parseSearchTags
(
searchTags
)
{
return
searchTags
.
split
(
"
"
).
join
(
"
!
"
);
}
</script>
</script>
<div
class=
"space-x-4 m-2"
>
<section
class=
"m-2 space-y-4"
>
<div
class=
"space-x-4"
>
<input
type=
"text"
placeholder=
"Tag name"
bind:value=
{
tag
}
/>
<input
type=
"text"
placeholder=
"Tag name"
bind:value=
{
tag
}
/>
<select
bind:value=
{
tagType
}
>
<select
bind:value=
{
tagType
}
>
<option
disabled
>
Tag type
</option>
<option
disabled
>
Tag type
</option>
...
@@ -57,10 +69,24 @@
...
@@ -57,10 +69,24 @@
<option
value=
{
type
}
>
{
type
}
</option>
<option
value=
{
type
}
>
{
type
}
</option>
{
/each
}
{
/each
}
</select>
</select>
<button
on:click=
{
addTag
}
disabled=
{
validTag
}
class=
"disabled:opacity-50"
<button
>
Add
</button
on:click=
{
addTag
}
disabled=
{
validTag
}
class=
"disabled:opacity-50"
>
Add
</button
>
>
</div>
{
#if
validTag
}
{
#if
validTag
}
<div>
No space or capital letter in tag name allowed.
</div>
<div>
No space or capital letter in tag name allowed.
</div>
{
/if
}
{
/if
}
</div>
<div
class=
"space-x-4"
>
<input
type=
"text"
placeholder=
"Search tag"
bind:value=
{
searchTags
}
/>
<button
disabled=
{
searchTags
===
""
}
class=
"disabled:opacity-50"
on:click=
{
searchImagesByTags
}
>
Search
</button
>
<div>
Delimit tags by space to search multiple
</div>
</div>
</section>
<ImageList
snowflakes=
{
searchedSnowflakes
}
/>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment