New Search Modal
This commit is contained in:
parent
cc2962220e
commit
6dc813a14c
9 changed files with 203 additions and 28 deletions
|
|
@ -8,11 +8,20 @@ export class APIManager {
|
|||
this.apis = [];
|
||||
}
|
||||
|
||||
async query(query: string, types: string[] = []): Promise<MediaTypeModel[]> {
|
||||
async query(query: string, apisToQuery: any): Promise<MediaTypeModel[]> {
|
||||
console.log('MDB | api manager queried');
|
||||
|
||||
let res: MediaTypeModel[] = [];
|
||||
|
||||
for (const api of this.apis) {
|
||||
if (Object.keys(apisToQuery).contains(api.apiName) && apisToQuery[api.apiName]) {
|
||||
const apiRes = await api.searchByTitle(query);
|
||||
// console.log(apiRes);
|
||||
res = res.concat(apiRes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (const api of this.apis) {
|
||||
if (types.length === 0 || api.hasTypeOverlap(types)) {
|
||||
const apiRes = await api.searchByTitle(query);
|
||||
|
|
@ -20,6 +29,7 @@ export class APIManager {
|
|||
res = res.concat(apiRes);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export class OMDbAPI extends APIModel {
|
|||
|
||||
for (const value of data.Search) {
|
||||
if (value.Type === 'movie') {
|
||||
ret.push(new MovieModel({title: value.Title, id: value.imdbID, dataSource: this.apiName, type: 'movie'} as MovieModel))
|
||||
ret.push(new MovieModel({title: value.Title, id: value.imdbID, dataSource: this.apiName, type: 'movie'} as MovieModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +61,6 @@ export class OMDbAPI extends APIModel {
|
|||
return model;
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ export class TestAPI extends APIModel {
|
|||
console.log(`MDB | api "${this.apiName}" queried`);
|
||||
|
||||
return [
|
||||
new MovieModel ({title: 'test_1', type: this.types[0], dataSource: this.apiName}) ,
|
||||
new MovieModel ({title: 'test_2', type: this.types[0], dataSource: this.apiName, producer: 'Max Musterman'}),
|
||||
new MovieModel({title: 'test_1', type: this.types[0], dataSource: this.apiName}),
|
||||
new MovieModel({title: 'test_2', type: this.types[0], dataSource: this.apiName, producer: 'Max Musterman'}),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue