Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
c991a48d
Commit
c991a48d
authored
Aug 06, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add upload resource button
parent
fd442556
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
18 deletions
+89
-18
ArchivedMemoDialog.tsx
web/src/components/ArchivedMemoDialog.tsx
+1
-1
ResourcesDialog.tsx
web/src/components/ResourcesDialog.tsx
+72
-17
resources-dialog.less
web/src/less/resources-dialog.less
+16
-0
No files found.
web/src/components/ArchivedMemoDialog.tsx
View file @
c991a48d
...
@@ -48,7 +48,7 @@ const ArchivedMemoDialog: React.FC<Props> = (props: Props) => {
...
@@ -48,7 +48,7 @@ const ArchivedMemoDialog: React.FC<Props> = (props: Props) => {
</
div
>
</
div
>
)
:
archivedMemos
.
length
===
0
?
(
)
:
archivedMemos
.
length
===
0
?
(
<
div
className=
"tip-text-container"
>
<
div
className=
"tip-text-container"
>
<
p
className=
"tip-text"
>
Here is No Zettel
s.
</
p
>
<
p
className=
"tip-text"
>
No archived memo
s.
</
p
>
</
div
>
</
div
>
)
:
(
)
:
(
<
div
className=
"archived-memos-container"
>
<
div
className=
"archived-memos-container"
>
...
...
web/src/components/ResourcesDialog.tsx
View file @
c991a48d
...
@@ -11,10 +11,18 @@ import "../less/resources-dialog.less";
...
@@ -11,10 +11,18 @@ import "../less/resources-dialog.less";
interface
Props
extends
DialogProps
{}
interface
Props
extends
DialogProps
{}
interface
State
{
resources
:
Resource
[];
isUploadingResource
:
boolean
;
}
const
ResourcesDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
ResourcesDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
destroy
}
=
props
;
const
{
destroy
}
=
props
;
const
loadingState
=
useLoading
();
const
loadingState
=
useLoading
();
const
[
resources
,
setResources
]
=
useState
<
Resource
[]
>
([]);
const
[
state
,
setState
]
=
useState
<
State
>
({
resources
:
[],
isUploadingResource
:
false
,
});
useEffect
(()
=>
{
useEffect
(()
=>
{
fetchResources
()
fetchResources
()
...
@@ -28,7 +36,45 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
...
@@ -28,7 +36,45 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
const
fetchResources
=
async
()
=>
{
const
fetchResources
=
async
()
=>
{
const
data
=
await
resourceService
.
getResourceList
();
const
data
=
await
resourceService
.
getResourceList
();
setResources
(
data
);
setState
({
...
state
,
resources
:
data
,
});
};
const
handleUploadFileBtnClick
=
async
()
=>
{
if
(
state
.
isUploadingResource
)
{
return
;
}
const
inputEl
=
document
.
createElement
(
"input"
);
inputEl
.
type
=
"file"
;
inputEl
.
multiple
=
false
;
inputEl
.
accept
=
"image/png, image/gif, image/jpeg"
;
inputEl
.
onchange
=
async
()
=>
{
if
(
!
inputEl
.
files
||
inputEl
.
files
.
length
===
0
)
{
return
;
}
setState
({
...
state
,
isUploadingResource
:
true
,
});
const
file
=
inputEl
.
files
[
0
];
try
{
await
resourceService
.
upload
(
file
);
}
catch
(
error
:
any
)
{
toastHelper
.
error
(
"Failed to upload resource
\n
"
+
JSON
.
stringify
(
error
,
null
,
4
));
}
finally
{
setState
({
...
state
,
isUploadingResource
:
false
,
});
await
fetchResources
();
}
};
inputEl
.
click
();
};
};
const
handleCopyResourceLinkBtnClick
=
(
resource
:
Resource
)
=>
{
const
handleCopyResourceLinkBtnClick
=
(
resource
:
Resource
)
=>
{
...
@@ -61,7 +107,12 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
...
@@ -61,7 +107,12 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
</
div
>
</
div
>
<
div
className=
"dialog-content-container"
>
<
div
className=
"dialog-content-container"
>
<
div
className=
"tip-text-container"
>
(👨💻WIP) View your static resources in memos. e.g. images
</
div
>
<
div
className=
"tip-text-container"
>
(👨💻WIP) View your static resources in memos. e.g. images
</
div
>
<
div
className=
"actions-container"
></
div
>
<
div
className=
"upload-resource-container"
onClick=
{
()
=>
handleUploadFileBtnClick
()
}
>
<
div
className=
"upload-resource-btn"
>
<
Icon
.
File
className=
"icon-img"
/>
<
span
>
Upload
</
span
>
</
div
>
</
div
>
{
loadingState
.
isLoading
?
(
{
loadingState
.
isLoading
?
(
<
div
className=
"loading-text-container"
>
<
div
className=
"loading-text-container"
>
<
p
className=
"tip-text"
>
fetching data...
</
p
>
<
p
className=
"tip-text"
>
fetching data...
</
p
>
...
@@ -74,21 +125,25 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
...
@@ -74,21 +125,25 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
<
span
className=
"field-text"
>
TYPE
</
span
>
<
span
className=
"field-text"
>
TYPE
</
span
>
<
span
></
span
>
<
span
></
span
>
</
div
>
</
div
>
{
resources
.
map
((
resource
)
=>
(
{
state
.
resources
.
length
===
0
?
(
<
div
key=
{
resource
.
id
}
className=
"resource-container"
>
<
p
className=
"tip-text"
>
No resource.
</
p
>
<
span
className=
"field-text"
>
{
resource
.
id
}
</
span
>
)
:
(
<
span
className=
"field-text name-text"
>
{
resource
.
filename
}
</
span
>
state
.
resources
.
map
((
resource
)
=>
(
<
span
className=
"field-text"
>
{
resource
.
type
}
</
span
>
<
div
key=
{
resource
.
id
}
className=
"resource-container"
>
<
div
className=
"buttons-container"
>
<
span
className=
"field-text"
>
{
resource
.
id
}
</
span
>
<
Dropdown
className=
"actions-dropdown"
>
<
span
className=
"field-text name-text"
>
{
resource
.
filename
}
</
span
>
<
button
onClick=
{
()
=>
handleCopyResourceLinkBtnClick
(
resource
)
}
>
Copy Link
</
button
>
<
span
className=
"field-text"
>
{
resource
.
type
}
</
span
>
<
button
className=
"delete-btn"
onClick=
{
()
=>
handleDeleteResourceBtnClick
(
resource
)
}
>
<
div
className=
"buttons-container"
>
Delete
<
Dropdown
className=
"actions-dropdown"
>
</
button
>
<
button
onClick=
{
()
=>
handleCopyResourceLinkBtnClick
(
resource
)
}
>
Copy Link
</
button
>
</
Dropdown
>
<
button
className=
"delete-btn"
onClick=
{
()
=>
handleDeleteResourceBtnClick
(
resource
)
}
>
Delete
</
button
>
</
Dropdown
>
</
div
>
</
div
>
</
div
>
</
div
>
))
)
)
}
)
}
</
div
>
</
div
>
)
}
)
}
</
div
>
</
div
>
...
...
web/src/less/resources-dialog.less
View file @
c991a48d
...
@@ -13,6 +13,18 @@
...
@@ -13,6 +13,18 @@
@apply w-full flex flex-row justify-start items-start border border-yellow-600 rounded px-2 py-1 mb-2 text-yellow-600 bg-yellow-50 text-sm;
@apply w-full flex flex-row justify-start items-start border border-yellow-600 rounded px-2 py-1 mb-2 text-yellow-600 bg-yellow-50 text-sm;
}
}
> .upload-resource-container {
@apply mt-2 mb-4 w-full rounded flex flex-row justify-start items-center;
> .upload-resource-btn {
@apply px-3 py-1 rounded cursor-pointer flex flex-row justify-center items-center border border-dashed border-blue-600 text-blue-600 bg-blue-50 hover:opacity-80;
> .icon-img {
@apply w-4 h-auto mr-1;
}
}
}
> .loading-text-container {
> .loading-text-container {
@apply flex flex-col justify-center items-center w-full h-32;
@apply flex flex-col justify-center items-center w-full h-32;
}
}
...
@@ -28,6 +40,10 @@
...
@@ -28,6 +40,10 @@
}
}
}
}
> .tip-text {
@apply w-full text-center text-base my-6 mt-8;
}
> .resource-container {
> .resource-container {
@apply px-2 py-2 w-full grid grid-cols-5;
@apply px-2 py-2 w-full grid grid-cols-5;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment