|
@@ -364,11 +364,12 @@
|
|
class="input"
|
|
class="input"
|
|
type="text"
|
|
type="text"
|
|
v-model="discogsQuery"
|
|
v-model="discogsQuery"
|
|
|
|
+ @change="onDiscogsQueryChange"
|
|
/>
|
|
/>
|
|
</p>
|
|
</p>
|
|
<button
|
|
<button
|
|
class="button is-info is-fullwidth"
|
|
class="button is-info is-fullwidth"
|
|
- v-on:click="searchDiscogs()"
|
|
|
|
|
|
+ v-on:click="searchDiscogsForPage(1)"
|
|
>
|
|
>
|
|
Search
|
|
Search
|
|
</button>
|
|
</button>
|
|
@@ -457,6 +458,17 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <button
|
|
|
|
+ v-if="
|
|
|
|
+ discogs.apiResults.length > 0 &&
|
|
|
|
+ !discogs.disableLoadMore &&
|
|
|
|
+ discogs.page < discogs.pages
|
|
|
|
+ "
|
|
|
|
+ class="button is-fullwidth is-info discogs-load-more"
|
|
|
|
+ @click="loadNextDiscogsPage()"
|
|
|
|
+ >
|
|
|
|
+ Load more...
|
|
|
|
+ </button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -600,7 +612,10 @@ export default {
|
|
youtubeVideoNote: "",
|
|
youtubeVideoNote: "",
|
|
useHTTPS: false,
|
|
useHTTPS: false,
|
|
discogs: {
|
|
discogs: {
|
|
- apiResults: []
|
|
|
|
|
|
+ apiResults: [],
|
|
|
|
+ page: 1,
|
|
|
|
+ pages: 1,
|
|
|
|
+ disableLoadMore: false
|
|
},
|
|
},
|
|
artistInputValue: "",
|
|
artistInputValue: "",
|
|
genreInputValue: "",
|
|
genreInputValue: "",
|
|
@@ -821,37 +836,65 @@ export default {
|
|
value: this.editing.song.discogs.album.artists
|
|
value: this.editing.song.discogs.album.artists
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- searchDiscogs() {
|
|
|
|
|
|
+ searchDiscogsForPage(page) {
|
|
const query = this.discogsQuery;
|
|
const query = this.discogsQuery;
|
|
|
|
|
|
- this.socket.emit("apis.searchDiscogs", query, res => {
|
|
|
|
|
|
+ this.socket.emit("apis.searchDiscogs", query, page, res => {
|
|
if (res.status === "success") {
|
|
if (res.status === "success") {
|
|
- Toast.methods.addToast(
|
|
|
|
- `Successfully searched. Got ${res.results.length} results.`,
|
|
|
|
- 4000
|
|
|
|
|
|
+ if (page === 1)
|
|
|
|
+ Toast.methods.addToast(
|
|
|
|
+ `Successfully searched. Got ${res.results.length} results.`,
|
|
|
|
+ 4000
|
|
|
|
+ );
|
|
|
|
+ else
|
|
|
|
+ Toast.methods.addToast(
|
|
|
|
+ `Successfully got ${res.results.length} more results.`,
|
|
|
|
+ 4000
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (page === 1) {
|
|
|
|
+ this.discogs.apiResults = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.discogs.pages = res.pages;
|
|
|
|
+
|
|
|
|
+ this.discogs.apiResults = this.discogs.apiResults.concat(
|
|
|
|
+ res.results.map(result => {
|
|
|
|
+ const type =
|
|
|
|
+ result.type.charAt(0).toUpperCase() +
|
|
|
|
+ result.type.slice(1);
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ expanded: false,
|
|
|
|
+ gotMoreInfo: false,
|
|
|
|
+ album: {
|
|
|
|
+ id: result.id,
|
|
|
|
+ title: result.title,
|
|
|
|
+ type,
|
|
|
|
+ year: result.year,
|
|
|
|
+ genres: result.genre,
|
|
|
|
+ albumArt: result.cover_image,
|
|
|
|
+ resourceUrl: result.resource_url
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ })
|
|
);
|
|
);
|
|
- this.discogs.apiResults = res.results.map(result => {
|
|
|
|
- const type =
|
|
|
|
- result.type.charAt(0).toUpperCase() +
|
|
|
|
- result.type.slice(1);
|
|
|
|
-
|
|
|
|
- return {
|
|
|
|
- expanded: false,
|
|
|
|
- gotMoreInfo: false,
|
|
|
|
- album: {
|
|
|
|
- id: result.id,
|
|
|
|
- title: result.title,
|
|
|
|
- type,
|
|
|
|
- year: result.year,
|
|
|
|
- genres: result.genre,
|
|
|
|
- albumArt: result.cover_image,
|
|
|
|
- resourceUrl: result.resource_url
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ this.discogs.page = page;
|
|
|
|
+ this.discogs.disableLoadMore = false;
|
|
} else Toast.methods.addToast(res.message, 8000);
|
|
} else Toast.methods.addToast(res.message, 8000);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ loadNextDiscogsPage() {
|
|
|
|
+ this.discogs.disableLoadMore = true;
|
|
|
|
+ this.searchDiscogsForPage(this.discogs.page + 1);
|
|
|
|
+ },
|
|
|
|
+ onDiscogsQueryChange() {
|
|
|
|
+ this.discogs.page = 1;
|
|
|
|
+ this.discogs.pages = 1;
|
|
|
|
+ this.discogs.apiResults = [];
|
|
|
|
+ this.discogs.disableLoadMore = false;
|
|
|
|
+ },
|
|
selectTrack(apiResultIndex, trackIndex) {
|
|
selectTrack(apiResultIndex, trackIndex) {
|
|
const apiResult = JSON.parse(
|
|
const apiResult = JSON.parse(
|
|
JSON.stringify(this.discogs.apiResults[apiResultIndex])
|
|
JSON.stringify(this.discogs.apiResults[apiResultIndex])
|
|
@@ -1690,6 +1733,10 @@ export default {
|
|
background-color: #f4f4f4;
|
|
background-color: #f4f4f4;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ .discogs-load-more {
|
|
|
|
+ margin-bottom: 8px;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|