Compare commits
No commits in common. "9df85d9580564db1cd0299935d7d9a37eb49050b" and "04c101982f8a16edfd74aef8ad60eca7ec0652c3" have entirely different histories.
9df85d9580
...
04c101982f
15 changed files with 1244 additions and 508 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" version="25.0.1">
|
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" version="24.7.8">
|
||||||
<diagram name="Page-1" id="G2-a1oUG1H-bwT7ce2_Y">
|
<diagram name="Page-1" id="G2-a1oUG1H-bwT7ce2_Y">
|
||||||
<mxGraphModel dx="698" dy="423" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
<mxGraphModel dx="986" dy="620" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||||
<root>
|
<root>
|
||||||
<mxCell id="0" />
|
<mxCell id="0" />
|
||||||
<mxCell id="1" style="" parent="0" />
|
<mxCell id="1" style="" parent="0" />
|
||||||
|
|
@ -10,36 +10,33 @@
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-27" value="<b>Backend</b><div>PostgreSQL</div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" parent="1" vertex="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-27" value="<b>Backend</b><div>PostgreSQL</div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" parent="1" vertex="1">
|
||||||
<mxGeometry x="680" y="40" width="100" height="40" as="geometry" />
|
<mxGeometry x="680" y="40" width="100" height="40" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;endArrow=classic;endFill=1;" edge="1" parent="1" source="rRo1dadeA1uCrzt-e38k-28" target="_PY1-sNXTUqCv9qV1nWE-1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-28" value="<b>Frontend</b><div>notes2.mjs</div>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
|
||||||
<mxGeometry relative="1" as="geometry" />
|
<mxGeometry x="40" y="40" width="100" height="40" as="geometry" />
|
||||||
</mxCell>
|
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-28" value="<b>Notes2 Component</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" parent="1" vertex="1">
|
|
||||||
<mxGeometry x="1200" y="40" width="150" height="40" as="geometry" />
|
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-29" value="<b>NodeStore</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-29" value="<b>NodeStore</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" parent="1" vertex="1">
|
||||||
<mxGeometry x="200" y="40" width="100" height="40" as="geometry" />
|
<mxGeometry x="200" y="40" width="100" height="40" as="geometry" />
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-30" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-30" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
||||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||||
<mxPoint x="90" y="480" as="sourcePoint" />
|
<mxPoint x="89.5" y="780" as="sourcePoint" />
|
||||||
<mxPoint x="89.5" y="80" as="targetPoint" />
|
<mxPoint x="89.5" y="80" as="targetPoint" />
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-31" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-31" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
||||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||||
<mxPoint x="250" y="480" as="sourcePoint" />
|
<mxPoint x="249.5" y="780" as="sourcePoint" />
|
||||||
<mxPoint x="249.5" y="80" as="targetPoint" />
|
<mxPoint x="249.5" y="80" as="targetPoint" />
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-32" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-32" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
||||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||||
<mxPoint x="570" y="480" as="sourcePoint" />
|
<mxPoint x="570" y="780" as="sourcePoint" />
|
||||||
<mxPoint x="570" y="80" as="targetPoint" />
|
<mxPoint x="570" y="80" as="targetPoint" />
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-33" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-33" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
||||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||||
<mxPoint x="730" y="480" as="sourcePoint" />
|
<mxPoint x="729.5" y="780" as="sourcePoint" />
|
||||||
<mxPoint x="729.5" y="80" as="targetPoint" />
|
<mxPoint x="729.5" y="80" as="targetPoint" />
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
|
|
@ -48,50 +45,10 @@
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-59" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-59" value="" style="endArrow=none;html=1;rounded=0;strokeColor=#B3B3B3;" parent="1" edge="1">
|
||||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||||
<mxPoint x="410" y="480" as="sourcePoint" />
|
<mxPoint x="409.5" y="780" as="sourcePoint" />
|
||||||
<mxPoint x="409.5" y="80" as="targetPoint" />
|
<mxPoint x="409.5" y="80" as="targetPoint" />
|
||||||
</mxGeometry>
|
</mxGeometry>
|
||||||
</mxCell>
|
</mxCell>
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;startArrow=classic;startFill=1;" edge="1" parent="1" source="_PY1-sNXTUqCv9qV1nWE-1" target="_PY1-sNXTUqCv9qV1nWE-3">
|
|
||||||
<mxGeometry relative="1" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-7" value="&nbsp;nodeStore.getTreeNodes()&nbsp;<div>First level of tree nodes</div>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="_PY1-sNXTUqCv9qV1nWE-4">
|
|
||||||
<mxGeometry x="-0.0383" y="-3" relative="1" as="geometry">
|
|
||||||
<mxPoint x="8" y="-28" as="offset" />
|
|
||||||
</mxGeometry>
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="_PY1-sNXTUqCv9qV1nWE-1" target="_PY1-sNXTUqCv9qV1nWE-10">
|
|
||||||
<mxGeometry relative="1" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-1" value="<b>Tree Component</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;" vertex="1" parent="1">
|
|
||||||
<mxGeometry x="1215" y="150" width="120" height="50" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-3" value="<b>NodeStore</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;" vertex="1" parent="1">
|
|
||||||
<mxGeometry x="1620" y="150" width="90" height="50" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-9" value="[]Nodes" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
|
||||||
<mxGeometry x="1450" y="178" width="60" height="30" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="_PY1-sNXTUqCv9qV1nWE-10" target="_PY1-sNXTUqCv9qV1nWE-12">
|
|
||||||
<mxGeometry relative="1" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-10" value="<b>TreeNode Component</b>" style="whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;rounded=1;" vertex="1" parent="1">
|
|
||||||
<mxGeometry x="1215" y="270" width="120" height="60" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="_PY1-sNXTUqCv9qV1nWE-12" target="_PY1-sNXTUqCv9qV1nWE-3">
|
|
||||||
<mxGeometry relative="1" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-17" value="getTreeNodes()<div>for children of node</div>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="_PY1-sNXTUqCv9qV1nWE-16">
|
|
||||||
<mxGeometry x="0.0125" y="1" relative="1" as="geometry">
|
|
||||||
<mxPoint as="offset" />
|
|
||||||
</mxGeometry>
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-12" value="<b>Node</b>" style="whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeColor=#82b366;rounded=1;" vertex="1" parent="1">
|
|
||||||
<mxGeometry x="1605" y="270" width="120" height="60" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="_PY1-sNXTUqCv9qV1nWE-15" value="When rendered, and parent is expanded,<div>fetchChildren()</div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
|
|
||||||
<mxGeometry x="1340" y="263" width="240" height="40" as="geometry" />
|
|
||||||
</mxCell>
|
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-44" value="Floats" style="" parent="0" />
|
<mxCell id="rRo1dadeA1uCrzt-e38k-44" value="Floats" style="" parent="0" />
|
||||||
<mxCell id="rRo1dadeA1uCrzt-e38k-54" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="rRo1dadeA1uCrzt-e38k-44" vertex="1">
|
<mxCell id="rRo1dadeA1uCrzt-e38k-54" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" parent="rRo1dadeA1uCrzt-e38k-44" vertex="1">
|
||||||
<mxGeometry x="240" y="120" width="20" height="140" as="geometry" />
|
<mxGeometry x="240" y="120" width="20" height="140" as="geometry" />
|
||||||
|
|
|
||||||
6
file.go
6
file.go
|
|
@ -44,20 +44,20 @@ func AddFile(userID int, file *File) (err error) { // {{{
|
||||||
err = rows.Scan(&file.ID)
|
err = rows.Scan(&file.ID)
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
func Files(userID int, nodeUUID string, fileID int) (files []File, err error) { // {{{
|
func Files(userID, nodeID, fileID int) (files []File, err error) { // {{{
|
||||||
var rows *sqlx.Rows
|
var rows *sqlx.Rows
|
||||||
rows, err = db.Queryx(
|
rows, err = db.Queryx(
|
||||||
`SELECT *
|
`SELECT *
|
||||||
FROM file
|
FROM file
|
||||||
WHERE
|
WHERE
|
||||||
user_id = $1 AND
|
user_id = $1 AND
|
||||||
node_uuid = $2 AND
|
node_id = $2 AND
|
||||||
CASE $3::int
|
CASE $3::int
|
||||||
WHEN 0 THEN true
|
WHEN 0 THEN true
|
||||||
ELSE id = $3
|
ELSE id = $3
|
||||||
END`,
|
END`,
|
||||||
userID,
|
userID,
|
||||||
nodeUUID,
|
nodeID,
|
||||||
fileID,
|
fileID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
21
main.go
21
main.go
|
|
@ -26,7 +26,6 @@ const VERSION = "v1"
|
||||||
const CONTEXT_USER = 1
|
const CONTEXT_USER = 1
|
||||||
|
|
||||||
var (
|
var (
|
||||||
FlagGenerate bool
|
|
||||||
FlagDev bool
|
FlagDev bool
|
||||||
FlagConfig string
|
FlagConfig string
|
||||||
FlagCreateUser string
|
FlagCreateUser string
|
||||||
|
|
@ -57,7 +56,6 @@ func init() { // {{{
|
||||||
|
|
||||||
flag.StringVar(&FlagConfig, "config", cfgFilename, "Configuration file")
|
flag.StringVar(&FlagConfig, "config", cfgFilename, "Configuration file")
|
||||||
flag.BoolVar(&FlagDev, "dev", false, "Use local files instead of embedded files")
|
flag.BoolVar(&FlagDev, "dev", false, "Use local files instead of embedded files")
|
||||||
flag.BoolVar(&FlagGenerate, "generate", false, "Generate test data")
|
|
||||||
flag.StringVar(&FlagCreateUser, "create-user", "", "Username for creating a new user")
|
flag.StringVar(&FlagCreateUser, "create-user", "", "Username for creating a new user")
|
||||||
flag.StringVar(&FlagChangePassword, "change-password", "", "Change the password for the given username")
|
flag.StringVar(&FlagChangePassword, "change-password", "", "Change the password for the given username")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
@ -87,16 +85,6 @@ func main() { // {{{
|
||||||
// The session manager contains authentication, authorization and session settings.
|
// The session manager contains authentication, authorization and session settings.
|
||||||
AuthManager, err = authentication.NewManager(db, Log, config.JWT.Secret, config.JWT.ExpireDays)
|
AuthManager, err = authentication.NewManager(db, Log, config.JWT.Secret, config.JWT.ExpireDays)
|
||||||
|
|
||||||
// Generate test data?
|
|
||||||
if FlagGenerate {
|
|
||||||
err := TestData()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%s\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// A new user?
|
// A new user?
|
||||||
if FlagCreateUser != "" {
|
if FlagCreateUser != "" {
|
||||||
createNewUser(FlagCreateUser)
|
createNewUser(FlagCreateUser)
|
||||||
|
|
@ -123,7 +111,7 @@ func main() { // {{{
|
||||||
http.HandleFunc("/user/authenticate", AuthManager.AuthenticationHandler)
|
http.HandleFunc("/user/authenticate", AuthManager.AuthenticationHandler)
|
||||||
|
|
||||||
http.HandleFunc("/node/tree/{timestamp}/{offset}", authenticated(actionNodeTree))
|
http.HandleFunc("/node/tree/{timestamp}/{offset}", authenticated(actionNodeTree))
|
||||||
http.HandleFunc("/node/retrieve/{uuid}", authenticated(actionNodeRetrieve))
|
http.HandleFunc("/node/retrieve/{id}", authenticated(actionNodeRetrieve))
|
||||||
|
|
||||||
http.HandleFunc("/service_worker.js", pageServiceWorker)
|
http.HandleFunc("/service_worker.js", pageServiceWorker)
|
||||||
|
|
||||||
|
|
@ -253,14 +241,17 @@ func actionNodeTree(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
MaxSeq uint64
|
MaxSeq uint64
|
||||||
Continue bool
|
Continue bool
|
||||||
}{true, nodes, maxSeq, moreRowsExist})
|
}{true, nodes, maxSeq, moreRowsExist})
|
||||||
|
Log.Debug("tree", "nodes", nodes)
|
||||||
w.Write(j)
|
w.Write(j)
|
||||||
} // }}}
|
} // }}}
|
||||||
func actionNodeRetrieve(w http.ResponseWriter, r *http.Request) { // {{{
|
func actionNodeRetrieve(w http.ResponseWriter, r *http.Request) { // {{{
|
||||||
user := getUser(r)
|
user := getUser(r)
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
uuid := r.PathValue("uuid")
|
idStr := r.PathValue("id")
|
||||||
node, err := RetrieveNode(user.ID, uuid)
|
id, _ := strconv.Atoi(idStr)
|
||||||
|
|
||||||
|
node, err := RetrieveNode(user.ID, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responseError(w, err)
|
responseError(w, err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
304
node.go
304
node.go
|
|
@ -38,13 +38,15 @@ type TreeNode struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
UUID string
|
ID int
|
||||||
UserID int `db:"user_id"`
|
UserID int `db:"user_id"`
|
||||||
ParentUUID string `db:"parent_uuid"`
|
ParentID int `db:"parent_id"`
|
||||||
CryptoKeyID int `db:"crypto_key_id"`
|
CryptoKeyID int `db:"crypto_key_id"`
|
||||||
Name string
|
Name string
|
||||||
Content string
|
Content string
|
||||||
Updated time.Time
|
Updated time.Time
|
||||||
|
Children []Node
|
||||||
|
Crumbs []Node
|
||||||
Files []File
|
Files []File
|
||||||
Complete bool
|
Complete bool
|
||||||
Level int
|
Level int
|
||||||
|
|
@ -56,7 +58,7 @@ type Node struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NodeTree(userID, offset int, synced uint64) (nodes []TreeNode, maxSeq uint64, moreRowsExist bool, err error) { // {{{
|
func NodeTree(userID, offset int, synced uint64) (nodes []TreeNode, maxSeq uint64, moreRowsExist bool, err error) { // {{{
|
||||||
const LIMIT = 100
|
const LIMIT = 8
|
||||||
var rows *sqlx.Rows
|
var rows *sqlx.Rows
|
||||||
rows, err = db.Queryx(`
|
rows, err = db.Queryx(`
|
||||||
SELECT
|
SELECT
|
||||||
|
|
@ -82,7 +84,7 @@ func NodeTree(userID, offset int, synced uint64) (nodes []TreeNode, maxSeq uint6
|
||||||
LIMIT $2 OFFSET $3
|
LIMIT $2 OFFSET $3
|
||||||
`,
|
`,
|
||||||
userID,
|
userID,
|
||||||
LIMIT+1,
|
LIMIT + 1,
|
||||||
offset,
|
offset,
|
||||||
synced,
|
synced,
|
||||||
)
|
)
|
||||||
|
|
@ -120,58 +122,244 @@ func NodeTree(userID, offset int, synced uint64) (nodes []TreeNode, maxSeq uint6
|
||||||
|
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
func RetrieveNode(userID int, nodeUUID string) (node Node, err error) { // {{{
|
func RetrieveNode(userID, nodeID int) (node Node, err error) { // {{{
|
||||||
var rows *sqlx.Row
|
if nodeID == 0 {
|
||||||
rows = db.QueryRowx(`
|
return RootNode(userID)
|
||||||
SELECT
|
}
|
||||||
uuid,
|
|
||||||
user_id,
|
var rows *sqlx.Rows
|
||||||
COALESCE(parent_uuid, '') AS parent_uuid,
|
rows, err = db.Queryx(`
|
||||||
/*COALESCE(crypto_key_id, 0) AS crypto_key_id,*/
|
WITH RECURSIVE recurse AS (
|
||||||
name,
|
SELECT
|
||||||
content,
|
id,
|
||||||
content_encrypted,
|
user_id,
|
||||||
markdown,
|
COALESCE(parent_id, 0) AS parent_id,
|
||||||
0 AS level
|
COALESCE(crypto_key_id, 0) AS crypto_key_id,
|
||||||
FROM node
|
name,
|
||||||
WHERE
|
content,
|
||||||
user_id = $1 AND
|
content_encrypted,
|
||||||
uuid = $2
|
markdown,
|
||||||
|
0 AS level
|
||||||
|
FROM node
|
||||||
|
WHERE
|
||||||
|
user_id = $1 AND
|
||||||
|
id = $2
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
n.id,
|
||||||
|
n.user_id,
|
||||||
|
n.parent_id,
|
||||||
|
COALESCE(n.crypto_key_id, 0) AS crypto_key_id,
|
||||||
|
n.name,
|
||||||
|
'' AS content,
|
||||||
|
'' AS content_encrypted,
|
||||||
|
false AS markdown,
|
||||||
|
r.level + 1 AS level
|
||||||
|
FROM node n
|
||||||
|
INNER JOIN recurse r ON n.parent_id = r.id AND r.level = 0
|
||||||
|
WHERE
|
||||||
|
n.user_id = $1
|
||||||
|
)
|
||||||
|
|
||||||
|
SELECT * FROM recurse ORDER BY level ASC
|
||||||
`,
|
`,
|
||||||
userID,
|
userID,
|
||||||
nodeUUID,
|
nodeID,
|
||||||
)
|
)
|
||||||
node = Node{}
|
if err != nil {
|
||||||
if err = rows.StructScan(&node); err != nil {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
type resultRow struct {
|
||||||
|
Node
|
||||||
|
Level int
|
||||||
|
}
|
||||||
|
|
||||||
|
node = Node{}
|
||||||
|
node.Children = []Node{}
|
||||||
|
for rows.Next() {
|
||||||
|
row := resultRow{}
|
||||||
|
if err = rows.StructScan(&row); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if row.Level == 0 {
|
||||||
|
node.ID = row.ID
|
||||||
|
node.UserID = row.UserID
|
||||||
|
node.ParentID = row.ParentID
|
||||||
|
node.CryptoKeyID = row.CryptoKeyID
|
||||||
|
node.Name = row.Name
|
||||||
|
node.Complete = true
|
||||||
|
node.Markdown = row.Markdown
|
||||||
|
|
||||||
|
if node.CryptoKeyID > 0 {
|
||||||
|
node.Content = row.ContentEncrypted
|
||||||
|
} else {
|
||||||
|
node.Content = row.Content
|
||||||
|
}
|
||||||
|
|
||||||
|
node.retrieveChecklist()
|
||||||
|
}
|
||||||
|
|
||||||
|
if row.Level == 1 {
|
||||||
|
node.Children = append(node.Children, Node{
|
||||||
|
ID: row.ID,
|
||||||
|
UserID: row.UserID,
|
||||||
|
ParentID: row.ParentID,
|
||||||
|
CryptoKeyID: row.CryptoKeyID,
|
||||||
|
Name: row.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
node.Crumbs, err = NodeCrumbs(node.ID)
|
||||||
|
node.Files, err = Files(userID, node.ID, 0)
|
||||||
|
|
||||||
|
return
|
||||||
|
} // }}}
|
||||||
|
func RootNode(userID int) (node Node, err error) { // {{{
|
||||||
|
var rows *sqlx.Rows
|
||||||
|
rows, err = db.Queryx(`
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
user_id,
|
||||||
|
0 AS parent_id,
|
||||||
|
name
|
||||||
|
FROM node
|
||||||
|
WHERE
|
||||||
|
user_id = $1 AND
|
||||||
|
parent_id IS NULL
|
||||||
|
`,
|
||||||
|
userID,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
node.Name = "Start"
|
||||||
|
node.UserID = userID
|
||||||
|
node.Complete = true
|
||||||
|
node.Children = []Node{}
|
||||||
|
node.Crumbs = []Node{}
|
||||||
|
node.Files = []File{}
|
||||||
|
for rows.Next() {
|
||||||
|
row := Node{}
|
||||||
|
if err = rows.StructScan(&row); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
node.Children = append(node.Children, Node{
|
||||||
|
ID: row.ID,
|
||||||
|
UserID: row.UserID,
|
||||||
|
ParentID: row.ParentID,
|
||||||
|
Name: row.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
func NodeCrumbs(nodeUUID string) (nodes []Node, err error) { // {{{
|
func (node *Node) retrieveChecklist() (err error) { // {{{
|
||||||
|
var rows *sqlx.Rows
|
||||||
|
rows, err = db.Queryx(`
|
||||||
|
SELECT
|
||||||
|
g.id AS group_id,
|
||||||
|
g.order AS group_order,
|
||||||
|
g.label AS group_label,
|
||||||
|
|
||||||
|
COALESCE(i.id, 0) AS item_id,
|
||||||
|
COALESCE(i.order, 0) AS item_order,
|
||||||
|
COALESCE(i.label, '') AS item_label,
|
||||||
|
COALESCE(i.checked, false) AS checked
|
||||||
|
|
||||||
|
FROM public.checklist_group g
|
||||||
|
LEFT JOIN public.checklist_item i ON i.checklist_group_id = g.id
|
||||||
|
WHERE
|
||||||
|
g.node_id = $1
|
||||||
|
ORDER BY
|
||||||
|
g.order DESC,
|
||||||
|
i.order DESC
|
||||||
|
`, node.ID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
groups := make(map[int]*ChecklistGroup)
|
||||||
|
var found bool
|
||||||
|
var group *ChecklistGroup
|
||||||
|
var item ChecklistItem
|
||||||
|
for rows.Next() {
|
||||||
|
row := struct {
|
||||||
|
GroupID int `db:"group_id"`
|
||||||
|
GroupOrder int `db:"group_order"`
|
||||||
|
GroupLabel string `db:"group_label"`
|
||||||
|
|
||||||
|
ItemID int `db:"item_id"`
|
||||||
|
ItemOrder int `db:"item_order"`
|
||||||
|
ItemLabel string `db:"item_label"`
|
||||||
|
Checked bool
|
||||||
|
}{}
|
||||||
|
err = rows.StructScan(&row)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if group, found = groups[row.GroupID]; !found {
|
||||||
|
group = new(ChecklistGroup)
|
||||||
|
group.ID = row.GroupID
|
||||||
|
group.NodeID = node.ID
|
||||||
|
group.Order = row.GroupOrder
|
||||||
|
group.Label = row.GroupLabel
|
||||||
|
group.Items = []ChecklistItem{}
|
||||||
|
groups[group.ID] = group
|
||||||
|
}
|
||||||
|
|
||||||
|
item = ChecklistItem{}
|
||||||
|
item.ID = row.ItemID
|
||||||
|
item.GroupID = row.GroupID
|
||||||
|
item.Order = row.ItemOrder
|
||||||
|
item.Label = row.ItemLabel
|
||||||
|
item.Checked = row.Checked
|
||||||
|
|
||||||
|
if item.ID > 0 {
|
||||||
|
group.Items = append(group.Items, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
node.ChecklistGroups = []ChecklistGroup{}
|
||||||
|
for _, group := range groups {
|
||||||
|
node.ChecklistGroups = append(node.ChecklistGroups, *group)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
} // }}}
|
||||||
|
func NodeCrumbs(nodeID int) (nodes []Node, err error) { // {{{
|
||||||
var rows *sqlx.Rows
|
var rows *sqlx.Rows
|
||||||
rows, err = db.Queryx(`
|
rows, err = db.Queryx(`
|
||||||
WITH RECURSIVE nodes AS (
|
WITH RECURSIVE nodes AS (
|
||||||
SELECT
|
SELECT
|
||||||
uuid,
|
id,
|
||||||
COALESCE(parent_uuid, '') AS parent_uuid,
|
COALESCE(parent_id, 0) AS parent_id,
|
||||||
name
|
name
|
||||||
FROM node
|
FROM node
|
||||||
WHERE
|
WHERE
|
||||||
uuid = $1
|
id = $1
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
n.uuid,
|
n.id,
|
||||||
COALESCE(n.parent_uuid, 0) AS parent_uuid,
|
COALESCE(n.parent_id, 0) AS parent_id,
|
||||||
n.name
|
n.name
|
||||||
FROM node n
|
FROM node n
|
||||||
INNER JOIN nodes nr ON n.uuid = nr.parent_uuid
|
INNER JOIN nodes nr ON n.id = nr.parent_id
|
||||||
)
|
)
|
||||||
SELECT * FROM nodes
|
SELECT * FROM nodes
|
||||||
`, nodeUUID)
|
`, nodeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -187,49 +375,3 @@ func NodeCrumbs(nodeUUID string) (nodes []Node, err error) { // {{{
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
func TestData() (err error) {
|
|
||||||
for range 10 {
|
|
||||||
hash1, name1, _ := generateOneTestNode("", "G")
|
|
||||||
for range 10 {
|
|
||||||
hash2, name2, _ := generateOneTestNode(hash1, name1)
|
|
||||||
for range 10 {
|
|
||||||
hash3, name3, _ := generateOneTestNode(hash2, name2)
|
|
||||||
for range 10 {
|
|
||||||
generateOneTestNode(hash3, name3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateOneTestNode(parentUUID, parentPath string) (hash, name string, err error) {
|
|
||||||
var sqlParentUUID sql.NullString
|
|
||||||
if parentUUID != "" {
|
|
||||||
sqlParentUUID.String = parentUUID
|
|
||||||
sqlParentUUID.Valid = true
|
|
||||||
}
|
|
||||||
query := `
|
|
||||||
INSERT INTO node(user_id, parent_uuid, name)
|
|
||||||
VALUES(
|
|
||||||
1,
|
|
||||||
$1,
|
|
||||||
CONCAT(
|
|
||||||
$2::text,
|
|
||||||
'-',
|
|
||||||
LPAD(nextval('test_data')::text, 4, '0')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
RETURNING uuid, name`
|
|
||||||
|
|
||||||
var row *sql.Row
|
|
||||||
row = db.QueryRow(query, sqlParentUUID, parentPath)
|
|
||||||
err = row.Scan(&hash, &name)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,43 +2,16 @@ html {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
#notes2 {
|
#notes2 {
|
||||||
min-height: 100vh;
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas: "tree crumbs" "tree name" "tree content" "tree checklist" "tree schedule" "tree files" "tree blank";
|
|
||||||
grid-template-columns: min-content 1fr;
|
grid-template-columns: min-content 1fr;
|
||||||
grid-template-rows: min-content /* crumbs */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
min-height: 100vh;
|
||||||
/* blank */
|
|
||||||
}
|
|
||||||
@media only screen and (max-width: 600px) {
|
|
||||||
#notes2 {
|
|
||||||
grid-template-areas: "crumbs" "name" "content" "checklist" "schedule" "files" "blank";
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
grid-template-rows: min-content /* crumbs */ min-content /* name */ min-content /* content */ min-content /* checklist */ min-content /* schedule */ min-content /* files */ 1fr;
|
|
||||||
/* blank */
|
|
||||||
}
|
|
||||||
#notes2 #tree {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#tree {
|
#tree {
|
||||||
grid-area: tree;
|
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
#tree #logo {
|
|
||||||
display: grid;
|
|
||||||
position: relative;
|
|
||||||
justify-items: center;
|
|
||||||
margin-bottom: 32px;
|
|
||||||
margin-left: 24px;
|
|
||||||
margin-right: 24px;
|
|
||||||
}
|
|
||||||
#tree #logo img {
|
|
||||||
width: 128px;
|
|
||||||
left: -20px;
|
|
||||||
}
|
|
||||||
#tree .node {
|
#tree .node {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 24px min-content;
|
grid-template-columns: 24px min-content;
|
||||||
|
|
@ -71,9 +44,6 @@ html {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#crumbs {
|
#crumbs {
|
||||||
grid-area: crumbs;
|
|
||||||
display: grid;
|
|
||||||
justify-items: center;
|
|
||||||
margin: 16px;
|
margin: 16px;
|
||||||
}
|
}
|
||||||
.crumbs {
|
.crumbs {
|
||||||
|
|
@ -82,7 +52,7 @@ html {
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
background: #e4e4e4;
|
background: #e4e4e4;
|
||||||
color: #333;
|
color: #333;
|
||||||
border-radius: 5px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
.crumbs .crumb {
|
.crumbs .crumb {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
|
|
@ -102,21 +72,12 @@ html {
|
||||||
content: '';
|
content: '';
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
}
|
}
|
||||||
#name {
|
|
||||||
color: #666;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 1.15em;
|
|
||||||
margin-top: 32px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
/* ============================================================= *
|
/* ============================================================= *
|
||||||
* Textarea replicates the height of an element expanding height *
|
* Textarea replicates the height of an element expanding height *
|
||||||
* ============================================================= */
|
* ============================================================= */
|
||||||
.grow-wrap {
|
.grow-wrap {
|
||||||
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
|
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-area: content;
|
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
.grow-wrap::after {
|
.grow-wrap::after {
|
||||||
|
|
@ -148,7 +109,16 @@ html {
|
||||||
grid-area: 1 / 1 / 2 / 2;
|
grid-area: 1 / 1 / 2 / 2;
|
||||||
}
|
}
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
#node-content {
|
.node-name {
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 32px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
.node-content {
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
|
@ -159,7 +129,7 @@ html {
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
#node-content:invalid {
|
.node-content:invalid {
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,65 +1,46 @@
|
||||||
import { h, Component, createRef } from 'preact'
|
import { h, Component, createRef } from 'preact'
|
||||||
import { signal } from 'preact/signals'
|
import { signal } from 'preact/signals'
|
||||||
import htm from 'htm'
|
import htm from 'htm'
|
||||||
|
import { API } from 'api'
|
||||||
import { Node, NodeUI } from 'node'
|
import { Node, NodeUI } from 'node'
|
||||||
import { ROOT_NODE } from 'node_store'
|
|
||||||
const html = htm.bind(h)
|
const html = htm.bind(h)
|
||||||
|
|
||||||
export class Notes2 extends Component {
|
export class Notes2 {
|
||||||
state = {
|
|
||||||
startNode: null,
|
|
||||||
}
|
|
||||||
constructor() {//{{{
|
constructor() {//{{{
|
||||||
super()
|
this.startNode = null
|
||||||
this.tree = createRef()
|
this.tree = null
|
||||||
this.nodeUI = createRef()
|
this.nodeUI = createRef()
|
||||||
|
this.nodeModified = signal(false)
|
||||||
this.getStartNode()
|
this.setStartNode()
|
||||||
}//}}}
|
}//}}}
|
||||||
render({}, { startNode }) {//{{{
|
render() {//{{{
|
||||||
if (startNode === null)
|
|
||||||
return
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<${Tree} ref=${this.tree} app=${this} startNode=${startNode} />
|
<${Tree} ref=${this.tree} app=${this} />
|
||||||
|
<div class="nodeui">
|
||||||
<div id="nodeui">
|
<${NodeUI} app=${this} ref=${this.nodeUI} />
|
||||||
<${NodeUI} app=${this} ref=${this.nodeUI} startNode=${startNode} />
|
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
}//}}}
|
}//}}}
|
||||||
getStartNode() {//{{{
|
setStartNode() {//{{{
|
||||||
let nodeUUID = ROOT_NODE
|
/*
|
||||||
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
|
const nodeID = urlParams.get('node')
|
||||||
|
*/
|
||||||
|
|
||||||
// Is a UUID provided on the URI as an anchor?
|
|
||||||
const parts = document.URL.split('#')
|
const parts = document.URL.split('#')
|
||||||
if (parts[1]?.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i))
|
const nodeID = parts[1]
|
||||||
nodeUUID = parts[1]
|
|
||||||
|
|
||||||
nodeStore.get(nodeUUID).then(node => {
|
this.startNode = new Node(this, nodeID ? Number.parseInt(nodeID) : 0)
|
||||||
this.setState({ startNode: node })
|
|
||||||
})
|
|
||||||
}//}}}
|
}//}}}
|
||||||
goToNode(nodeUUID, dontPush) {//{{{
|
|
||||||
// Don't switch notes until saved.
|
|
||||||
if (this.nodeUI.current.nodeModified.value) {
|
|
||||||
if (!confirm("Changes not saved. Do you want to discard changes?"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dontPush)
|
treeGet() {//{{{
|
||||||
history.pushState({ nodeUUID }, '', `/notes2#${nodeUUID}`)
|
const req = {}
|
||||||
|
API.query('POST', '/node/tree', req)
|
||||||
// New node is fetched in order to retrieve content and files.
|
.then(response => {
|
||||||
// Such data is unnecessary to transfer for tree/navigational purposes.
|
console.log(response.Nodes)
|
||||||
nodeStore.get(nodeUUID).then(node => {
|
nodeStore.add(response.Nodes)
|
||||||
this.nodeUI.current.setNode(node)
|
})
|
||||||
//this.showPage('node')
|
.catch(e => console.log(e.type, e.error))
|
||||||
})
|
|
||||||
}//}}}
|
|
||||||
logout() {//{{{
|
|
||||||
localStorage.removeItem('session.UUID')
|
|
||||||
location.href = '/'
|
|
||||||
}//}}}
|
}//}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,25 +53,19 @@ class Tree extends Component {
|
||||||
this.selectedTreeNode = null
|
this.selectedTreeNode = null
|
||||||
this.props.app.tree = this
|
this.props.app.tree = this
|
||||||
|
|
||||||
this.populateFirstLevel()
|
this.retrieve()
|
||||||
}//}}}
|
}//}}}
|
||||||
render({ app }) {//{{{
|
render({ app }) {//{{{
|
||||||
const renderedTreeTrunk = this.treeTrunk.map(node => {
|
const renderedTreeTrunk = this.treeTrunk.map(node => {
|
||||||
this.treeNodeComponents[node.UUID] = createRef()
|
this.treeNodeComponents[node.ID] = createRef()
|
||||||
return html`<${TreeNode} key=${`treenode_${node.UUID}`} tree=${this} node=${node} ref=${this.treeNodeComponents[node.UUID]} selected=${node.UUID === app.startNode?.UUID} />`
|
return html`<${TreeNode} key=${`treenode_${node.ID}`} tree=${this} node=${node} ref=${this.treeNodeComponents[node.ID]} selected=${node.ID === app.startNode.ID} />`
|
||||||
})
|
})
|
||||||
return html`
|
return html`<div id="tree">${renderedTreeTrunk}</div>`
|
||||||
<div id="tree">
|
|
||||||
<div id="logo"><a href="/notes2"><img src="/images/${_VERSION}/logo.svg" /></a></div>
|
|
||||||
${renderedTreeTrunk}
|
|
||||||
</div>`
|
|
||||||
}//}}}
|
}//}}}
|
||||||
|
|
||||||
populateFirstLevel(callback = null) {//{{{
|
retrieve(callback = null) {//{{{
|
||||||
nodeStore.getTreeNodes('', 0)
|
nodeStore.getTreeNodes()
|
||||||
.then(async res => {
|
.then(res => {
|
||||||
res.sort(Node.sort)
|
|
||||||
|
|
||||||
this.treeNodes = {}
|
this.treeNodes = {}
|
||||||
this.treeNodeComponents = {}
|
this.treeNodeComponents = {}
|
||||||
this.treeTrunk = []
|
this.treeTrunk = []
|
||||||
|
|
@ -100,13 +75,26 @@ class Tree extends Component {
|
||||||
// returned from the server to be sorted in such a way that
|
// returned from the server to be sorted in such a way that
|
||||||
// a parent node always appears before a child node.
|
// a parent node always appears before a child node.
|
||||||
// The server uses a recursive SQL query delivering this.
|
// The server uses a recursive SQL query delivering this.
|
||||||
for (const node of res) {
|
for (const nodeData of res) {
|
||||||
this.treeNodes[node.UUID] = node
|
const node = new Node(
|
||||||
|
this,
|
||||||
|
nodeData.ID,
|
||||||
|
)
|
||||||
|
node.Children = []
|
||||||
|
node.Crumbs = []
|
||||||
|
node.Files = []
|
||||||
|
node.Level = nodeData.Level
|
||||||
|
node.Name = nodeData.Name
|
||||||
|
node.ParentID = nodeData.ParentID
|
||||||
|
node.Updated = nodeData.Updated
|
||||||
|
node.UserID = nodeData.UserID
|
||||||
|
|
||||||
if (node.ParentUUID === '')
|
this.treeNodes[node.ID] = node
|
||||||
|
|
||||||
|
if (node.ParentID === 0)
|
||||||
this.treeTrunk.push(node)
|
this.treeTrunk.push(node)
|
||||||
else if (this.treeNodes[node.ParentUUD] !== undefined)
|
else if (this.treeNodes[node.ParentID] !== undefined)
|
||||||
this.treeNodes[node.ParentUUID].Children.push(node)
|
this.treeNodes[node.ParentID].Children.push(node)
|
||||||
}
|
}
|
||||||
// When starting with an explicit node value, expanding all nodes
|
// When starting with an explicit node value, expanding all nodes
|
||||||
// on its path gives the user a sense of location. Not necessarily working
|
// on its path gives the user a sense of location. Not necessarily working
|
||||||
|
|
@ -149,15 +137,15 @@ class Tree extends Component {
|
||||||
if (node !== undefined)
|
if (node !== undefined)
|
||||||
this.setSelected(node)
|
this.setSelected(node)
|
||||||
}//}}}
|
}//}}}
|
||||||
expandToTrunk(nodeUUID) {//{{{
|
expandToTrunk(nodeID) {//{{{
|
||||||
let node = this.treeNodes[nodeUUID]
|
let node = this.treeNodes[nodeID]
|
||||||
if (node === undefined)
|
if (node === undefined)
|
||||||
return
|
return
|
||||||
|
|
||||||
node = this.treeNodes[node.ParentUUID]
|
node = this.treeNodes[node.ParentID]
|
||||||
while (node !== undefined) {
|
while (node !== undefined) {
|
||||||
this.treeNodeComponents[node.UUID].current.expanded.value = true
|
this.treeNodeComponents[node.ID].current.expanded.value = true
|
||||||
node = this.treeNodes[node.ParentUUID]
|
node = this.treeNodes[node.ParentID]
|
||||||
}
|
}
|
||||||
}//}}}
|
}//}}}
|
||||||
}
|
}
|
||||||
|
|
@ -167,19 +155,12 @@ class TreeNode extends Component {
|
||||||
super(props)
|
super(props)
|
||||||
this.selected = signal(props.selected)
|
this.selected = signal(props.selected)
|
||||||
this.expanded = signal(this.props.node._expanded)
|
this.expanded = signal(this.props.node._expanded)
|
||||||
|
|
||||||
this.children_populated = signal(false)
|
|
||||||
if (this.props.node.Level === 0)
|
|
||||||
this.fetchChildren()
|
|
||||||
}//}}}
|
}//}}}
|
||||||
render({ tree, node, parent }) {//{{{
|
render({ tree, node }) {//{{{
|
||||||
// Fetch the next level of children if the parent tree node is expanded and our children thus will be visible.
|
|
||||||
if (!this.children_populated.value && parent?.expanded.value)
|
|
||||||
this.fetchChildren()
|
|
||||||
|
|
||||||
const children = node.Children.map(node => {
|
const children = node.Children.map(node => {
|
||||||
tree.treeNodeComponents[node.UUID] = createRef()
|
tree.treeNodeComponents[node.ID] = createRef()
|
||||||
return html`<${TreeNode} key=${`treenode_${node.UUID}`} tree=${tree} node=${node} parent=${this} ref=${tree.treeNodeComponents[node.UUID]} selected=${node.UUID === tree.props.app.startNode?.UUID} />`
|
return html`<${TreeNode} key=${`treenode_${node.ID}`} tree=${tree} node=${node} ref=${tree.treeNodeComponents[node.ID]} selected=${node.ID === tree.props.app.startNode.ID} />`
|
||||||
})
|
})
|
||||||
|
|
||||||
let expandImg = ''
|
let expandImg = ''
|
||||||
|
|
@ -192,20 +173,16 @@ class TreeNode extends Component {
|
||||||
expandImg = html`<img src="/images/${window._VERSION}/collapsed.svg" />`
|
expandImg = html`<img src="/images/${window._VERSION}/collapsed.svg" />`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const selected = (this.selected.value ? 'selected' : '')
|
const selected = (this.selected.value ? 'selected' : '')
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="node">
|
<div class="node">
|
||||||
<div class="expand-toggle" onclick=${() => { this.expanded.value ^= true }}>${expandImg}</div>
|
<div class="expand-toggle" onclick=${() => { this.expanded.value ^= true }}>${expandImg}</div>
|
||||||
<div class="name ${selected}" onclick=${() => window._notes2.current.goToNode(node.UUID)}>${node.Name}</div>
|
<div class="name ${selected}" onclick=${() => window._notes2.current.nodeUI.current.goToNode(node.ID)}>${node.Name}</div>
|
||||||
<div class="children ${node.Children.length > 0 && this.expanded.value ? 'expanded' : 'collapsed'}">${children}</div>
|
<div class="children ${node.Children.length > 0 && this.expanded.value ? 'expanded' : 'collapsed'}">${children}</div>
|
||||||
</div>`
|
</div>`
|
||||||
}//}}}
|
}//}}}
|
||||||
fetchChildren() {//{{{
|
|
||||||
this.props.node.fetchChildren().then(() => {
|
|
||||||
this.children_populated.value = true
|
|
||||||
})
|
|
||||||
}//}}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: foldmethod=marker
|
// vim: foldmethod=marker
|
||||||
9
static/js/lib/node_modules/.package-lock.json
generated
vendored
9
static/js/lib/node_modules/.package-lock.json
generated
vendored
|
|
@ -13,15 +13,6 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"node_modules/preact": {
|
|
||||||
"version": "10.25.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/preact/-/preact-10.25.1.tgz",
|
|
||||||
"integrity": "sha512-frxeZV2vhQSohQwJ7FvlqC40ze89+8friponWUFeVEkaCfhC6Eu4V0iND5C9CXz8JLndV07QRDeXzH1+Anz5Og==",
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/preact"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
static/js/lib/package-lock.json
generated
12
static/js/lib/package-lock.json
generated
|
|
@ -5,8 +5,7 @@
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"marked": "^11.1.1",
|
"marked": "^11.1.1"
|
||||||
"preact": "^10.25.1"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/marked": {
|
"node_modules/marked": {
|
||||||
|
|
@ -19,15 +18,6 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"node_modules/preact": {
|
|
||||||
"version": "10.25.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/preact/-/preact-10.25.1.tgz",
|
|
||||||
"integrity": "sha512-frxeZV2vhQSohQwJ7FvlqC40ze89+8friponWUFeVEkaCfhC6Eu4V0iND5C9CXz8JLndV07QRDeXzH1+Anz5Og==",
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/preact"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"marked": "^11.1.1",
|
"marked": "^11.1.1"
|
||||||
"preact": "^10.25.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,4 @@
|
||||||
import { API } from 'api'
|
import { API } from 'api'
|
||||||
import { Node } from 'node'
|
|
||||||
|
|
||||||
export const ROOT_NODE = '00000000-0000-0000-0000-000000000000'
|
|
||||||
|
|
||||||
export class NodeStore {
|
export class NodeStore {
|
||||||
constructor() {//{{{
|
constructor() {//{{{
|
||||||
|
|
@ -50,9 +47,7 @@ export class NodeStore {
|
||||||
|
|
||||||
req.onsuccess = (event) => {
|
req.onsuccess = (event) => {
|
||||||
this.db = event.target.result
|
this.db = event.target.result
|
||||||
this.initializeRootNode().then(() =>
|
resolve()
|
||||||
resolve()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req.onerror = (event) => {
|
req.onerror = (event) => {
|
||||||
|
|
@ -60,35 +55,6 @@ export class NodeStore {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}//}}}
|
}//}}}
|
||||||
initializeRootNode() {//{{{
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
// The root node is a magical node which displays as the first node if none is specified.
|
|
||||||
// If not already existing, it will be created.
|
|
||||||
const trx = this.db.transaction('nodes', 'readwrite')
|
|
||||||
const nodes = trx.objectStore('nodes')
|
|
||||||
const getRequest = nodes.get(ROOT_NODE)
|
|
||||||
getRequest.onsuccess = (event) => {
|
|
||||||
// Root node exists - nice!
|
|
||||||
if (event.target.result !== undefined) {
|
|
||||||
resolve(event.target.result)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const putRequest = nodes.put({
|
|
||||||
UUID: ROOT_NODE,
|
|
||||||
Name: 'Notes2',
|
|
||||||
Content: 'Hello, World!',
|
|
||||||
})
|
|
||||||
putRequest.onsuccess = (event) => {
|
|
||||||
resolve(event.target.result)
|
|
||||||
}
|
|
||||||
putRequest.onerror = (event) => {
|
|
||||||
reject(event.target.error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getRequest.onerror = (event) => reject(event.target.error)
|
|
||||||
})
|
|
||||||
}//}}}
|
|
||||||
|
|
||||||
async getAppState(key) {//{{{
|
async getAppState(key) {//{{{
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
@ -129,7 +95,7 @@ export class NodeStore {
|
||||||
})
|
})
|
||||||
}//}}}
|
}//}}}
|
||||||
|
|
||||||
async upsertTreeRecords(records) {//{{{
|
async updateTreeRecords(records) {//{{{
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const t = this.db.transaction('treeNodes', 'readwrite')
|
const t = this.db.transaction('treeNodes', 'readwrite')
|
||||||
const nodeStore = t.objectStore('treeNodes')
|
const nodeStore = t.objectStore('treeNodes')
|
||||||
|
|
@ -165,24 +131,6 @@ export class NodeStore {
|
||||||
|
|
||||||
})
|
})
|
||||||
}//}}}
|
}//}}}
|
||||||
async getTreeNodes(parent, newLevel) {//{{{
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const trx = this.db.transaction('treeNodes', 'readonly')
|
|
||||||
const nodeStore = trx.objectStore('treeNodes')
|
|
||||||
const index = nodeStore.index('parentIndex')
|
|
||||||
const req = index.getAll(parent)
|
|
||||||
req.onsuccess = (event) => {
|
|
||||||
const nodes = []
|
|
||||||
for (const i in event.target.result) {
|
|
||||||
const node = new Node(event.target.result[i], newLevel)
|
|
||||||
nodes.push(node)
|
|
||||||
|
|
||||||
}
|
|
||||||
resolve(nodes)
|
|
||||||
}
|
|
||||||
req.onerror = (event) => reject(event.target.error)
|
|
||||||
})
|
|
||||||
}//}}}
|
|
||||||
async add(records) {//{{{
|
async add(records) {//{{{
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -213,29 +161,27 @@ export class NodeStore {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}//}}}
|
}//}}}
|
||||||
async get(uuid) {//{{{
|
async get(id) {//{{{
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Node is always returned from IndexedDB if existing there.
|
// Node is always returned from IndexedDB if existing there.
|
||||||
// Otherwise an attempt to get it from backend is executed.
|
// Otherwise an attempt to get it from backend is executed.
|
||||||
const trx = this.db.transaction('nodes', 'readonly')
|
const trx = this.db.transaction('nodes', 'readonly')
|
||||||
const nodeStore = trx.objectStore('nodes')
|
const nodeStore = trx.objectStore('nodes')
|
||||||
const getRequest = nodeStore.get(uuid)
|
const getRequest = nodeStore.get(id)
|
||||||
getRequest.onsuccess = (event) => {
|
getRequest.onsuccess = (event) => {
|
||||||
// Node found in IndexedDB and returned.
|
// Node found in IndexedDB and returned.
|
||||||
if (event.target.result !== undefined) {
|
if (event.target.result !== undefined) {
|
||||||
const node = new Node(event.target.result, -1)
|
resolve(event.target.result)
|
||||||
resolve(node)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Node not found and a request to the backend is made.
|
// Node not found and a request to the backend is made.
|
||||||
API.query("POST", `/node/retrieve/${uuid}`, {})
|
API.query("POST", `/node/retrieve/${id}`, {})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const trx = this.db.transaction('nodes', 'readwrite')
|
const trx = this.db.transaction('nodes', 'readwrite')
|
||||||
const nodeStore = trx.objectStore('nodes')
|
const nodeStore = trx.objectStore('nodes')
|
||||||
const putRequest = nodeStore.put(res.Node)
|
const putRequest = nodeStore.put(res.Node)
|
||||||
const node = new Node(res.Node, -1)
|
putRequest.onsuccess = () => resolve(res.Node)
|
||||||
putRequest.onsuccess = () => resolve(node)
|
|
||||||
putRequest.onerror = (event) => {
|
putRequest.onerror = (event) => {
|
||||||
reject(event.target.error)
|
reject(event.target.error)
|
||||||
}
|
}
|
||||||
|
|
@ -244,6 +190,15 @@ export class NodeStore {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}//}}}
|
}//}}}
|
||||||
|
async getTreeNodes() {//{{{
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const trx = this.db.transaction('nodes', 'readonly')
|
||||||
|
const nodeStore = trx.objectStore('nodes')
|
||||||
|
const req = nodeStore.getAll()
|
||||||
|
req.onsuccess = (event) => resolve(event.target.result)
|
||||||
|
req.onerror = (event) => reject(event.target.error)
|
||||||
|
})
|
||||||
|
}//}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: foldmethod=marker
|
// vim: foldmethod=marker
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
import { API } from 'api'
|
import { API } from 'api'
|
||||||
|
|
||||||
export class Sync {
|
export class Sync {
|
||||||
constructor() {
|
|
||||||
this.foo = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
static async tree() {
|
static async tree() {
|
||||||
try {
|
try {
|
||||||
const state = await nodeStore.getAppState('latest_sync')
|
const state = await nodeStore.getAppState('latest_sync')
|
||||||
const oldMax = (state?.value ? state.value : 0)
|
let oldMax = (state?.value ? state.value : 0)
|
||||||
let newMax = 0
|
let newMax = 0
|
||||||
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
|
|
@ -20,12 +16,40 @@ export class Sync {
|
||||||
res = await API.query('POST', `/node/tree/${oldMax}/${offset}`, {})
|
res = await API.query('POST', `/node/tree/${oldMax}/${offset}`, {})
|
||||||
offset += res.Nodes.length
|
offset += res.Nodes.length
|
||||||
newMax = res.MaxSeq
|
newMax = res.MaxSeq
|
||||||
await nodeStore.upsertTreeRecords(res.Nodes)
|
await nodeStore.updateTreeRecords(res.Nodes)
|
||||||
} while (res.Continue)
|
} while (res.Continue)
|
||||||
|
|
||||||
nodeStore.setAppState('latest_sync', Math.max(oldMax, newMax))
|
nodeStore.setAppState('latest_sync', Math.max(oldMax, newMax))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('sync node tree', e)
|
console.log('sync node tree', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
nodeStore.getAppState('latest_sync')
|
||||||
|
.then(state => {
|
||||||
|
if (state !== null) {
|
||||||
|
oldMax = state.value
|
||||||
|
return state.value
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
.then(async sequence => {
|
||||||
|
let offset = 0
|
||||||
|
let res = { Continue: false }
|
||||||
|
try {
|
||||||
|
do {
|
||||||
|
res = await API.query('POST', `/node/tree/${sequence}/${offset}`, {})
|
||||||
|
offset += res.Nodes.length
|
||||||
|
newMax = res.MaxSeq
|
||||||
|
await nodeStore.updateTreeRecords(res.Nodes)
|
||||||
|
} while (res.Continue)
|
||||||
|
} catch (e) {
|
||||||
|
return new Promise((_, reject) => reject(e))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => nodeStore.setAppState('latest_sync', Math.max(oldMax, newMax)))
|
||||||
|
.catch(e => console.log('sync', e))
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,75 +5,18 @@ html {
|
||||||
}
|
}
|
||||||
|
|
||||||
#notes2 {
|
#notes2 {
|
||||||
min-height: 100vh;
|
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
|
||||||
"tree crumbs"
|
|
||||||
"tree name"
|
|
||||||
"tree content"
|
|
||||||
"tree checklist"
|
|
||||||
"tree schedule"
|
|
||||||
"tree files"
|
|
||||||
"tree blank"
|
|
||||||
;
|
|
||||||
grid-template-columns: min-content 1fr;
|
grid-template-columns: min-content 1fr;
|
||||||
grid-template-rows:
|
min-height: 100vh;
|
||||||
min-content /* crumbs */
|
|
||||||
min-content /* name */
|
|
||||||
min-content /* content */
|
|
||||||
min-content /* checklist */
|
|
||||||
min-content /* schedule */
|
|
||||||
min-content /* files */
|
|
||||||
1fr; /* blank */
|
|
||||||
|
|
||||||
@media only screen and (max-width: 600px) {
|
|
||||||
grid-template-areas:
|
|
||||||
"crumbs"
|
|
||||||
"name"
|
|
||||||
"content"
|
|
||||||
"checklist"
|
|
||||||
"schedule"
|
|
||||||
"files"
|
|
||||||
"blank"
|
|
||||||
;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
grid-template-rows:
|
|
||||||
min-content /* crumbs */
|
|
||||||
min-content /* name */
|
|
||||||
min-content /* content */
|
|
||||||
min-content /* checklist */
|
|
||||||
min-content /* schedule */
|
|
||||||
min-content /* files */
|
|
||||||
1fr; /* blank */
|
|
||||||
|
|
||||||
#tree {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#tree {
|
#tree {
|
||||||
grid-area: tree;
|
//grid-area: tree;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
z-index: 100; // Over crumbs shadow
|
z-index: 100; // Over crumbs shadow
|
||||||
|
|
||||||
#logo {
|
|
||||||
display: grid;
|
|
||||||
position: relative;
|
|
||||||
justify-items: center;
|
|
||||||
margin-bottom: 32px;
|
|
||||||
margin-left: 24px;
|
|
||||||
margin-right: 24px;
|
|
||||||
img {
|
|
||||||
width: 128px;
|
|
||||||
left: -20px;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.node {
|
.node {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 24px min-content;
|
grid-template-columns: 24px min-content;
|
||||||
|
|
@ -119,20 +62,17 @@ html {
|
||||||
}
|
}
|
||||||
|
|
||||||
#crumbs {
|
#crumbs {
|
||||||
grid-area: crumbs;
|
//grid-area: crumbs;
|
||||||
display: grid;
|
|
||||||
justify-items: center;
|
|
||||||
margin: 16px;
|
margin: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.crumbs {
|
.crumbs {
|
||||||
background: #e4e4e4;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
padding: 8px 16px;
|
padding: 8px 16px;
|
||||||
background: #e4e4e4;
|
background: #e4e4e4;
|
||||||
color: #333;
|
color: #333;
|
||||||
border-radius: 5px;
|
border-radius: 6px;
|
||||||
|
|
||||||
.crumb {
|
.crumb {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
|
|
@ -157,22 +97,13 @@ html {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#name {
|
|
||||||
color: @color3;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 1.15em;
|
|
||||||
margin-top: 32px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ============================================================= *
|
/* ============================================================= *
|
||||||
* Textarea replicates the height of an element expanding height *
|
* Textarea replicates the height of an element expanding height *
|
||||||
* ============================================================= */
|
* ============================================================= */
|
||||||
.grow-wrap {
|
.grow-wrap {
|
||||||
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
|
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height */
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-area: content;
|
//grid-area: content;
|
||||||
font-size: 1.0em;
|
font-size: 1.0em;
|
||||||
}
|
}
|
||||||
.grow-wrap::after {
|
.grow-wrap::after {
|
||||||
|
|
@ -208,8 +139,18 @@ html {
|
||||||
grid-area: 1 / 1 / 2 / 2;
|
grid-area: 1 / 1 / 2 / 2;
|
||||||
}
|
}
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
.node-name {
|
||||||
|
background: #fff;
|
||||||
|
color: #000;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 32px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
#node-content {
|
.node-content {
|
||||||
|
//grid-area: content;
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
|
@ -219,6 +160,7 @@ html {
|
||||||
resize: none;
|
resize: none;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
|
||||||
|
|
||||||
&:invalid {
|
&:invalid {
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ const CACHED_ASSETS = [
|
||||||
|
|
||||||
'/js/{{ .VERSION }}/api.mjs',
|
'/js/{{ .VERSION }}/api.mjs',
|
||||||
'/js/{{ .VERSION }}/node_store.mjs',
|
'/js/{{ .VERSION }}/node_store.mjs',
|
||||||
'/js/{{ .VERSION }}/notes2.mjs',
|
'/js/{{ .VERSION }}/app.mjs',
|
||||||
'/js/{{ .VERSION }}/key.mjs',
|
'/js/{{ .VERSION }}/key.mjs',
|
||||||
'/js/{{ .VERSION }}/crypto.mjs',
|
'/js/{{ .VERSION }}/crypto.mjs',
|
||||||
'/js/{{ .VERSION }}/checklist.mjs',
|
'/js/{{ .VERSION }}/checklist.mjs',
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,8 @@ import 'preact/debug'
|
||||||
import 'preact/devtools'
|
import 'preact/devtools'
|
||||||
{{- end }}
|
{{- end }}
|
||||||
import { NodeStore } from 'node_store'
|
import { NodeStore } from 'node_store'
|
||||||
import { Notes2 } from "/js/{{ .VERSION }}/notes2.mjs"
|
import { Notes2 } from "/js/{{ .VERSION }}/app.mjs"
|
||||||
import { API } from 'api'
|
import { API } from 'api'
|
||||||
import { Sync } from 'sync'
|
|
||||||
|
|
||||||
window.Sync = Sync
|
|
||||||
|
|
||||||
if (!API.hasAuthenticationToken()) {
|
if (!API.hasAuthenticationToken()) {
|
||||||
location.href = '/login'
|
location.href = '/login'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue