var t = ` ` import Icon from './icon.js' import GraphD3 from './graph-d3.js' import Preview from './preview.js' export default { components: { Icon, GraphD3, Preview }, emits: ['graph-close', 'note-open'], data() { return { query: '', nodes: [], graphData: null, selectedNodeId: '', showSettings: false, showSettingsDisplay: true, showSettingsForces: false, display: { showTitles: { value: true, title: 'show titles' }, scaleTitles: { value: true, title: 'auto-scale titles' }, dynamicNodeRadius: { value: false, title: 'size nodes per links' }, }, forces: { chargeStrength: { value: -30, min: -100, max: 0, step: 1, title: 'repel force' }, collideRadius: { value: 1, min: 1, max: 50, step: 1, title: 'collide radius' }, collideStrength: { value: 0.5, min: 0, max: 1, step: 0.05, title: 'collide strength' }, }, } }, methods: { fetchGraph() { fetch("/api/notes") .then(r => r.ok ? r.json() : r.json().then(e => Promise.reject(e))) .then(response => { let nodes = []; let links = []; const notes = Object.values(response); notes.forEach(note => { nodes.push({ id: note.Filename, title: note.Title, isLabel: note.IsLabel }); if (note.OutgoingLinks) { note.OutgoingLinks.forEach(link => { if (link.Title !== '') links.push({ source: note.Filename, target: link.Filename }); }); } }); this.nodes = nodes; this.graphData = { nodes, links }; }) .catch(e => { console.error(e); }); }, }, computed: { emphasizeNodeIds() { if (this.query) { const queryWords = this.query.toLowerCase().split(' '); return this.nodes.filter(node => queryWords.every(queryWord => node.title.toLowerCase().includes(queryWord))).map(node => node.id); } return this.selectedNodeId ? [this.selectedNodeId] : []; } }, mounted() { this.fetchGraph(); }, created() { this.$nextTick(() => { this.$refs.queryInput.focus(); }); }, template: t }