diff --git a/main.go b/main.go index 22facee..5bfdc84 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ import ( const VERSION = "v11" const CONTEXT_USER = 1 -const SYNC_PAGINATION = 20 +const SYNC_PAGINATION = 200 var ( FlagGenerate bool @@ -141,6 +141,7 @@ func main() { // {{{ http.HandleFunc("/node/retrieve/{uuid}", authenticated(actionNodeRetrieve)) http.HandleFunc("/node/history/retrieve/{uuid}/{offset}", authenticated(actionNodeHistoryRetrieve)) + http.HandleFunc("/node/history/count/{uuid}", authenticated(actionNodeHistoryCount)) http.HandleFunc("/service_worker.js", pageServiceWorker) @@ -352,6 +353,23 @@ func actionNodeHistoryRetrieve(w http.ResponseWriter, r *http.Request) { // {{{ "HasMore": hasMore, }) } // }}} +func actionNodeHistoryCount(w http.ResponseWriter, r *http.Request) { // {{{ + user := getUser(r) + var err error + + uuid := r.PathValue("uuid") + + count, err := RetrieveNodeHistoryCount(user.UserID, uuid) + if err != nil { + responseError(w, err) + return + } + + responseData(w, map[string]any{ + "OK": true, + "Count": count, + }) +} // }}} func actionSyncToServer(w http.ResponseWriter, r *http.Request) { // {{{ user := getUser(r) diff --git a/node.go b/node.go index 4d7da95..0beb1b1 100644 --- a/node.go +++ b/node.go @@ -293,6 +293,26 @@ func RetrieveNodeHistory(userID int, nodeUUID string, offset int) (nodes []Node, } return } // }}} +func RetrieveNodeHistoryCount(userID int, nodeUUID string) (count int, err error) { // {{{ + var row *sql.Row + row = db.QueryRow(` + SELECT + COUNT(*) + FROM node_history + WHERE + user_id = $1 AND + uuid = $2 + `, + userID, + nodeUUID, + ) + if err = row.Scan(&count); err != nil { + err = werr.Wrap(err) + return + } + + return +} // }}} func NodeCrumbs(nodeUUID string) (nodes []Node, err error) { // {{{ var rows *sqlx.Rows rows, err = db.Queryx(` diff --git a/static/css/notes2.css b/static/css/notes2.css index 11b8164..f7051f3 100644 --- a/static/css/notes2.css +++ b/static/css/notes2.css @@ -20,6 +20,10 @@ html { filter: var(--colorize); } +button { + font-size: 1e m; +} + /* ------------------------------------- * * Default application grid in wide mode * * ------------------------------------- */ @@ -550,6 +554,18 @@ n2-pagehistory { rgba(0, 0, 0, 0.2) 0px -3px 0px inset; } + .el-stats { + margin-bottom: 16px; + display: grid; + grid-template-columns: min-content 1fr; + grid-gap: 8px 12px; + white-space: nowrap; + } + + .el-fetch-history-progress { + margin-top: 16px; + } + .el-back-image, .el-back-text { cursor: pointer; diff --git a/static/js/page_history.mjs b/static/js/page_history.mjs index 9149a02..f37cfbb 100644 --- a/static/js/page_history.mjs +++ b/static/js/page_history.mjs @@ -3,8 +3,7 @@ import { Node } from './page_node.mjs' export class N2PageHistory extends CustomHTMLElement { static PAGESIZE = 15 - - static { + static {// {{{ this.tmpl = document.createElement('template') this.tmpl.innerHTML = `