-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
974c0c1
commit 1e577a7
Showing
28 changed files
with
505 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from "@ember/service"; | ||
import {action, set,get} from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
import { action, set, get } from '@ember/object'; | ||
|
||
export default class NavBarComponent extends Component { | ||
// @service data; | ||
@service userPreference; | ||
|
||
// get libraryReq(){ | ||
// return this.data.libraryReq; | ||
// } | ||
|
||
// get booksReq(){ | ||
// return this.data.booksReq; | ||
// } | ||
|
||
get theme(){ | ||
let t = this.userPreference.theme; | ||
|
||
// setting body colour | ||
let backgroundColour = t == 'dark' ? 'grey' : 'white'; | ||
let colour = t == 'dark' ? 'white' : 'black'; | ||
$('body').css('background-color', backgroundColour); | ||
$('body').css('color', colour); | ||
|
||
return t; | ||
} | ||
|
||
@action | ||
changeTheme(){ | ||
let t = this.theme == 'dark' ? 'light' : 'dark'; | ||
this.userPreference.setTheme(t); | ||
} | ||
|
||
// @action | ||
// changeColour(){ | ||
// let backgroundColour = this.theme == 'dark' ? 'grey' : 'white'; | ||
// let colour = this.theme == 'dark' ? 'white' : 'black'; | ||
// $('body').css('background-color', backgroundColour); | ||
// $('body').css('color', colour); | ||
// } | ||
|
||
@service data; | ||
@service userPreference; | ||
|
||
get libraryReq() { | ||
return this.data.libraryReq; | ||
} | ||
|
||
get booksReq() { | ||
return this.data.booksReq; | ||
} | ||
|
||
get theme() { | ||
let t = this.userPreference.theme; | ||
|
||
// setting body colour | ||
let backgroundColour = t == 'dark' ? 'grey' : 'white'; | ||
let colour = t == 'dark' ? 'white' : 'black'; | ||
$('body').css('background-color', backgroundColour); | ||
$('body').css('color', colour); | ||
|
||
return t; | ||
} | ||
|
||
@action | ||
changeTheme() { | ||
let t = this.theme == 'dark' ? 'light' : 'dark'; | ||
this.userPreference.setTheme(t); | ||
} | ||
|
||
// @action | ||
// changeColour(){ | ||
// let backgroundColour = this.theme == 'dark' ? 'grey' : 'white'; | ||
// let colour = this.theme == 'dark' ? 'white' : 'black'; | ||
// $('body').css('background-color', backgroundColour); | ||
// $('body').css('color', colour); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import Route from '@ember/routing/route'; | ||
import {inject as service} from '@ember/service'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class ApplicationRoute extends Route { | ||
@service router; | ||
beforeModel(transition){ | ||
// console.log(transition.to.name); | ||
if(transition.to.name==='index'){ | ||
this.router.transitionTo('home'); | ||
} | ||
@service router; | ||
beforeModel(transition) { | ||
// console.log(transition.to.name); | ||
if (transition.to.name === 'index') { | ||
this.router.transitionTo('home'); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import Route from '@ember/routing/route'; | ||
import {action} from '@ember/object'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class LatestBooksRoute extends Route { | ||
@action | ||
loading(transition){ | ||
console.log("loading"); | ||
return true; | ||
} | ||
@action | ||
loading(transition) { | ||
console.log('loading'); | ||
return true; | ||
} | ||
|
||
@action | ||
error(){ | ||
console.log("error"); | ||
return true; | ||
} | ||
@action | ||
error() { | ||
console.log('error'); | ||
return true; | ||
} | ||
|
||
model() { | ||
return fetch('https://www.googleapis.com/books/v1/volumes?q=publishedDate:2013&maxResults=8') | ||
.then(response => response.json()) | ||
.then(data => { | ||
return data.items; | ||
}) | ||
// let data=await fetch('https://www.googleapis.com/books/v1/volumes?q=publishedDate:2013&maxResults=8') | ||
// .then(response => response.json()) | ||
// .then(data => { | ||
// return data.items; | ||
// }) | ||
// return data; | ||
} | ||
model() { | ||
return fetch( | ||
'https://www.googleapis.com/books/v1/volumes?q=publishedDate:2013&maxResults=8', | ||
) | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
return data.items; | ||
}); | ||
// let data=await fetch('https://www.googleapis.com/books/v1/volumes?q=publishedDate:2013&maxResults=8') | ||
// .then(response => response.json()) | ||
// .then(data => { | ||
// return data.items; | ||
// }) | ||
// return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class LibraryRoute extends Route { | ||
|
||
} | ||
export default class LibraryRoute extends Route {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from "@ember/service"; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class LibraryDetailsRoute extends Route { | ||
// @service('LibraryData') library; | ||
// @service data; | ||
@service router; | ||
@service data; | ||
@service router; | ||
|
||
model({ library_id }) { | ||
// let url = "library/" + library_id; | ||
// let lib = this.data.getData(url); | ||
model({ library_id }) { | ||
let url = '/libraries/' + library_id; | ||
let lib = this.data.getData(url); | ||
|
||
// this.library.data.forEach(element => { | ||
// if (element.id == library_id) { | ||
// lib = element; | ||
// return; | ||
// } | ||
// }); | ||
|
||
let lib = fetch(`/libraries/${library_id}`).then((response)=>response.json()).then((r)=> r.data) | ||
|
||
if (!lib) { | ||
this.router.transitionTo('not-found', "notFound"); | ||
} | ||
return lib; | ||
if (!lib) { | ||
this.router.transitionTo('not-found', 'notFound'); | ||
} | ||
return lib; | ||
} | ||
} | ||
|
||
// this.library.data.forEach(element => { | ||
// if (element.id == library_id) { | ||
// lib = element; | ||
// return; | ||
// } | ||
// }); | ||
|
||
// let lib = fetch(`/libraries/${library_id}`).then((response)=>response.json()).then((r)=> r.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class LibraryDetailsBooksRoute extends Route { | ||
} | ||
export default class LibraryDetailsBooksRoute extends Route {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from "@ember/service"; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class LibraryDetailsBooksBookRoute extends Route { | ||
@service router; | ||
// @service data; | ||
@service router; | ||
@service data; | ||
|
||
async model({ book_id }) { | ||
// let library_id = this.paramsFor('library.details').library_id; | ||
// let url = `library/${library_id}/books/${book_id}`; | ||
// let book = this.data.getData(url); | ||
|
||
// library.books.forEach(element => { | ||
// if (element.id == book_id) { | ||
// book = element; | ||
// return | ||
// } | ||
// }); | ||
let book = await fetch(`/books/${book_id}`).then((response) => response.json()).then((r) => r.data); | ||
|
||
if (!book) { | ||
this.router.transitionTo('not-found', "notfound"); | ||
} | ||
return book; | ||
async model({ book_id }) { | ||
let library_id = this.paramsFor('library.details').library_id; | ||
let url = `/libraries/${library_id}/books/${book_id}`; | ||
let book = await this.data.getData(url); | ||
if (!book) { | ||
this.router.transitionTo('not-found', 'notfound'); | ||
} | ||
return book; | ||
} | ||
} | ||
|
||
// library.books.forEach(element => { | ||
// if (element.id == book_id) { | ||
// book = element; | ||
// return | ||
// } | ||
// }); | ||
// let book = await fetch(`/books/${book_id}`).then((response) => response.json()).then((r) => r.data); |
Oops, something went wrong.