-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69cf469
commit 4dcc508
Showing
14 changed files
with
93 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 20 additions & 59 deletions
79
teammapper-frontend/src/app/core/services/pictograms/picto-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,22 @@ | ||
export type IPictogramResponse = { | ||
schematic: boolean, | ||
sex: boolean, | ||
violence: boolean, | ||
aac: boolean, | ||
aacColor: boolean, | ||
skin: boolean, | ||
hair: boolean, | ||
downloads: number, | ||
categories: string[], | ||
synsets: string[], | ||
tags: string[], | ||
_id: number, | ||
schematic: boolean; | ||
sex: boolean; | ||
violence: boolean; | ||
aac: boolean; | ||
aacColor: boolean; | ||
skin: boolean; | ||
hair: boolean; | ||
downloads: number; | ||
categories: string[]; | ||
synsets: string[]; | ||
tags: string[]; | ||
_id: number; | ||
keywords: { | ||
keyword: string, | ||
type: number, | ||
plural: string, | ||
hasLocution: boolean | ||
}[], | ||
created: Date, | ||
lastUpdated: Date, | ||
} | ||
|
||
export type ISearchResultResponse = { | ||
_id: number, | ||
tags: string[], | ||
synsets: string[], | ||
sex: boolean, | ||
schematic: boolean, | ||
keywords: { | ||
type: number, | ||
meaning: string, | ||
plural: string, | ||
keyword: string, | ||
hasLocation: boolean, | ||
}[], | ||
desc: string, | ||
categories: string[], | ||
violence: boolean, | ||
hair: false, | ||
skin: false, | ||
aac: false, | ||
aacColor: false, | ||
score: number, | ||
}[] | ||
|
||
export type IPictogramNewResponse = { | ||
aac: boolean, | ||
aacColor: boolean, | ||
categories: string[], | ||
downloads: number, | ||
hair: boolean, | ||
keywords: string[], | ||
schematic: boolean, | ||
sex: boolean, | ||
skin: boolean, | ||
synsets: string[], | ||
tags: string[], | ||
violence: boolean, | ||
_id: number, | ||
}[]; | ||
keyword: string; | ||
type: number; | ||
plural: string; | ||
hasLocution: boolean; | ||
}[]; | ||
created: Date; | ||
lastUpdated: Date; | ||
}; |
38 changes: 18 additions & 20 deletions
38
teammapper-frontend/src/app/core/services/pictograms/pictogram.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
import { Injectable, OnDestroy } from "@angular/core"; | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Observable } from "rxjs/internal/Observable"; | ||
import { IPictogramResponse } from "./picto-types"; | ||
import { Observable } from 'rxjs/internal/Observable'; | ||
import { IPictogramResponse } from './picto-types'; | ||
import { environment } from 'src/environments/environment'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class PictogramService implements OnDestroy { | ||
private apirUrl = "https://api.arasaac.org/v1/pictograms" | ||
private staticAssetUrl = "https://static.arasaac.org/pictograms" | ||
private apiResource = "bestsearch" | ||
//export const apiBaseUrl = process.env.REACT_APP_API || 'https://api.arasaac.org/api'; | ||
//export const apiIdentifierBaseUrl = process.env.REACT_APP_API_IMAGES || 'https://static.arasaac.org/images'; | ||
export class PictogramService { | ||
private apirUrl = | ||
environment.pictogramApiUrl || 'https://api.arasaac.org/v1/pictograms'; | ||
private staticAssetUrl = | ||
environment.pictogramStaticUrl || 'https://static.arasaac.org/pictograms'; | ||
private apiResource = 'bestsearch'; | ||
|
||
constructor(private http: HttpClient) {} | ||
|
||
ngOnDestroy() { | ||
} | ||
|
||
getPictos(seachTerm: string): Observable<IPictogramResponse[]> { | ||
const language = 'de' | ||
const url = `${this.apirUrl}/${language}/${this.apiResource}/${seachTerm}` | ||
return this.http.get<IPictogramResponse[]>(url) | ||
const language = 'de'; | ||
const url = `${this.apirUrl}/${language}/${this.apiResource}/${seachTerm}`; | ||
return this.http.get<IPictogramResponse[]>(url); | ||
} | ||
|
||
getPictoImageUrl(id: number, size: number = 300, fileType: string = 'png') { | ||
return `${this.staticAssetUrl}/${id}/${id}_${size}.${fileType}` | ||
getPictoImageUrl(id: number, size = 300, fileType = 'png') { | ||
return `${this.staticAssetUrl}/${id}/${id}_${size}.${fileType}`; | ||
} | ||
|
||
getPictoImage(id: number): Observable<Blob> { | ||
const url = this.getPictoImageUrl(id) | ||
return this.http.get(url, { responseType: 'blob' }) | ||
const url = this.getPictoImageUrl(id); | ||
return this.http.get(url, { responseType: 'blob' }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,5 +157,5 @@ export class UtilsService { | |
resolve(reader.result); | ||
}; | ||
}); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters