JAVA-11240 Moved spring-cloud to spring-cloud-modules

This commit is contained in:
Dhawal Kapil
2022-05-29 19:32:17 +05:30
parent a7cae2e766
commit 85d134952e
934 changed files with 35 additions and 230 deletions
@@ -0,0 +1,58 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "ui"
},
"apps": [
{
"root": "src",
"outDir": "../../resources/static/home",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# System Files
.DS_Store
Thumbs.db
@@ -0,0 +1,28 @@
# Ui
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
@@ -0,0 +1,14 @@
import {UiPage} from "./app.po";
describe('ui App', () => {
let page: UiPage;
beforeEach(() => {
page = new UiPage();
});
it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
});
});
@@ -0,0 +1,11 @@
import {browser, element, by} from "protractor";
export class UiPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types":[
"jasmine",
"node"
]
}
}
@@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
@@ -0,0 +1,47 @@
{
"name": "ui",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"bootstrap": "^4.0.0-alpha.6",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
@@ -0,0 +1,30 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
@@ -0,0 +1,3 @@
.custom-close {
float:right;
}
@@ -0,0 +1,37 @@
<nav class="navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Book Rater <span *ngIf="principal.isAdmin()">Admin</span></a>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
</ul>
<button *ngIf="principal.authenticated" type="button" class="btn btn-link" (click)="onLogout()">Logout</button>
</div>
</nav>
<div class="jumbotron">
<div class="container">
<h1>Book Rater App</h1>
<p *ngIf="!principal.authenticated" class="lead">Anyone can view the books.</p>
<p *ngIf="principal.authenticated && !principal.isAdmin()" class="lead">Users can view and create ratings</p>
<p *ngIf="principal.isAdmin()" class="lead">Admins can do anything!</p>
</div>
</div>
<section class="books">
<div class="container">
<div class="row">
<div class="col-md">
<div class="row">
<div class="col-md-12">
<app-book-list [principal]="principal" (onBookSelected)="selectBook($event)"></app-book-list>
</div>
</div>
</div>
<div *ngIf="selectedBook != null" class="col-md-3">
<app-book-detail [selectedBook]="selectedBook" [principal]="principal" (closeBook)="closeBookDetail()"></app-book-detail>
</div>
</div>
</div>
</section>
@@ -0,0 +1,50 @@
import {Component} from "@angular/core";
import {Principal} from "./principal";
import {Response} from "@angular/http";
import {Book} from "./book";
import {HttpService} from "./http.service";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
selectedBook: Book = null;
principal: Principal = new Principal(false, []);
loginFailed: boolean = false;
constructor(private httpService: HttpService){}
ngOnInit(): void {
this.httpService.me()
.subscribe((response: Response) => {
let principalJson = response.json();
this.principal = new Principal(principalJson.authenticated, principalJson.authorities);
}, (error) => {
console.log(error);
});
}
onLogout() {
this.httpService.logout()
.subscribe((response: Response) => {
if (response.status === 200) {
this.loginFailed = false;
this.principal = new Principal(false, []);
window.location.replace(response.url);
}
}, (error) => {
console.log(error);
});
}
closeBookDetail() {
this.selectedBook = null;
}
selectBook(book: Book) {
this.selectedBook = book;
}
}
@@ -0,0 +1,28 @@
import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {AppComponent} from "./app.component";
import {RatingComponent} from "./rating/rating.component";
import {ClickStopPropagationDirective} from "./click-stop-propagation.directive";
import {BookDetailComponent} from "./book/book-detail/book-detail.component";
import {BookListComponent} from "./book/book-list/book-list.component";
import {HttpService} from "./http.service";
@NgModule({
declarations: [
AppComponent,
RatingComponent,
ClickStopPropagationDirective,
BookDetailComponent,
BookListComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [HttpService],
bootstrap: [AppComponent]
})
export class AppModule { }
@@ -0,0 +1,10 @@
export class Book {
id: number;
author: String;
title: String;
constructor(id: number, author: String, title: String){
this.id = id;
this.author = author;
this.title = title;
}
}
@@ -0,0 +1,11 @@
<div class="card">
<div class="card-block">
<button type="button" class="close" aria-label="Close" (click)="closeBookDetail()">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="card-title">Title: {{selectedBook.title}}</h4>
<h6 class="card-subtitle mb-2 text-muted">Author: {{selectedBook.author}}</h6>
<p class="card-text">A quick summary of the book</p>
<app-rating *ngIf="principal.authenticated" [bookId]="selectedBook.id" [principal]="principal"></app-rating>
</div>
</div>
@@ -0,0 +1,26 @@
import {Component, OnInit, Input, Output, EventEmitter} from "@angular/core";
import {Book} from "../../book";
import {Principal} from "../../principal";
@Component({
selector: 'app-book-detail',
templateUrl: './book-detail.component.html',
styleUrls: ['./book-detail.component.css']
})
export class BookDetailComponent implements OnInit {
@Input() selectedBook: Book = null;
@Input() principal: Principal = null;
@Output() closeBook: EventEmitter<any> = new EventEmitter<any>();
constructor() { }
ngOnInit() {
}
closeBookDetail() {
this.closeBook.emit(null);
}
}
@@ -0,0 +1,54 @@
<div class="col-md-12" *ngFor="let book of books; let i = index;" (click)="selectBook(book)">
<div class="card">
<div class="card-block">
<div *ngIf="booksToEdit.indexOf(i) === -1 ; then bookView else bookEdit"></div>
<ng-template #bookView>
<button appClickStopPropagation *ngIf="principal.isAdmin()" type="button" class="btn btn-danger custom-close" (click)="delete(i)">Delete</button>
<button appClickStopPropagation *ngIf="principal.isAdmin()" type="button" class="btn btn-warning custom-close" (click)="editBook(i)">Edit</button>
<h4 class="card-title">Title: {{book.title}}</h4>
<h6 class="card-subtitle mb-2 text-muted">Author: {{book.author}}</h6>
</ng-template>
<ng-template #bookEdit>
<button appClickStopPropagation type="button" class="btn btn-secondary custom-close" (click)="cancelEditBook(i)">Cancel</button>
<form appClickStopPropagation (ngSubmit)="saveBook(i, newBooks[i])" class="mt-2 mt-md-0" #f1="ngForm">
<div class="form-group">
<label for="title">Title:</label>
<input id="title" name="title" [(ngModel)]="newBooks[i].title" required class="form-control mr-sm-2" type="text">
</div>
<div class="form-group">
<label for="author">Author:</label>
<input id="author" name="author" [(ngModel)]="newBooks[i].author" required class="form-control mr-sm-2" type="text">
</div>
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" [disabled]="!f1.valid">Save</button>
</form>
</ng-template>
</div>
</div>
</div>
<div *ngIf="principal.isAdmin()" class="col-md-12">
<div class="card">
<div class="card-block">
<div *ngIf="!isAddNewBook; then bookPlaceHolder else bookAdd"></div>
<ng-template #bookPlaceHolder>
<h4 (click)="activateAddNewBook()" class="card-title center-block">Add New Book</h4>
</ng-template>
<ng-template #bookAdd>
<button appClickStopPropagation type="button" class="btn btn-secondary custom-close" (click)="cancelAddBook()">Cancel</button>
<form appClickStopPropagation (ngSubmit)="addNewBook(newBook, titleNewBook)" class="mt-2 mt-md-0" #f2="ngForm">
<div class="form-group">
<label for="titleNewBook">Title:</label>
<input id="titleNewBook" name="title" [(ngModel)]="newBook.title" required class="form-control mr-sm-2" type="text" #titleNewBook>
</div>
<div class="form-group">
<label for="authorNewBook">Author:</label>
<input id="authorNewBook" name="author" [(ngModel)]="newBook.author" required class="form-control mr-sm-2" type="text">
</div>
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" [disabled]="!f2.valid">Save</button>
</form>
</ng-template>
</div>
</div>
</div>
@@ -0,0 +1,122 @@
import {Component, OnInit, Input, Output, EventEmitter} from "@angular/core";
import {Principal} from "../../principal";
import {Book} from "../../book";
import {Response} from "@angular/http";
import {HttpService} from "../../http.service";
@Component({
selector: 'app-book-list',
templateUrl: './book-list.component.html',
styleUrls: ['./book-list.component.css']
})
export class BookListComponent implements OnInit {
@Input() principal: Principal = null;
@Output() onBookSelected: EventEmitter<Book> = new EventEmitter<Book>();
books: Book[] = [];
newBooks: Book[] = [];
newBook: Book = new Book(Math.floor(Math.random() * 1000), '', '');
booksToEdit: number[] = [];
isAddNewBook: boolean = false;
selectedBook: Book = null;
constructor(private httpService: HttpService) { }
ngOnInit() {
this.loadBooks();
}
loadBooks() {
this.httpService.getBooks()
.subscribe((response: Response) => {
let booksJson: any[] = response.json()
booksJson.forEach(book => {
this.books.push(new Book(book.id, book.author, book.title));
this.newBooks.push(new Book(book.id, book.author, book.title));
})
}, (error) => {
console.log(error);
});
}
cancelEditBook(bookIndex: number) {
if (this.booksToEdit.indexOf(bookIndex) !== -1) {
this.booksToEdit.splice(this.booksToEdit.indexOf(bookIndex), 1); //remove the index of the book to edit
//get the original book
let bookCopy: Book = new Book(this.books[bookIndex].id, this.books[bookIndex].author, this.books[bookIndex].title);
this.newBooks.splice(bookIndex,1,bookCopy); //replace the edited book with the old book
}
}
editBook(bookIndex: number) {
this.booksToEdit.push(bookIndex);
}
saveBook(bookIndex: number, newBook: Book) {
console.log(newBook);
//save the book to the database
this.httpService.updateBook(newBook)
.subscribe((response: Response) => {
let bookJson = response.json();
let book: Book = new Book(bookJson.id, bookJson.author, bookJson.title);
//update the current array of books
let bookArr: Book = this.books.find(b => b.id === book.id);
bookArr.title = book.title;
bookArr.author = book.author;
this.booksToEdit.splice(this.booksToEdit.indexOf(bookIndex), 1); //remove the index of the book to edit
}, (error) => {
console.log(error);
});
}
delete(bookIndex: number) {
let book: Book = this.books[bookIndex];
this.httpService.deleteBook(book)
.subscribe(() => {
if (this.selectedBook !== null && this.books[bookIndex].id === this.selectedBook.id) {
this.selectedBook = null;
this.onBookSelected.emit(this.selectedBook);
}
this.books.splice(bookIndex, 1); //remove the book at this index;
this.newBooks.splice(bookIndex, 1); //remove the editing book at this index
}, (error) => {
console.log(error);
});
}
activateAddNewBook() {
this.isAddNewBook = true;
this.newBook = new Book(null, '', '');
}
addNewBook(newBook: Book, element: any) {
//write new book to db
this.httpService.createBook(newBook)
.subscribe((response: Response) => {
let bookJson = response.json();
let book: Book = new Book(bookJson.id, bookJson.author, bookJson.title);
console.log(book);
this.books.push(book);
this.newBooks.push(book);
this.newBook = new Book(Math.floor(Math.random() * 1000), '', '');
element.focus();
}, (error) => {
console.log(error);
});
}
cancelAddBook() {
this.isAddNewBook = false;
}
selectBook(book: Book) {
this.selectedBook = book;
this.onBookSelected.emit(book);
}
}
@@ -0,0 +1,13 @@
import {Directive, HostListener} from "@angular/core";
@Directive({
selector: '[appClickStopPropagation]'
})
export class ClickStopPropagationDirective
{
@HostListener("click", ["$event"])
public onClick(event: any): void
{
event.stopPropagation();
}
}
@@ -0,0 +1,56 @@
import {Injectable} from "@angular/core";
import {Observable} from "rxjs";
import {Response, Http, Headers, RequestOptions} from "@angular/http";
import {Book} from "./book";
import {Rating} from "./rating";
@Injectable()
export class HttpService {
constructor(private http: Http) { }
me(): Observable<Response> {
return this.http.get("/me", this.makeOptions())
}
logout(): Observable<Response> {
return this.http.post("/logout", '', this.makeOptions())
}
getBooks(): Observable<Response> {
return this.http.get("/book-service/books", this.makeOptions())
}
updateBook(newBook: Book): Observable<Response> {
return this.http.put("/book-service/books/" + newBook.id, newBook, this.makeOptions())
}
deleteBook(book: Book): Observable<Response> {
return this.http.delete("/book-service/books/" + book.id, this.makeOptions())
}
createBook(newBook: Book): Observable<Response> {
return this.http.post("/book-service/books", newBook, this.makeOptions())
}
getRatings(bookId: number): Observable<Response> {
return this.http.get("/rating-service/ratings?bookId=" + bookId, this.makeOptions())
}
createRating(rating: Rating): Observable<Response> {
return this.http.post("/rating-service/ratings", rating, this.makeOptions())
}
deleteRating(ratingId: number) {
return this.http.delete("/rating-service/ratings/" + ratingId, this.makeOptions())
}
updateRating(rating: Rating) {
return this.http.put("/rating-service/ratings/" + rating.id, rating, this.makeOptions())
}
private makeOptions(): RequestOptions {
let headers = new Headers({'Content-Type': 'application/json'});
return new RequestOptions({headers: headers});
}
}
@@ -0,0 +1,21 @@
export class Principal {
public authenticated: boolean;
public authorities: Authority[] = [];
constructor(authenticated: boolean, authorities: any[]) {
this.authenticated = authenticated;
authorities.map(auth => this.authorities.push(new Authority(auth.authority)))
}
isAdmin() {
return this.authorities.some((auth: Authority) => auth.authority.indexOf('ADMIN') > -1)
}
}
export class Authority {
public authority: String;
constructor(authority: String) {
this.authority = authority;
}
}
@@ -0,0 +1,11 @@
export class Rating{
id: number;
bookId: number;
stars: number;
constructor(id: number, bookId: number, stars: number) {
this.id = id;
this.bookId = bookId;
this.stars = stars;
}
}
@@ -0,0 +1,11 @@
div.progress {
margin-top: 5px;
}
.rating:hover {
border: solid blue;
}
.selected {
border: solid blue;
}
@@ -0,0 +1,25 @@
Ratings:
<div *ngFor="let rating of ratings; let i = index;" class="row">
<div class="col-md-10">
<div class="progress" [ngClass]="{'selected': principal.isAdmin() && rating === newRating, 'rating': principal.isAdmin()}" (click)="selectRating(rating)">
<div class="progress-bar bg-success" role="progressbar" [style.width]="findWidth(rating)" [attr.aria-valuenow]="rating.stars" aria-valuemin="0" aria-valuemax="5"></div>
</div>
</div>
<div class="col-md-1">
<button *ngIf="principal?.isAdmin()" type="button" class="close" aria-label="Close" (click)="deleteRating(i)">
<span aria-hidden="true">&times;</span>
</button>
</div>
</div>
<form (ngSubmit)="onSaveRating(f)" #f="ngForm">
<div class="form-check form-check-inline" *ngFor="let star of stars; let i = index;">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="star" [(ngModel)]="newRating.stars" [value]="star">{{star}}
</label>
</div>
<button *ngIf="newRating.id === null" type="submit" class="btn btn-secondary" [disabled]="!f.valid">Add Rating</button>
<button *ngIf="principal.isAdmin() && newRating.id !== null" type="button" class="btn btn-secondary" (click)="updateRating()">Save</button>
<button *ngIf="principal.isAdmin() && newRating.id !== null" type="button" class="btn btn-secondary" (click)="cancelSelection()">Cancel</button>
</form>
@@ -0,0 +1,90 @@
import {Component, OnInit, Input, OnChanges} from "@angular/core";
import {Rating} from "../rating";
import {Principal} from "../principal";
import {HttpService} from "../http.service";
import {Response} from "@angular/http";
@Component({
selector: 'app-rating',
templateUrl: './rating.component.html',
styleUrls: ['./rating.component.css']
})
export class RatingComponent implements OnInit, OnChanges {
@Input() bookId: number;
@Input() principal: Principal = null;
ratings: Rating[] = [];
stars: number[] = [1,2,3,4,5];
newRating: Rating = null;
constructor(private httpService: HttpService) { }
ngOnInit() {}
ngOnChanges() {
this.newRating = new Rating(null, this.bookId, 1);
this.ratings = [];
this.loadRatings();
}
findWidth(rating: Rating): String {
let percent: number = (rating.stars/5)*100;
return percent.toString() + '%';
}
private loadRatings() {
this.httpService.getRatings(this.bookId)
.subscribe((response: Response) => {
let responseJson: any[] = response.json();
responseJson.forEach(rating => this.ratings.push(new Rating(rating.id, rating.bookId, rating.stars)))
}, (error) => {
console.log(error);
});
}
onSaveRating() {
console.log(this.newRating);
let ratingCopy: Rating = Object.assign({}, this.newRating);
this.httpService.createRating(ratingCopy)
.subscribe((response: Response) => {
let ratingJson = response.json()
this.ratings.push(new Rating(ratingJson.id, ratingJson.bookId, ratingJson.stars))
}, (error) => {
console.log(error);
});
}
updateRating() {
this.httpService.updateRating(this.newRating)
.subscribe(() => {
this.newRating = new Rating(null, this.bookId, 1);
}, (error) => {
console.log(error);
});
}
selectRating(rating: Rating) {
if (this.principal.isAdmin()) {
this.newRating = rating;
}
}
cancelSelection() {
this.newRating = new Rating(null, this.bookId, 1);
}
deleteRating(index: number) {
let rating = this.ratings[index];
this.httpService.deleteRating(rating.id)
.subscribe(() => {
if (this.ratings[index] === this.newRating) {
this.newRating = new Rating(null, this.bookId, 1);
}
this.ratings.splice(index, 1);
}, (error) => {
console.log(error);
});
}
}
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
@@ -0,0 +1,8 @@
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = {
production: false
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ui</title>
<base href="/home/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>
@@ -0,0 +1,10 @@
import {enableProdMode} from "@angular/core";
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app/app.module";
import {environment} from "./environments/environment";
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
@@ -0,0 +1,15 @@
import "core-js/es6/reflect";
import "core-js/es7/reflect";
import "zone.js/dist/zone";
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/**
* Date, currency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.
@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */
@@ -0,0 +1,27 @@
import "zone.js/dist/long-stack-trace-zone";
import "zone.js/dist/proxy.js";
import "zone.js/dist/sync-test";
import "zone.js/dist/jasmine-patch";
import "zone.js/dist/async-test";
import "zone.js/dist/fake-async-test";
import {getTestBed} from "@angular/core/testing";
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from "@angular/platform-browser-dynamic/testing";
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
declare var require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
@@ -0,0 +1,20 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"target": "es5",
"baseUrl": "",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
@@ -0,0 +1,5 @@
/* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule {
id: string;
}
@@ -0,0 +1,20 @@
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
@@ -0,0 +1,116 @@
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": true,
"import-blacklist": [true, "rxjs"],
"import-spacing": true,
"indent": [
true,
"spaces"
],
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [true, "ignore-params"],
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"directive-selector": [true, "attribute", "app", "camelCase"],
"component-selector": [true, "element", "app", "kebab-case"],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true
}
}