mirror of
https://github.com/zadam/trilium.git
synced 2024-09-20 15:45:58 +08:00
empty page on new tab nw offers list of available workspaces
This commit is contained in:
parent
744ed27d91
commit
6541523e88
10841
package-lock.json
generated
10841
package-lock.json
generated
File diff suppressed because it is too large
Load diff
12
package.json
12
package.json
|
@ -51,6 +51,7 @@
|
|||
"is-animated": "^2.0.1",
|
||||
"is-svg": "4.3.1",
|
||||
"jimp": "0.16.1",
|
||||
"joplin-turndown-plugin-gfm": "1.0.12",
|
||||
"jsdom": "16.5.1",
|
||||
"mime-types": "2.1.29",
|
||||
"multer": "1.4.2",
|
||||
|
@ -63,14 +64,13 @@
|
|||
"sanitize-filename": "1.6.3",
|
||||
"sanitize-html": "2.3.3",
|
||||
"sax": "1.2.4",
|
||||
"semver": "7.3.4",
|
||||
"semver": "7.3.5",
|
||||
"serve-favicon": "2.5.0",
|
||||
"session-file-store": "1.5.0",
|
||||
"stream-throttle": "^0.1.3",
|
||||
"striptags": "3.1.1",
|
||||
"tmp": "^0.2.1",
|
||||
"turndown": "7.0.0",
|
||||
"joplin-turndown-plugin-gfm": "1.0.12",
|
||||
"unescape": "1.0.1",
|
||||
"ws": "7.4.4",
|
||||
"yauzl": "2.10.0",
|
||||
|
@ -78,7 +78,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "12.0.1",
|
||||
"electron": "12.0.2",
|
||||
"electron-builder": "22.10.5",
|
||||
"electron-packager": "15.2.0",
|
||||
"electron-rebuild": "2.3.5",
|
||||
|
@ -87,10 +87,10 @@
|
|||
"jsdoc": "3.6.6",
|
||||
"lorem-ipsum": "2.0.3",
|
||||
"rcedit": "3.0.0",
|
||||
"webpack": "5.27.1",
|
||||
"webpack-cli": "4.5.0"
|
||||
"webpack": "5.28.0",
|
||||
"webpack-cli": "4.6.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron-installer-debian": "2.0.1"
|
||||
"electron-installer-debian": "3.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import treeCache from './tree_cache.js';
|
|||
import noteTooltipService from './note_tooltip.js';
|
||||
import protectedSessionService from './protected_session.js';
|
||||
import dateNotesService from './date_notes.js';
|
||||
import searchService from './search.js';
|
||||
import CollapsibleWidget from '../widgets/collapsible_widget.js';
|
||||
import ws from "./ws.js";
|
||||
import appContext from "./app_context.js";
|
||||
|
@ -199,11 +200,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||
* @returns {Promise<NoteShort[]>}
|
||||
*/
|
||||
this.searchForNotes = async searchString => {
|
||||
const noteIds = await this.runOnBackend(
|
||||
searchString => api.searchForNotes(searchString).map(note => note.noteId),
|
||||
[searchString]);
|
||||
|
||||
return await treeCache.getNotes(noteIds);
|
||||
return await searchService.searchForNotes(searchString);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
17
src/public/app/services/search.js
Normal file
17
src/public/app/services/search.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import server from "./server.js";
|
||||
import treeCache from "./tree_cache.js";
|
||||
|
||||
async function searchForNoteIds(searchString) {
|
||||
return await server.get('search/' + encodeURIComponent(searchString));
|
||||
}
|
||||
|
||||
async function searchForNotes(searchString) {
|
||||
const noteIds = await server.get('search/' + encodeURIComponent(searchString));
|
||||
|
||||
return await treeCache.getNotes(noteIds);
|
||||
}
|
||||
|
||||
export default {
|
||||
searchForNoteIds,
|
||||
searchForNotes
|
||||
}
|
|
@ -1,15 +1,46 @@
|
|||
import noteAutocompleteService from '../../services/note_autocomplete.js';
|
||||
import TypeWidget from "./type_widget.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
import searchService from "../../services/search.js";
|
||||
import linkService from "../../services/link.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="note-detail-empty note-detail-printable">
|
||||
<style>
|
||||
.workspace-notes {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.workspace-notes .workspace-note {
|
||||
width: 130px;
|
||||
text-align: center;
|
||||
margin: 10px;
|
||||
padding; 10px;
|
||||
border: 1px transparent solid;
|
||||
}
|
||||
|
||||
.workspace-notes .workspace-note:hover {
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--main-border-color);
|
||||
}
|
||||
|
||||
.workspace-icon {
|
||||
text-align: center;
|
||||
font-size: 500%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Open a note by typing the note's title into the input below or choose a note in the tree.</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control note-autocomplete" placeholder="search for a note by its name">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="workspace-notes"></div>
|
||||
</div>`;
|
||||
|
||||
export default class EmptyTypeWidget extends TypeWidget {
|
||||
|
@ -35,9 +66,23 @@ export default class EmptyTypeWidget extends TypeWidget {
|
|||
});
|
||||
|
||||
noteAutocompleteService.showRecentNotes(this.$autoComplete);
|
||||
|
||||
this.$workspaceNotes = this.$widget.find('.workspace-notes');
|
||||
}
|
||||
|
||||
doRefresh(note) {
|
||||
this.$autoComplete.trigger('focus');
|
||||
async doRefresh(note) {
|
||||
const workspaceNotes = await searchService.searchForNotes('#workspace');
|
||||
|
||||
this.$workspaceNotes.empty();
|
||||
|
||||
for (const workspaceNote of workspaceNotes) {
|
||||
this.$workspaceNotes.append(
|
||||
$('<div class="workspace-note">')
|
||||
.append($("<div>").addClass(workspaceNote.getIcon() + " workspace-icon"))
|
||||
.append($("<div>").append(workspaceNote.title))
|
||||
.attr("title", "Enter workspace " + workspaceNote.title)
|
||||
.on('click', () => this.triggerCommand('hoistNote', {noteId: workspaceNote.noteId}))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,6 +219,19 @@ function quickSearch(req) {
|
|||
.map(sr => sr.noteId);
|
||||
}
|
||||
|
||||
function search(req) {
|
||||
const {searchString} = req.params;
|
||||
|
||||
const searchContext = new SearchContext({
|
||||
fastSearch: false,
|
||||
includeArchivedNotes: true,
|
||||
fuzzyAttributeSearch: false
|
||||
});
|
||||
|
||||
return searchService.findNotesWithQuery(searchString, searchContext)
|
||||
.map(sr => sr.noteId);
|
||||
}
|
||||
|
||||
function getRelatedNotes(req) {
|
||||
const attr = req.body;
|
||||
|
||||
|
@ -302,5 +315,6 @@ module.exports = {
|
|||
searchFromNote,
|
||||
searchAndExecute,
|
||||
getRelatedNotes,
|
||||
quickSearch
|
||||
quickSearch,
|
||||
search
|
||||
};
|
||||
|
|
|
@ -266,6 +266,7 @@ function register(app) {
|
|||
apiRoute(GET, '/api/search-note/:noteId', searchRoute.searchFromNote);
|
||||
apiRoute(POST, '/api/search-and-execute-note/:noteId', searchRoute.searchAndExecute);
|
||||
apiRoute(POST, '/api/search-related', searchRoute.getRelatedNotes);
|
||||
apiRoute(GET, '/api/search/:searchString', searchRoute.search);
|
||||
|
||||
route(POST, '/api/login/sync', [], loginApiRoute.loginSync, apiResultHandler);
|
||||
// this is for entering protected mode so user has to be already logged-in (that's the reason we don't require username)
|
||||
|
|
|
@ -391,8 +391,7 @@ sqlInit.dbReady.then(() => {
|
|||
setTimeout(cls.wrap(sync), 5000);
|
||||
});
|
||||
|
||||
if (sqlInit.isDbInitialized())
|
||||
{
|
||||
if (sqlInit.isDbInitialized()) {
|
||||
// called just so ws.setLastSyncedPush() is called
|
||||
getLastSyncedPush();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue