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

Fixed ng lint warnings #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 3 deletions src/app/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { catchError, tap, map } from 'rxjs/operators';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
const apiUrl = "/api";
const apiUrl = '/api';

@Injectable({
providedIn: 'root'
Expand All @@ -28,10 +28,10 @@ export class ApiService {
}
// return an observable with a user-facing error message
return throwError('Something bad happened; please try again later.');
};
}

private extractData(res: Response) {
let body = res;
const body = res;
return body || { };
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
MatIconModule,
MatButtonModule,
MatCardModule,
MatFormFieldModule } from "@angular/material";
MatFormFieldModule } from '@angular/material';

const appRoutes: Routes = [
{
Expand Down
16 changes: 8 additions & 8 deletions src/app/book-create/book-create.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Valida
export class BookCreateComponent implements OnInit {

bookForm: FormGroup;
isbn:string='';
title:string='';
description:string='';
author:string='';
publisher:string='';
published_year:string='';
isbn = '';
title = '';
description = '';
author = '';
publisher = '';
published_year = '';

constructor(private router: Router, private api: ApiService, private formBuilder: FormBuilder) { }

Expand All @@ -31,10 +31,10 @@ export class BookCreateComponent implements OnInit {
});
}

onFormSubmit(form:NgForm) {
onFormSubmit(form: NgForm) {
this.api.postBook(form)
.subscribe(res => {
let id = res['_id'];
const id = res['_id'];
this.router.navigate(['/book-details', id]);
}, (err) => {
console.log(err);
Expand Down
18 changes: 9 additions & 9 deletions src/app/book-edit/book-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Valida
export class BookEditComponent implements OnInit {

bookForm: FormGroup;
id:string = '';
isbn:string = '';
title:string = '';
description:string = '';
author:string = '';
publisher:string = '';
published_year:string = '';
id = '';
isbn = '';
title = '';
description = '';
author = '';
publisher = '';
published_year = '';

constructor(private router: Router, private route: ActivatedRoute, private api: ApiService, private formBuilder: FormBuilder) { }

Expand Down Expand Up @@ -47,10 +47,10 @@ export class BookEditComponent implements OnInit {
});
}

onFormSubmit(form:NgForm) {
onFormSubmit(form: NgForm) {
this.api.updateBook(this.id, form)
.subscribe(res => {
let id = res['_id'];
const id = res['_id'];
this.router.navigate(['/book-details', id]);
}, (err) => {
console.log(err);
Expand Down
28 changes: 14 additions & 14 deletions src/app/book/book.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ import { ApiService } from '../api.service';
import { DataSource } from '@angular/cdk/collections';
import { Observable } from 'rxjs';

export class BookDataSource extends DataSource<any> {
constructor(private api: ApiService) {
super();
}

connect() {
return this.api.getBooks();
}

disconnect() {

}
}

@Component({
selector: 'app-book',
templateUrl: './book.component.html',
Expand All @@ -26,17 +40,3 @@ export class BookComponent implements OnInit {
});
}
}

export class BookDataSource extends DataSource<any> {
constructor(private api: ApiService) {
super()
}

connect() {
return this.api.getBooks();
}

disconnect() {

}
}