Skip to content

Commit

Permalink
Merge pull request #17 from treymo/simple-notebook-filtering
Browse files Browse the repository at this point in the history
Simple notebook filtering in Graph UI Settings panel #13
  • Loading branch information
treymo committed Feb 4, 2021
2 parents b4a86d0 + cd25104 commit d41a18b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "joplin-plugin-link-graph-ui",
"version": "0.8.4",
"version": "0.9.0",
"scripts": {
"dist": "webpack --joplin-plugin-config buildMain && webpack --joplin-plugin-config buildExtraScripts && webpack --joplin-plugin-config createArchive",
"prepare": "npm run dist",
Expand Down
53 changes: 38 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,52 @@ var deepEqual = require('deep-equal')
const DEFAULT_MAX_NOTES = 700;

async function createSettings() {
await joplin.settings.registerSection('graph-ui.settings', {
label: 'Graph UI',
// Check out https://forkaweso.me/Fork-Awesome/icons/ for available icons.
iconName: 'fas fa-sitemap'
});
const sectionName = "graph-ui.settings"
await joplin.settings.registerSection(sectionName, {
label: 'Graph UI',
// Check out https://forkaweso.me/Fork-Awesome/icons/ for available icons.
iconName: 'fas fa-sitemap'
});

await joplin.settings.registerSetting('maxNodesOnGraph', {
value: DEFAULT_MAX_NOTES,
type: SettingItemType.Int,
section: 'graph-ui.settings',
public: true,
label: 'Max nodes in graph',
description: 'Maximun number of nodes shown in the graph. Most recent nodes have priority.'
});
await joplin.settings.registerSetting('maxNodesOnGraph', {
value: DEFAULT_MAX_NOTES,
type: SettingItemType.Int,
section: sectionName,
public: true,
label: 'Max nodes in graph',
description: 'Maximun number of nodes shown in the graph. Most recent nodes have priority.'
});

await joplin.settings.registerSetting("filteredNotebookNames", {
value: "",
type: SettingItemType.String,
section: sectionName,
public: true,
label: "Notebooks names to filter out",
description: "Comma separated list of Notebook names to filter.",
});
}

async function getFilteredNotebooks(notebooks) {
const filteredNotebookNames = await joplin.settings.value("filteredNotebookNames");
if ("" === filteredNotebookNames) return new Set();

const allNotebooks = new Map();
notebooks.forEach(n => allNotebooks.set(n.title, n.id))

var namesToFilter = filteredNotebookNames.split(",");
namesToFilter = namesToFilter.filter(name => allNotebooks.has(name));
namesToFilter = namesToFilter.map(name => allNotebooks.get(name)); // Name to ID
return new Set(namesToFilter);
}

// Set of notebook IDs to filter out of the graph view.
var filteredNotebooks = new Set;
async function fetchData() {
const selectedNote = await joplin.workspace.selectedNote();
const notes = await joplinData.getNotes();
const notebooks = await joplinData.getNotebooks();
// Set of notebook IDs to filter out of the graph view.
var filteredNotebooks = await getFilteredNotebooks(notebooks);

const data = {
"nodes": [],
"edges": [],
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 1,
"id": "io.treymo.LinkGraph",
"app_min_version": "1.7",
"version": "0.8.4",
"version": "0.9.0",
"name": "Link Graph UI",
"description": "View the connections between Joplin notes.",
"author": "Trey Moore",
Expand Down

0 comments on commit d41a18b

Please sign in to comment.