From: Adam Dullage Date: Sat, 20 Aug 2022 13:09:09 +0000 (+0100) Subject: Added A-Z index page. Resolves #5. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=a107114efafe3f59d0a7b0f5a2ca997aabdeac9e;p=flatnotes.git Added A-Z index page. Resolves #5. --- diff --git a/flatnotes/main.py b/flatnotes/main.py index 7877241..4ac37cf 100644 --- a/flatnotes/main.py +++ b/flatnotes/main.py @@ -48,6 +48,7 @@ async def token(data: LoginModel): @app.get("/login") @app.get("/search") @app.get("/new") +@app.get("/notes") @app.get("/note/{title}") async def root(title: str = ""): with open("flatnotes/dist/index.html", "r", encoding="utf-8") as f: diff --git a/flatnotes/src/api.js b/flatnotes/src/api.js index 7f970de..0ab3a26 100644 --- a/flatnotes/src/api.js +++ b/flatnotes/src/api.js @@ -29,7 +29,7 @@ api.interceptors.response.use( ) { EventBus.$emit( "navigate", - `/${constants.basePaths.login}?${constants.params.redirect}=${encodeURI( + `${constants.basePaths.login}?${constants.params.redirect}=${encodeURI( window.location.pathname + window.location.search )}` ); diff --git a/flatnotes/src/classes.js b/flatnotes/src/classes.js index 7a58597..4349e29 100644 --- a/flatnotes/src/classes.js +++ b/flatnotes/src/classes.js @@ -8,7 +8,15 @@ class Note { } get href() { - return `/${constants.basePaths.note}/${this.title}`; + return `${constants.basePaths.note}/${this.title}`; + } + + get lastModifiedAsDate() { + return new Date(this.lastModified * 1000); + } + + get lastModifiedAsString() { + return this.lastModifiedAsDate.toLocaleString(); } } diff --git a/flatnotes/src/colours.scss b/flatnotes/src/colours.scss index 1cc3862..1c2b2a7 100644 --- a/flatnotes/src/colours.scss +++ b/flatnotes/src/colours.scss @@ -2,7 +2,8 @@ $off-white: #f8f9fd70; $form-control-border: #ced4da; $drop-shadow: #0000000a; $muted-text: #6c757d; +$very-muted-text: #d8dbdd; $text: #222222; -$button-background: #00000010; +$button-background: #00000008; $input-highlight: #bbcdff; $logo-key-colour: #f9a76b; diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 813b5ef..f9f8314 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -7,8 +7,8 @@ import Login from "./Login"; import Logo from "./Logo"; import Mousetrap from "mousetrap"; import NavBar from "./NavBar"; +import NoteList from "./NoteList"; import NoteViewerEditor from "./NoteViewerEditor"; -import RecentlyModified from "./RecentlyModified"; import SearchInput from "./SearchInput"; import SearchResults from "./SearchResults"; @@ -16,7 +16,7 @@ export default { name: "App", components: { - RecentlyModified, + NoteList, LoadingIndicator, Login, NavBar, @@ -33,6 +33,7 @@ export default { home: 1, note: 2, search: 3, + notes: 4, }, currentView: 1, @@ -44,12 +45,12 @@ export default { methods: { route: function() { let path = window.location.pathname.split("/"); - let basePath = path[1]; + let basePath = `/${path[1]}`; this.$bvModal.hide("search-modal"); // Home Page - if (basePath == "") { + if (basePath == constants.basePaths.home) { this.updateDocumentTitle(); this.currentView = this.views.home; this.$nextTick(function() { @@ -77,6 +78,12 @@ export default { this.currentView = this.views.note; } + // Notes + else if (basePath == constants.basePaths.notes) { + this.updateDocumentTitle(); + this.currentView = this.views.notes; + } + // Login else if (basePath == constants.basePaths.login) { this.updateDocumentTitle("Log In"); @@ -102,11 +109,11 @@ export default { logout: function() { sessionStorage.removeItem("token"); localStorage.removeItem("token"); - this.navigate(`/${constants.basePaths.login}`); + this.navigate(constants.basePaths.login); }, newNote: function() { - this.navigate(`/${constants.basePaths.new}`); + this.navigate(constants.basePaths.new); }, noteDeletedToast: function() { @@ -148,6 +155,8 @@ export default { created: function() { let parent = this; + this.constants = constants; + EventBus.$on("navigate", this.navigate); EventBus.$on("unhandledServerError", this.unhandledServerErrorToast); EventBus.$on("updateDocumentTitle", this.updateDocumentTitle); diff --git a/flatnotes/src/components/App.vue b/flatnotes/src/components/App.vue index 9667281..d9b66ee 100644 --- a/flatnotes/src/components/App.vue +++ b/flatnotes/src/components/App.vue @@ -13,8 +13,9 @@ v-if="currentView != views.login" class="w-100 mb-5" :show-logo="currentView != views.home" - @navigate-home="navigate('/')" + @navigate-home="navigate(constants.basePaths.home)" @new-note="newNote()" + @a-z="navigate(constants.basePaths.notes)" @logout="logout()" @search="openSearch()" > @@ -41,21 +42,38 @@ :initial-value="searchTerm" class="search-input mb-4" > - +
- +
+ + + + + diff --git a/flatnotes/src/components/LoadingIndicator.vue b/flatnotes/src/components/LoadingIndicator.vue index 3919544..fc8b11d 100644 --- a/flatnotes/src/components/LoadingIndicator.vue +++ b/flatnotes/src/components/LoadingIndicator.vue @@ -1,10 +1,13 @@ + + + + diff --git a/flatnotes/src/components/RecentlyModified.vue b/flatnotes/src/components/RecentlyModified.vue deleted file mode 100644 index 794a108..0000000 --- a/flatnotes/src/components/RecentlyModified.vue +++ /dev/null @@ -1,76 +0,0 @@ - - - \ No newline at end of file diff --git a/flatnotes/src/components/SearchInput.vue b/flatnotes/src/components/SearchInput.vue index 22749d6..561f042 100644 --- a/flatnotes/src/components/SearchInput.vue +++ b/flatnotes/src/components/SearchInput.vue @@ -72,7 +72,7 @@ export default { if (this.searchTermInput) { EventBus.$emit( "navigate", - `/${constants.basePaths.search}?${ + `${constants.basePaths.search}?${ constants.params.searchTerm }=${encodeURI(this.searchTermInput)}` ); diff --git a/flatnotes/src/components/SearchResults.vue b/flatnotes/src/components/SearchResults.vue index 96e1bf0..23f835a 100644 --- a/flatnotes/src/components/SearchResults.vue +++ b/flatnotes/src/components/SearchResults.vue @@ -28,12 +28,23 @@ - + +