Remove unused components
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
.link_click {
|
|
||||||
cursor:pointer;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">Game Title</th>
|
|
||||||
<th scope="col">Publisher</th>
|
|
||||||
<th scope="col">Developed by</th>
|
|
||||||
<th scope="col">Publishing Year</th>
|
|
||||||
<th scope="col">Retail Price</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let title of allTitles; let i = index">
|
|
||||||
<td>{{i}}</td>
|
|
||||||
<td>{{title.gameTitleValue}}</td>
|
|
||||||
<td>{{title.publisherValue}}</td>
|
|
||||||
<td>{{title.devStudioNameValue}}</td>
|
|
||||||
<td>{{title.publishingYearValue}}</td>
|
|
||||||
<td>${{title.retailPriceValue}}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
|
||||||
import { HttpErrorResponse } from "@angular/common/http";
|
|
||||||
// import { PageSecurityService } from "../common/pageSecurity.service";
|
|
||||||
import { GameTitlesService } from "../../services/gameTitles.service";
|
|
||||||
import { LoginService } from "../../auth/login.service";
|
|
||||||
import { GameTitle } from "../../dataModels/gameTitle.type";
|
|
||||||
import { PageSecurityService } from "src/app/services/pageSecurity.service";
|
|
||||||
import { AuthService } from "src/app/auth/auth.service";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: "app-root",
|
|
||||||
templateUrl: "./index.component.html",
|
|
||||||
styleUrls: ["./index.component.css"],
|
|
||||||
})
|
|
||||||
export class IndexComponent implements OnInit {
|
|
||||||
private _allTitles: Array<GameTitle> = [];
|
|
||||||
public testArray: Array<String> = [];
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private loginService: LoginService,
|
|
||||||
private pageSecurityService: PageSecurityService,
|
|
||||||
private gameTitlesService: GameTitlesService,
|
|
||||||
private authService: AuthService
|
|
||||||
) {
|
|
||||||
this.testArray.push("Test1");
|
|
||||||
this.testArray.push("Test2");
|
|
||||||
this.testArray.push("Test3");
|
|
||||||
this.testArray.push("Test4");
|
|
||||||
this.testArray.push("Test5");
|
|
||||||
}
|
|
||||||
|
|
||||||
public get allTitles(): Array<GameTitle> {
|
|
||||||
return this._allTitles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set allTitles(val: Array<GameTitle>) {
|
|
||||||
this._allTitles = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
// let userLoggedIn: Boolean = this.authService.checkUserLoggedIn();
|
|
||||||
// if (!userLoggedIn) {
|
|
||||||
// this.pageSecurityService.gotoLoginPage();
|
|
||||||
// } else {
|
|
||||||
this.loadAllGameTitles();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private loadAllGameTitles(): void {
|
|
||||||
let self = this;
|
|
||||||
self.gameTitlesService.getAllGameTitles().subscribe(
|
|
||||||
(resp: any) => {
|
|
||||||
if (resp && resp.length > 0) {
|
|
||||||
for (var itm of resp) {
|
|
||||||
if (itm) {
|
|
||||||
let titleToAdd: GameTitle = new GameTitle(
|
|
||||||
itm.gameTitle,
|
|
||||||
itm.publisher,
|
|
||||||
itm.devStudioName,
|
|
||||||
itm.publishingYear,
|
|
||||||
itm.retailPrice
|
|
||||||
);
|
|
||||||
self._allTitles.push(titleToAdd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(error: HttpErrorResponse) => {
|
|
||||||
if (error != null) {
|
|
||||||
if (error.status === 0) {
|
|
||||||
// XXX
|
|
||||||
console.log("Client error.");
|
|
||||||
} else if (error.status === 401 || error.status === 403) {
|
|
||||||
// XXX
|
|
||||||
alert("You are not authorized.");
|
|
||||||
console.log("You are not authorized.");
|
|
||||||
self.loginService.removeSessionCurrentUser();
|
|
||||||
self.pageSecurityService.gotoLoginPage();
|
|
||||||
} else if (error.status === 500) {
|
|
||||||
alert("Server error.");
|
|
||||||
console.log("Server error occurred.");
|
|
||||||
} else {
|
|
||||||
alert("Unknown error.");
|
|
||||||
console.log("Unknown error: " + error.status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
// import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
// import { AuthService } from './auth.service';
|
|
||||||
|
|
||||||
// describe('AuthService', () => {
|
|
||||||
// let service: AuthService;
|
|
||||||
|
|
||||||
// beforeEach(() => {
|
|
||||||
// TestBed.configureTestingModule({});
|
|
||||||
// service = TestBed.inject(AuthService);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should be created', () => {
|
|
||||||
// expect(service).toBeTruthy();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
// import { HttpClient } from '@angular/common/http';
|
|
||||||
// import { Injectable } from '@angular/core';
|
|
||||||
// import { map } from 'rxjs/operators';
|
|
||||||
|
|
||||||
// @Injectable({
|
|
||||||
// providedIn: 'root',
|
|
||||||
// })
|
|
||||||
// export class AuthenticationService {
|
|
||||||
// // BASE_PATH: 'http://localhost:8080'
|
|
||||||
// USER_NAME_SESSION_ATTRIBUTE_NAME = 'authenticatedUser';
|
|
||||||
|
|
||||||
// public username: string | undefined;
|
|
||||||
// public password: string | undefined;
|
|
||||||
|
|
||||||
// constructor(private http: HttpClient) {}
|
|
||||||
|
|
||||||
// authenticationService(username: string, password: string) {
|
|
||||||
// // return this.http
|
|
||||||
// // .get(`http://localhost:8080/authenticate`, {
|
|
||||||
// // // .get(`http://localhost:8080/`, {
|
|
||||||
// // headers: {
|
|
||||||
// // 'Content-Type': 'application/json',
|
|
||||||
// // Authorization: this.createBasicAuthToken(username, password),
|
|
||||||
// // },
|
|
||||||
// // })
|
|
||||||
// return this.http
|
|
||||||
// .post<any>('http://localhost:8080/hello', {
|
|
||||||
// userName: username,
|
|
||||||
// userPass: password,
|
|
||||||
// })
|
|
||||||
// .pipe(
|
|
||||||
// map((res) => {
|
|
||||||
// this.username = username;
|
|
||||||
// this.password = password;
|
|
||||||
// this.registerSuccessfulLogin(username, password);
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// createBasicAuthToken(username: string, password: string) {
|
|
||||||
// return 'Basic ' + window.btoa(username + ':' + password);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// registerSuccessfulLogin(username: string, password: string) {
|
|
||||||
// sessionStorage.setItem(this.USER_NAME_SESSION_ATTRIBUTE_NAME, username);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// logout() {
|
|
||||||
// sessionStorage.removeItem(this.USER_NAME_SESSION_ATTRIBUTE_NAME);
|
|
||||||
// this.username = undefined;
|
|
||||||
// this.password = undefined;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// isUserLoggedIn() {
|
|
||||||
// let user = sessionStorage.getItem(this.USER_NAME_SESSION_ATTRIBUTE_NAME);
|
|
||||||
// if (user === undefined) return false;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// getLoggedInUserName() {
|
|
||||||
// let user = sessionStorage.getItem(this.USER_NAME_SESSION_ATTRIBUTE_NAME);
|
|
||||||
// if (user === undefined) return '';
|
|
||||||
// return user;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
|
||||||
import { Observable } from "rxjs";
|
|
||||||
|
|
||||||
import { environment } from "../../environments/environment";
|
|
||||||
import { LoginService } from "../auth/login.service";
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: "root",
|
|
||||||
})
|
|
||||||
export class GameTitlesService {
|
|
||||||
constructor(private http: HttpClient, private userService: LoginService) {}
|
|
||||||
|
|
||||||
public getAllGameTitles(): Observable<any> {
|
|
||||||
let jwtToken: String = this.userService.getUserSecurityToken(),
|
|
||||||
headers: HttpHeaders = new HttpHeaders({
|
|
||||||
authorization: "bearer " + jwtToken,
|
|
||||||
}),
|
|
||||||
options = { headers: headers };
|
|
||||||
return this.http.get<any>(
|
|
||||||
environment.apiBaseUrl + "secure/allGameTitles",
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { Injectable } from "@angular/core";
|
|
||||||
import { Router } from "@angular/router";
|
|
||||||
import { HttpErrorResponse } from "@angular/common/http";
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: "root",
|
|
||||||
})
|
|
||||||
export class PageSecurityService {
|
|
||||||
constructor(private router: Router) {}
|
|
||||||
|
|
||||||
public gotoLoginPage() {
|
|
||||||
this.router.navigate(["/login"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public checkPageSecurityError(httpError: HttpErrorResponse) {
|
|
||||||
if (!httpError || httpError.status == null) {
|
|
||||||
throw new Error("Invalid http error object.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (httpError.status === 401) {
|
|
||||||
this.gotoLoginPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (httpError.status === 403) {
|
|
||||||
this.router.navigate(["/accessDenied"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { TokenStorageService } from './token-storage.service';
|
|
||||||
|
|
||||||
describe('TokenStorageService', () => {
|
|
||||||
let service: TokenStorageService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({});
|
|
||||||
service = TestBed.inject(TokenStorageService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class TokenStorageService {
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user