Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
82
gaia/apps/music/views/artists/view.js
Executable file
82
gaia/apps/music/views/artists/view.js
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
/* global View */
|
||||
'use strict';
|
||||
|
||||
var ArtistsView = View.extend(function ArtistsView() {
|
||||
View.call(this); // super();
|
||||
|
||||
this.searchBox = document.getElementById('search-box');
|
||||
this.searchResults = document.getElementById('search-results');
|
||||
this.list = document.getElementById('list');
|
||||
|
||||
this.client.on('databaseChange', () => this.update());
|
||||
|
||||
this.setupSearch();
|
||||
this.setupList();
|
||||
this.update();
|
||||
});
|
||||
|
||||
ArtistsView.prototype.update = function() {
|
||||
return this.getArtists().then((artists) => {
|
||||
this.artists = artists;
|
||||
return this.render();
|
||||
});
|
||||
};
|
||||
|
||||
ArtistsView.prototype.destroy = function() {
|
||||
this.client.destroy();
|
||||
View.prototype.destroy.call(this); // super(); // Always call *last*
|
||||
};
|
||||
|
||||
ArtistsView.prototype.render = function() {
|
||||
return this.list.setModel(this.artists)
|
||||
.then(() => this.list.cache())
|
||||
.then(this.onRenderDone);
|
||||
};
|
||||
|
||||
ArtistsView.prototype.getArtists = function() {
|
||||
return document.l10n.formatValue('unknownArtist')
|
||||
.then((unknownArtist) => {
|
||||
return this.fetch('/api/artists/list')
|
||||
.then(response => response.json())
|
||||
.then((artists) => {
|
||||
return artists.map((artist) => {
|
||||
return {
|
||||
name: artist.name,
|
||||
url: '/artist-detail?id=' + encodeURIComponent(artist.name),
|
||||
artist: artist.metadata.artist || unknownArtist
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ArtistsView.prototype.getThumbnail = function(filePath) {
|
||||
return this.fetch('/api/artwork/url/thumbnail/' + filePath)
|
||||
.then(response => response.json());
|
||||
};
|
||||
|
||||
ArtistsView.prototype.search = function(query) {
|
||||
if (!query) {
|
||||
return Promise.resolve(this.searchResults.clearResults());
|
||||
}
|
||||
|
||||
return document.l10n.formatValue('unknownArtist').then((unknownArtist) => {
|
||||
return this.fetch('/api/search/artist/' + query)
|
||||
.then(response => response.json())
|
||||
.then((artists) => {
|
||||
var results = artists.map((artist) => {
|
||||
return {
|
||||
name: artist.name,
|
||||
title: artist.metadata.artist || unknownArtist,
|
||||
subtitle: '',
|
||||
section: 'artists',
|
||||
url: '/artist-detail?id=' + encodeURIComponent(artist.name)
|
||||
};
|
||||
});
|
||||
|
||||
return this.searchResults.setResults(results);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
window.view = new ArtistsView();
|
||||
Loading…
Reference in a new issue