Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/details subscribe #39

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ static/
__pycache__/
env/
node_modules/
themes/
demo/
6 changes: 6 additions & 0 deletions assets/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ <h4 class="mb-5">
</div>

</div>
<div class="d-flex align-items-left justify-content-between">
<div class="form-check">
<a href="{{forgetPasswordUrl}}">Forget password?</a>
</div>
</div>

<div class="d-flex align-items-center justify-content-between">
<div class="form-check">
<input type="checkbox" [checked]="rememberMe" (change)="rememberMe = !rememberMe" name="" class="form-check-input" id="rememberUser">
Expand Down
3 changes: 3 additions & 0 deletions assets/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { Title } from '@angular/platform-browser';
styleUrls: ['./app.component.css'],
providers: [AuthService]
})

export class AppComponent implements OnInit {
usersForm;
errors;
rememberMe:boolean = false;
domain_url = '192.168.2.30';
forgetPasswordUrl = "http://"+this.domain_url+":8000/user/password_reset/";

constructor(
private authService: AuthService,
Expand Down
7 changes: 4 additions & 3 deletions assets/src/app/commons/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ export class AuthService {
rememberMe:boolean;
token;
user;
domain_url = '192.168.2.30';
constructor(private http: HttpClient) { }

// Generate token upon login
loginAuth(user,remember){
this.rememberMe = remember;
this.user = user;
return this.http.post<any>("http://localhost:8000/user/login/", user)
return this.http.post<any>("http://"+this.domain_url+":8000/user/login/", user)
.toPromise()
.then(
response => {
Expand All @@ -31,7 +32,7 @@ export class AuthService {

// Generate token upon register
registerAuth(user){
return this.http.post<any>("http://localhost:8000/user/register/", user)
return this.http.post<any>("http://"+this.domain_url+"/user/register/", user)
.toPromise()
.then(
response => {
Expand All @@ -44,7 +45,7 @@ export class AuthService {
}

refreshToken(user){
return this.http.get<any>("http://localhost:8000/user/refresh/", user)
return this.http.get<any>("http://"+this.domain_url+"localhost:8000/user/refresh/", user)
.toPromise()
.then(
response => {
Expand Down
37 changes: 36 additions & 1 deletion assets/src/app/commons/services/cart/cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
export class CartService {

httpHeaders = new HttpHeaders({'Content-type':'application/json'});
domain_url = '192.168.2.30';
edit;

constructor(
private http: HttpClient) { }

getThemeCart(id){
return this.http.get<any>('http://localhost:8000/home/theme/cart/'+id+'/', {headers: this.httpHeaders})
return this.http.get<any>('http://'+this.domain_url+':8000/home/theme/cart/'+id+'/', {headers: this.httpHeaders})
.toPromise()
.then(
response => {
Expand All @@ -24,4 +27,36 @@ export class CartService {
}
)
}

buyThemeService(id){
return this.http.get<any>('http://'+this.domain_url+':8000/details/download/'+id+'/', {headers: this.httpHeaders})
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)

}

editLicenseService(id,license_id){
this.edit = {'id': id, 'license_id': license_id}
return this.http.post<any>('http://'+this.domain_url+':8000/home/theme/edit_license/', this.edit)
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}
}
20 changes: 18 additions & 2 deletions assets/src/app/commons/services/details/details.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
})
export class DetailsService {

domain_url = '192.168.2.30';
httpHeaders = new HttpHeaders({'Content-type': 'application/json'});
constructor(
private http: HttpClient) { }

getThemeDetailsService(id){
return this.http.get<any>('http://localhost:8000/home/theme/details/'+id+'/', {headers: this.httpHeaders})
return this.http.get<any>('http://'+this.domain_url+':8000/home/theme/details/'+id+'/', {headers: this.httpHeaders})
.toPromise()
.then(
response =>{
Expand All @@ -26,7 +27,7 @@ export class DetailsService {
}

createReviewService(comment){
return this.http.post<any>("http://localhost:8000/details/createReview/",comment)
return this.http.post<any>("http://"+this.domain_url+":8000/details/createReview/",comment)
.toPromise()
.then(
response => {
Expand All @@ -39,4 +40,19 @@ export class DetailsService {
}
);
}

subscribeService(data){
return this.http.post<any>("http://"+this.domain_url+":8000/home/theme/subscribe/",data)
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}
}
21 changes: 19 additions & 2 deletions assets/src/app/commons/services/home/home.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { Observable } from 'rxjs';
})
export class HomeService {

domain_url = '192.168.2.30';
httpHeaders = new HttpHeaders({'Content-type': 'application/json'});
public categories;
constructor(private http: HttpClient) {
this.categories = this.getCategory();
}

getThemes(){
return this.http.get<any>("http://localhost:8000/home/theme/", {headers: this.httpHeaders})
return this.http.get<any>("http://"+this.domain_url+":8000/home/theme/", {headers: this.httpHeaders})
.toPromise()
.then(
response => {
Expand All @@ -29,7 +30,23 @@ export class HomeService {
}

getCategory(){
return this.http.get<any>("http://localhost:8000/home/theme/category/", {headers: this.httpHeaders})
return this.http.get<any>("http://"+this.domain_url+":8000/home/theme/category/", {headers: this.httpHeaders})
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}

subscribeService(data){
console.log('clicked');
return this.http.post<any>("http://"+this.domain_url+":8000/home/theme/subscribe/", data)
.toPromise()
.then(
response => {
Expand Down
46 changes: 38 additions & 8 deletions assets/src/app/components/cart/cart.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="mb-5">
<div class="row align-items-start">
<div class="col-md-6">
<img src="http://localhost:8000{{ theme.thumbnail.thumbnail }}" class="img-fluid" data-rjs="3">
<img src="http://{{ domain_url }}:8000{{ theme.thumbnail.thumbnail }}" class="img-fluid" data-rjs="3">
</div>
<div class="col-md-4 offset-md-1">
<div class="product-details">
Expand All @@ -12,7 +12,7 @@ <h2 >{{theme.name}}</h2>
<p>License Type:</p>
<div class="license-type mb-4">
<p>{{ theme.license.license }}</p>
<a href="">Change</a>
<a href="#" data-target="#licenseModal" data-toggle="modal">Change</a>
</div>
<div class="checkout-price mb-4">
<p class="mb-0">Unit Price:</p>
Expand All @@ -28,15 +28,45 @@ <h3 class="mb-0">${{ theme.price }}</h3>
</div>
</div>
<p>Payment:</p>
<div class="d-flex payment-option">
<div class="d-flex payment-option" (click)="buyTheme($event,theme.id)">
<img src="assets/images/paypal-logo.jpg" class="mr-3" data-rjs="3">
<button class="btn btn-primary form-control ">
<span class="mr-3">Pay with PayPal</span>
<span class="icon ion-ios-arrow-thin-right"></span>
</button>
<a href="http://{{domain_url}}:8000{{ theme.file }}">
<button class="btn btn-primary form-control">
<span class="mr-3">Pay with PayPal</span>
<span class="icon ion-ios-arrow-thin-right"></span>
</button>
</a>
</div>
</div>
</div>
</div>
</section>
</article>
</article>

<aside class="modal fade" id="licenseModal" tabindex="-1" role="dialog" arai-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="text-center pt-5 mx-auto">
<h4 class="mb-5">
Choose a license type
</h4>

</div>
</div>
<div class="modal-body">
<form class="form">
<ng-container *ngFor="let licenses of theme.licenses.license; let idx = index">
<div class="radio">
<label>
<input type="radio" name="optradio" [checked]="theme.license.pk === licenses.pk" (change)="changeLicense($event,theme.id,licenses.pk)" value="{{ licenses.license }}">{{ licenses.license }}
</label>
</div>
</ng-container>

</form>
</div>
</div>
</div>

</aside>
33 changes: 33 additions & 0 deletions assets/src/app/components/cart/cart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class CartComponent implements OnInit {
theme;
discount;
dis_price;
domain_url = '192.168.2.30';
category;

constructor(
private cartService: CartService,
private route: ActivatedRoute,
Expand Down Expand Up @@ -51,6 +54,36 @@ export class CartComponent implements OnInit {
)
}

buyTheme(event,theme_id){
console.log('clicked');
this.cartService.buyThemeService(theme_id)
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}

changeLicense(event,theme_id,license_id){
this.cartService.editLicenseService(theme_id,license_id)
.then(
response => {
this.themeCart();
return response;
}
)
.catch(
error => {
return error;
}
)
}



}
13 changes: 9 additions & 4 deletions assets/src/app/components/details/details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h5 class="section-title text-primary mb-1">{{ theme.name }}</h5>
<section class="mb-5">
<div class="row align-items-start">
<div class="col-md-6">
<img src="http://localhost:8000{{theme.thumbnail.thumbnail}}" class="img-fluid" data-rjs="3">
<img src="http://{{domain_url}}:8000{{theme.thumbnail.thumbnail}}" class="img-fluid" data-rjs="3">
</div>
<div class="col-md-4 offset-md-1">
<div class="product-details">
Expand Down Expand Up @@ -108,7 +108,7 @@ <h2 >{{ theme.name }}</h2>
<div class="col-md-6">
<h3 class="section-title">Screenshots</h3>
<ng-container *ngFor="let screenshots of theme.screenshot.screenshot">
<img src="http://localhost:8000/media/{{ screenshots.image }}/" data-rjs="3" class="img-fluid">
<img src="http://{{domain_url}}:8000/media/{{ screenshots.image }}/" data-rjs="3" class="img-fluid">
</ng-container>
</div>
<div class="col-md-6">
Expand Down Expand Up @@ -342,12 +342,17 @@ <h3 class="section-title">Reviews</h3>
<h2 class="h1">Be the first to know!</h2>
<h3>Get the updates about new products.</h3>
</div>
<ng-container>
<h4 class="text-center">{{ message }}</h4>
</ng-container>
<form [(formGroup)]="subscribe" (ngSubmit)="subscribeMarket()" method=post>
<div class="subscribe row">
<div class="col-md-8 mx-auto d-flex justify-content-between align-items-center py-5">
<input type="email" name="" class="form-control" placeholder="Enter your email">
<a href="" class="btn btn-cta btn-primary">Subscribe</a>
<input formControlName="email" type="email" name="" class="form-control" placeholder="Enter your email">
<button class="btn btn-cta btn-primary">Subscribe</button>
</div>
</div>
</form>
</div>
</section>
</article>
Loading