Skip to content

Commit

Permalink
added deployment steps
Browse files Browse the repository at this point in the history
hemant10yadav committed Dec 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7768cbe commit c94567e
Showing 13 changed files with 55 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ jobs:
npm install
npm install -g @angular/cli
- name: Inject API Key
run: |
echo "export const environment = { production: true, apiKey: '${{ secrets.REST_API_KEY }}' };" > src/environments/environment.prod.ts
- name: Build the Angular app
run: ng build --configuration=production --base-href="https://hemant10yadav.github.io/book-store/"

12 changes: 8 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,12 @@
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"budgets": [
{
"type": "initial",
@@ -61,12 +67,10 @@
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "book-store:build:production",
"proxyConfig": "src/proxy.conf.json"
"browserTarget": "book-store:build:production"
},
"development": {
"browserTarget": "book-store:build:development",
"proxyConfig": "src/proxy.conf.json"
"browserTarget": "book-store:build:development"
}
},
"defaultConfiguration": "development"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config src/proxy.conf.json",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
8 changes: 4 additions & 4 deletions src/app/components/book-widget/book-widget.component.html
Original file line number Diff line number Diff line change
@@ -16,19 +16,19 @@
draggable="false"
#img
(error)="img.src = 'assets/img/book3.png'"
[ngSrc]="book.image"
[ngSrc]="book.volumeInfo.imageLinks.thumbnail"
alt="book"
height="194"
width="170"
/>
<div class="p-2">
<div [title]="book.name" class="mt-2 fs-16 fw-600 book-name">
{{ book.name }}
{{ book.volumeInfo.title }}
</div>
<div class="mt-1">
<app-rating
[ratings]="book.rating"
[user]="book.review_count"
[ratings]="book.volumeInfo.averageRating"
[user]="book.volumeInfo.ratingsCount"
></app-rating>
</div>
<div class="widget-button">
2 changes: 1 addition & 1 deletion src/app/components/book-widget/book-widget.component.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import { Book } from '../../../utils/types';
styleUrls: ['./book-widget.component.scss'],
})
export class BookWidgetComponent {
@Input() public book!: Book;
@Input() public book!: any;
@Input() public index!: number | null;
@Input() mode: 'light' | 'dark' = 'light';
}
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@
width="170"
#img
[alt]="book.name"
[ngSrc]="book.image"
[ngSrc]="book.volumeInfo.imageLinks.thumbnail"
(error)="img.src = 'assets/img/book3.png'"
/>
<div class="mt-2">
<div class="fs-16 book-name">{{ book.name }}</div>
<span class="fs-14 mt-3 d-block">{{ book.book_order }} books</span>
<div class="fs-16 book-name">{{ book.volumeInfo.title }}</div>
<span class="fs-14 mt-3 d-block">{{ book.volumeInfo.ratingsCount }} books</span>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@ import { Book } from '../../../utils/types';
styleUrls: ['./popular-widget.component.scss'],
})
export class PopularWidgetComponent {
@Input() public book!: Book;
@Input() public book!: any;
@Input() mode: 'light' | 'dark' = 'light';
}
26 changes: 16 additions & 10 deletions src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import { BookService } from '../../service/book.service';
})
export class HomeComponent implements OnInit {
private age = 5;
public topSellerBooks!: Book[];
public topSellerBooks!: any[];
public popularBooks!: Book[];
public genreBooks!: Book[];
public teachersPick!: Book[];
@@ -63,38 +63,44 @@ export class HomeComponent implements OnInit {
}
public getTopSellerBooks(): void {
this.bookService.getTopSellerBooks(this.age).subscribe({
next: (res: RestCategoryData) =>
(this.topSellerBooks = res?.book_set[0]?.books),
next: (res: any) =>{
console.log("topseller");
console.log("@@@@@");

this.topSellerBooks = res.items
console.log("topseller");
console.log(this.topSellerBooks);
},
error: (err) => console.log(err),
});
}

private getPopularBooks(): void {
this.bookService.getPopularBooks(this.age).subscribe({
next: (res: RestCategoryData) =>
(this.popularBooks = res?.book_set[0]?.books),
next: (res: any) =>
(this.popularBooks = res.items),
error: (err) => console.log(err),
});
}

private getGenreBooks(): void {
this.bookService.getBooksPickByTeachers(this.age).subscribe({
next: (res: RestCategoryData) =>
(this.genreBooks = res?.book_set[0]?.books),
next: (res: any) =>
(this.genreBooks = res.items),
error: (err) => console.log(err),
});
}
private getMustReadBooks(): void {
this.bookService.getMustReadBooks(this.age).subscribe({
next: (res: RestCategoryData) => (this.mustReads = res?.book_set),
next: (res: any) => (this.mustReads = res.items),
error: (err) => console.log(err),
});
}

private getTeachersPick(): void {
this.bookService.getBooksPickByTeachers(this.age).subscribe({
next: (res: RestCategoryData) =>
(this.teachersPick = res?.book_set[0].books),
next: (res: any) =>
(this.teachersPick = res.items),
error: (err) => console.log(err),
});
}
5 changes: 3 additions & 2 deletions src/app/service/api.service.ts
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Predicate } from '../../utils/types';
import { environment } from 'src/environments/environment';

