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
6a8c559e
Commit
6a8c559e
authored
Jul 09, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update visitor view buttons
parent
7418d296
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
47 additions
and
53 deletions
+47
-53
basic_auth.go
server/basic_auth.go
+1
-1
memo.go
server/memo.go
+1
-1
shortcut.go
server/shortcut.go
+1
-1
tag.go
server/tag.go
+8
-1
10002__memo.sql
store/db/seed/10002__memo.sql
+2
-4
MemoList.tsx
web/src/components/MemoList.tsx
+1
-7
MenuBtnsPopup.tsx
web/src/components/MenuBtnsPopup.tsx
+3
-12
Sidebar.tsx
web/src/components/Sidebar.tsx
+25
-9
memo-list.less
web/src/less/memo-list.less
+5
-16
Home.tsx
web/src/pages/Home.tsx
+0
-1
No files found.
server/basic_auth.go
View file @
6a8c559e
...
...
@@ -55,7 +55,7 @@ func removeUserSession(c echo.Context) error {
func
BasicAuthMiddleware
(
s
*
Server
,
next
echo
.
HandlerFunc
)
echo
.
HandlerFunc
{
return
func
(
c
echo
.
Context
)
error
{
// Skip auth for some paths.
if
common
.
HasPrefixes
(
c
.
Path
(),
"/api/auth"
,
"/api/ping"
,
"/api/status"
,
"/api/user/:
id/
"
)
{
if
common
.
HasPrefixes
(
c
.
Path
(),
"/api/auth"
,
"/api/ping"
,
"/api/status"
,
"/api/user/:
userId
"
)
{
return
next
(
c
)
}
...
...
server/memo.go
View file @
6a8c559e
...
...
@@ -70,7 +70,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
}
else
{
userID
,
ok
:=
c
.
Get
(
getUserIDContextKey
())
.
(
int
)
if
!
ok
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Missing
creatorI
d to find memo"
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Missing
user i
d to find memo"
)
}
memoFind
.
CreatorID
=
&
userID
...
...
server/shortcut.go
View file @
6a8c559e
...
...
@@ -66,7 +66,7 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
}
else
{
userID
,
ok
:=
c
.
Get
(
getUserIDContextKey
())
.
(
int
)
if
!
ok
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Missing
creatorI
d to find shortcut"
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Missing
user i
d to find shortcut"
)
}
shortcutFind
.
CreatorID
=
&
userID
...
...
server/tag.go
View file @
6a8c559e
...
...
@@ -26,12 +26,19 @@ func (s *Server) registerTagRoutes(g *echo.Group) {
}
else
{
userID
,
ok
:=
c
.
Get
(
getUserIDContextKey
())
.
(
int
)
if
!
ok
{
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Missing
creatorId to find shortcut
"
)
return
echo
.
NewHTTPError
(
http
.
StatusBadRequest
,
"Missing
user id to find tag
"
)
}
memoFind
.
CreatorID
=
&
userID
}
// Only can get PUBLIC memos in visitor mode
_
,
ok
:=
c
.
Get
(
getUserIDContextKey
())
.
(
int
)
if
!
ok
{
publicVisibility
:=
api
.
Public
memoFind
.
Visibility
=
&
publicVisibility
}
memoList
,
err
:=
s
.
Store
.
FindMemoList
(
&
memoFind
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find memo list"
)
.
SetInternal
(
err
)
...
...
store/db/seed/10002__memo.sql
View file @
6a8c559e
...
...
@@ -7,8 +7,7 @@ INSERT INTO
VALUES
(
101
,
'#Hello 👋 Welcome to memos
'
,
'#Hello 👋 Welcome to memos'
,
101
);
...
...
@@ -25,8 +24,7 @@ VALUES
- [ ] Take more photos about **🌄 sunset**;
- [x] Clean the room;
- [x] Read *📖 The Little Prince*;
(👆 click to toggle status)
'
,
(👆 click to toggle status)'
,
101
);
...
...
web/src/components/MemoList.tsx
View file @
6a8c559e
...
...
@@ -101,13 +101,7 @@ const MemoList: React.FC<Props> = () => {
))
}
<
div
className=
"status-text-container"
>
<
p
className=
"status-text"
>
{
isFetching
?
"Fetching data..."
:
sortedMemos
.
length
===
0
?
"Oops, there is nothing"
:
showMemoFilter
?
""
:
"Fetching completed 🎉"
}
{
isFetching
?
"Fetching data..."
:
sortedMemos
.
length
===
0
?
"No memos 🌃"
:
showMemoFilter
?
""
:
"All memos are ready 🎉"
}
</
p
>
</
div
>
</
div
>
...
...
web/src/components/MenuBtnsPopup.tsx
View file @
6a8c559e
import
{
useEffect
,
useRef
}
from
"react"
;
import
*
as
api
from
"../helpers/api"
;
import
{
locationService
,
userService
}
from
"../services"
;
import
{
useAppSelector
}
from
"../store"
;
import
toastHelper
from
"./Toast"
;
import
Only
from
"./common/OnlyWhen"
;
import
showAboutSiteDialog
from
"./AboutSiteDialog"
;
import
"../less/menu-btns-popup.less"
;
...
...
@@ -13,7 +13,6 @@ interface Props {
const
MenuBtnsPopup
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
shownStatus
,
setShownStatus
}
=
props
;
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
const
popupElRef
=
useRef
<
HTMLDivElement
>
(
null
);
useEffect
(()
=>
{
...
...
@@ -65,19 +64,11 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
<
button
className=
"btn action-btn"
onClick=
{
handlePingBtnClick
}
>
<
span
className=
"icon"
>
🎯
</
span
>
Ping
</
button
>
{
!
userService
.
isVisitorMode
()
?
(
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
button
className=
"btn action-btn"
onClick=
{
handleSignOutBtnClick
}
>
<
span
className=
"icon"
>
👋
</
span
>
Sign out
</
button
>
)
:
user
?
(
<
button
className=
"btn action-btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/"
)
}
>
<
span
className=
"icon"
>
🏠
</
span
>
Go Back
</
button
>
)
:
(
<
button
className=
"btn action-btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/signin"
)
}
>
<
span
className=
"icon"
>
👉
</
span
>
Sign in
</
button
>
)
}
</
Only
>
</
div
>
);
};
...
...
web/src/components/Sidebar.tsx
View file @
6a8c559e
import
{
userService
}
from
"../services"
;
import
{
useAppSelector
}
from
"../store"
;
import
Only
from
"./common/OnlyWhen"
;
import
showDailyReviewDialog
from
"./DailyReviewDialog"
;
import
showSettingDialog
from
"./SettingDialog"
;
...
...
@@ -12,6 +13,8 @@ import "../less/siderbar.less";
interface
Props
{}
const
Sidebar
:
React
.
FC
<
Props
>
=
()
=>
{
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
const
handleMyAccountBtnClick
=
()
=>
{
showSettingDialog
();
};
...
...
@@ -29,18 +32,31 @@ const Sidebar: React.FC<Props> = () => {
</
div
>
<
UserBanner
/>
<
UsageHeatMap
/>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
div
className=
"action-btns-container"
>
<
button
className=
"btn action-btn"
onClick=
{
()
=>
showDailyReviewDialog
()
}
>
<
span
className=
"icon"
>
📅
</
span
>
Daily Review
</
button
>
<
div
className=
"action-btns-container"
>
<
button
className=
"btn action-btn"
onClick=
{
()
=>
showDailyReviewDialog
()
}
>
<
span
className=
"icon"
>
📅
</
span
>
Daily Review
</
button
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
button
className=
"btn action-btn"
onClick=
{
handleMyAccountBtnClick
}
>
<
span
className=
"icon"
>
⚙️
</
span
>
Setting
</
button
>
<
button
className=
"btn action-btn"
onClick=
{
handleArchivedBtnClick
}
>
<
span
className=
"icon"
>
🗂
</
span
>
Archived
</
button
>
</
div
>
</
Only
>
<
button
className=
"btn action-btn"
onClick=
{
handleArchivedBtnClick
}
>
<
span
className=
"icon"
>
🗂
</
span
>
Archived
</
button
>
<
Only
when=
{
userService
.
isVisitorMode
()
}
>
{
user
?
(
<
button
className=
"btn action-btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/"
)
}
>
<
span
className=
"icon"
>
🏠
</
span
>
Back to Home
</
button
>
)
:
(
<
button
className=
"btn action-btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/signin"
)
}
>
<
span
className=
"icon"
>
👉
</
span
>
Sign in
</
button
>
)
}
</
Only
>
</
div
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
ShortcutList
/>
</
Only
>
<
TagList
/>
...
...
web/src/less/memo-list.less
View file @
6a8c559e
@import "./mixin.less";
.memo-list-container {
.flex(column, flex-start, flex-start);
width: 100%;
max-width: 100%;
overflow-y: scroll;
@apply flex flex-col justify-start items-start w-full max-w-full overflow-y-scroll;
.hide-scroll-bar();
> .status-text-container {
.flex(column, flex-start, center);
width: 100%;
margin-top: 16px;
margin-bottom: 16px;
@apply flex flex-col justify-start items-center w-full my-6;
&.completed {
margin-bottom: 64px;
}
&.invisible {
visibility: hidden;
@apply mb-16;
}
> .status-text {
font-size: 13px;
color: gray;
@apply text-sm text-gray-400 italic;
}
}
&.completed {
@apply pb-
40
;
@apply pb-
16
;
}
}
web/src/pages/Home.tsx
View file @
6a8c559e
import
{
useEffect
}
from
"react"
;
import
{
locationService
,
userService
}
from
"../services"
;
import
*
as
api
from
"../helpers/api"
;
import
useLoading
from
"../hooks/useLoading"
;
import
Only
from
"../components/common/OnlyWhen"
;
import
Sidebar
from
"../components/Sidebar"
;
...
...
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