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
34ae9b06
Commit
34ae9b06
authored
Oct 05, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update default storage back to database
parent
077bf954
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
12 deletions
+23
-12
resource.go
api/v1/resource.go
+1
-1
storage.go
api/v1/storage.go
+3
-2
system.go
api/v1/system.go
+1
-1
resource_service.go
api/v2/resource_service.go
+14
-4
StorageSection.tsx
web/src/components/Settings/StorageSection.tsx
+2
-2
ShareMemoDialog.tsx
web/src/components/ShareMemoDialog.tsx
+1
-1
en.json
web/src/locales/en.json
+1
-1
No files found.
api/v1/resource.go
View file @
34ae9b06
...
@@ -567,7 +567,7 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc
...
@@ -567,7 +567,7 @@ func SaveResourceBlob(ctx context.Context, s *store.Store, create *store.Resourc
return
errors
.
Wrap
(
err
,
"Failed to find SystemSettingStorageServiceIDName"
)
return
errors
.
Wrap
(
err
,
"Failed to find SystemSettingStorageServiceIDName"
)
}
}
storageServiceID
:=
Local
Storage
storageServiceID
:=
Default
Storage
if
systemSettingStorageServiceID
!=
nil
{
if
systemSettingStorageServiceID
!=
nil
{
err
=
json
.
Unmarshal
([]
byte
(
systemSettingStorageServiceID
.
Value
),
&
storageServiceID
)
err
=
json
.
Unmarshal
([]
byte
(
systemSettingStorageServiceID
.
Value
),
&
storageServiceID
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
api/v1/storage.go
View file @
34ae9b06
...
@@ -13,10 +13,11 @@ import (
...
@@ -13,10 +13,11 @@ import (
const
(
const
(
// LocalStorage means the storage service is local file system.
// LocalStorage means the storage service is local file system.
// Default storage service is local file system.
LocalStorage
int32
=
-
1
LocalStorage
int32
=
-
1
// DatabaseStorage means the storage service is database.
// DatabaseStorage means the storage service is database.
DatabaseStorage
int32
=
0
DatabaseStorage
int32
=
0
// Default storage service is database.
DefaultStorage
int32
=
DatabaseStorage
)
)
type
StorageType
string
type
StorageType
string
...
@@ -212,7 +213,7 @@ func (s *APIV1Service) DeleteStorage(c echo.Context) error {
...
@@ -212,7 +213,7 @@ func (s *APIV1Service) DeleteStorage(c echo.Context) error {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find storage"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find storage"
)
.
SetInternal
(
err
)
}
}
if
systemSetting
!=
nil
{
if
systemSetting
!=
nil
{
storageServiceID
:=
Local
Storage
storageServiceID
:=
Default
Storage
err
=
json
.
Unmarshal
([]
byte
(
systemSetting
.
Value
),
&
storageServiceID
)
err
=
json
.
Unmarshal
([]
byte
(
systemSetting
.
Value
),
&
storageServiceID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal storage service id"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal storage service id"
)
.
SetInternal
(
err
)
...
...
api/v1/system.go
View file @
34ae9b06
...
@@ -89,7 +89,7 @@ func (s *APIV1Service) GetSystemStatus(c echo.Context) error {
...
@@ -89,7 +89,7 @@ func (s *APIV1Service) GetSystemStatus(c echo.Context) error {
Appearance
:
"system"
,
Appearance
:
"system"
,
ExternalURL
:
""
,
ExternalURL
:
""
,
},
},
StorageServiceID
:
Local
Storage
,
StorageServiceID
:
Default
Storage
,
LocalStoragePath
:
"assets/{timestamp}_{filename}"
,
LocalStoragePath
:
"assets/{timestamp}_{filename}"
,
MemoDisplayWithUpdatedTs
:
false
,
MemoDisplayWithUpdatedTs
:
false
,
}
}
...
...
api/v2/resource_service.go
View file @
34ae9b06
...
@@ -39,7 +39,7 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListReso
...
@@ -39,7 +39,7 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListReso
response
:=
&
apiv2pb
.
ListResourcesResponse
{}
response
:=
&
apiv2pb
.
ListResourcesResponse
{}
for
_
,
resource
:=
range
resources
{
for
_
,
resource
:=
range
resources
{
response
.
Resources
=
append
(
response
.
Resources
,
convertResourceFromStore
(
resource
))
response
.
Resources
=
append
(
response
.
Resources
,
s
.
convertResourceFromStore
(
ctx
,
resource
))
}
}
return
response
,
nil
return
response
,
nil
}
}
...
@@ -63,7 +63,7 @@ func (s *ResourceService) UpdateResource(ctx context.Context, request *apiv2pb.U
...
@@ -63,7 +63,7 @@ func (s *ResourceService) UpdateResource(ctx context.Context, request *apiv2pb.U
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to update resource: %v"
,
err
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to update resource: %v"
,
err
)
}
}
return
&
apiv2pb
.
UpdateResourceResponse
{
return
&
apiv2pb
.
UpdateResourceResponse
{
Resource
:
convertResourceFromStore
(
resource
),
Resource
:
s
.
convertResourceFromStore
(
ctx
,
resource
),
},
nil
},
nil
}
}
...
@@ -90,7 +90,17 @@ func (s *ResourceService) DeleteResource(ctx context.Context, request *apiv2pb.D
...
@@ -90,7 +90,17 @@ func (s *ResourceService) DeleteResource(ctx context.Context, request *apiv2pb.D
return
&
apiv2pb
.
DeleteResourceResponse
{},
nil
return
&
apiv2pb
.
DeleteResourceResponse
{},
nil
}
}
func
convertResourceFromStore
(
resource
*
store
.
Resource
)
*
apiv2pb
.
Resource
{
func
(
s
*
ResourceService
)
convertResourceFromStore
(
ctx
context
.
Context
,
resource
*
store
.
Resource
)
*
apiv2pb
.
Resource
{
var
memoID
*
int32
if
resource
.
MemoID
!=
nil
{
memo
,
_
:=
s
.
Store
.
GetMemo
(
ctx
,
&
store
.
FindMemo
{
ID
:
resource
.
MemoID
,
})
if
memo
!=
nil
{
memoID
=
&
memo
.
ID
}
}
return
&
apiv2pb
.
Resource
{
return
&
apiv2pb
.
Resource
{
Id
:
resource
.
ID
,
Id
:
resource
.
ID
,
CreatedTs
:
timestamppb
.
New
(
time
.
Unix
(
resource
.
CreatedTs
,
0
)),
CreatedTs
:
timestamppb
.
New
(
time
.
Unix
(
resource
.
CreatedTs
,
0
)),
...
@@ -98,6 +108,6 @@ func convertResourceFromStore(resource *store.Resource) *apiv2pb.Resource {
...
@@ -98,6 +108,6 @@ func convertResourceFromStore(resource *store.Resource) *apiv2pb.Resource {
ExternalLink
:
resource
.
ExternalLink
,
ExternalLink
:
resource
.
ExternalLink
,
Type
:
resource
.
Type
,
Type
:
resource
.
Type
,
Size
:
resource
.
Size
,
Size
:
resource
.
Size
,
MemoId
:
resource
.
M
emoID
,
MemoId
:
m
emoID
,
}
}
}
}
web/src/components/Settings/StorageSection.tsx
View file @
34ae9b06
...
@@ -66,13 +66,13 @@ const StorageSection = () => {
...
@@ -66,13 +66,13 @@ const StorageSection = () => {
handleActiveStorageServiceChanged
(
Number
(
event
.
target
.
value
));
handleActiveStorageServiceChanged
(
Number
(
event
.
target
.
value
));
}
}
}
}
>
>
<
div
className=
"w-full flex flex-row justify-start items-center gap-x-2"
>
<
Radio
value=
{
"0"
}
label=
{
t
(
"setting.storage-section.type-database"
)
}
/>
<
div
className=
"w-full mt-2 flex flex-row justify-start items-center gap-x-2"
>
<
Radio
value=
{
"-1"
}
label=
{
t
(
"setting.storage-section.type-local"
)
}
/>
<
Radio
value=
{
"-1"
}
label=
{
t
(
"setting.storage-section.type-local"
)
}
/>
<
IconButton
size=
"sm"
onClick=
{
()
=>
showUpdateLocalStorageDialog
(
systemStatus
.
localStoragePath
)
}
>
<
IconButton
size=
"sm"
onClick=
{
()
=>
showUpdateLocalStorageDialog
(
systemStatus
.
localStoragePath
)
}
>
<
Icon
.
PenBox
className=
"w-4 h-auto"
/>
<
Icon
.
PenBox
className=
"w-4 h-auto"
/>
</
IconButton
>
</
IconButton
>
</
div
>
</
div
>
<
Radio
value=
{
"0"
}
label=
{
t
(
"setting.storage-section.type-database"
)
}
/>
{
storageList
.
map
((
storage
)
=>
(
{
storageList
.
map
((
storage
)
=>
(
<
Radio
key=
{
storage
.
id
}
value=
{
storage
.
id
}
label=
{
storage
.
name
}
/>
<
Radio
key=
{
storage
.
id
}
value=
{
storage
.
id
}
label=
{
storage
.
name
}
/>
))
}
))
}
...
...
web/src/components/ShareMemoDialog.tsx
View file @
34ae9b06
...
@@ -119,7 +119,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
...
@@ -119,7 +119,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
<
div
className=
"flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-700 py-4 px-6"
>
<
div
className=
"flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-700 py-4 px-6"
>
<
UserAvatar
className=
"mr-2"
avatarUrl=
{
user
.
avatarUrl
}
/>
<
UserAvatar
className=
"mr-2"
avatarUrl=
{
user
.
avatarUrl
}
/>
<
div
className=
"w-auto grow truncate flex mr-2 flex-col justify-center items-start"
>
<
div
className=
"w-auto grow truncate flex mr-2 flex-col justify-center items-start"
>
<
span
className=
"w-full text
-sm truncate font-bold
text-gray-600 dark:text-gray-300"
>
{
user
.
nickname
||
user
.
username
}
</
span
>
<
span
className=
"w-full text
truncate font-medium
text-gray-600 dark:text-gray-300"
>
{
user
.
nickname
||
user
.
username
}
</
span
>
</
div
>
</
div
>
<
QRCodeSVG
<
QRCodeSVG
value=
{
`${window.location.origin}/m/${memo.id}`
}
value=
{
`${window.location.origin}/m/${memo.id}`
}
...
...
web/src/locales/en.json
View file @
34ae9b06
...
@@ -202,7 +202,7 @@
...
@@ -202,7 +202,7 @@
"storage-section"
:
{
"storage-section"
:
{
"current-storage"
:
"Current object storage"
,
"current-storage"
:
"Current object storage"
,
"type-database"
:
"Database"
,
"type-database"
:
"Database"
,
"type-local"
:
"Local"
,
"type-local"
:
"Local
file system
"
,
"storage-services-list"
:
"Storage service list"
,
"storage-services-list"
:
"Storage service list"
,
"create-a-service"
:
"Create a service"
,
"create-a-service"
:
"Create a service"
,
"update-a-service"
:
"Update a service"
,
"update-a-service"
:
"Update a service"
,
...
...
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