@Injectable({
providedIn: 'root',
})
export class ApiService {
constructor(private http: HttpClient) {}

public apiUrl = '/api_v2_books';
public apiUrl = 'https://www.googleapis.com/books/v1/';
private headers = new HttpHeaders({
Accept: 'application/json, text/plain, */*',
});
@@ -18,7 +19,7 @@ export class ApiService {
if (queryParams != null) {
url = this.addQueryParams(url, queryParams);
}
return this.http.get<U>(`${this.apiUrl}${url}`, { headers: this.headers });
return this.http.get<U>(`${this.apiUrl}${url}&key=${environment.apiKey}`, { headers: this.headers });
}

public put<U>(url: string, data: Object): Observable<U> {
12 changes: 6 additions & 6 deletions src/app/service/book.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Injectable } from '@angular/core';
import { ApiService } from './api.service';
import { count, Observable } from 'rxjs';
import {Observable } from 'rxjs';
import { Predicate, RestCategoryData } from '../../utils/types';
import { PredicateUtils } from '../../utils/PredicateUtils';


@Injectable({
providedIn: 'root',
})
@@ -41,7 +42,7 @@ export class BookService {
const predicate: Predicate[] = PredicateUtils.getAgePageSizePredicate(age);
predicate.push(new Predicate('count', count));
predicate.push(new Predicate('category_limit', categoryLimit));
return this.api.get(this.topSellerUrl, predicate);
return this.api.get("volumes?q=subject:fiction&orderBy=relevance&maxResults=10&key=AIzaSyCTMYcu2sKymPYh9eU7gn7641l4mKbi31I");
}

public getPopularBooks(
@@ -52,7 +53,7 @@ export class BookService {
const predicate: Predicate[] = PredicateUtils.getAgePageSizePredicate(age);
predicate.push(new Predicate('count', count));
predicate.push(new Predicate('category_limit', categoryLimit));
return this.api.get(this.popularUrl, predicate);
return this.api.get("volumes?q=kid&maxResults=20&orderBy=relevance");
}

public getBooksByGenre(
@@ -73,8 +74,7 @@ export class BookService {
pageSize = 20,
): Observable<RestCategoryData> {
return this.api.get(
this.teacherPickUrl,
PredicateUtils.getAgePageSizePredicate(age),
"volumes?q=Mystery&maxResults=20&orderBy=relevance"
);
}

@@ -88,7 +88,7 @@ export class BookService {
predicates.push(new Predicate('section_name', 'Best Seller Series'));
predicates.push(new Predicate('book_count', bookCount));
predicates.push(new Predicate('show_unavailable', true));
return this.api.get(this.mustReadUrl, predicates);
return this.api.get("volumes?qgames&maxResults=20&orderBy=relevance");
}

public searchBooks(searchQuery: string): Observable<RestCategoryData> {
4 changes: 4 additions & 0 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const environment = {
production: true,
apiKey: ''
};
4 changes: 4 additions & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const environment = {
production: true,
apiKey: ''
};
8 changes: 0 additions & 8 deletions src/proxy.conf.json

This file was deleted.

0 comments on commit c94567e

Please sign in to comment.