Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ static/
__pycache__/
env/
node_modules/

# for theme viewing
themes/

# downloads
download/
12 changes: 9 additions & 3 deletions assets/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h4 class="mb-5">
</div>
<div class="modal-body">
<form [(formGroup)]="usersForm" (ngSubmit)="login()" id="form-login" class="form" method="post">

<div class="form-group mb-5">
<label>Email</label>
<input formControlName="email" type="email" class="form-control" placeholder="[email protected]">
Expand All @@ -52,14 +53,19 @@ <h4 class="mb-5">
<p>Try to check your password by clicking the uncover icon</p>
</div>
</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">
<!-- <input type="checkbox" [checked]="rememberMe" (change)="rememberMe = !rememberMe" name="" class="form-check-input" id="rememberUser">
<label class="form-check-label" for="rememberUser">
Remember me
</label>
</label> -->
</div>
<button id="loginbtn" class="btn btn-primary">Log in</button>
</div>
Expand Down
20 changes: 13 additions & 7 deletions assets/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, HostListener, OnDestroy } from '@angular/core';
import { AuthService} from './commons/services/auth/auth.service';
import { FormControl, FormBuilder, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Location } from '@angular/common';
import { Title } from '@angular/platform-browser';
import { domain_url } from './commons/constants/global.constants';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [AuthService]
})
export class AppComponent implements OnInit {

export class AppComponent implements OnInit{
usersForm;
errors;
rememberMe:boolean = false;
user;
token;
rememberMe:boolean = true;
forgetPasswordUrl = "http://"+domain_url+":8000/user/password_reset/";


constructor(
private authService: AuthService,
private fb: FormBuilder,
private router: Router,
private location: Location,
private title: Title,
){ }
){}

ngOnInit(){
this.usersForm = this.fb.group({
Expand All @@ -32,8 +38,8 @@ export class AppComponent implements OnInit {

}

get username(){
return this.usersForm.get('username');
get email(){
return this.usersForm.get('email');
}

get password(){
Expand All @@ -44,8 +50,8 @@ export class AppComponent implements OnInit {
this.authService.loginAuth(this.usersForm.value,this.rememberMe)
.then(
response => {
location.reload();
this.router.navigate(['']);
location.reload();
})
.catch(
error => {
Expand Down
12 changes: 12 additions & 0 deletions assets/src/app/commons/constants/global.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const domain_url = 'localhost';

// home urls
export const home_theme = '/home/theme/';
export const home_category = '/home/theme/category/';
export const home_subscribe = '/home/theme/subscribe/';

// categories
export const categories = ['Angular JS','E-Commerce','General','Bootstrap 4'];

//user
export let user_object:any;
34 changes: 9 additions & 25 deletions assets/src/app/commons/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { domain_url } from '../../constants/global.constants';

@Injectable({
providedIn: 'root'
Expand All @@ -8,13 +9,14 @@ export class AuthService {
rememberMe:boolean;
token;
user;

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)
localStorage['remember'] = JSON.stringify(remember);
localStorage['user'] = JSON.stringify(user);
return this.http.post<any>("http://"+domain_url+":8000/user/login/", user)
.toPromise()
.then(
response => {
Expand All @@ -31,7 +33,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://"+domain_url+":8000/user/register/", user)
.toPromise()
.then(
response => {
Expand All @@ -44,7 +46,7 @@ export class AuthService {
}

refreshToken(user){
return this.http.get<any>("http://localhost:8000/user/refresh/", user)
return this.http.get<any>("http://"+domain_url+":8000/user/refresh/", user)
.toPromise()
.then(
response => {
Expand All @@ -60,34 +62,16 @@ export class AuthService {

setToken(token){
this.token = token;
if(this.rememberMe == true){
localStorage['token'] = JSON.stringify(token);
}
else{
sessionStorage['token'] = JSON.stringify(token);
}
localStorage['token'] = JSON.stringify(token);
}

getToken(){
if(this.rememberMe == true){
let token = localStorage.getItem('token');
return JSON.parse(token);
}
this.getSessionToken();
}

getSessionToken(){
if(sessionStorage['token'] == null ||
sessionStorage['token'] == undefined){
return JSON.parse(null);
}
this.token = this.refreshToken(this.user);
sessionStorage['token'] = JSON.stringify(this.token);

let token = sessionStorage.getItem('token');
return JSON.parse(token);
}


removeToken(){
localStorage.removeItem('token');
}
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
@@ -1,17 +1,20 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { domain_url } from '../../constants/global.constants';

@Injectable({
providedIn: 'root'
})
export class CartService {

httpHeaders = new HttpHeaders({'Content-type':'application/json'});
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://'+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://'+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://'+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
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { domain_url } from '../../constants/global.constants';

@Injectable({
providedIn: 'root'
Expand All @@ -11,7 +12,7 @@ export class DetailsService {
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://'+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://"+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://"+domain_url+":8000/home/theme/subscribe/",data)
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}
}
27 changes: 21 additions & 6 deletions assets/src/app/commons/services/home/home.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { domain_url, home_theme, home_category, home_subscribe} from '../../constants/global.constants';

@Injectable({
providedIn: 'root'
Expand All @@ -9,12 +10,10 @@ export class HomeService {

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

getThemes(){
return this.http.get<any>("http://localhost:8000/home/theme/", {headers: this.httpHeaders})
getThemes(auth){
return this.http.get<any>("http://"+domain_url+":8000"+home_theme+auth+"/", {headers: this.httpHeaders})
.toPromise()
.then(
response => {
Expand All @@ -29,7 +28,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://"+domain_url+":8000"+home_category, {headers: this.httpHeaders})
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}

subscribeService(data){
console.log('clicked');
return this.http.post<any>("http://"+domain_url+":8000"+home_subscribe, data)
.toPromise()
.then(
response => {
Expand Down
1 change: 0 additions & 1 deletion assets/src/app/components/account/account.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ <h4 class="mb-5">
</div>
</div>
</div>

<span id="email-error" class="error-msg">{{ registrationForm.value.success }}</span>
<div class="col-md-4 offset-md-4">
<button class="btn btn-primary form-control mb-5" (click)="register()">Sign up</button>
Expand Down
Loading