diff --git a/music_graph/.eslintrc.js b/music_graph/.eslintrc.js index d94a692..e76412d 100644 --- a/music_graph/.eslintrc.js +++ b/music_graph/.eslintrc.js @@ -30,5 +30,6 @@ module.exports = { "no-underscore-dangle": 0, "no-trailing-spaces": 0, "space-before-function-paren": 0, + "standard/no-callback-literal": 0, } }; diff --git a/music_graph/src/MusicGraph.js b/music_graph/src/MusicGraph.js index b8f7ded..6f631ee 100644 --- a/music_graph/src/MusicGraph.js +++ b/music_graph/src/MusicGraph.js @@ -498,8 +498,8 @@ export function MusicGraph(data) { return null } - this.addArtistByName = function (name) { - this.api.getRelatedByName(name) + this.addArtistByMbid = function (mbid) { + this.api.getRelatedByMbid(mbid) .then(data => { this.addNode(data.node, data.relations) }) diff --git a/music_graph/src/MusicGraphApi.js b/music_graph/src/MusicGraphApi.js index c385a96..9fb8164 100644 --- a/music_graph/src/MusicGraphApi.js +++ b/music_graph/src/MusicGraphApi.js @@ -63,18 +63,6 @@ export function MusicGraphApi() { return d3.json(this.url + '/artist/details/' + mbid) } - this.getRelatedByName = function (name) { - return d3.json(this.url + '/artist/related_by_name/' + name.replace(/ /g, '+')) - .then((r) => { - return { - node: nodeUtils.fromRawDict(r.artists.find(a => a.name === name)), - // TODO: newNodes is always ignored, remove this? - newNodes: r.artists.map(nodeUtils.fromRawDict), - relations: r.relations - } - }) - } - this.getGroupMembers = function (mbid, originId) { return d3.json(this.url + '/artist/members/' + mbid) .then((r) => { @@ -149,6 +137,7 @@ export function MusicGraphApi() { return d3.json(this.url + '/artist/related/' + mbid) .then((r) => { return { + node: nodeUtils.fromRawDict(r.artists.find(a => a.mbid === mbid)), newNodes: r.artists.map(nodeUtils.fromRawDict), relations: r.relations } @@ -172,4 +161,11 @@ export function MusicGraphApi() { } }) } + + this.autoComplete = function (prefix) { + prefix = prefix.replace(/[^\w.\-!?& ]/g, '_').toUpperCase() + prefix = prefix.replace(/ /g, '+') + + return d3.json(this.url + '/artist/autocomplete/' + prefix) + } } diff --git a/music_graph/src/components/HelloWorld.vue b/music_graph/src/components/HelloWorld.vue index 22f7f5a..e7c5414 100644 --- a/music_graph/src/components/HelloWorld.vue +++ b/music_graph/src/components/HelloWorld.vue @@ -24,13 +24,11 @@ export default { }, methods: { onQuery: function (e) { - console.log(e) - this.mm.addArtistByName(e) + this.mm.addArtistByMbid(e) } }, mounted() { this.mm = new MusicGraph(data) - this.mm.addArtistByName('Tool') } } diff --git a/music_graph/src/components/InputBar.vue b/music_graph/src/components/InputBar.vue index 503750d..17c6991 100644 --- a/music_graph/src/components/InputBar.vue +++ b/music_graph/src/components/InputBar.vue @@ -1,33 +1,62 @@