wip-feat: populates filter from api options
This commit is contained in:
@@ -27,10 +27,23 @@ export default class extends Controller {
|
||||
'episodes': Array,
|
||||
}
|
||||
|
||||
connect() {
|
||||
if (this.mediaTypeValue === "tvshows") {
|
||||
this.activeFilter['season'] = 1;
|
||||
}
|
||||
async connect() {
|
||||
await fetch('/api/preferences/media')
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
this.addResolutions(response['resolution']);
|
||||
this.addCodecs(response['codec']);
|
||||
});
|
||||
|
||||
await fetch('/api/user/preferences/values')
|
||||
.then(response => response.json())
|
||||
.then(response => {
|
||||
this.activeFilter = response;
|
||||
if (this.mediaTypeValue === "tvshows") {
|
||||
this.activeFilter['season'] = 1;
|
||||
}
|
||||
console.log(this.activeFilter);
|
||||
})
|
||||
}
|
||||
|
||||
async movieResultsOutletConnected(outlet) {
|
||||
@@ -51,6 +64,20 @@ export default class extends Controller {
|
||||
})
|
||||
}
|
||||
|
||||
addResolutions(resolutions) {
|
||||
this.resolutionTarget.innerHTML = '<option value="">n/a</option>';
|
||||
this.resolutionTarget.innerHTML += resolutions.preferenceOptions
|
||||
.map((resolution) => '<option value="'+resolution.name.toLowerCase()+'">'+resolution.name+'</option>')
|
||||
.join();
|
||||
}
|
||||
|
||||
addCodecs(codecs) {
|
||||
this.codecTarget.innerHTML = '<option value="">n/a</option>';
|
||||
this.codecTarget.innerHTML += codecs.preferenceOptions
|
||||
.map((codec) => '<option value="'+codec.name.toLowerCase()+'">'+codec.name+'</option>')
|
||||
.join();
|
||||
}
|
||||
|
||||
addLanguages(option, props) {
|
||||
const languages = Object.assign([], JSON.parse(props['languages']));
|
||||
languages.forEach((language) => {
|
||||
|
||||
Reference in New Issue
Block a user