started using environment variables
This commit is contained in:
1 parent
c9c7a92012
commit
8958ead210
12 files changed
+42
-21
No files matched your search
@@ -1,13 +1,13 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { EntrySeen } from '../../shared/models/entrySeen.model';
|
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entryRating.model';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class EntryRatingsService {
|
export class EntryRatingsService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'entry-ratings';
|
private apiAction = 'entry-ratings';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
@@ -16,7 +16,7 @@ export class EntryRatingsService {
|
|||||||
return this.http.put<EntryRating>(
|
return this.http.put<EntryRating>(
|
||||||
`${this.backend_apiUrl}/${this.apiAction}/${entryRatings.id}`,
|
`${this.backend_apiUrl}/${this.apiAction}/${entryRatings.id}`,
|
||||||
{
|
{
|
||||||
entryR: entryRatings
|
entryR: entryRatings,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { EntrySeen } from '../../shared/models/entrySeen.model';
|
import { EntrySeen } from '../../shared/models/entrySeen.model';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class EntrySeenService {
|
export class EntrySeenService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'entry-seen';
|
private apiAction = 'entry-seen';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { Observable, map } from 'rxjs';
|
|||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { EntryId } from '../../shared/models/entryId.model';
|
import { EntryId } from '../../shared/models/entryId.model';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entryRating.model';
|
||||||
// import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class EntryService {
|
export class EntryService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'entries';
|
private apiAction = 'entries';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { EpisodeSeen } from '../../shared/models/episodeSeen.model';
|
import { EpisodeSeen } from '../../shared/models/episodeSeen.model';
|
||||||
import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto';
|
import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class EpisodeSeenService {
|
export class EpisodeSeenService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'episode-seen';
|
private apiAction = 'episode-seen';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class EpisodeService {
|
export class EpisodeService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'episodes';
|
private apiAction = 'episodes';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
|
|||||||
import { MovieDateSeen } from '../../shared/models/dtos/movieDateSeen.model';
|
import { MovieDateSeen } from '../../shared/models/dtos/movieDateSeen.model';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ImporterService {
|
export class ImporterService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'entries';
|
private apiAction = 'entries';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { catchError, switchMap, tap } from 'rxjs/operators';
|
|||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { EntryId } from '../../shared/models/entryId.model';
|
import { EntryId } from '../../shared/models/entryId.model';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entryRating.model';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -13,7 +14,8 @@ export class LibraryService implements OnInit {
|
|||||||
private libraryEntriesSubject = new ReplaySubject<Entry[]>(1);
|
private libraryEntriesSubject = new ReplaySubject<Entry[]>(1);
|
||||||
private entriesLoaded = false;
|
private entriesLoaded = false;
|
||||||
|
|
||||||
private backend_apiUrl = ' http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
|
private apiAction = 'entries';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ export class LibraryService implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fetchAllEntries(forceFetch: boolean = false): Observable<Entry[]> {
|
private fetchAllEntries(forceFetch: boolean = false): Observable<Entry[]> {
|
||||||
const endPoint = `${this.backend_apiUrl}/entries`;
|
const endPoint = `${this.backend_apiUrl}/${this.apiAction}`;
|
||||||
|
|
||||||
// If data is already loaded and not force fetching, immediately return the cached observable.
|
// If data is already loaded and not force fetching, immediately return the cached observable.
|
||||||
if (this.entriesLoaded && !forceFetch) {
|
if (this.entriesLoaded && !forceFetch) {
|
||||||
@@ -80,10 +82,13 @@ export class LibraryService implements OnInit {
|
|||||||
if (existingEntry) {
|
if (existingEntry) {
|
||||||
return of(existingEntry);
|
return of(existingEntry);
|
||||||
} else {
|
} else {
|
||||||
return this.http.post<Entry>(`${this.backend_apiUrl}/entries`, {
|
return this.http.post<Entry>(
|
||||||
|
`${this.backend_apiUrl}/${this.apiAction}`,
|
||||||
|
{
|
||||||
tmdb_id: tmdb_id,
|
tmdb_id: tmdb_id,
|
||||||
is_tvserie: is_tvserie,
|
is_tvserie: is_tvserie,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -91,7 +96,7 @@ export class LibraryService implements OnInit {
|
|||||||
|
|
||||||
deleteEntry(id: number): Observable<any> {
|
deleteEntry(id: number): Observable<any> {
|
||||||
// Directly attempt to delete the entry without fetching all entries first.
|
// Directly attempt to delete the entry without fetching all entries first.
|
||||||
return this.http.delete(`${this.backend_apiUrl}/entries/${id}`);
|
return this.http.delete(`${this.backend_apiUrl}/${this.apiAction}/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
isInLibrary(tmdb_id: string): Observable<Entry | null> {
|
isInLibrary(tmdb_id: string): Observable<Entry | null> {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Season } from '../../shared/models/season.model';
|
import { Season } from '../../shared/models/season.model';
|
||||||
import { Episode } from '../../shared/models/episode.models';
|
import { Episode } from '../../shared/models/episode.models';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class SeasonService {
|
export class SeasonService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'seasons';
|
private apiAction = 'seasons';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Observable, from, map, of, switchMap, toArray } from 'rxjs';
|
|||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
import { EntryId } from '../../shared/models/entryId.model';
|
import { EntryId } from '../../shared/models/entryId.model';
|
||||||
import { EntryRating } from '../../shared/models/entryRating.model';
|
import { EntryRating } from '../../shared/models/entryRating.model';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -14,8 +15,8 @@ export class TmdbService {
|
|||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
// private apiUrl = environment.apiBaseUrl;
|
// private apiUrl = environment.apiBaseUrl;
|
||||||
private tmdb_apiUrl = 'https://api.themoviedb.org/3';
|
private tmdb_apiUrl = environment.TMDB_API_URL;
|
||||||
private tmdb_apiKey = '5323ef3dc430df54dcb9e58c37fd22bb';
|
private tmdb_apiKey = environment.TMDB_API_KEY;
|
||||||
|
|
||||||
fetchdata(endPoint: string): Observable<any> {
|
fetchdata(endPoint: string): Observable<any> {
|
||||||
if (this.cach[endPoint]) {
|
if (this.cach[endPoint]) {
|
||||||
@@ -34,9 +35,6 @@ export class TmdbService {
|
|||||||
|
|
||||||
getEntriesUsingEndPoint(endPoint: string): Observable<Entry[]> {
|
getEntriesUsingEndPoint(endPoint: string): Observable<Entry[]> {
|
||||||
return this.fetchdata(endPoint).pipe(
|
return this.fetchdata(endPoint).pipe(
|
||||||
// map((response) =>
|
|
||||||
// response.results.map((movie: any) => this.adaptMovieToEntry(movie))
|
|
||||||
// )
|
|
||||||
map((response) => {
|
map((response) => {
|
||||||
// Check if the data is from cache and has `exist` property
|
// Check if the data is from cache and has `exist` property
|
||||||
if (response.exist) {
|
if (response.exist) {
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import { Observable } from 'rxjs';
|
|||||||
import { UserCollection } from '../../shared/models/userCollection.model';
|
import { UserCollection } from '../../shared/models/userCollection.model';
|
||||||
import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model';
|
import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model';
|
||||||
import { Entry } from '../../shared/models/entry.model';
|
import { Entry } from '../../shared/models/entry.model';
|
||||||
|
import { environment } from '../../../environments/environment.prod';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class UserCollectionService {
|
export class UserCollectionService {
|
||||||
private backend_apiUrl = 'http://localhost:4000/api/v1';
|
private backend_apiUrl = environment.API_URL;
|
||||||
private apiAction = 'user-collections';
|
private apiAction = 'user-collections';
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: true,
|
||||||
|
API_URL: 'http://localhost:4000/api/v1',
|
||||||
|
TMDB_API_URL: 'https://api.themoviedb.org/3',
|
||||||
|
TMDB_API_KEY: '5323ef3dc430df54dcb9e58c37fd22bb',
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: false,
|
||||||
|
API_URL: 'http://localhost:4000/api/v1',
|
||||||
|
TMDB_API_URL: 'https://api.themoviedb.org/3',
|
||||||
|
TMDB_API_KEY: '5323ef3dc430df54dcb9e58c37fd22bb',
|
||||||
|
};
|
||||||
Reference in new issue
Block a user